diff options
author | Profpatsch <mail@profpatsch.de> | 2019-11-29 16:27:11 +0100 |
---|---|---|
committer | Profpatsch <mail@profpatsch.de> | 2019-12-04 21:17:01 +0100 |
commit | 8deaf41d60144551cc1ba98d695cc8390b85662b (patch) | |
tree | b40e9e288c89ba98910c536b73d15b0170fd5a92 /pkgs/build-support/trivial-builders.nix | |
parent | 03ad033f970beb1482000ec951d441910f48022f (diff) | |
download | nixpkgs-8deaf41d60144551cc1ba98d695cc8390b85662b.tar nixpkgs-8deaf41d60144551cc1ba98d695cc8390b85662b.tar.gz nixpkgs-8deaf41d60144551cc1ba98d695cc8390b85662b.tar.bz2 nixpkgs-8deaf41d60144551cc1ba98d695cc8390b85662b.tar.lz nixpkgs-8deaf41d60144551cc1ba98d695cc8390b85662b.tar.xz nixpkgs-8deaf41d60144551cc1ba98d695cc8390b85662b.tar.zst nixpkgs-8deaf41d60144551cc1ba98d695cc8390b85662b.zip |
pkgs/build-support/trivial-builders: add runCommandLocal
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.
Diffstat (limited to 'pkgs/build-support/trivial-builders.nix')
-rw-r--r-- | pkgs/build-support/trivial-builders.nix | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/pkgs/build-support/trivial-builders.nix b/pkgs/build-support/trivial-builders.nix index 55df09121b4..263320ca6d9 100644 --- a/pkgs/build-support/trivial-builders.nix +++ b/pkgs/build-support/trivial-builders.nix @@ -2,11 +2,16 @@ let - runCommand' = stdenv: name: env: buildCommand: + runCommand' = runLocal: stdenv: name: env: buildCommand: stdenv.mkDerivation ({ inherit name buildCommand; passAsFile = [ "buildCommand" ]; - } // env); + } + // (lib.optionalAttrs runLocal { + preferLocalBuild = true; + allowSubstitutes = false; + }) + // env); in @@ -21,10 +26,26 @@ rec { * runCommand "name" {envVariable = true;} ''echo hello > $out'' * runCommandNoCC "name" {envVariable = true;} ''echo hello > $out'' # equivalent to prior * runCommandCC "name" {} ''gcc -o myfile myfile.c; cp myfile $out''; + * + * The `*Local` variants force a derivation to be built locally, + * it is not substituted. + * + * This is intended for very cheap commands (<1s execution time). + * It saves on the network roundrip and can speed up a build. + * + * It is the same as adding the special fields + * `preferLocalBuild = true;` + * `allowSubstitutes = false;` + * to a derivation’s attributes. */ runCommand = runCommandNoCC; - runCommandNoCC = runCommand' stdenvNoCC; - runCommandCC = runCommand' stdenv; + runCommandLocal = runCommandNoCCLocal; + + runCommandNoCC = runCommand' false stdenvNoCC; + runCommandNoCCLocal = runCommand' true stdenvNoCC; + + runCommandCC = runCommand' false stdenv; + runCommandCCLocal = runCommand' true stdenv; /* Writes a text file to the nix store. |