From 561db6136f904c0d9ed307f52c64859fbc53cfc6 Mon Sep 17 00:00:00 2001 From: Tobias Stenzel Date: Fri, 8 Sep 2023 12:08:31 +0200 Subject: [PATCH] Fix packing nixexprs in release job, better compression upstream introduced a test which tests behaviour with broken symlinks, related to RFC 140. Our combined sources for the release tarball contain symlinks to the various inputs (nixpkgs, fc, nixos-mailserver) which have to be dereferenced by tar, thus using the -h option. This causes tar to fail on the test symlink which points to nothing. We use tar now without dereferencing which makes it a bit more complicated to get the desired archive structure. This change also modifies xz compression settings to reduce file size and decompression time. xz now uses the default of -6 with additional "extreme" tuning which reduces size even further without increasing decompression time. We now also use all available cores for compression. --- release/default.nix | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/release/default.nix b/release/default.nix index 2e958baa2..05200aecb 100644 --- a/release/default.nix +++ b/release/default.nix @@ -333,17 +333,30 @@ jobs // { patchPhase = "touch .update-on-nixos-rebuild"; - XZ_OPT = "-1"; tarOpts = '' - --owner=0 --group=0 --mtime="1970-01-01 00:00:00 UTC" \ + --owner=0 --group=0 \ + --mtime="1970-01-01 00:00:00 UTC" \ --exclude-vcs-ignores \ - --transform='s!^\.!${name}!' \ ''; installPhase = '' mkdir -p $out/{tarballs,nix-support} - cd nixos - tar cJhf $out/tarballs/nixexprs.tar.xz ${tarOpts} . + tarball=$out/tarballs/nixexprs.tar + + # Add all files in nixos/ including hidden ones. + # (-maxdepth 1: don't recurse into subdirs) + find nixos/ -maxdepth 1 -type f -exec \ + tar uf "$tarball" --transform "s|^nixos|${name}|" ${tarOpts} {} \; + + # Add files from linked subdirectories. We want to keep the name of the + # link in the archive, not the target. Example: + # "nixos/fc/default.nix" becomes "release-23.05.2222.12abcdef/fc/default.nix" + for d in nixos/*/; do + tar uf "$tarball" --transform "s|^$d\\.|${name}/$(basename "$d")|" ${tarOpts} "$d." + done + + # Compress using multiple cores and with "extreme settings" to reduce compressed size. + xz -T0 -e "$tarball" echo "channel - $out/tarballs/nixexprs.tar.xz" > "$out/nix-support/hydra-build-products" echo $constituents > "$out/nix-support/hydra-aggregate-constituents"