1
0
mirror of https://git.oat.zone/dark-firepit/dotfiles synced 2024-11-26 06:08:48 +01:00
git.oat.zone--dark-firepit-.../modules/users.nix

83 lines
2.0 KiB
Nix
Raw Normal View History

2022-01-11 18:44:40 +01:00
{ options, config, lib, pkgs, ... }:
with lib;
let
in {
2022-01-11 18:44:40 +01:00
options = {
user = mkOption {
2022-01-11 18:44:40 +01:00
type = types.attrs;
default = {};
description = "Defaults to apply to all normal users in the system.";
};
normalUsers = mkOption {
type = types.attrsOf (types.submodule { options = {
conf = mkOption {
type = types.attrs;
default = {};
};
homeConf = mkOption {
type = types.attrs;
default = {};
};
};});
default = {};
2022-01-11 18:44:40 +01:00
};
home = {
_ = mkOption {
type = types.attrs;
default = {};
description = "Universal home-level user configuration";
};
configFile = mkOption {
type = types.attrs;
default = {};
description = "(XDG) Configuration files managed by home-manager";
2022-01-11 18:44:40 +01:00
};
};
configDir = mkOption {
type = types.path;
default = ../config;
};
};
config = {
home-manager.useUserPackages = true;
user = {
packages = with pkgs; [ wget ];
extraGroups = [ ];
};
2022-01-11 18:44:40 +01:00
home._ = {
home.stateVersion = config.system.stateVersion;
2022-04-20 10:53:28 +02:00
home.file = mkAliasDefinitions options.home.configFile;
2022-01-11 18:44:40 +01:00
xdg.enable = true;
xdg.configFile = mkAliasDefinitions options.home.configFile;
};
environment = {
sessionVariables = {
XDG_CACHE_HOME = "$HOME/.cache";
XDG_CONFIG_HOME = "$HOME/.config";
XDG_DATA_HOME = "$HOME/.local/share";
XDG_BIN_HOME = "$HOME/.local/bin";
XDG_DESKTOP_DIR = "$HOME";
};
};
users.groups = mapAttrs (_: _: {}) config.normalUsers;
users.users = mapAttrs (username: user: (mkMerge [
(mkAliasDefinitions options.user)
user.conf
{
isNormalUser = true;
group = username;
}
])) config.normalUsers;
2022-01-11 18:44:40 +01:00
home-manager.users = mapAttrs (username: user: (mkMerge [(mkAliasDefinitions options.home._) user.homeConf])) config.normalUsers;
2022-01-11 18:44:40 +01:00
};
}