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

Loading…
Cancel
Save