aboutsummaryrefslogtreecommitdiff
path: root/flakes/lib/flake.nix
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2021-09-13 01:00:43 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2021-10-15 23:15:02 +0200
commit27dd65fc95a91155367acbe15754dc22c8869552 (patch)
tree73e85423c5b359c87e51749f7791cda61a900315 /flakes/lib/flake.nix
parentdef6ad9963ed6f3f81fddea854f2a7b110dd5183 (diff)
downloadNix-27dd65fc95a91155367acbe15754dc22c8869552.tar.gz
Nix-27dd65fc95a91155367acbe15754dc22c8869552.tar.zst
Nix-27dd65fc95a91155367acbe15754dc22c8869552.zip
Add filesWatcher flake
Diffstat (limited to 'flakes/lib/flake.nix')
-rw-r--r--flakes/lib/flake.nix28
1 files changed, 28 insertions, 0 deletions
diff --git a/flakes/lib/flake.nix b/flakes/lib/flake.nix
new file mode 100644
index 0000000..8faa136
--- /dev/null
+++ b/flakes/lib/flake.nix
@@ -0,0 +1,28 @@
1{
2 inputs.nixpkgs.url = "github:NixOS/nixpkgs";
3
4 description = "Useful libs";
5 outputs = { self, nixpkgs }: {
6 lib = rec {
7 computeNarHash = path:
8 let pkgs = import nixpkgs {};
9 in
10 builtins.readFile (pkgs.runCommand "narHash" {
11 buildInputs = [ pkgs.nix ];
12 } "echo -n $(nix hash-path ${path}) > $out");
13
14 withNarKeyCompat = flakeCompat: path: moduleAttrs:
15 let module = (flakeCompat path).${moduleAttrs};
16 narHash = computeNarHash path;
17 in if builtins.isFunction module
18 then args@{ config, lib, pkgs, ... }: (module args // { key = narHash; })
19 else module // { key = narHash; };
20
21 withNarKey = dep: moduleAttrs:
22 let module = dep.${moduleAttrs};
23 in if builtins.isFunction module
24 then args@{ config, lib, pkgs, ... }: (module args // { key = dep.narHash; })
25 else module // { key = dep.narHash; };
26 };
27 };
28}