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
142
143
144
145
146
147
148
149
150
|
pkgs: let
inherit (builtins) elem elemAt readFile replaceStrings splitVersion toJSON;
inherit (pkgs.lib) filterAttrs;
readVer = file: replaceStrings ["\n"] [""] (readFile file);
toTOML = (pkgs.formats.toml {}).generate;
docgen = pkgs.gi-docgen.overrideAttrs {
patches = [./gi-docgen.patch];
};
dependency = {
"GObject-2.0" = {
name = "GObject";
description = "The base type system library";
docs_url = "https://docs.gtk.org/gobject/";
};
"Gtk-3.0" = {
name = "Gtk";
description = "The GTK toolkit";
docs_url = "https://docs.gtk.org/gtk3/";
};
"Gtk-4.0" = {
name = "Gtk";
description = "The GTK toolkit";
docs_url = "https://docs.gtk.org/gtk4/";
};
"AstalIO-0.1" = {
name = "AstalIO";
description = "Astal Core library";
docs_url = "https://aylur.github.io/libastal/io";
};
"NM-1.0" = {
name = "NetworkManager";
description = "The standard Linux network configuration tool suite";
docs_url = "https://networkmanager.dev/docs/libnm/latest/";
};
"WP-0.5" = {
name = "WirePlumber";
description = "Modular session/policy manager for PipeWire";
docs_url = "https://pipewire.pages.freedesktop.org/wireplumber/";
};
};
urlmap = pkgs.writeText "urlmap" ''
baseURLs = ${toJSON [
["GLib" "https://docs.gtk.org/glib/"]
["GObject" "https://docs.gtk.org/gobject/"]
["Gio" "https://docs.gtk.org/gio/"]
["Gdk" "https://docs.gtk.org/gdk3/"]
["Gtk" "https://docs.gtk.org/gtk3/"]
["GdkPixbuf" "https://docs.gtk.org/gdk-pixbuf/"]
["AstalIO" "https://aylur.github.io/libastal/io"]
# FIXME: these are not gi-docgen generated, therefore links are broken
["NM" "https://networkmanager.dev/docs/libnm/latest/"]
["WP" "https://pipewire.pages.freedesktop.org/wireplumber/"]
]}
'';
in
{
src,
pname,
libname,
gir-suffix,
authors,
description,
dependencies ? [],
repo-path ? libname,
website-path ? libname,
nativeBuildInputs ? [],
packages ? [],
postUnpack ? "",
}: let
version = readVer "${src}/version";
ver = splitVersion version;
api-ver = "${elemAt ver 0}.${elemAt ver 1}";
girName = "Astal${gir-suffix}-${api-ver}";
in
pkgs.stdenv.mkDerivation {
inherit pname src version;
outputs = ["out" "dev" "doc"];
nativeBuildInputs = with pkgs;
[
wrapGAppsHook
gobject-introspection
meson
pkg-config
ninja
vala
wayland
wayland-scanner
python3
]
++ nativeBuildInputs;
propagatedBuildInputs = with pkgs;
[
glib
]
++ packages;
postUnpack = ''
cp --remove-destination ${../lib/gir.py} $sourceRoot/gir.py
${postUnpack}
'';
postInstall = let
data = toTOML libname {
library = {
inherit description authors version;
license = "LGPL-2.1";
browse_url = "https://github.com/Aylur/astal/tree/main/lib/${repo-path}";
repository_url = "https://github.com/aylur/aylur.git";
website_url = "https://aylur.github.io/astal/guide/libraries/${website-path}";
dependencies = ["GObject-2.0"] ++ dependencies;
};
extra.urlmap_file = "urlmap.js";
dependencies =
{inherit (dependency) "GObject-2.0";}
// (filterAttrs (n: _: elem n dependencies) dependency);
};
in ''
gir="${girName}.gir"
mkdir -p $out/share/doc/${website-path}
cat ${urlmap} > urlmap.js
if [ -d "src" ]; then
gir="src/$gir"
fi
${docgen}/bin/gi-docgen generate --config ${data} $gir
mv ${girName}/* $out/share/doc/${website-path}
'';
passthru = {
inherit girName;
};
meta = {
inherit description;
homepage = "https://aylur.github.io/astal";
license = pkgs.lib.licenses.lgpl21;
};
}
|