lix/src/libstore
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
..
binary-cache-store.cc Revert "Get rid of unicode quotes (#1140)" 2016-11-26 00:38:01 +01:00
binary-cache-store.hh Remove addPathToAccessor 2016-10-21 18:09:30 +02:00
build.cc Add support for passing structured data to builders 2017-01-26 20:40:33 +01:00
builtins.cc Revert "Get rid of unicode quotes (#1140)" 2016-11-26 00:38:01 +01:00
builtins.hh Make <nix/fetchurl.nix> a builtin builder 2015-07-20 04:38:46 +02:00
crypto.cc Use secret-key-files for verifying 2016-04-07 15:16:57 +02:00
crypto.hh Revert "Get rid of unicode quotes (#1140)" 2016-11-26 00:38:01 +01:00
derivations.cc Fix S3BinaryCacheStore 2016-12-08 15:31:27 +01:00
derivations.hh Add a mechanism for derivation attributes to reference the derivation's outputs 2016-08-17 17:19:32 +02:00
download.cc On HTTP errors, also show the curl error 2017-01-26 20:40:32 +01:00
download.hh Revert "Get rid of unicode quotes (#1140)" 2016-11-26 00:38:01 +01:00
export-import.cc Revert "Get rid of unicode quotes (#1140)" 2016-11-26 00:38:01 +01:00
fs-accessor.hh Add NAR / Store accessor abstraction 2016-02-25 17:43:19 +01:00
gc.cc AutoCloseDir: Use std::unique_ptr 2017-01-16 22:39:27 +01:00
globals.cc Revert "Get rid of unicode quotes (#1140)" 2016-11-26 00:38:01 +01:00
globals.hh nix-store --serve: Suppress log output on stderr when repeating a build 2016-12-06 17:43:39 +01:00
http-binary-cache-store.cc Revert "Get rid of unicode quotes (#1140)" 2016-11-26 00:38:01 +01:00
local-binary-cache-store.cc Revert "Get rid of unicode quotes (#1140)" 2016-11-26 00:38:01 +01:00
local-fs-store.cc Revert "Get rid of unicode quotes (#1140)" 2016-11-26 00:38:01 +01:00
local-store.cc Revert "Get rid of unicode quotes (#1140)" 2016-11-26 00:38:01 +01:00
local-store.hh Revert "Get rid of unicode quotes (#1140)" 2016-11-26 00:38:01 +01:00
local.mk Revert "Merge branch 'seccomp' of https://github.com/aszlig/nix" 2016-12-19 11:52:57 +01:00
misc.cc Revert "Get rid of unicode quotes (#1140)" 2016-11-26 00:38:01 +01:00
nar-accessor.cc Fix warning on 32-bit systems 2016-12-08 20:37:58 +01:00
nar-accessor.hh Add NAR / Store accessor abstraction 2016-02-25 17:43:19 +01:00
nar-info-disk-cache.cc SQLite:: Add some convenience 2016-08-10 18:05:35 +02:00
nar-info-disk-cache.hh HttpBinaryCacheStore: Fix caching of WantMassQuery 2016-06-01 16:24:17 +02:00
nar-info.cc Revert "Get rid of unicode quotes (#1140)" 2016-11-26 00:38:01 +01:00
nar-info.hh Make the store directory a member variable of Store 2016-06-01 16:24:17 +02:00
nix-store.pc.in Install some pkgconfig files 2014-09-18 12:00:40 +02:00
optimise-store.cc AutoCloseDir: Use std::unique_ptr 2017-01-16 22:39:27 +01:00
pathlocks.cc Fix assertion failure when a path is locked 2017-01-26 20:40:33 +01:00
pathlocks.hh openLockFile: Return an AutoCloseFD 2017-01-26 20:40:33 +01:00
profiles.cc Revert "Get rid of unicode quotes (#1140)" 2016-11-26 00:38:01 +01:00
profiles.hh Allow setting the state directory as a store parameter 2016-06-02 16:02:48 +02:00
references.cc Revert "Get rid of unicode quotes (#1140)" 2016-11-26 00:38:01 +01:00
references.hh Use "#pragma once" to prevent repeated header file inclusion 2012-07-18 14:59:03 -04:00
remote-fs-accessor.cc Revert "Get rid of unicode quotes (#1140)" 2016-11-26 00:38:01 +01:00
remote-fs-accessor.hh Factor a general remote FS accessor out of BinaryCacheStore 2016-09-02 14:24:34 -04:00
remote-store.cc AutoDeleteArray -> std::unique_ptr 2017-01-16 22:24:49 +01:00
remote-store.hh Merge branch 'ssh-store' of https://github.com/shlevy/nix 2016-11-09 18:57:22 +01:00
s3-binary-cache-store.cc Call Aws::InitAPI 2016-12-22 17:39:49 +01:00
s3-binary-cache-store.hh Fix getS3Stats() 2016-10-06 17:00:52 +02:00
sandbox-defaults.sb.in Revert "remove sandbox-defaults.sb" 2015-11-21 16:40:24 -05:00
schema.sql Mark content-addressed paths in the Nix database and in .narinfo 2016-08-10 18:05:35 +02:00
sqlite.cc Revert "Get rid of unicode quotes (#1140)" 2016-11-26 00:38:01 +01:00
sqlite.hh SQLite:: Add some convenience 2016-08-10 18:05:35 +02:00
ssh-store.cc build-remote: Implement in C++ 2016-11-10 11:09:15 -05:00
store-api.cc Revert "Get rid of unicode quotes (#1140)" 2016-11-26 00:38:01 +01:00
store-api.hh Merge pull request #981 from shlevy/build-remote-c++ 2017-01-19 18:21:55 +01:00
worker-protocol.hh Merge branch 'ssh-store' of https://github.com/shlevy/nix 2016-11-09 18:57:22 +01:00