New to Nix OS only bashed my keyboard twice today, so thats good.
I’m looking to import two .nix files, one of which starts a number of docker containers and has the line services.docker.enable = true;
I’m importing the the file but I don’t believe its being executed. it builds but I cant do docker
it says command not found.
how I can get it so all the .nix files in myModules and ./containers/containers.nix are actually run and executed? Id rather not list all of these twice in the code. Also any general comments on my design would be greatly appreciated. I dont have nixos or linux friends so im approaching all of this stuff on my own (well with chat gpt but they freaking suck at nix os ).
flake.nix
{
description = "Nixos config flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, ... }@inputs: {
# modules
myModules = {
vscodeServer = import ./modules/vscode-server.nix;
};
# docker containers
myContainers = import ./containers/containers.nix;
# NixOS configuration entrypoint
nixosConfigurations.hostname = nixpkgs.lib.nixosSystem {
specialArgs = {inherit inputs;};
modules = [
./configuration.nix
inputs.home-manager.nixosModules.default
];
};
## home-manager modules
#homeManagerModules = import ./modules/home-manager;
## Standalone home-manager configuration entrypoint
#homeConfigurations = {
# "username@hostname" = home-manager.lib.homeManagerConfiguration {
# pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
# extraSpecialArgs = {inherit inputs outputs;};
# modules = [
# ./home.nix
# ];
# };
#};
};
}
Docker nix file
{ config, pkgs, ... }:
let
composeFiles = [
"./docker-mgmt.yml"
# "./pihole.yml"
# "./media.yml"
];
composeServices = builtins.map (file: {
name = file;
value = "${pkgs.docker-compose}/bin/docker-compose -f ${./docker-compose}/${file} up -d";
}) composeFiles;
in
{
services.docker.enable = true;
systemd.services = builtins.listToAttrs composeServices;
}