]> Git — Sourcephile - sourcephile-nix.git/blob - shell/modules.nix
sanoid: syncoid: backup my work on losurdo to mermet
[sourcephile-nix.git] / shell / modules.nix
1 { pkgs
2 , lib ? pkgs.lib
3 , modules ? []
4 , extraArgs ? {}
5 , specialArgs ? {}
6 , check ? true
7 , prefix ? []
8 }:
9 let extraArgs_ = extraArgs;
10 pkgs_ = pkgs;
11 baseModules = map import (lib.findFiles ".*\\.nix" ./modules );
12 pkgsModule = rec {
13 _file = ./modules.nix;
14 key = _file;
15 config = {
16 _module.args.pkgs = lib.mkIf (pkgs_ != null) (lib.mkForce pkgs_);
17 };
18 };
19 in
20 rec {
21 # Merge the option definitions in all modules,
22 # forming the full system configuration.
23 inherit (lib.evalModules {
24 inherit prefix;
25 inherit check;
26 modules = modules ++ baseModules ++ [ pkgsModule ];
27 args = extraArgs;
28 inherit specialArgs;
29 #specialArgs = { modulesPath = config/modules.nix; } // specialArgs;
30 }) config options;
31
32 # These are the extra arguments passed to every module.
33 # In particular, Nixpkgs is passed through the "pkgs" argument.
34 extraArgs = extraArgs_ // {
35 inherit modules;
36 inherit baseModules;
37 };
38
39 inherit (config._module.args) pkgs;
40 }