feat: function to create nixosSystem complete
This commit is contained in:
parent
749aaf258e
commit
8ef0e1e3d6
1 changed files with 29 additions and 9 deletions
38
flake.nix
38
flake.nix
|
@ -13,18 +13,38 @@
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, deploy-rs, ... }: {
|
outputs = { self, nixpkgs, deploy-rs, ... }: let
|
||||||
nixosConfigurations.some-random-system = nixpkgs.lib.nixosSystem {
|
|
||||||
system = "x86_64-linux";
|
|
||||||
modules = [
|
|
||||||
./machines/base.nix
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
deploy.nodes.some-random-system = {
|
|
||||||
|
machine_config = [
|
||||||
|
# each system one line
|
||||||
|
{
|
||||||
|
name = "test01";
|
||||||
|
system = "x86_64-linux";
|
||||||
|
modules = [
|
||||||
|
./machines/base.nix
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
# the best part, nix is functional, so lets have some functions
|
||||||
|
|
||||||
|
# map applies this function to every item in an array
|
||||||
|
create_nixosConfigurations = map (
|
||||||
|
# converts it into {name_of_machiene = {system = '..'; modules = '..'}}
|
||||||
|
config: {${config.name} = nixpkgs.lib.nixosSystem (nixpkgs.lib.attrsets.filterAttrs (n: v: n != "name") config); }
|
||||||
|
);
|
||||||
|
|
||||||
|
# this merges together an array of atributes
|
||||||
|
merge = nixpkgs.lib.lists.foldl (a: b: a // b) {};
|
||||||
|
|
||||||
|
in {
|
||||||
|
nixosConfigurations = merge (create_nixosConfigurations machine_config);
|
||||||
|
|
||||||
|
deploy.nodes.some-random-system2 = {
|
||||||
hostname = "test01.home.brendan.ie";
|
hostname = "test01.home.brendan.ie";
|
||||||
profiles.system = {
|
profiles.system = {
|
||||||
path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.some-random-system;
|
path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.test01;
|
||||||
sshUser = "root";
|
sshUser = "root";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue