lix/src
Eelco Dolstra 6de33a9c67
Add support for passing structured data to builders
Previously, all derivation attributes had to be coerced into strings
so that they could be passed via the environment. This is lossy
(e.g. lists get flattened, necessitating configureFlags
vs. configureFlagsArray, of which the latter cannot be specified as an
attribute), doesn't support attribute sets at all, and has size
limitations (necessitating hacks like passAsFile).

This patch adds a new mode for passing attributes to builders, namely
encoded as a JSON file ".attrs.json" in the current directory of the
builder. This mode is activated via the special attribute

  __structuredAttrs = true;

(The idea is that one day we can set this in stdenv.mkDerivation.)

For example,

  stdenv.mkDerivation {
    __structuredAttrs = true;
    name = "foo";
    buildInputs = [ pkgs.hello pkgs.cowsay ];
    doCheck = true;
    hardening.format = false;
  }

results in a ".attrs.json" file containing (sans the indentation):

  {
    "buildInputs": [],
    "builder": "/nix/store/ygl61ycpr2vjqrx775l1r2mw1g2rb754-bash-4.3-p48/bin/bash",
    "configureFlags": [
      "--with-foo",
      "--with-bar=1 2"
    ],
    "doCheck": true,
    "hardening": {
      "format": false
    },
    "name": "foo",
    "nativeBuildInputs": [
      "/nix/store/10h6li26i7g6z3mdpvra09yyf10mmzdr-hello-2.10",
      "/nix/store/4jnvjin0r6wp6cv1hdm5jbkx3vinlcvk-cowsay-3.03"
    ],
    "propagatedBuildInputs": [],
    "propagatedNativeBuildInputs": [],
    "stdenv": "/nix/store/f3hw3p8armnzy6xhd4h8s7anfjrs15n2-stdenv",
    "system": "x86_64-linux"
  }

"passAsFile" is ignored in this mode because it's not needed - large
strings are included directly in the JSON representation.

It is up to the builder to do something with the JSON
representation. For example, in bash-based builders, lists/attrsets of
string values could be mapped to bash (associative) arrays.
2017-01-26 20:40:33 +01:00
..
boost Force stack trace for boost format errors 2016-03-02 15:46:07 +01:00
build-remote openLockFile: Return an AutoCloseFD 2017-01-26 20:40:33 +01:00
buildenv Fix Fedora build 2016-08-30 13:56:22 +02:00
download-via-ssh printMsg(lvlError, ...) -> printError(...) etc. 2016-09-21 16:54:53 +02:00
libexpr Add support for passing structured data to builders 2017-01-26 20:40:33 +01:00
libmain Fix interrupt handling 2017-01-26 20:40:33 +01:00
libstore Add support for passing structured data to builders 2017-01-26 20:40:33 +01:00
libutil Fix interrupt handling 2017-01-26 20:40:33 +01:00
nix Merge pull request #981 from shlevy/build-remote-c++ 2017-01-19 18:21:55 +01:00
nix-build assign environ to a temp variable to ensure liveness 2017-01-16 23:52:44 +01:00
nix-channel nix-channel: Fix --update <CHANNELS> 2016-11-21 15:54:19 +01:00
nix-collect-garbage printMsg(lvlError, ...) -> printError(...) etc. 2016-09-21 16:54:53 +02:00
nix-daemon nix-daemon: Fix splice faking on non-Linux 2016-11-17 08:10:12 -05:00
nix-env printMsg(lvlError, ...) -> printError(...) etc. 2016-09-21 16:54:53 +02:00
nix-instantiate Allow setting the state directory as a store parameter 2016-06-02 16:02:48 +02:00
nix-prefetch-url printMsg(lvlError, ...) -> printError(...) etc. 2016-09-21 16:54:53 +02:00
nix-store Add a hook to run diffoscope when non-determinism is detected 2016-12-07 17:57:35 +01:00
resolve-system-dependencies printMsg(lvlError, ...) -> printError(...) etc. 2016-09-21 16:54:53 +02:00