File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3838 inherit revstring diskName ;
3939 } ;
4040
41- disk-script-fn =
42- { moduleIds ? null
43- ,
44- } :
45- pkgs . callPackage ./disk-script {
46- bundle = bundle-fn { inherit moduleIds ; } ;
47- } ;
48-
4941in
5042rec {
5143 default = moduleit ;
@@ -66,11 +58,15 @@ rec {
6658 # For prod use: builds the Nixmodules disk image
6759 bundle-image-tarball = pkgs . callPackage ./bundle-image-tarball { inherit bundle-image revstring ; } ;
6860
69- disk-script-dev = disk-script-fn {
70- moduleIds = dev-module-ids ;
61+ disk-script = pkgs . callPackage ./ disk-script {
62+ bundle = bundle-fn { } ;
7163 } ;
7264
73- disk-script = disk-script-fn { } ;
65+ disk-script-dev = pkgs . callPackage ./disk-script-dev {
66+ bundle = bundle-fn {
67+ moduleIds = dev-module-ids ;
68+ } ;
69+ } ;
7470
7571 # For dev use: builds the shared Nixmodules disk
7672 bundle-squashfs = bundle-squashfs-fn {
Original file line number Diff line number Diff line change 1+ { writeShellApplication
2+ , bundle
3+ , squashfsTools
4+ , coreutils
5+ , findutils
6+ , closureInfo
7+ ,
8+ } :
9+
10+ let
11+ diskClosureInfo = closureInfo { rootPaths = [ bundle ] ; } ;
12+ in
13+ writeShellApplication {
14+ name = "disk-script" ;
15+ runtimeInputs = [
16+ coreutils
17+ findutils
18+ squashfsTools
19+ ] ;
20+ text = ''
21+ set -x
22+ TMP_DIR=$(mktemp -d)
23+
24+ cd "$TMP_DIR"
25+
26+ root="$TMP_DIR/root"
27+ diskImage="$TMP_DIR/disk.sqsh"
28+
29+ (
30+ mkdir -p "$root/nix/store" "$root/etc/nixmodules"
31+
32+ cp --archive --reflink=auto "${ bundle } /etc/nixmodules/"* "$root/etc/nixmodules"
33+
34+ SECONDS=0
35+ xargs -P "$(nproc)" cp -a --reflink=auto -t "$root/nix/store/" < "${ diskClosureInfo } /store-paths"
36+ echo "xargs copy took $SECONDS seconds" >&2
37+
38+ echo "making squashfs..."
39+ SECONDS=0
40+ mksquashfs "$root" "$diskImage" -force-uid 11000 -force-gid 11000 -comp lz4 -b 1M
41+ echo "mksquashfs took $SECONDS seconds" >&2
42+
43+ ) 1>&2
44+
45+ echo "$diskImage"
46+ '' ;
47+ }
Original file line number Diff line number Diff line change @@ -30,7 +30,8 @@ writeShellApplication {
3030 cd "$TMP_DIR"
3131
3232 root="$TMP_DIR/root"
33- diskImage="$TMP_DIR/disk.sqsh"
33+ # gcp requires that disks end in "disk.raw"
34+ diskImage="$TMP_DIR/disk.raw"
3435 tarball="$TMP_DIR/disk.sqsh.tar.gz"
3536
3637 (
@@ -48,7 +49,7 @@ writeShellApplication {
4849 echo "mksquashfs took $SECONDS seconds" >&2
4950
5051 SECONDS=0
51- tar --use-compress-program="pigz --best --recursive | pv" -Scf "$tarball" disk.sqsh
52+ tar --use-compress-program="pigz --best --recursive | pv" -Scf "$tarball" "$diskImage"
5253 echo "tar took $SECONDS seconds" >&2
5354
5455 echo Tarball created at "$tarball" >&2
You can’t perform that action at this time.
0 commit comments