refactor: revert username global var

This commit is contained in:
Mohammad Rafiq 2025-03-27 02:49:54 +08:00
parent d5b4b54403
commit 16f28bf227
No known key found for this signature in database
11 changed files with 66 additions and 35 deletions

View file

@ -5,7 +5,6 @@
... ...
}@inputs: }@inputs:
let let
username = "rafiq";
mkSystem = type: hostname: { mkSystem = type: hostname: {
name = "${hostname}"; name = "${hostname}";
value = value =
@ -16,13 +15,16 @@
inputs inputs
type type
hostname hostname
username
; ;
}; };
in in
inputs.nixpkgs.lib.nixosSystem { inputs.nixpkgs.lib.nixosSystem {
specialArgs = args; specialArgs = args;
modules = [ ./systems ]; modules = [
./systems
inputs.home-manager.nixosModules.home-manager
inputs.sops-nix.nixosModules.sops
];
}; };
}; };
in in

View file

@ -18,8 +18,8 @@
./modules/bootloaders/systemd-boot.nix ./modules/bootloaders/systemd-boot.nix
./modules/programs/zsh.nix ./modules/programs/zsh.nix
./modules/hardware/networking.nix ./modules/hardware/networking.nix
inputs.sops-nix.nixosModules.sops ./modules/security.nix
inputs.home-manager.nixosModules.home-manager ./modules/users.nix
] ]
# Options for desktops. # Options for desktops.
(lib.optionals (type == "desktop") [ (lib.optionals (type == "desktop") [
@ -53,29 +53,16 @@
"sd_mod" "sd_mod"
]; ];
}; };
home-manager = { home-manager = {
useGlobalPkgs = true; useGlobalPkgs = true;
useUserPackages = true; useUserPackages = true;
extraSpecialArgs = specialArgs; extraSpecialArgs = specialArgs;
users.${username}.imports = [ ../users/rafiq.nix ];
}; };
system.stateVersion = "24.11"; system.stateVersion = "24.11";
users.mutableUsers = false; # Always reset users on system activation users.mutableUsers = false; # Always reset users on system activation
users.users.${username} = {
isNormalUser = true;
description = "${username}";
hashedPasswordFile = config.sops.secrets.password.path;
extraGroups = [
"networkmanager"
"wheel"
];
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILdsZyY3gu8IGB8MzMnLdh+ClDxQQ2RYG9rkeetIKq8n"
];
};
security.sudo.wheelNeedsPassword = false;
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
nix = { nix = {
@ -108,9 +95,4 @@
i18n.defaultLocale = "en_SG.UTF-8"; i18n.defaultLocale = "en_SG.UTF-8";
sops = {
defaultSopsFile = ../secrets/secrets.yaml;
age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
secrets.password.neededForUsers = true;
};
} }

View file

@ -1,6 +1,5 @@
{ username, ... }:
{ {
services.getty = { services.getty = {
autologinUser = "${username}"; autologinUser = "rafiq";
}; };
} }

View file

@ -2,7 +2,6 @@
inputs, inputs,
hostname, hostname,
pkgs, pkgs,
username,
... ...
}: }:
let let
@ -18,7 +17,7 @@ let
in in
{ {
security.pam.services.hyprlock = { }; security.pam.services.hyprlock = { };
home-manager.users.${username} = { home-manager.users.rafiq = {
programs.hyprlock = { programs.hyprlock = {
enable = true; enable = true;
package = inputs.hyprlock.packages.${pkgs.stdenv.hostPlatform.system}.hyprlock; package = inputs.hyprlock.packages.${pkgs.stdenv.hostPlatform.system}.hyprlock;

View file

@ -0,0 +1,2 @@
{
}

View file

@ -0,0 +1,9 @@
{
sops = {
defaultSopsFile = ../../secrets/secrets.yaml;
age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
secrets.password.neededForUsers = true;
};
security.sudo.wheelNeedsPassword = false;
}

View file

@ -0,0 +1,8 @@
{ inputs, ... }:
{
sops = {
defaultSopsFile = ../../../secrets/secrets.yaml;
age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
secrets.password.neededForUsers = true;
};
}

View file

@ -1,4 +1,4 @@
{ inputs, username, ... }: { inputs, ... }:
let let
opacity = 0.8; opacity = 0.8;
toImport = [ toImport = [
@ -25,12 +25,12 @@ in
fonts.enableDefaultPackages = true; fonts.enableDefaultPackages = true;
imports = [ inputs.stylix.nixosModules.stylix ] ++ toImport; imports = [ inputs.stylix.nixosModules.stylix ] ++ toImport;
home-manager.users.${username}.imports = [ inputs.stylix.homeManagerModules.stylix ] ++ toImport; home-manager.users.rafiq.imports = [ inputs.stylix.homeManagerModules.stylix ] ++ toImport;
# Put options that only exist in the NixOS module here. # Put options that only exist in the NixOS module here.
stylix.homeManagerIntegration.autoImport = false; stylix.homeManagerIntegration.autoImport = false;
stylix.homeManagerIntegration.followSystem = false; stylix.homeManagerIntegration.followSystem = false;
# Put options that only exist in the home-manager module here. # Put options that only exist in the home-manager module here.
# home-manager.users.${username}.stylix = {}; # home-manager.users.rafiq.stylix = {};
} }

16
systems/modules/users.nix Normal file
View file

@ -0,0 +1,16 @@
{ config, ... }:
{
home-manager.users.rafiq.imports = [ ../../users/rafiq.nix ];
users.users.rafiq = {
isNormalUser = true;
description = "rafiq";
hashedPasswordFile = config.sops.secrets.password.path;
extraGroups = [
"networkmanager"
"wheel"
];
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILdsZyY3gu8IGB8MzMnLdh+ClDxQQ2RYG9rkeetIKq8n"
];
};
}

View file

@ -0,0 +1,16 @@
{ inputs, config, ... }:
{
home-manager.users.rafiq.imports = [ ../../../users/rafiq.nix ];
users.users.rafiq = {
isNormalUser = true;
description = "rafiq";
hashedPasswordFile = config.sops.secrets.password.path;
extraGroups = [
"networkmanager"
"wheel"
];
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILdsZyY3gu8IGB8MzMnLdh+ClDxQQ2RYG9rkeetIKq8n"
];
};
}

View file

@ -1,8 +1,6 @@
{ {
pkgs, pkgs,
inputs, inputs,
lib,
username,
... ...
}: }:
{ {
@ -57,8 +55,8 @@
}; };
home = { home = {
username = "${username}"; username = "rafiq";
homeDirectory = "/home/${username}"; homeDirectory = "/home/rafiq";
# This defines the version home-manager # This defines the version home-manager
# was originally bulit against on this system. # was originally bulit against on this system.