feat(users/Profpatsch): add a rewriter for lib.stdenv changes

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>
This commit is contained in:
Profpatsch 2021-01-10 20:56:52 +01:00
parent c1cb4c260c
commit 2f807d7f14
3 changed files with 187 additions and 0 deletions

23
users/Profpatsch/lib.nix Normal file
View file

@ -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
;
}