Added custom lib (stolen from hlissner's dotifles)

This commit is contained in:
marc committed 2022-11-14 21:19:51 +01:00
1 parent e22078b34a
commit 5c609ddd42
11 files changed
+202 -113

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
{ inputs, lib, pkgs, ... }:
let
inherit (lib) makeExtensible attrValues foldr;
inherit (modules) mapModules;
# We define modules, so we can use mapModules
modules = import ./modules.nix {
inherit lib;
self.attrs = import ./attrs.nix { inherit lib; self = {}; };
};
# mylib = {
# "attrs" = import "attrs.nix" { selg lib pkgs inputs };
# "options" = import "options.nix" { selg lib pkgs inputs };
# ...
# "extend": <<lambda>>; # from makeExtensible
# "__unfix__": <<lambda>>; # from makeExtensible
# }
mylib = makeExtensible (self:
with self; mapModules ./.
(file: import file { inherit self lib pkgs inputs; }));
in
# We have
# (attrValues super) = [ (import "attrs.nix" {...}) (import "options.nix" {...}) ... ]
# And thus
# mylib.extend(...) = (import "attrs.nix" {...}) // (import "options.nix" {...}) // ...
# Which is what we want, default.nix returns all modules merged (and extensible)
mylib.extend
(self: super:
foldr (a: b: a // b) {} (attrValues super))