nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 fetchurl,
4 buildDotnetPackage,
5 unzip,
6}:
7
8attrs@{
9 pname,
10 version,
11 url ? "https://www.nuget.org/api/v2/package/${pname}/${version}",
12 sha256 ? "",
13 hash ? "",
14 md5 ? "",
15 ...
16}:
17if md5 != "" then
18 throw "fetchnuget does not support md5 anymore, please use 'hash' attribute with SRI hash: ${
19 lib.generators.toPretty { } attrs
20 }"
21# This is also detected in fetchurl, but we just throw here to avoid confusion
22else if (sha256 != "" && hash != "") then
23 throw "multiple hashes passed to fetchNuGet: ${lib.generators.toPretty { } url}"
24else
25 buildDotnetPackage (
26 {
27 src = fetchurl {
28 inherit url sha256 hash;
29 name = "${pname}.${version}.zip";
30 };
31
32 sourceRoot = ".";
33
34 nativeBuildInputs = [ unzip ];
35
36 dontBuild = true;
37
38 preInstall = ''
39 function traverseRename () {
40 for e in *
41 do
42 t="$(echo "$e" | sed -e "s/%20/\ /g" -e "s/%2B/+/g")"
43 [ "$t" != "$e" ] && mv -vn "$e" "$t"
44 if [ -d "$t" ]
45 then
46 cd "$t"
47 traverseRename
48 cd ..
49 fi
50 done
51 }
52
53 traverseRename
54 '';
55 }
56 // attrs
57 )