diff --git a/inputs/system/modules/base/boot/default.nix b/inputs/system/modules/base/boot/default.nix new file mode 100644 index 0000000..898c005 --- /dev/null +++ b/inputs/system/modules/base/boot/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./loader + ./plymouth.nix + ]; +} diff --git a/inputs/system/modules/base/boot/loader/default.nix b/inputs/system/modules/base/boot/loader/default.nix new file mode 100644 index 0000000..02d8604 --- /dev/null +++ b/inputs/system/modules/base/boot/loader/default.nix @@ -0,0 +1,17 @@ +{ lib, ... }: + +let + inherit (lib) types mkOption; +in + +{ + imports = [ + ./systemd + # ./grub + ]; + + options.systemModules.boot.loader = mkOption { + type = types.enum ["systemd" "grub"]; + default = "systemd"; + }; +} diff --git a/inputs/system/modules/base/bootloader/grub/default.nix b/inputs/system/modules/base/boot/loader/grub.nix similarity index 100% rename from inputs/system/modules/base/bootloader/grub/default.nix rename to inputs/system/modules/base/boot/loader/grub.nix diff --git a/inputs/system/modules/base/bootloader/systemd/default.nix b/inputs/system/modules/base/boot/loader/systemd.nix similarity index 69% rename from inputs/system/modules/base/bootloader/systemd/default.nix rename to inputs/system/modules/base/boot/loader/systemd.nix index 77cd45d..d20b61f 100644 --- a/inputs/system/modules/base/bootloader/systemd/default.nix +++ b/inputs/system/modules/base/boot/loader/systemd.nix @@ -2,11 +2,11 @@ let inherit (lib) mkIf; - host = config.systemModules.host; + bootloader = config.systemModules.boot.loader; in { - config = mkIf (host.type != "phone") { + config = mkIf (bootloader == "systemd") { boot.loader = { systemd-boot = { enable = true; diff --git a/inputs/system/modules/base/bootloader/plymouth/default.nix b/inputs/system/modules/base/boot/plymouth.nix similarity index 65% rename from inputs/system/modules/base/bootloader/plymouth/default.nix rename to inputs/system/modules/base/boot/plymouth.nix index 7a58c26..c70170f 100644 --- a/inputs/system/modules/base/bootloader/plymouth/default.nix +++ b/inputs/system/modules/base/boot/plymouth.nix @@ -1,11 +1,14 @@ { lib, config, pkgs, ... }: let + inherit (lib) mkIf mkEnableOption; cfg = config.systemModules.plymouth; in { - config = lib.mkIf cfg.enable { + options.systemModules.boot.plymouth.enable = mkEnableOption ""; + + config = mkIf cfg.enable { boot.plymouth = { enable = true; themePackages = [(pkgs.catppuccin-plymouth.override {variant = "mocha";})]; diff --git a/inputs/system/modules/base/bootloader/default.nix b/inputs/system/modules/base/bootloader/default.nix deleted file mode 100644 index a4e74f2..0000000 --- a/inputs/system/modules/base/bootloader/default.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ lib, ... }: - -{ - imports = [ ./systemd ./plymouth ]; - - options.systemModules = { - bootloader = { - systemd = { - enable = lib.mkEnableOption "Enable systemd bootloader module"; - }; - }; - plymouth = { - enable = lib.mkEnableOption "Enable plymouth bootscreen"; - }; - }; -} diff --git a/inputs/system/modules/base/displayManager/tuigreet.nix b/inputs/system/modules/base/displayManager/tuigreet.nix new file mode 100644 index 0000000..e2b6adf --- /dev/null +++ b/inputs/system/modules/base/displayManager/tuigreet.nix @@ -0,0 +1,30 @@ +{ pkgs, lib, config, ... }: +let + inherit (lib) mkIf; + tuigreet = "${pkgs.greetd.tuigreet}/bin/tuigreet"; + host = config.systemModules.host; +in +{ + config = mkIf (host.type != "phone") { + services.greetd = { + enable = true; + settings = { + default_session = { + command = "${tuigreet} --time --remember --cmd Hyprland"; # TODO: dont hardcode this + user = "greeter"; + }; + }; + }; + + systemd.services.greetd.serviceConfig = { + Type = "idle"; + StandardInput = "tty"; + StandardOutput = "tty"; + StandardError = "journal"; # Without this errors will spam on screen + # Without these bootlogs will spam on screen + TTYReset = true; + TTYVHangup = true; + TTYVTDisallocate = true; + }; + }; +} diff --git a/inputs/system/modules/base/host/admin/default.nix b/inputs/system/modules/base/host/admin.nix similarity index 100% rename from inputs/system/modules/base/host/admin/default.nix rename to inputs/system/modules/base/host/admin.nix diff --git a/inputs/system/modules/base/host/default.nix b/inputs/system/modules/base/host/default.nix index cf914b2..968834b 100644 --- a/inputs/system/modules/base/host/default.nix +++ b/inputs/system/modules/base/host/default.nix @@ -1,9 +1,9 @@ { imports = [ - ./admin - ./name - ./type - ./function + ./admin.nix + ./name.nix + ./type.nix + ./role.nix ./hardware ]; } diff --git a/inputs/system/modules/base/host/function/workstation/default.nix b/inputs/system/modules/base/host/function/workstation/default.nix deleted file mode 100644 index cd4687b..0000000 --- a/inputs/system/modules/base/host/function/workstation/default.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ lib, config, ... }: - - let - inherit (lib) mkIf; - inherit (builtins) elem; - function = config.systemModules.host.function; - in - -{ - config = mkIf (elem "workstation" function) { - systemModules = { - - audio.enable = true; - video.enable = true; - - programs = { - dconf.enable = true; - wireshark.enable = true; - bandwhich.enable = true; - kdeconnect.enable = true; - }; - - services = { - - } - } - } - -} diff --git a/inputs/system/modules/base/host/hardware/common/default.nix b/inputs/system/modules/base/host/hardware/common.nix similarity index 100% rename from inputs/system/modules/base/host/hardware/common/default.nix rename to inputs/system/modules/base/host/hardware/common.nix diff --git a/inputs/system/modules/base/host/hardware/cpu/amd/default.nix b/inputs/system/modules/base/host/hardware/cpu/amd.nix similarity index 100% rename from inputs/system/modules/base/host/hardware/cpu/amd/default.nix rename to inputs/system/modules/base/host/hardware/cpu/amd.nix diff --git a/inputs/system/modules/base/host/hardware/cpu/default.nix b/inputs/system/modules/base/host/hardware/cpu/default.nix index 58b75a3..f309f87 100644 --- a/inputs/system/modules/base/host/hardware/cpu/default.nix +++ b/inputs/system/modules/base/host/hardware/cpu/default.nix @@ -6,8 +6,8 @@ in { imports = [ - ./amd - ./intel + ./amd.nix + ./intel.nix ]; options.systemModules.host.hardware.cpu.type = mkOption { diff --git a/inputs/system/modules/base/host/hardware/cpu/intel/default.nix b/inputs/system/modules/base/host/hardware/cpu/intel.nix similarity index 100% rename from inputs/system/modules/base/host/hardware/cpu/intel/default.nix rename to inputs/system/modules/base/host/hardware/cpu/intel.nix diff --git a/inputs/system/modules/base/host/hardware/default.nix b/inputs/system/modules/base/host/hardware/default.nix index 6c88323..710bbc1 100644 --- a/inputs/system/modules/base/host/hardware/default.nix +++ b/inputs/system/modules/base/host/hardware/default.nix @@ -3,6 +3,6 @@ ./cpu ./gpu ./features - ./common + ./common.nix ]; } diff --git a/inputs/system/modules/base/host/hardware/features/audio.nix b/inputs/system/modules/base/host/hardware/features/audio.nix new file mode 100644 index 0000000..d61954b --- /dev/null +++ b/inputs/system/modules/base/host/hardware/features/audio.nix @@ -0,0 +1,111 @@ +{ config, lib, pkgs, ... }: + +let + inherit (lib) mkIf; + inherit (lib.generators) toLua; + inherit (lib.lists) elem optionals; + # inherit (builtins) elem; + features = config.systemModules.host.hardware.features; + hasBT = (elem "bluetooth" features); +in + +{ + config = mkIf (elem "audio" features) { + 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" /* 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/host/hardware/features/backlight/default.nix b/inputs/system/modules/base/host/hardware/features/backlight.nix similarity index 100% rename from inputs/system/modules/base/host/hardware/features/backlight/default.nix rename to inputs/system/modules/base/host/hardware/features/backlight.nix diff --git a/inputs/system/modules/base/host/hardware/features/battery/default.nix b/inputs/system/modules/base/host/hardware/features/battery.nix similarity index 100% rename from inputs/system/modules/base/host/hardware/features/battery/default.nix rename to inputs/system/modules/base/host/hardware/features/battery.nix diff --git a/inputs/system/modules/base/host/hardware/features/bluetooth/default.nix b/inputs/system/modules/base/host/hardware/features/bluetooth.nix similarity index 100% rename from inputs/system/modules/base/host/hardware/features/bluetooth/default.nix rename to inputs/system/modules/base/host/hardware/features/bluetooth.nix diff --git a/inputs/system/modules/base/host/hardware/features/default.nix b/inputs/system/modules/base/host/hardware/features/default.nix index 1513b5b..ad81c07 100644 --- a/inputs/system/modules/base/host/hardware/features/default.nix +++ b/inputs/system/modules/base/host/hardware/features/default.nix @@ -6,14 +6,16 @@ in { imports = [ - ./bluetooth - ./backlight - ./battery - ./ssd + ./bluetooth.nix + ./backlight.nix + ./battery.nix + ./ssd.nix + ./audio.nix + ./video.nix ]; options.systemModules.host.hardware.features = mkOption { - type = with types; listOf (enum ["bluetooth" "backlight" "battery" "ssd"]); + type = with types; listOf (enum ["audio" "video" "bluetooth" "backlight" "battery" "ssd"]); default = []; description = "What extra hardware feature system modules to use"; }; diff --git a/inputs/system/modules/base/host/hardware/features/ssd/default.nix b/inputs/system/modules/base/host/hardware/features/ssd.nix similarity index 100% rename from inputs/system/modules/base/host/hardware/features/ssd/default.nix rename to inputs/system/modules/base/host/hardware/features/ssd.nix diff --git a/inputs/system/modules/base/host/hardware/features/video.nix b/inputs/system/modules/base/host/hardware/features/video.nix new file mode 100644 index 0000000..c68d495 --- /dev/null +++ b/inputs/system/modules/base/host/hardware/features/video.nix @@ -0,0 +1,31 @@ +{ lib, config, pkgs, ... }: + +let + inherit (lib) mkIf; + inherit (builtins) elem; + isx86Linux = pkgs: with pkgs.stdenv; hostPlatform.isLinux && hostPlatform.isx86; + features = config.systemModules.host.hardware.features; +in + +{ + config = mkIf (elem "video" features) { + hardware = { + opengl = { + enable = true; + driSupport = true; + driSupport32Bit = isx86Linux pkgs; + }; + }; + xdg.portal = { + enable = true; + xdgOpenUsePortal = true; + extraPortals = [ + pkgs.xdg-desktop-portal-gtk + ]; + config = { + common.default = ["gtk"]; + hyprland.default = ["gtk" "hyprland"]; + }; + }; + }; +} diff --git a/inputs/system/modules/base/host/hardware/gpu/amd/default.nix b/inputs/system/modules/base/host/hardware/gpu/amd.nix similarity index 100% rename from inputs/system/modules/base/host/hardware/gpu/amd/default.nix rename to inputs/system/modules/base/host/hardware/gpu/amd.nix diff --git a/inputs/system/modules/base/host/hardware/gpu/default.nix b/inputs/system/modules/base/host/hardware/gpu/default.nix index 6417200..beffd6d 100644 --- a/inputs/system/modules/base/host/hardware/gpu/default.nix +++ b/inputs/system/modules/base/host/hardware/gpu/default.nix @@ -6,9 +6,9 @@ in { imports = [ - ./amd - ./intel - ./nvidia + ./amd.nix + ./intel.nix + ./nvidia.nix ]; options.systemModules.host.hardware.gpu.type = mkOption { diff --git a/inputs/system/modules/base/host/hardware/gpu/intel/default.nix b/inputs/system/modules/base/host/hardware/gpu/intel.nix similarity index 100% rename from inputs/system/modules/base/host/hardware/gpu/intel/default.nix rename to inputs/system/modules/base/host/hardware/gpu/intel.nix diff --git a/inputs/system/modules/base/host/hardware/gpu/nvidia/default.nix b/inputs/system/modules/base/host/hardware/gpu/nvidia.nix similarity index 100% rename from inputs/system/modules/base/host/hardware/gpu/nvidia/default.nix rename to inputs/system/modules/base/host/hardware/gpu/nvidia.nix diff --git a/inputs/system/modules/base/host/name/default.nix b/inputs/system/modules/base/host/name.nix similarity index 100% rename from inputs/system/modules/base/host/name/default.nix rename to inputs/system/modules/base/host/name.nix diff --git a/inputs/system/modules/base/host/function/default.nix b/inputs/system/modules/base/host/role.nix similarity index 100% rename from inputs/system/modules/base/host/function/default.nix rename to inputs/system/modules/base/host/role.nix diff --git a/inputs/system/modules/base/host/type/default.nix b/inputs/system/modules/base/host/type.nix similarity index 100% rename from inputs/system/modules/base/host/type/default.nix rename to inputs/system/modules/base/host/type.nix diff --git a/inputs/system/modules/base/locale.nix b/inputs/system/modules/base/locale.nix new file mode 100644 index 0000000..71838bc --- /dev/null +++ b/inputs/system/modules/base/locale.nix @@ -0,0 +1,17 @@ +{ lib, ... }: + +let + inherit (lib) mkDefault; +in + +{ + i18n = { + defaultLocale = mkDefault "en_US.UTF-8"; + supportedLocales = mkDefault [ + "en_US.UTF-8/UTF-8" + ]; + }; + time.timeZone = mkDefault "Pacific/Auckland"; + location.provider = "geoclue2"; + services.geoclue2.enable = true; +} diff --git a/inputs/system/modules/base/networking/firewall/default.nix b/inputs/system/modules/base/networking/firewall.nix similarity index 100% rename from inputs/system/modules/base/networking/firewall/default.nix rename to inputs/system/modules/base/networking/firewall.nix diff --git a/inputs/system/modules/base/networking/resolved/default.nix b/inputs/system/modules/base/networking/resolved.nix similarity index 100% rename from inputs/system/modules/base/networking/resolved/default.nix rename to inputs/system/modules/base/networking/resolved.nix diff --git a/inputs/system/modules/base/networking/ssh/default.nix b/inputs/system/modules/base/networking/ssh.nix similarity index 100% rename from inputs/system/modules/base/networking/ssh/default.nix rename to inputs/system/modules/base/networking/ssh.nix diff --git a/inputs/system/modules/base/networking/tailscale/default.nix b/inputs/system/modules/base/networking/tailscale.nix similarity index 100% rename from inputs/system/modules/base/networking/tailscale/default.nix rename to inputs/system/modules/base/networking/tailscale.nix diff --git a/inputs/system/modules/base/networking/tcp/default.nix b/inputs/system/modules/base/networking/tcp.nix similarity index 100% rename from inputs/system/modules/base/networking/tcp/default.nix rename to inputs/system/modules/base/networking/tcp.nix diff --git a/inputs/system/modules/base/networking/tools/default.nix b/inputs/system/modules/base/networking/tools.nix similarity index 100% rename from inputs/system/modules/base/networking/tools/default.nix rename to inputs/system/modules/base/networking/tools.nix diff --git a/inputs/system/modules/base/nix/nh/default.nix b/inputs/system/modules/base/nix/nh.nix similarity index 100% rename from inputs/system/modules/base/nix/nh/default.nix rename to inputs/system/modules/base/nix/nh.nix diff --git a/inputs/system/modules/base/nix/nix/default.nix b/inputs/system/modules/base/nix/nix/default.nix deleted file mode 100644 index 640acce..0000000 --- a/inputs/system/modules/base/nix/nix/default.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ config, lib, inputs, ... }: - -let - inherit (lib) mkIf mapAttrs mkDefault; - host = config.systemModules.host; -in - -{ - config = mkIf (host.type != "phone") { - nix = { - settings = { - trusted-users = [ "root" "@wheel" ]; - 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 = mapAttrs (_: value: { flake = value; }) inputs; - nixPath = [ "nixpkgs=${inputs.nixpkgs.outPath}" ]; - }; - }; -} diff --git a/inputs/system/modules/base/nix/nixpkgs/default.nix b/inputs/system/modules/base/nix/nixpkgs.nix similarity index 86% rename from inputs/system/modules/base/nix/nixpkgs/default.nix rename to inputs/system/modules/base/nix/nixpkgs.nix index 3241932..7cb5a22 100644 --- a/inputs/system/modules/base/nix/nixpkgs/default.nix +++ b/inputs/system/modules/base/nix/nixpkgs.nix @@ -17,6 +17,7 @@ in }; overlays = [ (final: prev: { + waybar = inputs.nixpkgs-wayland.packages.${prev.system}.waybar; zjstatus = inputs.zjstatus.packages.${prev.system}.default; }) ]; diff --git a/inputs/system/modules/base/nix/subs/default.nix b/inputs/system/modules/base/nix/sub.nix similarity index 100% rename from inputs/system/modules/base/nix/subs/default.nix rename to inputs/system/modules/base/nix/sub.nix diff --git a/inputs/system/modules/base/gaming/default.nix b/inputs/system/modules/gaming/default.nix similarity index 100% rename from inputs/system/modules/base/gaming/default.nix rename to inputs/system/modules/gaming/default.nix diff --git a/outputs/overlays/default.nix b/outputs/overlays/default.nix index 1dd917a..0839bdf 100644 --- a/outputs/overlays/default.nix +++ b/outputs/overlays/default.nix @@ -18,9 +18,9 @@ zjstatus = inputs.zjstatus.packages.${prev.system}.default; }; - waybar = final: prev: { - waybar = inputs.nixpkgs-wayland.packages.${prev.system}.waybar; - }; + # waybar = final: prev: { + # waybar = inputs.nixpkgs-wayland.packages.${prev.system}.waybar; + # }; additions = final: prev: import ../pkgs { pkgs = final; }; }