1
0
Fork 0
shelter/home/flake-module-options.nix

48 lines
1.2 KiB
Nix

# SPDX-FileCopyrightText: 2024 yushyin <https://forge.nihilum.space/~yushyin/>
#
# SPDX-License-Identifier: MIT
{ self, config, lib, inputs, withSystem, ... }:
let
inherit (lib)
types
mkOption
;
homeConfigsOptions =
{ name, ... }:
{
options = {
system = mkOption {
type = types.nonEmptyStr;
default = lib.throwIf lib.inPureEvalMode "needs --impure" builtins.currentSystem;
};
modules = mkOption {
type = with types; listOf deferredModule;
default = [
self.homeModules.home
(lib.dotfiles.fs.toTreeModule ./configs/${name})
];
};
};
};
in
{
options.shelter.homeConfigs = mkOption {
type = types.attrsOf (types.submodule homeConfigsOptions);
};
config.flake.homeConfigurations = lib.mapAttrs
(
_: cfg: withSystem cfg.system
({ pkgs, ... }:
inputs.home-manager.lib.homeManagerConfiguration {
inherit pkgs lib;
extraSpecialArgs = {
inherit inputs;
flake = self;
};
modules = cfg.modules;
})
)
config.shelter.homeConfigs;
}