From 097307c46fc5a7bda63a5916cfd1ee3ad661a0a6 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Wed, 25 Jul 2018 03:11:41 +0200 Subject: pkgs/profpatsch: WIP execline experiments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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. --- pkgs/profpatsch/execline/importer.nix | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 pkgs/profpatsch/execline/importer.nix (limited to 'pkgs/profpatsch/execline/importer.nix') 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 -- cgit 1.4.1