refactor: rename snowfallorg.user to snowfallorg.users in system configs

This commit is contained in:
Jake Hamilton 2024-03-04 09:42:48 -08:00
parent 1fd6a70a82
commit 8d6612527a
No known key found for this signature in database
GPG key ID: 9762169A1B35EA68
3 changed files with 38 additions and 13 deletions

View file

@ -6,14 +6,22 @@
inputs,
...
}: let
inherit (lib) types mkOption mkDefault foldl optionalAttrs;
inherit
(lib)
types
mkOption
mkDefault
mkRenamedOptionModule
foldl
optionalAttrs
;
cfg = config.snowfallorg;
user-names = builtins.attrNames cfg.user;
user-names = builtins.attrNames cfg.users;
create-system-users = system-users: name: let
user = cfg.user.${name};
user = cfg.users.${name};
in
system-users
// (optionalAttrs user.create {
@ -23,8 +31,12 @@
};
});
in {
imports = [
(mkRenamedOptionModule ["snowfallorg" "user"] ["snowfallorg" "users"])
];
options.snowfallorg = {
user = mkOption {
users = mkOption {
description = "User configuration.";
default = {};
type = types.attrsOf (types.submodule ({name, ...}: {

View file

@ -5,16 +5,25 @@ args @ {
config,
...
}: let
inherit (lib) types mkOption mkDefault foldl optionalAttrs optional;
inherit
(lib)
types
mkOption
mkDefault
mkRenamedOptionModule
foldl
optionalAttrs
optional
;
cfg = config.snowfallorg;
inputs = args.inputs or {};
user-names = builtins.attrNames cfg.user;
user-names = builtins.attrNames cfg.users;
create-system-users = system-users: name: let
user = cfg.user.${name};
user = cfg.users.${name};
in
system-users
// (optionalAttrs user.create {
@ -30,8 +39,12 @@ args @ {
};
});
in {
imports = [
(mkRenamedOptionModule ["snowfallorg" "user"] ["snowfallorg" "users"])
];
options.snowfallorg = {
user = mkOption {
users = mkOption {
description = "User configuration.";
default = {};
type = types.attrsOf (types.submodule ({name, ...}: {

View file

@ -318,7 +318,7 @@ in {
(builtins.trace ''
=============
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:
https://github.com/snowfallorg/lib/issues/new
@ -326,13 +326,13 @@ in {
'')
user-option;
home-config = mkAliasAndWrapDefinitions wrap-user-options options.snowfallorg.user;
home-config = mkAliasAndWrapDefinitions wrap-user-options options.snowfallorg.users;
in {
_file = "virtual:snowfallorg/home/user/${name}";
config = mkIf host-matches {
# Initialize user information.
snowfallorg.user.${user-name}.home.config = {
snowfallorg.users.${user-name}.home.config = {
snowfallorg.user = {
enable = mkDefault true;
name = mkDefault user-name;
@ -346,9 +346,9 @@ in {
};
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];
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