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

@Profpatsch Profpatsch commented Nov 29, 2019

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 {})

This comment has been minimized.

@Infinisil

Infinisil Dec 3, 2019
Member

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

This comment has been minimized.

@Profpatsch

Profpatsch Dec 3, 2019
Author Member

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 Profpatsch:build-support-trivial-builders-add-runCommandLocal branch from afd505b to affa896 Dec 3, 2019
Profpatsch added 3 commits Nov 29, 2019
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 Profpatsch:build-support-trivial-builders-add-runCommandLocal branch from affa896 to 242b043 Dec 3, 2019
@Profpatsch Profpatsch requested a review from Infinisil Dec 3, 2019
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
12 checks passed
12 checks passed
Evaluation Performance Report Evaluator Performance Report
Details
grahamcofborg-eval ^.^!
Details
grahamcofborg-eval-check-meta config.nix: checkMeta = true
Details
grahamcofborg-eval-darwin nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A darwin-tested
Details
grahamcofborg-eval-nixos nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./nixos/release-combined.nix -A tested
Details
grahamcofborg-eval-nixos-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./nixos/release.nix -A manual
Details
grahamcofborg-eval-nixos-options nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./nixos/release.nix -A options
Details
grahamcofborg-eval-nixpkgs-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A manual
Details
grahamcofborg-eval-nixpkgs-tarball nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A tarball
Details
grahamcofborg-eval-nixpkgs-unstable-jobset nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A unstable
Details
grahamcofborg-eval-package-list nix-env -qa --json --file .
Details
grahamcofborg-eval-package-list-no-aliases nix-env -qa --json --file . --arg config { allowAliases = false; }
Details
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
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.