Skip to content

Commit

Permalink
Fix packing nixexprs in release job, better compression
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dpausp committed Sep 13, 2023
1 parent 0c21a8f commit 561db61
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions release/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 561db61

Please sign in to comment.