rewrite user profile to user module

This commit is contained in:
Hendrik Sokolowski 2023-11-10 16:07:54 +01:00
parent a3f04973fd
commit a3ea8e873a
27 changed files with 41 additions and 44 deletions

View file

Before

Width:  |  Height:  |  Size: 513 KiB

After

Width:  |  Height:  |  Size: 513 KiB

View file

@ -1,12 +1,16 @@
{ {
lib,
config, config,
pkgs, pkgs,
lib,
... ...
}: }:
with lib; let with lib; let
cfg = config.pub-solar; psCfg = config.pub-solar;
in { in
with lib; {
imports = [
./home.nix
];
options.pub-solar = { options.pub-solar = {
user = { user = {
name = mkOption { name = mkOption {
@ -56,4 +60,37 @@ in {
}; };
}; };
}; };
config = {
users = {
mutableUsers = false;
users = with pkgs;
pkgs.lib.setAttrByPath [psCfg.user.name] {
# Indicates whether this is an account for a “real” user.
# This automatically sets group to users, createHome to true,
# home to /home/username, useDefaultShell to true, and isSystemUser to false.
isNormalUser = true;
description = psCfg.user.description;
extraGroups = [
"input"
"lp"
"networkmanager"
"scanner"
"video"
"dialout"
"wheel"
];
shell = pkgs.bash;
initialHashedPassword =
if psCfg.user.password != null
then psCfg.user.password
else "";
openssh.authorizedKeys.keys =
if psCfg.user.publicKeys != null
then psCfg.user.publicKeys
else [];
};
};
};
} }

View file

@ -20,6 +20,7 @@ in {
# paths it should manage. # paths it should manage.
home.username = psCfg.user.name; home.username = psCfg.user.name;
home.homeDirectory = "/home/${psCfg.user.name}"; home.homeDirectory = "/home/${psCfg.user.name}";
home.stateVersion = "22.11";
home.packages = with pkgs; []; home.packages = with pkgs; [];

View file

@ -1,41 +0,0 @@
{
config,
pkgs,
lib,
...
}: let
psCfg = config.pub-solar;
in {
imports = [
./home.nix
];
users = {
mutableUsers = false;
users = with pkgs;
pkgs.lib.setAttrByPath [psCfg.user.name] {
# Indicates whether this is an account for a “real” user.
# This automatically sets group to users, createHome to true,
# home to /home/username, useDefaultShell to true, and isSystemUser to false.
isNormalUser = true;
description = psCfg.user.description;
extraGroups = [
"input"
"lp"
"networkmanager"
"scanner"
"video"
"wheel"
];
initialHashedPassword =
if psCfg.user.password != null
then psCfg.user.password
else "";
openssh.authorizedKeys.keys =
if psCfg.user.publicKeys != null
then psCfg.user.publicKeys
else [];
};
};
}