From 7d37b92e172e3f4556900c57f73dc38b65ee63c0 Mon Sep 17 00:00:00 2001 From: alexion Date: Mon, 5 Oct 2026 23:15:01 -0400 Subject: [PATCH] refactor(nixos): scope user profile to hosts --- configs/nixos/modules/default.nix | 65 +------------------------------ configs/nixos/modules/host.nix | 60 ++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 64 deletions(-) diff --git a/configs/nixos/modules/default.nix b/configs/nixos/modules/default.nix index f46e319..85cda14 100644 --- a/configs/nixos/modules/default.nix +++ b/configs/nixos/modules/default.nix @@ -1,14 +1,10 @@ { config, lib, - pkgs, inputs, ... }: # The shared foundation for every host and guest. -let - stateVersion = "26.05"; -in { imports = [ inputs.home-manager.nixosModules.home-manager ]; @@ -24,7 +20,7 @@ in }; config = { - system.stateVersion = stateVersion; + system.stateVersion = "26.05"; nixpkgs.config.allowUnfree = true; nix.settings.experimental-features = [ @@ -42,66 +38,7 @@ in users.groups.storage.gid = 10000; - security.sudo.extraConfig = '' - Defaults env_keep += "EDITOR VISUAL" - ''; - time.timeZone = "America/New_York"; i18n.defaultLocale = "en_GB.UTF-8"; - - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - users.${config.user.name} = { - home.username = config.user.name; - home.homeDirectory = "/home/${config.user.name}"; - home.stateVersion = stateVersion; - home.packages = with pkgs; [ - eza - wget - ]; - }; - }; - - registry.shell-shortcut.${config.networking.hostName} = { - ls = { - command = "eza -alg --color=always --group-directories-first --icons=always"; - abbreviation = false; - }; - ll = { - command = "eza -lg --color=always --group-directories-first --icons=always"; - abbreviation = false; - }; - lt = { - command = "eza -aT -I '.git' --color=always --group-directories-first --icons=always"; - abbreviation = false; - }; - ".." = "cd .."; - "..." = "cd ../.."; - "...." = "cd ../../.."; - - cp = "cp -v"; - tarnow = "tar -acf "; - untar = "tar -zxvf "; - wget = "wget -c "; - grep = "grep --color=auto"; - fgrep = "fgrep --color=auto"; - egrep = "egrep --color=auto"; - jctl = "journalctl -p 3 -xb"; - - update = "sudo nixos-rebuild switch --flake .#${config.networking.hostName}"; - cleanup = "sudo nix-collect-garbage -d"; - sops-host = { - command = "sudo --preserve-env=EDITOR,VISUAL env SOPS_AGE_KEY_FILE=/var/lib/sops-nix/key.txt nix shell nixpkgs#sops nixpkgs#neovim -c sops"; - abbreviation = false; - }; - }; - - modules.shell.fish.enable = lib.mkDefault true; - modules.shell.fish.defaultShell = lib.mkDefault true; - modules.shell.tmux.enable = lib.mkDefault true; - modules.shell.nvim.enable = lib.mkDefault true; - modules.shell.git.enable = lib.mkDefault true; - modules.shell.yazi.enable = lib.mkDefault true; }; } diff --git a/configs/nixos/modules/host.nix b/configs/nixos/modules/host.nix index 3805c92..44d97a4 100644 --- a/configs/nixos/modules/host.nix +++ b/configs/nixos/modules/host.nix @@ -1,6 +1,7 @@ { config, lib, + pkgs, ... }: let @@ -48,5 +49,64 @@ in users.mutableUsers = false; sops.secrets.${passwordSecret}.neededForUsers = true; users.users.${user.name}.hashedPasswordFile = config.sops.secrets.${passwordSecret}.path; + + security.sudo.extraConfig = '' + Defaults env_keep += "EDITOR VISUAL" + ''; + + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + users.${user.name} = { + home.username = user.name; + home.homeDirectory = "/home/${user.name}"; + home.stateVersion = config.system.stateVersion; + home.packages = with pkgs; [ + eza + wget + ]; + }; + }; + + registry.shell-shortcut.${config.networking.hostName} = { + ls = { + command = "eza -alg --color=always --group-directories-first --icons=always"; + abbreviation = false; + }; + ll = { + command = "eza -lg --color=always --group-directories-first --icons=always"; + abbreviation = false; + }; + lt = { + command = "eza -aT -I '.git' --color=always --group-directories-first --icons=always"; + abbreviation = false; + }; + ".." = "cd .."; + "..." = "cd ../.."; + "...." = "cd ../../.."; + + cp = "cp -v"; + tarnow = "tar -acf "; + untar = "tar -zxvf "; + wget = "wget -c "; + grep = "grep --color=auto"; + fgrep = "fgrep --color=auto"; + egrep = "egrep --color=auto"; + jctl = "journalctl -p 3 -xb"; + + update = "sudo nixos-rebuild switch --flake .#${config.networking.hostName}"; + cleanup = "sudo nix-collect-garbage -d"; + sops-host = { + command = "sudo --preserve-env=EDITOR,VISUAL env SOPS_AGE_KEY_FILE=/var/lib/sops-nix/key.txt nix shell nixpkgs#sops nixpkgs#neovim -c sops"; + abbreviation = false; + }; + }; + + modules.shell.fish.enable = lib.mkDefault true; + modules.shell.fish.defaultShell = lib.mkDefault true; + modules.shell.tmux.enable = lib.mkDefault true; + modules.shell.nvim.enable = lib.mkDefault true; + modules.shell.git.enable = lib.mkDefault true; + modules.shell.yazi.enable = lib.mkDefault true; }; }