about summary refs log tree commit diff
path: root/machines/default.nix
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2015-06-29 18:24:45 +0200
committeraszlig <aszlig@redmoonstudios.org>2015-06-29 18:33:15 +0200
commitd179c1337089f8a62482f5d2916037652ec226de (patch)
tree039e5c4d91aee04c3c35ce30a6b45c9687830646 /machines/default.nix
parent18e5d2918bcce3d2028a5914ca9cae6b363a9cd2 (diff)
machines: Properly override ISO configuration.
We now do it the exact opposite way than introduced in 27dce7b. Instead
of evaluating the machine config and stripping off the options we don't
want to conflict with the iso-image.nix module, we now wrap the
iso-image.nix module itself and just mkForce the values we don't want to
collide.

The reason for this is that the previous implementation just didn't work
because dependent module options from the machine config (for example
config.system.build.*) were already evaluated and thus we end up with
overriding configuration options but get an initrd with the machine
options (which we actually want to override) instead of the
fileSystem/boot options that come with the iso-image.nix module.

Although I'm not quite happy with this approach, it's still better than
the old one and if iso-image.nix gets conflicting options we at least
get a better error message rather than the definitions simply being
stripped off.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'machines/default.nix')
-rw-r--r--machines/default.nix28
1 files changed, 19 insertions, 9 deletions
diff --git a/machines/default.nix b/machines/default.nix
index 0be491ef..54b70321 100644
--- a/machines/default.nix
+++ b/machines/default.nix
@@ -9,17 +9,27 @@ let
       inherit system;
       modules = [ config ] ++ import ../modules/module-list.nix;
     };
-    iso = import "${nixpkgs}/nixos/lib/eval-config.nix" {
+    iso = let
+      isoModule = "${nixpkgs}/nixos/modules/installer/cd-dvd/iso-image.nix";
+      wrapIso = { config, pkgs, lib, ... }@attrs: let
+        eval = (import isoModule attrs);
+        evalcfg = eval.config or {};
+        bootcfg = evalcfg.boot or {};
+        fscfg = evalcfg.fileSystems or {};
+      in {
+        options = eval.options or {};
+        imports = eval.imports or [];
+        config = evalcfg // {
+          boot = bootcfg // lib.optionalAttrs (bootcfg ? loader) {
+            loader = lib.mkForce bootcfg.loader;
+          };
+          fileSystems = lib.mapAttrs (lib.const lib.mkForce) fscfg;
+        };
+      };
+    in import "${nixpkgs}/nixos/lib/eval-config.nix" {
       inherit system;
       modules = [
-        { options = { inherit (build.options) vuizvui; };
-          config = (builtins.removeAttrs build.config [
-            "_module" "boot" "fileSystems"
-          ]) // {
-            boot = builtins.removeAttrs build.config.boot [ "loader" ];
-          };
-        }
-        "${nixpkgs}/nixos/modules/installer/cd-dvd/iso-image.nix"
+        use wrapIso
         (
           { lib, ... }: let
             name = build.config.networking.hostName;