From bb8d9c67526aa850e08700b714703e71f6c39e88 Mon Sep 17 00:00:00 2001 From: lightly-toasted Date: Sat, 9 Aug 2025 12:15:43 +0900 Subject: [PATCH] refactor: modularize host configuration --- hosts/nixos/configuration.nix | 122 +++------------------------- hosts/nixos/modules/boot.nix | 6 ++ hosts/nixos/modules/environment.nix | 8 ++ hosts/nixos/modules/hardware.nix | 17 ++++ hosts/nixos/modules/network.nix | 7 ++ hosts/nixos/modules/packages.nix | 9 ++ hosts/nixos/modules/programs.nix | 17 ++++ hosts/nixos/modules/services.nix | 43 ++++++++++ hosts/nixos/modules/time.nix | 23 ++++++ hosts/nixos/modules/users.nix | 11 +++ 10 files changed, 152 insertions(+), 111 deletions(-) create mode 100644 hosts/nixos/modules/boot.nix create mode 100644 hosts/nixos/modules/environment.nix create mode 100644 hosts/nixos/modules/hardware.nix create mode 100644 hosts/nixos/modules/network.nix create mode 100644 hosts/nixos/modules/packages.nix create mode 100644 hosts/nixos/modules/programs.nix create mode 100644 hosts/nixos/modules/services.nix create mode 100644 hosts/nixos/modules/time.nix create mode 100644 hosts/nixos/modules/users.nix diff --git a/hosts/nixos/configuration.nix b/hosts/nixos/configuration.nix index b0f5f9e..a2227ea 100644 --- a/hosts/nixos/configuration.nix +++ b/hosts/nixos/configuration.nix @@ -5,118 +5,18 @@ [ inputs.nix-flatpak.nixosModules.nix-flatpak ./hardware-configuration.nix + + ./modules/boot.nix + ./modules/network.nix + ./modules/time.nix + ./modules/users.nix + ./modules/packages.nix + ./modules/services.nix + ./modules/hardware.nix + ./modules/environment.nix + ./modules/programs.nix ]; - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - - networking.hostName = "nixos"; - networking.networkmanager.enable = true; - networking.firewall.enable = false; - - time.timeZone = "Asia/Seoul"; - i18n = { - defaultLocale = "en_US.UTF-8"; - extraLocaleSettings = { - LC_ADDRESS = "ko_KR.UTF-8"; - LC_IDENTIFICATION = "ko_KR.UTF-8"; - LC_MEASUREMENT = "ko_KR.UTF-8"; - LC_MONETARY = "ko_KR.UTF-8"; - LC_NAME = "ko_KR.UTF-8"; - LC_NUMERIC = "ko_KR.UTF-8"; - LC_PAPER = "ko_KR.UTF-8"; - LC_TELEPHONE = "ko_KR.UTF-8"; - LC_TIME = "ko_KR.UTF-8"; - }; - inputMethod = { - enable = true; - type = "kime"; - }; - }; - services.xserver = { - xkb.layout = "us"; - videoDrivers = [ "nvidia" ]; - }; - - users.users.toast = { - isNormalUser = true; - description = "toast"; - extraGroups = [ "networkmanager" "wheel" ]; - packages = with pkgs; []; - shell = pkgs.zsh; - }; - - environment.systemPackages = with pkgs; [ - vim - wget - ]; - nixpkgs.config.allowUnfree = true; - - programs.zsh.enable = true; - programs.hyprland = { - enable = true; - withUWSM = true; - xwayland.enable = true; - }; - programs.thunar = { - enable = true; - plugins = with pkgs.xfce; [ - thunar-volman - ]; - }; - programs.xfconf.enable = true; - services.gvfs.enable = true; # Mount, trash, and other functionalities - services.tumbler.enable = true; # Thumbnail support for images - - environment.sessionVariables = { - # WLR_NO_HARDWARE_CURSORS = "1"; - NIXOS_OZONE_WL = "1"; - }; - - hardware = { - graphics.enable = true; - nvidia = { - modesetting.enable = true; - powerManagement.enable = false; - powerManagement.finegrained = false; - open = false; - nvidiaSettings = true; - package = config.boot.kernelPackages.nvidiaPackages.stable; - }; - }; - - services.greetd = { - enable = true; - settings = { - default_session = { - command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --remember --remember-session"; - user = "greeter"; - }; - }; - }; - services.zerotierone.enable = true; - services.flatpak = { - enable = true; - packages = [ - "org.prismlauncher.PrismLauncher" - "org.vinegarhq.Sober" - "org.vinegarhq.Vinegar" - ]; - overrides = { - "org.prismlauncher.PrismLauncher".Context = { - filesystems = [ - "home" - ]; - }; - "org.vinegarhq.Sober".Context = { - filesystems = [ - "xdg-run/app/com.discordapp.Discord:create" - "xdg-run/discord-ipc-0" - ]; - }; - }; - }; - system.stateVersion = "25.05"; nix.settings.experimental-features = [ "nix-command" "flakes" ]; -} +} \ No newline at end of file diff --git a/hosts/nixos/modules/boot.nix b/hosts/nixos/modules/boot.nix new file mode 100644 index 0000000..89395d2 --- /dev/null +++ b/hosts/nixos/modules/boot.nix @@ -0,0 +1,6 @@ +{ config, pkgs, ... }: + +{ + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; +} diff --git a/hosts/nixos/modules/environment.nix b/hosts/nixos/modules/environment.nix new file mode 100644 index 0000000..5258262 --- /dev/null +++ b/hosts/nixos/modules/environment.nix @@ -0,0 +1,8 @@ +{ config, pkgs, ... }: + +{ + environment.sessionVariables = { + # WLR_NO_HARDWARE_CURSORS = "1"; + NIXOS_OZONE_WL = "1"; + }; +} diff --git a/hosts/nixos/modules/hardware.nix b/hosts/nixos/modules/hardware.nix new file mode 100644 index 0000000..06d68f2 --- /dev/null +++ b/hosts/nixos/modules/hardware.nix @@ -0,0 +1,17 @@ +{ config, pkgs, ... }: + +{ + hardware = { + graphics.enable = true; + nvidia = { + modesetting.enable = true; + powerManagement = { + enable = false; + finegrained = false; + }; + open = false; + nvidiaSettings = true; + package = config.boot.kernelPackages.nvidiaPackages.stable; + }; + }; +} diff --git a/hosts/nixos/modules/network.nix b/hosts/nixos/modules/network.nix new file mode 100644 index 0000000..a5d3c65 --- /dev/null +++ b/hosts/nixos/modules/network.nix @@ -0,0 +1,7 @@ +{ config, pkgs, ... }: + +{ + networking.hostName = "nixos"; + networking.networkmanager.enable = true; + networking.firewall.enable = false; +} diff --git a/hosts/nixos/modules/packages.nix b/hosts/nixos/modules/packages.nix new file mode 100644 index 0000000..3b57a05 --- /dev/null +++ b/hosts/nixos/modules/packages.nix @@ -0,0 +1,9 @@ +{ config, pkgs, ... }: + +{ + environment.systemPackages = with pkgs; [ + vim + wget + ]; + nixpkgs.config.allowUnfree = true; +} diff --git a/hosts/nixos/modules/programs.nix b/hosts/nixos/modules/programs.nix new file mode 100644 index 0000000..574de9a --- /dev/null +++ b/hosts/nixos/modules/programs.nix @@ -0,0 +1,17 @@ +{ config, pkgs, ... }: + +{ + programs.zsh.enable = true; + programs.hyprland = { + enable = true; + withUWSM = true; + xwayland.enable = true; + }; + programs.thunar = { + enable = true; + plugins = with pkgs.xfce; [ + thunar-volman + ]; + }; + programs.xfconf.enable = true; +} diff --git a/hosts/nixos/modules/services.nix b/hosts/nixos/modules/services.nix new file mode 100644 index 0000000..fd62bcb --- /dev/null +++ b/hosts/nixos/modules/services.nix @@ -0,0 +1,43 @@ +{ config, pkgs, ... }: + +{ + services.xserver = { + xkb.layout = "us"; + videoDrivers = [ "nvidia" ]; + }; + + services.gvfs.enable = true; # Mount, trash, and other functionalities + services.tumbler.enable = true; # Thumbnail support for images + + services.greetd = { + enable = true; + settings = { + default_session = { + command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --remember --remember-session"; + user = "greeter"; + }; + }; + }; + services.zerotierone.enable = true; + services.flatpak = { + enable = true; + packages = [ + "org.prismlauncher.PrismLauncher" + "org.vinegarhq.Sober" + "org.vinegarhq.Vinegar" + ]; + overrides = { + "org.prismlauncher.PrismLauncher".Context = { + filesystems = [ + "home" + ]; + }; + "org.vinegarhq.Sober".Context = { + filesystems = [ + "xdg-run/app/com.discordapp.Discord:create" + "xdg-run/discord-ipc-0" + ]; + }; + }; + }; +} diff --git a/hosts/nixos/modules/time.nix b/hosts/nixos/modules/time.nix new file mode 100644 index 0000000..6e4eb28 --- /dev/null +++ b/hosts/nixos/modules/time.nix @@ -0,0 +1,23 @@ +{ config, pkgs, ... }: + +{ + time.timeZone = "Asia/Seoul"; + i18n = { + defaultLocale = "en_US.UTF-8"; + extraLocaleSettings = { + LC_ADDRESS = "ko_KR.UTF-8"; + LC_IDENTIFICATION = "ko_KR.UTF-8"; + LC_MEASUREMENT = "ko_KR.UTF-8"; + LC_MONETARY = "ko_KR.UTF-8"; + LC_NAME = "ko_KR.UTF-8"; + LC_NUMERIC = "ko_KR.UTF-8"; + LC_PAPER = "ko_KR.UTF-8"; + LC_TELEPHONE = "ko_KR.UTF-8"; + LC_TIME = "ko_KR.UTF-8"; + }; + inputMethod = { + enable = true; + type = "kime"; + }; + }; +} diff --git a/hosts/nixos/modules/users.nix b/hosts/nixos/modules/users.nix new file mode 100644 index 0000000..fce86d0 --- /dev/null +++ b/hosts/nixos/modules/users.nix @@ -0,0 +1,11 @@ +{ config, pkgs, ... }: + +{ + users.users.toast = { + isNormalUser = true; + description = "toast"; + extraGroups = [ "networkmanager" "wheel" ]; + packages = with pkgs; []; + shell = pkgs.zsh; + }; +}