Merge pull request #154677 from IvarWithoutBones/dotnetModule-installphase

buildDotnetModule: wrap executables in preFixup
This commit is contained in:
Pavol Rusnak 2022-01-16 15:22:54 +01:00 committed by GitHub
commit 5c32667d6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 37 additions and 37 deletions

View File

@ -84,7 +84,7 @@ To package Dotnet applications, you can use `buildDotnetModule`. This has simila
<ProjectReference Include="../foo/bar.fsproj" />
<PackageReference Include="bar" Version="*" Condition=" '$(ContinuousIntegrationBuild)'=='true' "/>
```
* `executables` is used to specify which executables get wrapped to `$out/bin`, relative to `$out/lib/$pname`. If this is unset, all executables generated will get installed. If you do not want to install any, set this to `[]`.
* `executables` is used to specify which executables get wrapped to `$out/bin`, relative to `$out/lib/$pname`. If this is unset, all executables generated will get installed. If you do not want to install any, set this to `[]`. This gets done in the `preFixup` phase.
* `runtimeDeps` is used to wrap libraries into `LD_LIBRARY_PATH`. This is how dotnet usually handles runtime dependencies.
* `buildType` is used to change the type of build. Possible values are `Release`, `Debug`, etc. By default, this is set to `Release`.
* `dotnet-sdk` is useful in cases where you need to change what dotnet SDK is being used.

View File

@ -26,7 +26,7 @@ buildDotnetModule rec {
makeWrapperArgs+=(--run "cd $out/lib/btcpayserver")
'';
postInstall = ''
postFixup = ''
mv $out/bin/{BTCPayServer,btcpayserver}
'';

View File

@ -17,7 +17,7 @@ buildDotnetModule rec {
dotnet-sdk = dotnetCorePackages.sdk_3_1;
dotnet-runtime = dotnetCorePackages.aspnetcore_3_1;
postInstall = ''
postFixup = ''
mv $out/bin/{NBXplorer,nbxplorer}
'';

View File

@ -36,7 +36,7 @@ buildDotnetModule rec {
)
'';
postInstall = ''
postFixup = ''
mv $out/bin/WalletWasabi.Backend $out/bin/WasabiBackend
'';

View File

@ -19,6 +19,7 @@ buildDotnetModule rec {
];
runtimeDeps = [ gtk3 ];
buildInputs = runtimeDeps;
dotnet-sdk = dotnetCorePackages.sdk_6_0;
dotnet-runtime = dotnetCorePackages.runtime_6_0;
@ -39,16 +40,7 @@ buildDotnetModule rec {
sha256 = "sha256-iOKJPB2bI/GjeDxzG7r6ew7SGIzgrJTcRXhEYzOpC9k=";
};
# FIXME: this should be propagated by wrapGAppsHook already, however for some
# reason it is not working. Maybe a bug in buildDotnetModule?
preInstall = ''
gappsWrapperArgs+=(
--prefix XDG_DATA_DIRS : "${gtk3}/share/gsettings-schemas/${gtk3.name}"
--set GDK_PIXBUF_MODULE_FILE ${librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache
)
'';
postInstall = ''
postFixup = ''
# Rename the binary
mv $out/bin/Pinta $out/bin/pinta
@ -76,12 +68,12 @@ buildDotnetModule rec {
--replace _Keywords Keywords
'';
meta = {
meta = with lib; {
homepage = "https://www.pinta-project.com/";
description = "Drawing/editing program modeled after Paint.NET";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ thiagokokada ];
platforms = with lib.platforms; linux;
license = licenses.mit;
maintainers = with maintainers; [ thiagokokada ];
platforms = with platforms; linux;
mainProgram = "pinta";
};
}

View File

@ -224,7 +224,7 @@ let
"''${dotnetInstallFlags[@]}" \
"''${dotnetFlags[@]}"
done
'' + (lib.optionalString packNupkg ''
'' + lib.optionalString packNupkg ''
for project in ''${projectFile[@]}; do
dotnet pack "$project" \
-p:ContinuousIntegrationBuild=true \
@ -235,16 +235,24 @@ let
"''${dotnetPackFlags[@]}" \
"''${dotnetFlags[@]}"
done
'') + (if executables != null then ''
for executable in $executables; do
'' + ''
runHook postInstall
'';
preFixup = ''
_wrapDotnetProgram() {
makeWrapper "$1" "$out/bin/$(basename "$executable")" \
--set DOTNET_ROOT "${dotnet-runtime}" \
--suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDeps}" \
"''${gappsWrapperArgs[@]}" \
"''${makeWrapperArgs[@]}"
}
'' + (if executables != null then ''
for executable in ''${executables[@]}; do
execPath="$out/lib/${args.pname}/$executable"
if [[ -f "$execPath" && -x "$execPath" ]]; then
makeWrapper "$execPath" "$out/bin/$(basename "$executable")" \
--set DOTNET_ROOT "${dotnet-runtime}" \
--suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDeps}" \
"''${gappsWrapperArgs[@]}" \
"''${makeWrapperArgs[@]}"
_wrapDotnetProgram $execPath
else
echo "Specified binary \"$executable\" is either not an executable, or does not exist!"
exit 1
@ -253,16 +261,10 @@ let
'' else ''
for executable in $out/lib/${args.pname}/*; do
if [[ -f "$executable" && -x "$executable" && "$executable" != *"dll"* ]]; then
makeWrapper "$executable" "$out/bin/$(basename "$executable")" \
--set DOTNET_ROOT "${dotnet-runtime}" \
--suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDeps}" \
"''${gappsWrapperArgs[@]}" \
"''${makeWrapperArgs[@]}"
_wrapDotnetProgram $executable
fi
done
'') + ''
runHook postInstall
'';
'');
});
in
package

View File

@ -1,7 +1,7 @@
{ lib, buildDotnetModule, fetchFromGitHub, makeDesktopItem, copyDesktopItems
, libX11, libgdiplus, ffmpeg
, SDL2_mixer, openal, libsoundio, sndio, pulseaudio
, gtk3, gobject-introspection, gdk-pixbuf, wrapGAppsHook
, gtk3, gdk-pixbuf, wrapGAppsHook
}:
buildDotnetModule rec {
@ -27,7 +27,10 @@ buildDotnetModule rec {
nativeBuildInputs = [
copyDesktopItems
wrapGAppsHook
gobject-introspection
];
buildInputs = [
gtk3
gdk-pixbuf
];
@ -78,6 +81,7 @@ buildDotnetModule rec {
changelog = "https://github.com/Ryujinx/Ryujinx/wiki/Changelog";
maintainers = [ maintainers.ivar ];
platforms = [ "x86_64-linux" ];
mainProgram = "Ryujinx";
};
passthru.updateScript = ./updater.sh;
}

View File

@ -68,7 +68,7 @@ buildDotnetModule rec {
"OpenTabletDriver.Tests.PluginRepositoryTest.ExpandRepositoryTarball"
];
postInstall = ''
postFixup = ''
# Give a more "*nix" name to the binaries
mv $out/bin/OpenTabletDriver.Console $out/bin/otd
mv $out/bin/OpenTabletDriver.Daemon $out/bin/otd-daemon

View File

@ -41,6 +41,7 @@ buildDotnetModule rec {
buildInputs = [
stdenv.cc.cc.lib
fontconfig
gtk3
];
runtimeDeps = [
@ -58,5 +59,6 @@ buildDotnetModule rec {
homepage = "https://github.com/trippsc2/OpenTracker";
license = licenses.mit;
maintainers = [ maintainers.ivar ];
mainProgram = "OpenTracker";
};
}