summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--lib/default.nix21
-rw-r--r--shell.nix18
-rw-r--r--system/settings/configuration/nix.nix1
-rw-r--r--system/settings/pin.nix8
4 files changed, 32 insertions, 16 deletions
diff --git a/lib/default.nix b/lib/default.nix
new file mode 100644
index 00000000..93f64059
--- /dev/null
+++ b/lib/default.nix
@@ -0,0 +1,21 @@
+{ pkgs }:
+with builtins;
+let
+  inherit (pkgs) lib;
+in
+rec {
+  importPathStore = p: "${append ../. "/${p}"}";
+
+  mkPathable = s:
+    if
+      s.type == "local"
+    then
+      lib.path.append ../. s.outPath
+    else
+      toString s.outPath
+  ;
+
+  mkNixPath = sources: lib.attrsets.mapAttrsToList
+    (k: v: "${k}=${mkPathable v}")
+    (removeAttrs sources [ "__functor" ]);
+}
diff --git a/shell.nix b/shell.nix
index 9167cb7e..81938c3f 100644
--- a/shell.nix
+++ b/shell.nix
@@ -2,26 +2,12 @@ with builtins;
 
 let
   sources = import ./nix/sources.nix;
-  sourcesJSON = fromJSON (readFile ./nix/sources.json);
 
   nixpkgs = sources.nixpkgs;
   pkgs = import nixpkgs { };
-  inherit (pkgs.lib) path attrsets;
+  lib = import ./lib { inherit pkgs; };
 
-  mkPathable = v: toString (
-    if
-      path.subpath.isValid v
-    then
-      path.append ./. v
-    else
-      v
-  );
-
-  nixPath = concatStringsSep ":" (
-    attrsets.mapAttrsToList
-      (k: v: "${k}=${mkPathable (getAttr "outPath" v)}")
-      (intersectAttrs sourcesJSON sources)
-  );
+  nixPath = concatStringsSep ":" (lib.mkNixPath sources);
 in
 pkgs.mkShell
 {
diff --git a/system/settings/configuration/nix.nix b/system/settings/configuration/nix.nix
index 57c7cedf..97cd7aeb 100644
--- a/system/settings/configuration/nix.nix
+++ b/system/settings/configuration/nix.nix
@@ -3,6 +3,7 @@
 , pkgs
 , ...
 }: {
+  imports = [ ../pin.nix ];
   nix = {
     settings = {
       cores = lib.mkDefault 0;
diff --git a/system/settings/pin.nix b/system/settings/pin.nix
new file mode 100644
index 00000000..e282cf66
--- /dev/null
+++ b/system/settings/pin.nix
@@ -0,0 +1,8 @@
+{ pkgs, ... }:
+let
+  lib = import ../../lib { inherit pkgs; };
+  sources = import ../../nix/sources.nix;
+in
+{
+  nix.nixPath = lib.mkNixPath sources;
+}