about summary refs log tree commit diff
path: root/machines/default.nix
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2015-06-27 17:22:18 +0200
committeraszlig <aszlig@redmoonstudios.org>2015-06-27 17:45:56 +0200
commit27dce7bc3400bbe4d97ee8bd3f841df2cb179f60 (patch)
tree4c8bfffc215a4f26d14cb7bf708815a5680066de /machines/default.nix
parente4dcd8a9bb46879df76594d095847b95299ed517 (diff)
machines: Allow to easily build ISO images.
I know it's a somewhat hacky approach to strip off "_module",
"boot.loader" and "fileSystems" from the machine config, but that should
be the options which are to be set by iso-image.nix but that way we can
re-use the upstream module.

Also, if one of our modules sets an option without a proper "vuizvui."
namespace, we get an error as well. But it's our policy anyway to always
namespace with "vuizvui." so it's even good to get an error here.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'machines/default.nix')
-rw-r--r--machines/default.nix28
1 files changed, 27 insertions, 1 deletions
diff --git a/machines/default.nix b/machines/default.nix
index 84d70423..fe293692 100644
--- a/machines/default.nix
+++ b/machines/default.nix
@@ -1,12 +1,38 @@
 { system ? builtins.currentSystem, ... }:
 
 let
+  nixpkgs = import ../nixpkgs-path.nix;
+
   callMachine = path: rec {
     config = import path;
-    build = import "${import ../nixpkgs-path.nix}/nixos/lib/eval-config.nix" {
+    build = import "${nixpkgs}/nixos/lib/eval-config.nix" {
       inherit system;
       modules = [ config ] ++ import ../modules/module-list.nix;
     };
+    iso = 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"
+        (
+          { lib, ... }: let
+            name = build.config.networking.hostName;
+            upperName = lib.toUpper name;
+          in rec {
+            isoImage.isoName = "${name}.iso";
+            isoImage.volumeID = builtins.substring 0 11 "${upperName}_LIVE";
+            isoImage.makeEfiBootable = true;
+            isoImage.makeUsbBootable = true;
+          }
+        )
+      ];
+    };
     use = {
       imports = [ config ] ++ import ../modules/module-list.nix;
     };