nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 76 lines 2.7 kB view raw
1{ 2 lib, 3 dotnet-sdk, 4 buildPackages, # buildDotnetModule 5 testers, 6 runCommand, 7}: 8let 9 copyrightString = "Original Copyright"; 10 originalCopyright = builtins.toFile "original-copyright.txt" copyrightString; 11 overridenCopyright = builtins.toFile "overridden-copyright.txt" ( 12 copyrightString + " with override!" 13 ); 14 15 inherit (buildPackages) buildDotnetModule; 16 17 app-recursive = buildDotnetModule (finalAttrs: { 18 name = "final-attrs-rec-test-application"; 19 src = ../structured-attrs/src; 20 nugetDeps = ../structured-attrs/nuget-deps.json; 21 dotnetFlags = [ "--property:Copyright=${finalAttrs.passthru.copyrightString}" ]; 22 env.TargetFramework = "net${lib.versions.majorMinor (lib.getVersion dotnet-sdk)}"; 23 __structuredAttrs = true; 24 passthru = { 25 inherit copyrightString; 26 }; 27 }); 28 29 app-const = buildDotnetModule { 30 name = "final-attrs-const-test-application"; 31 src = ../structured-attrs/src; 32 nugetDeps = ../structured-attrs/nuget-deps.json; 33 dotnetFlags = [ "--property:Copyright=${copyrightString}" ]; 34 env.TargetFramework = "net${lib.versions.majorMinor (lib.getVersion dotnet-sdk)}"; 35 __structuredAttrs = true; 36 passthru = { 37 inherit copyrightString; 38 }; 39 }; 40 41 override = 42 app: 43 app.overrideAttrs (previousAttrs: { 44 passthru = previousAttrs.passthru // { 45 copyrightString = previousAttrs.passthru.copyrightString + " with override!"; 46 }; 47 }); 48 49 run = 50 name: app: 51 runCommand name { } '' 52 ${app}/bin/Application >"$out" 53 ''; 54in 55{ 56 check-output = testers.testEqualContents { 57 assertion = "buildDotnetModule produces the expected output when called with a recursive function"; 58 expected = originalCopyright; 59 actual = run "dotnet-final-attrs-test-rec-output" app-recursive; 60 }; 61 output-matches-const = testers.testEqualContents { 62 assertion = "buildDotnetModule produces the same output when called with attrs or a recursive function"; 63 expected = run "dotnet-final-attrs-test-const" app-const; 64 actual = run "dotnet-final-attrs-test-rec" app-recursive; 65 }; 66 override-has-no-effect = testers.testEqualContents { 67 assertion = "buildDotnetModule produces the expected output when called with a recursive function"; 68 expected = originalCopyright; 69 actual = run "dotnet-final-attrs-test-override-const-output" (override app-const); 70 }; 71 override-modifies-output = testers.testEqualContents { 72 assertion = "buildDotnetModule produces the expected output when called with a recursive function"; 73 expected = overridenCopyright; 74 actual = run "dotnet-final-attrs-test-override-rec-output" (override app-recursive); 75 }; 76}