nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 ags,
4 astal,
5 dart-sass,
6 fzf,
7 gjs,
8 gnused,
9 gobject-introspection,
10 gtk3,
11 gtk4-layer-shell,
12 stdenvNoCC,
13 wrapGAppsHook3,
14 wrapGAppsHook4,
15}:
16{
17 entry ? "app.ts",
18 dependencies ? [ ],
19 enableGtk4 ? false,
20 ...
21}@attrs:
22stdenvNoCC.mkDerivation (
23 finalAttrs:
24 attrs
25 // {
26 nativeBuildInputs = (attrs.nativeBuildInputs or [ ]) ++ [
27 (ags.override { extraPackages = dependencies; })
28 gnused
29 gobject-introspection
30 (if enableGtk4 then wrapGAppsHook4 else wrapGAppsHook3)
31 ];
32
33 buildInputs =
34 (attrs.buildInputs or [ ])
35 ++ dependencies
36 ++ [
37 gjs
38 astal.astal4
39 astal.astal3
40 astal.io
41 ];
42
43 preFixup = ''
44 gappsWrapperArgs+=(
45 --prefix PATH : ${
46 lib.makeBinPath (
47 dependencies
48 ++ [
49 dart-sass
50 fzf
51 gtk3
52 ]
53 )
54 }
55 )
56 ''
57 + lib.optionalString enableGtk4 ''
58 gappsWrapperArgs+=(
59 --set LD_PRELOAD "${gtk4-layer-shell}/lib/libgtk4-layer-shell.so"
60 )
61 ''
62 + (attrs.preFixup or "");
63
64 installPhase =
65 let
66 outBin = "$out/bin/${finalAttrs.pname}";
67 in
68 # bash
69 ''
70 runHook preInstall
71
72 mkdir -p "$out/bin" "$out/share"
73 cp -r ./* "$out/share"
74 ags bundle "${entry}" "${outBin}" -d "SRC='$out/share'"
75
76 chmod +x "${outBin}"
77
78 if ! head -n 1 "${outBin}" | grep -q "^#!"; then
79 sed -i '1i #!${gjs}/bin/gjs -m' "${outBin}"
80 fi
81
82 runHook postInstall
83 '';
84 }
85)