-
Notifications
You must be signed in to change notification settings - Fork 37
/
package.nix
122 lines (109 loc) · 3.88 KB
/
package.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
{
pkgs ? import <nixpkgs> {},
theme ? "SpicetifyDefault",
colorScheme ? "",
thirdParyThemes ? {},
thirdParyExtensions ? {},
thirdParyCustomApps ? {},
enabledExtensions ? [],
enabledCustomApps ? [],
spotifyLaunchFlags ? "",
injectCss ? false,
replaceColors ? false,
overwriteAssets ? false,
disableSentry ? true,
disableUiLogging ? true,
removeRtlRule ? true,
exposeApis ? true,
disableUpgradeCheck ? true,
fastUserSwitching ? false,
visualizationHighFramerate ? false,
radio ? false,
songPage ? false,
experimentalFeatures ? false,
home ? false,
lyricAlwaysShow ? false,
lyricForceNoSync ? false
}:
let
inherit (pkgs.lib.lists) foldr;
inherit (pkgs.lib.attrsets) mapAttrsToList;
# Helper functions
pipeConcat = foldr (a: b: a + "|" + b) "";
lineBreakConcat = foldr (a: b: a + "\n" + b) "";
boolToString = x: if x then "1" else "0";
makeLnCommands = type: (mapAttrsToList (name: path: "ln -sf ${path} ./${type}/${name}"));
# Setup spicetify
spicetifyPkg = pkgs.callPackage ./spicetify.nix {};
spicetify = "SPICETIFY_CONFIG=. ${spicetifyPkg}/spicetify";
themes = import ./themes-src.nix;
# Dribblish is a theme which needs a couple extra settings
isDribblish = theme == "Dribbblish";
extraCommands = (if isDribblish then "cp ./Themes/Dribbblish/dribbblish.js ./Extensions \n" else "")
+ (lineBreakConcat (makeLnCommands "Themes" thirdParyThemes))
+ (lineBreakConcat (makeLnCommands "Extensions" thirdParyExtensions))
+ (lineBreakConcat (makeLnCommands "CustomApps" thirdParyCustomApps));
customAppsFixupCommands = lineBreakConcat (makeLnCommands "Apps" thirdParyCustomApps);
injectCssOrDribblish = boolToString (isDribblish || injectCss);
replaceColorsOrDribblish = boolToString (isDribblish || replaceColors);
overwriteAssetsOrDribblish = boolToString (isDribblish || overwriteAssets);
extensionString = pipeConcat ((if isDribblish then [ "dribbblish.js" ] else []) ++ enabledExtensions);
customAppsString = pipeConcat enabledCustomApps;
in
pkgs.spotify-unwrapped.overrideAttrs (oldAttrs: rec {
postInstall=''
touch $out/prefs
mkdir Themes
mkdir Extensions
mkdir CustomApps
find ${themes} -maxdepth 1 -type d -exec ln -s {} Themes \;
${extraCommands}
${spicetify} config \
spotify_path "$out/share/spotify" \
prefs_path "$out/prefs" \
current_theme ${theme} \
${if
colorScheme != ""
then
''color_scheme "${colorScheme}" \''
else
''\'' }
${if
extensionString != ""
then
''extensions "${extensionString}" \''
else
''\'' }
${if
customAppsString != ""
then
''custom_apps "${customAppsString}" \''
else
''\'' }
${if
spotifyLaunchFlags != ""
then
''spotify_launch_flags "${spotifyLaunchFlags}" \''
else
''\'' }
inject_css ${injectCssOrDribblish} \
replace_colors ${replaceColorsOrDribblish} \
overwrite_assets ${overwriteAssetsOrDribblish} \
disable_sentry ${boolToString disableSentry } \
disable_ui_logging ${boolToString disableUiLogging } \
remove_rtl_rule ${boolToString removeRtlRule } \
expose_apis ${boolToString exposeApis } \
disable_upgrade_check ${boolToString disableUpgradeCheck } \
fastUser_switching ${boolToString fastUserSwitching } \
visualization_high_framerate ${boolToString visualizationHighFramerate } \
radio ${boolToString radio } \
song_page ${boolToString songPage } \
experimental_features ${boolToString experimentalFeatures } \
home ${boolToString home } \
lyric_always_show ${boolToString lyricAlwaysShow } \
lyric_force_no_sync ${boolToString lyricForceNoSync }
${spicetify} backup apply
cd $out/share/spotify
${customAppsFixupCommands}
'';
})