From 9cd634f650551080b01e06763c11836ce33e0613 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 12 Sep 2018 14:57:09 +0200 Subject: pkgs: add writePerl{,Bin} --- examples/hello_world.nix | 3 +++ examples/simple.nix | 4 ++++ pkgs/default.nix | 17 +++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/examples/hello_world.nix b/examples/hello_world.nix index 4bb3db1..4944c13 100644 --- a/examples/hello_world.nix +++ b/examples/hello_world.nix @@ -18,6 +18,9 @@ in { main = do putStrLn "hello world" ''; + perl = pkgs.writePerl "hello-world" {} '' + print "hello world\n"; + ''; python2 = pkgs.writePython2 "hello-world" {} '' print "hello world" ''; diff --git a/examples/simple.nix b/examples/simple.nix index 32a4cee..ad62b84 100644 --- a/examples/simple.nix +++ b/examples/simple.nix @@ -14,6 +14,10 @@ in { main :: IO () main = print Rolf ''; + perl = pkgs.writePerl "simple.pl" { deps = [ pkgs.perlPackages.boolean ]; } '' + use boolean; + print "Howdy!\n" if true; + ''; python2 = pkgs.writePython2 "hello-world" { deps = [ pkgs.python2Packages.pyyaml ]; } '' import yaml diff --git a/pkgs/default.nix b/pkgs/default.nix index 29457ca..b7b0dde 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -313,6 +313,23 @@ pkgs: oldpkgs: { ${pkgs.cabal2nix}/bin/cabal2nix ${path} > $out ''); + writePerl = name: { deps ? [] }: + let + perl-env = pkgs.buildEnv { + name = "perl-environment"; + paths = deps; + pathsToLink = [ + "/lib/perl5/site_perl" + ]; + }; + in + pkgs.makeScriptWriter { + interpreter = "${pkgs.perl}/bin/perl -I ${perl-env}/lib/perl5/site_perl"; + } name; + + writePerlBin = name: + pkgs.writePerl "/bin/${name}"; + writePython2 = name: { deps ? [], flakeIgnore ? [] }: let py = pkgs.python2.withPackages (ps: deps); -- cgit v1.2.3