Closed SolidRhino closed 4 months ago
So currently, the nixosConfigurations
block in flake.nix
just iterates over the system types and creates flake targets automatically. You could remove this in favor of your own, specific targets. Then create files in hosts/nixos
for each host.
Something like:
nixosConfigurations = {
host1 = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = inputs;
modules = [
disko.nixosModules.disko
home-manager.nixosModules.home-manager {
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.${user} = import ./modules/nixos/home-manager.nix;
};
}
./hosts/nixos/host-1.nix
];
};
host2 = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = inputs;
modules = [
disko.nixosModules.disko
home-manager.nixosModules.home-manager {
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.${user} = import ./modules/nixos/home-manager.nix;
};
}
./hosts/nixos/host-1.nix
];
};
# Add other hosts here in a similar manner
};
};
Then just check out the simple scripts to run build
and build-switch
. You'll see we just call a simple command nixos-rebuild switch
to switch to a new Nix generation.
https://github.com/dustinlyons/nixos-config/blob/main/apps/x86_64-linux/build-switch
Your command would look like:
/run/current-system/sw/bin/nixos-rebuild switch --flake .#host1
I want to add an extra NixOS config for my Raspberry Pi 4. How can I accomplish that?