nix-fast-build icon indicating copy to clipboard operation
nix-fast-build copied to clipboard

[BUG] --out-link does not work

Open hjkatz opened this issue 1 year ago • 8 comments

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

hjkatz avatar May 28 '24 15:05 hjkatz

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.

hjkatz avatar May 28 '24 15:05 hjkatz

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 avatar May 29 '24 14:05 Mic92

@Mic92 Could you explain with an example? What do you mean by gcroot?

hjkatz avatar May 29 '24 19:05 hjkatz

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.

Mic92 avatar Jun 10 '24 03:06 Mic92

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?

hjkatz avatar Jun 10 '24 16:06 hjkatz

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.

Mic92 avatar Jun 11 '24 08:06 Mic92

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.

magthe avatar Jan 26 '25 11:01 magthe

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.

MidAutumnMoon avatar Mar 14 '25 09:03 MidAutumnMoon