summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-12-01 00:44:53 +0000
committertv <tv@krebsco.de>2026-12-01 02:15:29 +0100
commit10eb6546fc88c73154d622048248266c64b3c53a (patch)
tree5d837535951f2fe118e528c099ab7c9d47602966 /lib
parentf1cd643abeb470065dd7b862617db71aef3b0dfc (diff)
lib: add debug, debugIf, pretty
pkgs/rust uses them.
Diffstat (limited to 'lib')
-rw-r--r--lib/pure.nix22
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 ("" + 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;