Clean up support code for Home Manager as a submodule
This removes the `nixosSubmodule` option in favor of a new option `submoduleSupport.enable`. This name better indicates that the submodule mode applies to both NixOS and nix-darwin.
This commit is contained in:
parent
524ce43e23
commit
2f372ab4d6
19
modules/misc/submodule-support.nix
Normal file
19
modules/misc/submodule-support.nix
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
{
|
||||||
|
meta.maintainers = [ maintainers.rycee ];
|
||||||
|
|
||||||
|
options.submoduleSupport = {
|
||||||
|
enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
internal = true;
|
||||||
|
description = ''
|
||||||
|
Whether the Home Manager module system is used as a submodule
|
||||||
|
in, for example, NixOS or nix-darwin.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -3,9 +3,6 @@
|
||||||
|
|
||||||
# Whether to enable module type checking.
|
# Whether to enable module type checking.
|
||||||
, check ? true
|
, check ? true
|
||||||
|
|
||||||
# Whether these modules are inside a NixOS submodule.
|
|
||||||
, nixosSubmodule ? false
|
|
||||||
}:
|
}:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
@ -33,6 +30,7 @@ let
|
||||||
(loadModule ./misc/nixpkgs.nix { })
|
(loadModule ./misc/nixpkgs.nix { })
|
||||||
(loadModule ./misc/pam.nix { })
|
(loadModule ./misc/pam.nix { })
|
||||||
(loadModule ./misc/qt.nix { })
|
(loadModule ./misc/qt.nix { })
|
||||||
|
(loadModule ./misc/submodule-support.nix { })
|
||||||
(loadModule ./misc/version.nix { })
|
(loadModule ./misc/version.nix { })
|
||||||
(loadModule ./misc/xdg.nix { })
|
(loadModule ./misc/xdg.nix { })
|
||||||
(loadModule ./programs/afew.nix { })
|
(loadModule ./programs/afew.nix { })
|
||||||
|
@ -129,17 +127,10 @@ let
|
||||||
modules = map (getAttr "file") (filter (getAttr "condition") allModules);
|
modules = map (getAttr "file") (filter (getAttr "condition") allModules);
|
||||||
|
|
||||||
pkgsModule = {
|
pkgsModule = {
|
||||||
options.nixosSubmodule = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
internal = true;
|
|
||||||
readOnly = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
config._module.args.baseModules = modules;
|
config._module.args.baseModules = modules;
|
||||||
config._module.args.pkgs = lib.mkDefault pkgs;
|
config._module.args.pkgs = lib.mkDefault pkgs;
|
||||||
config._module.check = check;
|
config._module.check = check;
|
||||||
config.lib = import ./lib { inherit lib; };
|
config.lib = import ./lib { inherit lib; };
|
||||||
config.nixosSubmodule = nixosSubmodule;
|
|
||||||
config.nixpkgs.system = mkDefault pkgs.system;
|
config.nixpkgs.system = mkDefault pkgs.system;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf (cfg.enable && !config.nixosSubmodule) {
|
config = mkIf (cfg.enable && !config.submoduleSupport.enable) {
|
||||||
home.packages = [
|
home.packages = [
|
||||||
(import ../../home-manager {
|
(import ../../home-manager {
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
|
|
|
@ -7,12 +7,10 @@ let
|
||||||
cfg = config.home-manager;
|
cfg = config.home-manager;
|
||||||
|
|
||||||
hmModule = types.submodule ({name, ...}: {
|
hmModule = types.submodule ({name, ...}: {
|
||||||
imports = import ../modules/modules.nix {
|
imports = import ../modules/modules.nix { inherit lib pkgs; };
|
||||||
inherit lib pkgs;
|
|
||||||
nixosSubmodule = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
submoduleSupport.enable = true;
|
||||||
home.username = config.users.users.${name}.name;
|
home.username = config.users.users.${name}.name;
|
||||||
home.homeDirectory = config.users.users.${name}.home;
|
home.homeDirectory = config.users.users.${name}.home;
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,12 +7,10 @@ let
|
||||||
cfg = config.home-manager;
|
cfg = config.home-manager;
|
||||||
|
|
||||||
hmModule = types.submodule ({name, ...}: {
|
hmModule = types.submodule ({name, ...}: {
|
||||||
imports = import ../modules/modules.nix {
|
imports = import ../modules/modules.nix { inherit lib pkgs; };
|
||||||
inherit lib pkgs;
|
|
||||||
nixosSubmodule = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
submoduleSupport.enable = true;
|
||||||
home.username = config.users.users.${name}.name;
|
home.username = config.users.users.${name}.name;
|
||||||
home.homeDirectory = config.users.users.${name}.home;
|
home.homeDirectory = config.users.users.${name}.home;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue