push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
{ lib, callPackage }:
{
project-references = callPackage ./project-references { };
use-dotnet-from-env = lib.recurseIntoAttrs (callPackage ./use-dotnet-from-env { });
structured-attrs = lib.recurseIntoAttrs (callPackage ./structured-attrs { });
final-attrs = lib.recurseIntoAttrs (callPackage ./final-attrs { });
nuget-deps = lib.recurseIntoAttrs (callPackage ./nuget-deps { });
}

View File

@@ -0,0 +1,76 @@
{
lib,
dotnet-sdk,
buildPackages, # buildDotnetModule
testers,
runCommand,
}:
let
copyrightString = "Original Copyright";
originalCopyright = builtins.toFile "original-copyright.txt" copyrightString;
overridenCopyright = builtins.toFile "overridden-copyright.txt" (
copyrightString + " with override!"
);
inherit (buildPackages) buildDotnetModule;
app-recursive = buildDotnetModule (finalAttrs: {
name = "final-attrs-rec-test-application";
src = ../structured-attrs/src;
nugetDeps = ../structured-attrs/nuget-deps.json;
dotnetFlags = [ "--property:Copyright=${finalAttrs.passthru.copyrightString}" ];
env.TargetFramework = "net${lib.versions.majorMinor (lib.getVersion dotnet-sdk)}";
__structuredAttrs = true;
passthru = {
inherit copyrightString;
};
});
app-const = buildDotnetModule {
name = "final-attrs-const-test-application";
src = ../structured-attrs/src;
nugetDeps = ../structured-attrs/nuget-deps.json;
dotnetFlags = [ "--property:Copyright=${copyrightString}" ];
env.TargetFramework = "net${lib.versions.majorMinor (lib.getVersion dotnet-sdk)}";
__structuredAttrs = true;
passthru = {
inherit copyrightString;
};
};
override =
app:
app.overrideAttrs (previousAttrs: {
passthru = previousAttrs.passthru // {
copyrightString = previousAttrs.passthru.copyrightString + " with override!";
};
});
run =
name: app:
runCommand name { } ''
${app}/bin/Application >"$out"
'';
in
{
check-output = testers.testEqualContents {
assertion = "buildDotnetModule produces the expected output when called with a recursive function";
expected = originalCopyright;
actual = run "dotnet-final-attrs-test-rec-output" app-recursive;
};
output-matches-const = testers.testEqualContents {
assertion = "buildDotnetModule produces the same output when called with attrs or a recursive function";
expected = run "dotnet-final-attrs-test-const" app-const;
actual = run "dotnet-final-attrs-test-rec" app-recursive;
};
override-has-no-effect = testers.testEqualContents {
assertion = "buildDotnetModule produces the expected output when called with a recursive function";
expected = originalCopyright;
actual = run "dotnet-final-attrs-test-override-const-output" (override app-const);
};
override-modifies-output = testers.testEqualContents {
assertion = "buildDotnetModule produces the expected output when called with a recursive function";
expected = overridenCopyright;
actual = run "dotnet-final-attrs-test-override-rec-output" (override app-recursive);
};
}

View File

@@ -0,0 +1,45 @@
# Tests that `nugetDeps` in buildDotnetModule can handle various types.
{
lib,
dotnet-sdk,
buildPackages, # buildDotnetModule
runCommand,
}:
let
inherit (lib)
mapAttrs
;
inherit (buildPackages)
emptyDirectory
buildDotnetModule
;
in
mapAttrs
(
name: nugetDeps:
buildDotnetModule {
name = "nuget-deps-${name}";
unpackPhase = ''
runHook preUnpack
mkdir test
cd test
dotnet new console -o .
ls -l
runHook postUnpack
'';
inherit nugetDeps;
}
)
{
"null" = null;
"nix-file" = ./nuget-deps.nix;
"json-file" = ./nuget-deps.json;
"derivation" = emptyDirectory;
"list" = [ emptyDirectory ];
}

View File

@@ -0,0 +1 @@
[]

View File

@@ -0,0 +1,6 @@
# This file was automatically generated by passthru.fetch-deps.
# Please dont edit it manually, your changes might get overwritten!
{ fetchNuGet }:
[
]

View File

@@ -0,0 +1 @@
ProjectReferencesTest.Library.Hello();

View File

@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>exe</OutputType>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../library/Library.csproj" />
<PackageReference Include="ProjectReferencesTest.Library" Version="*" Condition=" '$(ContinuousIntegrationBuild)'=='true' " />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,43 @@
# Tests the `projectReferences = [ ... ];` feature of buildDotnetModule.
# The `library` derivation exposes a .nupkg, which is then consumed by the `application` derivation.
# https://nixos.org/manual/nixpkgs/unstable/index.html#packaging-a-dotnet-application
{
lib,
dotnet-sdk,
buildPackages, # buildDotnetModule
runCommand,
}:
let
inherit (buildPackages) buildDotnetModule;
nugetDeps = ./nuget-deps.json;
# Specify the TargetFramework via an environment variable so that we don't
# have to update the .csproj files when updating dotnet-sdk
TargetFramework = "net${lib.versions.majorMinor (lib.getVersion dotnet-sdk)}";
library = buildDotnetModule {
name = "project-references-test-library";
src = ./library;
inherit nugetDeps;
env.TargetFramework = TargetFramework;
packNupkg = true;
};
application = buildDotnetModule {
name = "project-references-test-application";
src = ./application;
inherit nugetDeps;
env.TargetFramework = TargetFramework;
projectReferences = [ library ];
};
in
runCommand "project-references-test" { } ''
${application}/bin/Application
mkdir $out
''

View File

@@ -0,0 +1,8 @@
namespace ProjectReferencesTest;
public static class Library
{
public static void Hello()
{
System.Console.WriteLine("Hello, World!");
}
}

View File

@@ -0,0 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>ProjectReferencesTest.Library</PackageId>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1 @@
[]

View File

@@ -0,0 +1,39 @@
{
lib,
dotnet-sdk,
buildPackages, # buildDotnetModule
testers,
runCommand,
}:
let
# Note: without structured attributes, we cant use derivation arguments that
# contain spaces unambiguously because arguments are passed as space-separated
# environment variables.
copyrightString = "Public domain 🅮";
inherit (buildPackages) buildDotnetModule;
app = buildDotnetModule {
name = "structured-attrs-test-application";
src = ./src;
nugetDeps = ./nuget-deps.json;
dotnetFlags = [ "--property:Copyright=${copyrightString}" ];
env.TargetFramework = "net${lib.versions.majorMinor (lib.getVersion dotnet-sdk)}";
__structuredAttrs = true;
};
in
{
no-structured-attrs = testers.testBuildFailure (
app.overrideAttrs {
__structuredAttrs = false;
}
);
check-output = testers.testEqualContents {
assertion = "buildDotnetModule sets AssemblyCopyrightAttribute with structured attributes";
expected = builtins.toFile "expected-copyright.txt" copyrightString;
actual = runCommand "dotnet-structured-attrs-test" { } ''
${app}/bin/Application >"$out"
'';
};
}

View File

@@ -0,0 +1 @@
[]

View File

@@ -0,0 +1,10 @@
using System;
using System.Reflection;
Console.Write(
(
(AssemblyCopyrightAttribute)Assembly
.GetExecutingAssembly()
.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), true)[0]
).Copyright
);

View File

@@ -0,0 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>exe</OutputType>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,65 @@
{
lib,
dotnet-sdk,
buildPackages, # buildDotnetModule, dotnet-runtime
testers,
runCommand,
removeReferencesTo,
}:
let
inherit (buildPackages) buildDotnetModule dotnet-runtime;
app = buildDotnetModule {
name = "use-dotnet-from-env-test-application";
src = ./src;
nugetDeps = ./nuget-deps.json;
useDotnetFromEnv = true;
env.TargetFramework = "net${lib.versions.majorMinor (lib.getVersion dotnet-sdk)}";
};
appWithoutFallback = app.overrideAttrs (oldAttrs: {
nativeBuildInputs = (oldAttrs.nativeBuildInputs or [ ]) ++ [
removeReferencesTo
];
postFixup = (oldAttrs.postFixup or "") + ''
remove-references-to -t ${dotnet-runtime} "$out/bin/Application"
'';
});
runtimeVersion = lib.head (lib.splitString "-" (lib.getVersion dotnet-runtime));
runtimeVersionFile = builtins.toFile "dotnet-version.txt" runtimeVersion;
in
{
fallback = testers.testEqualContents {
assertion = "buildDotnetModule sets fallback DOTNET_ROOT in wrapper";
expected = runtimeVersionFile;
actual = runCommand "use-dotnet-from-env-fallback-test" { } ''
${app}/bin/Application >"$out"
'';
};
# Check that appWithoutFallback does not use fallback .NET runtime.
without-fallback = testers.testBuildFailure (
runCommand "use-dotnet-from-env-without-fallback-test" { } ''
${appWithoutFallback}/bin/Application >"$out"
''
);
# NB assumes that without-fallback above to passes.
use-dotnet-root-env = testers.testEqualContents {
assertion = "buildDotnetModule uses DOTNET_ROOT from environment in wrapper";
expected = runtimeVersionFile;
actual =
runCommand "use-dotnet-from-env-root-test" { env.DOTNET_ROOT = "${dotnet-runtime}/share/dotnet"; }
''
${appWithoutFallback}/bin/Application >"$out"
'';
};
use-dotnet-path-env = testers.testEqualContents {
assertion = "buildDotnetModule uses DOTNET_ROOT from dotnet in PATH in wrapper";
expected = runtimeVersionFile;
actual = runCommand "use-dotnet-from-env-path-test" { dotnetRuntime = dotnet-runtime; } ''
PATH=$dotnetRuntime/bin''${PATH+:}$PATH ${appWithoutFallback}/bin/Application >"$out"
'';
};
}

View File

@@ -0,0 +1 @@
[]

View File

@@ -0,0 +1,3 @@
using System;
Console.Write(Environment.Version.ToString());

View File

@@ -0,0 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>exe</OutputType>
</PropertyGroup>
</Project>