]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - flakes/lib/flake.nix
Bump backports
[perso/Immae/Config/Nix.git] / flakes / lib / flake.nix
index 8faa136898ce51107e1ab6156f96a1c3b1cf40de..a352c4c018a4a395c52cb600cc0cba4d452b2e1a 100644 (file)
@@ -4,25 +4,19 @@
   description = "Useful libs";
   outputs = { self, nixpkgs }: {
     lib = rec {
-      computeNarHash = path:
-        let pkgs = import nixpkgs {};
-        in
-          builtins.readFile (pkgs.runCommand "narHash" {
-            buildInputs = [ pkgs.nix ];
-          } "echo -n $(nix hash-path ${path}) > $out");
-
       withNarKeyCompat = flakeCompat: path: moduleAttrs:
         let module = (flakeCompat path).${moduleAttrs};
-            narHash = computeNarHash path;
+            key = builtins.hashString "sha256" (builtins.path { inherit path; name = "source"; });
         in if builtins.isFunction module
-          then args@{ config, lib, pkgs, ... }: (module args // { key = narHash; })
-          else module // { key = narHash; };
+          then args@{ config, lib, pkgs, ... }: (module args // { inherit key; })
+          else module // { inherit key; };
 
       withNarKey = dep: moduleAttrs:
         let module = dep.${moduleAttrs};
+            key = builtins.hashString "sha256" (builtins.path { path = dep.sourceInfo.outPath; name = "source"; });
         in if builtins.isFunction module
-          then args@{ config, lib, pkgs, ... }: (module args // { key = dep.narHash; })
-          else module // { key = dep.narHash; };
+          then args@{ config, lib, pkgs, ... }: (module args // { inherit key; })
+          else module // { inherit key; };
     };
   };
 }