refactor(modules): make username not hardcoded

This commit is contained in:
Mohammad Rafiq 2025-05-03 12:40:20 +08:00
parent 9e17187b02
commit fc7d95acfd
No known key found for this signature in database
4 changed files with 15 additions and 4 deletions

View file

@ -17,6 +17,7 @@
];
nixosModules.enable = true;
nixosModules.hostname = hostname;
nixosModules.mainUser = "rafiq";
hmModules.enable = true;
nix-config.enable = true;
boot-config.enable = true;

View file

@ -8,6 +8,7 @@
let
moduleName = "hmModules";
cfg = config."${moduleName}";
username = config.nixosModules.mainUser;
in
{
imports = [
@ -26,9 +27,9 @@ in
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = specialArgs;
users.rafiq.home = {
username = "rafiq";
homeDirectory = "/home/rafiq";
users."${username}".home = {
username = username;
homeDirectory = "/home/${username}";
stateVersion = "25.05";
};
};

View file

@ -3,10 +3,13 @@
lib,
...
}:
let
username = config.nixosModules.mainUser;
in
{
config = lib.mkMerge [
(lib.mkIf config."hardware-config".usbAutoMount {
home-manager.users.rafiq.services.udiskie = {
home-manager.users.${username}.services.udiskie = {
enable = true;
settings = {
# workaround for

View file

@ -27,6 +27,12 @@ in
example = "goron";
description = "The name this machine will be known by.";
};
mainUser = lib.mkOption {
type = lib.types.str;
default = "";
example = "link";
description = "The main user of pantheon.";
};
};
};