File tree Expand file tree Collapse file tree 3 files changed +94
-0
lines changed
Expand file tree Collapse file tree 3 files changed +94
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ source common.sh
4+
5+ # Store layer needs bugfix
6+ requireDaemonNewerThan " 2.27pre20250205"
7+
8+ TODO_NixOS # can't enable a sandbox feature easily
9+
10+ enableFeatures ' recursive-nix'
11+ restartDaemon
12+
13+ NIX_BIN_DIR=" $( dirname " $( type -p nix) " ) "
14+ export NIX_BIN_DIR
15+
16+ nix build -L --file ./non-trivial.nix
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ suites += {
1515 ' failing-outer.sh' ,
1616 ' dep-built-drv.sh' ,
1717 ' old-daemon-error-hack.sh' ,
18+ ' dep-built-drv-2.sh' ,
1819 ],
1920 ' workdir' : meson .current_source_dir(),
2021}
Original file line number Diff line number Diff line change 1+ with import ./config.nix ;
2+
3+ builtins . outputOf
4+ ( mkDerivation {
5+ name = "make-derivations.drv" ;
6+
7+ requiredSystemFeatures = [ "recursive-nix" ] ;
8+
9+ buildCommand = ''
10+ set -e
11+ set -u
12+
13+ PATH=${ builtins . getEnv "NIX_BIN_DIR" } :$PATH
14+
15+ export NIX_CONFIG='extra-experimental-features = nix-command ca-derivations dynamic-derivations'
16+
17+ declare -A deps=(
18+ [a]=""
19+ [b]="a"
20+ [c]="a"
21+ [d]="b c"
22+ [e]="b c d"
23+ )
24+
25+ # Cannot just literally include this, or Nix will think it is the
26+ # *outer* derivation that's trying to refer to itself, and
27+ # substitute the string too soon.
28+ placeholder=$(nix eval --raw --expr 'builtins.placeholder "out"')
29+
30+ declare -A drvs=()
31+ for word in a b c d e; do
32+ inputDrvs=""
33+ for dep in '' ${deps[$word]}; do
34+ if [[ "$inputDrvs" != "" ]]; then
35+ inputDrvs+=","
36+ fi
37+ read -r -d "" line <<EOF || true
38+ "'' ${drvs[$dep]}": {
39+ "outputs": ["out"],
40+ "dynamicOutputs": {}
41+ }
42+ EOF
43+ inputDrvs+="$line"
44+ done
45+ read -r -d "" json <<EOF || true
46+ {
47+ "args": ["-c", "set -xeu; echo \"word env vav $word is \$$word\" >> \"\$out\""],
48+ "builder": "${ shell } ",
49+ "env": {
50+ "out": "$placeholder",
51+ "$word": "hello, from $word!",
52+ "PATH": ${ builtins . toJSON path }
53+ },
54+ "inputDrvs": {
55+ $inputDrvs
56+ },
57+ "inputSrcs": [],
58+ "name": "build-$word",
59+ "outputs": {
60+ "out": {
61+ "method": "nar",
62+ "hashAlgo": "sha256"
63+ }
64+ },
65+ "system": "${ system } "
66+ }
67+ EOF
68+ drvs[$word]="$(echo "$json" | nix derivation add)"
69+ done
70+ cp "'' ${drvs[e]}" $out
71+ '' ;
72+
73+ __contentAddressed = true ;
74+ outputHashMode = "text" ;
75+ outputHashAlgo = "sha256" ;
76+ } ) . outPath
77+ "out"
You can’t perform that action at this time.
0 commit comments