Skip to content

Commit 8c3fe9c

Browse files
committed
feat(flake-module): add module path special args
That is, provide `modulesPath` and `extraModulesPath` in the arguments to devshell configurations defined using the flake-parts module. This harmonizes the behavior of `devshell.mkShell` and the flake module.
1 parent f7795ed commit 8c3fe9c

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

flake-module.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ in
2121
'';
2222

2323
type = types.lazyAttrsOf (
24-
types.submoduleWith { modules = import ./modules/modules.nix { inherit pkgs lib; }; }
24+
types.submoduleWith (import ./modules/eval-args.nix { inherit pkgs lib; })
2525
);
2626
default = { };
2727
};

modules/default.nix

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,13 @@ nixpkgs:
66
extraSpecialArgs ? { },
77
}:
88
let
9-
devenvModules = import ./modules.nix {
10-
pkgs = nixpkgs;
11-
inherit lib;
12-
};
13-
14-
module = lib.evalModules {
15-
modules = [ configuration ] ++ devenvModules;
16-
specialArgs = {
17-
modulesPath = builtins.toString ./.;
18-
extraModulesPath = builtins.toString ../extra;
19-
} // extraSpecialArgs;
20-
};
9+
module = lib.evalModules (
10+
import ./eval-args.nix {
11+
inherit lib extraSpecialArgs;
12+
pkgs = nixpkgs;
13+
modules = [ configuration ];
14+
}
15+
);
2116
in
2217
{
2318
inherit (module) config options;

modules/eval-args.nix

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Arguments for `lib.evalModules` or `types.submoduleWith`.
2+
{
3+
pkgs,
4+
lib,
5+
modules ? [ ],
6+
extraSpecialArgs ? { },
7+
}:
8+
let
9+
devenvModules = import ./modules.nix { inherit lib pkgs; };
10+
in
11+
{
12+
modules = (lib.toList modules) ++ devenvModules;
13+
specialArgs = {
14+
modulesPath = builtins.toString ./.;
15+
extraModulesPath = builtins.toString ../extra;
16+
} // extraSpecialArgs;
17+
}

0 commit comments

Comments
 (0)