Mic92 / nix-fast-build

Combine the power of nix-eval-jobs with nix-output-monitor to speed-up your evaluation and building process.
MIT License
242 stars 12 forks source link

nix-fast-build depends on "nixpkgs" in the flake registry #52

Closed matrss closed 4 months ago

matrss commented 10 months ago

I tried to build my nixfiles repo using nix-fast-build and got the following:

$ nix run github:Mic92/nix-fast-build
INFO:nix_fast_build:run nix-eval-jobs --gc-roots-dir /tmp/tmp213llfvo --force-recurse --max-memory-size 4096 --workers 8 --flake '.#checks'
warning: unknown setting 'allowed-users'
warning: unknown setting 'trusted-users'
error: cannot find flake 'flake:nixpkgs' in the flake registries
  building x86_64-linux.lint/nixpkgs-fmt
  building x86_64-linux.lint/deadnix
  building x86_64-linux.lint/statix
  building x86_64-linux.lint/gitleaks
  building x86_64-linux.lint/editorconfig-checker
  building x86_64-linux.lint/tofu-fmt
/nix/store/x8cz3lv4nn3yqnipw1fbsbql0mcp4pij-lint.gitleaks
/nix/store/5yjz8ilhs0azg6axv4w725k6m8jhc61p-lint.editorconfig-checker
/nix/store/0ak8ssa3ddzq4xs5fmziwwkddq7p7ll2-lint.tofu-fmt
/nix/store/xjs2xajl9m4hlkw4hqp0xn4a4dnrnp79-lint.statix
/nix/store/10wfqg315wjqzwywnbs7ispnbmj9mv9s-lint.nixpkgs-fmt
/nix/store/f7gzlqvv6bw47kmk9qj54y9yiylagzp5-lint.deadnix
ERROR:nix_fast_build:nix-output-monitor exited with 1

The error seems weird. I do indeed not have nixpkgs in my flake registry (I instead have a pinned version of nixpkgs under a different name). I think this error is coming from here: https://github.com/Mic92/nix-fast-build/blob/4376b8a33b217ee2f78ba3dcff01a3e464d13a46/nix_fast_build/__init__.py#L467

Since nixpkgs in the flake registry is, by default, not pinned to any version I think nix-fast-build should not try to use anything from there and instead use the nix-output-monitor that is already in its closure.

Is this a bug or am I missing some reason for this?

Mic92 commented 10 months ago

It's in there because of the --remote flag. When doing ssh on the remote machine it's not trivial otherwise to make sure we have nix-eval-jobs or nom available. Nom cannot run locally since it needs to access derivations.

matrss commented 10 months ago

I thought that might be the reason.

Wouldn't it be possible to copy over the versions of nix-eval-jobs and nom that the nix-fast-build derivation depends on first, and use those? Or maybe pull them in through the nix-fast-build flake, instead of assuming nixpkgs to be in the registry?

Mic92 commented 10 months ago

No. The target system might be of a different architecture than the current nix-fast-build running on the local machine.

Mic92 commented 4 months ago

The flake registry now is only a fallback, in case the remote system doesn't provide the command. nix-fast-build will now lookup $PATH beforehand. This should give people better control over what version gets installed. Implementation in https://github.com/Mic92/nix-fast-build/pull/63/commits/55283e292b2f397aaa747f36501cc18860664aa7