feat: Make username customizable

Now it's possible to use whatever username you want for your system. The
default value of "user" is good if you're concerned about information
disclosure attacks through things like the username being visible in
logs or other output.
This commit is contained in:
Donovan Glover 2024-04-04 16:36:08 -04:00
parent 558e0b1623
commit 7f05a66fa5
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65
5 changed files with 34 additions and 23 deletions

View File

@ -1,5 +1,8 @@
{ pkgs, ... }:
{ pkgs, lib, config, ... }:
let
inherit (config.modules.system) username;
in
{
imports = [
../modules/fish.nix
@ -52,11 +55,9 @@
users = {
allowNoPasswordLogin = true;
users = {
user = {
password = lib.mkForce null;
extraGroups = lib.mkForce [ ];
};
users.${username} = {
password = lib.mkForce null;
extraGroups = lib.mkForce [ ];
};
};

View File

@ -4,6 +4,7 @@ let
inherit (lib) mkEnableOption mkIf;
inherit (pkgs.xfce) thunar-volman exo;
inherit (pkgs) glib;
inherit (config.modules.system) username;
theme = "monokai";
opacity = 0.95;
@ -100,7 +101,7 @@ in
initial_session = {
command = "${pkgs.hyprland}/bin/Hyprland";
user = "user";
user = username;
};
};
};

View File

@ -4,11 +4,17 @@ let
inherit (lib) mkOption;
inherit (lib.types) str listOf;
inherit (pkgs.nixVersions) nix_2_19;
inherit (cfg) username;
cfg = config.modules.system;
in
{
options.modules.system = {
username = mkOption {
type = str;
default = "user";
};
timeZone = mkOption {
type = str;
default = "America/New_York";
@ -81,13 +87,11 @@ in
users = {
mutableUsers = false;
users = {
user = {
isNormalUser = true;
uid = 1000;
password = "user";
extraGroups = [ "wheel" "networkmanager" ];
};
users.${username} = {
isNormalUser = true;
uid = 1000;
password = "user";
extraGroups = [ "wheel" "networkmanager" ];
};
};
@ -100,11 +104,10 @@ in
programs.man.generateCaches = true;
}];
users = {
user = {
home.username = "user";
home.homeDirectory = "/home/user";
};
users.${username}.home = {
inherit username;
homeDirectory = "/home/${username}";
};
};
};

View File

@ -1,5 +1,8 @@
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:
let
inherit (config.modules.system) username;
in
{
services.xserver = {
enable = true;
@ -13,7 +16,7 @@
autoLogin = {
enable = true;
user = "user";
user = username;
};
};

View File

@ -1,5 +1,8 @@
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:
let
inherit (config.modules.system) username;
in
{
services.xserver = {
enable = true;
@ -9,7 +12,7 @@
autoLogin = {
enable = true;
user = "user";
user = username;
};
};