nix-config/lib/default.nix
Bruno BELANYI 331b7cf8e3 lib: create 'my' extensions
Inspired by this [1] repo, I want to add some functions to `lib.my`. I
would have liked to make it work without having to use an overlay, but I
did not manage to do it...

[1]: https://github.com/hlissner/dotfiles
2021-03-14 12:18:09 +00:00

22 lines
563 B
Nix

# Extension mechanism shamelessly stolen from [1].
#
# [1]: https://github.com/hlissner/dotfiles/blob/master/lib/default.nix
{ lib, pkgs, inputs }:
let
inherit (lib) makeExtensible attrValues foldr;
inherit (modules) mapModules;
modules = import ./modules.nix {
inherit lib;
self.attrs = import ./attrs.nix { inherit lib; self = { }; };
};
mylib = makeExtensible (self:
with self; mapModules ./.
(file: import file { inherit self lib pkgs inputs; })
);
in
mylib.extend (self: super:
foldr (a: b: a // b) { } (attrValues super)
)