-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathdefault.nix
116 lines (115 loc) · 2.5 KB
/
default.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
{
rustPlatform,
pkg-config,
cmake,
rust,
alsa-lib,
xorg,
pango,
glib,
cairo,
mkShellNoCC,
rust-analyzer-unwrapped,
rust-bin,
lib,
withGui ? true,
withCli ? true,
}:
assert withGui || withCli; let
buildInputs =
[
alsa-lib
]
++ (lib.lists.optionals withGui [
xorg.libXft
xorg.libXext
xorg.libXinerama
xorg.libXcursor
xorg.libXfixes
cairo
pango
glib
]);
nativeBuildInputs = [
pkg-config
cmake
];
rust = rust-bin.stable.latest.default;
pname =
if withGui && withCli
then "swyh-rs"
else if withGui
then "swyh-rs-gui"
else "swyh-rs-cli";
swyh-rs = rustPlatform.buildRustPackage rec {
version = "1.12.4";
inherit nativeBuildInputs buildInputs pname;
# Filter-out generated, version-control and nix-related files to prevent
# cache invalidation while editing them
src = lib.cleanSourceWith {
filter = path: type:
with builtins; let
bn = baseNameOf path;
in
(!lib.hasSuffix ".nix" bn) && bn != "flake.lock";
src = lib.cleanSource ./.;
};
cargoLock.lockFile = ./Cargo.lock;
buildNoDefaultFeatures = true;
buildPhase =
''
runHook preBuild
safePostBuildHooks=("''${postBuildHooks[@]}")
postBuildHooks=()
preBuildHooks=()
''
+ (lib.optionalString withGui ''
cargoBuildFeatures="gui"
cargoBuildHook
'')
+ (lib.optionalString withCli ''
cargoBuildFeatures="cli"
cargoBuildHook
'')
+ ''
postBuildHooks=("''${safePostBuildHooks[@]}")
runHook postBuild
'';
postInstall =
if withGui
then ''
mv $out/bin/swyh-rs $out/bin/swyh-rs-gui
ln -s swyh-rs-gui $out/bin/swyh-rs
''
else ''
ln -s swyh-rs-cli $out/bin/swyh-rs
'';
meta = with lib; {
description = "Stream What You Hear written in rust, inspired by SWYH";
homepage = "https://github.com/dheijl/swyh-rs";
license = licenses.mit;
maintainers = [
{
name = "Yury Shvedov";
email = "mestofel13@gmail.com";
github = "ein-shved";
githubId = 3513222;
}
];
};
};
devShell = mkShellNoCC {
buildInputs =
[
rust
rust-analyzer-unwrapped
]
++ buildInputs
++ nativeBuildInputs;
RUST_SRC_PATH = "${rust}/lib/rustlib/src/rust/library";
};
in
swyh-rs
// {
inherit devShell;
}