nix-fast-build
nix-fast-build copied to clipboard
[BUG] --out-link does not work
I think --out-link is being overridden by this logic here. Could you help confirm?
https://github.com/Mic92/nix-fast-build/blob/cfff239d93716e92f6467f8953d8f8c12da1892a/nix_fast_build/init.py#L681-L685
I expect that --out-link path/to/out should link to path/to/out not path/to/out-<attr> because when attr is unset (for --flake) then we see path/to/out- (notice the trailing -) which is different than what we specified in the option.
We kind of depend on --out-link to have a gcroot. Than the package can be uploaded afterwards without things getting garbage collected right away.
@Mic92 Could you explain with an example? What do you mean by gcroot?
A gcroot is a link that prevents nix from deleting files when using nix-collect-garbage. If you use nix-build '<nixpkgs>' -A hello, it will also put a symlink called result in the current directory. That symlink also serves as a gcroot.
I'm not understanding how --out-link=/my/custom/path.out would cause that gcroot to not be considered by nix. Must the out-link be named result- with no attribute?
It probably would be but we would still need to append a custom suffix somehow since we build several builds instead of just one, and the name would clash here between those.
Having just arrived here and trying it out a little I do think --out-link does work as intended, though reading the help text is likely to cause confusion.
In one of my projects, if I run nix-fast-build --out-link foo I get
lrwxrwxrwx 1 elrond elrond 59 Jan 26 12:08 foo-x86_64-linux.image -> /nix/store/jias91j2yl96m9349q2gn51j7kc8s074-lumbergh.tar.gz
but if I runnix-fast-build '.#packages.x86_64-linux --out-link foo I get
lrwxrwxrwx 1 elrond elrond 59 Jan 26 12:05 foo- -> /nix/store/jias91j2yl96m9349q2gn51j7kc8s074-lumbergh.tar.gz
Given the help text for --out-link
--out-link OUT_LINK Name of the out-link for builds (default: result)
it's a little surprising to see the behaviour. --out-link is more of a prefix, the default is result-, and the - is added automatically and mustn't be included in the argument.
What to do about it? I'm not sure, but changing the help text might be a good first step.
I was switching to use nix-fast-build on CI and got bitten by this recently. It would be great if at least the --help is more detailed.