A new start
This commit is contained in:
commit
f4e2368893
93 changed files with 7621 additions and 0 deletions
50
modules/home/user/default.nix
Normal file
50
modules/home/user/default.nix
Normal file
|
@ -0,0 +1,50 @@
|
|||
{ lib, config, pkgs, osConfig ? { }, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) types mkIf mkDefault mkMerge;
|
||||
inherit (lib.metacfg) mkOpt;
|
||||
|
||||
cfg = config.metacfg.user;
|
||||
|
||||
is-linux = pkgs.stdenv.isLinux;
|
||||
is-darwin = pkgs.stdenv.isDarwin;
|
||||
|
||||
home-directory =
|
||||
if cfg.name == null then
|
||||
null
|
||||
else if is-darwin then
|
||||
"/Users/${cfg.name}"
|
||||
else
|
||||
"/home/${cfg.name}";
|
||||
in
|
||||
{
|
||||
options.metacfg.user = {
|
||||
enable = mkOpt types.bool false "Whether to configure the user account.";
|
||||
name = mkOpt (types.nullOr types.str) config.snowfallorg.user.name "The user account.";
|
||||
|
||||
fullName = mkOpt types.str "Harald Hoyer" "The full name of the user.";
|
||||
email = mkOpt types.str "harald@hoyer.xyz" "The email of the user.";
|
||||
|
||||
home = mkOpt (types.nullOr types.str) home-directory "The user's home directory.";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
{
|
||||
assertions = [
|
||||
{
|
||||
assertion = cfg.name != null;
|
||||
message = "metacfg.user.name must be set";
|
||||
}
|
||||
{
|
||||
assertion = cfg.home != null;
|
||||
message = "metacfg.user.home must be set";
|
||||
}
|
||||
];
|
||||
|
||||
home = {
|
||||
username = mkDefault cfg.name;
|
||||
homeDirectory = mkDefault cfg.home;
|
||||
};
|
||||
}
|
||||
]);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue