diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2020-11-28 17:09:12 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2020-11-28 17:09:12 +0000 |
commit | c6617d28ef3762bbd5cb11dd3c56afb778ff42cc (patch) | |
tree | 18fbdfb4783a2e0c5625cdb51606058ca50e2ca8 /pkgs/build-support | |
parent | 29cdd8ae609d107889469610176aa53676382eb1 (diff) | |
parent | 05d95cfe79a69cf690cec5d356b37e29d7d13d18 (diff) |
Merge remote-tracking branch 'upstream/master' into aj-rust-custom-target
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/build-bazel-package/default.nix | 2 | ||||
-rw-r--r-- | pkgs/build-support/libredirect/libredirect.c | 7 | ||||
-rw-r--r-- | pkgs/build-support/make-desktopitem/default.nix | 70 | ||||
-rwxr-xr-x | pkgs/build-support/setup-hooks/move-systemd-user-units.sh | 25 | ||||
-rw-r--r-- | pkgs/build-support/setup-hooks/validate-pkg-config.sh | 3 | ||||
-rw-r--r-- | pkgs/build-support/wrapper-common/utils.bash | 10 | ||||
-rw-r--r-- | pkgs/build-support/writers/default.nix | 7 |
7 files changed, 85 insertions, 39 deletions
diff --git a/pkgs/build-support/build-bazel-package/default.nix b/pkgs/build-support/build-bazel-package/default.nix index 4d22a329e416..10a331bcc9e7 100644 --- a/pkgs/build-support/build-bazel-package/default.nix +++ b/pkgs/build-support/build-bazel-package/default.nix @@ -9,7 +9,7 @@ let in args@{ - name + name ? "${args.pname}-${args.version}" , bazel ? bazelPkg , bazelFlags ? [] , bazelBuildFlags ? [] diff --git a/pkgs/build-support/libredirect/libredirect.c b/pkgs/build-support/libredirect/libredirect.c index e7f74c736ab0..c8d6956a6bfe 100644 --- a/pkgs/build-support/libredirect/libredirect.c +++ b/pkgs/build-support/libredirect/libredirect.c @@ -121,6 +121,13 @@ FILE * fopen(const char * path, const char * mode) return fopen_real(rewrite(path, buf), mode); } +FILE * __nss_files_fopen(const char * path) +{ + FILE * (*__nss_files_fopen_real) (const char *) = dlsym(RTLD_NEXT, "__nss_files_fopen"); + char buf[PATH_MAX]; + return __nss_files_fopen_real(rewrite(path, buf)); +} + FILE * fopen64(const char * path, const char * mode) { FILE * (*fopen64_real) (const char *, const char *) = dlsym(RTLD_NEXT, "fopen64"); diff --git a/pkgs/build-support/make-desktopitem/default.nix b/pkgs/build-support/make-desktopitem/default.nix index 8355a5ad29bc..8e51dc1b8480 100644 --- a/pkgs/build-support/make-desktopitem/default.nix +++ b/pkgs/build-support/make-desktopitem/default.nix @@ -1,50 +1,60 @@ { lib, runCommandLocal, desktop-file-utils }: -{ name +# See https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html +{ name # The name of the desktop file , type ? "Application" , exec , icon ? null , comment ? null -, terminal ? "false" -, desktopName +, terminal ? false +, desktopName # The name of the application , genericName ? null , mimeType ? null , categories ? null , startupNotify ? null -, extraEntries ? null +, extraDesktopEntries ? {} # Extra key-value pairs to add to the [Desktop Entry] section. This may override other values +, extraEntries ? "" # Extra configuration. Will be appended to the end of the file and may thus contain extra sections , fileValidation ? true # whether to validate resulting desktop file. }: let - optionalEntriesList = [{k="Icon"; v=icon;} - {k="Comment"; v=comment;} - {k="GenericName"; v=genericName;} - {k="MimeType"; v=mimeType;} - {k="Categories"; v=categories;} - {k="StartupNotify"; v=startupNotify;}]; + # like builtins.toString, but null -> null instead of null -> "" + nullableToString = value: if value == null then null + else if builtins.isBool value then lib.boolToString value + else builtins.toString value; - valueNotNull = {k, v}: v != null; - entriesToKeep = builtins.filter valueNotNull optionalEntriesList; + # The [Desktop entry] section of the desktop file, as attribute set. + mainSection = { + "Type" = toString type; + "Exec" = nullableToString exec; + "Icon" = nullableToString icon; + "Comment" = nullableToString comment; + "Terminal" = nullableToString terminal; + "Name" = toString desktopName; + "GenericName" = nullableToString genericName; + "MimeType" = nullableToString mimeType; + "Categories" = nullableToString categories; + "StartupNotify" = nullableToString startupNotify; + } // extraDesktopEntries; - mkEntry = {k, v}: k + "=" + v; - optionalEntriesString = lib.concatMapStringsSep "\n" mkEntry entriesToKeep; + # Map all entries to a list of lines + desktopFileStrings = + ["[Desktop Entry]"] + ++ builtins.filter + (v: v != null) + (lib.mapAttrsToList + (name: value: if value != null then "${name}=${value}" else null) + mainSection + ) + ++ (if extraEntries == "" then [] else ["${extraEntries}"]); in runCommandLocal "${name}.desktop" {} - '' + ('' mkdir -p "$out/share/applications" cat > "$out/share/applications/${name}.desktop" <<EOF - [Desktop Entry] - Type=${type} - Exec=${exec} - Terminal=${terminal} - Name=${desktopName} - ${optionalEntriesString} - ${if extraEntries == null then ''EOF'' else '' - ${extraEntries} - EOF''} - - ${lib.optionalString fileValidation '' - echo "Running desktop-file validation" - ${desktop-file-utils}/bin/desktop-file-validate "$out/share/applications/${name}.desktop" - ''} - '' + ${builtins.concatStringsSep "\n" desktopFileStrings} + EOF + '' + lib.optionalString fileValidation '' + echo "Running desktop-file validation" + ${desktop-file-utils}/bin/desktop-file-validate "$out/share/applications/${name}.desktop" + '') diff --git a/pkgs/build-support/setup-hooks/move-systemd-user-units.sh b/pkgs/build-support/setup-hooks/move-systemd-user-units.sh new file mode 100755 index 000000000000..5963d87c7515 --- /dev/null +++ b/pkgs/build-support/setup-hooks/move-systemd-user-units.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +# This setup hook, for each output, moves everything in +# $output/lib/systemd/user to $output/share/systemd/user, and replaces +# $output/lib/systemd/user with a symlink to +# $output/share/systemd/user. + +fixupOutputHooks+=(_moveSystemdUserUnits) + +_moveSystemdUserUnits() { + if [ "${dontMoveSystemdUserUnits:-0}" = 1 ]; then return; fi + if [ ! -e "${prefix:?}/lib/systemd/user" ]; then return; fi + local source="$prefix/lib/systemd/user" + local target="$prefix/share/systemd/user" + echo "moving $source/* to $target" + mkdir -p "$target" + ( + shopt -s dotglob + for i in "$source"/*; do + mv "$i" "$target" + done + ) + rmdir "$source" + ln -s "$target" "$source" +} diff --git a/pkgs/build-support/setup-hooks/validate-pkg-config.sh b/pkgs/build-support/setup-hooks/validate-pkg-config.sh index 54fc9cc122ca..ada1b56760d6 100644 --- a/pkgs/build-support/setup-hooks/validate-pkg-config.sh +++ b/pkgs/build-support/setup-hooks/validate-pkg-config.sh @@ -3,9 +3,8 @@ fixupOutputHooks+=(_validatePkgConfig) _validatePkgConfig() { + local bail=0 for pc in $(find "$prefix" -name '*.pc'); do - local bail=0 - # Do not fail immediately. It's nice to see all errors when # there are multiple pkgconfig files. if ! pkg-config --validate "$pc"; then diff --git a/pkgs/build-support/wrapper-common/utils.bash b/pkgs/build-support/wrapper-common/utils.bash index 8c4680a8e446..d164982b4345 100644 --- a/pkgs/build-support/wrapper-common/utils.bash +++ b/pkgs/build-support/wrapper-common/utils.bash @@ -69,9 +69,13 @@ badPath() { # directory (including the build directory). test \ "$p" != "/dev/null" -a \ - "${p:0:${#NIX_STORE}}" != "$NIX_STORE" -a \ - "${p:0:4}" != "/tmp" -a \ - "${p:0:${#NIX_BUILD_TOP}}" != "$NIX_BUILD_TOP" + "${p#${NIX_STORE}}" = "$p" -a \ + "${p#${NIX_BUILD_TOP}}" = "$p" -a \ + "${p#/tmp}" = "$p" -a \ + "${p#${TMP:-/tmp}}" = "$p" -a \ + "${p#${TMPDIR:-/tmp}}" = "$p" -a \ + "${p#${TEMP:-/tmp}}" = "$p" -a \ + "${p#${TEMPDIR:-/tmp}}" = "$p" } expandResponseParams() { diff --git a/pkgs/build-support/writers/default.nix b/pkgs/build-support/writers/default.nix index 495a56b41974..9c709921d210 100644 --- a/pkgs/build-support/writers/default.nix +++ b/pkgs/build-support/writers/default.nix @@ -1,4 +1,4 @@ -{ pkgs, lib }: +{ pkgs, lib, gawk, gnused, gixy }: with lib; rec { @@ -219,10 +219,11 @@ rec { writeNginxConfig = name: text: pkgs.runCommandLocal name { inherit text; passAsFile = [ "text" ]; + nativeBuildInputs = [ gawk gnused gixy ]; } /* sh */ '' # nginx-config-formatter has an error - https://github.com/1connect/nginx-config-formatter/issues/16 - ${pkgs.gawk}/bin/awk -f ${awkFormatNginx} "$textPath" | ${pkgs.gnused}/bin/sed '/^\s*$/d' > $out - ${pkgs.gixy}/bin/gixy $out + awk -f ${awkFormatNginx} "$textPath" | sed '/^\s*$/d' > $out + gixy $out ''; # writePerl takes a name an attributeset with libraries and some perl sourcecode and |