From d18110a0184fd4dbdedc9b72e29cd342785bcd3e Mon Sep 17 00:00:00 2001 From: maxstrb Date: Mon, 22 Sep 2025 10:19:00 +0200 Subject: [PATCH] refactors --- configuration/laptop/configuration.nix | 172 +++------------------- configuration/main/configuration.nix | 163 ++------------------ configuration/modules/audio.nix | 13 ++ configuration/modules/boot.nix | 11 ++ configuration/modules/desktop.nix | 52 +++++++ configuration/modules/file-management.nix | 22 +++ configuration/modules/locale.nix | 19 +++ configuration/modules/main-user.nix | 9 ++ configuration/modules/printing.nix | 3 + configuration/modules/programs.nix | 12 ++ configuration/modules/steam.nix | 8 + configuration/modules/system.nix | 10 ++ flake.nix | 97 ++++-------- home/laptop/home.nix | 6 +- home/modules/shells.nix | 12 +- 15 files changed, 230 insertions(+), 379 deletions(-) create mode 100644 configuration/modules/audio.nix create mode 100644 configuration/modules/boot.nix create mode 100644 configuration/modules/desktop.nix create mode 100644 configuration/modules/file-management.nix create mode 100644 configuration/modules/locale.nix create mode 100644 configuration/modules/main-user.nix create mode 100644 configuration/modules/printing.nix create mode 100644 configuration/modules/programs.nix create mode 100644 configuration/modules/steam.nix create mode 100644 configuration/modules/system.nix diff --git a/configuration/laptop/configuration.nix b/configuration/laptop/configuration.nix index 7a8d017..9e7e388 100644 --- a/configuration/laptop/configuration.nix +++ b/configuration/laptop/configuration.nix @@ -1,170 +1,32 @@ { - pkgs, - inputs, - ... -}: { - nix.settings.experimental-features = ["nix-command" "flakes"]; - - nixpkgs = { - config.allowUnfree = true; - }; - - environment.systemPackages = with pkgs; [ - nushell - wl-clipboard - gvfs - libsForQt5.qt5.qtquickcontrols2 - libsForQt5.qt5.qtgraphicaleffects + imports = [ + ../modules/locale.nix + ../modules/main-user.nix + ../modules/system.nix + ../modules/boot.nix + ../modules/file-management.nix + ../modules/desktop.nix + ../modules/audio.nix + ../modules/printing.nix + ../modules/programs.nix ]; - hardware.graphics = { - enable = true; - enable32Bit = true; - }; + nix.settings.experimental-features = ["nix-command" "flakes"]; + nixpkgs.config.allowUnfree = true; - xdg = { - mime.enable = true; - menus.enable = true; - - portal = { - enable = true; - }; - }; - - programs = { - firefox.enable = true; - bash.blesh.enable = true; - xfconf.enable = true; - thunar = { - enable = true; - plugins = with pkgs.xfce; [ - thunar-archive-plugin - thunar-volman - ]; - }; - - hyprland = { - enable = true; - withUWSM = true; - package = inputs.hyprland.packages."x86_64-linux".hyprland; - portalPackage = inputs.hyprland.packages."x86_64-linux".xdg-desktop-portal-hyprland; - }; - - steam = { - enable = true; - remotePlay.openFirewall = true; - dedicatedServer.openFirewall = true; - localNetworkGameTransfers.openFirewall = true; - }; - - nix-ld = { - enable = true; - #libraries = with pkgs; [ - # Add libraries here - #]; - }; - }; - - boot = { - loader = { - systemd-boot.enable = true; - efi.canTouchEfiVariables = true; - }; - - kernelPackages = pkgs.linuxPackages_latest; - #kernelPackages = pkgs.linuxPackages_zen; - }; + services.avahi.enable = true; networking = { - hostName = "max-laptop"; proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - networkmanager.enable = true; + networkmanager.enable = false; wireless = { - enable = false; + enable = true; networks = { aaa = {psk = "laserjet6plas";}; - }; - }; - firewall = { - enable = true; - allowedTCPPorts = [8000]; - }; - }; - - environment.sessionVariables = { - XDG_CURRENT_DESKTOP = "Hyprland"; - TERMINAL = "foot"; - }; - - time.timeZone = "Europe/Prague"; - i18n = { - defaultLocale = "en_US.UTF-8"; - extraLocaleSettings = { - LC_ADDRESS = "cs_CZ.UTF-8"; - LC_IDENTIFICATION = "cs_CZ.UTF-8"; - LC_MEASUREMENT = "cs_CZ.UTF-8"; - LC_MONETARY = "cs_CZ.UTF-8"; - LC_NAME = "cs_CZ.UTF-8"; - LC_NUMERIC = "cs_CZ.UTF-8"; - LC_PAPER = "cs_CZ.UTF-8"; - LC_TELEPHONE = "cs_CZ.UTF-8"; - LC_TIME = "cs_CZ.UTF-8"; - }; - }; - - services = { - xserver = { - enable = true; - videoDrivers = ["amdgpu"]; - xkb = { - layout = "cz"; - variant = ""; - options = "caps:escape"; + "Mi Phone" = {psk = "simoneKYS";}; }; }; - tumbler.enable = true; - printing.enable = true; - avahi.enable = true; - - displayManager.sddm = { - enable = true; - theme = "${import ./sddm-theme.nix {inherit pkgs;}}"; - autoNumlock = true; - }; - - devmon.enable = true; - gvfs.enable = true; - - pipewire = { - enable = true; - - alsa = { - enable = true; - support32Bit = true; - }; - - pulse.enable = true; - jack.enable = true; - }; - }; - - console.keyMap = "cz-lat2"; - security.rtkit.enable = true; - - users.users.maxag = { - isNormalUser = true; - description = "Max Ag"; - extraGroups = ["networkmanager" "wheel" "video" "input"]; - - shell = pkgs.nushell; - }; - - system = { - stateVersion = "25.11"; - activationScripts.cleanBackups = '' - echo "Removing .backup_nix files..." - find /home/maxag -type f -name "*.backup_nix" -delete - ''; + firewall.enable = true; }; } diff --git a/configuration/main/configuration.nix b/configuration/main/configuration.nix index d972057..163f344 100644 --- a/configuration/main/configuration.nix +++ b/configuration/main/configuration.nix @@ -1,83 +1,23 @@ { - pkgs, - inputs, - ... -}: { imports = [ ./verbatim.nix + ../modules/steam.nix + + ../modules/locale.nix + ../modules/main-user.nix + ../modules/system.nix + ../modules/boot.nix + ../modules/file-management.nix + ../modules/desktop.nix + ../modules/audio.nix + ../modules/printing.nix + ../modules/programs.nix ]; nix.settings.experimental-features = ["nix-command" "flakes"]; + nixpkgs.config.allowUnfree = true; - nixpkgs = { - config.allowUnfree = true; - }; - - environment.systemPackages = with pkgs; [ - nushell - wl-clipboard - gvfs - libsForQt5.qt5.qtquickcontrols2 - libsForQt5.qt5.qtgraphicaleffects - ]; - - hardware.graphics = { - enable = true; - enable32Bit = true; - }; - - xdg = { - mime.enable = true; - menus.enable = true; - - portal = { - enable = true; - }; - }; - - programs = { - firefox.enable = true; - bash.blesh.enable = true; - xfconf.enable = true; - thunar = { - enable = true; - plugins = with pkgs.xfce; [ - thunar-archive-plugin - thunar-volman - ]; - }; - - hyprland = { - enable = true; - withUWSM = true; - package = inputs.hyprland.packages."x86_64-linux".hyprland; - portalPackage = inputs.hyprland.packages."x86_64-linux".xdg-desktop-portal-hyprland; - }; - - steam = { - enable = true; - remotePlay.openFirewall = true; - dedicatedServer.openFirewall = true; - localNetworkGameTransfers.openFirewall = true; - }; - - nix-ld = { - enable = true; - #libraries = with pkgs; [ - # Add libraries here - #]; - }; - }; - - boot = { - loader = { - systemd-boot.enable = true; - efi.canTouchEfiVariables = true; - }; - - kernelPackages = pkgs.linuxPackages_latest; - #kernelPackages = pkgs.linuxPackages_zen; - }; + services.avahi.enable = true; networking = { hostName = "max-main"; @@ -88,81 +28,4 @@ allowedTCPPorts = [8000]; }; }; - - environment.sessionVariables = { - XDG_CURRENT_DESKTOP = "Hyprland"; - TERMINAL = "foot"; - }; - - time.timeZone = "Europe/Prague"; - i18n = { - defaultLocale = "en_US.UTF-8"; - extraLocaleSettings = { - LC_ADDRESS = "cs_CZ.UTF-8"; - LC_IDENTIFICATION = "cs_CZ.UTF-8"; - LC_MEASUREMENT = "cs_CZ.UTF-8"; - LC_MONETARY = "cs_CZ.UTF-8"; - LC_NAME = "cs_CZ.UTF-8"; - LC_NUMERIC = "cs_CZ.UTF-8"; - LC_PAPER = "cs_CZ.UTF-8"; - LC_TELEPHONE = "cs_CZ.UTF-8"; - LC_TIME = "cs_CZ.UTF-8"; - }; - }; - - services = { - xserver = { - enable = true; - videoDrivers = ["amdgpu"]; - xkb = { - layout = "cz"; - variant = ""; - options = "caps:escape"; - }; - }; - - tumbler.enable = true; - printing.enable = true; - avahi.enable = true; - - displayManager.sddm = { - enable = true; - theme = "${import ./sddm-theme.nix {inherit pkgs;}}"; - autoNumlock = true; - }; - - devmon.enable = true; - gvfs.enable = true; - - pipewire = { - enable = true; - - alsa = { - enable = true; - support32Bit = true; - }; - - pulse.enable = true; - jack.enable = true; - }; - }; - - console.keyMap = "cz-lat2"; - security.rtkit.enable = true; - - users.users.maxag = { - isNormalUser = true; - description = "Max Ag"; - extraGroups = ["networkmanager" "wheel" "video" "input"]; - - shell = pkgs.nushell; - }; - - system = { - stateVersion = "25.11"; - activationScripts.cleanBackups = '' - echo "Removing .backup_nix files..." - find /home/maxag -type f -name "*.backup_nix" -delete - ''; - }; } diff --git a/configuration/modules/audio.nix b/configuration/modules/audio.nix new file mode 100644 index 0000000..bfb244a --- /dev/null +++ b/configuration/modules/audio.nix @@ -0,0 +1,13 @@ +{ + services.pipewire = { + enable = true; + alsa = { + enable = true; + support32Bit = true; + }; + pulse.enable = true; + jack.enable = true; + }; + + security.rtkit.enable = true; +} diff --git a/configuration/modules/boot.nix b/configuration/modules/boot.nix new file mode 100644 index 0000000..98d367b --- /dev/null +++ b/configuration/modules/boot.nix @@ -0,0 +1,11 @@ +{pkgs, ...}: { + boot = { + loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = true; + }; + + kernelPackages = pkgs.linuxPackages_latest; + #kernelPackages = pkgs.linuxPackages_zen; + }; +} diff --git a/configuration/modules/desktop.nix b/configuration/modules/desktop.nix new file mode 100644 index 0000000..d755785 --- /dev/null +++ b/configuration/modules/desktop.nix @@ -0,0 +1,52 @@ +{ + pkgs, + inputs, + ... +}: { + environment.systemPackages = with pkgs; [ + wl-clipboard + libsForQt5.qt5.qtquickcontrols2 + libsForQt5.qt5.qtgraphicaleffects + ]; + + hardware.graphics = { + enable = true; + enable32Bit = true; + }; + + xdg = { + mime.enable = true; + menus.enable = true; + portal.enable = true; + }; + + programs.hyprland = { + enable = true; + withUWSM = true; + package = inputs.hyprland.packages."x86_64-linux".hyprland; + portalPackage = inputs.hyprland.packages."x86_64-linux".xdg-desktop-portal-hyprland; + }; + + services = { + xserver = { + enable = true; + videoDrivers = ["amdgpu"]; + xkb = { + layout = "cz"; + variant = ""; + options = "caps:escape"; + }; + }; + displayManager.sddm = { + enable = true; + theme = "${import ./sddm-theme.nix {inherit pkgs;}}"; + autoNumlock = true; + }; + }; + + environment.sessionVariables = { + XDG_CURRENT_DESKTOP = "Hyprland"; + TERMINAL = "foot"; + EDITOR = "nvim"; + }; +} diff --git a/configuration/modules/file-management.nix b/configuration/modules/file-management.nix new file mode 100644 index 0000000..d8ac2df --- /dev/null +++ b/configuration/modules/file-management.nix @@ -0,0 +1,22 @@ +{pkgs, ...}: { + environment.systemPackages = with pkgs; [ + gvfs + ]; + + programs = { + xfconf.enable = true; + thunar = { + enable = true; + plugins = with pkgs.xfce; [ + thunar-archive-plugin + thunar-volman + ]; + }; + }; + + services = { + devmon.enable = true; + gvfs.enable = true; + tumbler.enable = true; + }; +} diff --git a/configuration/modules/locale.nix b/configuration/modules/locale.nix new file mode 100644 index 0000000..c1e9d41 --- /dev/null +++ b/configuration/modules/locale.nix @@ -0,0 +1,19 @@ +{ + console.keyMap = "cz-lat2"; + time.timeZone = "Europe/Prague"; + + i18n = { + defaultLocale = "en_US.UTF-8"; + extraLocaleSettings = { + LC_ADDRESS = "cs_CZ.UTF-8"; + LC_IDENTIFICATION = "cs_CZ.UTF-8"; + LC_MEASUREMENT = "cs_CZ.UTF-8"; + LC_MONETARY = "cs_CZ.UTF-8"; + LC_NAME = "cs_CZ.UTF-8"; + LC_NUMERIC = "cs_CZ.UTF-8"; + LC_PAPER = "cs_CZ.UTF-8"; + LC_TELEPHONE = "cs_CZ.UTF-8"; + LC_TIME = "cs_CZ.UTF-8"; + }; + }; +} diff --git a/configuration/modules/main-user.nix b/configuration/modules/main-user.nix new file mode 100644 index 0000000..ddedbc6 --- /dev/null +++ b/configuration/modules/main-user.nix @@ -0,0 +1,9 @@ +{pkgs, ...}: { + users.users.maxag = { + isNormalUser = true; + description = "Max Ag"; + extraGroups = ["networkmanager" "wheel" "video" "input"]; + + shell = pkgs.nushell; + }; +} diff --git a/configuration/modules/printing.nix b/configuration/modules/printing.nix new file mode 100644 index 0000000..dc591ea --- /dev/null +++ b/configuration/modules/printing.nix @@ -0,0 +1,3 @@ +{ + services.printing.enable = true; +} diff --git a/configuration/modules/programs.nix b/configuration/modules/programs.nix new file mode 100644 index 0000000..d295907 --- /dev/null +++ b/configuration/modules/programs.nix @@ -0,0 +1,12 @@ +{ + programs = { + firefox.enable = true; + bash.blesh.enable = true; # Enhanced bash + nix-ld = { + enable = true; + #libraries = with pkgs; [ + # Add libraries here + #]; + }; + }; +} diff --git a/configuration/modules/steam.nix b/configuration/modules/steam.nix new file mode 100644 index 0000000..baa3811 --- /dev/null +++ b/configuration/modules/steam.nix @@ -0,0 +1,8 @@ +{ + programs.steam = { + enable = true; + remotePlay.openFirewall = true; + dedicatedServer.openFirewall = true; + localNetworkGameTransfers.openFirewall = true; + }; +} diff --git a/configuration/modules/system.nix b/configuration/modules/system.nix new file mode 100644 index 0000000..5f28fbb --- /dev/null +++ b/configuration/modules/system.nix @@ -0,0 +1,10 @@ +{name, ...}: { + networking.hostName = "max-${name}"; + system = { + stateVersion = "25.11"; + activationScripts.cleanBackups = '' + echo "Removing .backup_nix files..." + find /home/maxag -type f -name "*.backup_nix" -delete + ''; + }; +} diff --git a/flake.nix b/flake.nix index 6cd5865..6b4a755 100644 --- a/flake.nix +++ b/flake.nix @@ -3,93 +3,54 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - nvf = { url = "github:notashelf/nvf"; inputs.nixpkgs.follows = "nixpkgs"; }; - home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; - stylix = { url = "github:danth/stylix"; inputs.nixpkgs.follows = "nixpkgs"; }; - hyprland = { url = "github:hyprwm/Hyprland"; inputs.nixpkgs.follows = "nixpkgs"; }; }; - outputs = {nixpkgs, ...} @ inputs: { + outputs = {nixpkgs, ...} @ inputs: let + mkSystem = name: + nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { + inherit inputs name; + }; + modules = [ + ./configuration/${name}/configuration.nix + ./configuration/${name}/hardware-configuration.nix + inputs.home-manager.nixosModules.default + inputs.stylix.nixosModules.stylix + { + home-manager = { + useUserPackages = true; + useGlobalPkgs = true; + extraSpecialArgs = {inherit inputs name;}; + backupFileExtension = "backup_nix"; + users.maxag = ./home/${name}/home.nix; + sharedModules = [ + inputs.stylix.homeModules.stylix + ]; + }; + } + ]; + }; + in { nixosConfigurations = { - max-laptop = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = { - inherit inputs; - }; - - modules = [ - ./configuration/laptop/configuration.nix - ./configuration/laptop/hardware-configuration.nix - - inputs.home-manager.nixosModules.default - { - home-manager = { - useUserPackages = true; - useGlobalPkgs = true; - - extraSpecialArgs = {inherit inputs;}; - backupFileExtension = "backup_nix"; - - users.maxag = ./home/laptop/home.nix; - }; - } - - inputs.stylix.nixosModules.stylix - { - home-manager.sharedModules = [ - inputs.stylix.homeModules.stylix - ]; - } - ]; - }; - - max-main = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = { - inherit inputs; - }; - - modules = [ - ./configuration/main/configuration.nix - ./configuration/main/hardware-configuration.nix - - inputs.home-manager.nixosModules.default - { - home-manager = { - useUserPackages = true; - useGlobalPkgs = true; - - extraSpecialArgs = {inherit inputs;}; - backupFileExtension = "backup_nix"; - - users.maxag = ./home/main/home.nix; - }; - } - - inputs.stylix.nixosModules.stylix - { - home-manager.sharedModules = [ - inputs.stylix.homeModules.stylix - ]; - } - ]; - }; + max-laptop = mkSystem "laptop"; + max-main = mkSystem "main"; }; }; } diff --git a/home/laptop/home.nix b/home/laptop/home.nix index a4c96de..8a0795a 100644 --- a/home/laptop/home.nix +++ b/home/laptop/home.nix @@ -1,4 +1,4 @@ -{ +{pkgs, ...}: { home = { username = "maxag"; homeDirectory = "/home/maxag"; @@ -7,6 +7,10 @@ programs.home-manager.enable = true; + home.packages = with pkgs; [ + brightnessctl + ]; + imports = [ ./hyprland.nix ../modules/nvf.nix diff --git a/home/modules/shells.nix b/home/modules/shells.nix index c2c4060..d52f3eb 100644 --- a/home/modules/shells.nix +++ b/home/modules/shells.nix @@ -1,4 +1,8 @@ -{pkgs, ...}: { +{ + pkgs, + name, + ... +}: { home.packages = with pkgs; [ bat ]; @@ -14,8 +18,6 @@ enable = true; extraConfig = '' - $env.config.buffer_editor = "nvim" - if "ZELLIJ" in $env == false { zellij exit @@ -77,8 +79,8 @@ zel = "zellij"; rebuild = "sudo nixos-rebuild switch --flake /home/maxag/.nix-config"; system = "nvim /home/maxag/.nix-config/flake.nix"; - home = "nvim /home/maxag/.nix-config/home/main/home.nix"; - config = "nvim /home/maxag/.nix-config/configuration/main/configuration.nix"; + home = "nvim /home/maxag/.nix-config/home/${name}/home.nix"; + config = "nvim /home/maxag/.nix-config/configuration/${name}/configuration.nix"; cat = "bat -p -P"; nvim = "edit"; nix-shell = "nix-shell --run nu";