From 87d132cb4feb1214b95e516831e44164394a616e Mon Sep 17 00:00:00 2001 From: Kenryu Shibata Date: Sun, 22 Dec 2024 16:56:40 +0900 Subject: [PATCH] started modifing configuration structure --- flake.nix | 31 +++++++----- hosts/default.nix | 23 +++++++++ hosts/syushiki/default.nix | 49 +++++++++++++++++++ hosts/syushiki/home.nix | 48 ++++++++++++++++++ .../{hardware/audio.nix => audio/default.nix} | 0 .../bluetooth.nix => bluetooth/default.nix} | 0 system/default.nix | 18 +++++++ system/env.nix | 2 +- system/hardware/time.nix | 4 -- .../default.nix} | 0 .../kernel.nix => kernel/default.nix} | 0 system/locale/default.nix | 14 ++++++ system/network/default.nix | 9 ++++ system/nix/default.nix | 33 +++++++++++++ .../nvidia.nix => nvidia/default.nix} | 0 .../opengl.nix => opengl/default.nix} | 0 .../services/{cups.nix => cups/default.nix} | 0 system/services/default.nix | 12 +++++ .../{docker.nix => docker/default.nix} | 0 .../{flatpak.nix => flatpak/default.nix} | 0 .../{libvirtd.nix => libvirtd/default.nix} | 0 system/services/network-manager.nix | 5 -- .../{podman.nix => podman/default.nix} | 0 .../{polkit.nix => polkit/default.nix} | 0 system/services/{ssh.nix => ssh/default.nix} | 0 .../services/{steam.nix => steam/default.nix} | 0 .../{tailscale.nix => tailscale/default.nix} | 0 system/time/default.nix | 6 +++ system/users/default.nix | 21 ++++++++ system/wm/{dbus.nix => dbus/default.nix} | 0 system/wm/default.nix | 11 +++++ system/wm/{fonts.nix => fonts/default.nix} | 0 .../default.nix} | 0 system/wm/{plasma.nix => plasma/default.nix} | 2 +- system/wm/{sddm.nix => sddm/default.nix} | 12 ++--- system/wm/{sway.nix => sway/default.nix} | 4 +- system/wm/{xmonad.nix => xmonad/default.nix} | 0 37 files changed, 272 insertions(+), 32 deletions(-) create mode 100644 hosts/default.nix create mode 100644 hosts/syushiki/default.nix create mode 100644 hosts/syushiki/home.nix rename system/{hardware/audio.nix => audio/default.nix} (100%) rename system/{hardware/bluetooth.nix => bluetooth/default.nix} (100%) create mode 100644 system/default.nix delete mode 100644 system/hardware/time.nix rename system/{hardware/inputMethods.nix => inputMethods/default.nix} (100%) rename system/{hardware/kernel.nix => kernel/default.nix} (100%) create mode 100644 system/locale/default.nix create mode 100644 system/network/default.nix create mode 100644 system/nix/default.nix rename system/{hardware/nvidia.nix => nvidia/default.nix} (100%) rename system/{hardware/opengl.nix => opengl/default.nix} (100%) rename system/services/{cups.nix => cups/default.nix} (100%) create mode 100644 system/services/default.nix rename system/services/{docker.nix => docker/default.nix} (100%) rename system/services/{flatpak.nix => flatpak/default.nix} (100%) rename system/services/{libvirtd.nix => libvirtd/default.nix} (100%) delete mode 100644 system/services/network-manager.nix rename system/services/{podman.nix => podman/default.nix} (100%) rename system/services/{polkit.nix => polkit/default.nix} (100%) rename system/services/{ssh.nix => ssh/default.nix} (100%) rename system/services/{steam.nix => steam/default.nix} (100%) rename system/services/{tailscale.nix => tailscale/default.nix} (100%) create mode 100644 system/time/default.nix create mode 100644 system/users/default.nix rename system/wm/{dbus.nix => dbus/default.nix} (100%) create mode 100644 system/wm/default.nix rename system/wm/{fonts.nix => fonts/default.nix} (100%) rename system/wm/{gnome-keyring.nix => gnome-keyring/default.nix} (100%) rename system/wm/{plasma.nix => plasma/default.nix} (93%) rename system/wm/{sddm.nix => sddm/default.nix} (80%) rename system/wm/{sway.nix => sway/default.nix} (76%) rename system/wm/{xmonad.nix => xmonad/default.nix} (100%) diff --git a/flake.nix b/flake.nix index b697192..29c0616 100644 --- a/flake.nix +++ b/flake.nix @@ -8,12 +8,12 @@ nixos-hardware.url = "github:NixOS/nixos-hardware/master"; }; - outputs = inputs@{ nixpkgs, home-manager, ... }: + outputs = inputs@{ self, nixpkgs, home-manager, ... }: let systemSettings = { system = "x86_64-linux"; hostname = "kenryu-nixos"; - machine = "workstation"; + host = "syushiki"; timezone = "Asia/Tokyo"; locale = "ja_JP.UTF-8"; bootConf = { @@ -35,32 +35,37 @@ pkgs = import inputs.nixpkgs { system = systemSettings.system; - config = { - allowUnfree = true; - allowUnfreePredicate = (_: true ); - }; }; lib = inputs.nixpkgs.lib; - home-manager = inputs.home-manager; in { - nixosConfigurations.system = lib.nixosSystem { + #nixosModules = { + # home-mngr = home-manager.nixosModules.home-manager { + # home-manager.useGlobalPkgs = true; + # home-manager.useUserPackages = true; + # home-manager.users.${userSettings.username} = import (./. + "/hosts/${systemSettings.host}/home.nix"); + # home-manager.extraSpecialArgs = { + # inherit userSettings; + # }; + # }; + #}; + + #nixosConfigurations = import ./hosts inputs { inherit systemSettings; inherit userSettings; }; + nixosConfigurations.syushiki = lib.nixosSystem { system = systemSettings.system; modules = [ - (./. + "/machines" + ("/" + systemSettings.machine) + "/configuration.nix") + ./hosts/syushiki home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; - home-manager.users.${userSettings.username} = import (./. + "/machines" + ("/" + systemSettings.machine) + "/home.nix"); + home-manager.users.${userSettings.username} = import (./. + "/hosts/${systemSettings.host}/home.nix"); home-manager.extraSpecialArgs = { inherit userSettings; }; } ]; specialArgs = { - inherit systemSettings; - inherit userSettings; - inherit inputs; + inherit inputs systemSettings userSettings; }; }; }; diff --git a/hosts/default.nix b/hosts/default.nix new file mode 100644 index 0000000..2f056eb --- /dev/null +++ b/hosts/default.nix @@ -0,0 +1,23 @@ +{ self, nixpkgs, ... }: { systemSettings, userSettings, ... }: +let + inherit (self) inputs; + inherit systemSettings userSettings; + mkHost = name: + nixpkgs.lib.nixosSystem { + modules = [ + ./${name} + { + nixpkgs.hostPlatform = systemSettings.system; + } + ] ++ builtins.attrValues self.nixosModules; + + specialArgs = { + inherit inputs; + inherit systemSettings; + inherit userSettings; + }; + }; +in +{ + syushiki = mkHost "syushiki"; +} diff --git a/hosts/syushiki/default.nix b/hosts/syushiki/default.nix new file mode 100644 index 0000000..b5abadb --- /dev/null +++ b/hosts/syushiki/default.nix @@ -0,0 +1,49 @@ +{ config, lib, pkgs, modulesPath, ... }: { + imports = [ + ../../system + ../../system/nvidia + (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/f4c95da6-3c6b-4414-a62a-c8c26c4a1c73"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/C83C-841F"; + fsType = "vfat"; + options = [ "fmask=0077" "dmask=0077" ]; + }; + + fileSystems."/run/media/kenryus/hdd" = { + device = "/dev/disk/by-uuid/0d146628-12f4-4bb6-abde-bbf798a57c25"; + fsType = "ext4"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/d933c349-8e70-41e1-8d13-605656dba18b"; } + ]; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + programs.appimage = { + enable = true; + binfmt = true; + }; + + # Open ports in the firewall. + networking.firewall.allowedTCPPorts = [ 3000 3001 22 ]; + + system.stateVersion = "24.05"; # Did you read the changelog? +} diff --git a/hosts/syushiki/home.nix b/hosts/syushiki/home.nix new file mode 100644 index 0000000..3380278 --- /dev/null +++ b/hosts/syushiki/home.nix @@ -0,0 +1,48 @@ +{ pkgs, userSettings, ... }: +{ + imports = [ + ../../user/apps/browsers/firefox.nix + ../../user/apps/browsers/chromium.nix + ../../user/apps/thunderbird.nix + ../../user/dev/tools/git.nix + ../../user/dev/tools/gitui.nix + ../../user/dev/tools/firefox-devedition.nix + ../../user/dev/tools/dbeaver-bin.nix + ../../user/dev/tools/tldr.nix + ../../user/dev/tools/gh.nix + ../../user/dev/editor/vscodium.nix + ../../user/dev/editor/zed-editor.nix + ../../user/dev/lang/cc.nix + ../../user/dev/lang/python.nix + ../../user/dev/lang/rust.nix + ../../user/dev/lang/ecmascript.nix + ../../user/dev/ide/qtcreator.nix + ../../user/apps/utils/alacritty.nix + ../../user/apps/utils/keepassxc.nix + #../../user/apps/utils/cava.nix + ../../user/apps/utils/owncloud-client.nix + ../../user/apps/utils/fzf.nix + ../../user/apps/utils/zoxide.nix + ../../user/apps/media/vlc.nix + ../../user/apps/media/mpv.nix + ../../user/apps/media/yt-dlp.nix + ../../user/apps/media/kdenlive.nix + ../../user/apps/media/obs-studio.nix + ../../user/apps/graphics/gimp.nix + ../../user/apps/graphics/inkscape.nix + ../../user/apps/games/mangohud.nix + ../../user/apps/office/texlive.nix + #../../user/apps/office/libreoffice-fresh.nix + ../../user/shell/bash.nix + ../../user/wm/xmonad/xmonad.nix + ]; + + home.username = userSettings.username; + home.homeDirectory = "/home/" + userSettings.username; + + programs.home-manager.enable = true; + + home.stateVersion = "24.05"; + + home.packages = with pkgs; []; +} diff --git a/system/hardware/audio.nix b/system/audio/default.nix similarity index 100% rename from system/hardware/audio.nix rename to system/audio/default.nix diff --git a/system/hardware/bluetooth.nix b/system/bluetooth/default.nix similarity index 100% rename from system/hardware/bluetooth.nix rename to system/bluetooth/default.nix diff --git a/system/default.nix b/system/default.nix new file mode 100644 index 0000000..0a52f4f --- /dev/null +++ b/system/default.nix @@ -0,0 +1,18 @@ +{ ... }: { + imports = [ + ./audio + ./bluetooth + ./inputMethods + ./kernel + ./locale + ./network + ./nix + ./opengl + ./time + ./users + ./services + ./wm + ./env.nix + ./utils.nix + ]; +} diff --git a/system/env.nix b/system/env.nix index 72c9fb0..08596dd 100644 --- a/system/env.nix +++ b/system/env.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ ... }: { environment.variables = { EDITOR = "vim"; diff --git a/system/hardware/time.nix b/system/hardware/time.nix deleted file mode 100644 index 44b1f23..0000000 --- a/system/hardware/time.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ ... }: -{ - services.timesyncd.enable = true; -} diff --git a/system/hardware/inputMethods.nix b/system/inputMethods/default.nix similarity index 100% rename from system/hardware/inputMethods.nix rename to system/inputMethods/default.nix diff --git a/system/hardware/kernel.nix b/system/kernel/default.nix similarity index 100% rename from system/hardware/kernel.nix rename to system/kernel/default.nix diff --git a/system/locale/default.nix b/system/locale/default.nix new file mode 100644 index 0000000..1b7330a --- /dev/null +++ b/system/locale/default.nix @@ -0,0 +1,14 @@ +{ systemSettings, ... }: { + i18n.defaultLocale = systemSettings.locale; + i18n.extraLocaleSettings = { + LC_ADDRESS = systemSettings.locale; + LC_IDENTIFICATION = systemSettings.locale; + LC_MEASUREMENT = systemSettings.locale; + LC_MONETARY = systemSettings.locale; + LC_NAME = systemSettings.locale; + LC_NUMERIC = systemSettings.locale; + LC_PAPER = systemSettings.locale; + LC_TELEPHONE = systemSettings.locale; + LC_TIME = systemSettings.locale; + }; +} diff --git a/system/network/default.nix b/system/network/default.nix new file mode 100644 index 0000000..8e2965f --- /dev/null +++ b/system/network/default.nix @@ -0,0 +1,9 @@ +{ systemSettings, ... }: +{ + networking = { + hostName = systemSettings.hostname; + networkmanager.enable = true; + firewall.enable = true; + }; + systemd.network.wait-online.enable = false; +} diff --git a/system/nix/default.nix b/system/nix/default.nix new file mode 100644 index 0000000..0e58393 --- /dev/null +++ b/system/nix/default.nix @@ -0,0 +1,33 @@ +{ ... }: { + nix = { + gc.automatic = false; + + settings = { + auto-optimise-store = true; + builders-use-substitutes = true; + allowed-users = ["@wheel"]; + trusted-users = ["@wheel"]; + commit-lockfile-summary = "Update flake.lock"; + accept-flake-config = true; + keep-derivations = true; + keep-outputs = true; + warn-dirty = false; + sandbox = true; + max-jobs = "auto"; + log-lines = 30; + experimental-features = [ "nix-command" "flakes" ]; + substituters = [ + "https://cache.nixos.org" + ]; + trusted-public-keys = [ + "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" + ]; + }; + }; + + nixpkgs = { + config = { + allowUnfree = true; + }; + }; +} diff --git a/system/hardware/nvidia.nix b/system/nvidia/default.nix similarity index 100% rename from system/hardware/nvidia.nix rename to system/nvidia/default.nix diff --git a/system/hardware/opengl.nix b/system/opengl/default.nix similarity index 100% rename from system/hardware/opengl.nix rename to system/opengl/default.nix diff --git a/system/services/cups.nix b/system/services/cups/default.nix similarity index 100% rename from system/services/cups.nix rename to system/services/cups/default.nix diff --git a/system/services/default.nix b/system/services/default.nix new file mode 100644 index 0000000..c7d3c96 --- /dev/null +++ b/system/services/default.nix @@ -0,0 +1,12 @@ +{ ... }: { + imports = [ + ./cups + ./flatpak + ./libvirtd + ./podman + ./polkit + ./ssh + ./steam + ./tailscale + ]; +} diff --git a/system/services/docker.nix b/system/services/docker/default.nix similarity index 100% rename from system/services/docker.nix rename to system/services/docker/default.nix diff --git a/system/services/flatpak.nix b/system/services/flatpak/default.nix similarity index 100% rename from system/services/flatpak.nix rename to system/services/flatpak/default.nix diff --git a/system/services/libvirtd.nix b/system/services/libvirtd/default.nix similarity index 100% rename from system/services/libvirtd.nix rename to system/services/libvirtd/default.nix diff --git a/system/services/network-manager.nix b/system/services/network-manager.nix deleted file mode 100644 index 47fea2e..0000000 --- a/system/services/network-manager.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ ... }: -{ - networking.networkmanager.enable = true; - systemd.network.wait-online.enable = false; -} diff --git a/system/services/podman.nix b/system/services/podman/default.nix similarity index 100% rename from system/services/podman.nix rename to system/services/podman/default.nix diff --git a/system/services/polkit.nix b/system/services/polkit/default.nix similarity index 100% rename from system/services/polkit.nix rename to system/services/polkit/default.nix diff --git a/system/services/ssh.nix b/system/services/ssh/default.nix similarity index 100% rename from system/services/ssh.nix rename to system/services/ssh/default.nix diff --git a/system/services/steam.nix b/system/services/steam/default.nix similarity index 100% rename from system/services/steam.nix rename to system/services/steam/default.nix diff --git a/system/services/tailscale.nix b/system/services/tailscale/default.nix similarity index 100% rename from system/services/tailscale.nix rename to system/services/tailscale/default.nix diff --git a/system/time/default.nix b/system/time/default.nix new file mode 100644 index 0000000..3e9ccbb --- /dev/null +++ b/system/time/default.nix @@ -0,0 +1,6 @@ +{ systemSettings, ... }: +{ + time.timeZone = systemSettings.timezone; + + services.timesyncd.enable = true; +} diff --git a/system/users/default.nix b/system/users/default.nix new file mode 100644 index 0000000..be6d731 --- /dev/null +++ b/system/users/default.nix @@ -0,0 +1,21 @@ +{ pkgs, config, userSettings, ... }: { + users.users.${userSettings.username} = { + isNormalUser = true; + description = userSettings.name; + extraGroups = [ + "networkmanager" + "wheel" + "docker" + "podman" + "input" + "flatpak" + "dialout" + "video" + "audio" + "libvirtd" + ]; + uid = 1000; + }; + + users.defaultUserShell = pkgs.bash; +} diff --git a/system/wm/dbus.nix b/system/wm/dbus/default.nix similarity index 100% rename from system/wm/dbus.nix rename to system/wm/dbus/default.nix diff --git a/system/wm/default.nix b/system/wm/default.nix new file mode 100644 index 0000000..95414fa --- /dev/null +++ b/system/wm/default.nix @@ -0,0 +1,11 @@ +{ ... }: { + imports = [ + ./dbus + ./fonts + ./gnome-keyring + ./plasma + ./sddm + ./sway + ./xmonad + ]; +} diff --git a/system/wm/fonts.nix b/system/wm/fonts/default.nix similarity index 100% rename from system/wm/fonts.nix rename to system/wm/fonts/default.nix diff --git a/system/wm/gnome-keyring.nix b/system/wm/gnome-keyring/default.nix similarity index 100% rename from system/wm/gnome-keyring.nix rename to system/wm/gnome-keyring/default.nix diff --git a/system/wm/plasma.nix b/system/wm/plasma/default.nix similarity index 93% rename from system/wm/plasma.nix rename to system/wm/plasma/default.nix index fa5577d..741e76d 100644 --- a/system/wm/plasma.nix +++ b/system/wm/plasma/default.nix @@ -1,7 +1,7 @@ { config, lib, pkgs, ... }: { imports = [ - ./dbus.nix + ../dbus ]; services.desktopManager.plasma6.enable = true; diff --git a/system/wm/sddm.nix b/system/wm/sddm/default.nix similarity index 80% rename from system/wm/sddm.nix rename to system/wm/sddm/default.nix index 66b90ee..190fecc 100644 --- a/system/wm/sddm.nix +++ b/system/wm/sddm/default.nix @@ -1,12 +1,12 @@ { config, pkgs, lib, ... }: { imports = [ - ./fonts.nix - ./dbus.nix - ./gnome-keyring.nix - ./xmonad.nix - ./sway.nix - ./plasma.nix + ../fonts + ../dbus + ../gnome-keyring + ../xmonad + ../sway + ../plasma ]; environment.systemPackages = with pkgs; [ diff --git a/system/wm/sway.nix b/system/wm/sway/default.nix similarity index 76% rename from system/wm/sway.nix rename to system/wm/sway/default.nix index 2ba9541..2c38215 100644 --- a/system/wm/sway.nix +++ b/system/wm/sway/default.nix @@ -1,8 +1,8 @@ { pkgs, lib, config, ... }: { imports = [ - ./gnome-keyring.nix - ./dbus.nix + ../gnome-keyring + ../dbus ]; programs.sway = { diff --git a/system/wm/xmonad.nix b/system/wm/xmonad/default.nix similarity index 100% rename from system/wm/xmonad.nix rename to system/wm/xmonad/default.nix