pkgs: get functions via rec

To import the writers outside of an overlay
remotes/lass/rec-lib
lassulus 8 years ago
parent 4d86790456
commit 2090f5d655
  1. 38
      pkgs/default.nix

@ -1,8 +1,8 @@
with import ../lib; with import ../lib;
pkgs: oldpkgs: { pkgs: oldpkgs: rec {
execve = name: { filename, argv ? null, envp ? {}, destination ? "" }: execve = name: { filename, argv ? null, envp ? {}, destination ? "" }:
pkgs.writeC name { inherit destination; } /* c */ '' writeC name { inherit destination; } /* c */ ''
#include <unistd.h> #include <unistd.h>
static char *const filename = ${toC filename}; static char *const filename = ${toC filename};
@ -27,11 +27,11 @@ pkgs: oldpkgs: {
''; '';
execveBin = name: cfg: execveBin = name: cfg:
pkgs.execve name (cfg // { destination = "/bin/${name}"; }); execve name (cfg // { destination = "/bin/${name}"; });
makeScriptWriter = { interpreter, check ? null }: name: text: makeScriptWriter = { interpreter, check ? null }: name: text:
assert (with types; either absolute-pathname filename).check name; assert (with types; either absolute-pathname filename).check name;
pkgs.write (baseNameOf name) { write (baseNameOf name) {
${optionalString (types.absolute-pathname.check name) name} = { ${optionalString (types.absolute-pathname.check name) name} = {
inherit check; inherit check;
executable = true; executable = true;
@ -110,7 +110,7 @@ pkgs: oldpkgs: {
writeBash = name: text: writeBash = name: text:
assert (with types; either absolute-pathname filename).check name; assert (with types; either absolute-pathname filename).check name;
pkgs.write (baseNameOf name) { write (baseNameOf name) {
${optionalString (types.absolute-pathname.check name) name} = { ${optionalString (types.absolute-pathname.check name) name} = {
executable = true; executable = true;
text = "#! ${pkgs.bash}/bin/bash\n${text}"; text = "#! ${pkgs.bash}/bin/bash\n${text}";
@ -119,7 +119,7 @@ pkgs: oldpkgs: {
writeBashBin = name: writeBashBin = name:
assert types.filename.check name; assert types.filename.check name;
pkgs.writeBash "/bin/${name}"; writeBash "/bin/${name}";
writeC = name: { destination ? "" }: text: pkgs.runCommand name { writeC = name: { destination ? "" }: text: pkgs.runCommand name {
inherit text; inherit text;
@ -137,13 +137,13 @@ pkgs: oldpkgs: {
strip --strip-unneeded "$exe" strip --strip-unneeded "$exe"
''; '';
writeDash = pkgs.makeScriptWriter { writeDash = makeScriptWriter {
interpreter = "${pkgs.dash}/bin/dash"; interpreter = "${pkgs.dash}/bin/dash";
}; };
writeDashBin = name: writeDashBin = name:
assert types.filename.check name; assert types.filename.check name;
pkgs.writeDash "/bin/${name}"; writeDash "/bin/${name}";
writeEximConfig = name: text: pkgs.runCommand name { writeEximConfig = name: text: pkgs.runCommand name {
inherit text; inherit text;
@ -259,9 +259,9 @@ pkgs: oldpkgs: {
writeJq = name: text: writeJq = name: text:
assert (with types; either absolute-pathname filename).check name; assert (with types; either absolute-pathname filename).check name;
pkgs.write (baseNameOf name) { write (baseNameOf name) {
${optionalString (types.absolute-pathname.check name) name} = { ${optionalString (types.absolute-pathname.check name) name} = {
check = pkgs.writeDash "jqcheck.sh" '' check = writeDash "jqcheck.sh" ''
exec ${pkgs.jq}/bin/jq -f "$1" < /dev/null exec ${pkgs.jq}/bin/jq -f "$1" < /dev/null
''; '';
inherit text; inherit text;
@ -288,31 +288,31 @@ pkgs: oldpkgs: {
let let
py = pkgs.python2.withPackages(ps: attrVals deps ps); py = pkgs.python2.withPackages(ps: attrVals deps ps);
in in
pkgs.makeScriptWriter { makeScriptWriter {
interpreter = "${py}/bin/python"; interpreter = "${py}/bin/python";
check = pkgs.writeDash "python2check.sh" '' check = writeDash "python2check.sh" ''
exec ${pkgs.python2Packages.flake8}/bin/flake8 --show-source "$1" exec ${pkgs.python2Packages.flake8}/bin/flake8 --show-source "$1"
''; '';
} name; } name;
writePython2Bin = name: writePython2Bin = d: name:
pkgs.writePython2 "/bin/${name}"; writePython2 d "/bin/${name}";
writePython3 = name: deps: writePython3 = name: deps:
let let
py = pkgs.python3.withPackages(ps: attrVals deps ps); py = pkgs.python3.withPackages(ps: attrVals deps ps);
in in
pkgs.makeScriptWriter { makeScriptWriter {
interpreter = "${py}/bin/python"; interpreter = "${py}/bin/python";
check = pkgs.writeDash "python3check.sh" '' check = writeDash "python3check.sh" ''
exec ${pkgs.python3Packages.flake8}/bin/flake8 --show-source "$1" exec ${pkgs.python3Packages.flake8}/bin/flake8 --show-source "$1"
''; '';
} name; } name;
writePython3Bin = name: writePython3Bin = d: name:
pkgs.writePython3 "/bin/${name}"; writePython3 d "/bin/${name}";
writeSed = pkgs.makeScriptWriter { writeSed = makeScriptWriter {
interpreter = "${pkgs.gnused}/bin/sed -f"; interpreter = "${pkgs.gnused}/bin/sed -f";
}; };
} }

Loading…
Cancel
Save