diff --git a/default.nix b/default.nix index 4052599..2d153ce 100644 --- a/default.nix +++ b/default.nix @@ -45,6 +45,12 @@ in { description = "Email for git to use"; }; }; + + sound = mkOption { + type = types.bool; + default = false; + description = "whether to enable sound"; + }; }; imports = [ diff --git a/flake.lock b/flake.lock index e3fa255..49e99ac 100644 --- a/flake.lock +++ b/flake.lock @@ -16,6 +16,45 @@ "type": "github" } }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1709336216, + "narHash": "sha256-Dt/wOWeW6Sqm11Yh+2+t0dfEWxoMxGBvv3JpIocFl9E=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f7b3c975cf067e56e7cda6cb098ebe3fb4d74ca2", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nix-gaming": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1710551318, + "narHash": "sha256-s1fOcZdpMbPOTuyVpzvN8QXdxS/viYjQ6J+hTR8NGys=", + "owner": "fufexan", + "repo": "nix-gaming", + "rev": "8b46b34b574cd1e6a9a8ded392f5b2f97b1f46a2", + "type": "github" + }, + "original": { + "owner": "fufexan", + "repo": "nix-gaming", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1710451336, @@ -31,9 +70,28 @@ "type": "indirect" } }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1709237383, + "narHash": "sha256-cy6ArO4k5qTx+l5o+0mL9f5fa86tYUX3ozE1S+Txlds=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1536926ef5621b09bba54035ae2bb6d806d72ac8", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "flake-compat": "flake-compat", + "nix-gaming": "nix-gaming", "nixpkgs": "nixpkgs", "utils": "utils" } diff --git a/flake.nix b/flake.nix index 1af31cf..708bc09 100644 --- a/flake.nix +++ b/flake.nix @@ -8,9 +8,13 @@ }; utils.url = "github:numtide/flake-utils"; nixpkgs.url = "flake:nixpkgs/nixos-unstable"; + nix-gaming = { + url = "github:fufexan/nix-gaming"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, utils, nixpkgs, ... }: let + outputs = inputs @ { self, utils, nixpkgs, nix-gaming, ... }: let lib = nixpkgs.lib; system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; diff --git a/modules/sound.nix b/modules/sound.nix new file mode 100644 index 0000000..93d5bbb --- /dev/null +++ b/modules/sound.nix @@ -0,0 +1,28 @@ +{ inputs, pkgs, config, lib, ... }: let + cfg = config.grimmShared; +in { + imports = [ + inputs.nix-gaming.nixosModules.pipewireLowLatency + ]; + + config = with cfg; lib.mkIf (enable && sound) { + sound.enable = true; + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + jack.enable = true; # osu uses jack + lowLatency.enable = true; + systemWide = true; # required for spotifyd as spotifyd runs as the spotifyd user + }; + + environment.systemPackages = with pkgs; [ + pavucontrol + playerctl + pulseaudio + ]; + }; +}