diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2021-09-13 01:00:43 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2021-10-15 23:15:02 +0200 |
commit | 27dd65fc95a91155367acbe15754dc22c8869552 (patch) | |
tree | 73e85423c5b359c87e51749f7791cda61a900315 /flakes/lib | |
parent | def6ad9963ed6f3f81fddea854f2a7b110dd5183 (diff) | |
download | Nix-27dd65fc95a91155367acbe15754dc22c8869552.tar.gz Nix-27dd65fc95a91155367acbe15754dc22c8869552.tar.zst Nix-27dd65fc95a91155367acbe15754dc22c8869552.zip |
Add filesWatcher flake
Diffstat (limited to 'flakes/lib')
-rw-r--r-- | flakes/lib/flake.lock | 26 | ||||
-rw-r--r-- | flakes/lib/flake.nix | 28 |
2 files changed, 54 insertions, 0 deletions
diff --git a/flakes/lib/flake.lock b/flakes/lib/flake.lock new file mode 100644 index 0000000..3e0b21e --- /dev/null +++ b/flakes/lib/flake.lock | |||
@@ -0,0 +1,26 @@ | |||
1 | { | ||
2 | "nodes": { | ||
3 | "nixpkgs": { | ||
4 | "locked": { | ||
5 | "lastModified": 1631570365, | ||
6 | "narHash": "sha256-vc6bfo0hijpicdUDiui2DvZXmpIP2iqOFZRcpMOuYPo=", | ||
7 | "owner": "NixOS", | ||
8 | "repo": "nixpkgs", | ||
9 | "rev": "df7113c0727881519248d4c7d080324e0ee3327b", | ||
10 | "type": "github" | ||
11 | }, | ||
12 | "original": { | ||
13 | "owner": "NixOS", | ||
14 | "repo": "nixpkgs", | ||
15 | "type": "github" | ||
16 | } | ||
17 | }, | ||
18 | "root": { | ||
19 | "inputs": { | ||
20 | "nixpkgs": "nixpkgs" | ||
21 | } | ||
22 | } | ||
23 | }, | ||
24 | "root": "root", | ||
25 | "version": 7 | ||
26 | } | ||
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 | } | ||