From 782e0000196146183ee4a7e91e60424c24652d2f Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sat, 4 May 2024 09:27:40 +0200 Subject: nix: set nix.nixPath --- lib/default.nix | 21 +++++++++++++++++++++ shell.nix | 18 ++---------------- system/settings/configuration/nix.nix | 1 + system/settings/pin.nix | 8 ++++++++ 4 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 lib/default.nix create mode 100644 system/settings/pin.nix 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; +} -- cgit 1.4.1