diff --git a/hosts/aristotle/hardware-configuration.nix b/hosts/aristotle/hardware-configuration.nix index 851da16..fea25e1 100644 --- a/hosts/aristotle/hardware-configuration.nix +++ b/hosts/aristotle/hardware-configuration.nix @@ -7,7 +7,7 @@ hardware.nvidia.nvidiaSettings = false; services.hdapsd.enable = false; - myFlake.hardware.components = { + my.hardware ={ audio.enable = true; bluetooth.enable = true; tpm.enable = true; diff --git a/hosts/blacksteel/hardware-configuration.nix b/hosts/blacksteel/hardware-configuration.nix index 204721a..fe1be3e 100644 --- a/hosts/blacksteel/hardware-configuration.nix +++ b/hosts/blacksteel/hardware-configuration.nix @@ -14,7 +14,7 @@ inputs.nixos-sensible.nixosModules.zram ]; - myFlake.hardware.components = { + my.hardware = { audio.enable = true; bluetooth.enable = true; tpm.enable = true; diff --git a/nixos/modules/default.nix b/nixos/modules/default.nix index 8326a5e..a9660af 100644 --- a/nixos/modules/default.nix +++ b/nixos/modules/default.nix @@ -1,13 +1,10 @@ {...}: { imports = [ # utils that is used internally - ./myFlake/boot.nix - ./myFlake/hardware/accessories/logitech-wireless.nix - ./myFlake/hardware/accessories/piper.nix - ./myFlake/hardware/accessories/xbox-one-controller.nix - ./myFlake/hardware/components/audio.nix - ./myFlake/hardware/components/bluetooth.nix - ./myFlake/hardware/components/tpm.nix + ./my/boot.nix + ./my/hardware/audio.nix + ./my/hardware/bluetooth.nix + ./my/hardware/tpm.nix # nixpkgs styled options ./services/hysteria.nix diff --git a/nixos/modules/myFlake/boot.nix b/nixos/modules/my/boot.nix similarity index 67% rename from nixos/modules/myFlake/boot.nix rename to nixos/modules/my/boot.nix index a21d0c0..5acad31 100644 --- a/nixos/modules/myFlake/boot.nix +++ b/nixos/modules/my/boot.nix @@ -3,14 +3,12 @@ lib, ... }: let - cfg = config.myFlake.boot; + cfg = config.my.boot; in { options = { - myFlake = { - boot = { - silentBoot = lib.mkEnableOption "Whether to enable silent boot."; - noLoaderMenu = lib.mkEnableOption "Whether to disable bootloader menu."; - }; + my.boot = { + silentBoot = lib.mkEnableOption "silent boot"; + noLoaderMenu = lib.mkEnableOption "" // {description = "Whether to disable bootloader menu.";}; }; }; diff --git a/nixos/modules/my/hardware/audio.nix b/nixos/modules/my/hardware/audio.nix new file mode 100644 index 0000000..85f77fc --- /dev/null +++ b/nixos/modules/my/hardware/audio.nix @@ -0,0 +1,24 @@ +{ + lib, + config, + ... +}: let + cfg = config.my.hardware.audio; +in { + options = { + my.hardware.audio.enable = lib.mkEnableOption "audio"; + }; + + # https://nixos.wiki/wiki/PipeWire + config = lib.mkIf cfg.enable { + security.rtkit.enable = true; + hardware.pulseaudio.enable = false; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + jack.enable = true; + }; + }; +} diff --git a/nixos/modules/myFlake/hardware/components/bluetooth.nix b/nixos/modules/my/hardware/bluetooth.nix similarity index 58% rename from nixos/modules/myFlake/hardware/components/bluetooth.nix rename to nixos/modules/my/hardware/bluetooth.nix index 120697b..274582f 100644 --- a/nixos/modules/myFlake/hardware/components/bluetooth.nix +++ b/nixos/modules/my/hardware/bluetooth.nix @@ -4,19 +4,15 @@ pkgs, ... }: let - cfg = config.myFlake.hardware.components.bluetooth; + cfg = config.my.hardware.bluetooth; in { options = { - myFlake.hardware.components.bluetooth.enable = lib.mkEnableOption "Whether to enable bluetooth."; + my.hardware.bluetooth.enable = lib.mkEnableOption "bluetooth"; }; # https://nixos.wiki/wiki/Bluetooth config = lib.mkIf cfg.enable { - # Bluetooth manager - #services.blueman.enable = true; environment.systemPackages = lib.mkIf config.services.xserver.enable (with pkgs; [blueberry]); - - # Bluetooth service hardware.bluetooth = { enable = true; settings.General.FastConnectable = true; diff --git a/nixos/modules/my/hardware/tpm.nix b/nixos/modules/my/hardware/tpm.nix new file mode 100644 index 0000000..54bcef9 --- /dev/null +++ b/nixos/modules/my/hardware/tpm.nix @@ -0,0 +1,20 @@ +{ + lib, + config, + ... +}: let + cfg = config.my.hardware.tpm; +in { + options = { + my.hardware.tpm.enable = lib.mkEnableOption "TPM"; + }; + + # https://nixos.wiki/wiki/TPM + config = lib.mkIf cfg.enable { + security.tpm2 = { + enable = true; + pkcs11.enable = true; + tctiEnvironment.enable = true; + }; + }; +} diff --git a/nixos/modules/myFlake/hardware/accessories/logitech-wireless.nix b/nixos/modules/myFlake/hardware/accessories/logitech-wireless.nix deleted file mode 100644 index 47e85e3..0000000 --- a/nixos/modules/myFlake/hardware/accessories/logitech-wireless.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ - lib, - config, - ... -}: let - cfg = config.myFlake.hardware.accessories.logitech-wireless; -in { - options = { - myFlake.hardware.accessories.logitech-wireless.enable = - lib.mkEnableOption "Whether to enable support for wireless Logitech hardwares."; - }; - - config = lib.mkIf cfg.enable { - hardware.logitech.wireless = { - enable = true; - enableGraphical = true; - }; - }; -} diff --git a/nixos/modules/myFlake/hardware/accessories/piper.nix b/nixos/modules/myFlake/hardware/accessories/piper.nix deleted file mode 100644 index 05b88ac..0000000 --- a/nixos/modules/myFlake/hardware/accessories/piper.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ - lib, - config, - pkgs, - ... -}: let - cfg = config.myFlake.hardware.accessories.piper; -in { - options = { - myFlake.hardware.accessories.piper.enable = - lib.mkEnableOption "Whether to enable Piper."; - }; - - config = lib.mkIf cfg.enable { - environment.systemPackages = [pkgs.piper]; - services.ratbagd.enable = true; - }; -} diff --git a/nixos/modules/myFlake/hardware/accessories/xbox-one-controller.nix b/nixos/modules/myFlake/hardware/accessories/xbox-one-controller.nix deleted file mode 100644 index 3e1ae52..0000000 --- a/nixos/modules/myFlake/hardware/accessories/xbox-one-controller.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ - lib, - config, - ... -}: let - cfg = config.myFlake.hardware.accessories.xboxOneController; -in { - options = { - myFlake.hardware.accessories.xboxOneController.enable = - lib.mkEnableOption "Whether to enable support for Xbox One controllers."; - }; - - # https://wiki.archlinux.org/title/Gamepad#Connect_Xbox_Wireless_Controller_with_Bluetooth - config = lib.mkIf cfg.enable { - hardware.xone.enable = true; # via wired or wireless dongle - hardware.xpadneo.enable = true; # via Bluetooth - }; -} diff --git a/nixos/modules/myFlake/hardware/components/audio.nix b/nixos/modules/myFlake/hardware/components/audio.nix deleted file mode 100644 index 8cc21d6..0000000 --- a/nixos/modules/myFlake/hardware/components/audio.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ - lib, - config, - ... -}: let - cfg = config.myFlake.hardware.components.audio; -in { - options = { - myFlake.hardware.components.audio.enable = lib.mkEnableOption "Whether to enable audio."; - myFlake.hardware.components.audio.soundServer = lib.mkOption { - type = lib.types.enum ["pipewire" "pulseaudio"]; - default = "pipewire"; - example = "pulseaudio"; - description = "Select desired sound system."; - }; - }; - - # https://nixos.wiki/wiki/PipeWire - # https://nixos.wiki/wiki/PulseAudio - config = lib.mkIf cfg.enable (lib.mkMerge [ - (lib.mkIf (cfg.soundServer == "pipewire") { - security.rtkit.enable = true; - hardware.pulseaudio.enable = false; - services.pipewire = { - enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - jack.enable = true; - }; - }) - (lib.mkIf (cfg.soundServer == "pulseaudio") { - hardware.pulseaudio.enable = true; - hardware.pulseaudio.support32Bit = true; - }) - ]); -} diff --git a/nixos/modules/myFlake/hardware/components/tpm.nix b/nixos/modules/myFlake/hardware/components/tpm.nix deleted file mode 100644 index 9c7af6a..0000000 --- a/nixos/modules/myFlake/hardware/components/tpm.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ - lib, - config, - ... -}: let - cfg = config.myFlake.hardware.components.tpm; -in { - options = { - myFlake.hardware.components.tpm.enable = lib.mkEnableOption "Whether to enable TPM."; - }; - - # https://nixos.wiki/wiki/TPM - config = lib.mkIf cfg.enable { - # TPM is currently broken on latest kernel, - # but luckily, linux-zen have a patch for it - # UPDATE: it got fixed in 6.5.3 - # - # python3.11-tpm2-pytss-2.1.0 failed with exit code 1 after ⏱ 34s - security.tpm2 = { - enable = true; - #pkcs11.enable = true; # expose /run/current-system/sw/lib/libtpm2_pkcs11.so - tctiEnvironment.enable = true; # tpm2tools_tcti and tpm2_pkcs11_tcti env variables - }; - }; -} diff --git a/nixos/profiles/common/graphical/default.nix b/nixos/profiles/common/graphical/default.nix index 9a8fcd7..17ed1a6 100644 --- a/nixos/profiles/common/graphical/default.nix +++ b/nixos/profiles/common/graphical/default.nix @@ -37,7 +37,7 @@ }; ### Options - myFlake.boot.noLoaderMenu = lib.mkDefault true; + my.boot.noLoaderMenu = lib.mkDefault true; fonts.enableDefaultPackages = false; security.pam.services.swaylock = {}; diff --git a/nixos/profiles/common/opt-in/gaming/default.nix b/nixos/profiles/common/opt-in/gaming/default.nix index 0f151b8..c3e7ff1 100644 --- a/nixos/profiles/common/opt-in/gaming/default.nix +++ b/nixos/profiles/common/opt-in/gaming/default.nix @@ -11,7 +11,9 @@ # https://github.com/NixOS/nixpkgs/issues/47932 hardware.opengl.driSupport32Bit = true; - myFlake.hardware.accessories.xboxOneController.enable = lib.mkDefault true; + # https://wiki.archlinux.org/title/Gamepad#Connect_Xbox_Wireless_Controller_with_Bluetooth + hardware.xone.enable = true; # via wired or wireless dongle + hardware.xpadneo.enable = true; # via Bluetooth programs.gamemode = { enable = true; @@ -23,7 +25,6 @@ # Integrate with NVIDIA Optimus offloading. # https://github.com/FeralInteractive/gamemode#note-for-hybrid-gpu-users - # https://github.com/NixOS/nixpkgs/pull/273177 environment.sessionVariables = { "GAMEMODERUNEXEC" = let inherit (config.hardware.nvidia.prime) offload;