Closed n8henrie closed 1 year ago
I'm somewhat worried about the closure-size impact of bringing in jq. I haven't investigated it though.
Fair enough.
Pre:
$ nix path-info -Sh .
/nix/store/ls0sndy28y5iphp9xk0l284nzr5r914d-agenix 106.2M
Post:
$ nix path-info -Sh .
/nix/store/lpm8p1mngxhik7lk38khwbqbm93qsa9x-agenix 106.9M
Not totally sure that's the right way to measure that.
I think it's more like this:
nix path-info -rsS . | cut - -f 3 | awk '{s+=$1} END {print s}' | numfmt --to=iec
current
1.8G
vs with jq
1.9G
So not that big of a difference. I wonder how many of those packages are commonly on people's systems anyway though.
Hmmm. Answers from https://unix.stackexchange.com/questions/665718/how-to-get-the-size-of-a-nix-derivation give me results more like the 106M:
$ git fetch upstream main
$ git checkout upstream/main
$ nix-store -q --requisites $(nix build --print-out-paths . ) | sort -u | xargs du -bc | tail -1
110898532 total
$ numfmt --to=iec 110898532
106M
$ git checkout sed_vs_jq
$ git rebase upstream/main
$ nix-store -q --requisites $(nix build --print-out-paths . ) | sort -u | xargs du -bc | tail -1
111625108 total
$ numfmt --to=iec $(( 111625108 - 110898532 ))
710K
This seems pretty consistent:
$ nix store diff-closures /nix/store/iqgvxqz16lpxqd2yg4n5lxgiya7qw7ry-agenix-0.13.0 /nix/store/fh73af13pm9yhzd6rnalvps08zqh16mv-agenix-0.13.0
gnused: 4.9 → ∅, -252.7 KiB
jq: ∅ → 1.6, +373.0 KiB
oniguruma: ∅ → 6.9.8, +590.4 KiB
Currently you're using sed in several piped steps that seem a fair amount more complex and less readable than just using the
--json
flag tonix-instantiate
andjq -r .[]
to spit out the lines. Is this on purpose?If not, would you consider a PR to this effect? Seems to work in my prelim testing, looks like you could completely replace the
sedBin
dependency with e.g.jqBin
.