Skip to content
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

pkgs/build-support/trivial-builders: add runCommandLocal #74642

Conversation

Profpatsch
Copy link
Member

A definition I’ve been copy-pasting everywhere so far, so it’s finally
time to add it to nixpkgs.

I’m using a remote builder for my regular nix builds, so trivial
runCommands which first try a substitution and then copy the inputs
to the builder to run for 0.2s are quite noticable.

If we just always build these, we gain some build time, so let’s make
it easy to switch from remote to local.

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @infinisil

// (if runLocal then {
preferLocalBuild = true;
allowSubstitutes = false;
} else {})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this should be the other way around, such that env can override preferLocalBuild. Also could use optionalAttrs runLocal { ... } here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are absolutely right, see force push.

Tested manually with

nix-build -E 'with import ./. {}; runCommandLocal "foo" { x = "y"; preferLocalBuild = false; } "echo $x"'

@Profpatsch Profpatsch force-pushed the build-support-trivial-builders-add-runCommandLocal branch from afd505b to affa896 Compare December 3, 2019 17:54
A definition I’ve been copy-pasting everywhere so far, so it’s finally
time to add it to nixpkgs.

I’m using a remote builder for my regular nix builds, so trivial
`runCommand`s which first try a substitution and then copy the inputs
to the builder to run for 0.2s are quite noticable.

If we just always build these, we gain some build time, so let’s make
it easy to switch from remote to local.
The link in the note points to the `id` added in
NixOS/nix#3255, so it might take some time to
start working correctly.
This makes it possible to reference single function definitions,
for pointing people to their exact definition.
@Profpatsch Profpatsch force-pushed the build-support-trivial-builders-add-runCommandLocal branch from affa896 to 242b043 Compare December 3, 2019 18:01
We shouldn’t force the user to have a C compiler in scope, just
because the derivation is forced to build locally. That can’t be
counted as “lightweight” anymore.

Co-Authored-By: Silvan Mosberger<contact@infinisil.com>
@Profpatsch Profpatsch merged commit c5c5465 into NixOS:master Dec 4, 2019
Profpatsch added a commit to openlab-aux/vuizvui that referenced this pull request Dec 8, 2019
`runCommandLocal` was added to nixpkgs in
NixOS/nixpkgs#74642
to speed up trivial `runCommand` derivations by always building them
locally. We have a few places where that’s good to use.
Profpatsch added a commit to openlab-aux/vuizvui that referenced this pull request Dec 8, 2019
`runCommandLocal` was added to nixpkgs in
NixOS/nixpkgs#74642
to speed up trivial `runCommand` derivations by always building them
locally. We have a few places where that’s good to use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants