-
Notifications
You must be signed in to change notification settings - Fork 44
/
generic.nix
141 lines (109 loc) · 2.83 KB
/
generic.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
{ version, hash, npmHash }:
{ lib
, stdenv
, fetchFromGitHub
, nodePackages
, nodejs
, cacert
, python3
, psmisc
}:
let
src = fetchFromGitHub {
owner = "SteamDeckHomebrew";
repo = "decky-loader";
rev = "v${version}";
inherit hash;
};
frontendDeps = stdenv.mkDerivation {
name = "decky-loader-frontend-deps-${version}.tar.gz";
inherit src;
nativeBuildInputs = [ nodePackages.pnpm ];
dontConfigure = true;
buildPhase = ''
runHook preBuild
export SOURCE_DATE_EPOCH=1
export NODE_EXTRA_CA_CERTS="${cacert}/etc/ssl/certs/ca-bundle.crt"
cd frontend
pnpm i --ignore-scripts --ignore-pnpmfile --frozen-lockfile --node-linker=hoisted
runHook postBuild
'';
installPhase = ''
runHook preInstall
rm node_modules/.modules.yaml
tar -czf $out --owner=0 --group=0 --numeric-owner --format=gnu \
--mtime="@$SOURCE_DATE_EPOCH" --sort=name --hard-dereference \
node_modules
runHook postInstall
'';
outputHashMode = "flat";
outputHashAlgo = "sha256";
outputHash = npmHash;
};
frontend = stdenv.mkDerivation {
pname = "decky-loader-frontend";
inherit version src;
nativeBuildInputs = [ nodejs nodePackages.pnpm ];
dontConfigure = true;
buildPhase = ''
runHook preBuild
pushd frontend
tar xf ${frontendDeps}
patchShebangs --build node_modules
pnpm build
popd
runHook postBuild
'';
installPhase = ''
runHook preInstall
cp -r backend/static $out
runHook postInstall
'';
};
pythonEnv = python3.withPackages (py: with py; [
aiohttp
aiohttp-jinja2
aiohttp-cors
watchdog
certifi
click # shotty
]);
loader = stdenv.mkDerivation {
pname = "decky-loader";
inherit version src;
patches = [
# hacks to make Decky behave on NixOS
./jovian.patch
];
buildInputs = [ pythonEnv ];
dontConfigure = true;
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out/lib
cp -r backend $out/lib/decky-loader
cp -r plugin $out/lib/decky-loader/
ln -s ${frontend} $out/lib/decky-loader/static
mkdir $out/bin
cat << EOF >$out/bin/decky-loader
#!/bin/sh
# psmisc used for killall
export PATH=${pythonEnv}/bin:${psmisc}/bin:\$PATH
export DECKY_VERSION=v${version}
exec ${pythonEnv}/bin/python3 $out/lib/decky-loader/main.py
EOF
chmod +x $out/bin/decky-loader
runHook postInstall
'';
passthru = {
inherit frontendDeps;
python = python3;
};
meta = with lib; {
description = "A plugin loader for the Steam Deck";
homepage = "https://github.com/SteamDeckHomebrew/decky-loader";
platforms = platforms.linux;
license = licenses.gpl2Only;
};
};
in loader