From bd9878f82a478ec2dc5beeffee5031acb9dff7ed Mon Sep 17 00:00:00 2001 From: Timothy DeHerrera Date: Wed, 3 Feb 2021 16:41:21 -0700 Subject: [PATCH] ci: move into build attribute --- hosts/ci.nix | 11 ----------- hosts/default.nix | 6 +++++- lib/default.nix | 24 +++++++++++++++++++++++- nix/ci.nix | 2 +- 4 files changed, 29 insertions(+), 14 deletions(-) delete mode 100644 hosts/ci.nix diff --git a/hosts/ci.nix b/hosts/ci.nix deleted file mode 100644 index 90d28af0..00000000 --- a/hosts/ci.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ suites, ... }: -{ - imports = with suites; allProfiles ++ allUsers; - - security.mitigations.acceptRisk = true; - - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - - fileSystems."/" = { device = "/dev/disk/by-label/nixos"; }; -} diff --git a/hosts/default.nix b/hosts/default.nix index 7baf62ed..221c6e1a 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -63,7 +63,11 @@ let system.configurationRevision = lib.mkIf (self ? rev) self.rev; }; - local = import "${toString ./.}/${hostName}.nix"; + local = { + require = [ + (import "${toString ./.}/${hostName}.nix") + ]; + }; # Everything in `./modules/list.nix`. flakeModules = diff --git a/lib/default.nix b/lib/default.nix index bd39e615..daf83f4d 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,7 +1,7 @@ { nixos, ... }: let inherit (builtins) attrNames attrValues isAttrs readDir listToAttrs mapAttrs - pathExists; + pathExists filter; inherit (nixos.lib) fold filterAttrs hasSuffix mapAttrs' nameValuePair removeSuffix recursiveUpdate genAttrs nixosSystem mkForce; @@ -76,6 +76,27 @@ in let modpath = "nixos/modules"; cd = "installer/cd-dvd/installation-cd-minimal-new-kernel.nix"; + ciConfig = + (nixosSystem (args // { + modules = + let + # remove host module + modules' = filter (x: ! x ? require) modules; + in + modules' ++ [ + ({ suites, ... }: { + imports = with suites; + allProfiles ++ allUsers; + security.mitigations.acceptRisk = true; + + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + fileSystems."/" = { device = "/dev/disk/by-label/nixos"; }; + }) + ]; + })).config; + isoConfig = (nixosSystem (args // { modules = modules ++ [ @@ -94,6 +115,7 @@ in modules ++ [{ system.build = { iso = isoConfig.system.build.isoImage; + ci = ciConfig.system.build.toplevel; }; }]; }); diff --git a/nix/ci.nix b/nix/ci.nix index 6b046c87..d8219a66 100644 --- a/nix/ci.nix +++ b/nix/ci.nix @@ -11,7 +11,7 @@ let }; ci = recurseIntoAttrs { - nixos = default.nixosConfigurations.ci.config.system.build.toplevel; + nixos = default.nixosConfigurations.NixOS.config.system.build.ci; }; in {