refactor: rename snowfallorg.user to snowfallorg.users in system configs
This commit is contained in:
parent
1fd6a70a82
commit
8d6612527a
3 changed files with 38 additions and 13 deletions
|
|
@ -6,14 +6,22 @@
|
||||||
inputs,
|
inputs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib) types mkOption mkDefault foldl optionalAttrs;
|
inherit
|
||||||
|
(lib)
|
||||||
|
types
|
||||||
|
mkOption
|
||||||
|
mkDefault
|
||||||
|
mkRenamedOptionModule
|
||||||
|
foldl
|
||||||
|
optionalAttrs
|
||||||
|
;
|
||||||
|
|
||||||
cfg = config.snowfallorg;
|
cfg = config.snowfallorg;
|
||||||
|
|
||||||
user-names = builtins.attrNames cfg.user;
|
user-names = builtins.attrNames cfg.users;
|
||||||
|
|
||||||
create-system-users = system-users: name: let
|
create-system-users = system-users: name: let
|
||||||
user = cfg.user.${name};
|
user = cfg.users.${name};
|
||||||
in
|
in
|
||||||
system-users
|
system-users
|
||||||
// (optionalAttrs user.create {
|
// (optionalAttrs user.create {
|
||||||
|
|
@ -23,8 +31,12 @@
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
in {
|
in {
|
||||||
|
imports = [
|
||||||
|
(mkRenamedOptionModule ["snowfallorg" "user"] ["snowfallorg" "users"])
|
||||||
|
];
|
||||||
|
|
||||||
options.snowfallorg = {
|
options.snowfallorg = {
|
||||||
user = mkOption {
|
users = mkOption {
|
||||||
description = "User configuration.";
|
description = "User configuration.";
|
||||||
default = {};
|
default = {};
|
||||||
type = types.attrsOf (types.submodule ({name, ...}: {
|
type = types.attrsOf (types.submodule ({name, ...}: {
|
||||||
|
|
|
||||||
|
|
@ -5,16 +5,25 @@ args @ {
|
||||||
config,
|
config,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib) types mkOption mkDefault foldl optionalAttrs optional;
|
inherit
|
||||||
|
(lib)
|
||||||
|
types
|
||||||
|
mkOption
|
||||||
|
mkDefault
|
||||||
|
mkRenamedOptionModule
|
||||||
|
foldl
|
||||||
|
optionalAttrs
|
||||||
|
optional
|
||||||
|
;
|
||||||
|
|
||||||
cfg = config.snowfallorg;
|
cfg = config.snowfallorg;
|
||||||
|
|
||||||
inputs = args.inputs or {};
|
inputs = args.inputs or {};
|
||||||
|
|
||||||
user-names = builtins.attrNames cfg.user;
|
user-names = builtins.attrNames cfg.users;
|
||||||
|
|
||||||
create-system-users = system-users: name: let
|
create-system-users = system-users: name: let
|
||||||
user = cfg.user.${name};
|
user = cfg.users.${name};
|
||||||
in
|
in
|
||||||
system-users
|
system-users
|
||||||
// (optionalAttrs user.create {
|
// (optionalAttrs user.create {
|
||||||
|
|
@ -30,8 +39,12 @@ args @ {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
in {
|
in {
|
||||||
|
imports = [
|
||||||
|
(mkRenamedOptionModule ["snowfallorg" "user"] ["snowfallorg" "users"])
|
||||||
|
];
|
||||||
|
|
||||||
options.snowfallorg = {
|
options.snowfallorg = {
|
||||||
user = mkOption {
|
users = mkOption {
|
||||||
description = "User configuration.";
|
description = "User configuration.";
|
||||||
default = {};
|
default = {};
|
||||||
type = types.attrsOf (types.submodule ({name, ...}: {
|
type = types.attrsOf (types.submodule ({name, ...}: {
|
||||||
|
|
|
||||||
|
|
@ -318,7 +318,7 @@ in {
|
||||||
(builtins.trace ''
|
(builtins.trace ''
|
||||||
=============
|
=============
|
||||||
Snowfall Lib:
|
Snowfall Lib:
|
||||||
Option value for `snowfallorg.user.${user-name}` was not detected to be merged.
|
Option value for `snowfallorg.users.${user-name}` was not detected to be merged.
|
||||||
|
|
||||||
Please report the issue on GitHub with a link to your configuration so we can debug the problem:
|
Please report the issue on GitHub with a link to your configuration so we can debug the problem:
|
||||||
https://github.com/snowfallorg/lib/issues/new
|
https://github.com/snowfallorg/lib/issues/new
|
||||||
|
|
@ -326,13 +326,13 @@ in {
|
||||||
'')
|
'')
|
||||||
user-option;
|
user-option;
|
||||||
|
|
||||||
home-config = mkAliasAndWrapDefinitions wrap-user-options options.snowfallorg.user;
|
home-config = mkAliasAndWrapDefinitions wrap-user-options options.snowfallorg.users;
|
||||||
in {
|
in {
|
||||||
_file = "virtual:snowfallorg/home/user/${name}";
|
_file = "virtual:snowfallorg/home/user/${name}";
|
||||||
|
|
||||||
config = mkIf host-matches {
|
config = mkIf host-matches {
|
||||||
# Initialize user information.
|
# Initialize user information.
|
||||||
snowfallorg.user.${user-name}.home.config = {
|
snowfallorg.users.${user-name}.home.config = {
|
||||||
snowfallorg.user = {
|
snowfallorg.user = {
|
||||||
enable = mkDefault true;
|
enable = mkDefault true;
|
||||||
name = mkDefault user-name;
|
name = mkDefault user-name;
|
||||||
|
|
@ -346,9 +346,9 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
home-manager = {
|
home-manager = {
|
||||||
users.${user-name} = mkIf config.snowfallorg.user.${user-name}.home.enable ({pkgs, ...}: {
|
users.${user-name} = mkIf config.snowfallorg.users.${user-name}.home.enable ({pkgs, ...}: {
|
||||||
imports = (home-config.imports or []) ++ other-modules ++ [user-module];
|
imports = (home-config.imports or []) ++ other-modules ++ [user-module];
|
||||||
config = home-config;
|
config = builtins.removeAttrs home-config ["imports"];
|
||||||
});
|
});
|
||||||
|
|
||||||
# NOTE: Without this home-manager will instead create its own package set which won't contain the same config and
|
# NOTE: Without this home-manager will instead create its own package set which won't contain the same config and
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue