about summary refs log tree commit diff
path: root/pkgs/profpatsch/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/profpatsch/default.nix')
-rw-r--r--pkgs/profpatsch/default.nix94
1 files changed, 64 insertions, 30 deletions
diff --git a/pkgs/profpatsch/default.nix b/pkgs/profpatsch/default.nix
index a4378ecf..dc746c2e 100644
--- a/pkgs/profpatsch/default.nix
+++ b/pkgs/profpatsch/default.nix
@@ -5,11 +5,25 @@ let
 
   # wrapper for execlineb that doesn’t need the execline commands
   # in PATH to work (making them appear like “builtins”)
+  # TODO: upstream into nixpkgs
+  # TODO: the grep could be nicer
   execlineb-with-builtins =
     let eldir = "${pkgs.execline}/bin";
     in pkgs.writeScriptBin "execlineb" ''
       #!${eldir}/execlineb -s0
+      # appends the execlineb bin dir to PATH if not yet in PATH
       ${eldir}/define eldir ${eldir}
+      ''${eldir}/ifelse
+      {
+        # since this is nix, we can grep for the execline drv hash in PATH
+        # to see whether it’s already in there
+        ''${eldir}/pipeline
+        { ${pkgs.coreutils}/bin/printenv PATH }
+        ${pkgs.gnugrep}/bin/grep --quiet "${eldir}"
+      }
+      # it’s there already
+      { ''${eldir}/execlineb $@ }
+      # not there yet, add it
       ''${eldir}/importas oldpath PATH
       ''${eldir}/export PATH "''${eldir}:''${oldpath}"
       ''${eldir}/execlineb $@
@@ -46,6 +60,52 @@ let
       allowSubstitutes = false;
     }) cmd;
 
+  testing = import ./testing {
+    inherit stdenv lib;
+    inherit (runExeclineFns) runExecline;
+    inherit (pkgs) runCommand;
+    bin = bins pkgs.s6PortableUtils [ "s6-touch" "s6-echo" ];
+  };
+
+  runExeclineFns =
+    # todo: factor out calling tests
+    let
+      it = import ./execline/run-execline.nix {
+        bin = (bins execlineb-with-builtins [ "execlineb" ])
+           // (bins pkgs.execline [ "redirfd" "importas" "exec" ]);
+        inherit stdenv lib;
+      };
+      itLocal = name: args: execline:
+        it name (args // {
+          derivationArgs = args.derivationArgs or {} // {
+            preferLocalBuild = true;
+            allowSubstitutes = false;
+          };
+        }) execline;
+
+      tests = import ./execline/run-execline-tests.nix {
+        # can’t use runExeclineLocal in the tests,
+        # because it is tested by the tests (well, it does
+        # work, but then you have to run the tests every time)
+        runExecline = it;
+        inherit (testing) drvSeqL;
+        inherit (pkgs) coreutils;
+        inherit stdenv;
+        bin = (bins execlineb-with-builtins [ "execlineb" ])
+           // (bins pkgs.execline [
+                 { use = "if"; as = "execlineIf"; }
+                 "redirfd" "importas"
+               ])
+           // (bins pkgs.s6PortableUtils
+                [ "s6-cat" "s6-grep" "s6-touch" "s6-test" "s6-chmod" ]);
+       };
+    in {
+      runExecline = it;
+      runExeclineLocal = name: args: execline:
+        testing.drvSeqL tests (itLocal name args execline);
+    };
+
+
 in rec {
   inherit (nixperiments)
     # filterSource by parsing a .gitignore file
@@ -60,10 +120,11 @@ in rec {
     json2json json2string;
 
   backlight = callPackage ./backlight { inherit (pkgs.xorg) xbacklight; };
-  display-infos = callPackage ./display-infos {};
+  display-infos = callPackage ./display-infos { inherit sfttime; };
   git-commit-index = callPackage ./git-commit-index { inherit script runCommandLocal; };
   nix-http-serve = callPackage ./nix-http-serve {};
   nman = callPackage ./nman {};
+  sfttime = callPackage ./sfttime {};
   show-qr-code = callPackage ./show-qr-code {};
   warpspeed = callPackage ./warpspeed {
     inherit (pkgs.haskellPackages) ghcWithPackages;
@@ -90,35 +151,8 @@ in rec {
     ];
   });
 
-  runExecline =
-    # todo: factor out calling tests
-    let
-      it = import ./execline/run-execline.nix {
-        bin = (bins execlineb-with-builtins [ "execlineb" ])
-           // (bins pkgs.execline [ "redirfd" "importas" "exec" ]);
-        inherit stdenv;
-      };
-      tests = import ./execline/run-execline-tests.nix {
-        runExecline = it;
-        inherit (testing) drvSeqL;
-        inherit (pkgs) coreutils;
-        inherit stdenv;
-        bin = (bins execlineb-with-builtins [ "execlineb" ])
-           // (bins pkgs.execline [
-                 { use = "if"; as = "execlineIf"; }
-                 "redirfd" "importas"
-               ])
-           // (bins pkgs.s6PortableUtils
-                [ "s6-cat" "s6-grep" "s6-touch" "s6-test" "s6-chmod" ]);
-       };
-    in tests;
-
-
-  testing = import ./testing {
-    inherit stdenv lib runExecline;
-    inherit (pkgs) runCommand;
-    bin = bins pkgs.s6PortableUtils [ "s6-touch" "s6-echo" ];
-  };
+  inherit (runExeclineFns)
+    runExecline runExeclineLocal;
 
   symlink = pkgs.callPackage ./execline/symlink.nix {
     inherit runExecline;