Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
235 lines (224 loc) · 8.57 KB
/
Copy pathflake.nix
File metadata and controls
235 lines (224 loc) · 8.57 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
{
description = "Spotify, native and fast";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# rust-toolchain.toml pins the compiler so local builds and CI agree.
# This reads that file rather than restating the version here.
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
rust-overlay,
...
}:
let
systems = [
"aarch64-darwin"
"x86_64-darwin"
"aarch64-linux"
"x86_64-linux"
];
forAllSystems =
f:
nixpkgs.lib.genAttrs systems (
system:
f (
import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
}
)
);
in
{
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
packages =
with pkgs;
[
(rust-bin.fromRustupToolchainFile ./rust-toolchain.toml)
rust-analyzer
pkg-config
# libprojectM (MilkDrop) is built from source by CMake, and its
# bindings by bindgen, which needs libclang.
cmake
rustPlatform.bindgenHook
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
apple-sdk
]
++ lib.optionals stdenv.hostPlatform.isLinux [
dbus
alsa-lib
libpulseaudio
libxkbcommon
wayland
libGL
libx11
libxcursor
libxi
libxrandr
];
# The GUI dlopens its Wayland, X11 and GL libraries at run time.
LD_LIBRARY_PATH = pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isLinux (
pkgs.lib.makeLibraryPath (
with pkgs;
[
dbus
libxkbcommon
wayland
libGL
libx11
libxcursor
libxi
libxrandr
]
)
);
};
});
packages = forAllSystems (
pkgs:
let
spotifast =
let
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
rustPlatform = pkgs.makeRustPlatform {
cargo = toolchain;
rustc = toolchain;
};
runtimeLibs = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux (
with pkgs;
[
dbus
libxkbcommon
wayland
libGL
libx11
libxcursor
libxi
libxrandr
]
);
in
rustPlatform.buildRustPackage rec {
pname = "spotifast";
version = (pkgs.lib.importTOML ./Cargo.toml).package.version;
src = self;
# The lock file contains git dependencies. fetchCargoVendor includes
# them in the fixed-output dependency tree, unlike cargoLock alone.
cargoDeps = pkgs.rustPlatform.fetchCargoVendor {
pname = "spotifast";
version = (pkgs.lib.importTOML ./Cargo.toml).package.version;
src = self;
hash = "sha256-a101gT1F5JpPEG3V6cIYxjOXP+rIUOM7iP6saCHHZHo=";
};
# projectm-sys only searches lib, while CMake may otherwise install to lib64.
postPatch = ''
substituteInPlace "$cargoDepsCopy"/source-git-*/projectm-sys-*/build.rs \
--replace-fail \
'.define("BUILD_SHARED_LIBS", build_shared_libs)' \
'.define("CMAKE_INSTALL_LIBDIR", "lib").define("BUILD_SHARED_LIBS", build_shared_libs)'
'';
nativeBuildInputs =
with pkgs;
[
pkg-config
# libprojectM (MilkDrop) is built from source by CMake, and
# its bindings by bindgen, which needs libclang.
cmake
rustPlatform.bindgenHook
]
++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [ makeWrapper ]
++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isDarwin [
rcodesign
icnsify
];
# The command-alias regression starts its own bus, isolated from
# the listener's desktop and running application.
nativeCheckInputs = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [ pkgs.dbus ];
buildInputs =
pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux (
with pkgs;
[
alsa-lib
libpulseaudio
# libprojectM links OpenGL directly and its GL loader needs
# X11 headers while it is built.
libGL
libx11
]
)
++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isDarwin [ pkgs.apple-sdk ];
# Nix's Rust check hook deliberately points SSL_CERT_FILE at a
# missing path. The librespot proxy regression test constructs a
# TLS connector before asserting its CONNECT request, so give the
# test an explicit, sandboxed trust store.
preCheck = ''
export SSL_CERT_FILE="${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
'';
# The GUI dlopens its Wayland, X11 and GL libraries at run time.
postFixup =
pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isLinux ''
wrapProgram $out/bin/fastpotify \
--prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath runtimeLibs}
wrapProgram $out/bin/spotifast \
--prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath runtimeLibs}
''
+ pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isDarwin ''
rcodesign sign "$out/Applications/Spotifast.app"
'';
postInstall =
pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isLinux ''
install -Dm644 packaging/applications/spotifast.desktop \
$out/share/applications/spotifast.desktop
install -Dm644 packaging/icons/spotifast.svg \
$out/share/icons/hicolor/scalable/apps/spotifast.svg
install -Dm644 contrib/omarchy/spotifast.json.tpl \
$out/share/spotifast/omarchy/spotifast.json.tpl
install -Dm755 contrib/omarchy/spotifast-theme \
$out/share/spotifast/omarchy/spotifast-theme
''
+ pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isDarwin ''
app="$out/Applications/Spotifast.app/Contents"
mkdir -p "$app/MacOS" "$app/Resources"
executable=Spotifast
identifier=rocks.spotifast.Spotifast
if [ "${version}" = "0.9.1" ]; then
executable=fastpotify
identifier=me.paolino.fastpotify
fi
cp "$out/bin/spotifast" "$app/MacOS/$executable"
icnsify packaging/macos/icon-1024.png -o "$app/Resources/spotifast.icns"
substitute packaging/macos/Info.plist "$app/Info.plist" \
--replace-fail __VERSION__ "${version}" \
--replace-fail __BUILD__ "${pkgs.lib.head (pkgs.lib.splitString "-" version)}" \
--replace-fail __EXECUTABLE__ "$executable" \
--replace-fail __IDENTIFIER__ "$identifier"
'';
meta = {
description = "Fast native Spotify client with local playback and Spotify Connect";
homepage = "https://spotifast.rocks";
license = pkgs.lib.licenses.mit;
mainProgram = "spotifast";
};
};
in
{
default = spotifast;
inherit spotifast;
fastpotify = spotifast;
}
// pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isDarwin {
fastpotify-app = spotifast;
spotifast-app = spotifast;
}
);
formatter = forAllSystems (pkgs: pkgs.nixfmt-tree);
};
}