From 2d93503bbcea2dc46869914152d82b89aaf8e0da Mon Sep 17 00:00:00 2001 From: ooks-io Date: Tue, 30 Apr 2024 20:20:35 +1200 Subject: [PATCH] refactor(treewide): cleanup --- system/hosts/ooksdesk/default.nix | 47 +++++++------ system/modules/default.nix | 16 +---- .../{profiles => modules}/gaming/default.nix | 9 ++- system/modules/host/admin/default.nix | 2 +- system/modules/host/default.nix | 1 + system/modules/host/function/default.nix | 6 -- .../modules/host/hardware/cpu/amd/default.nix | 13 ++-- system/modules/host/hardware/default.nix | 2 +- .../host/hardware/features/ssd/default.nix | 2 +- system/modules/host/name/default.nix | 2 +- system/modules/networking/tcp/default.nix | 2 +- system/modules/nix/nix/default.nix | 6 +- system/modules/nix/nixpkgs/default.nix | 2 +- system/modules/programs/bandwhich/default.nix | 9 ++- system/modules/programs/dconf/default.nix | 9 ++- system/modules/programs/default.nix | 13 ++-- system/modules/programs/gnomeServices.nix | 18 ----- .../kdeconnect/default.nix | 3 +- system/modules/programs/seahorse/default.nix | 9 ++- system/modules/programs/wireshark/default.nix | 9 ++- system/modules/security/default.nix | 2 +- system/modules/services/default.nix | 1 - system/modules/services/gvfs/default.nix | 2 +- system/modules/shell/zsh/default.nix | 2 +- system/modules/user/default.nix | 14 ---- system/modules/user/ooks.nix | 30 -------- .../default.nix | 0 system/profiles/base/default.nix | 69 ------------------- system/profiles/default.nix | 32 --------- system/profiles/mediaServer/default.nix | 17 ----- 30 files changed, 76 insertions(+), 273 deletions(-) rename system/{profiles => modules}/gaming/default.nix (88%) delete mode 100644 system/modules/programs/gnomeServices.nix rename system/modules/{services => programs}/kdeconnect/default.nix (84%) delete mode 100644 system/modules/user/default.nix delete mode 100644 system/modules/user/ooks.nix rename system/modules/{virtualisation => virtualization}/default.nix (100%) delete mode 100644 system/profiles/base/default.nix delete mode 100644 system/profiles/default.nix delete mode 100644 system/profiles/mediaServer/default.nix diff --git a/system/hosts/ooksdesk/default.nix b/system/hosts/ooksdesk/default.nix index 7b880f4..85200c2 100644 --- a/system/hosts/ooksdesk/default.nix +++ b/system/hosts/ooksdesk/default.nix @@ -1,33 +1,40 @@ -{ config, inputs, pkgs, ... }: +{ lib, config, inputs, pkgs, ... }: + +let + key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBn3ff3HaZHIyH4K13k8Mwqu/o7jIABJ8rANK+r2PfJk"; +in { imports = [ ./hardware-configuration.nix - ../../profiles - ]; + ../../modules + ]; - activeProfiles = ["base" "gaming"]; - - systemModules.user = { - ooks.enable = true; + systemModules.host = { + name = "ooksdesk"; + type = "desktop"; + function = [ "workstation" "gaming" ]; + admin = { + name = "ooks"; shell = "fish"; + sshKey = key; }; - - systemModules.hardware = { + hardware = { cpu.type = "amd"; + cpu.amd.pstate.enable = true; gpu.type = "amd"; + features = [ "ssd" ]; }; + }; - systemModules.networking.tailscale = { - enable = true; - client = true; - }; + systemModules.networking.tailscale = { + enable = true; + client = true; + }; - networking = { - hostName = "ooksdesk"; - # useDHCP = true; - }; - boot = { - kernelPackages = pkgs.linuxPackages_xanmod_latest; - }; + boot = { + kernelPackages = pkgs.linuxPackages_xanmod_latest; + }; + + system.stateVersion = lib.mkDefault "23.11"; } diff --git a/system/modules/default.nix b/system/modules/default.nix index 539d202..bf80828 100644 --- a/system/modules/default.nix +++ b/system/modules/default.nix @@ -2,36 +2,26 @@ { imports = [ - ./hardware + ./gaming + ./shell ./bootloader ./nix ./programs - ./user ./displayManager ./networking ./locale - ./virtualisation + ./virtualization ./security ./services ./audio - ./meta ./host ./video ]; options.systemModules = { - pipewire = { - enable = lib.mkEnableOption "Enable pipewire module"; - }; - networking = { - enable = lib.mkEnableOption "Enable networking module"; - }; virtualisation = { enable = lib.mkEnableOption "Enable virtualisation module"; }; - locale = { - enable = lib.mkEnableOption "Enable locale module"; - }; }; } diff --git a/system/profiles/gaming/default.nix b/system/modules/gaming/default.nix similarity index 88% rename from system/profiles/gaming/default.nix rename to system/modules/gaming/default.nix index a474d61..c5a0449 100644 --- a/system/profiles/gaming/default.nix +++ b/system/modules/gaming/default.nix @@ -1,7 +1,8 @@ -{ lib, config, pkgs, inputs, ... }: +{ lib, config, pkgs, ... }: let - cfg = config.systemProfile.gaming; + inherit (lib) mkIf; + inherit (builtins) elem; steamFix = pkgs.steam.override { extraPkgs = pkgs: with pkgs; [ xorg.libXcursor @@ -21,10 +22,11 @@ let gtk3-x11 ]; }; + host = config.systemModules.host; in { - config = lib.mkIf cfg.enable { + config = mkIf (elem "gamiing" host.function) { hardware.opengl.extraPackages = [ pkgs.gamescope ]; programs = { steam = { @@ -63,3 +65,4 @@ in }; }; } + diff --git a/system/modules/host/admin/default.nix b/system/modules/host/admin/default.nix index 61a6639..8d21730 100644 --- a/system/modules/host/admin/default.nix +++ b/system/modules/host/admin/default.nix @@ -36,7 +36,7 @@ in isNormalUser = true; shell = pkgs.${cfg.shell}; initialPassword = "password"; - openssh.authorizedKeys = "${cfg.sshKey}"; + openssh.authorizedKeys.keys = [ "${cfg.sshKey}" ]; extraGroups = [ "wheel" "video" diff --git a/system/modules/host/default.nix b/system/modules/host/default.nix index ed7c8c1..cf914b2 100644 --- a/system/modules/host/default.nix +++ b/system/modules/host/default.nix @@ -4,5 +4,6 @@ ./name ./type ./function + ./hardware ]; } diff --git a/system/modules/host/function/default.nix b/system/modules/host/function/default.nix index 8a06929..06dd37b 100644 --- a/system/modules/host/function/default.nix +++ b/system/modules/host/function/default.nix @@ -5,12 +5,6 @@ let in { - imports = [ - ./gaming - ./workstation - ./media-server - ]; - options.systemModules.host.function = mkOption { type = with types; listOf (enum ["gaming" "workstation" "media-server"]); default = []; diff --git a/system/modules/host/hardware/cpu/amd/default.nix b/system/modules/host/hardware/cpu/amd/default.nix index 2f860d1..4449b2d 100644 --- a/system/modules/host/hardware/cpu/amd/default.nix +++ b/system/modules/host/hardware/cpu/amd/default.nix @@ -2,19 +2,18 @@ let inherit (lib) mkMerge mkEnableOption mkIf versionAtLeast versionOlder; - hardware = config.systemModules.host.hardware.cpu; - cfg = hardware.amd; - kernelVersion = config.kernelPackages.kernel.version; + inherit (builtins) elem; + cpu = config.systemModules.host.hardware.cpu; + cfg = cpu.amd; + kernelVersion = config.boot.kernelPackages.kernel.version; kernelVersionAtLeast = versionAtLeast kernelVersion; kernelVersionOlder= versionOlder kernelVersion; in { - options.systemModules.host.hardware.cpu.amd = { - pstate.enable = mkEnableOption "Enable pstate amd module"; - }; + options.systemModules.host.hardware.cpu.amd.pstate.enable = mkEnableOption "Enable amd pstate module"; - config = mkIf (builtins.elem hardware.type ["amd"]) { + config = mkIf (elem cpu.type ["amd"]) { environment.systemPackages = [pkgs.amdctl]; hardware.cpu.amd.updateMicrocode = true; boot = mkMerge [ diff --git a/system/modules/host/hardware/default.nix b/system/modules/host/hardware/default.nix index 7b40e27..6c88323 100644 --- a/system/modules/host/hardware/default.nix +++ b/system/modules/host/hardware/default.nix @@ -3,6 +3,6 @@ ./cpu ./gpu ./features - ./ssd + ./common ]; } diff --git a/system/modules/host/hardware/features/ssd/default.nix b/system/modules/host/hardware/features/ssd/default.nix index f9cdaed..b0dd097 100644 --- a/system/modules/host/hardware/features/ssd/default.nix +++ b/system/modules/host/hardware/features/ssd/default.nix @@ -1,7 +1,7 @@ { lib, config, ... }: let - features = config.systemModules.host.hardware.ssd; + features = config.systemModules.host.hardware.features; inherit (lib) mkIf; inherit (builtins) elem; in diff --git a/system/modules/host/name/default.nix b/system/modules/host/name/default.nix index a497a98..895cfc2 100644 --- a/system/modules/host/name/default.nix +++ b/system/modules/host/name/default.nix @@ -15,7 +15,7 @@ in }; config = { - networking.hostname = cfg.name; + networking.hostName = cfg.name; environment.sessionVariables.HN = cfg.name; }; } diff --git a/system/modules/networking/tcp/default.nix b/system/modules/networking/tcp/default.nix index 129e67f..635cf4f 100644 --- a/system/modules/networking/tcp/default.nix +++ b/system/modules/networking/tcp/default.nix @@ -2,7 +2,7 @@ let inherit (lib) mkIf; - host = config.systemModules.type; + host = config.systemModules.host; in { diff --git a/system/modules/nix/nix/default.nix b/system/modules/nix/nix/default.nix index b55bd89..640acce 100644 --- a/system/modules/nix/nix/default.nix +++ b/system/modules/nix/nix/default.nix @@ -1,7 +1,7 @@ { config, lib, inputs, ... }: let - inherit (lib) mkIf; + inherit (lib) mkIf mapAttrs mkDefault; host = config.systemModules.host; in @@ -10,13 +10,13 @@ in nix = { settings = { trusted-users = [ "root" "@wheel" ]; - auto-optimise-store = lib.mkDefault true; + auto-optimise-store = mkDefault true; experimental-features = [ "nix-command" "flakes" "repl-flake" ]; warn-dirty = false; system-features = [ "kvm" "big-parallel" "nixos-test" ]; flake-registry = ""; }; - registry = lib.mapAttrs (_: value: { flake = value; }) inputs; + registry = mapAttrs (_: value: { flake = value; }) inputs; nixPath = [ "nixpkgs=${inputs.nixpkgs.outPath}" ]; }; }; diff --git a/system/modules/nix/nixpkgs/default.nix b/system/modules/nix/nixpkgs/default.nix index c97cb93..fc31ea5 100644 --- a/system/modules/nix/nixpkgs/default.nix +++ b/system/modules/nix/nixpkgs/default.nix @@ -6,7 +6,7 @@ let in { - config = mkIf host.type != "phone" { + config = mkIf (host.type != "phone") { nixpkgs = { overlays = builtins.attrValues outputs.overlays; config = { diff --git a/system/modules/programs/bandwhich/default.nix b/system/modules/programs/bandwhich/default.nix index 360a183..eb8e229 100644 --- a/system/modules/programs/bandwhich/default.nix +++ b/system/modules/programs/bandwhich/default.nix @@ -1,14 +1,13 @@ { lib, config, ... }: let - inherit (lib) mkIf mkEnableOption; - cfg = config.systemModules.programs.bandwhich; + inherit (lib) mkIf; + inherit (builtins) elem; + host = config.systemModules.host; in { - options.systemModules.programs.bandwhich.enable = mkEnableOption "Enable bandwhich system module"; - - config = mkIf cfg.enable { + config = mkIf (elem "workstation" host.function) { programs.bandwhich.enable = true; }; } diff --git a/system/modules/programs/dconf/default.nix b/system/modules/programs/dconf/default.nix index 483394c..c9cc39d 100644 --- a/system/modules/programs/dconf/default.nix +++ b/system/modules/programs/dconf/default.nix @@ -1,14 +1,13 @@ { lib, config, ... }: let - inherit (lib) mkIf mkEnableOption; - cfg = config.systemModules.programs.dconf; + inherit (lib) mkIf; + inherit (builtins) elem; + host = config.systemModules.host; in { - options.systemModules.programs.dconf.enable = mkEnableOption "Enable dconf system module"; - - config = mkIf cfg.enable { + config = mkIf (elem "workstation" host.function){ programs.dconf.enable = true; }; } diff --git a/system/modules/programs/default.nix b/system/modules/programs/default.nix index db3f9a7..d00b1de 100644 --- a/system/modules/programs/default.nix +++ b/system/modules/programs/default.nix @@ -1,14 +1,9 @@ -{ lib, ... }: - { imports = [ - ./gnomeServices.nix ./dconf + ./kdeconnect + ./seahorse + ./wireshark + ./bandwhich ]; - - options.systemModules.programs = { - gnomeServices = { - enable = lib.mkEnableOption "Enable gnome services module"; - }; - }; } diff --git a/system/modules/programs/gnomeServices.nix b/system/modules/programs/gnomeServices.nix deleted file mode 100644 index aded2f7..0000000 --- a/system/modules/programs/gnomeServices.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ config, lib, pkgs, ... }: - -let - cfg = config.systemModules.programs.gnomeServices; -in - -{ - config = lib.mkIf cfg.enable { - services = { - dbus.packages = with pkgs; [ - gcr - gnome.gnome-settings-daemon - ]; - gnome.gnome-keyring.enable = true; - gvfs.enable = true; - }; - }; -} diff --git a/system/modules/services/kdeconnect/default.nix b/system/modules/programs/kdeconnect/default.nix similarity index 84% rename from system/modules/services/kdeconnect/default.nix rename to system/modules/programs/kdeconnect/default.nix index ebcd31d..e9ba399 100644 --- a/system/modules/services/kdeconnect/default.nix +++ b/system/modules/programs/kdeconnect/default.nix @@ -9,9 +9,8 @@ in options.systemModules.services.kdeconnect.enable = mkEnableOption "Enable kdeconnect system module"; config = mkIf cfg.enable { - services.kdeconnect = { + programs.kdeconnect = { enable = true; - indicator = true; }; }; } diff --git a/system/modules/programs/seahorse/default.nix b/system/modules/programs/seahorse/default.nix index 6d58255..eafd2d7 100644 --- a/system/modules/programs/seahorse/default.nix +++ b/system/modules/programs/seahorse/default.nix @@ -1,14 +1,13 @@ { lib, config, ... }: let - inherit (lib) mkIf mkEnableOption; - cfg = config.systemModules.programs.seahorse; + inherit (lib) mkIf; + inherit (builtins) elem; + host = config.systemModules.host; in { - options.systemModules.programs.seahorse.enable = mkEnableOption "Enable seahorse system module"; - - config = mkIf cfg.enable { + config = mkIf (elem "workstation" host.function) { programs.seahorse.enable = true; }; } diff --git a/system/modules/programs/wireshark/default.nix b/system/modules/programs/wireshark/default.nix index 0af3109..af948ba 100644 --- a/system/modules/programs/wireshark/default.nix +++ b/system/modules/programs/wireshark/default.nix @@ -1,14 +1,13 @@ { lib, config, ... }: let - inherit (lib) mkIf mkEnableOption; - cfg = config.systemModules.programs.wireshark; + inherit (lib) mkIf; + inherit (builtins) elem; + host = config.systemModules.host; in { - options.systemModules.programs.wireshark.enable = mkEnableOption "Enable wireshark system module"; - - config = mkIf cfg.enable { + config = mkIf (elem "workstation" host.function) { programs.wireshark.enable = true; }; } diff --git a/system/modules/security/default.nix b/system/modules/security/default.nix index 336bf05..77b692f 100644 --- a/system/modules/security/default.nix +++ b/system/modules/security/default.nix @@ -1,5 +1,5 @@ { - import = [ + imports = [ ./1password ./kernel ./pam diff --git a/system/modules/services/default.nix b/system/modules/services/default.nix index 888560c..e0fd8d6 100644 --- a/system/modules/services/default.nix +++ b/system/modules/services/default.nix @@ -5,7 +5,6 @@ ./mediaServer ./system76Scheduler ./dbus - ./kdeconnect ./gnome ./gvfs ]; diff --git a/system/modules/services/gvfs/default.nix b/system/modules/services/gvfs/default.nix index 60530e6..451a49f 100644 --- a/system/modules/services/gvfs/default.nix +++ b/system/modules/services/gvfs/default.nix @@ -7,6 +7,6 @@ in { config = mkIf ( host.type != "phone") { - services.gvfs = true; + services.gvfs.enable = true; }; } diff --git a/system/modules/shell/zsh/default.nix b/system/modules/shell/zsh/default.nix index 1e5fab0..f03f6de 100644 --- a/system/modules/shell/zsh/default.nix +++ b/system/modules/shell/zsh/default.nix @@ -8,7 +8,7 @@ in { - options.systemModules.zsh.enable = mkEnableOption "Enable zsh module"; + options.systemModules.shell.zsh.enable = mkEnableOption "Enable zsh module"; config = mkIf (adminShell == "zsh" || cfg.enable) { programs.zsh = { diff --git a/system/modules/user/default.nix b/system/modules/user/default.nix deleted file mode 100644 index ad5494c..0000000 --- a/system/modules/user/default.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ lib, ... }: - -{ - imports = [ - ./shell - ./ooks.nix - ]; - - options.systemModules.user = { - ooks = { - enable = lib.mkEnableOption "Enable the user ooks"; - }; - }; -} diff --git a/system/modules/user/ooks.nix b/system/modules/user/ooks.nix deleted file mode 100644 index da5f378..0000000 --- a/system/modules/user/ooks.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ lib, pkgs, config, ... }: - -let - ifTheyExist = groups: builtins.filter (group: builtins.hasAttr group config.users.groups) groups; - cfg = config.systemModules.user.ooks; -in - -{ - config = lib.mkIf cfg.enable { - users.users.ooks = { - isNormalUser = true; - extraGroups = [ - "wheel" - "video" - "audio" - ] ++ ifTheyExist [ - "git" - "media" - "network" - "libvirtd" - "deluge" - "streamer" - "torrenter" - ]; - - packages = [ pkgs.home-manager ]; - }; - home-manager.users.ooks = import ../../../home/user/ooks/${config.networking.hostName}; - }; -} diff --git a/system/modules/virtualisation/default.nix b/system/modules/virtualization/default.nix similarity index 100% rename from system/modules/virtualisation/default.nix rename to system/modules/virtualization/default.nix diff --git a/system/profiles/base/default.nix b/system/profiles/base/default.nix deleted file mode 100644 index d332b25..0000000 --- a/system/profiles/base/default.nix +++ /dev/null @@ -1,69 +0,0 @@ -{ inputs, outputs, lib, config, pkgs, ... }: - -let - isx86Linux = pkgs: with pkgs.stdenv; hostPlatform.isLinux && hostPlatform.isx86; - cfg = config.systemProfile.base; -in - -{ - - imports = [ - ../../modules - inputs.home-manager.nixosModules.home-manager - ]; - - config = lib.mkIf cfg.enable { - systemModules = { - security.enable = true; - nixOptions.enable = true; - pipewire.enable = true; - networking = { - enable = true; - firewall = true; - resolved = true; - ssh = true; - tools = true; - hardenTcp = true; - }; - - locale.enable = true; - bootloader.systemd.enable = true; - programs.gnomeServices.enable = true; - displayManager.tuigreet.enable = true; - hardware.ssd.enable = true; - services.system76Scheduler.enable = true; - }; - - environment.systemPackages = [pkgs.git]; - environment.enableAllTerminfo = true; - - services = { - dbus.enable = true; # Need this for gtk - printing.enable = true; # Do I even print? - udisks2 = { # Used to manage mount of temp storage - enable = true; - mountOnMedia = true; # Auto mounts device to /media - }; - }; - - boot.supportedFilesystems = ["ntfs"]; # For when someone hands me a usb - - programs = { - dconf.enable = true; - kdeconnect.enable = true; - }; - - home-manager.extraSpecialArgs = { inherit inputs outputs; }; - - hardware = { - enableAllFirmware = true; - enableRedistributableFirmware = true; - opengl = { - enable = true; - driSupport = true; - driSupport32Bit = isx86Linux pkgs; - }; - }; - system.stateVersion = lib.mkDefault "23.11"; - }; -} diff --git a/system/profiles/default.nix b/system/profiles/default.nix deleted file mode 100644 index 6bc7634..0000000 --- a/system/profiles/default.nix +++ /dev/null @@ -1,32 +0,0 @@ -{ lib, config, ... }: - -let - profileEnabler = let - reducer = l: r: {"${r}".enable = true;} // l; - in - builtins.foldl' reducer {} config.activeProfiles; -in -{ - imports = [ - ./base - ./gaming - ]; - - options = { - activeProfiles = lib.mkOption { - type = lib.types.listOf lib.types.str; - default = []; - }; - - systemProfile = { - base = { - enable = lib.mkEnableOption "Enable the base profile"; - }; - gaming = { - enable = lib.mkEnableOption "Enable the gaming profile"; - }; - }; - }; - - config.systemProfile = profileEnabler; -} diff --git a/system/profiles/mediaServer/default.nix b/system/profiles/mediaServer/default.nix deleted file mode 100644 index e7adefb..0000000 --- a/system/profiles/mediaServer/default.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ config, lib, ... }: -let - cfg = config.systemProfile.mediaServer; -in -{ - imports = [ - ../../modules - ]; - - config = lib.mkIf cfg.enable { - systemModules = { - services = { - nixarr.enable = true; - }; - }; - }; -}