-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathdefault.nix
More file actions
108 lines (94 loc) · 2.67 KB
/
default.nix
File metadata and controls
108 lines (94 loc) · 2.67 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
{
src ? ./.,
lib,
yarnConfigHook,
yarnBuildHook,
fetchYarnDeps,
fetchFromGitHub,
cmake,
pkg-config,
ruby,
makeWrapper,
clangStdenv,
nodejs,
electron,
fmt_11,
yaml-cpp,
hidapi,
ssco,
scope_guard,
}:
clangStdenv.mkDerivation {
name = "nudelta";
inherit src;
nativeBuildInputs = [
yarnConfigHook
cmake
pkg-config
ruby
makeWrapper
];
buildInputs = [fmt_11 yaml-cpp hidapi ssco scope_guard];
dontUseCmakeConfigure = true;
packageJSON = ./package.json;
yarnLock = ./yarn.lock;
offlineCache = fetchYarnDeps {
yarnLock = ./yarn.lock;
hash = "sha256-SyPGcKRaiA7OjS6nAflY0+jqoBn8YycdHPvnHkvlHsk=";
};
env =
{
NIX_CFLAGS_COMPILE = "-I${nodejs.dev}/include/node -I${hidapi}/include/hidapi";
}
// lib.optionalAttrs clangStdenv.isDarwin {
NIX_LDFLAGS = "-framework IOKit";
};
buildPhase = ''
runHook preBuild
substituteInPlace node_modules/cmake-js/lib/dist.js \
--replace-fail '!this.downloaded' 'false'
cp -R ${electron.dist} electron_dist
chmod -R u+w electron_dist
substituteInPlace node_modules/.bin/rollup \
--replace-fail "#!/usr/bin/env node" "#!${nodejs}/bin/node"
substituteInPlace node_modules/.bin/electron-builder \
--replace-fail "#!/usr/bin/env node" "#!${nodejs}/bin/node"
yarn build_native
yarn run rollup -c
yarn run electron-builder \
--dir \
-c.electronDist=electron_dist \
-c.electronVersion=${electron.version}
runHook postBuild
'';
installPhase =
''
runHook preInstall
mkdir -p $out/bin
cp -r build/nudelta-cli $out/bin/nudelta-cli
''
+ lib.optionalString clangStdenv.isDarwin ''
mkdir -p $out/Applications
cp -r dist/mac-*/nudelta.app $out/Applications
''
+ lib.optionalString clangStdenv.isLinux ''
mkdir -p "$out/share/nudelta"
cp -r dist/*-unpacked/{locales,resources{,.pak}} "$out/share/nudelta"
'';
postFixup =
lib.optionalString clangStdenv.isDarwin ''
makeWrapper $out/Applications/nudelta.app/Contents/MacOS/nudelta $out/bin/nudelta
''
+ lib.optionalString clangStdenv.isLinux ''
makeWrapper ${electron}/bin/electron $out/bin/nudelta \
--add-flags $out/share/nudelta/resources/app.asar \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true --wayland-text-input-version=3}}" \
--set-default ELECTRON_FORCE_IS_PACKAGED 1 \
--set-default ELECTRON_IS_DEV 0 \
--inherit-argv0
'';
meta = {
license = lib.licenses.gpl3Plus;
mainProgram = "nudelta";
};
}