nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 buildDotnetModule,
3 emptyDirectory,
4 fetchNupkg,
5 dotnet-sdk,
6 lib,
7}:
8
9fnOrAttrs:
10
11buildDotnetModule (
12 finalAttrs:
13 (
14 {
15 pname,
16 version,
17 # Name of the nuget package to install, if different from pname
18 nugetName ? pname,
19 # Hash of the nuget package to install, will be given on first build
20 # nugetHash uses SRI hash and should be preferred
21 nugetHash ? "",
22 nugetSha256 ? "",
23 # Additional nuget deps needed by the tool package
24 nugetDeps ? (_: [ ]),
25 # Executables to wrap into `$out/bin`, same as in `buildDotnetModule`, but with
26 # a default of `pname` instead of null, to avoid auto-wrapping everything
27 executables ? pname,
28 # The dotnet runtime to use, dotnet tools need a full SDK to function
29 dotnet-runtime ? dotnet-sdk,
30 ...
31 }@args:
32 let
33 nupkg = fetchNupkg {
34 pname = nugetName;
35 inherit version;
36 sha256 = nugetSha256;
37 hash = nugetHash;
38 installable = true;
39 };
40 in
41 args
42 // {
43 inherit
44 pname
45 version
46 dotnet-runtime
47 executables
48 ;
49
50 src = emptyDirectory;
51
52 buildInputs = [ nupkg ];
53
54 dotnetGlobalTool = true;
55
56 useDotnetFromEnv = true;
57
58 dontBuild = true;
59
60 installPhase = ''
61 runHook preInstall
62
63 dotnet tool install --tool-path $out/lib/${pname} ${nugetName} --version ${version}
64
65 # remove files that contain nix store paths to temp nuget sources we made
66 find $out -name 'project.assets.json' -delete
67 find $out -name '.nupkg.metadata' -delete
68
69 runHook postInstall
70 '';
71
72 passthru = {
73 updateScript = ./update.sh;
74 nupkg = nupkg;
75 }
76 // args.passthru or { };
77 }
78 )
79 (if lib.isFunction fnOrAttrs then fnOrAttrs finalAttrs else fnOrAttrs)
80)