summary refs log tree commit diff
path: root/pkgs/build-support/writers
diff options
context:
space:
mode:
authorMarkus S. Wamser <github-dev@mail2013.wamser.eu>2021-12-10 22:03:06 +0100
committerMarkus S. Wamser <github-dev@mail2013.wamser.eu>2021-12-15 09:56:14 +0100
commit4e42f6bcb3506355cb84a71b9a8af501e936b976 (patch)
treebf6d75040fd79fd31e44a953935091473aab46ce /pkgs/build-support/writers
parent977810ca505c4aed35e99f11de0d3d86a0e6c425 (diff)
downloadnixpkgs-4e42f6bcb3506355cb84a71b9a8af501e936b976.tar
nixpkgs-4e42f6bcb3506355cb84a71b9a8af501e936b976.tar.gz
nixpkgs-4e42f6bcb3506355cb84a71b9a8af501e936b976.tar.bz2
nixpkgs-4e42f6bcb3506355cb84a71b9a8af501e936b976.tar.lz
nixpkgs-4e42f6bcb3506355cb84a71b9a8af501e936b976.tar.xz
nixpkgs-4e42f6bcb3506355cb84a71b9a8af501e936b976.tar.zst
nixpkgs-4e42f6bcb3506355cb84a71b9a8af501e936b976.zip
writers.writePython2: remove
Diffstat (limited to 'pkgs/build-support/writers')
-rw-r--r--pkgs/build-support/writers/aliases.nix35
-rw-r--r--pkgs/build-support/writers/default.nix31
-rw-r--r--pkgs/build-support/writers/test.nix27
3 files changed, 44 insertions, 49 deletions
diff --git a/pkgs/build-support/writers/aliases.nix b/pkgs/build-support/writers/aliases.nix
new file mode 100644
index 00000000000..fb108a6fd85
--- /dev/null
+++ b/pkgs/build-support/writers/aliases.nix
@@ -0,0 +1,35 @@
+lib: prev:
+
+let
+  # Removing recurseForDerivation prevents derivations of aliased attribute
+  # set to appear while listing all the packages available.
+  removeRecurseForDerivations = alias: with lib;
+    if alias.recurseForDerivations or false then
+      removeAttrs alias ["recurseForDerivations"]
+    else alias;
+
+  # Disabling distribution prevents top-level aliases for non-recursed package
+  # sets from building on Hydra.
+  removeDistribute = alias: with lib;
+    if isDerivation alias then
+      dontDistribute alias
+    else alias;
+
+  # Make sure that we are not shadowing something from
+  # writers.
+  checkInPkgs = n: alias: if builtins.hasAttr n prev
+                          then throw "Alias ${n} is still in writers"
+                          else alias;
+
+  mapAliases = aliases:
+    lib.mapAttrs (n: alias: removeDistribute
+                             (removeRecurseForDerivations
+                              (checkInPkgs n alias)))
+                     aliases;
+
+in
+mapAliases ({
+  /* Cleanup before 22.05, Added 2021-12-11 */
+  writePython2 = "Python 2 is EOL and the use of writers.writePython2 is deprecated.";
+  writePython2Bin = "Python 2 is EOL and the use of writers.writePython2Bin is deprecated.";
+})
diff --git a/pkgs/build-support/writers/default.nix b/pkgs/build-support/writers/default.nix
index 3797df56afa..e16c00534f8 100644
--- a/pkgs/build-support/writers/default.nix
+++ b/pkgs/build-support/writers/default.nix
@@ -1,7 +1,9 @@
-{ pkgs, buildPackages, lib, stdenv, libiconv, gawk, gnused, gixy }:
+{ pkgs, config, buildPackages, lib, stdenv, libiconv, gawk, gnused, gixy }:
 
-with lib;
-rec {
+let
+  aliases = if (config.allowAliases or true) then (import ./aliases.nix lib) else prev: {};
+
+  writers = with lib; rec {
   # Base implementation for non-compiled executables.
   # Takes an interpreter, for example `${pkgs.bash}/bin/bash`
   #
@@ -245,24 +247,6 @@ rec {
     '');
   } name;
 
-  # writePython2 takes a name an attributeset with libraries and some python2 sourcecode and
-  # returns an executable
-  #
-  # Example:
-  # writePython2 "test_python2" { libraries = [ pkgs.python2Packages.enum ]; } ''
-  #   from enum import Enum
-  #
-  #   class Test(Enum):
-  #       a = "success"
-  #
-  #   print Test.a
-  # ''
-  writePython2 = makePythonWriter pkgs.python2 pkgs.python2Packages;
-
-  # writePython2Bin takes the same arguments as writePython2 but outputs a directory (like writeScriptBin)
-  writePython2Bin = name:
-    writePython2 "/bin/${name}";
-
   # writePython3 takes a name an attributeset with libraries and some python3 sourcecode and
   # returns an executable
   #
@@ -280,4 +264,7 @@ rec {
   # writePython3Bin takes the same arguments as writePython3 but outputs a directory (like writeScriptBin)
   writePython3Bin = name:
     writePython3 "/bin/${name}";
-}
+
+};
+in
+writers // (aliases writers)
diff --git a/pkgs/build-support/writers/test.nix b/pkgs/build-support/writers/test.nix
index 69bc7dd2c61..8b7007e3869 100644
--- a/pkgs/build-support/writers/test.nix
+++ b/pkgs/build-support/writers/test.nix
@@ -3,7 +3,6 @@
 , lib
 , nodePackages
 , perlPackages
-, python2Packages
 , python3Packages
 , runCommand
 , writers
@@ -54,17 +53,6 @@ let
       print "success\n" if true;
     '';
 
-    python2 = writePython2Bin "test-writers-python2-bin" { libraries = [ python2Packages.enum ]; } ''
-      from enum import Enum
-
-
-      class Test(Enum):
-          a = "success"
-
-
-      print Test.a
-    '';
-
     python3 = writePython3Bin "test-writers-python3-bin" { libraries = [ python3Packages.pyyaml ]; } ''
       import yaml
 
@@ -111,17 +99,6 @@ let
       print "success\n" if true;
     '';
 
-    python2 = writePython2 "test-writers-python2" { libraries = [ python2Packages.enum ]; } ''
-      from enum import Enum
-
-
-      class Test(Enum):
-          a = "success"
-
-
-      print Test.a
-    '';
-
     python3 = writePython3 "test-writers-python3" { libraries = [ python3Packages.pyyaml ]; } ''
       import yaml
 
@@ -131,10 +108,6 @@ let
       print(y[0]['test'])
     '';
 
-    python2NoLibs = writePython2 "test-writers-python2-no-libs" {} ''
-      print("success")
-    '';
-
     python3NoLibs = writePython3 "test-writers-python3-no-libs" {} ''
       print("success")
     '';