Files
nixpkgs/pkgs/build-support/dotnet/build-dotnet-global-tool/default.nix
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

81 lines
1.8 KiB
Nix

{
buildDotnetModule,
emptyDirectory,
fetchNupkg,
dotnet-sdk,
lib,
}:
fnOrAttrs:
buildDotnetModule (
finalAttrs:
(
{
pname,
version,
# Name of the nuget package to install, if different from pname
nugetName ? pname,
# Hash of the nuget package to install, will be given on first build
# nugetHash uses SRI hash and should be preferred
nugetHash ? "",
nugetSha256 ? "",
# Additional nuget deps needed by the tool package
nugetDeps ? (_: [ ]),
# Executables to wrap into `$out/bin`, same as in `buildDotnetModule`, but with
# a default of `pname` instead of null, to avoid auto-wrapping everything
executables ? pname,
# The dotnet runtime to use, dotnet tools need a full SDK to function
dotnet-runtime ? dotnet-sdk,
...
}@args:
let
nupkg = fetchNupkg {
pname = nugetName;
inherit version;
sha256 = nugetSha256;
hash = nugetHash;
installable = true;
};
in
args
// {
inherit
pname
version
dotnet-runtime
executables
;
src = emptyDirectory;
buildInputs = [ nupkg ];
dotnetGlobalTool = true;
useDotnetFromEnv = true;
dontBuild = true;
installPhase = ''
runHook preInstall
dotnet tool install --tool-path $out/lib/${pname} ${nugetName} --version ${version}
# remove files that contain nix store paths to temp nuget sources we made
find $out -name 'project.assets.json' -delete
find $out -name '.nupkg.metadata' -delete
runHook postInstall
'';
passthru = {
updateScript = ./update.sh;
nupkg = nupkg;
}
// args.passthru or { };
}
)
(if lib.isFunction fnOrAttrs then fnOrAttrs finalAttrs else fnOrAttrs)
)