]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - flakes/lib/flake.nix
a352c4c018a4a395c52cb600cc0cba4d452b2e1a
[perso/Immae/Config/Nix.git] / flakes / lib / flake.nix
1 {
2 inputs.nixpkgs.url = "github:NixOS/nixpkgs";
3
4 description = "Useful libs";
5 outputs = { self, nixpkgs }: {
6 lib = rec {
7 withNarKeyCompat = flakeCompat: path: moduleAttrs:
8 let module = (flakeCompat path).${moduleAttrs};
9 key = builtins.hashString "sha256" (builtins.path { inherit path; name = "source"; });
10 in if builtins.isFunction module
11 then args@{ config, lib, pkgs, ... }: (module args // { inherit key; })
12 else module // { inherit key; };
13
14 withNarKey = dep: moduleAttrs:
15 let module = dep.${moduleAttrs};
16 key = builtins.hashString "sha256" (builtins.path { path = dep.sourceInfo.outPath; name = "source"; });
17 in if builtins.isFunction module
18 then args@{ config, lib, pkgs, ... }: (module args // { inherit key; })
19 else module // { inherit key; };
20 };
21 };
22 }