diff options
| author | tv <tv@krebsco.de> | 2026-12-01 00:44:53 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-12-01 02:15:29 +0100 |
| commit | d81d9aaac6d50b6f2690cfb63987678d3ee90d4c (patch) | |
| tree | be2809ea9d722df3b7ebb957e606917a7ac5ac0a | |
| parent | ec852a9fcad1ce2652880556f2f18ade084da279 (diff) | |
lib: add debug, debugIf, pretty
pkgs/rust uses them.
| -rw-r--r-- | lib/pure.nix | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/pure.nix b/lib/pure.nix index 4178fcf7..0d807404 100644 --- a/lib/pure.nix +++ b/lib/pure.nix @@ -1,8 +1,28 @@ -{ lib, ... }: +{ lib +, localHomeDirectory ? /var/empty +, ... +}: let nixpkgs-lib = lib; stockholm.lib = with stockholm.lib; nixpkgs-lib // builtins // { + debug = s: builtins.trace ("[35m" + s + "[m") true; + + debugIf = c: s: if c then debug s else true; + + pretty = x: + if lib.isPath x then + if lib.hasPrefix (toString localHomeDirectory) (toString x) then + "~" + lib.removePrefix (toString localHomeDirectory) (toString x) + else if lib.hasPrefix (toString ./..) (toString x) then + "~/sync/src/hrm" + lib.removePrefix (toString ./..) (toString x) + else + toString x + else if lib.isDerivation x then + x.name + else + toString x; + evalModulesConfig = modules: let eval = evalModules { inherit modules; |
