add local submodules to nix path
Alan Pearce alan@alanpearce.eu
Thu, 30 May 2024 17:29:18 +0200
2 files changed, 22 insertions(+), 7 deletions(-)
jump to
M lib/default.nix → lib/default.nix
@@ -7,12 +7,19 @@ rec { importPathStore = p: "${append ../. "/${p}"}"; mkPathable = s: toString ( - if s.type == "local" - then (lib.path.append ../. s.outPath) - else s.outPath + if lib.path.subpath.isValid s + then (lib.path.append ../. s) + else s ); + kvPath = k: v: "${k}=${v}"; + + fromSources = sources: + lib.attrsets.mapAttrs + (k: v: v.outPath) + sources; + mkNixPath = sources: lib.attrsets.mapAttrsToList - (k: v: "${k}=${mkPathable v}") - (removeAttrs sources [ "__functor" ]); + (k: v: kvPath k (mkPathable v)) + sources; }
M shell.nix → shell.nix
@@ -3,9 +3,17 @@ sources = import ./npins; nixpkgs = sources.nixpkgs; pkgs = import nixpkgs { }; - lib = import ./lib { inherit pkgs; }; + inherit (pkgs) lib; + # lib = import ./lib { inherit pkgs; }; + inherit (import ./lib { inherit pkgs; }) mkNixPath fromSources; - nixPath = builtins.concatStringsSep ":" (lib.mkNixPath sources); + nixPath = builtins.concatStringsSep ":" (mkNixPath + ({ + personal = ./packages; + nixpkgs-overlays = ./overlays; + private = ./private; + } // (fromSources sources)) + ); in pkgs.mkShell {