+9
nixpkgs-extend-lib/flake.nix
+9
nixpkgs-extend-lib/flake.nix
+28
nixpkgs-extend-lib/lib/default.nix
+28
nixpkgs-extend-lib/lib/default.nix
···
1
+
# modified from
2
+
# https://github.com/isabelroses/dotfiles/blob/c4b76ef3db97976ba7a26127d38cae7a11c056e9/modules/flake/lib/default.nix
3
+
#
4
+
# following https://github.com/NixOS/nixpkgs/blob/77ee426a4da240c1df7e11f48ac6243e0890f03e/lib/default.nix
5
+
# as a rough template we can create our own extensible lib and expose it to the flake
6
+
# we can then use that elsewhere like our hosts
7
+
{ inputs, ... }:
8
+
let
9
+
nixpkgsLib = inputs.nixpkgs.lib;
10
+
11
+
myLib = nixpkgsLib.makeExtensible (
12
+
self:
13
+
let
14
+
callLib = file: import file { lib = self; };
15
+
in
16
+
{
17
+
math = callLib ./math.nix;
18
+
19
+
# reexport from our math namespace
20
+
inherit (self.math) increment;
21
+
}
22
+
);
23
+
24
+
# we need to extend myLib with the nixpkgs lib to get the full set of functions
25
+
# if we do it the otherway around we will get errors saying mkMerge and so on don't exist
26
+
finalLib = myLib.extend (_: _: nixpkgsLib);
27
+
in
28
+
finalLib