Commit Graph

182 Commits

Author SHA1 Message Date
Smaug123
45037a9d73
buildDotnetModule: split fetch-deps script to new file
This makes the minimal change to put the script in a new file.
It does not fix the resulting ShellCheck warnings (which would
have been present in the previous version; I've just exposed
them).
2024-07-12 09:53:13 +01:00
David McFarland
691bec7b0e nuget-to-nix: fix hash generation when resolving multiple sources
Fixes: 2280d5c467
2024-07-08 12:14:09 -03:00
aleksana
74597434a7 buildDotNetGlobalTool: add SRI hash support 2024-07-04 20:16:51 +08:00
aleksana
2280d5c467 nuget-to-nix: generate SRI hash instead of sha256 2024-07-04 20:16:51 +08:00
aleksana
c3698a127a mkNugetDeps: add SRI hash support 2024-07-04 20:16:51 +08:00
aleksana
9aee77e045 fetchNuGet: add SRI hash support 2024-07-04 17:33:34 +08:00
Ivan Trubach
4caf9a61f9 buildDotnetModule: convert makeWrapperArgs to an array 2024-06-19 00:34:15 +03:00
David McFarland
b5447275d2
Merge pull request #313005 from tie/dotnet-cross
buildDotnetModule: fix structured attributes support
2024-06-17 09:43:51 -03:00
Alexis Hildebrandt
755b915a15 treewide: Remove indefinite article from meta.description
nix run nixpkgs#silver-searcher -- -G '\.nix$' -0l 'description.*"[Aa]n?' pkgs \
  | xargs -0 nix run nixpkgs#gnused -- -i '' -Ee 's/(description.*")[Aa]n? (.)/\1\U\2/'
2024-06-09 23:07:45 +02:00
Ivan Trubach
f7d8046fb8 buildDotnetModule: fix structured attributes support
This change refactors internal hooks used by buildDotnetModule to
support derivations with structured attributes. Note that this changes
variable names that the internal hooks expect.
2024-05-29 08:45:25 +03:00
Ivan Trubach
cfd1bd6141 buildDotnetModule: remove unnecessary callPackage calls
This change removes no-op callPackage calls and reformats the file with
nixpkgs-fmt.
2024-05-22 03:12:30 +03:00
Ivan Trubach
0e64e645c9 buildDotnetModule: fix cross-compilation and remove dotnet-test-sdk
This change fixes cross-compilation for .NET packages (that are not
using .sln as project files). See relevant comment in the change list
for more details.

In addition to that, it removes dotnet-test-sdk that appears to be
broken, that is, dotnet --list-sdks does not recognize SDKs from PATH,
and when propagated from the check hook it was shadowed by inputs from
preceding hooks.

Note that dotnet-test-sdk used to work when it was introduced in PR
144062, but PR 155257 probably overlooked this case. However, currently
it is not used in Nixpkgs and I think dotnetCorePackages.combinePackages
should cover the intended use case for dotnet-test-sdk.
2024-05-22 03:08:42 +03:00
Ivan Trubach
7877140075 buildDotnetModule: do not run dotnet command using env
There should be no reason to use env here:

1. In places where it is used to run dotnet with environment variables,
   the same can be done with shell syntax.

   For example, `env "FOO=$bar" baz` is equivalent to `FOO="$bar" baz`.

2. Otherwise, it just unnecessarily forces PATH lookup for dotnet
   command. In addition to that, some dotnet invocations did not use
   env.
2024-05-20 03:02:23 +03:00
David McFarland
26c3d6878a dotnet: fix dotnet executables in darwin sandbox
This fixes:

    Could not load ICU data. UErrorCode: 2

We're using a hook instead of a wrapper because various things like to
reference the unwrapped dotnet executable.
2024-05-04 19:14:39 -03:00
Weijia Wang
7b1000581c
Merge pull request #295812 from UlyssesZh/fix-nuget-to-nix-trailing-slash
nuget-to-nix: fix the bug of wrong url in the generated nix file when base url does not have trailing slash
2024-04-05 06:31:00 +02:00
éclairevoyant
858f4db304
buildDotnetModule: fix handling executables with an empty list 2024-04-02 13:08:31 -04:00
Ulysses Zhan
acaf847d4f nuget-to-nix: fix the bug of wrong url in the generated nix file when the package base address of the nuget source does not have a trailing slash 2024-03-14 00:29:50 -07:00
David McFarland
92a255d13b nuget-to-nix: fix error handling 2024-03-06 10:14:21 -04:00
David McFarland
6b047e397a mkNugetDeps: provide default for nugetDeps 2024-03-03 09:57:47 -04:00
David McFarland
ca181cefee nuget-to-nix: skip local sources 2024-03-03 09:57:47 -04:00
Weijia Wang
b0fb3f62d0
Merge pull request #278242 from raphaelr/mknugetsource-remove-ifd
mkNugetSource: Remove meta.licenses attribute
2024-01-18 09:22:38 +01:00
Ryan Lahfa
d74aefe80e
Merge pull request #251267 from lilyinstarlight/fix/dotnet-installPath
buildDotnetModule: actually use installPath
2024-01-12 19:30:12 +01:00
Raphael Robatsch
928d66083e mkNugetSource: Allow passing arbitrary stdenv.mkDerivation attrs
This allows things such as

    mkNugetSource {
        name = "foo-nuget-source";
        deps = [ ... ];
        meta = {
            hydraPlatforms = [ ];
        };
    }
2024-01-02 20:27:20 +01:00
Raphael Robatsch
5fb3301dad mkNugetSource: Remove meta.licenses attribute
- It's useless. The correct attribute name would be `license` and not
  `licenses`. Meaning setting this never did anything useful.
- It used IFD in its implementation, meaning to know what the licenses
  of a nuget source are, you first had to build that nuget source. This
  defeats the point of having license checks in the first place.
- IFD is not allowed by the nixpkgs CI and build farm anyway.
2024-01-02 11:21:19 +01:00
David McFarland
a185ed85be nuget-to-nix: handle packages with mismatched nuspec case
e.g. cake.tool 3.0.0 which uses Cake.Tool.nuspec.
2023-12-22 12:06:02 +01:00
Sandro Jäckel
bf81cded7d makeNugetSource: symlink files instead of copying them
this reduces the closure size of the resulting derivation drastically
2023-12-15 01:23:21 +00:00
Sandro Jäckel
5ef866783f makeNugetSource: fix meta.description being overwritten, misc cleanup 2023-12-15 01:23:21 +00:00
mdarocha
5b43e78193 buildDotnetModule: fix rare error when evaluation of version fails 2023-12-04 20:24:09 +01:00
mdarocha
d016404ccd buildDotnetModule: parse version before passing it to dotnet
This avoids problems when the Nix version attribute does not fit the
format required by .NET
2023-10-17 18:59:52 +02:00
mdarocha
8318df5b63 buildDotnetModule: fix running fetch-deps with no nugetDeps defined.
This eases the initial setup when creating a package
2023-09-30 13:21:12 +02:00
Lily Foster
20e1dd2d1e
buildDotnetModule: actually use installPath 2023-08-24 20:15:13 -04:00
OTABI Tomoya
ccaca85500
Merge pull request #249091 from TomaSajt/dotnet-fix
Fix useDotnetFromEnv's DOTNET_ROOT detection
2023-08-23 14:04:47 +09:00
TomaSajt
9646cb5c49
buildDotnetGlobalTool: fix typo 2023-08-14 20:56:27 +02:00
TomaSajt
ed60ed3562
Fix useDotnetFromEnv's DOTNET_ROOT detection 2023-08-08 00:37:49 +02:00
David McFarland
f2027f4960 nuget-to-nix: set nullglob
This stops nuget-to-nix from failing when there are no packages in the
output.
2023-06-24 19:13:16 -03:00
David McFarland
bca3a9edfc buildDotnetModule: fix indentation 2023-06-24 19:13:16 -03:00
David McFarland
afe26f5f1d buildDotnetModule: remove fetch-deps from tool packages
This helps if we want to run nixpkgs.*.fetch-deps.  Previously
e.g. fable.fetch-deps existed, but was broken.
2023-06-24 19:13:16 -03:00
David McFarland
d6fa0f0a26 buildDotnetModule: use tmp file for fetch-deps output 2023-06-24 19:13:16 -03:00
David McFarland
cf9976de74 buildDotnetModule: unset TMPDIR instead of setting it empty
This was breaking nix-prefetch-url when running fetch-deps in nix-shell.

e.g.

    $ TMPDIR= nix-prefetch-url foo
    nix-prefetch-url: src/libutil/util.cc:119: nix::Path
    nix::canonPath(PathView, bool): Assertion `path != ""' failed. [2]
    881198 abort (core dumped)
2023-06-24 19:13:16 -03:00
David McFarland
9c16cea2bb buildDotnetModule: allow lockFile path to be set in nugetDeps
This allows fetch-deps to find the lock-file for roslyn.
2023-06-24 17:17:41 -03:00
mdarocha
29e770e0eb buildDotnetModule: support native binaries in nuget packages
This helps with ie. crossgen2 building, and packages that use protoc
2023-06-21 17:06:30 +02:00
mdarocha
c51141d997 buildDotnetModule: pass runtimeId whenever possible and disable trimming when not allowed.
This fixes up some build errors
2023-06-21 17:06:30 +02:00
mdarocha
3408b40fb5 buildDotnetGlobalTool: init 2023-06-20 17:20:52 +02:00
mdarocha
abf6081bc2 buildDotnetModule: add useDotnetFromEnv option
This causes an alternative wrapper to be used, that takes the dotnet
runtime from the environment.
2023-06-20 17:20:51 +02:00
mdarocha
6c639e869c buildDotnetModule: tweaks to support paket
Projects that use paket, and have it setup so that it's executed
transparently during "dotnet restore" as a dotnet tool should now work.
2023-06-20 17:20:51 +02:00
Raphael Robatsch
0d29814880 mkNugetSource: Also copy .nupkg files from subdirectories
Previously only .nupkg files directly in the deps directory were copied.
This is a regression because it breaks `projectReferences = [ ... ];` in
buildDotnetModule.
2023-05-26 16:18:07 +02:00
Guillaume Maudoux
33399c9de8
Merge pull request #229008 from whonore/dafny-4
dafny: 2.3.0 -> 4.0.0
2023-05-17 09:53:06 +02:00
Raphael Robatsch
d347b0400c mkNugetSource: remove mono from build closure
A directory full of *.nupkg files is a valid nuget source. We do not need mono
and the Nuget command line tool to create this structure. This has two
advantages:

- Nuget is currently broken due to a kernel bug affecting mono (#229476).
  Replacing the mkNugetSource implementation allows affected users on 6.1+
  kernels compile .NET core packages again.
- It removes mono from the build closure of .NET core packages. .NET core
  builds should not depend on .NET framework tools like mono.

There is no equivalent of the `nuget init` command in .NET core. The closest
command is `dotnet nuget push`, which just copies the *.nupkg files around
anyway, just like this PR does with `cp`.

`nuget init` used to extract the *.nuspec files from the nupkgs, this new
implementation doesn't. .NET core doesn't care, but it makes the license
extraction more difficult. What was previously done with find/grep/xml2 is now
a python script (extract-licenses-from-nupkgs.py).
2023-05-05 18:38:06 +00:00
Guillaume Maudoux
6efefdc8c1 buildDotnetModule: add support for dotnet tools 2023-04-29 18:54:04 -04:00
7c6f434c
17b4ad7c2f
Merge pull request #217587 from winterqt/build-dotnet-module-darwin-sandbox
buildDotnetModule: fix sandboxed builds on darwin
2023-04-17 14:08:21 +00:00
Sandro
06c40b7498
Merge pull request #218991 from Trundle/builddotnetmodule-space-wrapper-args 2023-03-31 01:19:55 +02:00
Artturin
780669daf5 treewide: don't hardcode /nix/store (no rebuilds changes)
improve experience for other store locations
2023-03-24 20:11:33 +02:00
mdarocha
d093086a2b buildDotnetModule: add support for using combinePackages as dotnet-sdk
This allows packages that require several dotnet versions to build (like
BeatSaberModManager) to properly depend on the dotnet-sdk specific deps.
This in turns avoids having to regenerate the deps of those packages
after each dotnet-sdk update.

This also changes nuget-to-nix to accept a file with a list of
exclusions instead of a folder.
2023-03-19 20:53:39 +01:00
Atemu
d390c28a89
Merge pull request #218849 from Atemu/buildDotnetModule-put-dep-file-path-in-fetch-script
buildDotnetModule: point fetch-deps at module's deps file by default
2023-03-06 17:46:32 +01:00
Andreas Stührk
b76ce89dfc buildDotnetModule: add support for args with spaces in makeWrapperArgs 2023-03-01 14:15:33 +01:00
Atemu
014eba883e buildDotnetModule: point fetch-deps at module's deps file by default
Previously, you had to provide the path to the deps.nix of the package inside
your Nixpkgs checkout as an argument manually. Now it just does that by default
when no argument is passed.
2023-02-28 19:04:56 +01:00
Winter
8c8524bc9a buildDotnetModule: fix sandboxed builds on darwin
ICU tries to unconditionally load files from /usr/share/icu on Darwin,
which makes builds fail in the sandbox. Thus, let's disable ICU during
the build on Darwin by setting DOTNET_SYSTEM_GLOBALIZATION_INVARIANT [0].

[0]: https://learn.microsoft.com/en-us/dotnet/core/runtime-config/globalization#invariant-mode
2023-02-21 18:04:39 -05:00
github-actions[bot]
c4fe2133de
Merge staging-next into staging 2023-02-15 06:01:44 +00:00
Felix Buehler
bc3d5934d7 treewide: use lib.optionals 2023-02-14 19:11:59 +01:00
Artturin
4e3dcf364e treewide: makeSetupHook deps -> propagatedBuildInputs 2023-02-07 21:02:00 +02:00
mdarocha
08e378f0d4 buildDotnetModule: proper escaping of disabledTests 2023-01-17 16:46:13 +01:00
Erik Arvstedt
89c457d847
build-dotnet-module: fix mktemp
Re-add missing `-t` arg which I erroneously removed in
a98e520855.

Without it, the tmpdir is created in $PWD.
2023-01-09 17:33:10 +01:00
Erik Arvstedt
a98e520855
build-dotnet-module: avoid /run/user for downloading packages
Inside `nix-shell`, `TMPDIR` (used by `mktemp`) is set to
`/run/user/<uid>` which is usually a tmpfs stored in RAM.

When fetching a large dotnet deps tree to this tmpdir from a
nix-shell (e.g. via `btcpayserver/update.sh`), this can easily exceed
system RAM and `fetch-deps` fails.

mktemp arg `-t` is deprecated and can be omitted.
2023-01-07 17:59:34 +01:00
David McFarland
824d40aa04 build-dotnet-module: restore for current runtime by default 2022-12-19 15:36:25 -04:00
David McFarland
4c861dd26c build-dotnet-module: add useAppHost parameter so it can be disabled 2022-12-19 15:36:25 -04:00
David McFarland
62ecb39a1f buildDotnetModule: run tests on projectFile if testProjectFile is unset 2022-12-19 15:36:25 -04:00
David McFarland
507eff880d build-dotnet: make passthru.packages a derivation 2022-12-19 15:36:25 -04:00
David McFarland
06e4d89943 build-dotnet-module: strip --runtime flags without using rid 2022-12-19 15:36:25 -04:00
David McFarland
3fdb6c5a90 dotnetCorePackages: move systemToDotnetRid out of sdk 2022-12-19 15:36:25 -04:00
figsoda
ec8cb34358 treewide: fix typos 2022-12-17 19:39:44 -05:00
mdarocha
8e7296e984 buildDotnetModule: generate a NuGet.config with source
Some references, like <Sdk />, ignore the --source argument.
To fix that, we generate a simple NuGet.config containing only
the given nuget source.
2022-11-25 18:50:44 +01:00
Sandro Jäckel
0f386859f5
build-dotnet-module: don't end with exit code 1 when update was sucessfull
otherwise scripts might end prematurely
2022-10-25 16:12:22 +02:00
David McFarland
abebf5f591 nuget-to-nix: fix warning when package is installed from sdk 2022-10-18 23:42:46 -03:00
David McFarland
b60c9fd2fe nuget-to-nix: find sources deterministically
The source used to download a particular package still isn't
deterministic in nuget. Even worse, the hash of the package can vary
between sources. This makes nuget use the first enabled source
containing the package.

The order of the dependencies may be slightly different because it now
uses glob order of the lower-case package names and versions, instead of
sorting the output.

If the package actually downloaded was the first source that contains
the package, then it will be hashed from disk to avoid downloading it
again.
2022-10-02 16:09:27 -03:00
David McFarland
f8763b87e0 nuget-to-nix: exclude by package source, not list
This allows exclusions to be by version.
2022-10-02 16:09:27 -03:00
David McFarland
0eb6874732 build-dotnet-module: fix fetch-deps usage message 2022-10-02 16:09:27 -03:00
David McFarland
f716d092e2 build-dotnet-module: limit package platforms by sdk support 2022-10-02 16:09:27 -03:00
David McFarland
4b40579b2d build-dotnet-module: clean up tmp file handling
Having:

rm -rf "$src" "$HOME"

Was slightly terrifying IMO, especially where the trap was installed
before HOME was set.
2022-10-02 16:09:24 -03:00
Ivar Scholten
4a8eb528be
buildDotnetModule: add the option to keep sources to fetch-deps 2022-09-18 18:02:03 +02:00
Ivar Scholten
8e00d6ac26
buildDotnetModule: move nugetDeps throw to when its actually needed
Previously we had an assert that would complain when nugetDeps wasnt set,
which also didnt allow any passthru attributes (like fetch-deps) to be
build. That causes a cycle where you need nugetDeps to fetch the nuget
deps, but arent able to build the script to do so.
2022-09-18 18:00:37 +02:00
Ivar Scholten
03a1b62cb3
buildDotnetModule: dont require specifing a projectFile
In a lot of cases dotnet can figure this out by itself, so we can just
invoke it without the project argument.
2022-09-18 18:00:37 +02:00
Ivar Scholten
a7c598e458
buildDotnetModule: minor changes to hooks
Abide by `set -e` rules and use `local -r` where applicable.
2022-09-18 18:00:37 +02:00
Ivar Scholten
e100b74627
buildDotnetModule: format with nixpkgs-fmt 2022-09-18 18:00:29 +02:00
Cole Helbling
e97ee029b4 build-dotnet-module/fetch-deps: fixup temp naming when pname has a capital X in it
For example, this script doesn't work for `xivlauncher` because its
proper `pname` is `XIVLauncher`, and `mktemp` complains about "too few
X's":

    $ mktemp -td "XXXXXX-XIVLauncher-home"
    mktemp: too few X's in template ‘XXXXXX-XIVLauncher-home’

vs

    $ mktemp -td "XIVLauncher-home-XXXXXX"
    /tmp/XIVLauncher-home-EdGMei
2022-09-16 09:18:22 -07:00
David McFarland
c91f7dd64a nuget-to-nix: skip local packages 2022-09-15 19:39:36 -03:00
David McFarland
4ec86553b1 make-nuget-deps: use . for version separator
This allows the output to be used as a nuget source.
2022-09-15 19:39:36 -03:00
Ivv
44ef157f55
Merge pull request #187359 from IvarWithoutBones/dotnetmodule-updatescripts
treewide: migrate buildDotnetModule update scripts to use fetch-deps
2022-09-11 21:40:06 +02:00
Sandro Jäckel
c3f51d1b55
dotenv: convert CRLF line endings into LF
otherwise git converts the line endings with every rebase on Linux
2022-09-11 17:02:00 +02:00
Ivar Scholten
efd92e7fd7
buildDotnetModule: restore for all platforms in fetch-deps
This makes buildDotnetModule restore nuget dependencies for the
platforms set in meta.platforms. This should help with generating
lockfiles for platforms other than the host machine.

Co-authored-by: mdarocha <git@mdarocha.pl>
2022-09-11 01:06:33 +02:00
Zhaofeng Li
3d07ae8afd build-dotnet-module: Allow specifying the output path of fetch-deps 2022-08-18 13:49:45 -06:00
Zhaofeng Li
1528ce3063 nuget-to-nix: Make exclusion file optional 2022-08-18 13:49:45 -06:00
Evan Petousis
b4de4dc3bf
buildDotnetModule: set fetch-deps utils via PATH 2022-08-18 23:46:37 +10:00
Evan Petousis
c51e1a1fba
buildDotnetModule: use coreutils in fetch-deps
cp on macOS doesn't support the -T flag, which causes the fetch-deps
script to fail. Use Nix's coreutils to ensure the script works
consistently across all platforms.
2022-08-18 23:36:25 +10:00
Evan Petousis
d7728dfc67
buildDotnetModule: use platform-agnostic cp format
cp on macOS doesn't support the -T flag, which causes the fetch-deps
script to fail. Appending `/.` to the source argument replicates the
same functionality.
2022-08-18 23:35:50 +10:00
Ivv
7ec728db17
Merge pull request #181512 from mdarocha/dotnet-6-update
dotnet-sdk: 6.0.301 -> 6.0.400, refactor to streamline dotnet updates
2022-08-14 15:08:43 +02:00
mdarocha
a3fff0c947 buildDotnetModule: exclude sdk-specific packages in fetch-deps result 2022-08-10 16:26:49 +02:00
mdarocha
886280e8a9 buildDotnetModule: include sdk-specific packages in nuget source
Some packages are defined by the build proccess, and change every time
the dotnet-sdk package changes. To avoid having to regenerate every
dependant packages dependencies every dotnet update, this moves these
packages into the `dotnet-sdk` `passthru` attribute, and includes them
every time `buildDotnetModule` is used.
2022-08-10 16:26:43 +02:00
mdarocha
134da4ce36 buildDotnetModule: fix build for dotnet-sdk versions below 6
The --self-contained and --no-self-contained switches were
added to the dotnet build command starting with .NET 6.
The switch is equivalent to the setting the SelfContained
property, so we use the property for backwards compatibility.
2022-08-03 16:15:59 +02:00
Sandro
f358b0d40d
Merge pull request #182273 from mdarocha/dotnet-self-contained-build
buildDotnetModule: add option to make a self-contained build
2022-07-28 11:59:09 +02:00
mdarocha
19403a85d9 buildDotnetModule: add option to make a self-contained build 2022-07-26 18:00:15 +02:00