feat: function to create nixosSystem complete

This commit is contained in:
silver 2023-01-12 23:58:35 +00:00
parent 749aaf258e
commit 8ef0e1e3d6

View file

@ -13,18 +13,38 @@
}; };
outputs = { self, nixpkgs, deploy-rs, ... }: { outputs = { self, nixpkgs, deploy-rs, ... }: let
nixosConfigurations.some-random-system = nixpkgs.lib.nixosSystem {
machine_config = [
# each system one line
{
name = "test01";
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ modules = [
./machines/base.nix ./machines/base.nix
]; ];
}; }
];
deploy.nodes.some-random-system = { # 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";
}; };
}; };