summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorVladimír Čunát <v@cunat.cz>2022-05-01 14:26:52 +0200
committerVladimír Čunát <v@cunat.cz>2022-05-01 14:26:52 +0200
commitcec6e7362c864813ab21453b3e078728cf7223c7 (patch)
treeb9cb8ab6926ee34b5d73032c113d19c587c66507 /pkgs/build-support
parentc480cc28958dd852aa1acb29dee80d5324b3571e (diff)
parentdf738d5143b711c87d0c0b9a1ed15475f404d59c (diff)
downloadnixpkgs-cec6e7362c864813ab21453b3e078728cf7223c7.tar
nixpkgs-cec6e7362c864813ab21453b3e078728cf7223c7.tar.gz
nixpkgs-cec6e7362c864813ab21453b3e078728cf7223c7.tar.bz2
nixpkgs-cec6e7362c864813ab21453b3e078728cf7223c7.tar.lz
nixpkgs-cec6e7362c864813ab21453b3e078728cf7223c7.tar.xz
nixpkgs-cec6e7362c864813ab21453b3e078728cf7223c7.tar.zst
nixpkgs-cec6e7362c864813ab21453b3e078728cf7223c7.zip
Merge branch 'master' into staging-next-2022-04-23
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/dotnet/build-dotnet-module/default.nix15
-rw-r--r--pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-build-hook.sh3
-rw-r--r--pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-check-hook.sh3
-rw-r--r--pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-configure-hook.sh6
-rw-r--r--pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-fixup-hook.sh9
-rw-r--r--pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh3
-rw-r--r--pkgs/build-support/dotnet/make-nuget-source/default.nix44
-rw-r--r--pkgs/build-support/dotnet/nuget-to-nix/default.nix28
-rwxr-xr-xpkgs/build-support/dotnet/nuget-to-nix/nuget-to-nix.sh4
9 files changed, 80 insertions, 35 deletions
diff --git a/pkgs/build-support/dotnet/build-dotnet-module/default.nix b/pkgs/build-support/dotnet/build-dotnet-module/default.nix
index b5651d72a92..6e7388a4a75 100644
--- a/pkgs/build-support/dotnet/build-dotnet-module/default.nix
+++ b/pkgs/build-support/dotnet/build-dotnet-module/default.nix
@@ -74,13 +74,16 @@ let
     inherit dotnet-sdk dotnet-test-sdk disabledTests nuget-source dotnet-runtime runtimeDeps buildType;
   }) dotnetConfigureHook dotnetBuildHook dotnetCheckHook dotnetInstallHook dotnetFixupHook;
 
-  _nugetDeps = mkNugetDeps { name = "${name}-nuget-deps"; nugetDeps = import nugetDeps; };
-  _localDeps = linkFarmFromDrvs "${name}-local-nuget-deps" projectReferences;
+  localDeps = if (projectReferences != [])
+    then linkFarmFromDrvs "${name}-project-references" projectReferences
+    else null;
+
+  _nugetDeps = mkNugetDeps { inherit name; nugetDeps = import nugetDeps; };
 
   nuget-source = mkNugetSource {
-    name = "${args.pname}-nuget-source";
-    description = "A Nuget source with the dependencies for ${args.pname}";
-    deps = [ _nugetDeps _localDeps ];
+    name = "${name}-nuget-source";
+    description = "A Nuget source with the dependencies for ${name}";
+    deps = [ _nugetDeps ] ++ lib.optional (localDeps != null) localDeps;
   };
 
 in stdenvNoCC.mkDerivation (args // {
@@ -103,6 +106,8 @@ in stdenvNoCC.mkDerivation (args // {
   dontWrapGApps = args.dontWrapGApps or true;
 
   passthru = {
+    inherit nuget-source;
+
     fetch-deps = writeScript "fetch-${pname}-deps" ''
       set -euo pipefail
       cd "$(dirname "''${BASH_SOURCE[0]}")"
diff --git a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-build-hook.sh b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-build-hook.sh
index a1dc80a77fd..0e2650da51c 100644
--- a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-build-hook.sh
+++ b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-build-hook.sh
@@ -1,4 +1,5 @@
-declare -a projectFile testProjectFile dotnetBuildFlags dotnetFlags
+# inherit arguments from derivation
+dotnetBuildFlags=( ${dotnetBuildFlags[@]-} )
 
 dotnetBuildHook() {
     echo "Executing dotnetBuildHook"
diff --git a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-check-hook.sh b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-check-hook.sh
index e3098908fe2..6b3deaa52f9 100644
--- a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-check-hook.sh
+++ b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-check-hook.sh
@@ -1,4 +1,5 @@
-declare -a testProjectFile dotnetTestFlags dotnetFlags
+# inherit arguments from derivation
+dotnetTestFlags=( ${dotnetTestFlags[@]-} )
 
 dotnetCheckHook() {
     echo "Executing dotnetCheckHook"
diff --git a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-configure-hook.sh b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-configure-hook.sh
index 59daacbac0e..f8ba8b8df2e 100644
--- a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-configure-hook.sh
+++ b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-configure-hook.sh
@@ -1,4 +1,8 @@
-declare -a projectFile testProjectFile dotnetRestoreFlags dotnetFlags
+declare -a projectFile testProjectFile
+
+# inherit arguments from derivation
+dotnetFlags=( ${dotnetFlags[@]-} )
+dotnetRestoreFlags=( ${dotnetRestoreFlags[@]-} )
 
 dotnetConfigureHook() {
     echo "Executing dotnetConfigureHook"
diff --git a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-fixup-hook.sh b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-fixup-hook.sh
index f8bbb7b1805..675006508f6 100644
--- a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-fixup-hook.sh
+++ b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-fixup-hook.sh
@@ -1,4 +1,5 @@
-declare -a makeWrapperArgs gappsWrapperArgs
+# Inherit arguments from the derivation
+makeWrapperArgs=( ${makeWrapperArgs-} )
 
 # First argument is the executable you want to wrap,
 # the second is the destination for the wrapper.
@@ -15,9 +16,9 @@ wrapDotnetProgram() {
 dotnetFixupHook() {
     echo "Executing dotnetFixupPhase"
 
-    if [ "${executables-}" ]; then
+    if [ "${executables}" ]; then
         for executable in ${executables[@]}; do
-            execPath="$out/lib/${pname-}/$executable"
+            execPath="$out/lib/${pname}/$executable"
 
             if [[ -f "$execPath" && -x "$execPath" ]]; then
                 wrapDotnetProgram "$execPath" "$out/bin/$(basename "$executable")"
@@ -27,7 +28,7 @@ dotnetFixupHook() {
             fi
         done
     else
-        for executable in $out/lib/${pname-}/*; do
+        for executable in $out/lib/${pname}/*; do
             if [[ -f "$executable" && -x "$executable" && "$executable" != *"dll"* ]]; then
                 wrapDotnetProgram "$executable" "$out/bin/$(basename "$executable")"
             fi
diff --git a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh
index ed2c9160cd2..ac9bc873ee9 100644
--- a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh
+++ b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh
@@ -1,4 +1,5 @@
-declare -a projectFile dotnetInstallFlags dotnetFlags
+# inherit arguments from derivation
+dotnetInstallFlags=( ${dotnetInstallFlags[@]-} )
 
 dotnetInstallHook() {
     echo "Executing dotnetInstallHook"
diff --git a/pkgs/build-support/dotnet/make-nuget-source/default.nix b/pkgs/build-support/dotnet/make-nuget-source/default.nix
index 0690a05aa2b..8dc77f3aac0 100644
--- a/pkgs/build-support/dotnet/make-nuget-source/default.nix
+++ b/pkgs/build-support/dotnet/make-nuget-source/default.nix
@@ -1,30 +1,38 @@
 { dotnetPackages, lib, xml2, stdenvNoCC }:
-{ name, description ? "", deps ? [] }:
+
+{ name
+, description ? ""
+, deps ? []
+}:
+
 let
-  _nuget-source = stdenvNoCC.mkDerivation rec {
+  nuget-source = stdenvNoCC.mkDerivation rec {
     inherit name;
-    meta.description = description;
 
+    meta.description = description;
     nativeBuildInputs = [ dotnetPackages.Nuget xml2 ];
+
     buildCommand = ''
       export HOME=$(mktemp -d)
       mkdir -p $out/{lib,share}
 
-      nuget sources Add -Name nixos -Source "$out/lib"
-      ${ lib.concatMapStringsSep "\n" (dep:
-          ''nuget init "${dep}" "$out/lib"''
-        ) deps }
+      ${lib.concatMapStringsSep "\n" (dep: ''
+        nuget init "${dep}" "$out/lib"
+      '') deps}
 
-      # Generates a list of all unique licenses' spdx ids.
+      # Generates a list of all licenses' spdx ids, if available.
+      # Note that this currently ignores any license provided in plain text (e.g. "LICENSE.txt")
       find "$out/lib" -name "*.nuspec" -exec sh -c \
-        "xml2 < {} | grep "license=" | cut -d'=' -f2" \; | sort -u > $out/share/licenses
+        "NUSPEC=\$(xml2 < {}) && echo "\$NUSPEC" | grep license/@type=expression | tr -s \  '\n' | grep "license=" | cut -d'=' -f2" \
+      \; | sort -u > $out/share/licenses
     '';
-} // { # This is done because we need data from `$out` for `meta`. We have to use overrides as to not hit infinite recursion.
-  meta.licence = let
-    depLicenses = lib.splitString "\n" (builtins.readFile "${_nuget-source}/share/licenses");
-    getLicence = spdx: lib.filter (license: license.spdxId or null == spdx) (builtins.attrValues lib.licenses);
-  in (lib.flatten (lib.forEach depLicenses (spdx:
-    if (getLicence spdx) != [] then (getLicence spdx) else [] ++ lib.optional (spdx != "") spdx
-  )));
-};
-in _nuget-source
+  } // { # We need data from `$out` for `meta`, so we have to use overrides as to not hit infinite recursion.
+    meta.licence = let
+      depLicenses = lib.splitString "\n" (builtins.readFile "${nuget-source}/share/licenses");
+    in (lib.flatten (lib.forEach depLicenses (spdx:
+      if (spdx != "")
+        then lib.getLicenseFromSpdxId spdx
+        else []
+    )));
+  };
+in nuget-source
diff --git a/pkgs/build-support/dotnet/nuget-to-nix/default.nix b/pkgs/build-support/dotnet/nuget-to-nix/default.nix
index a5fc4e209cd..5267bc24a76 100644
--- a/pkgs/build-support/dotnet/nuget-to-nix/default.nix
+++ b/pkgs/build-support/dotnet/nuget-to-nix/default.nix
@@ -1,5 +1,27 @@
-{ runCommand }:
+{ lib
+, runCommandLocal
+, runtimeShell
+, substituteAll
+, nix
+, coreutils
+, findutils
+, gnused
+}:
 
-runCommand "nuget-to-nix" { preferLocalBuild = true; } ''
-  install -D -m755 ${./nuget-to-nix.sh} $out/bin/nuget-to-nix
+runCommandLocal "nuget-to-nix" {
+  script = substituteAll {
+    src = ./nuget-to-nix.sh;
+    inherit runtimeShell;
+
+    binPath = lib.makeBinPath [
+      nix
+      coreutils
+      findutils
+      gnused
+    ];
+  };
+
+  meta.description = "Convert a nuget packages directory to a lockfile for buildDotnetModule";
+} ''
+  install -Dm755 $script $out/bin/nuget-to-nix
 ''
diff --git a/pkgs/build-support/dotnet/nuget-to-nix/nuget-to-nix.sh b/pkgs/build-support/dotnet/nuget-to-nix/nuget-to-nix.sh
index d2e7882caf6..d9eaa041754 100755
--- a/pkgs/build-support/dotnet/nuget-to-nix/nuget-to-nix.sh
+++ b/pkgs/build-support/dotnet/nuget-to-nix/nuget-to-nix.sh
@@ -1,7 +1,9 @@
-#!/usr/bin/env bash
+#!@runtimeShell@
 
 set -euo pipefail
 
+export PATH="@binPath@"
+
 if [ $# -eq 0 ]; then
   >&2 echo "Usage: $0 [packages directory] > deps.nix"
   exit 1