1{
2 pnpm_9,
3 nodejs,
4 stdenv,
5 clang,
6 buildGoModule,
7 fetchFromGitHub,
8 lib,
9 _experimental-update-script-combinators,
10 nix-update-script,
11}:
12
13let
14 pname = "daed";
15 version = "1.0.0";
16
17 src = fetchFromGitHub {
18 owner = "daeuniverse";
19 repo = "daed";
20 tag = "v${version}";
21 hash = "sha256-WaybToEcFrKOcJ+vfCTc9uyHkTPOrcAEw9lZFEIBPgY=";
22 fetchSubmodules = true;
23 };
24
25 web = stdenv.mkDerivation {
26 inherit pname version src;
27
28 pnpmDeps = pnpm_9.fetchDeps {
29 inherit pname version src;
30 fetcherVersion = 1;
31 hash = "sha256-+yLpSbDzr1OV/bmUUg6drOvK1ok3cBd+RRV7Qrrlp+Q=";
32 };
33
34 nativeBuildInputs = [
35 nodejs
36 pnpm_9.configHook
37 ];
38
39 buildPhase = ''
40 runHook preBuild
41
42 pnpm build
43
44 runHook postBuild
45 '';
46
47 installPhase = ''
48 runHook preInstall
49
50 cp -R dist $out
51
52 runHook postInstall
53 '';
54 };
55in
56
57buildGoModule rec {
58 inherit
59 pname
60 version
61 src
62 web
63 ;
64
65 sourceRoot = "${src.name}/wing";
66
67 vendorHash = "sha256-+uf8PJQvsJMUyQ6W+nDfdwrxBO2YRUL328ajTJpVDZk=";
68
69 proxyVendor = true;
70
71 nativeBuildInputs = [ clang ];
72
73 hardeningDisable = [ "zerocallusedregs" ];
74
75 prePatch = ''
76 substituteInPlace Makefile \
77 --replace-fail /bin/bash /bin/sh
78
79 # ${web} does not have write permission
80 mkdir dist
81 cp -r ${web}/* dist
82 chmod -R 755 dist
83 '';
84
85 buildPhase = ''
86 runHook preBuild
87
88 make CFLAGS="-D__REMOVE_BPF_PRINTK -fno-stack-protector -Wno-unused-command-line-argument" \
89 NOSTRIP=y \
90 WEB_DIST=dist \
91 AppName=${pname} \
92 VERSION=${version} \
93 OUTPUT=$out/bin/daed \
94 bundle
95
96 runHook postBuild
97 '';
98
99 postInstall = ''
100 install -Dm444 $src/install/daed.service -t $out/lib/systemd/system
101 substituteInPlace $out/lib/systemd/system/daed.service \
102 --replace-fail /usr/bin $out/bin
103 '';
104
105 passthru.updateScript = _experimental-update-script-combinators.sequence [
106 (nix-update-script {
107 attrPath = "daed.web";
108 })
109 (nix-update-script {
110 extraArgs = [ "--version=skip" ];
111 })
112 ];
113
114 meta = {
115 description = "Modern dashboard with dae";
116 homepage = "https://github.com/daeuniverse/daed";
117 license = lib.licenses.mit;
118 maintainers = with lib.maintainers; [ oluceps ];
119 platforms = lib.platforms.linux;
120 mainProgram = "daed";
121 };
122}