diff options
author | sefidel <contact@sefidel.net> | 2024-02-11 02:11:21 +0900 |
---|---|---|
committer | sefidel <contact@sefidel.net> | 2024-02-11 02:15:33 +0900 |
commit | f4d8ab880a58e00af5a7fcda112baa7de2f8f0df (patch) | |
tree | a93467f9cdae84f38e00c95a62464709fa222b82 /lib | |
parent | 955671dc0751f320d22ca5cfd2b0a2eb60dd8a99 (diff) | |
download | infra-f4d8ab880a58e00af5a7fcda112baa7de2f8f0df.tar.gz infra-f4d8ab880a58e00af5a7fcda112baa7de2f8f0df.zip |
feat(project)!: support nixos-rebuild and hydra
Diffstat (limited to 'lib')
-rw-r--r-- | lib/system.nix | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/lib/system.nix b/lib/system.nix index 8fc4dce..e1709e3 100644 --- a/lib/system.nix +++ b/lib/system.nix @@ -1,22 +1,47 @@ -{ self, inputs, lib, pkgs, ... }: +{ self, inputs, lib, pkgs, ... } @ args: with lib; with lib.my; { - mkSystem = path: attrs @ { ... }: { - imports = [ + mkSystem = { hostPath, nixpkgs ? inputs.unstable, system ? "x86_64-linux", overlays ? null, extraModules ? null }: + nixpkgs.lib.nixosSystem ( { - networking.hostName = mkDefault - (removeSuffix ".nix" (baseNameOf path)); - system.configurationRevision = self.rev or "dirty"; + system = system; + + specialArgs = args; + + modules = [ + { + networking.hostName = mkDefault (removeSuffix ".nix" (baseNameOf hostPath)); + nix.flakes.enable = true; + system.configurationRevision = self.rev or "dirty"; + documentation.man = { enable = true; generateCaches = true; }; + } + (import hostPath) + ] ++ mapModulesRec' ../modules import + ++ nixpkgs.lib.optional (overlays != null) { nixpkgs.overlays = overlays; } + ++ nixpkgs.lib.optionals (extraModules != null) extraModules; + + # let deployment options to be set without breaking eval on nixosConfigurations + extraModules = [ inputs.colmena.nixosModules.deploymentOptions ]; } - ../. # /default.nix - (import path) - ]; - }; + ); mapSystems = dir: attrs @ { system ? system, ... }: mapModules dir - (hostPath: mkSystem hostPath attrs); + (hostPath: mkSystem { inherit hostPath; }); + + mkColmenaFromNixOSConfigurations = conf: + { + meta = { + # Colmena requirement. Will be overridden in nodeNixpkgs. + nixpkgs = import inputs.unstable { system = "x86_64-linux"; }; + nodeNixpkgs = builtins.mapAttrs (_: value: value.pkgs) conf; + nodeSpecialArgs = builtins.mapAttrs (_: value: value._module.specialArgs) conf; + }; + } // builtins.mapAttrs (_: value: { imports = value._module.args.modules; }) conf; + + mkHydraFromNixOSConfigurations = conf: + mapAttrs' (name: value: { name = "nixos-${name}"; value = value.config.system.build.toplevel; }) conf; } |