{ description = "Deployment for skynet"; inputs = { # gonna start off with a fairly modern base nixpkgs.url = "nixpkgs/nixos-22.11"; # utility stuff flake-utils.url = "github:numtide/flake-utils"; agenix.url = "github:ryantm/agenix"; deploy-rs.url = "github:serokell/deploy-rs"; }; outputs = { self, nixpkgs, deploy-rs, ... }: let 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: { # need to extract teh name of the machiene ${config.name} = ( # nixpkgs.lib.nixosSystem is a fucntion that is used to turn a attribute set into the config for a machiene nixpkgs.lib.nixosSystem { system = config.system; modules = config.modules; } ); } ); # 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"; profiles.system = { path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.test01; sshUser = "root"; }; }; # This is highly advised, and will prevent many possible mistakes checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib; }; }