From 10eb6546fc88c73154d622048248266c64b3c53a Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 1 Dec 2026 00:44:53 +0000 Subject: lib: add debug, debugIf, pretty pkgs/rust uses them. --- lib/pure.nix | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'lib') 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 ("" + s + "") 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; -- cgit v1.3.1