make-disk-image: Add additionalPaths argument

Add an argument which makes it possible to add additional paths to the
image's nix store.
main
talyz 3 years ago committed by Yuka
parent 398a73ac98
commit 87d8eec069
  1. 14
      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 ''

Loading…
Cancel
Save