New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make-system-tarball: allow alternate compression methods #37288
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the options for building release tarballs. I built locally since I'm not sure if borg can handle arguments and everything worked as expected.
nixos/lib/make-system-tarball.sh
Outdated
@@ -54,8 +53,8 @@ mkdir -p $out/tarball | |||
|
|||
rm env-vars | |||
|
|||
tar --sort=name --mtime='@1' --owner=0 --group=0 --numeric-owner -cvJf $out/tarball/$fileName.tar.xz * $extraArgs | |||
time tar --sort=name --mtime='@1' --owner=0 --group=0 --numeric-owner -c * $extraArgs | $compression $compressorFlags > $out/tarball/$fileName.tar.${extension} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you intend to leave time in here or was it just for testing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a bit of both, with the -v
gone its a bit too silent, and it could be handy to know how long just the compression phase took, since half the time is taken up by a cp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it! Maybe a no-compression option would be nice too.
nixos/lib/make-system-tarball.nix
Outdated
gzip = gzip; | ||
pigz = pigz; | ||
bzip2 = bzip2; | ||
lzma = lzma; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could just use inherit xz pixz gzip pigz bzip2 lzma;
4e905fe
to
14cf486
Compare
|
nixos/lib/make-system-tarball.nix
Outdated
|
||
inherit fileName pathsFromGraph extraArgs extraCommands; | ||
inherit fileName pathsFromGraph extraArgs extraCommands compressorFlags; | ||
compression = if (compression == "none") then "cat" else compression; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move this in to the inputMap so there is no special case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inputMap
is a list of derivations to have in buildInputs
, but this one is a string, what command to pipe the tar file thru, i would need a 3rd mapping
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps instead:
{
compression = {
none = {
inputs = [ ];
extension = "";
command = "cat";
};
pigz = {
inputs = [ pigz ];
extension = ".pigz";
command = "pigz";
};
};
}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, that can work
@@ -1,5 +1,4 @@ | |||
source $stdenv/setup | |||
set -x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was overly verbose, and i thought that this is typically only kept in when debugging things
nixos/lib/make-system-tarball.nix
Outdated
inputMap = { | ||
inherit xz pixz gzip pigz bzip2 lzma; | ||
none = null; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love that this isn't extendable by the caller, but perhaps it is not necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i could also just add some more arguments, that default to looking things up in the map, so you can bypass the map easily?
To be honest, this seems like over-engineering. If you really need a different compression method, you can easily keep that in a local git tree. |
mainly wanted to avoid duplicating the code |
Perhaps, then, the best way would be to allow overriding but not build-in the different compression algos. |
that can work, just move everything to arguments, and remove the mappings |
14cf486
to
31b8de9
Compare
nixos/lib/make-system-tarball.nix
Outdated
# extra inputs, like the compressor to use | ||
, extraInputs ? [ pixz ] | ||
# flags passed to the compressor | ||
, compressorFlags ? "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe drop compressorFlags and just pass yourcmd -abc
as the command, instead of as a separate parameter. This simplifies the calling code and we don't do anything special at all with the arguments anyway. Beyond this, which is a minor nit, this LGTM.
31b8de9
to
3c9e579
Compare
# Extension for the compressed tarball | ||
, compressionExtension ? ".xz" | ||
# extra inputs, like the compressor to use | ||
, extraInputs ? [ pixz ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than this, compressCommand
could just be ${pixz}/bin/pixz
?
Motivation for this change
sometimes an
xz
based tarball cant be used, and sometimes you may want to compress in parallel withpixz
orpigz
Things done
added support for gzip, lzma, bzip2, parallel xz/gz
tested with
nix-build nixos/release.nix -A containerTarball.x86_64-linux
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)the stats i gathered during testing: