Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nixos/modules/services/networking/ircd-hybrid/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

doSub() {
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/web-servers/jboss/builder.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set -e

if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

mkdir -p $out/bin
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/misc/adobe-reader/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

echo "unpacking $src..."
Expand Down
13 changes: 4 additions & 9 deletions pkgs/build-support/binary-cache/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ lib, stdenv, buildPackages }:
{ lib, stdenv, coreutils, jq, python3, nix, xz }:

# This function is for creating a flat-file binary cache, i.e. the kind created by
# nix copy --to file:///some/path and usable as a substituter (with the file:// prefix).
Expand All @@ -19,15 +19,10 @@ stdenv.mkDerivation {

preferLocalBuild = true;

PATH = lib.makeBinPath (with buildPackages; [ coreutils jq python3 nix xz ]);
nativeBuildInputs = [ coreutils jq python3 nix xz ];

builder = builtins.toFile "builder" ''
. .attrs.sh

export out=''${outputs[out]}

mkdir $out
mkdir $out/nar
buildCommand = ''
mkdir -p $out/nar

python ${./make-binary-cache.py}

Expand Down
2 changes: 1 addition & 1 deletion pkgs/build-support/binary-cache/make-binary-cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import subprocess

with open(".attrs.json", "r") as f:
with open(os.environ["NIX_ATTRS_JSON_FILE"], "r") as f:
closures = json.load(f)["closure"]

os.chdir(os.environ["out"])
Expand Down
14 changes: 6 additions & 8 deletions pkgs/build-support/closure-info.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# "nix-store --load-db" and "nix-store --register-validity
# --hash-given".

{ stdenv, buildPackages }:
{ stdenv, coreutils, jq }:

{ rootPaths }:

Expand All @@ -19,18 +19,16 @@ stdenv.mkDerivation {

preferLocalBuild = true;

PATH = "${buildPackages.coreutils}/bin:${buildPackages.jq}/bin";
nativeBuildInputs = [ coreutils jq ];

builder = builtins.toFile "builder"
buildCommand =
''
. .attrs.sh

out=''${outputs[out]}

mkdir $out

jq -r ".closure | map(.narSize) | add" < .attrs.json > $out/total-nar-size
jq -r '.closure | map([.path, .narHash, .narSize, "", (.references | length)] + .references) | add | map("\(.)\n") | add' < .attrs.json | head -n -1 > $out/registration
jq -r .closure[].path < .attrs.json > $out/store-paths
jq -r ".closure | map(.narSize) | add" < "$NIX_ATTRS_JSON_FILE" > $out/total-nar-size
jq -r '.closure | map([.path, .narHash, .narSize, "", (.references | length)] + .references) | add | map("\(.)\n") | add' < "$NIX_ATTRS_JSON_FILE" | head -n -1 > $out/registration
jq -r '.closure[].path' < "$NIX_ATTRS_JSON_FILE" > $out/store-paths
'';
}
2 changes: 1 addition & 1 deletion pkgs/build-support/fetchbzr/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source "$stdenv/setup"

echo "exporting \`$url' (revision $rev) into \`$out'"
Expand Down
2 changes: 1 addition & 1 deletion pkgs/build-support/fetchcvs/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

(echo "#!$SHELL"; \
Expand Down
2 changes: 1 addition & 1 deletion pkgs/build-support/fetchdarcs/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

tagtext=""
Expand Down
2 changes: 1 addition & 1 deletion pkgs/build-support/fetchdocker/fetchdocker-builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source "${stdenv}/setup"
echo "exporting ${repository}/${imageName} (tag: ${tag}) into ${out}"
mkdir -p "${out}"
Expand Down
2 changes: 1 addition & 1 deletion pkgs/build-support/fetchfossil/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
echo "Cloning Fossil $url [$rev] into $out"

Expand Down
2 changes: 1 addition & 1 deletion pkgs/build-support/fetchgit/builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# - revision specified and remote has a HEAD
# - revision specified and remote without HEAD
#
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

echo "exporting $url (rev $rev) into $out"
Expand Down
2 changes: 1 addition & 1 deletion pkgs/build-support/fetchhg/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup
echo "getting $url${rev:+ ($rev)} into $out"

Expand Down
2 changes: 1 addition & 1 deletion pkgs/build-support/fetchipfs/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

# Curl flags to handle redirects, not use EPSV, handle cookies for
Expand Down
2 changes: 1 addition & 1 deletion pkgs/build-support/fetchmtn/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

set -x
Expand Down
2 changes: 1 addition & 1 deletion pkgs/build-support/fetchsvn/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

echo "exporting $url (r$rev) into $out"
Expand Down
2 changes: 1 addition & 1 deletion pkgs/build-support/fetchsvnssh/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

echo "exporting $url (r$rev) into $out"
Expand Down
2 changes: 1 addition & 1 deletion pkgs/build-support/fetchurl/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

source $mirrorsFile
Expand Down
13 changes: 5 additions & 8 deletions pkgs/build-support/references-by-popularity/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ path: runCommand "closure-paths"
exportReferencesGraph.graph = path;
__structuredAttrs = true;
preferLocalBuild = true;
PATH = "${coreutils}/bin:${python3}/bin";
builder = builtins.toFile "builder"
''
. .attrs.sh
python3 ${./closure-graph.py} .attrs.json graph > ''${outputs[out]}
'';
}
""
nativeBuildInputs = [ coreutils python3 ];
}
''
python3 ${./closure-graph.py} "$NIX_ATTRS_JSON_FILE" graph > ''${outputs[out]}
''
2 changes: 1 addition & 1 deletion pkgs/desktops/gnustep/make/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

providedPreConfigure="$preConfigure";
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/compilers/aspectj/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

export JAVA_HOME=$jre
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/compilers/chicken/4/fetchegg/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

echo "exporting egg ${eggName} (version $version) into $out"
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/compilers/fpc/binary-builder-darwin.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

pkgdir=$(pwd)/pkg
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/compilers/fpc/binary-builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

tar xf $src
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- shell-script -*-
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

function extract
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/compilers/ocaml/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

configureFlags="-prefix $out $configureFlags"
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/libraries/glibc/locales-builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
# Glibc cannot have itself in its RPATH.
export NIX_NO_SELF_RPATH=1

Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/libraries/gtk-sharp/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

genericBuild
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/libraries/wtk/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

mkdir unzipped
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/perl-modules/generic/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

PERL5LIB="$PERL5LIB${PERL5LIB:+:}$out/lib/perl5/site_perl"
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/tools/build-managers/boot/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

boot_bin=$out/bin/boot
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/tools/misc/automake/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

# Wrap the given `aclocal' program, appending extra `-I' flags
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/tools/parsing/antlr/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

tar zxvf $src
Expand Down
2 changes: 1 addition & 1 deletion pkgs/misc/cups/drivers/samsung/4.00.39/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

arch=$(uname -m)
Expand Down
2 changes: 1 addition & 1 deletion pkgs/os-specific/linux/nvidia-x11/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

unpackManually() {
Expand Down
2 changes: 1 addition & 1 deletion pkgs/os-specific/linux/opengl/xorg-sys/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

mkdir -p $out/lib
Expand Down
2 changes: 1 addition & 1 deletion pkgs/servers/http/tomcat/axis2/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
source $stdenv/setup

unzip $src
Expand Down
2 changes: 1 addition & 1 deletion pkgs/servers/x11/xorg/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
# This is the builder for all X.org components.
source $stdenv/setup

Expand Down
4 changes: 1 addition & 3 deletions pkgs/stdenv/generic/default-builder.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
if [ -f .attrs.sh ]; then
. .attrs.sh
fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi

source $stdenv/setup
genericBuild
17 changes: 2 additions & 15 deletions pkgs/stdenv/generic/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,15 @@ if (( "${NIX_DEBUG:-0}" >= 6 )); then
set -x
fi

if [ -f .attrs.sh ]; then
if [ -f .attrs.sh ] || [[ -n "${NIX_ATTRS_JSON_FILE:-}" ]]; then
__structuredAttrs=1
echo "structuredAttrs is enabled"
else
__structuredAttrs=
fi

if [ -n "$__structuredAttrs" ]; then
for outputName in "${!outputs[@]}"; do
# ex: out=/nix/store/...
export "$outputName=${outputs[$outputName]}"
done

# Before Nix 2.4, $NIX_ATTRS_*_FILE was named differently:
# https://github.com/NixOS/nix/commit/27ce722
if [[ -n "${ATTRS_JSON_FILE:-}" ]]; then
export NIX_ATTRS_JSON_FILE="$ATTRS_JSON_FILE"
fi

if [[ -n "${ATTRS_SH_FILE:-}" ]]; then
export NIX_ATTRS_SH_FILE="$ATTRS_SH_FILE"
fi

# $NIX_ATTRS_JSON_FILE pointed to the wrong location in sandbox
# https://github.com/NixOS/nix/issues/6736; please keep around until the
# fix reaches *every patch version* that's >= lib/minver.nix
Expand All @@ -49,6 +35,7 @@ if [ -n "$__structuredAttrs" ]; then
export NIX_ATTRS_SH_FILE="$NIX_BUILD_TOP/.attrs.sh"
fi
else
__structuredAttrs=
: "${outputs:=out}"
fi

Expand Down
2 changes: 1 addition & 1 deletion pkgs/test/simple/builder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if [ -e .attrs.sh ]; then source .attrs.sh; fi
if [ -e "$NIX_ATTRS_SH_FILE" ]; then . "$NIX_ATTRS_SH_FILE"; elif [ -f .attrs.sh ]; then . .attrs.sh; fi
set -x

export NIX_DEBUG=1
Expand Down