-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
buildDotnetModule: allow fetching nuget dependencies at compile time #314990
Draft
purepani
wants to merge
5
commits into
NixOS:master
Choose a base branch
from
purepani:dotnet-module-fetch-impure-deps-new
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+222
−28
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
125d731
buildDotnetModule: allow fetching nuget dependencies at compile time
purepani 5a573fb
buildDotnetModule: Makes build time lockfile generation functional
purepani 5987390
jellyfin: Moves to build-time lockfile generation
purepani 02e7e1c
buildDotnetModule: Changes nugetSha256 in build-dotnet-module to
purepani c4ea389
buildDotnetModules: Removes assertion for project file
purepani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
pkgs/build-support/dotnet/build-dotnet-module/fetch-deps.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{ lib | ||
, buildDotnetModule | ||
, dotnetValidateLockfileHook | ||
, nuget-to-nix | ||
, lockfileSha256 | ||
|
||
, src | ||
, name | ||
, meta | ||
, dotnet-sdk | ||
, projectFile | ||
, testProjectFile | ||
, dotnetFlags | ||
, dotnetRestoreFlags | ||
, enableParallelBuilding | ||
, sdkExclusions | ||
} @ args: | ||
|
||
buildDotnetModule rec { | ||
name = "${args.name}-nuget-lockfile"; | ||
|
||
inherit src dotnet-sdk projectFile testProjectFile dotnetFlags dotnetRestoreFlags enableParallelBuilding; | ||
|
||
nativeBuildInputs = [ | ||
dotnetValidateLockfileHook | ||
(nuget-to-nix.override {inherit dotnet-sdk;}) | ||
]; | ||
|
||
generateLockfile = true; | ||
dontSetNugetSource = true; | ||
dontDotnetFixup = true; | ||
|
||
impureEnvVars = lib.fetchers.proxyImpureEnvVars; | ||
outputHashAlgo = "sha256"; | ||
outputHashMode = "flat"; | ||
outputHash = if (lockfileSha256 != null) | ||
then lockfileSha256 | ||
else ""; # This needs to be set for networking, an empty string prints the "empty hash found" warning | ||
|
||
preConfigure = '' | ||
dotnetRestoreFlags+=( | ||
--packages "$HOME/nuget-pkgs" | ||
) | ||
|
||
echo "Evaluating and fetching Nuget dependencies" | ||
''; | ||
|
||
buildPhase = '' | ||
runHook preBuild | ||
|
||
NUGET_DEPS="$HOME/deps.nix" | ||
echo "Writing lockfile..." | ||
nuget-to-nix "$HOME/nuget-pkgs" "${sdkExclusions}" > "$NUGET_DEPS" | ||
|
||
runHook postBuild | ||
''; | ||
|
||
installPhase = '' | ||
runHook preInstall | ||
|
||
cp "$NUGET_DEPS" $out | ||
echo "Installed lockfile to: $out" | ||
|
||
runHook postInstall | ||
''; | ||
|
||
# This is the last phase that runs before we error out about the hash being wrong | ||
postFixup = lib.optionalString (lockfileSha256 == null) '' | ||
echo "Please set lockfileSha256 to the hash below!" | ||
''; | ||
|
||
meta = { | ||
description = "A lockfile containing the Nuget dependencies for ${name}"; | ||
inherit (args.meta) maintainers platforms; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented out due to making a network call; I believe that telemetry will just need to be disabled with
export DOTNET_CLI_TELEMETRY_OPTOUT=1
now that I think about it.