From 3d22c316793a4e0c5c42de0fb339f87557c4aa98 Mon Sep 17 00:00:00 2001 From: Peter Rice Date: Sun, 5 Jul 2026 03:34:54 -0400 Subject: [PATCH] add local user alias --- modules/hosts/macbook.nix | 2 +- modules/nixos/persistence.nix | 2 +- modules/nixos/vm.nix | 2 +- modules/services/podcasts.nix | 2 +- modules/user/hjem.nix | 2 +- modules/user/peter.nix | 56 ++++++++++++++++++++--------------- 6 files changed, 37 insertions(+), 29 deletions(-) diff --git a/modules/hosts/macbook.nix b/modules/hosts/macbook.nix index dc6f397..b227b8b 100644 --- a/modules/hosts/macbook.nix +++ b/modules/hosts/macbook.nix @@ -7,7 +7,7 @@ flake.modules.darwin.default = { pkgs, ... }: { - local.user.name = "price"; + local.username = "price"; nix.enable = false; security.pki.installCACerts = false; system.keyboard.enableKeyMapping = true; diff --git a/modules/nixos/persistence.nix b/modules/nixos/persistence.nix index 280e431..c09f8b4 100644 --- a/modules/nixos/persistence.nix +++ b/modules/nixos/persistence.nix @@ -4,7 +4,7 @@ { config, lib, ... }: let cfg = config.local.persistence; - username = config.local.user.name; + username = config.local.username; persistCfg = config.environment.persistence; persistDir = persistCfg.nixos.persistentStoragePath; sshPath = config.environment.persistence.nixos.persistentStoragePath + "/etc/ssh"; diff --git a/modules/nixos/vm.nix b/modules/nixos/vm.nix index 5bb1ef9..9e2c560 100644 --- a/modules/nixos/vm.nix +++ b/modules/nixos/vm.nix @@ -2,7 +2,7 @@ flake.modules.nixos.core = { config, lib, ... }: let - username = config.local.user.name; + username = config.local.username; userCfg = config.users.users.${username}; vmVariant = { nixpkgs.hostPlatform = "x86_64-linux"; diff --git a/modules/services/podcasts.nix b/modules/services/podcasts.nix index def5a8d..292c27a 100644 --- a/modules/services/podcasts.nix +++ b/modules/services/podcasts.nix @@ -12,7 +12,7 @@ podcastSubdir = "hosted-podcasts"; fetch = { enable = true; - user = config.local.user.name; + user = config.local.username; group = "users"; startAt = "0,8,16:0"; }; diff --git a/modules/user/hjem.nix b/modules/user/hjem.nix index 54633e4..123a0eb 100644 --- a/modules/user/hjem.nix +++ b/modules/user/hjem.nix @@ -3,7 +3,7 @@ let hjemModule = { config, ... }: { - hjem.users.${config.local.user.name}.enable = true; + hjem.users.${config.local.username}.enable = true; hjem.extraModules = [ inputs.self.modules.hjem.core ]; }; in diff --git a/modules/user/peter.nix b/modules/user/peter.nix index 8410381..97be298 100644 --- a/modules/user/peter.nix +++ b/modules/user/peter.nix @@ -1,6 +1,6 @@ { lib, ... }: let - options.name = lib.mkOption { + options.local.username = lib.mkOption { type = lib.types.str; default = "peter"; }; @@ -11,37 +11,45 @@ let "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIObxXM22QQwNosuoH9UXhJWAm5PQOMtxEHGI3ElhsdCn peter@arseille" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJojCQs1VjUFaO/2dOq2N/zQgfRtBtFE7nLu3VpJZkwt price@jurai" ]; + aliasModule = + { config, ... }: + { + imports = [ + (lib.mkAliasOptionModule + [ + "local" + "user" + ] + [ + "users" + "users" + config.local.username + ] + ) + ]; + }; + in { config.flake.modules.nixos.user = { config, ... }: - let - cfg = config.local.user; - in { - options.local.user = { - inherit (options) name; - extraGroups = lib.mkOption { - type = with lib.types; listOf str; - default = [ ]; - apply = groups: [ "wheel" ] ++ groups; - }; - }; - - config.users.users.${cfg.name} = { + imports = [ + { inherit options; } + aliasModule + ]; + local.user = { isNormalUser = true; - inherit (cfg) extraGroups; + extraGroups = [ "wheel" ]; inherit openssh; }; }; - config.flake.modules.darwin.default = - { config, ... }: - let - cfg = config.local.user; - in - { - options.local.user = { inherit (options) name; }; - config.users.users.${cfg.name} = { inherit openssh; }; - }; + config.flake.modules.darwin.default = { + imports = [ + { inherit options; } + aliasModule + ]; + local.user = { inherit openssh; }; + }; } -- 2.51.2