Files
nix-flake/modules/features/applications/gui/spotify.nix
T

76 lines
3.2 KiB
Nix

{ inputs, self, ... }: let
spicetifyEnableOptionAttrs = { lib }: {
type = lib.types.bool;
description = "Whether to enable Spicetify, a modified version of Spotify that supports plugins and themes.";
default = false;
};
spicetifyThemeOptionAttrs = { pkgs, lib }: {
type = inputs.nixpkgs.lib.types.nullOr (inputs.nixpkgs.lib.types.enum (builtins.attrNames inputs.spicetify.legacyPackages.${pkgs.stdenv.hostPlatform.system}.themes));
description = "This option is used to select a theme for Spicetify to use, from the list of available packages themes.";
default = null;
};
in {
imports = [ (inputs.helpers.mkMirroredModulesFlakeModule "graphicsOptions" ({ lib, ... }: {
options.features.applications.gui.spotify.enable = lib.mkEnableOption "Spotify";
})) ];
flake.nixosModules.graphicsOptions = { lib, pkgs, ... }: {
options.features.applications.gui.spotify.spicetify = {
enable = inputs.helpers.mkRedundantOption "features.nixos.home-manager.enable" "true" (spicetifyEnableOptionAttrs { inherit lib; });
theme = inputs.helpers.mkRedundantOption "features.nixos.home-manager.enable" "true" (spicetifyThemeOptionAttrs { inherit pkgs lib; });
};
};
flake.nixosModules.graphics = { pkgs, config, lib, ... }: let
spicePkgs = inputs.spicetify.legacyPackages.${pkgs.stdenv.hostPlatform.system};
in {
config = lib.mkIf (config.features.applications.gui.spotify.enable) (inputs.helpers.mkIfElse (config.features.nixos.home-manager.enable) {
home-manager.users.grey.features.applications.gui.spotify = {
enable = lib.mkDefault true;
spicetify = lib.mkDefault config.features.applications.gui.spotify.spicetify;
};
} {
environment.systemPackages = [ pkgs.spotify ];
});
};
flake.homeModules.graphicsOptions = { lib, pkgs, ... }: {
options.features.applications.gui.spotify.spicetify = {
enable = lib.mkOption (spicetifyEnableOptionAttrs { inherit lib; });
theme = lib.mkOption (spicetifyThemeOptionAttrs { inherit pkgs lib; });
};
};
flake.homeModules.graphics = { pkgs, config, lib, ... }: let
spicePkgs = inputs.spicetify.legacyPackages.${pkgs.stdenv.hostPlatform.system};
in {
imports = [
inputs.spicetify.homeManagerModules.default
];
config = lib.mkIf (config.features.applications.gui.spotify.enable) {
home.packages = lib.mkIf (!config.features.applications.gui.spotify.spicetify.enable) [ pkgs.spotify ];
programs.spicetify = lib.mkIf (config.features.applications.gui.spotify.spicetify.enable) {
enable = true;
enabledExtensions = with spicePkgs.extensions; [
# hidePodcasts
];
enabledSnippets = with spicePkgs.snippets; [
spinningCdCoverArt
oneko
hideMiniPlayerButton
hideFullScreenButton
declutterNowPlayingBar
modernScrollbar
];
enabledCustomApps = with spicePkgs.apps; [
# marketplace
];
theme = lib.mkIf (config.features.applications.gui.spotify.spicetify.theme != null) spicePkgs.themes.${config.features.applications.gui.spotify.spicetify.theme};
windowManagerPatch = true;
};
};
};
}