diff options
| -rw-r--r-- | flake.nix | 8 | ||||
| -rw-r--r-- | hosts/adam/configuration.nix | 74 | ||||
| -rw-r--r-- | hosts/lilith/configuration.nix | 43 | ||||
| -rw-r--r-- | lib/default.nix | 167 | ||||
| -rw-r--r-- | modules/hosts/desktop/default.nix | 19 | ||||
| -rw-r--r-- | modules/hosts/system/users.nix | 19 | ||||
| -rw-r--r-- | modules/users/productivity/anki/default.nix | 18 | ||||
| -rw-r--r-- | modules/users/terminal/default.nix | 2 |
8 files changed, 225 insertions, 125 deletions
@@ -37,6 +37,10 @@ username = "schererleander"; system = linux-system; overlays = overlays; + extraHomeModules = [ + inputs.nixcord.homeModules.nixcord + inputs.spicetify-nix.homeManagerModules.spicetify + ]; }; sachiel = lib.mkSystem { host = "sachiel"; @@ -50,6 +54,10 @@ username = username; system = darwin-system; overlays = overlays; + extraHomeModules = [ + inputs.nixcord.homeModules.nixcord + inputs.spicetify-nix.homeManagerModules.spicetify + ]; }; }; } diff --git a/hosts/adam/configuration.nix b/hosts/adam/configuration.nix index 27aa010..4c8ea21 100644 --- a/hosts/adam/configuration.nix +++ b/hosts/adam/configuration.nix @@ -1,7 +1,6 @@ { pkgs, username, - inputs, ... }: @@ -10,8 +9,6 @@ ./hardware-configuration.nix ]; - home-manager.extraSpecialArgs = { inherit inputs; }; - boot = { kernelPackages = pkgs.linuxPackages_latest; kernelParams = [ @@ -66,32 +63,25 @@ programs.dconf.enable = true; - home-manager.users.${username} = { - home.username = username; - home.homeDirectory = "/home/${username}"; - imports = [ - ../../modules/users - inputs.nixcord.homeModules.nixcord - inputs.spicetify-nix.homeManagerModules.spicetify - ]; - - programs.home-manager.enable = true; - home.packages = with pkgs; [ - imv - mpv - firefox + nx = { + desktop.kde.enable = true; - zoxide - ]; + user.${username} = { + stateVersion = "25.11"; + packages = with pkgs; [ + imv + mpv + firefox + zoxide + ]; + shellAliases = { + open = "xdg-open"; + }; - programs.zsh.shellAliases = { - open = "xdg-open"; - }; + nx = { + terminal.defaultShell = "zsh"; - nx = { - #browsers.firefox.enable = true; - editors = { - neovim = { + editors.neovim = { enable = true; langs = { python = true; @@ -100,27 +90,19 @@ latex = true; }; }; + git.enable = true; + cli.opencode.enable = true; + media = { + spicetify.enable = true; + nixcord.enable = true; + }; + productivity = { + nextcloud-client.enable = true; + obsidian.enable = true; + latex.enable = true; + anki.enable = true; + }; }; - git.enable = true; - cli = { - opencode.enable = true; - }; - media = { - spicetify.enable = true; - nixcord.enable = true; - }; - productivity = { - obsidian.enable = true; - latex.enable = true; - }; - }; - - home.stateVersion = "25.11"; - }; - - nx = { - desktop = { - kde.enable = true; }; }; diff --git a/hosts/lilith/configuration.nix b/hosts/lilith/configuration.nix index f3962d8..2a35c74 100644 --- a/hosts/lilith/configuration.nix +++ b/hosts/lilith/configuration.nix @@ -2,27 +2,15 @@ pkgs, host, username, - inputs, ... }: { - users.users.${username}.home = "/Users/${username}"; - networking.hostName = host; - home-manager.users.${username} = { - home.username = username; - home.homeDirectory = "/Users/${username}"; - programs.home-manager.enable = true; - - imports = [ - ../../modules/users - inputs.nixcord.homeModules.nixcord - inputs.spicetify-nix.homeManagerModules.spicetify - ]; - - home.packages = with pkgs; [ + nx.user.${username} = { + stateVersion = "25.11"; + packages = with pkgs; [ htop ffmpeg wget @@ -37,27 +25,24 @@ nerd-fonts.symbols-only ]; - home.stateVersion = "25.11"; - home.sessionVariables = { + sessionVariables = { PATH = "/opt/homebrew/opt/openjdk@21/bin:$PATH"; }; nx = { - editors = { - neovim = { - enable = true; - langs = { - python = true; - go = true; - java = true; - latex = true; - }; + terminal.defaultShell = "zsh"; + + editors.neovim = { + enable = true; + langs = { + python = true; + go = true; + java = true; + latex = true; }; }; git.enable = true; - cli = { - opencode.enable = true; - }; + cli.opencode.enable = true; media = { spicetify.enable = true; nixcord.enable = true; diff --git a/lib/default.nix b/lib/default.nix index 76bcb08..5424801 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -5,6 +5,134 @@ let isDarwin = s: lib.strings.hasSuffix "-darwin" s; in { + mkUser = + { + username, + homeDirectory ? null, + useHomeManager ? true, + extraHomeModules ? [ ], + }: + { + config, + pkgs, + lib, + system, + inputs, + ... + }: + let + inherit (lib) + mkOption + types + mkIf + mkMerge + optional + optionals + ; + + darwinHost = isDarwin system; + defaultHome = if darwinHost then "/Users/${username}" else "/home/${username}"; + home = if homeDirectory != null then homeDirectory else defaultHome; + + anyDesktopEnabled = + (config.nx.desktop.kde.enable or false) + || (config.nx.desktop.hyprland.enable or false) + || (config.nx.desktop.gnome.enable or false) + || (config.nx.desktop.cinnamon.enable or false) + || (config.nx.desktop.sway.enable or false) + || (config.nx.desktop.labwc.enable or false); + + cfg = config.nx.user.${username}; + + shellPkg = if (cfg.nx.terminal.defaultShell or "bash") == "zsh" then pkgs.zsh else pkgs.bash; + in + { + options.nx.user.${username} = mkOption { + description = "User configuration for ${username}"; + type = types.submodule { + freeformType = types.attrsOf types.anything; + options = { + stateVersion = mkOption { + type = types.str; + description = "home.stateVersion for this user"; + }; + + packages = mkOption { + type = types.listOf types.package; + default = [ ]; + description = "Extra packages for this user"; + }; + + shellAliases = mkOption { + type = types.attrsOf types.str; + default = { }; + description = "Shell aliases"; + }; + + sessionVariables = mkOption { + type = types.attrsOf types.str; + default = { }; + description = "Session environment variables"; + }; + + nx = mkOption { + type = types.attrsOf types.anything; + default = { }; + description = "User module options (proxied to home-manager's nx.*)"; + }; + }; + }; + default = { }; + }; + + config = mkMerge [ + (mkIf (!darwinHost) { + users.users.${username} = { + isNormalUser = true; + home = home; + shell = shellPkg; + ignoreShellProgramCheck = true; + extraGroups = + [ + "wheel" + ] + ++ optional (config.networking.networkmanager.enable or false) "networkmanager" + ++ optionals anyDesktopEnabled [ + "video" + "input" + ] + ++ optional (config.nx.services.audio.enable or false) "audio" + ++ optional (config.nx.printer.enable or false) "lp"; + }; + }) + + (mkIf darwinHost { + users.users.${username}.home = home; + }) + + (mkIf useHomeManager { + home-manager.extraSpecialArgs = { inherit inputs; }; + + home-manager.users.${username} = { + home.username = username; + home.homeDirectory = home; + home.stateVersion = cfg.stateVersion; + home.packages = cfg.packages; + home.sessionVariables = cfg.sessionVariables; + + programs.home-manager.enable = true; + + programs.zsh.shellAliases = mkIf (cfg.nx.terminal.defaultShell == "zsh") cfg.shellAliases; + programs.bash.shellAliases = mkIf (cfg.nx.terminal.defaultShell == "bash") cfg.shellAliases; + + imports = [ ../modules/users ] ++ extraHomeModules; + + nx = cfg.nx; + }; + }) + ]; + }; + mkSystem = { host, @@ -14,13 +142,17 @@ in extraModules ? [ ], extraSpecialArgs ? { }, useHomeManager ? true, + extraHomeModules ? [ ], }: let darwinHost = isDarwin system; - builder = if darwinHost then inputs.nix-darwin.lib.darwinSystem else inputs.nixpkgs.lib.nixosSystem; + builder = + if darwinHost then inputs.nix-darwin.lib.darwinSystem else inputs.nixpkgs.lib.nixosSystem; hostDir = ../hosts/${host}; hostCfg = hostDir + /configuration.nix; + self = import ./. { inherit inputs; }; + nixpkgsModule = { nixpkgs.overlays = overlays; nixpkgs.config.allowUnfree = true; @@ -31,18 +163,26 @@ in ]; }; - modules = [ - hostCfg - nixpkgsModule - ] - ++ (lib.optional (!darwinHost) ../modules/hosts) - ++ (lib.optional useHomeManager ( - if darwinHost then - inputs.home-manager.darwinModules.home-manager - else - inputs.home-manager.nixosModules.home-manager - )) - ++ extraModules; + modules = + [ + hostCfg + nixpkgsModule + ] + ++ (lib.optional (!darwinHost) ../modules/hosts) + ++ (lib.optional useHomeManager ( + if darwinHost then + inputs.home-manager.darwinModules.home-manager + else + inputs.home-manager.nixosModules.home-manager + )) + ++ (lib.optional useHomeManager (self.mkUser { + inherit + username + useHomeManager + extraHomeModules + ; + })) + ++ extraModules; in builder { system = system; @@ -53,6 +193,7 @@ in system host username + useHomeManager ; } // extraSpecialArgs diff --git a/modules/hosts/desktop/default.nix b/modules/hosts/desktop/default.nix index 137b68c..7d7f3ae 100644 --- a/modules/hosts/desktop/default.nix +++ b/modules/hosts/desktop/default.nix @@ -1,14 +1,17 @@ -{ ... }: +{ useHomeManager ? true, ... }: { imports = [ - #./sway - #./dunst.nix - #./waybar.nix - #./gnome + # NixOS-only modules (no home-manager) ./cinnamon + ./gnome ./kde - #./labwc - #./hyprland - ]; + ] ++ (if useHomeManager then [ + # Modules that require home-manager + ./hyprland + ./labwc + ./sway + ./dunst.nix + ./waybar.nix + ] else [ ]); } diff --git a/modules/hosts/system/users.nix b/modules/hosts/system/users.nix index 5ecdfba..9550e8d 100644 --- a/modules/hosts/system/users.nix +++ b/modules/hosts/system/users.nix @@ -1,22 +1,5 @@ -{ - config, - username, - pkgs, - lib, - ... -}: +{ ... }: { - users.users."${username}" = { - isNormalUser = true; - extraGroups = [ - "wheel" - "video" - "input" - (lib.mkIf config.networking.networkmanager.enable "networkmanager") - ]; - shell = pkgs.zsh; - ignoreShellProgramCheck = true; - }; security.sudo.wheelNeedsPassword = false; } diff --git a/modules/users/productivity/anki/default.nix b/modules/users/productivity/anki/default.nix index efe4ab5..58d8f49 100644 --- a/modules/users/productivity/anki/default.nix +++ b/modules/users/productivity/anki/default.nix @@ -1,6 +1,5 @@ { config, - options, lib, ... }: @@ -17,14 +16,13 @@ in }; }; config = mkIf cfg.enable { - # Marked as broken - #home-manager.users.${username}.programs.anki = { - #enable = true; - #style = "native"; - #addons = with pkgs.ankiAddons; [ - # anki-connect - # review-heatmap - #]; - #}; + programs.anki = { + enable = true; + #style = "native"; + #addons = with pkgs.ankiAddons; [ + # anki-connect + # review-heatmap + #]; + }; }; } diff --git a/modules/users/terminal/default.nix b/modules/users/terminal/default.nix index 4a9b254..937c086 100644 --- a/modules/users/terminal/default.nix +++ b/modules/users/terminal/default.nix @@ -30,7 +30,7 @@ in "bash" "zsh" ]; - default = "zsh"; + default = "bash"; }; }; } |
