about summary refs log tree commit diff stats
path: root/lib/default.nix
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-12-20 17:50:16 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-12-20 17:50:16 +0100
commit0ac11166a8fb22d1ce4de111f46e8a3ba1de7663 (patch)
tree25187cbc4273c69ca553dc0450b69fdfb9bea19a /lib/default.nix
parentfix(modules/lf): Always retry connecting to the server (diff)
downloadnixos-config-0ac11166a8fb22d1ce4de111f46e8a3ba1de7663.tar.gz
nixos-config-0ac11166a8fb22d1ce4de111f46e8a3ba1de7663.zip
refactor(lib): Upstream `lib` to vhack.eu
This allows to share it with the server config.
Diffstat (limited to '')
-rw-r--r--lib/default.nix42
1 files changed, 0 insertions, 42 deletions
diff --git a/lib/default.nix b/lib/default.nix
deleted file mode 100644
index dfa9fb17..00000000
--- a/lib/default.nix
+++ /dev/null
@@ -1,42 +0,0 @@
-{}: let
-  # string -> string -> string
-  colorize = color: string: "[${color}m${string}";
-
-  # Taken from `nixpkgs/lib`.
-  # Is here to avoid a dependency on `lib` (making this file easy to test with `nix eval`)
-  warn =
-    # Since Nix 2.23, https://github.com/NixOS/nix/pull/10592
-    builtins.warn
-    or (
-      # Do not eta reduce v, so that we have the same strictness as `builtins.warn`.
-      msg: v:
-      # `builtins.warn` requires a string message, so we enforce that in our implementation, so that callers aren't accidentally incompatible with newer Nix versions.
-        assert builtins.isString msg;
-          builtins.trace "${colorize "1;35" "evaluation warning:"} ${msg}" v
-    );
-in {
-  mkByName = import ./by-name-overlay.nix {inherit warn;};
-
-  # Only merge two attrsets if the RHS does not share names with the LHS.
-  # # Example:
-  # ```nix
-  # let
-  # attr1 = {atuin = "first"; default = "second";};
-  # attr2 = {atuin = "hi"; other = "hi2";};
-  # in
-  # maybeMerge attr1 attr2 "Failed to merge"
-  # ```
-  # # Type:
-  # {} -> {} -> string -> {}
-  maybeMerge = lhs: rhs: sourceSet: let
-    overridden = builtins.intersectAttrs lhs rhs;
-    merged = lhs // rhs;
-    mkWarning = overriddenAttrs:
-      builtins.concatStringsSep " " (builtins.map (colorize "1;97") (builtins.attrNames overriddenAttrs));
-  in
-    if overridden != {}
-    then
-      warn "Attributes overridden while merging ${sourceSet}: ${mkWarning overridden}"
-      merged
-    else merged;
-}