146 lines
3.8 KiB
Nix
146 lines
3.8 KiB
Nix
{
|
|
user ? throw "user argument is required",
|
|
home ? throw "home argument is required",
|
|
}:
|
|
{
|
|
config,
|
|
inputs,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
{
|
|
networking.firewall = {
|
|
allowedTCPPorts = [ 57621 ];
|
|
allowedUDPPorts = [ 5353 ];
|
|
};
|
|
|
|
environment.persistence = {
|
|
"/persist"."${home}/.config/spotify" = { };
|
|
"/cache"."${home}/.cache/spotify" = { };
|
|
};
|
|
|
|
home-manager.users.${user} = {
|
|
imports = [ inputs.spicetify-nix.homeManagerModules.default ];
|
|
|
|
programs.spicetify =
|
|
let
|
|
spicePkgs = inputs.spicetify-nix.legacyPackages.${pkgs.system};
|
|
in
|
|
{
|
|
enable = true;
|
|
|
|
spicetifyPackage = pkgs.spicetify-cli.overrideAttrs (oldAttrs: {
|
|
patches = oldAttrs.patches or [ ] ++ [ ./user-colors.patch ];
|
|
});
|
|
|
|
theme = spicePkgs.themes.sleek // {
|
|
extraCommands = ''
|
|
export COLORS_CSS_PATH="${home}/.config/spotify/colors.css"
|
|
'';
|
|
|
|
additionalCss = ''
|
|
.main-topBar-topbarContentRight button {
|
|
background-color: unset !important;
|
|
}
|
|
'';
|
|
};
|
|
|
|
enabledExtensions = with spicePkgs.extensions; [
|
|
loopyLoop
|
|
trashbin
|
|
fullAlbumDate
|
|
phraseToPlaylist
|
|
songStats
|
|
copyToClipboard
|
|
betterGenres
|
|
adblock
|
|
autoSkip
|
|
];
|
|
};
|
|
|
|
systemd.user = {
|
|
services =
|
|
let
|
|
merge = lib.meta.getExe (
|
|
pkgs.writeShellApplication {
|
|
name = "merge";
|
|
runtimeInputs = with pkgs; [
|
|
gnugrep
|
|
coreutils
|
|
];
|
|
text = builtins.readFile ./config/merge.sh;
|
|
}
|
|
);
|
|
in
|
|
{
|
|
spotify-init = {
|
|
Unit = {
|
|
Description = "Populate Spotify preferences from template";
|
|
After = config.environment.persistence."/persist"."${home}/.config/spotify".mount;
|
|
DefaultDependencies = false;
|
|
};
|
|
|
|
Service = {
|
|
ExecStart = "${merge} ${./config/prefs} ${home}/.config/spotify/prefs";
|
|
Type = "oneshot";
|
|
RemainAfterExit = true;
|
|
};
|
|
};
|
|
|
|
spotify-init-user = {
|
|
Unit = {
|
|
Description = "Populate Spotify user preferences from template";
|
|
After = config.environment.persistence."/persist"."${home}/.config/spotify".mount;
|
|
DefaultDependencies = false;
|
|
};
|
|
|
|
Service = {
|
|
ExecStart = lib.meta.getExe (
|
|
pkgs.writeShellApplication {
|
|
name = "merge-user";
|
|
text = ''
|
|
for USER_DIR in ${home}/.config/spotify/Users/*/; do
|
|
${merge} ${./config/user-prefs} "$USER_DIR/prefs"
|
|
done
|
|
'';
|
|
}
|
|
);
|
|
Type = "oneshot";
|
|
RemainAfterExit = true;
|
|
};
|
|
};
|
|
};
|
|
|
|
paths = {
|
|
spotify-init = {
|
|
Unit = {
|
|
Description = "Monitor Spotify directory";
|
|
After = config.environment.persistence."/persist"."${home}/.config/spotify".mount;
|
|
};
|
|
|
|
Path.PathExists = "${home}/.config/spotify";
|
|
|
|
Install.WantedBy = [ "graphical-session.target" ];
|
|
};
|
|
|
|
spotify-init-user = {
|
|
Unit = {
|
|
Description = "Monitor Spotify user directory";
|
|
After = config.environment.persistence."/persist"."${home}/.config/spotify".mount;
|
|
};
|
|
|
|
Path = {
|
|
PathExists = "${home}/.config/spotify/Users";
|
|
PathModified = "${home}/.config/spotify/Users";
|
|
};
|
|
|
|
Install.WantedBy = [ "graphical-session.target" ];
|
|
};
|
|
};
|
|
};
|
|
|
|
theme.template."${home}/.config/spotify/colors.css".source = ./colors.css;
|
|
};
|
|
}
|