1{
2 lib,
3 astal,
4 blueprint-compiler,
5 buildGoModule,
6 callPackage,
7 dart-sass,
8 symlinkJoin,
9 fetchFromGitHub,
10 gjs,
11 glib,
12 gobject-introspection,
13 gtk4-layer-shell,
14 installShellFiles,
15 nix-update-script,
16 nodejs,
17 stdenv,
18 wrapGAppsHook3,
19
20 extraPackages ? [ ],
21}:
22buildGoModule rec {
23 pname = "ags";
24 version = "2.3.0";
25
26 src = fetchFromGitHub {
27 owner = "Aylur";
28 repo = "ags";
29 tag = "v${version}";
30 hash = "sha256-GLyNtU9A2VN22jNRHZ2OXuFfTJLh8uEVVt+ftsKUX0c=";
31 };
32
33 vendorHash = "sha256-Pw6UNT5YkDVz4HcH7b5LfOg+K3ohrBGPGB9wYGAQ9F4=";
34 proxyVendor = true;
35
36 ldflags = [
37 "-s"
38 "-w"
39 "-X main.astalGjs=${astal.gjs}/share/astal/gjs"
40 "-X main.gtk4LayerShell=${gtk4-layer-shell}/lib/libgtk4-layer-shell.so"
41 ];
42
43 nativeBuildInputs = [
44 wrapGAppsHook3
45 gobject-introspection
46 installShellFiles
47 ];
48
49 buildInputs = extraPackages ++ [
50 glib
51 astal.io
52 astal.astal3
53 astal.astal4
54 gobject-introspection # needed for type generation
55 ];
56
57 preFixup =
58 let
59 # git files are usually in `dev` output.
60 # `propagatedBuildInputs` are also available in the gjs runtime
61 # so we also want to generate types for these.
62 depsOf = pkg: [ (pkg.dev or pkg) ] ++ (map depsOf (pkg.propagatedBuildInputs or [ ]));
63 girDirs = symlinkJoin {
64 name = "gir-dirs";
65 paths = lib.flatten (map depsOf buildInputs);
66 };
67 in
68 ''
69 gappsWrapperArgs+=(
70 --prefix EXTRA_GIR_DIRS : "${girDirs}/share/gir-1.0"
71 --prefix PATH : "${
72 lib.makeBinPath (
73 [
74 gjs
75 nodejs
76 dart-sass
77 blueprint-compiler
78 astal.io
79 ]
80 ++ extraPackages
81 )
82 }"
83 )
84 '';
85
86 postInstall =
87 lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform)
88 # bash
89 ''
90 installShellCompletion \
91 --cmd ags \
92 --bash <($out/bin/ags completion bash) \
93 --fish <($out/bin/ags completion fish) \
94 --zsh <($out/bin/ags completion zsh)
95 '';
96
97 passthru = {
98 bundle = callPackage ./bundle.nix { };
99 updateScript = nix-update-script { };
100 };
101
102 meta = {
103 description = "Scaffolding CLI for Astal widget system";
104 homepage = "https://github.com/Aylur/ags";
105 changelog = "https://github.com/Aylur/ags/releases/tag/v${version}";
106 license = lib.licenses.gpl3Plus;
107 maintainers = with lib.maintainers; [
108 foo-dogsquared
109 johnrtitor
110 perchun
111 ];
112 mainProgram = "ags";
113 platforms = lib.platforms.linux;
114 };
115}