discordchatexporter-cli: use buildDotnetModule

This commit is contained in:
IvarWithoutBones 2021-09-23 19:44:06 +02:00
parent 84cb383424
commit e93d52e69e

View File

@ -1,11 +1,12 @@
{ lib, stdenv, fetchFromGitHub, fetchurl, linkFarmFromDrvs, makeWrapper, autoPatchelfHook
, dotnet-sdk_5, dotnetPackages, dotnetCorePackages, cacert
{ lib
, stdenv
, buildDotnetModule
, fetchFromGitHub
, autoPatchelfHook
, dotnetCorePackages
}:
let
projectFile = "DiscordChatExporter.Cli/DiscordChatExporter.Cli.csproj";
in
stdenv.mkDerivation rec {
buildDotnetModule rec {
pname = "discordchatexporter-cli";
version = "2.30.1";
@ -16,66 +17,13 @@ stdenv.mkDerivation rec {
sha256 = "JSYIhd+DNVOKseHtWNNChECR5hKr+ntu1Yyqtnlg8rM=";
};
nativeBuildInputs = [ dotnet-sdk_5 dotnetPackages.Nuget cacert makeWrapper autoPatchelfHook ];
projectFile = "DiscordChatExporter.Cli/DiscordChatExporter.Cli.csproj";
dotnet-runtime = dotnetCorePackages.netcore_3_1;
nugetDeps = ./deps.nix;
nativeBuildInputs = [ autoPatchelfHook ];
buildInputs = [ stdenv.cc.cc.lib ];
nugetDeps = linkFarmFromDrvs "${pname}-nuget-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;
};
});
configurePhase = ''
runHook preConfigure
export HOME=$(mktemp -d)
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_NOLOGO=1
nuget sources Add -Name nixos -Source "$PWD/nixos"
nuget init "$nugetDeps" "$PWD/nixos"
# FIXME: https://github.com/NuGet/Home/issues/4413
mkdir -p $HOME/.nuget/NuGet
cp $HOME/.config/NuGet/NuGet.Config $HOME/.nuget/NuGet
dotnet restore --source "$PWD/nixos" ${projectFile}
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
dotnet build ${projectFile} \
--no-restore \
--configuration Release \
-p:Version=${version}
runHook postBuild
'';
installPhase = ''
runHook preInstall
dotnet publish ${projectFile} \
--no-build \
--configuration Release \
--no-self-contained \
--output $out/lib/${pname}
shopt -s extglob
makeWrapper $out/lib/${pname}/DiscordChatExporter.Cli $out/bin/discordchatexporter-cli \
--set DOTNET_ROOT "${dotnetCorePackages.sdk_3_1}"
runHook postInstall
'';
# Strip breaks the executable.
dontStrip = true;
meta = with lib; {
description = "A tool to export Discord chat logs to a file";
homepage = "https://github.com/Tyrrrz/DiscordChatExporter";