# nixLib - A library of nix functions for vhack.eu # # Copyright (C) 2025 Benedikt Peetz # SPDX-License-Identifier: LGPL-3.0-or-later # # This file is part of vhack.eu's nix library. # # You should have received a copy of the License along with this program. # If not, see . {lib}: let # string -> string -> string colorize = color: string: "[${color}m${string}"; in { /** Converts a `by-name` structured directory into. * */ mkByName = import ./by-name.nix; # Warn while merging two attrsets if the RHS shares names with the LHS. # # # Example: # ```nix # let # attr1 = {atuin = "first"; default = "second";}; # attr2 = {atuin = "hi"; other = "hi2";}; # in # warnMerge attr1 attr2 "attr1 core value set" # ``` # # # Type: # {} -> {} -> string -> {} warnMerge = 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 builtins.warn "Attributes overridden while merging ${sourceSet}: ${mkWarning overridden}" merged else merged; math = import ./math.nix {inherit lib;}; options = import ./options.nix {inherit lib;}; }