From 62c62ef680f9a96e1b613611141028432a3f80b6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Feb 2026 20:54:32 +0000 Subject: [PATCH] Centralize hostname/user defaults Co-authored-by: ragusa-it <196988693+ragusa-it@users.noreply.github.com> --- README.md | 24 ++++++++++++------------ flake.nix | 7 +++++-- modules/common.nix | 19 +++++++++---------- modules/dev.nix | 6 +++--- modules/gaming.nix | 6 +++--- 5 files changed, 32 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 7b991e8..c2b1aa9 100644 --- a/README.md +++ b/README.md @@ -52,18 +52,18 @@ mkdir -p hosts/ cp /etc/nixos/hardware-configuration.nix hosts// ``` -### 2. Replace Placeholders +### 2. Review Configuration Defaults -Edit the following files and replace these placeholders: +Defaults are set in `flake.nix` and used across modules. Update them there: -| Placeholder | Example Value | Files | -|-------------|---------------|-------| -| `` | `desktop` | `flake.nix`, `modules/common.nix` | -| `` | `john` | `modules/common.nix`, `modules/dev.nix`, `modules/gaming.nix` | -| `` | `America/New_York` | `modules/common.nix` | -| `` | `en_US.UTF-8` | `modules/common.nix` | +| Setting | Example Value | File | +|---------|---------------|------| +| `hostname` | `desktop` | `flake.nix` | +| `username` | `john` | `flake.nix` | +| `time.timeZone` | `America/New_York` | `modules/common.nix` | +| `i18n.defaultLocale` | `en_US.UTF-8` | `modules/common.nix` | -Also rename the `hosts/hostname/` directory to match your actual hostname, and ensure the same hostname is used for all `` placeholders (including in `flake.nix`). +Also rename the `hosts//` directory to match your actual hostname, and ensure the same hostname is set in `flake.nix`. ### 3. Stage Files in Git @@ -136,10 +136,10 @@ sudo nixos-rebuild boot --profile-name gaming --flake .#gaming ### Change Password -Generate a password hash and update `modules/common.nix`: +Generate a password hash and save it to `/etc/nixos/secrets//password.hash`: ```bash mkpasswd -m sha-512 -# Copy the output and replace in common.nix +# Save the output to /etc/nixos/secrets//password.hash with 600 permissions ``` ### Setup MangoWC @@ -225,4 +225,4 @@ cat /proc/sys/vm/max_map_count # Should be 2147483642 on gaming profile ## License -MIT \ No newline at end of file +MIT diff --git a/flake.nix b/flake.nix index ff0dd48..0ecfbdc 100644 --- a/flake.nix +++ b/flake.nix @@ -37,15 +37,18 @@ outputs = { self, nixpkgs, mango, quickshell, noctalia, nix-gaming, home-manager, ... }@inputs: let system = "x86_64-linux"; + hostname = "atlas"; + username = "pinj"; lib = nixpkgs.lib; - specialArgs = { inherit inputs system; }; + hostConfig = ./hosts + "/${hostname}/hardware-configuration.nix"; + specialArgs = { inherit inputs system hostname username; }; # Verify mango flake exports the expected module mangoModule = assert lib.hasAttrByPath [ "nixosModules" "mango" ] mango; mango.nixosModules.mango; commonModules = [ - ./hosts/atlas/hardware-configuration.nix + hostConfig ./modules/common.nix mangoModule # Home Manager module - Foundation for user-level package management diff --git a/modules/common.nix b/modules/common.nix index cb1413e..d77c70f 100644 --- a/modules/common.nix +++ b/modules/common.nix @@ -1,4 +1,4 @@ -{ config, pkgs, inputs, system, ... }: +{ config, pkgs, inputs, system, hostname, username, ... }: { # -------------------------------------------------------------------------- @@ -10,7 +10,7 @@ # -------------------------------------------------------------------------- # SYSTEM # -------------------------------------------------------------------------- - networking.hostName = "atlas"; + networking.hostName = hostname; time.timeZone = "Europe/Berlin"; i18n.defaultLocale = "en_US.UTF-8"; @@ -57,12 +57,11 @@ # RADV (Mesa) is the default and performs better for gaming }; - # RADV is already the default Vulkan driver - # This variable is optional but makes it explicit - environment.variables.AMD_VULKAN_ICD = "RADV"; - # Wayland session variables for proper app integration environment.sessionVariables = { + # RADV is already the default Vulkan driver + # This variable is optional but makes it explicit + AMD_VULKAN_ICD = "RADV"; QT_QPA_PLATFORM = "wayland"; MOZ_ENABLE_WAYLAND = "1"; NIXOS_OZONE_WL = "1"; # Electron apps (VS Code, Discord, etc.) @@ -101,19 +100,19 @@ enable = true; settings.default_session = { command = "mango"; - user = "pinj"; + user = username; }; }; # -------------------------------------------------------------------------- # USER ACCOUNT # -------------------------------------------------------------------------- - users.users.pinj = { + users.users.${username} = { isNormalUser = true; extraGroups = [ "wheel" "networkmanager" "video" "seat" ]; # IMPORTANT: Generate a password hash with: mkpasswd -m sha-512 - # Then replace the placeholder below with the generated hash - hashedPassword = ""; + # Save it to the path below (ensure permissions are 600) + hashedPasswordFile = "/etc/nixos/secrets/${username}/password.hash"; packages = with pkgs; [ # -- Noctalia Shell -- inputs.quickshell.packages.${system}.default diff --git a/modules/dev.nix b/modules/dev.nix index 55c183e..95ead8d 100644 --- a/modules/dev.nix +++ b/modules/dev.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ pkgs, username, ... }: { # Identification tag (shows in boot menu and `nixos-version`) @@ -24,7 +24,7 @@ # NOTE: After first enabling/applying this dev profile, you must log out and # log back in (or reboot) for the docker group membership to take effect. - users.users.pinj.extraGroups = [ "docker" ]; + users.users.${username}.extraGroups = [ "docker" ]; # -------------------------------------------------------------------------- # DEVELOPMENT TOOLS @@ -34,7 +34,7 @@ nix-direnv.enable = true; # Caches nix shells }; - users.users.pinj.packages = with pkgs; [ + users.users.${username}.packages = with pkgs; [ # -- Git -- lazygit gh # GitHub CLI diff --git a/modules/gaming.nix b/modules/gaming.nix index b93f913..9dc9fbd 100644 --- a/modules/gaming.nix +++ b/modules/gaming.nix @@ -1,4 +1,4 @@ -{ pkgs, inputs, ... }: +{ pkgs, inputs, username, ... }: { # Identification tags (shows in boot menu) @@ -62,12 +62,12 @@ # programs to function correctly. These groups are only added when using # the gaming profile. If you need consistent group membership across # both profiles, add these groups to common.nix instead. - users.users.pinj.extraGroups = [ "corectrl" "gamemode" ]; + users.users.${username}.extraGroups = [ "corectrl" "gamemode" ]; # -------------------------------------------------------------------------- # GAMING PACKAGES # -------------------------------------------------------------------------- - users.users.pinj.packages = with pkgs; [ + users.users.${username}.packages = with pkgs; [ # -- Performance Overlays -- mangohud # FPS counter, GPU stats goverlay # MangoHud GUI config