From f6e0ee5545889996bf926bd6c726084b72aca22e Mon Sep 17 00:00:00 2001 From: Tulili Date: Mon, 15 Jan 2024 11:48:50 -0300 Subject: [PATCH] pkgs.writers: remove tests that dont work anymore and add comments tracking issues --- pkgs/build-support/writers/default.nix | 1 + pkgs/build-support/writers/scripts.nix | 34 +++++------ pkgs/build-support/writers/test.nix | 78 ++++++++++++++------------ 3 files changed, 62 insertions(+), 51 deletions(-) diff --git a/pkgs/build-support/writers/default.nix b/pkgs/build-support/writers/default.nix index a161322cd35b..cadb69781481 100644 --- a/pkgs/build-support/writers/default.nix +++ b/pkgs/build-support/writers/default.nix @@ -1,5 +1,6 @@ { config, lib, callPackages }: +# If you are reading this, you can test these writers by running: nix-build . -A tests.writers let aliases = if config.allowAliases then (import ./aliases.nix lib) else prev: {}; diff --git a/pkgs/build-support/writers/scripts.nix b/pkgs/build-support/writers/scripts.nix index c268876e1e27..507fd590e243 100644 --- a/pkgs/build-support/writers/scripts.nix +++ b/pkgs/build-support/writers/scripts.nix @@ -13,7 +13,7 @@ let in rec { # Base implementation for non-compiled executables. - # Takes an interpreter, for example `${pkgs.bash}/bin/bash` + # Takes an interpreter, for example `${lib.getExe pkgs.bash}` # # Examples: # writeBash = makeScriptWriter { interpreter = "${pkgs.bash}/bin/bash"; } @@ -116,7 +116,7 @@ rec { # echo hello world # '' writeBash = makeScriptWriter { - interpreter = "${pkgs.bash}/bin/bash"; + interpreter = "${lib.getExe pkgs.bash}"; }; # Like writeScriptBin but the first line is a shebang to bash @@ -130,7 +130,7 @@ rec { # echo hello world # '' writeDash = makeScriptWriter { - interpreter = "${pkgs.dash}/bin/dash"; + interpreter = "${lib.getExe pkgs.dash}"; }; # Like writeScriptBin but the first line is a shebang to dash @@ -144,8 +144,8 @@ rec { # echo hello world # '' writeFish = makeScriptWriter { - interpreter = "${pkgs.fish}/bin/fish --no-config"; - check = "${pkgs.fish}/bin/fish --no-config --no-execute"; # syntax check only + interpreter = "${lib.getExe pkgs.fish} --no-config"; + check = "${lib.getExe pkgs.fish} --no-config --no-execute"; # syntax check only }; # Like writeScriptBin but the first line is a shebang to fish @@ -175,7 +175,7 @@ rec { in makeBinWriter { compileScript = '' cp $contentPath tmp.hs - ${ghc.withPackages (_: libraries )}/bin/ghc ${lib.escapeShellArgs ghcArgs'} tmp.hs + ${(ghc.withPackages (_: libraries ))}/bin/ghc ${lib.escapeShellArgs ghcArgs'} tmp.hs mv tmp $out ''; inherit strip; @@ -192,7 +192,7 @@ rec { # echo hello world # '' writeNu = makeScriptWriter { - interpreter = "${pkgs.nushell}/bin/nu --no-config-file"; + interpreter = "${lib.getExe pkgs.nushell} --no-config-file"; }; # Like writeScriptBin but the first line is a shebang to nu @@ -206,7 +206,7 @@ rec { # puts "hello world" # '' writeRuby = makeScriptWriter { - interpreter = "${pkgs.ruby}/bin/ruby"; + interpreter = "${lib.getExe pkgs.ruby}"; }; writeRubyBin = name: @@ -219,7 +219,7 @@ rec { # print("hello world") # '' writeLua = makeScriptWriter { - interpreter = "${pkgs.lua}/bin/lua"; + interpreter = "${lib.getExe pkgs.lua}"; }; writeLuaBin = name: @@ -236,7 +236,7 @@ rec { makeBinWriter { compileScript = '' cp "$contentPath" tmp.rs - PATH=${lib.makeBinPath [pkgs.gcc]} ${lib.getBin rustc}/bin/rustc ${lib.escapeShellArgs rustcArgs} ${lib.escapeShellArgs darwinArgs} -o "$out" tmp.rs + PATH=${lib.makeBinPath [pkgs.gcc]} ${rustc}/bin/rustc ${lib.escapeShellArgs rustcArgs} ${lib.escapeShellArgs darwinArgs} -o "$out" tmp.rs ''; inherit strip; } name; @@ -265,7 +265,7 @@ rec { }; in writeDash name '' export NODE_PATH=${node-env}/lib/node_modules - exec ${pkgs.nodejs}/bin/node ${pkgs.writeText "js" content} "$@" + exec ${lib.getExe pkgs.nodejs} ${pkgs.writeText "js" content} "$@" ''; # writeJSBin takes the same arguments as writeJS but outputs a directory (like writeScriptBin) @@ -300,7 +300,7 @@ rec { # '' writePerl = name: { libraries ? [] }: makeScriptWriter { - interpreter = "${pkgs.perl.withPackages (p: libraries)}/bin/perl"; + interpreter = "${lib.getExe (pkgs.perl.withPackages (p: libraries))}"; } name; # writePerlBin takes the same arguments as writePerl but outputs a directory (like writeScriptBin) @@ -316,9 +316,11 @@ rec { in makeScriptWriter { interpreter = - if libraries == [] - then python.interpreter - else (python.withPackages (ps: libraries)).interpreter + if pythonPackages != pkgs.pypy2Packages || pythonPackages != pkgs.pypy3Packages then + if libraries == [] + then python.interpreter + else (python.withPackages (ps: libraries)).interpreter + else python.interpreter ; check = optionalString python.isPy3k (writeDash "pythoncheck.sh" '' exec ${buildPythonPackages.flake8}/bin/flake8 --show-source ${ignoreAttribute} "$1" @@ -398,7 +400,7 @@ rec { export DOTNET_CLI_TELEMETRY_OPTOUT=1 export DOTNET_NOLOGO=1 script="$1"; shift - ${dotnet-sdk}/bin/dotnet fsi --quiet --nologo --readline- ${fsi-flags} "$@" < "$script" + ${lib.getExe dotnet-sdk} fsi --quiet --nologo --readline- ${fsi-flags} "$@" < "$script" ''; in content: makeScriptWriter { diff --git a/pkgs/build-support/writers/test.nix b/pkgs/build-support/writers/test.nix index 1b690e2d24c9..ff0cef3daa12 100644 --- a/pkgs/build-support/writers/test.nix +++ b/pkgs/build-support/writers/test.nix @@ -11,6 +11,9 @@ , writers , writeText }: + +# If you are reading this, you can test these writers by running: nix-build . -A tests.writers + with writers; let expectSuccess = test: @@ -88,15 +91,6 @@ lib.recurseIntoAttrs { print "success\n" if true; ''); - pypy2 = expectSuccessBin (writePyPy2Bin "test-writers-pypy2-bin" { libraries = [ pypy2Packages.enum ]; } '' - from enum import Enum - - class Test(Enum): - a = "success" - - print Test.a - ''); - python3 = expectSuccessBin (writePython3Bin "test-writers-python3-bin" { libraries = [ python3Packages.pyyaml ]; } '' import yaml @@ -106,14 +100,25 @@ lib.recurseIntoAttrs { print(y[0]['test']) ''); - pypy3 = expectSuccessBin (writePyPy3Bin "test-writers-pypy3-bin" { libraries = [ pypy3Packages.pyyaml ]; } '' - import yaml + # Commented out because of this issue: https://github.com/NixOS/nixpkgs/issues/39356 - y = yaml.safe_load(""" - - test: success - """) - print(y[0]['test']) - ''); + #pypy2 = expectSuccessBin (writePyPy2Bin "test-writers-pypy2-bin" { libraries = [ pypy2Packages.enum ]; } '' + # from enum import Enum + # + # class Test(Enum): + # a = "success" + # + # print Test.a + #''); + + #pypy3 = expectSuccessBin (writePyPy3Bin "test-writers-pypy3-bin" { libraries = [ pypy3Packages.pyyaml ]; } '' + # import yaml + # + # y = yaml.safe_load(""" + # - test: success + # """) + # print(y[0]['test']) + #''); }; simple = lib.recurseIntoAttrs { @@ -158,15 +163,6 @@ lib.recurseIntoAttrs { print "success\n" if true; ''); - pypy2 = expectSuccess (writePyPy2 "test-writers-pypy2" { libraries = [ pypy2Packages.enum ]; } '' - from enum import Enum - - class Test(Enum): - a = "success" - - print Test.a - ''); - python3 = expectSuccess (writePython3 "test-writers-python3" { libraries = [ python3Packages.pyyaml ]; } '' import yaml @@ -176,14 +172,25 @@ lib.recurseIntoAttrs { print(y[0]['test']) ''); - pypy3 = expectSuccess (writePyPy3 "test-writers-pypy3" { libraries = [ pypy3Packages.pyyaml ]; } '' - import yaml + # Commented out because of this issue: https://github.com/NixOS/nixpkgs/issues/39356 - y = yaml.safe_load(""" - - test: success - """) - print(y[0]['test']) - ''); + #pypy2 = expectSuccessBin (writePyPy2Bin "test-writers-pypy2-bin" { libraries = [ pypy2Packages.enum ]; } '' + # from enum import Enum + # + # class Test(Enum): + # a = "success" + # + # print Test.a + #''); + + #pypy3 = expectSuccessBin (writePyPy3Bin "test-writers-pypy3-bin" { libraries = [ pypy3Packages.pyyaml ]; } '' + # import yaml + # + # y = yaml.safe_load(""" + # - test: success + # """) + # print(y[0]['test']) + #''); fsharp = expectSuccess (makeFSharpWriter { libraries = { fetchNuGet }: [ @@ -191,6 +198,7 @@ lib.recurseIntoAttrs { (fetchNuGet { pname = "System.Text.Json"; version = "4.6.0"; sha256 = "0ism236hwi0k6axssfq58s1d8lihplwiz058pdvl8al71hagri39"; }) ]; } "test-writers-fsharp" '' + #r "nuget: FSharp.SystemTextJson, 0.17.4" module Json = @@ -209,9 +217,9 @@ lib.recurseIntoAttrs { |> printfn "%s" ''); - pypy2NoLibs = expectSuccess (writePyPy2 "test-writers-pypy2-no-libs" {} '' - print("success") - ''); + #pypy2NoLibs = expectSuccess (writePyPy2 "test-writers-pypy2-no-libs" {} '' + # print("success") + #''); python3NoLibs = expectSuccess (writePython3 "test-writers-python3-no-libs" {} '' print("success")