summaryrefslogtreecommitdiffstats
path: root/modules/by-name/us/users/module.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/by-name/us/users/module.nix')
-rw-r--r--modules/by-name/us/users/module.nix132
1 files changed, 71 insertions, 61 deletions
diff --git a/modules/by-name/us/users/module.nix b/modules/by-name/us/users/module.nix
index d9097fe1..0f84b58b 100644
--- a/modules/by-name/us/users/module.nix
+++ b/modules/by-name/us/users/module.nix
@@ -1,80 +1,90 @@
-# nixos-config - My current NixOS configuration
-#
-# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
-# SPDX-License-Identifier: GPL-3.0-or-later
-#
-# This file is part of my nixos-config.
-#
-# You should have received a copy of the License along with this program.
-# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
{
config,
- pkgs,
lib,
+ pkgs,
...
}: let
- cfg = config.soispha.users;
-in {
- options.soispha.users = {
- enable = lib.mkEnableOption "user set-up for soispha";
+ cfg = config.vhack.users;
- hashedPassword = lib.mkOption {
- type = lib.types.str;
- example = lib.literalExpression "$y$jFT$ONrCqZIJKB7engmfA4orD/$0GO58/wV5wrYWj0cyONhyujZPjFmbT0XKtx2AvXLG0B";
- description = "The hashed password of the user";
- };
- groups = lib.mkOption {
- type = lib.types.listOf lib.types.str;
- default = ["wheel" "audio"];
- description = "The groups the soispha user should be part of";
+ mkUser = {
+ name,
+ hashedPassword,
+ uid,
+ sshKey,
+ }: {
+ inherit name;
+ value = {
+ inherit name uid hashedPassword;
+ isNormalUser = true;
+ createHome = true;
+ home = "/home/${name}";
+ extraGroups = cfg.groups ++ lib.optional cfg.enableDeprecatedPlugdev "plugdev";
+ openssh.authorizedKeys.keys = [
+ sshKey
+ ];
};
-
- # Although deprecated, this helps with old udev rules, that still use this group.
- # TODO: Try to find a way to remove this option (i.e. set it always to false).
- enableDeprecatedPlugdev = lib.mkEnableOption "the deprecated plugdev group for the user";
};
- config = lib.mkIf cfg.enable {
- users = {
- mutableUsers = false;
+ extraUsers = lib.listToAttrs (
+ builtins.map mkUser cfg.users
+ );
+in {
+ options.vhack.users = {
+ enable = lib.mkEnableOption "user setup";
+ users = lib.mkOption {
+ type = lib.types.listOf (lib.types.submodule {
+ options = {
+ name = lib.mkOption {
+ type = lib.types.str;
+ description = "User name";
+ };
- users = {
- soispha = {
- isNormalUser = true;
- home = "/home/soispha";
- createHome = true;
- shell = config.home-manager.users.soispha.programs.fish.package;
- initialHashedPassword = cfg.hashedPassword;
- extraGroups = cfg.groups ++ lib.optional cfg.enableDeprecatedPlugdev "plugdev";
+ groups = lib.mkOption {
+ type = lib.types.listOf lib.types.str;
+ default = ["wheel"];
+ description = "The groups the user should be part of";
+ };
- uid = 1000;
- openssh.authorizedKeys.keys = [
- # TODO: This should be parameterized. <2024-05-16>
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIME4ZVa+IoZf6T3U08JG93i6QIAJ4amm7mkBzO14JSkz"
- ];
- };
+ # Although deprecated, this helps with old udev rules, that still use this group.
+ # TODO: Try to find a way to remove this option (i.e. set it always to false).
+ enableDeprecatedPlugdev = lib.mkEnableOption "the deprecated plugdev group for the user";
- root = {
- hashedPassword = lib.mkForce null; # to lock root
- openssh.authorizedKeys.keys = lib.mkForce [];
+ hashedPassword = lib.mkOption {
+ type = lib.types.str;
+ description = "Hashed user password.";
+ };
+ sshKey = lib.mkOption {
+ type = lib.types.str;
+ description = "public ssh key, for ssh access.";
+ };
+ uid = lib.mkOption {
+ type = lib.types.int;
+ description = "UNIQUE user id, ideally greater than 1000.";
+ };
};
- };
+ });
+ description = "Users";
+ };
+ };
+
+ config = lib.mkIf cfg.enable {
+ programs.fish = {
+ enable = true;
+ useBabelfish = true;
};
- home-manager.users = {
- soispha.home = {
- username = "soispha";
- homeDirectory = config.users.users.soispha.home;
- stateVersion = "23.05";
- enableNixpkgsReleaseCheck = true;
- };
+ users = {
+ mutableUsers = false;
+ defaultUserShell = config.programs.fish.package;
- root.home = {
- username = "root";
- homeDirectory = config.users.users.root.home;
- stateVersion = "23.05";
- enableNixpkgsReleaseCheck = true;
- };
+ users =
+ {
+ root = {
+ hashedPassword = lib.mkForce null; # to lock root
+ openssh.authorizedKeys.keys = lib.mkForce [];
+ };
+ }
+ // extraUsers;
};
};
}