From 597d6d2bcdc15ce330f88459d23fb3cab206a147 Mon Sep 17 00:00:00 2001 From: Andrew Childs Date: Fri, 25 Jan 2019 00:32:39 +0900 Subject: nix-prefetch-git: propagate errors under --quiet --- pkgs/build-support/fetchgit/nix-prefetch-git | 47 +++++++++++++++++++--------- 1 file changed, 32 insertions(+), 15 deletions(-) (limited to 'pkgs/build-support') diff --git a/pkgs/build-support/fetchgit/nix-prefetch-git b/pkgs/build-support/fetchgit/nix-prefetch-git index fa4e504c908f..0a9314d22a3c 100755 --- a/pkgs/build-support/fetchgit/nix-prefetch-git +++ b/pkgs/build-support/fetchgit/nix-prefetch-git @@ -270,7 +270,7 @@ make_deterministic_repo(){ } -_clone_user_rev() { +clone_user_rev() { local dir="$1" local url="$2" local rev="${3:-HEAD}" @@ -307,19 +307,29 @@ _clone_user_rev() { fi } -clone_user_rev() { - if ! test -n "$QUIET"; then - _clone_user_rev "$@" - else - errfile="$(mktemp "${TMPDIR:-/tmp}/git-checkout-err-XXXXXXXX")" - # shellcheck disable=SC2064 - trap "rm -rf \"$errfile\"" EXIT - _clone_user_rev "$@" 2> "$errfile" || ( - status="$?" - cat "$errfile" >&2 - exit "$status" - ) +exit_handlers=() + +run_exit_handlers() { + exit_status=$? + for handler in "${exit_handlers[@]}"; do + eval "$handler $exit_status" + done +} + +trap run_exit_handlers EXIT + +quiet_exit_handler() { + exec 2>&3 3>&- + if [ $1 -ne 0 ]; then + cat "$errfile" >&2 fi + rm -f "$errfile" +} + +quiet_mode() { + errfile="$(mktemp "${TMPDIR:-/tmp}/git-checkout-err-XXXXXXXX")" + exit_handlers+=(quiet_exit_handler) + exec 3>&2 2>"$errfile" } json_escape() { @@ -362,6 +372,14 @@ EOF fi } +remove_tmpPath() { + rm -rf "$tmpPath" +} + +if test -n "$QUIET"; then + quiet_mode +fi + if test -z "$branchName"; then branchName=fetchgit fi @@ -390,8 +408,7 @@ else if test -z "$finalPath"; then tmpPath="$(mktemp -d "${TMPDIR:-/tmp}/git-checkout-tmp-XXXXXXXX")" - # shellcheck disable=SC2064 - trap "rm -rf \"$tmpPath\"" EXIT + exit_handlers+=(remove_tmpPath) tmpFile="$tmpPath/$(url_to_name "$url" "$rev")" mkdir -p "$tmpFile" -- cgit 1.4.1 From 3c66428859e2bd56673db95423c813a41d94249b Mon Sep 17 00:00:00 2001 From: Sebastian Jordan Date: Mon, 17 Jun 2019 18:35:52 +0200 Subject: nix-prefetch-github: 2.2 -> 2.3 --- pkgs/build-support/nix-prefetch-github/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'pkgs/build-support') diff --git a/pkgs/build-support/nix-prefetch-github/default.nix b/pkgs/build-support/nix-prefetch-github/default.nix index acc95eaf993f..7de30d573bf3 100644 --- a/pkgs/build-support/nix-prefetch-github/default.nix +++ b/pkgs/build-support/nix-prefetch-github/default.nix @@ -5,13 +5,13 @@ python3.pkgs.buildPythonApplication rec { pname = "nix-prefetch-github"; - version = "2.2"; + version = "2.3"; src = fetchFromGitHub { owner = "seppeljordan"; repo = "nix-prefetch-github"; rev = "v${version}"; - sha256 = "1m1d1fzacvwprfvhxih1hzr1m0y1jjxiznf8p8b3bi5a41yzvrrl"; + sha256 = "0b2hgfyxhlqq6lyi5cr98dz6if5kl6b3kq67f2lzfkalydywl1dh"; }; propagatedBuildInputs = with python3.pkgs; [ -- cgit 1.4.1 From a3667ee6be57c9dd51a692aba6be94eef4f2d6f5 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Sun, 16 Jun 2019 17:27:22 +0200 Subject: libredirect: add posix_spawnp support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After bumping sublime3 in #61636 we realized that saving files as root doesn’t work anymore and somehow the paths weren’t patched by `libredirect`. After some debugging it came out that Sublime switched from `posix_spawn(3)` to `posix_spawnp(3)` to start new processes internally. Since `libredirect` only handled the former, `/usr/bin/pkexec` stopped being redirected. Wrapping `posix_spawnp` fixes the problem. --- pkgs/build-support/libredirect/libredirect.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'pkgs/build-support') diff --git a/pkgs/build-support/libredirect/libredirect.c b/pkgs/build-support/libredirect/libredirect.c index 655399af58f5..8e8da00b02a2 100644 --- a/pkgs/build-support/libredirect/libredirect.c +++ b/pkgs/build-support/libredirect/libredirect.c @@ -160,6 +160,19 @@ int posix_spawn(pid_t * pid, const char * path, return posix_spawn_real(pid, rewrite(path, buf), file_actions, attrp, argv, envp); } +int posix_spawnp(pid_t * pid, const char * file, + const posix_spawn_file_actions_t * file_actions, + const posix_spawnattr_t * attrp, + char * const argv[], char * const envp[]) +{ + int (*posix_spawnp_real) (pid_t *, const char *, + const posix_spawn_file_actions_t *, + const posix_spawnattr_t *, + char * const argv[], char * const envp[]) = dlsym(RTLD_NEXT, "posix_spawnp"); + char buf[PATH_MAX]; + return posix_spawnp_real(pid, rewrite(file, buf), file_actions, attrp, argv, envp); +} + int execv(const char *path, char *const argv[]) { int (*execv_real) (const char *path, char *const argv[]) = dlsym(RTLD_NEXT, "execv"); -- cgit 1.4.1 From 08dbc6097423baeb8529e758f470af983fbaab50 Mon Sep 17 00:00:00 2001 From: Sebastian Jordan Date: Wed, 19 Jun 2019 00:06:29 +0200 Subject: nix-prefetch-github: Remove propagatedBuildInputs `requests' `requests' is no longer required per setup.cfg --- pkgs/build-support/nix-prefetch-github/default.nix | 1 - 1 file changed, 1 deletion(-) (limited to 'pkgs/build-support') diff --git a/pkgs/build-support/nix-prefetch-github/default.nix b/pkgs/build-support/nix-prefetch-github/default.nix index 7de30d573bf3..3c5cbe2b4928 100644 --- a/pkgs/build-support/nix-prefetch-github/default.nix +++ b/pkgs/build-support/nix-prefetch-github/default.nix @@ -19,7 +19,6 @@ python3.pkgs.buildPythonApplication rec { click effect jinja2 - requests ]; meta = with stdenv.lib; { description = "Prefetch sources from github"; -- cgit 1.4.1 From 0cfd90a1091888a49e08b3acf8df8045ff528db7 Mon Sep 17 00:00:00 2001 From: Timo Kaufmann Date: Thu, 20 Jun 2019 18:35:16 +0200 Subject: buildBazelPackage: fix directory symlink handling The previous behaviour would work fine as long as `symlink` is a link to a file. If is a link to a directory though, the new `ln` wouldn't overwrite it but would create a new link *in that directory* (with the name of the link source). Instead, we can precompute the target location, then first remove the symlink and write the new one in its place. --- pkgs/build-support/build-bazel-package/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'pkgs/build-support') diff --git a/pkgs/build-support/build-bazel-package/default.nix b/pkgs/build-support/build-bazel-package/default.nix index b0840192ecec..37cee98a3160 100644 --- a/pkgs/build-support/build-bazel-package/default.nix +++ b/pkgs/build-support/build-bazel-package/default.nix @@ -59,7 +59,9 @@ in stdenv.mkDerivation (fBuildAttrs // { # Patching symlinks to remove build directory reference find $bazelOut/external -type l | while read symlink; do - ln -sf $(readlink "$symlink" | sed "s,$NIX_BUILD_TOP,NIX_BUILD_TOP,") "$symlink" + new_target="$(readlink "$symlink" | sed "s,$NIX_BUILD_TOP,NIX_BUILD_TOP,")" + rm "$symlink" + ln -sf "$new_target" "$symlink" done cp -r $bazelOut/external $out -- cgit 1.4.1 From 883725b22fc8e22048e315b743b03192565b1a1a Mon Sep 17 00:00:00 2001 From: Timo Kaufmann Date: Thu, 20 Jun 2019 20:01:22 +0200 Subject: buildBazelPackage: disable multithreaded fetching To work around https://github.com/bazelbuild/bazel/issues/6502. --- pkgs/build-support/build-bazel-package/default.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'pkgs/build-support') diff --git a/pkgs/build-support/build-bazel-package/default.nix b/pkgs/build-support/build-bazel-package/default.nix index 37cee98a3160..1004a7ce3f92 100644 --- a/pkgs/build-support/build-bazel-package/default.nix +++ b/pkgs/build-support/build-bazel-package/default.nix @@ -34,8 +34,10 @@ in stdenv.mkDerivation (fBuildAttrs // { # https://github.com/bazelbuild/bazel/blob/9323c57607d37f9c949b60e293b573584906da46/src/main/cpp/startup_options.cc#L123-L124 # # On macOS Bazel will use the system installed Xcode or CLT toolchain instead of the one in the PATH unless we pass BAZEL_USE_CPP_ONLY_TOOLCHAIN - # - BAZEL_USE_CPP_ONLY_TOOLCHAIN=1 USER=homeless-shelter bazel --output_base="$bazelOut" --output_user_root="$bazelUserRoot" fetch $bazelFlags $bazelTarget + + # We disable multithreading for the fetching phase since it can lead to timeouts with many dependencies/threads: + # https://github.com/bazelbuild/bazel/issues/6502 + BAZEL_USE_CPP_ONLY_TOOLCHAIN=1 USER=homeless-shelter bazel --output_base="$bazelOut" --output_user_root="$bazelUserRoot" fetch --loading_phase_threads=1 $bazelFlags $bazelTarget runHook postBuild ''; -- cgit 1.4.1 From 76ef802d3d60cc4d199f19ba69e8bcfe63b88e7b Mon Sep 17 00:00:00 2001 From: Bas van Dijk Date: Sun, 23 Jun 2019 21:11:49 +0200 Subject: mkShell: compose shellHooks Running the following expression with nix-shell: let pkgs = import {}; shell1 = pkgs.mkShell { shellHook = '' echo shell1 ''; }; shell2 = pkgs.mkShell { shellHook = '' echo shell2 ''; }; shell3 = pkgs.mkShell { inputsFrom = [ shell1 shell2 ]; shellHook = '' echo shell3 ''; }; in shell3 Will now results in: shell2 shell1 shell3 Note that packages in the front of inputsFrom have precedence over packages in the back. The outermost mkShell has precedence over all. --- pkgs/build-support/mkshell/default.nix | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'pkgs/build-support') diff --git a/pkgs/build-support/mkshell/default.nix b/pkgs/build-support/mkshell/default.nix index a98b4affacba..698974590880 100644 --- a/pkgs/build-support/mkshell/default.nix +++ b/pkgs/build-support/mkshell/default.nix @@ -25,6 +25,7 @@ let "nativeBuildInputs" "propagatedBuildInputs" "propagatedNativeBuildInputs" + "shellHook" ]; in @@ -37,6 +38,9 @@ stdenv.mkDerivation ({ propagatedBuildInputs = mergeInputs "propagatedBuildInputs"; propagatedNativeBuildInputs = mergeInputs "propagatedNativeBuildInputs"; + shellHook = lib.concatStringsSep "\n" (lib.catAttrs "shellHook" + (lib.reverseList inputsFrom ++ [attrs])); + nobuildPhase = '' echo echo "This derivation is not meant to be built, aborting"; -- cgit 1.4.1 From cee35739ff0800f5738ecbedb43c356a2f06c96f Mon Sep 17 00:00:00 2001 From: Bas van Dijk Date: Sun, 23 Jun 2019 21:39:29 +0200 Subject: mkshell: improve mergeInputs mergeInputs is now simply defined in terms of `concatLists` and `catAttrs` instead of a more complicated `foldr`. Note that the order of PATH has also changed. For example running the following with nix-shell: let pkgs = import {}; shell1 = pkgs.mkShell { buildInputs = [ pkgs.htop ]; }; shell2 = pkgs.mkShell { buildInputs = [ pkgs.hello ]; }; shell3 = pkgs.mkShell { inputsFrom = [ shell1 shell2 ]; buildInputs = [ pkgs.tree ]; }; in shell3 Results in the following PATH: $ echo $PATH ... /nix/store/yifq4bikf7m07160bpia7z48ciqddbfi-tree-1.8.0/bin: /nix/store/vhxqk81234ivqw1a7j200a1c69k8mywi-htop-2.2.0/bin: /nix/store/n9vm3m58y1n3rg3mlll17wanc9hln58k-hello-2.10/bin ... Previously the order was: /nix/store/n9vm3m58y1n3rg3mlll17wanc9hln58k-hello-2.10/bin /nix/store/vhxqk81234ivqw1a7j200a1c69k8mywi-htop-2.2.0/bin: /nix/store/yifq4bikf7m07160bpia7z48ciqddbfi-tree-1.8.0/bin: I think the new order makes more sense because it allows to override the PATH in the outermost mkShell. --- pkgs/build-support/mkshell/default.nix | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'pkgs/build-support') diff --git a/pkgs/build-support/mkshell/default.nix b/pkgs/build-support/mkshell/default.nix index 698974590880..a70dc0390cb5 100644 --- a/pkgs/build-support/mkshell/default.nix +++ b/pkgs/build-support/mkshell/default.nix @@ -11,13 +11,8 @@ ... }@attrs: let - mergeInputs = name: - let - op = item: sum: sum ++ item."${name}" or []; - nul = []; - list = [attrs] ++ inputsFrom; - in - lib.foldr op nul list; + mergeInputs = name: lib.concatLists (lib.catAttrs name + ([attrs] ++ inputsFrom)); rest = builtins.removeAttrs attrs [ "inputsFrom" -- cgit 1.4.1