about summary refs log tree commit diff
path: root/users/Profpatsch/lib.nix
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2021-01-10T19·56+0100
committerProfpatsch <mail@profpatsch.de>2021-01-10T20·03+0000
commit2f807d7f141068d2d60676a89213eaa5353ca6e0 (patch)
tree4f2b13aab630c4febb5d9ccd3d701565009b6c39 /users/Profpatsch/lib.nix
parentc1cb4c260c97ad83a68f323dfeb4534f972c375a (diff)
feat(users/Profpatsch): add a rewriter for lib.stdenv changes r/2070
This is in order to advance the rewriting from stdenv.lib to lib.
https://github.com/NixOS/nixpkgs/issues/108938

The hard part about changing the argument is that a package might not
include lib in its arguments, which is why I use hnix to check whether
lib is included and add it to the import list if it doesn’t already
exist there.

So far, only the really common pattern of

    meta = with stdenv.lib;

is rewritten.

Change-Id: I370f0a321b0e5a5bd21ec21fc7cefdd65ec845ed
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2345
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
Diffstat (limited to 'users/Profpatsch/lib.nix')
-rw-r--r--users/Profpatsch/lib.nix23
1 files changed, 23 insertions, 0 deletions
diff --git a/users/Profpatsch/lib.nix b/users/Profpatsch/lib.nix
new file mode 100644
index 0000000000..8120a01d5b
--- /dev/null
+++ b/users/Profpatsch/lib.nix
@@ -0,0 +1,23 @@
+{ depot, pkgs, ... }:
+let
+  bins = depot.nix.getBins pkgs.coreutils ["printf" "echo"];
+
+  debugExec = msg: depot.nix.writeExecline "debug-exec" {} [
+    "if" [
+      "fdmove" "-c" "1" "2"
+      "if" [ bins.printf "%s: " msg ]
+      "if" [ bins.echo "$@" ]
+    ]
+    "$@"
+  ];
+
+  eprintf = depot.nix.writeExecline "eprintf" {} [
+    "fdmove" "-c" "1" "2" bins.printf "%s" "$@"
+  ];
+
+in {
+  inherit
+    debugExec
+    eprintf
+    ;
+}