From f47154c2347c4c75e57feef21f6d2b198fe9f475 Mon Sep 17 00:00:00 2001 From: ooks-io Date: Fri, 24 May 2024 23:44:07 +1200 Subject: [PATCH] refactor(system): flatten --- inputs/system/hosts/ooksdesk/default.nix | 2 +- .../modules/base/audio/pipewire/default.nix | 111 ------------------ inputs/system/modules/base/default.nix | 3 - .../base/host/hardware/features/video.nix | 5 +- .../system/modules/base/networking/tools.nix | 5 + inputs/system/modules/base/nix/default.nix | 2 +- .../base/programs/bandwhich/default.nix | 13 -- .../system/modules/base/programs/default.nix | 9 -- .../base/programs/seahorse/default.nix | 13 -- .../base/programs/wireshark/default.nix | 13 -- .../system/modules/base/security/default.nix | 9 +- .../{kernel/default.nix => kernel.nix} | 0 .../security/{pam/default.nix => pam.nix} | 0 .../{polkit/default.nix => polkit.nix} | 0 .../security/{sudo/default.nix => sudo.nix} | 0 .../services/{dbus/default.nix => dbus.nix} | 0 .../system/modules/base/services/default.nix | 18 +-- .../services/{gnome/default.nix => gnome.nix} | 0 .../services/{gvfs/default.nix => gvfs.nix} | 0 .../base/services/mediaServer/default.nix | 51 -------- .../default.nix => system76Scheduler.nix} | 0 inputs/system/modules/base/video/default.nix | 31 ----- .../modules/{ => roles}/gaming/default.nix | 0 .../audio => roles/workstation}/default.nix | 2 +- .../workstation/programs/1password.nix} | 0 .../workstation/programs/dconf.nix} | 0 .../roles/workstation/programs/default.nix | 7 ++ .../workstation/programs/kdeconnect.nix} | 0 outputs/nixos.nix | 6 + 29 files changed, 32 insertions(+), 268 deletions(-) delete mode 100644 inputs/system/modules/base/audio/pipewire/default.nix delete mode 100644 inputs/system/modules/base/programs/bandwhich/default.nix delete mode 100644 inputs/system/modules/base/programs/default.nix delete mode 100644 inputs/system/modules/base/programs/seahorse/default.nix delete mode 100644 inputs/system/modules/base/programs/wireshark/default.nix rename inputs/system/modules/base/security/{kernel/default.nix => kernel.nix} (100%) rename inputs/system/modules/base/security/{pam/default.nix => pam.nix} (100%) rename inputs/system/modules/base/security/{polkit/default.nix => polkit.nix} (100%) rename inputs/system/modules/base/security/{sudo/default.nix => sudo.nix} (100%) rename inputs/system/modules/base/services/{dbus/default.nix => dbus.nix} (100%) rename inputs/system/modules/base/services/{gnome/default.nix => gnome.nix} (100%) rename inputs/system/modules/base/services/{gvfs/default.nix => gvfs.nix} (100%) delete mode 100644 inputs/system/modules/base/services/mediaServer/default.nix rename inputs/system/modules/base/services/{system76Scheduler/default.nix => system76Scheduler.nix} (100%) delete mode 100644 inputs/system/modules/base/video/default.nix rename inputs/system/modules/{ => roles}/gaming/default.nix (100%) rename inputs/system/modules/{base/audio => roles/workstation}/default.nix (60%) rename inputs/system/modules/{base/security/1password/default.nix => roles/workstation/programs/1password.nix} (100%) rename inputs/system/modules/{base/programs/dconf/default.nix => roles/workstation/programs/dconf.nix} (100%) create mode 100644 inputs/system/modules/roles/workstation/programs/default.nix rename inputs/system/modules/{base/programs/kdeconnect/default.nix => roles/workstation/programs/kdeconnect.nix} (100%) diff --git a/inputs/system/hosts/ooksdesk/default.nix b/inputs/system/hosts/ooksdesk/default.nix index df0036c..8f5ec32 100644 --- a/inputs/system/hosts/ooksdesk/default.nix +++ b/inputs/system/hosts/ooksdesk/default.nix @@ -23,7 +23,7 @@ in cpu.type = "amd"; cpu.amd.pstate.enable = true; gpu.type = "amd"; - features = [ "ssd" ]; + features = [ "ssd" "audio" "video" ]; }; }; diff --git a/inputs/system/modules/base/audio/pipewire/default.nix b/inputs/system/modules/base/audio/pipewire/default.nix deleted file mode 100644 index e0d8210..0000000 --- a/inputs/system/modules/base/audio/pipewire/default.nix +++ /dev/null @@ -1,111 +0,0 @@ -{ config, lib, pkgs, ... }: - -let - inherit (lib) mkIf; - inherit (lib.generators) toLua; - inherit (lib.lists) any elem optionals; - # inherit (builtins) elem; - hasBT = (elem "bluetooth" config.systemModules.host.hardware.features); - hasFunction = f: elem f config.systemModules.host.function; -in - -{ - config = mkIf (any hasFunction ["workstation" "gaming" "media-server"]) { - hardware.pulseaudio.enable = !config.services.pipewire.enable; - security.rtkit.enable = config.services.pipewire.enable; - services.pipewire = - let - quantum = 64; - rate = 48000; - qr = "${toString quantum}/${toString rate}"; - in - { - enable = true; - - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - jack.enable = true; - - # Low latency module provided by notashelf/nyx - extraConfig.pipewire."99-lowlatency" = { - context = { - properties.default.clock.min-quantum = quantum; - modules = [ - { - name = "libpipewire-module-rtkit"; - flags = ["ifexists" "nofail"]; - args = { - nice.level = -15; - rt = { - prio = 88; - time.soft = 200000; - time.hard = 200000; - }; - }; - } - { - name = "libpipewire-module-protocol-pulse"; - args = { - server.address = ["unix:native"]; - pulse.min = { - req = qr; - quantum = qr; - frag = qr; - }; - }; - } - ]; - - stream.properties = { - node.latency = qr; - resample.quality = 1; - }; - }; - }; - - wireplumber = { - enable = true; - configPackages = let - matches = toLua { - multiline = false; - indent = false; - } [[["node.name" "matches" "alsa_output.*"]]]; - - apply_properties = toLua {} { - "audio.format" = "S32LE"; - "audio.rate" = rate * 2; - "api.alsa.period-size" = 2; - }; - in - [ - (pkgs.writeTextDir "share/lowlatency.lua.d/99-alsa-lowlatency.lua" '' - alsa_monitor.rules = { - { - matches = ${matches}; - apply_properties = ${apply_properties}; - } - } - '') - ] - ++ optionals hasBT [ - (pkgs.writeTextDir "share/bluetooth.lua.d/51-bluez-config.lua" '' - bluez_monitor.properties = { - ["bluez5.enable-sbc-xq"] = true, - ["bluez5.enable-msbc"] = true, - ["bluez5.enable-hw-volume"] = true, - ["bluez5.headset-roles"] = "[ hsp_hs hsp_ag hfp_hf hfp_ag ]" - } - '') - ]; - }; - }; - - systemd.user.services = { - pipewire.wantedBy = ["default.target"]; - pipewire-pulse.wantedBy = ["default.target"]; - }; - }; -} - - diff --git a/inputs/system/modules/base/default.nix b/inputs/system/modules/base/default.nix index 17a6e72..a0dfafb 100644 --- a/inputs/system/modules/base/default.nix +++ b/inputs/system/modules/base/default.nix @@ -5,16 +5,13 @@ ./shell ./boot ./nix - ./programs ./displayManager ./networking ./locale.nix ./virtualization ./security ./services - ./audio ./host - ./video ]; diff --git a/inputs/system/modules/base/host/hardware/features/video.nix b/inputs/system/modules/base/host/hardware/features/video.nix index c68d495..52d5e15 100644 --- a/inputs/system/modules/base/host/hardware/features/video.nix +++ b/inputs/system/modules/base/host/hardware/features/video.nix @@ -19,8 +19,9 @@ in xdg.portal = { enable = true; xdgOpenUsePortal = true; - extraPortals = [ - pkgs.xdg-desktop-portal-gtk + extraPortals = with pkgs; [ + xdg-desktop-portal-hyprland + xdg-desktop-portal-gtk ]; config = { common.default = ["gtk"]; diff --git a/inputs/system/modules/base/networking/tools.nix b/inputs/system/modules/base/networking/tools.nix index 9cf0501..418c755 100644 --- a/inputs/system/modules/base/networking/tools.nix +++ b/inputs/system/modules/base/networking/tools.nix @@ -6,4 +6,9 @@ mtr tcpdump ]; + + programs = { + wireshark.enable = true; + bandwhich.enable = true; + }; } diff --git a/inputs/system/modules/base/nix/default.nix b/inputs/system/modules/base/nix/default.nix index b8b8582..3ebbf38 100644 --- a/inputs/system/modules/base/nix/default.nix +++ b/inputs/system/modules/base/nix/default.nix @@ -38,7 +38,7 @@ in options = "--delete-older-than 30d"; }; settings = { - flake-registry = "etc/nix/registry.json"; + flake-registry = "/etc/nix/registry.json"; allowed-users = [ "root" "@wheel" ]; trusted-users = [ "root" "@wheel" ]; experimental-features = [ "nix-command" "flakes" ]; diff --git a/inputs/system/modules/base/programs/bandwhich/default.nix b/inputs/system/modules/base/programs/bandwhich/default.nix deleted file mode 100644 index eb8e229..0000000 --- a/inputs/system/modules/base/programs/bandwhich/default.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ lib, config, ... }: - -let - inherit (lib) mkIf; - inherit (builtins) elem; - host = config.systemModules.host; -in - -{ - config = mkIf (elem "workstation" host.function) { - programs.bandwhich.enable = true; - }; -} diff --git a/inputs/system/modules/base/programs/default.nix b/inputs/system/modules/base/programs/default.nix deleted file mode 100644 index d00b1de..0000000 --- a/inputs/system/modules/base/programs/default.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ - imports = [ - ./dconf - ./kdeconnect - ./seahorse - ./wireshark - ./bandwhich - ]; -} diff --git a/inputs/system/modules/base/programs/seahorse/default.nix b/inputs/system/modules/base/programs/seahorse/default.nix deleted file mode 100644 index eafd2d7..0000000 --- a/inputs/system/modules/base/programs/seahorse/default.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ lib, config, ... }: - -let - inherit (lib) mkIf; - inherit (builtins) elem; - host = config.systemModules.host; -in - -{ - config = mkIf (elem "workstation" host.function) { - programs.seahorse.enable = true; - }; -} diff --git a/inputs/system/modules/base/programs/wireshark/default.nix b/inputs/system/modules/base/programs/wireshark/default.nix deleted file mode 100644 index af948ba..0000000 --- a/inputs/system/modules/base/programs/wireshark/default.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ lib, config, ... }: - -let - inherit (lib) mkIf; - inherit (builtins) elem; - host = config.systemModules.host; -in - -{ - config = mkIf (elem "workstation" host.function) { - programs.wireshark.enable = true; - }; -} diff --git a/inputs/system/modules/base/security/default.nix b/inputs/system/modules/base/security/default.nix index 77b692f..c27a183 100644 --- a/inputs/system/modules/base/security/default.nix +++ b/inputs/system/modules/base/security/default.nix @@ -1,9 +1,8 @@ { imports = [ - ./1password - ./kernel - ./pam - ./polkit - ./sudo + ./kernel.nix + ./pam.nix + ./polkit.nix + ./sudo.nix ]; } diff --git a/inputs/system/modules/base/security/kernel/default.nix b/inputs/system/modules/base/security/kernel.nix similarity index 100% rename from inputs/system/modules/base/security/kernel/default.nix rename to inputs/system/modules/base/security/kernel.nix diff --git a/inputs/system/modules/base/security/pam/default.nix b/inputs/system/modules/base/security/pam.nix similarity index 100% rename from inputs/system/modules/base/security/pam/default.nix rename to inputs/system/modules/base/security/pam.nix diff --git a/inputs/system/modules/base/security/polkit/default.nix b/inputs/system/modules/base/security/polkit.nix similarity index 100% rename from inputs/system/modules/base/security/polkit/default.nix rename to inputs/system/modules/base/security/polkit.nix diff --git a/inputs/system/modules/base/security/sudo/default.nix b/inputs/system/modules/base/security/sudo.nix similarity index 100% rename from inputs/system/modules/base/security/sudo/default.nix rename to inputs/system/modules/base/security/sudo.nix diff --git a/inputs/system/modules/base/services/dbus/default.nix b/inputs/system/modules/base/services/dbus.nix similarity index 100% rename from inputs/system/modules/base/services/dbus/default.nix rename to inputs/system/modules/base/services/dbus.nix diff --git a/inputs/system/modules/base/services/default.nix b/inputs/system/modules/base/services/default.nix index e0fd8d6..1365ae9 100644 --- a/inputs/system/modules/base/services/default.nix +++ b/inputs/system/modules/base/services/default.nix @@ -1,18 +1,8 @@ -{ lib, ... }: - { imports = [ - ./mediaServer - ./system76Scheduler - ./dbus - ./gnome - ./gvfs + ./system76Scheduler.nix + ./dbus.nix + ./gnome.nix + ./gvfs.nix ]; - - options.systemModules.services = { - mediaServer = { - enable = lib.mkEnableOption "Enable mediaserver service module"; - }; - }; - } diff --git a/inputs/system/modules/base/services/gnome/default.nix b/inputs/system/modules/base/services/gnome.nix similarity index 100% rename from inputs/system/modules/base/services/gnome/default.nix rename to inputs/system/modules/base/services/gnome.nix diff --git a/inputs/system/modules/base/services/gvfs/default.nix b/inputs/system/modules/base/services/gvfs.nix similarity index 100% rename from inputs/system/modules/base/services/gvfs/default.nix rename to inputs/system/modules/base/services/gvfs.nix diff --git a/inputs/system/modules/base/services/mediaServer/default.nix b/inputs/system/modules/base/services/mediaServer/default.nix deleted file mode 100644 index f55f5d9..0000000 --- a/inputs/system/modules/base/services/mediaServer/default.nix +++ /dev/null @@ -1,51 +0,0 @@ -{ config, lib, pkgs, ... }: - -let - cfg = config.systemModules.services.mediaServer; -in - -{ - config = lib.mkIf cfg.enable { - - users.groups.media = { }; - - environment.systemPackages = with pkgs; [ - jellyfin - jellyfin-web - jellyfin-ffmpeg - ]; - - services = { - jellyfin = { - group = "media"; - enable = true; - openFirewall = true; - }; - deluge = { - group = "media"; - enable = true; - web.enable = true; - }; - radarr = { - group = "media"; - enable = true; - openFirewall = true; - }; - sonarr = { - group = "media"; - enable = true; - openFirewall = true; - }; - prowlarr.enable = true; - }; - - systemd.tmpfiles.rules = [ - "d /jellyfin 0770 - media - -" - ]; - - fileSystems."/jellyfin" = { - device = "/dev/disk/by-label/jellyfin"; - fsType = "btrfs"; - }; - }; -} diff --git a/inputs/system/modules/base/services/system76Scheduler/default.nix b/inputs/system/modules/base/services/system76Scheduler.nix similarity index 100% rename from inputs/system/modules/base/services/system76Scheduler/default.nix rename to inputs/system/modules/base/services/system76Scheduler.nix diff --git a/inputs/system/modules/base/video/default.nix b/inputs/system/modules/base/video/default.nix deleted file mode 100644 index 1ef4a38..0000000 --- a/inputs/system/modules/base/video/default.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ lib, config, pkgs, ... }: - -let - inherit (lib) mkIf; - isx86Linux = pkgs: with pkgs.stdenv; hostPlatform.isLinux && hostPlatform.isx86; - host = config.systemModules.host; -in - -{ - config = mkIf (host.type != "phone") { - hardware = { - opengl = { - enable = true; - driSupport = true; - driSupport32Bit = isx86Linux pkgs; - }; - }; - xdg.portal = { - enable = true; - xdgOpenUsePortal = true; - extraPortals = with pkgs; [ - xdg-desktop-portal-gtk - xdg-desktop-portal-hyprland - ]; - config = { - common.default = ["gtk"]; - hyprland.default = ["gtk" "hyprland"]; - }; - }; - }; -} diff --git a/inputs/system/modules/gaming/default.nix b/inputs/system/modules/roles/gaming/default.nix similarity index 100% rename from inputs/system/modules/gaming/default.nix rename to inputs/system/modules/roles/gaming/default.nix diff --git a/inputs/system/modules/base/audio/default.nix b/inputs/system/modules/roles/workstation/default.nix similarity index 60% rename from inputs/system/modules/base/audio/default.nix rename to inputs/system/modules/roles/workstation/default.nix index 40e81f7..5d85a74 100644 --- a/inputs/system/modules/base/audio/default.nix +++ b/inputs/system/modules/roles/workstation/default.nix @@ -1,5 +1,5 @@ { imports = [ - ./pipewire + ./programs ]; } diff --git a/inputs/system/modules/base/security/1password/default.nix b/inputs/system/modules/roles/workstation/programs/1password.nix similarity index 100% rename from inputs/system/modules/base/security/1password/default.nix rename to inputs/system/modules/roles/workstation/programs/1password.nix diff --git a/inputs/system/modules/base/programs/dconf/default.nix b/inputs/system/modules/roles/workstation/programs/dconf.nix similarity index 100% rename from inputs/system/modules/base/programs/dconf/default.nix rename to inputs/system/modules/roles/workstation/programs/dconf.nix diff --git a/inputs/system/modules/roles/workstation/programs/default.nix b/inputs/system/modules/roles/workstation/programs/default.nix new file mode 100644 index 0000000..7c4d05e --- /dev/null +++ b/inputs/system/modules/roles/workstation/programs/default.nix @@ -0,0 +1,7 @@ +{ + imports = [ + ./dconf.nix + ./kdeconnect.nix + ./1password.nix + ]; +} diff --git a/inputs/system/modules/base/programs/kdeconnect/default.nix b/inputs/system/modules/roles/workstation/programs/kdeconnect.nix similarity index 100% rename from inputs/system/modules/base/programs/kdeconnect/default.nix rename to inputs/system/modules/roles/workstation/programs/kdeconnect.nix diff --git a/outputs/nixos.nix b/outputs/nixos.nix index c4bf348..b875733 100644 --- a/outputs/nixos.nix +++ b/outputs/nixos.nix @@ -9,6 +9,10 @@ let hosts = "${systemInputs}/hosts"; base = "${systemInputs}/modules/base"; + gaming = "${systemInputs}/modules/roles/gaming"; + workstation = "${systemInputs}/modules/roles/workstation"; + + specialArgs = {inherit inputs self;}; in @@ -20,6 +24,8 @@ in "${hosts}/ooksdesk" hm base + gaming + workstation ]; }; }