summary refs log tree commit diff
path: root/nixos/modules/system/activation/top-level.nix
diff options
context:
space:
mode:
authorrnhmjoj <rnhmjoj@inventati.org>2021-02-24 20:53:45 +0100
committerrnhmjoj <rnhmjoj@inventati.org>2021-03-31 21:35:37 +0200
commit61b7cab4811e0e90937bcc8b4c1ca32b387c895c (patch)
treedb5dc9f491f86fe61dc23dcf042ea6eed08327aa /nixos/modules/system/activation/top-level.nix
parent3966039910db296c1c2dca2120ab0976952fe11c (diff)
downloadnixpkgs-61b7cab4811e0e90937bcc8b4c1ca32b387c895c.tar
nixpkgs-61b7cab4811e0e90937bcc8b4c1ca32b387c895c.tar.gz
nixpkgs-61b7cab4811e0e90937bcc8b4c1ca32b387c895c.tar.bz2
nixpkgs-61b7cab4811e0e90937bcc8b4c1ca32b387c895c.tar.lz
nixpkgs-61b7cab4811e0e90937bcc8b4c1ca32b387c895c.tar.xz
nixpkgs-61b7cab4811e0e90937bcc8b4c1ca32b387c895c.tar.zst
nixpkgs-61b7cab4811e0e90937bcc8b4c1ca32b387c895c.zip
treewide: use perl.withPackages when possible
Since 03eaa48 added perl.withPackages, there is a canonical way to
create a perl interpreter from a list of libraries, for use in script
shebangs or generic build inputs. This method is declarative (what we
are doing is clear), produces short shebangs[1] and needs not to wrap
existing scripts.

Unfortunately there are a few exceptions that I've found:

  1. Scripts that are calling perl with the -T switch. This makes perl
  ignore PERL5LIB, which is what perl.withPackages is using to inform
  the interpreter of the library paths.

  2. Perl packages that depends on libraries in their own path. This
  is not possible because perl.withPackages works at build time. The
  workaround is to add `-I $out/${perl.libPrefix}` to the shebang.

In all other cases I propose to switch to perl.withPackages.

[1]: https://lwn.net/Articles/779997/
Diffstat (limited to 'nixos/modules/system/activation/top-level.nix')
-rw-r--r--nixos/modules/system/activation/top-level.nix3
1 files changed, 1 insertions, 2 deletions
diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix
index b0f77ca3fb8..9dbca4e33f3 100644
--- a/nixos/modules/system/activation/top-level.nix
+++ b/nixos/modules/system/activation/top-level.nix
@@ -113,8 +113,7 @@ let
     configurationName = config.boot.loader.grub.configurationName;
 
     # Needed by switch-to-configuration.
-
-    perl = "${pkgs.perl}/bin/perl " + (concatMapStringsSep " " (lib: "-I${lib}/${pkgs.perl.libPrefix}") (with pkgs.perlPackages; [ FileSlurp NetDBus XMLParser XMLTwig ]));
+    perl = pkgs.perl.withPackages (p: with p; [ FileSlurp NetDBus XMLParser XMLTwig ]);
   };
 
   # Handle assertions and warnings