Merge pull request #142218 from IvarWithoutBones/use/nbxporer-buildDotnetModule

{btcpayserver,nbxplorer}: use buildDotnetModule
This commit is contained in:
Pavol Rusnak 2021-10-25 10:21:49 +02:00 committed by GitHub
commit 8e18c70837
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 75 deletions

View File

@ -1,19 +1,7 @@
{ lib, stdenv, fetchFromGitHub, fetchurl, linkFarmFromDrvs, makeWrapper,
dotnetPackages, dotnetCorePackages, altcoinSupport ? false
}:
{ lib, buildDotnetModule, fetchFromGitHub, dotnetCorePackages
, altcoinSupport ? false }:
let
deps = import ./deps.nix {
fetchNuGet = { name, version, sha256 }: fetchurl {
name = "nuget-${name}-${version}.nupkg";
url = "https://www.nuget.org/api/v2/package/${name}/${version}";
inherit sha256;
};
};
dotnetSdk = dotnetCorePackages.sdk_3_1;
in
stdenv.mkDerivation rec {
buildDotnetModule rec {
pname = "btcpayserver";
version = "1.2.4";
@ -24,35 +12,29 @@ stdenv.mkDerivation rec {
sha256 = "sha256-vjNJ08twsJ036TTFF6srOGshDpP7ZwWCGN0XjrtFT/g=";
};
nativeBuildInputs = [ dotnetSdk dotnetPackages.Nuget makeWrapper ];
projectFile = "BTCPayServer/BTCPayServer.csproj";
nugetDeps = ./deps.nix;
buildPhase = ''
export HOME=$TMP/home
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
dotnet-sdk = dotnetCorePackages.sdk_3_1;
dotnet-runtime = dotnetCorePackages.aspnetcore_3_1;
nuget sources Add -Name tmpsrc -Source $TMP/nuget
nuget init ${linkFarmFromDrvs "deps" deps} $TMP/nuget
dotnet restore --source $TMP/nuget ${lib.optionalString altcoinSupport ''/p:Configuration="Altcoins-Release"''} BTCPayServer/BTCPayServer.csproj
dotnet publish --no-restore --output $out/share/$pname ${lib.optionalString altcoinSupport "-c Altcoins-Release"} BTCPayServer/BTCPayServer.csproj
'';
dotnetFlags = lib.optionals altcoinSupport [ "/p:Configuration=Altcoins-Release" ];
# btcpayserver requires the publish directory as its working dir
# https://github.com/btcpayserver/btcpayserver/issues/1894
installPhase = ''
makeWrapper $out/share/$pname/BTCPayServer $out/bin/$pname \
--set DOTNET_ROOT "${dotnetSdk}" \
--run "cd $out/share/$pname"
preInstall = ''
makeWrapperArgs+=(--run "cd $out/lib/btcpayserver")
'';
dontStrip = true;
postInstall = ''
mv $out/bin/{BTCPayServer,btcpayserver}
'';
meta = with lib; {
description = "Self-hosted, open-source cryptocurrency payment processor";
homepage = "https://btcpayserver.org";
maintainers = with maintainers; [ kcalvinalvin earvstedt ];
license = lib.licenses.mit;
platforms = lib.platforms.linux;
license = licenses.mit;
platforms = platforms.linux;
};
}

View File

@ -1,19 +1,6 @@
{ lib, stdenv, fetchFromGitHub, fetchurl, linkFarmFromDrvs, makeWrapper,
dotnetPackages, dotnetCorePackages
}:
{ lib, buildDotnetModule, fetchFromGitHub, dotnetCorePackages }:
let
deps = import ./deps.nix {
fetchNuGet = { name, version, sha256 }: fetchurl {
name = "nuget-${name}-${version}.nupkg";
url = "https://www.nuget.org/api/v2/package/${name}/${version}";
inherit sha256;
};
};
dotnetSdk = dotnetCorePackages.sdk_3_1;
in
stdenv.mkDerivation rec {
buildDotnetModule rec {
pname = "nbxplorer";
version = "2.2.11";
@ -24,31 +11,20 @@ stdenv.mkDerivation rec {
sha256 = "sha256-ZDqzkANGMdvv3e5gWCYcacUYKLJRquXRHLr8RAzT9hY=";
};
nativeBuildInputs = [ dotnetSdk dotnetPackages.Nuget makeWrapper ];
projectFile = "NBXplorer/NBXplorer.csproj";
nugetDeps = ./deps.nix;
buildPhase = ''
export HOME=$TMP/home
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
dotnet-sdk = dotnetCorePackages.sdk_3_1;
dotnet-runtime = dotnetCorePackages.aspnetcore_3_1;
nuget sources Add -Name tmpsrc -Source $TMP/nuget
nuget init ${linkFarmFromDrvs "deps" deps} $TMP/nuget
dotnet restore --source $TMP/nuget NBXplorer/NBXplorer.csproj
dotnet publish --no-restore --output $out/share/$pname -c Release NBXplorer/NBXplorer.csproj
postInstall = ''
mv $out/bin/{NBXplorer,nbxplorer}
'';
installPhase = ''
makeWrapper $out/share/$pname/NBXplorer $out/bin/$pname \
--set DOTNET_ROOT "${dotnetSdk}"
'';
dontStrip = true;
meta = with lib; {
description = "Minimalist UTXO tracker for HD Cryptocurrency Wallets";
maintainers = with maintainers; [ kcalvinalvin earvstedt ];
license = lib.licenses.mit;
platforms = lib.platforms.linux;
license = licenses.mit;
platforms = platforms.linux;
};
}

View File

@ -51,6 +51,8 @@ let
});
package = stdenv.mkDerivation (args // {
inherit buildType;
nativeBuildInputs = args.nativeBuildInputs or [] ++ [ dotnet-sdk dotnetPackages.Nuget cacert makeWrapper ];
# Stripping breaks the executable
@ -71,7 +73,7 @@ let
mkdir -p $HOME/.nuget/NuGet
cp $HOME/.config/NuGet/NuGet.Config $HOME/.nuget/NuGet
dotnet restore ${lib.escapeShellArg projectFile} \
dotnet restore "$projectFile" \
${lib.optionalString (!enableParallelBuilding) "--disable-parallel"} \
-p:ContinuousIntegrationBuild=true \
-p:Deterministic=true \
@ -85,13 +87,13 @@ let
buildPhase = args.buildPhase or ''
runHook preBuild
dotnet build ${lib.escapeShellArg projectFile} \
dotnet build "$projectFile" \
-maxcpucount:${if enableParallelBuilding then "$NIX_BUILD_CORES" else "1"} \
-p:BuildInParallel=${if enableParallelBuilding then "true" else "false"} \
-p:ContinuousIntegrationBuild=true \
-p:Deterministic=true \
-p:Version=${args.version} \
--configuration ${buildType} \
--configuration "$buildType" \
--no-restore \
"''${dotnetBuildFlags[@]}" \
"''${dotnetFlags[@]}"
@ -102,17 +104,17 @@ let
installPhase = args.installPhase or ''
runHook preInstall
dotnet publish ${lib.escapeShellArg projectFile} \
dotnet publish "$projectFile" \
-p:ContinuousIntegrationBuild=true \
-p:Deterministic=true \
--output $out/lib/${args.pname} \
--configuration ${buildType} \
--configuration "$buildType" \
--no-build \
--no-self-contained \
"''${dotnetInstallFlags[@]}" \
"''${dotnetFlags[@]}"
'' + (if executables != null then ''
for executable in ''${executables}; do
for executable in $executables; do
execPath="$out/lib/${args.pname}/$executable"
if [[ -f "$execPath" && -x "$execPath" ]]; then
@ -120,7 +122,7 @@ let
--set DOTNET_ROOT "${dotnet-runtime}" \
--suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDeps}" \
"''${gappsWrapperArgs[@]}" \
''${makeWrapperArgs}
"''${makeWrapperArgs[@]}"
else
echo "Specified binary \"$executable\" is either not an executable, or does not exist!"
exit 1
@ -133,7 +135,7 @@ let
--set DOTNET_ROOT "${dotnet-runtime}" \
--suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDeps}" \
"''${gappsWrapperArgs[@]}" \
''${makeWrapperArgs}
"''${makeWrapperArgs[@]}"
fi
done
'') + ''