Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
MattSturgeon committed Jul 31, 2024
1 parent 2a2caa5 commit 803f31a
Showing 1 changed file with 70 additions and 27 deletions.
97 changes: 70 additions & 27 deletions pkgs/by-name/ne/nexusmods-app/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,29 @@
dotnetCorePackages,
fetchFromGitHub,
fontconfig,
glibc,
libICE,
libSM,
libX11,
nexusmods-app,
runCommand,
xdg-utils,
enableUnfree ? false, # Set to true to support RAR format mods
}:
let
_7zzWithOptionalUnfreeRarSupport = _7zz.override { inherit enableUnfree; };

# From https://nexus-mods.github.io/NexusMods.App/developers/Contributing/#for-package-maintainers
# TODO: add DefineConstants support to buildDotnetModule
constants = [
# Tell the app it is a distro package; affects wording in update prompts
"INSTALLATION_METHOD_PACKAGE_MANAGER"

# Don't include upstream's 7zz binary; we use the nixpkgs version
"NEXUSMODS_APP_USE_SYSTEM_EXTRACTOR"
];
in
buildDotnetModule rec {
pname = "nexusmods-app" + lib.strings.optionalString enableUnfree "-unfree";
version = "0.5.3";

Expand All @@ -43,71 +56,101 @@ in
dotnet-sdk = dotnetCorePackages.sdk_8_0;
dotnet-runtime = dotnetCorePackages.runtime_8_0;

preConfigure = ''
substituteInPlace Directory.Build.props \
--replace '</PropertyGroup>' '<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles></PropertyGroup>'
'';
dotnetBuildFlags = [
# From https://github.com/Nexus-Mods/NexusMods.App/blob/v0.5.3/src/NexusMods.App/app.pupnet.conf#L38
"--property:Version=${version}"
"--property:TieredCompilation=true"
"--property:DefineConstants=${lib.strings.concatStringsSep "%3B" constants}"
];

postPatch = ''
# We still need to do this because the tests don't respect INSTALLATION_METHOD_PACKAGE_MANAGER?
ln --force --symbolic "${lib.getExe _7zzWithOptionalUnfreeRarSupport}" src/ArchiveManagement/NexusMods.FileExtractor/runtimes/linux-x64/native/7zz
# for some reason these tests fail (intermittently?) with a zero timestamp
touch tests/NexusMods.UI.Tests/WorkspaceSystem/*.verified.png
# TODO: Should we patch the desktop file here?
'';

makeWrapperArgs = [
"--prefix PATH : ${lib.makeBinPath [ desktop-file-utils ]}"
"--set APPIMAGE $out/bin/${meta.mainProgram}" # Make associating with nxm links work on Linux
# Ensure 7zz is on the PATH
# TODO: is there a better way to do this?
"--prefix PATH : ${
lib.makeBinPath [
_7zzWithOptionalUnfreeRarSupport
xdg-utils
desktop-file-utils
]
}"

# Make associating with nxm links work on Linux
# TODO: is this still needed when we use INSTALLATION_METHOD_PACKAGE_MANAGER?
"--set APPIMAGE ${placeholder "out"}/bin/NexusMods.App"
];

# TODO: is this needed?
buildInputs = [ _7zzWithOptionalUnfreeRarSupport ];

runtimeDeps = [
# TODO: Is this needed here? This only adds to LD_LIBRARY_PATH, not PATH...
_7zzWithOptionalUnfreeRarSupport
# TODO: is this still needed when we use INSTALLATION_METHOD_PACKAGE_MANAGER?
desktop-file-utils
fontconfig
libICE
libSM
libX11
glibc
];

executables = [ nexusmods-app.meta.mainProgram ];
executables = [ "NexusMods.App" ];

doCheck = true;

dotnetTestFlags = [
"--environment=USER=nobody"
(lib.strings.concatStrings [
"--filter="
(lib.strings.concatStrings (
lib.strings.intersperse "&" (
dotnetTestFlags =
let
# NOTE: Can't use `disabledTests` because we have additional category based filters
filters =
[
"Category!=Disabled"
"FlakeyTest!=True"
"RequiresNetworking!=True"
]
++ lib.map (n: "FullyQualifiedName!=${n}") (
[
"Category!=Disabled"
"FlakeyTest!=True"
"RequiresNetworking!=True"
"FullyQualifiedName!=NexusMods.UI.Tests.ImageCacheTests.Test_LoadAndCache_RemoteImage"
"FullyQualifiedName!=NexusMods.UI.Tests.ImageCacheTests.Test_LoadAndCache_ImageStoredFile"
"NexusMods.UI.Tests.ImageCacheTests.Test_LoadAndCache_RemoteImage"
"NexusMods.UI.Tests.ImageCacheTests.Test_LoadAndCache_ImageStoredFile"
]
++ lib.optionals (!enableUnfree) [
"FullyQualifiedName!=NexusMods.Games.FOMOD.Tests.FomodXmlInstallerTests.InstallsFilesSimple_UsingRar"
"NexusMods.Games.FOMOD.Tests.FomodXmlInstallerTests.InstallsFilesSimple_UsingRar"
]
)
))
])
];
);
in
[
"--environment=USER=nobody"
"--filter=${lib.strings.concatStringsSep "&" filters}"
"--property:DefineConstants=${lib.strings.concatStringsSep "%3B" constants}"
];

passthru = {
# FIXME: won't this use the _wrong_ derivation when called with non-default `callPackage` arguments?
# Maybe we can use a fixed-point argument when calling `buildDotnetModule`?
tests = {
serve = runCommand "${pname}-test-serve" { } ''
${nexusmods-app}/bin/${nexusmods-app.meta.mainProgram}
${lib.getExe nexusmods-app}
touch $out
'';
help = runCommand "${pname}-test-help" { } ''
${nexusmods-app}/bin/${nexusmods-app.meta.mainProgram} --help
${lib.getExe nexusmods-app}
touch $out
'';
associate-nxm = runCommand "${pname}-test-associate-nxm" { } ''
${nexusmods-app}/bin/${nexusmods-app.meta.mainProgram} associate-nxm
${lib.getExe nexusmods-app}
touch $out
'';
list-tools = runCommand "${pname}-test-list-tools" { } ''
${nexusmods-app}/bin/${nexusmods-app.meta.mainProgram} list-tools
${lib.getExe nexusmods-app}
touch $out
'';
};
Expand Down

0 comments on commit 803f31a

Please sign in to comment.