about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authortalyz <kim.lindberger@gmail.com>2021-10-05 20:56:25 +0200
committerYuka <yuka@yuka.dev>2021-10-28 12:55:01 +0200
commit87d8eec0691caf16b924ad7401a29e2783b12896 (patch)
tree7a0659d696e6af930c7097e6907e45c26ef4c286 /nixos
parent398a73ac980f2e89981d8d704d7e800bb7a9bfaf (diff)
downloadnixlib-87d8eec0691caf16b924ad7401a29e2783b12896.tar
nixlib-87d8eec0691caf16b924ad7401a29e2783b12896.tar.gz
nixlib-87d8eec0691caf16b924ad7401a29e2783b12896.tar.bz2
nixlib-87d8eec0691caf16b924ad7401a29e2783b12896.tar.lz
nixlib-87d8eec0691caf16b924ad7401a29e2783b12896.tar.xz
nixlib-87d8eec0691caf16b924ad7401a29e2783b12896.tar.zst
nixlib-87d8eec0691caf16b924ad7401a29e2783b12896.zip
make-disk-image: Add additionalPaths argument
Add an argument which makes it possible to add additional paths to the
image's nix store.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/lib/make-disk-image.nix14
1 files changed, 13 insertions, 1 deletions
diff --git a/nixos/lib/make-disk-image.nix b/nixos/lib/make-disk-image.nix
index d302fae430c1..9bbfc6c490e3 100644
--- a/nixos/lib/make-disk-image.nix
+++ b/nixos/lib/make-disk-image.nix
@@ -70,6 +70,9 @@
   # utils, but changes the hash of the image when the sources are
   # updated.
   copyChannel ? true
+
+, # Additional store paths to copy to the image's store.
+  additionalPaths ? []
 }:
 
 assert partitionTableType == "legacy" || partitionTableType == "legacy+gpt" || partitionTableType == "efi" || partitionTableType == "hybrid" || partitionTableType == "none";
@@ -172,8 +175,13 @@ let format' = format; in let
   users   = map (x: x.user  or "''") contents;
   groups  = map (x: x.group or "''") contents;
 
+  basePaths = [ config.system.build.toplevel ]
+    ++ lib.optional copyChannel channelSources;
+
+  additionalPaths' = subtractLists basePaths additionalPaths;
+
   closureInfo = pkgs.closureInfo {
-    rootPaths = [ config.system.build.toplevel ] ++ (lib.optional copyChannel channelSources);
+    rootPaths = basePaths ++ additionalPaths';
   };
 
   blockSize = toString (4 * 1024); # ext4fs block size (not block device sector size)
@@ -266,6 +274,10 @@ let format' = format; in let
       ${if copyChannel then "--channel ${channelSources}" else "--no-channel-copy"} \
       --substituters ""
 
+    ${optionalString (additionalPaths' != []) ''
+      nix copy --to $root --no-check-sigs ${concatStringsSep " " additionalPaths'}
+    ''}
+
     diskImage=nixos.raw
 
     ${if diskSize == "auto" then ''