nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 dotnet-sdk,
4 buildPackages, # buildDotnetModule
5 testers,
6 runCommand,
7}:
8let
9 # Note: without structured attributes, we can’t use derivation arguments that
10 # contain spaces unambiguously because arguments are passed as space-separated
11 # environment variables.
12 copyrightString = "Public domain 🅮";
13
14 inherit (buildPackages) buildDotnetModule;
15
16 app = buildDotnetModule {
17 name = "structured-attrs-test-application";
18 src = ./src;
19 nugetDeps = ./nuget-deps.json;
20 dotnetFlags = [ "--property:Copyright=${copyrightString}" ];
21 env.TargetFramework = "net${lib.versions.majorMinor (lib.getVersion dotnet-sdk)}";
22 __structuredAttrs = true;
23 };
24in
25{
26 no-structured-attrs = testers.testBuildFailure (
27 app.overrideAttrs {
28 __structuredAttrs = false;
29 }
30 );
31
32 check-output = testers.testEqualContents {
33 assertion = "buildDotnetModule sets AssemblyCopyrightAttribute with structured attributes";
34 expected = builtins.toFile "expected-copyright.txt" copyrightString;
35 actual = runCommand "dotnet-structured-attrs-test" { } ''
36 ${app}/bin/Application >"$out"
37 '';
38 };
39}