diff options
author | talyz <kim.lindberger@gmail.com> | 2021-10-05 19:08:57 +0200 |
---|---|---|
committer | Yuka <yuka@yuka.dev> | 2021-10-28 12:55:01 +0200 |
commit | 398a73ac980f2e89981d8d704d7e800bb7a9bfaf (patch) | |
tree | da8ab9aa56b9d6c66eb4ba86e394afa63add7fc7 /nixos/lib | |
parent | 56c5efa25b51e4a1b8452ef2adb18d96dadfb323 (diff) |
make-disk-image: Add copyChannel argument
Add a copyChannel argument which controls whether the current source tree will be made available as a nix channel in the image or not. Previously, it always was. Making it available is useful for interactive use of nix utils, but changes the hash of the image when the sources are updated.
Diffstat (limited to 'nixos/lib')
-rw-r--r-- | nixos/lib/make-disk-image.nix | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/nixos/lib/make-disk-image.nix b/nixos/lib/make-disk-image.nix index 63dd5594af301..d302fae430c1f 100644 --- a/nixos/lib/make-disk-image.nix +++ b/nixos/lib/make-disk-image.nix @@ -64,6 +64,12 @@ , # Disk image format, one of qcow2, qcow2-compressed, vdi, vpc, raw. format ? "raw" + +, # Whether a nix channel based on the current source tree should be + # made available inside the image. Useful for interactive use of nix + # utils, but changes the hash of the image when the sources are + # updated. + copyChannel ? true }: assert partitionTableType == "legacy" || partitionTableType == "legacy+gpt" || partitionTableType == "efi" || partitionTableType == "hybrid" || partitionTableType == "none"; @@ -166,7 +172,9 @@ let format' = format; in let users = map (x: x.user or "''") contents; groups = map (x: x.group or "''") contents; - closureInfo = pkgs.closureInfo { rootPaths = [ config.system.build.toplevel channelSources ]; }; + closureInfo = pkgs.closureInfo { + rootPaths = [ config.system.build.toplevel ] ++ (lib.optional copyChannel channelSources); + }; blockSize = toString (4 * 1024); # ext4fs block size (not block device sector size) @@ -254,7 +262,9 @@ let format' = format; in let chmod 755 "$TMPDIR" echo "running nixos-install..." nixos-install --root $root --no-bootloader --no-root-passwd \ - --system ${config.system.build.toplevel} --channel ${channelSources} --substituters "" + --system ${config.system.build.toplevel} \ + ${if copyChannel then "--channel ${channelSources}" else "--no-channel-copy"} \ + --substituters "" diskImage=nixos.raw |