From 77272fb93169139f293b979bba2492a843b835e4 Mon Sep 17 00:00:00 2001 From: mjallen18 Date: Fri, 30 May 2025 10:39:27 -0500 Subject: [PATCH] beginning a lot of reorganizing stuff --- base/base-gui/default.nix | 4 + base/base-gui/services.nix | 15 ++ base/base-nogui/boot.nix | 14 ++ base/base-nogui/default.nix | 45 +++++ base/base-nogui/environment.nix | 12 ++ base/base-nogui/nix-settings.nix | 41 +++++ base/base-nogui/security.nix | 31 ++++ base/base-nogui/services.nix | 25 +++ base/default.nix | 27 +++ base/options.nix | 35 ++++ flake.nix | 42 +++-- hosts/desktop/boot.nix | 2 +- hosts/desktop/configuration.nix | 6 +- hosts/desktop/services.nix | 14 +- hosts/desktop/users.nix | 2 +- hosts/desktop/wifi-fixer.nix | 2 +- hosts/nas/configuration.nix | 2 - .../desktop-environments/cosmic/default.nix | 10 +- .../cosmic/specialisation.nix | 14 +- .../desktop-environments/gnome/default.nix | 23 +++ .../desktop-environments/hyprland/default.nix | 174 +++++++++--------- .../hyprland/specialisation.nix | 6 + share/amd/default.nix | 2 +- share/gaming/default.nix | 2 +- 24 files changed, 401 insertions(+), 149 deletions(-) create mode 100644 base/base-gui/default.nix create mode 100644 base/base-gui/services.nix create mode 100644 base/base-nogui/boot.nix create mode 100644 base/base-nogui/default.nix create mode 100644 base/base-nogui/environment.nix create mode 100644 base/base-nogui/nix-settings.nix create mode 100644 base/base-nogui/security.nix create mode 100644 base/base-nogui/services.nix create mode 100644 base/default.nix create mode 100644 base/options.nix create mode 100644 modules/desktop-environments/gnome/default.nix create mode 100755 modules/desktop-environments/hyprland/specialisation.nix diff --git a/base/base-gui/default.nix b/base/base-gui/default.nix new file mode 100644 index 0000000..150b6a1 --- /dev/null +++ b/base/base-gui/default.nix @@ -0,0 +1,4 @@ +{ ... }: +{ + imports = [ ./services.nix ]; +} \ No newline at end of file diff --git a/base/base-gui/services.nix b/base/base-gui/services.nix new file mode 100644 index 0000000..b9964a5 --- /dev/null +++ b/base/base-gui/services.nix @@ -0,0 +1,15 @@ +{ lib, ... }: +{ + services = { + # configure pipewire + pipewire = { + enable = lib.mkDefault true; + alsa.enable = lib.mkDefault true; + alsa.support32Bit = lib.mkDefault true; + pulse.enable = lib.mkDefault true; + }; + + # Enable CUPS to print documents. + printing.enable = lib.mkDefault true; + }; +} \ No newline at end of file diff --git a/base/base-nogui/boot.nix b/base/base-nogui/boot.nix new file mode 100644 index 0000000..cde074e --- /dev/null +++ b/base/base-nogui/boot.nix @@ -0,0 +1,14 @@ +{ lib, pkgs, ... }: +{ + boot = { + # Enable AppImage + binfmt.registrations.appimage = { + wrapInterpreterInShell = lib.mkDefault false; + interpreter = "${pkgs.appimage-run}/bin/appimage-run"; + recognitionType = "magic"; + offset = 0; + mask = "\\xff\\xff\\xff\\xff\\x00\\x00\\x00\\x00\\xff\\xff\\xff"; + magicOrExtension = "\\x7fELF....AI\\x02"; + }; + }; +} \ No newline at end of file diff --git a/base/base-nogui/default.nix b/base/base-nogui/default.nix new file mode 100644 index 0000000..da369ff --- /dev/null +++ b/base/base-nogui/default.nix @@ -0,0 +1,45 @@ +{ lib, ... }: +let + timezone = "America/Chicago"; +in +{ + imports = [ + ./boot.nix + ./environment.nix + ./nix-settings.nix + ./security.nix + ./services.nix + ../../share + ]; + + # Hardware configs + hardware = { + # Bluetooth + bluetooth.enable = lib.mkDefault true; + + # Enable all firmware + enableAllFirmware = lib.mkForce true; + }; + + # Time config + time = { + # Set your time zone. + timeZone = timezone; + }; + + programs = { + zsh.enable = lib.mkDefault true; + gnupg.agent = { + enable = lib.mkDefault true; + enableSSHSupport = lib.mkDefault true; + }; + command-not-found.enable = lib.mkForce false; + nix-index = { + enable = true; + enableBashIntegration = false; + enableZshIntegration = true; + }; + }; + + system.stateVersion = "23.11"; +} diff --git a/base/base-nogui/environment.nix b/base/base-nogui/environment.nix new file mode 100644 index 0000000..4ba1d06 --- /dev/null +++ b/base/base-nogui/environment.nix @@ -0,0 +1,12 @@ +{ pkgs, ... }: +{ + environment = { + systemPackages = with pkgs; [ + uutils-coreutils + uutils-diffutils + uutils-findutils + coreutils + nixd + ]; + }; +} \ No newline at end of file diff --git a/base/base-nogui/nix-settings.nix b/base/base-nogui/nix-settings.nix new file mode 100644 index 0000000..f499eef --- /dev/null +++ b/base/base-nogui/nix-settings.nix @@ -0,0 +1,41 @@ +{ lib, outputs, ... }: +{ + nix = { + settings = { + substituters = [ + "https://nix-community.cachix.org" + "https://cache.nixos.org/" + ]; + trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + warn-dirty = lib.mkForce false; + experimental-features = lib.mkForce [ + "nix-command" + "flakes" + ]; + trusted-users = [ "@wheel" ]; + }; + + # Garbage collect automatically every week + gc.automatic = lib.mkDefault true; + gc.options = lib.mkDefault "--delete-older-than 30d"; + + optimise.automatic = lib.mkDefault true; + }; + + # Nixpkgs configuration + nixpkgs = { + # add unstable and stable overlays + overlays = [ + outputs.overlays.nixpkgs-unstable + outputs.overlays.nixpkgs-stable + ]; + config = { + allowUnfree = lib.mkForce true; + permittedInsecurePackages = [ + # ... + ]; + }; + }; +} \ No newline at end of file diff --git a/base/base-nogui/security.nix b/base/base-nogui/security.nix new file mode 100644 index 0000000..64e8dcd --- /dev/null +++ b/base/base-nogui/security.nix @@ -0,0 +1,31 @@ +{ lib, pkgs, ... }: +{ + security = { + rtkit.enable = lib.mkDefault true; + + # configure sudo + sudo.enable = lib.mkDefault false; + sudo-rs = { + enable = lib.mkDefault true; + extraRules = [ + { + commands = [ + { + command = "${pkgs.systemd}/bin/systemctl suspend"; + options = [ "NOPASSWD" ]; + } + { + command = "${pkgs.systemd}/bin/reboot"; + options = [ "NOPASSWD" ]; + } + { + command = "${pkgs.systemd}/bin/poweroff"; + options = [ "NOPASSWD" ]; + } + ]; + groups = [ "wheel" ]; + } + ]; + }; + }; +} \ No newline at end of file diff --git a/base/base-nogui/services.nix b/base/base-nogui/services.nix new file mode 100644 index 0000000..bd03696 --- /dev/null +++ b/base/base-nogui/services.nix @@ -0,0 +1,25 @@ +{ lib, ... }: +{ + services = { + openssh.enable = lib.mkDefault true; + + # Enable firmware updates + fwupd.enable = lib.mkForce true; + + fstrim.enable = lib.mkDefault true; + + pcscd.enable = lib.mkDefault true; + + # Enable Avahi for .local hostname resolution + avahi = { + enable = lib.mkDefault true; + nssmdns4 = lib.mkDefault true; # For modern systems, use nssmdns4 instead of nssmdns + publish = { + enable = lib.mkDefault true; + addresses = lib.mkDefault true; + domain = lib.mkDefault true; + workstation = lib.mkDefault true; + }; + }; + }; +} \ No newline at end of file diff --git a/base/default.nix b/base/default.nix new file mode 100644 index 0000000..539d6e8 --- /dev/null +++ b/base/default.nix @@ -0,0 +1,27 @@ +# { lib, config, ... }: + +# let +# cfg = config.base; + +# cosmicPath = +# if cfg.desktopEnvironments.cosmic.enableSpecialisation then +# ../../modules/desktop-environments/cosmic/specialisation.nix +# else +# ../../modules/desktop-environments/cosmic/default.nix; + +# hyprlandPath = +# if cfg.desktopEnvironments.hyprland.enableSpecialisation then +# ../../modules/desktop-environments/hyprland/specialisation.nix +# else +# ../../modules/desktop-environments/hyprland/default.nix; + +# extraImports = lib.optionals cfg.enable ( +# [ ./base-nogui ] +# ++ lib.optional cfg.baseGui.enable ./base-gui +# ++ lib.optional cfg.desktopEnvironments.cosmic.enable cosmicPath +# ++ lib.optional cfg.desktopEnvironments.hyprland.enable hyprlandPath +# ); +# in +# { +# imports = [ ./options.nix ] ++ extraImports; +# } diff --git a/base/options.nix b/base/options.nix new file mode 100644 index 0000000..0a413c3 --- /dev/null +++ b/base/options.nix @@ -0,0 +1,35 @@ +{ lib, ... }: +with lib; +{ + options.base = { + enable = mkEnableOption "base config"; + + baseGui.enable = mkOption { + type = types.bool; + default = false; + }; + + desktopEnvironments = { + cosmic = { + enable = mkOption { + type = types.bool; + default = false; + }; + enableSpecialisation = mkOption { + type = types.bool; + default = false; + }; + }; + hyprland = { + enable = mkOption { + type = types.bool; + default = false; + }; + enableSpecialisation = mkOption { + type = types.bool; + default = false; + }; + }; + }; + }; +} diff --git a/flake.nix b/flake.nix index c1ae93f..80ab98b 100755 --- a/flake.nix +++ b/flake.nix @@ -347,11 +347,22 @@ inherit inputs outputs; }; modules = [ - desktop-impermanence.nixosModules.impermanence - desktop-lanzaboote.nixosModules.lanzaboote + ./base/base-nogui + ./base/base-gui ./hosts/desktop/configuration.nix - ./share/impermanence + ./modules/desktop-environments/gnome + + # Lanzaboote + desktop-lanzaboote.nixosModules.lanzaboote + + # Chaotic Nyx desktop-chaotic.nixosModules.default + + # Impermanence + desktop-impermanence.nixosModules.impermanence + ./share/impermanence + + # Home Manager desktop-home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; @@ -376,14 +387,13 @@ home-manager.backupFileExtension = "backup"; } + # nixos hardware desktop-nixos-hardware.nixosModules.common-cpu-amd desktop-nixos-hardware.nixosModules.common-cpu-amd-pstate desktop-nixos-hardware.nixosModules.common-cpu-amd-zenpower desktop-nixos-hardware.nixosModules.common-gpu-amd desktop-nixos-hardware.nixosModules.common-hidpi desktop-nixos-hardware.nixosModules.common-pc - - desktop-sops-nix.nixosModules.sops ]; }; @@ -394,11 +404,18 @@ inherit inputs outputs; }; modules = [ - nas-impermanence.nixosModules.impermanence - nas-lanzaboote.nixosModules.lanzaboote - nas-cosmic.nixosModules.default + ./base/base-nogui + ./base/base-gui ./hosts/nas/configuration.nix + ./modules/desktop-environments/cosmic + + nas-lanzaboote.nixosModules.lanzaboote + + nas-impermanence.nixosModules.impermanence ./hosts/nas/impermanence.nix + + nas-cosmic.nixosModules.default + nas-home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = false; @@ -501,15 +518,6 @@ pi4-impermanence.nixosModules.impermanence pi4-sops-nix.nixosModules.sops ./hosts/pi4/configuration.nix - #{ - # # Hardware specific configuration, see section below for a more complete - # # list of modules - # imports = with nixos-raspberrypi.nixosModules; [ - # raspberry-pi-4.base - # raspberry-pi-4.display-vc4 - # raspberry-pi-4.bluetooth - # ]; - #} pi4-home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; diff --git a/hosts/desktop/boot.nix b/hosts/desktop/boot.nix index 1a7633d..cea056f 100755 --- a/hosts/desktop/boot.nix +++ b/hosts/desktop/boot.nix @@ -3,7 +3,7 @@ let configLimit = 5; # default = "@saved"; kernel = pkgs.linuxPackages_cachyos; - pkgsVersion = pkgs.unstable; + pkgsVersion = pkgs; #.unstable; in { # Configure bootloader with lanzaboot and secureboot diff --git a/hosts/desktop/configuration.nix b/hosts/desktop/configuration.nix index 311a490..defa34a 100755 --- a/hosts/desktop/configuration.nix +++ b/hosts/desktop/configuration.nix @@ -9,7 +9,7 @@ ... }: let - pkgsVersion = pkgs.unstable; + pkgsVersion = pkgs; #.unstable; environmentVariables = { STEAM_FORCE_DESKTOPUI_SCALING = "1.0"; GDK_SCALE = "1"; @@ -158,10 +158,6 @@ in ]; }; coolercontrol.enable = true; - kdeconnect = { - enable = true; - package = pkgs.gnomeExtensions.gsconnect; - }; }; # Common Configuration diff --git a/hosts/desktop/services.nix b/hosts/desktop/services.nix index 3b80e9d..4a2fe29 100755 --- a/hosts/desktop/services.nix +++ b/hosts/desktop/services.nix @@ -1,21 +1,9 @@ { config, lib, pkgs, ... }: let - pkgsVersion = pkgs.unstable; + pkgsVersion = pkgs; #.unstable; in { services = { - # Enable Desktop Environment. - xserver = { - desktopManager.gnome.enable = true; - # Enable Desktop Environment. - displayManager = { - gdm.enable = lib.mkDefault true; - gdm.wayland = lib.mkDefault true; - }; - }; - - gnome.gnome-remote-desktop.enable = true; - # Enable Flatpak flatpak.enable = lib.mkDefault false; diff --git a/hosts/desktop/users.nix b/hosts/desktop/users.nix index 37e695b..f14e94f 100644 --- a/hosts/desktop/users.nix +++ b/hosts/desktop/users.nix @@ -2,7 +2,7 @@ let user = "matt"; passwordFile = config.sops.secrets."desktop/matt_password".path; - pkgsVersion = pkgs.unstable; + pkgsVersion = pkgs; #.unstable; in { users.users."${user}" = { diff --git a/hosts/desktop/wifi-fixer.nix b/hosts/desktop/wifi-fixer.nix index 1a615a6..90bddfa 100644 --- a/hosts/desktop/wifi-fixer.nix +++ b/hosts/desktop/wifi-fixer.nix @@ -75,7 +75,7 @@ let if __name__ == "__main__": main() ''; - pkgsVersion = pkgs.unstable; + pkgsVersion = pkgs; #.unstable; in { systemd = { diff --git a/hosts/nas/configuration.nix b/hosts/nas/configuration.nix index c70e477..6439f76 100755 --- a/hosts/nas/configuration.nix +++ b/hosts/nas/configuration.nix @@ -21,8 +21,6 @@ ./samba.nix ./services.nix ./sops.nix - ../default.nix - ../../modules/desktop-environments/cosmic/default.nix ]; powerManagement.cpuFreqGovernor = "powersave"; diff --git a/modules/desktop-environments/cosmic/default.nix b/modules/desktop-environments/cosmic/default.nix index e2975dd..6fb2263 100755 --- a/modules/desktop-environments/cosmic/default.nix +++ b/modules/desktop-environments/cosmic/default.nix @@ -1,9 +1,7 @@ { ... }: { - # specialisation.cosmic.configuration = { - services = { - desktopManager.cosmic.enable = true; - displayManager.cosmic-greeter.enable = true; - }; - # }; + services = { + desktopManager.cosmic.enable = true; + displayManager.cosmic-greeter.enable = true; + }; } diff --git a/modules/desktop-environments/cosmic/specialisation.nix b/modules/desktop-environments/cosmic/specialisation.nix index ecdc2d9..5fba884 100755 --- a/modules/desktop-environments/cosmic/specialisation.nix +++ b/modules/desktop-environments/cosmic/specialisation.nix @@ -1,18 +1,6 @@ { lib, ... }: { specialisation.cosmic.configuration = { - services = { - desktopManager.cosmic.enable = lib.mkForce true; - displayManager.cosmic-greeter.enable = lib.mkForce true; - # Disable Gnome - xserver = { - desktopManager.gnome.enable = lib.mkForce false; - # Enable Desktop Environment. - displayManager = { - gdm.enable = lib.mkForce false; - gdm.wayland = lib.mkForce false; - }; - }; - }; + imports = [ ./default.nix ] }; } diff --git a/modules/desktop-environments/gnome/default.nix b/modules/desktop-environments/gnome/default.nix new file mode 100644 index 0000000..d9f0b63 --- /dev/null +++ b/modules/desktop-environments/gnome/default.nix @@ -0,0 +1,23 @@ +{ pkgs, ... }: +{ + services = { + # Enable Desktop Environment. + xserver = { + desktopManager.gnome.enable = true; + # Enable Desktop Environment. + displayManager = { + gdm.enable = lib.mkDefault true; + gdm.wayland = lib.mkDefault true; + }; + }; + + gnome.gnome-remote-desktop.enable = true; + }; + + programs = { + kdeconnect = { + enable = true; + package = pkgs.gnomeExtensions.gsconnect; + }; + }; +} \ No newline at end of file diff --git a/modules/desktop-environments/hyprland/default.nix b/modules/desktop-environments/hyprland/default.nix index 9fba23a..bc6bf39 100755 --- a/modules/desktop-environments/hyprland/default.nix +++ b/modules/desktop-environments/hyprland/default.nix @@ -3,106 +3,104 @@ let sddmTheme = "catppuccin-mocha"; in { - specialisation.hyprland.configuration = { - imports = [ - ./environment.nix - ]; + imports = [ + ./environment.nix + ]; - home-manager.users.matt = import ./home.nix; + home-manager.users.matt = import ./home.nix; - services = { - displayManager.sddm.enable = true; - displayManager.sddm.package = pkgs.kdePackages.sddm; - displayManager.sddm.theme = sddmTheme; - displayManager.defaultSession = "hyprland"; - # disable plasma - desktopManager.plasma6.enable = false; + services = { + displayManager.sddm.enable = true; + displayManager.sddm.package = pkgs.kdePackages.sddm; + displayManager.sddm.theme = sddmTheme; + displayManager.defaultSession = "hyprland"; + # disable plasma + desktopManager.plasma6.enable = false; - dbus.enable = true; + dbus.enable = true; - ddccontrol.enable = true; + ddccontrol.enable = true; - blueman.enable = true; - }; + blueman.enable = true; + }; - programs.hyprland = { - enable = true; - xwayland.enable = true; - portalPackage = pkgs.xdg-desktop-portal-hyprland; - }; + programs.hyprland = { + enable = true; + xwayland.enable = true; + portalPackage = pkgs.xdg-desktop-portal-hyprland; + }; - programs.nm-applet.enable = true; + programs.nm-applet.enable = true; - systemd = { - user.services.polkit-gnome-authentication-agent-1 = { - description = "polkit-gnome-authentication-agent-1"; - wantedBy = [ "graphical-session.target" ]; - wants = [ "graphical-session.target" ]; - after = [ "graphical-session.target" ]; - serviceConfig = { - Type = "simple"; - ExecStart = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1"; - Restart = "on-failure"; - RestartSec = 1; - TimeoutStopSec = 10; - }; + systemd = { + user.services.polkit-gnome-authentication-agent-1 = { + description = "polkit-gnome-authentication-agent-1"; + wantedBy = [ "graphical-session.target" ]; + wants = [ "graphical-session.target" ]; + after = [ "graphical-session.target" ]; + serviceConfig = { + Type = "simple"; + ExecStart = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1"; + Restart = "on-failure"; + RestartSec = 1; + TimeoutStopSec = 10; }; - extraConfig = '' - DefaultTimeoutStopSec=10s - ''; }; + extraConfig = '' + DefaultTimeoutStopSec=10s + ''; + }; - security = { - polkit.enable = true; + security = { + polkit.enable = true; - # configure sudo - sudo.extraRules = [ - { - commands = [ - { - command = "/run/current-system/sw/bin/waybar-weather"; - options = [ "NOPASSWD" ]; - } - { - command = "/run/current-system/sw/bin/waybar-updates"; - options = [ "NOPASSWD" ]; - } - ]; - groups = [ "wheel" ]; - } - ]; - }; - - xdg.portal = { - enable = true; - wlr.enable = false; - xdgOpenUsePortal = false; - extraPortals = [ - pkgs.xdg-desktop-portal-hyprland - pkgs.xdg-desktop-portal-gtk - ]; - }; - - fonts.packages = with pkgs; [ - font-awesome - noto-fonts - noto-fonts-color-emoji - nerdfonts - meslo-lgs-nf - ]; - - fonts.fontconfig.defaultFonts = { - emoji = [ - "Noto Color Emoji" - ]; - }; - - nixpkgs.overlays = [ - (self: super: { - waybar = super.waybar.overrideAttrs (oldAttrs: { - mesonFlags = oldAttrs.mesonFlags ++ [ "-Dexperimental=true" ]; - }); - }) + # configure sudo + sudo.extraRules = [ + { + commands = [ + { + command = "/run/current-system/sw/bin/waybar-weather"; + options = [ "NOPASSWD" ]; + } + { + command = "/run/current-system/sw/bin/waybar-updates"; + options = [ "NOPASSWD" ]; + } + ]; + groups = [ "wheel" ]; + } ]; }; + + xdg.portal = { + enable = true; + wlr.enable = false; + xdgOpenUsePortal = false; + extraPortals = [ + pkgs.xdg-desktop-portal-hyprland + pkgs.xdg-desktop-portal-gtk + ]; + }; + + fonts.packages = with pkgs; [ + font-awesome + noto-fonts + noto-fonts-color-emoji + nerdfonts + meslo-lgs-nf + ]; + + fonts.fontconfig.defaultFonts = { + emoji = [ + "Noto Color Emoji" + ]; + }; + + nixpkgs.overlays = [ + (self: super: { + waybar = super.waybar.overrideAttrs (oldAttrs: { + mesonFlags = oldAttrs.mesonFlags ++ [ "-Dexperimental=true" ]; + }); + }) + ]; } diff --git a/modules/desktop-environments/hyprland/specialisation.nix b/modules/desktop-environments/hyprland/specialisation.nix new file mode 100755 index 0000000..9225bc6 --- /dev/null +++ b/modules/desktop-environments/hyprland/specialisation.nix @@ -0,0 +1,6 @@ +{ lib, ... }: +{ + specialisation.hyprland.configuration = { + imports = [ ./default.nix ] + }; +} diff --git a/share/amd/default.nix b/share/amd/default.nix index 14437c5..d95edb0 100755 --- a/share/amd/default.nix +++ b/share/amd/default.nix @@ -6,7 +6,7 @@ }: let cfg = config.share.hardware.amd; - pkgsVersion = pkgs.unstable; + pkgsVersion = pkgs;#.unstable; in { imports = [ ./options.nix ]; diff --git a/share/gaming/default.nix b/share/gaming/default.nix index 42663a3..83766d4 100755 --- a/share/gaming/default.nix +++ b/share/gaming/default.nix @@ -1,7 +1,7 @@ { lib, config, pkgs, ... }: let cfg = config.share.gaming; - pkgsVersion = pkgs.unstable; + pkgsVersion = pkgs; #.unstable; in { imports = [ ./options.nix ];