diff options
author | Profpatsch <mail@profpatsch.de> | 2018-07-25 03:11:41 +0200 |
---|---|---|
committer | Profpatsch <mail@profpatsch.de> | 2018-07-25 03:17:14 +0200 |
commit | 097307c46fc5a7bda63a5916cfd1ee3ad661a0a6 (patch) | |
tree | 21aad88f5d534f3546e3d3a6b43ed64c2d275c6e /pkgs/profpatsch/execline/importer.nix | |
parent | fd8db354af44cfd2142186c762d2c280c0639233 (diff) |
pkgs/profpatsch: WIP execline experiments
* runExecline: like runCommand, but a lot more lightweight * symlink: symlink a given list of links together * importer: a small DSL to “import” “modules” into a build context Some highlights: * runExecline does not use any stdenv (apart from the `execline` build) * symlink uses netstrings to pass correct fields into the derivation * no use of bash, everything uses execline.
Diffstat (limited to 'pkgs/profpatsch/execline/importer.nix')
-rw-r--r-- | pkgs/profpatsch/execline/importer.nix | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/pkgs/profpatsch/execline/importer.nix b/pkgs/profpatsch/execline/importer.nix new file mode 100644 index 00000000..67464d17 --- /dev/null +++ b/pkgs/profpatsch/execline/importer.nix @@ -0,0 +1,45 @@ +{ lib, coreutils, s6-portable-utils, symlink }: +let + example = {from, as, just, ...}: + [ + (from coreutils [ + (just "echo") + (as "core-ls" "ls") + ]) + (from s6-portable-utils [ + (as "ls" "s6-ls") + (just "s6-echo") + ]) + ]; + + runImport = impsFn: + let + combinators = rec { + from = source: imports: { + inherit source imports; + }; + as = newname: oldname: { + inherit oldname newname; + }; + just = x: as x x; + }; + + # Drv -> As -> Symlink + toBin = module: {oldname, newname}: { + dest = "bin/${newname}"; + orig = "${module}/bin/${oldname}"; + }; + # List (Import { source: Drv + # , imports: List (As { oldname: String + # , newname: String })) + # -> Drv + run = imps: + symlink "foo" (lib.concatLists + (map ({source, imports}: + map (toBin source) imports) + imps)); + + # TODO: typecheck w/ newtypes + in run (impsFn combinators); + +in runImport example |