about summary refs log tree commit diff
path: root/nixpkgs/pkgs/build-support
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2019-07-14 15:50:11 +0000
committerAlyssa Ross <hi@alyssa.is>2019-08-14 00:01:17 +0000
commit69a15dd2dc85051ba1436613805f9286850e0596 (patch)
treed53cec2bb5b8d07df1d1919b212cb2deb3628cd6 /nixpkgs/pkgs/build-support
parent6941276da135c3eb3b50e0be33d92e7d01ccba9a (diff)
parentbeff2f8d75ef2c65017fb25e251337c6bb2e950d (diff)
downloadnixlib-69a15dd2dc85051ba1436613805f9286850e0596.tar
nixlib-69a15dd2dc85051ba1436613805f9286850e0596.tar.gz
nixlib-69a15dd2dc85051ba1436613805f9286850e0596.tar.bz2
nixlib-69a15dd2dc85051ba1436613805f9286850e0596.tar.lz
nixlib-69a15dd2dc85051ba1436613805f9286850e0596.tar.xz
nixlib-69a15dd2dc85051ba1436613805f9286850e0596.tar.zst
nixlib-69a15dd2dc85051ba1436613805f9286850e0596.zip
Merge commit 'beff2f8d75ef2c65017fb25e251337c6bb2e950d'
v#	modified:   nixpkgs/pkgs/tools/networking/dhcpcd/default.nix
Diffstat (limited to 'nixpkgs/pkgs/build-support')
-rw-r--r--nixpkgs/pkgs/build-support/appimage/default.nix2
-rw-r--r--nixpkgs/pkgs/build-support/build-bazel-package/default.nix20
-rw-r--r--nixpkgs/pkgs/build-support/libredirect/libredirect.c13
-rw-r--r--nixpkgs/pkgs/build-support/mkshell/default.nix13
-rw-r--r--nixpkgs/pkgs/build-support/nix-prefetch-github/default.nix5
-rw-r--r--nixpkgs/pkgs/build-support/snap/default.nix4
-rw-r--r--nixpkgs/pkgs/build-support/snap/example-firefox.nix28
-rw-r--r--nixpkgs/pkgs/build-support/snap/example-hello.nix12
-rw-r--r--nixpkgs/pkgs/build-support/snap/make-snap.nix84
-rw-r--r--nixpkgs/pkgs/build-support/trivial-builders.nix2
10 files changed, 164 insertions, 19 deletions
diff --git a/nixpkgs/pkgs/build-support/appimage/default.nix b/nixpkgs/pkgs/build-support/appimage/default.nix
index cdfbe4e7c381..990f1ce2e3e3 100644
--- a/nixpkgs/pkgs/build-support/appimage/default.nix
+++ b/nixpkgs/pkgs/build-support/appimage/default.nix
@@ -149,7 +149,7 @@ rec {
       libidn
       tbb
       wayland
-      mesa_noglu
+      mesa
       libxkbcommon
 
       flac
diff --git a/nixpkgs/pkgs/build-support/build-bazel-package/default.nix b/nixpkgs/pkgs/build-support/build-bazel-package/default.nix
index b0840192ecec..7c9fc83e0f1b 100644
--- a/nixpkgs/pkgs/build-support/build-bazel-package/default.nix
+++ b/nixpkgs/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
     '';
@@ -49,8 +51,10 @@ in stdenv.mkDerivation (fBuildAttrs // {
       rm -rf $bazelOut/external/{local_*,\@local_*}
 
       # Patching markers to make them deterministic
-      sed -i 's, -\?[0-9][0-9]*$, 1,' $bazelOut/external/\@*.marker
-      sed -i '/^ENV:TMP.*/d' $bazelOut/external/\@*.marker
+      find $bazelOut/external -name '@*\.marker' -exec sed -i \
+        -e 's, -\?[0-9][0-9]*$, 1,' \
+        -e '/^ENV:TMP.*/d' \
+        '{}' \;
 
       # Remove all vcs files
       rm -rf $(find $bazelOut/external -type d -name .git)
@@ -59,7 +63,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
@@ -82,8 +88,8 @@ in stdenv.mkDerivation (fBuildAttrs // {
   '';
 
   preConfigure = ''
-    mkdir -p $bazelOut/external
-    cp -r $deps/* $bazelOut/external
+    mkdir -p "$bazelOut"
+    cp -r $deps $bazelOut/external
     chmod -R +w $bazelOut
     find $bazelOut -type l | while read symlink; do
       ln -sf $(readlink "$symlink" | sed "s,NIX_BUILD_TOP,$NIX_BUILD_TOP,") "$symlink"
diff --git a/nixpkgs/pkgs/build-support/libredirect/libredirect.c b/nixpkgs/pkgs/build-support/libredirect/libredirect.c
index 655399af58f5..8e8da00b02a2 100644
--- a/nixpkgs/pkgs/build-support/libredirect/libredirect.c
+++ b/nixpkgs/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");
diff --git a/nixpkgs/pkgs/build-support/mkshell/default.nix b/nixpkgs/pkgs/build-support/mkshell/default.nix
index a98b4affacba..a70dc0390cb5 100644
--- a/nixpkgs/pkgs/build-support/mkshell/default.nix
+++ b/nixpkgs/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"
@@ -25,6 +20,7 @@ let
     "nativeBuildInputs"
     "propagatedBuildInputs"
     "propagatedNativeBuildInputs"
+    "shellHook"
   ];
 in
 
@@ -37,6 +33,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";
diff --git a/nixpkgs/pkgs/build-support/nix-prefetch-github/default.nix b/nixpkgs/pkgs/build-support/nix-prefetch-github/default.nix
index acc95eaf993f..3c5cbe2b4928 100644
--- a/nixpkgs/pkgs/build-support/nix-prefetch-github/default.nix
+++ b/nixpkgs/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; [
@@ -19,7 +19,6 @@ python3.pkgs.buildPythonApplication rec {
     click
     effect
     jinja2
-    requests
   ];
   meta = with stdenv.lib; {
     description = "Prefetch sources from github";
diff --git a/nixpkgs/pkgs/build-support/snap/default.nix b/nixpkgs/pkgs/build-support/snap/default.nix
new file mode 100644
index 000000000000..ba5271868911
--- /dev/null
+++ b/nixpkgs/pkgs/build-support/snap/default.nix
@@ -0,0 +1,4 @@
+{ callPackage, hello }:
+{
+  makeSnap = callPackage ./make-snap.nix { };
+}
diff --git a/nixpkgs/pkgs/build-support/snap/example-firefox.nix b/nixpkgs/pkgs/build-support/snap/example-firefox.nix
new file mode 100644
index 000000000000..d58c98a65a2e
--- /dev/null
+++ b/nixpkgs/pkgs/build-support/snap/example-firefox.nix
@@ -0,0 +1,28 @@
+let
+  inherit (import <nixpkgs> { }) snapTools firefox;
+in snapTools.makeSnap {
+  meta = {
+    name = "nix-example-firefox";
+    summary = firefox.meta.description;
+    architectures = [ "amd64" ];
+    apps.nix-example-firefox = {
+      command = "${firefox}/bin/firefox";
+      plugs = [
+        "pulseaudio"
+        "camera"
+        "browser-support"
+        "avahi-observe"
+        "cups-control"
+        "desktop"
+        "desktop-legacy"
+        "gsettings"
+        "home"
+        "network"
+        "mount-observe"
+        "removable-media"
+        "x11"
+      ];
+    };
+    confinement = "strict";
+  };
+}
diff --git a/nixpkgs/pkgs/build-support/snap/example-hello.nix b/nixpkgs/pkgs/build-support/snap/example-hello.nix
new file mode 100644
index 000000000000..123da80c5477
--- /dev/null
+++ b/nixpkgs/pkgs/build-support/snap/example-hello.nix
@@ -0,0 +1,12 @@
+let
+  inherit (import <nixpkgs> { }) snapTools hello;
+in snapTools.makeSnap {
+  meta = {
+    name = "hello";
+    summary = hello.meta.description;
+    description = hello.meta.longDescription;
+    architectures = [ "amd64" ];
+    confinement = "strict";
+    apps.hello.command = "${hello}/bin/hello";
+  };
+}
diff --git a/nixpkgs/pkgs/build-support/snap/make-snap.nix b/nixpkgs/pkgs/build-support/snap/make-snap.nix
new file mode 100644
index 000000000000..cef7500bcbaf
--- /dev/null
+++ b/nixpkgs/pkgs/build-support/snap/make-snap.nix
@@ -0,0 +1,84 @@
+{
+  runCommand, squashfsTools, closureInfo, lib, jq, writeText
+}:
+
+{
+  # The meta parameter is the contents of the `snap.yaml`, NOT the
+  # `snapcraft.yaml`.
+  #
+  # - `snap.yaml` is what is inside of the final Snap,
+  # - `snapcraft.yaml` is used by `snapcraft` to build snaps
+  #
+  # Since we skip the `snapcraft` tool, we skip the `snapcraft.yaml`
+  # file. For more information:
+  #
+  #   https://docs.snapcraft.io/snap-format
+  #
+  # Note: unsquashfs'ing an existing snap from the store can be helpful
+  # for determining what you you're missing.
+  #
+  meta
+}: let
+    snap_yaml = let
+      # Validate the snap's meta contains a name.
+      # Also: automatically set the `base` parameter and the layout for
+      # the `/nix` bind.
+      validate = { name, ... } @ args:
+        args // {
+          # Combine the provided arguments with the required options.
+
+          # base: built from https://github.com/NixOS/snapd-nix-base
+          # and published as The NixOS Foundation on the Snapcraft store.
+          base = "nix-base";
+          layout = (args.layout or {}) // {
+            # Bind mount the Snap's root nix directory to `/nix` in the
+            # execution environment's filesystem namespace.
+            "/nix".bind = "$SNAP/nix";
+          };
+        };
+    in writeText "snap.yaml"
+      (builtins.toJSON (validate meta));
+
+  # These are specifically required by snapd, so don't change them
+  # unless you've verified snapcraft / snapd can handle them. Best bet
+  # is to just mirror this list against how snapcraft creates images.
+  # from: https://github.com/snapcore/snapcraft/blob/b88e378148134383ffecf3658e3a940b67c9bcc9/snapcraft/internal/lifecycle/_packer.py#L96-L98
+  mksquashfs_args = [
+    "-noappend" "-comp" "xz" "-no-xattrs" "-no-fragments"
+
+    # Note: We want -all-root every time, since all the files are
+    # owned by root anyway. This is true for Nix, but not true for
+    # other builds.
+    # from: https://github.com/snapcore/snapcraft/blob/b88e378148134383ffecf3658e3a940b67c9bcc9/snapcraft/internal/lifecycle/_packer.py#L100
+    "-all-root"
+  ];
+
+in runCommand "squashfs.img" {
+  nativeBuildInputs = [ squashfsTools jq ];
+
+  closureInfo = closureInfo {
+    rootPaths = [ snap_yaml ];
+  };
+} ''
+  root=$PWD/root
+  mkdir $root
+
+  (
+    # Put the snap.yaml in to `/meta/snap.yaml`, setting the version
+    # to the hash part of the store path
+    mkdir $root/meta
+    version=$(echo $out | cut -d/ -f4 | cut -d- -f1)
+    cat ${snap_yaml} | jq  ". + { version: \"$version\" }" \
+      > $root/meta/snap.yaml
+  )
+
+  (
+    # Copy the store closure in to the root
+    mkdir -p $root/nix/store
+    cat $closureInfo/store-paths | xargs -I{} cp -r {} $root/nix/store/
+  )
+
+  # Generate the squashfs image.
+  mksquashfs $root $out \
+    ${lib.concatStringsSep " " mksquashfs_args}
+''
diff --git a/nixpkgs/pkgs/build-support/trivial-builders.nix b/nixpkgs/pkgs/build-support/trivial-builders.nix
index b66c1d9e4d15..5706a98f6008 100644
--- a/nixpkgs/pkgs/build-support/trivial-builders.nix
+++ b/nixpkgs/pkgs/build-support/trivial-builders.nix
@@ -143,7 +143,7 @@ rec {
    * Automatically includes interpreter above the contents passed.
    *
    * Example:
-   * # Writes my-file to /nix/store/<store path>/my-file and makes executable.
+   * # Writes my-file to /nix/store/<store path> and makes executable.
    * writeShellScript "my-file"
    *   ''
    *   Contents of File