summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/gi-docs.yml3
-rw-r--r--docs/default.nix240
-rw-r--r--examples/js/simple-bar/widget/Bar.tsx4
-rw-r--r--examples/lua/simple-bar/widget/Bar.lua4
-rw-r--r--examples/py/simple-bar/widget/Bar.py2
-rw-r--r--examples/vala/simple-bar/widget/Bar.vala2
-rw-r--r--flake.lock6
-rw-r--r--flake.nix103
-rw-r--r--lang/gjs/default.nix16
-rw-r--r--lib/apps/default.nix15
-rw-r--r--lib/astal/gtk3/default.nix21
-rw-r--r--lib/astal/gtk3/src/widget/icon.vala19
-rw-r--r--lib/astal/gtk4/default.nix21
-rw-r--r--lib/astal/io/default.nix12
-rw-r--r--lib/auth/default.nix15
-rw-r--r--lib/battery/default.nix15
-rw-r--r--lib/bluetooth/default.nix10
-rw-r--r--lib/cava/default.nix56
-rw-r--r--lib/greet/default.nix15
-rw-r--r--lib/hyprland/default.nix15
-rw-r--r--lib/mpris/default.nix15
-rw-r--r--lib/network/default.nix16
-rw-r--r--lib/notifd/default.nix15
-rw-r--r--lib/powerprofiles/default.nix15
-rw-r--r--lib/river/default.nix21
-rw-r--r--lib/river/include/wayland-source.h16
-rw-r--r--lib/river/meson.build3
-rw-r--r--lib/river/src/meson.build4
-rw-r--r--lib/river/src/river.c12
-rw-r--r--lib/river/src/wayland-source.c104
l---------lib/river/subprojects/wayland-glib1
-rw-r--r--lib/tray/default.nix41
-rw-r--r--lib/wayland-glib/meson.build40
-rw-r--r--lib/wayland-glib/version1
-rw-r--r--lib/wayland-glib/wl-source.vala44
-rw-r--r--lib/wireplumber/default.nix16
-rw-r--r--nix/appmenu-glib.nix35
-rw-r--r--nix/gi-docgen.patch (renamed from nix/doc/gi-docgen.patch)0
-rw-r--r--nix/libcava.nix60
-rw-r--r--nix/lua.nix6
-rw-r--r--nix/mkAstalPkg.nix141
41 files changed, 663 insertions, 537 deletions
diff --git a/.github/workflows/gi-docs.yml b/.github/workflows/gi-docs.yml
index d0ac9b8..565b6d5 100644
--- a/.github/workflows/gi-docs.yml
+++ b/.github/workflows/gi-docs.yml
@@ -44,7 +44,8 @@ jobs:
- name: Clean and Copy Files
run: |
rm -rf dist/libastal
- cp -r src/result/libastal dist/libastal
+ mkdir dist/libastal
+ cp -r src/result/* dist/libastal
- name: Push to Pages Repo
run: |
diff --git a/docs/default.nix b/docs/default.nix
index 3eae600..5c7a8c7 100644
--- a/docs/default.nix
+++ b/docs/default.nix
@@ -2,239 +2,15 @@
self,
pkgs,
}: let
- inherit (builtins) replaceStrings readFile;
- readVer = file: replaceStrings ["\n"] [""] (readFile file);
+ inherit (builtins) removeAttrs concatStringsSep map attrValues;
+ packages = attrValues (removeAttrs self.packages.${pkgs.system} ["default" "docs" "gjs"]);
- toTOML = (pkgs.formats.toml {}).generate;
+ cp = pkg: ''
+ doc="${pkg.doc}/share/doc"
+ name=$(ls $doc)
- docgen = pkgs.gi-docgen.overrideAttrs {
- patches = [../nix/doc/gi-docgen.patch];
- };
-
- genLib = {
- flakepkg,
- gir,
- version,
- description,
- api-ver ? "0.1",
- authors ? "Aylur",
- dependencies ? {},
- out ? "libastal/${flakepkg}",
- browse ? flakepkg,
- website ? flakepkg,
- }: let
- name = "Astal${gir}-${api-ver}";
- src = self.packages.${pkgs.system}.${flakepkg}.dev;
-
- data = toTOML gir {
- library = {
- inherit description authors;
- version = readVer version;
- license = "LGPL-2.1";
- browse_url = "https://github.com/Aylur/astal/tree/main/lib/${browse}";
- repository_url = "https://github.com/aylur/aylur.git";
- website_url = "https://aylur.github.io/astal/guide/libraries/${website}";
- dependencies = ["GObject-2.0"] ++ (builtins.attrNames dependencies);
- };
-
- extra.urlmap_file = "urlmap.js";
- dependencies = {inherit (dependency) "GObject-2.0";} // dependencies;
- };
- in ''
- mkdir -p $out/${out}
- cat ${urlmap} > urlmap.js
- gi-docgen generate -C ${data} ${src}/share/gir-1.0/${name}.gir
- cp -r ${name}/* $out/${out}
- '';
-
- 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 = ${builtins.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/"]
- ]}
+ mkdir -p "$out/$name"
+ cp -r "$doc/$name" $out
'';
in
- pkgs.stdenvNoCC.mkDerivation {
- name = "reference";
- src = ./.;
-
- nativeBuildInputs = with pkgs; [
- docgen
- glib
- json-glib
- gobject-introspection
- gtk3
- gtk4
- gtk-layer-shell
- gtk4-layer-shell
- gdk-pixbuf
- libdbusmenu-gtk3
- wireplumber
- networkmanager
- self.packages.${system}.io
- ];
-
- installPhase = ''
- runHook preInstall
- ${genLib {
- flakepkg = "io";
- gir = "IO";
- api-ver = "0.1";
- browse = "astal/io";
- description = "Astal Core library";
- version = ../lib/astal/io/version;
- }}
- ${genLib {
- flakepkg = "astal3";
- gir = "";
- api-ver = "3.0";
- browse = "astal/gtk3";
- description = "Astal GTK3 widget library";
- version = ../lib/astal/gtk3/version;
- dependencies = {inherit (dependency) "AstalIO-0.1" "Gtk-3.0";};
- }}
- ${genLib {
- flakepkg = "astal4";
- gir = "";
- api-ver = "4.0";
- browse = "astal/gtk4";
- description = "Astal GTK4 widget library";
- version = ../lib/astal/gtk4/version;
- dependencies = {inherit (dependency) "AstalIO-0.1" "Gtk-4.0";};
- }}
- ${genLib {
- flakepkg = "apps";
- gir = "Apps";
- description = "Application query library";
- version = ../lib/apps/version;
- }}
- ${genLib {
- flakepkg = "auth";
- gir = "Auth";
- authors = "kotontrion";
- description = "Authentication using pam";
- version = ../lib/auth/version;
- }}
- ${genLib {
- flakepkg = "battery";
- gir = "Battery";
- description = "DBus proxy for upowerd devices";
- version = ../lib/battery/version;
- }}
- ${genLib {
- flakepkg = "bluetooth";
- gir = "Bluetooth";
- description = "DBus proxy for bluez";
- version = ../lib/bluetooth/version;
- }}
- ${genLib {
- flakepkg = "cava";
- gir = "Cava";
- description = "Audio visualization library using cava";
- version = ../lib/cava/version;
- authors = "kotontrion";
- }}
- ${genLib {
- flakepkg = "greet";
- gir = "Greet";
- description = "IPC client for greetd";
- version = ../lib/greet/version;
- }}
- ${genLib {
- flakepkg = "hyprland";
- gir = "Hyprland";
- description = "IPC client for Hyprland";
- version = ../lib/hyprland/version;
- }}
- ${genLib {
- flakepkg = "mpris";
- gir = "Mpris";
- description = "Control mpris players";
- version = ../lib/mpris/version;
- }}
- ${genLib {
- flakepkg = "network";
- gir = "Network";
- description = "NetworkManager wrapper library";
- version = ../lib/network/version;
- dependencies = {inherit (dependency) "NM-1.0";}; # FIXME: why does this not work?
- }}
- ${genLib {
- flakepkg = "notifd";
- gir = "Notifd";
- description = "Notification daemon library";
- version = ../lib/notifd/version;
- }}
- ${genLib {
- flakepkg = "powerprofiles";
- gir = "PowerProfiles";
- description = "DBus proxy for upowerd profiles";
- version = ../lib/powerprofiles/version;
- }}
- ${genLib {
- flakepkg = "river";
- gir = "River";
- description = "IPC client for River";
- version = ../lib/river/version;
- authors = "kotontrion";
- }}
- ${genLib {
- flakepkg = "tray";
- gir = "Tray";
- description = "StatusNotifierItem implementation";
- version = ../lib/tray/version;
- authors = "kotontrion";
- }}
- ${genLib {
- flakepkg = "wireplumber";
- gir = "Wp";
- description = "Wrapper library over the wireplumber API";
- version = ../lib/wireplumber/version;
- authors = "kotontrion";
- dependencies = {inherit (dependency) "WP-0.5";}; # FIXME: why does this not work?
- }}
- runHook postInstall
- '';
- }
+ pkgs.runCommand "docs" {} (concatStringsSep "" (map cp packages))
diff --git a/examples/js/simple-bar/widget/Bar.tsx b/examples/js/simple-bar/widget/Bar.tsx
index 54a14b0..c109aec 100644
--- a/examples/js/simple-bar/widget/Bar.tsx
+++ b/examples/js/simple-bar/widget/Bar.tsx
@@ -18,9 +18,9 @@ function SysTray() {
usePopover={false}
actionGroup={bind(item, "action-group").as(ag => ["dbusmenu", ag])}
menuModel={bind(item, "menu-model")}>
- <icon gIcon={bind(item, "gicon")} />
+ <icon gicon={bind(item, "gicon")} />
</menubutton>
- ))}
+ )))}
</box>
}
diff --git a/examples/lua/simple-bar/widget/Bar.lua b/examples/lua/simple-bar/widget/Bar.lua
index 5e62253..e0d8b20 100644
--- a/examples/lua/simple-bar/widget/Bar.lua
+++ b/examples/lua/simple-bar/widget/Bar.lua
@@ -26,7 +26,7 @@ local function SysTray()
return { "dbusmenu", ag }
end),
Widget.Icon({
- g_icon = bind(item, "gicon"),
+ gicon = bind(item, "gicon"),
}),
})
end)
@@ -127,7 +127,7 @@ local function Workspaces()
end)
return map(wss, function(ws)
- if !(ws.id >= -99 and ws.id <= -2) then -- filter out special workspaces
+ if not (ws.id >= -99 and ws.id <= -2) then -- filter out special workspaces
return Widget.Button({
class_name = bind(hypr, "focused-workspace"):as(function(fw)
return fw == ws and "focused" or ""
diff --git a/examples/py/simple-bar/widget/Bar.py b/examples/py/simple-bar/widget/Bar.py
index 3c5c3f8..c6902b4 100644
--- a/examples/py/simple-bar/widget/Bar.py
+++ b/examples/py/simple-bar/widget/Bar.py
@@ -124,7 +124,7 @@ class SysTray(Gtk.Box):
icon = Astal.Icon(visible=True)
item.bind_property("tooltip-markup", btn, "tooltip-markup", SYNC)
- item.bind_property("gicon", icon, "g-icon", SYNC)
+ item.bind_property("gicon", icon, "gicon", SYNC)
item.bind_property("menu-model", btn, "menu-model", SYNC)
btn.insert_action_group("dbusmenu", item.get_action_group())
diff --git a/examples/vala/simple-bar/widget/Bar.vala b/examples/vala/simple-bar/widget/Bar.vala
index 8913c95..295a3b7 100644
--- a/examples/vala/simple-bar/widget/Bar.vala
+++ b/examples/vala/simple-bar/widget/Bar.vala
@@ -121,7 +121,7 @@ class SysTray : Gtk.Box {
var icon = new Astal.Icon() { visible = true };
item.bind_property("tooltip-markup", btn, "tooltip-markup", BindingFlags.SYNC_CREATE);
- item.bind_property("gicon", icon, "g-icon", BindingFlags.SYNC_CREATE);
+ item.bind_property("gicon", icon, "gicon", BindingFlags.SYNC_CREATE);
item.bind_property("menu-model", btn, "menu-model", BindingFlags.SYNC_CREATE);
btn.insert_action_group("dbusmenu", item.action_group);
item.notify["action-group"].connect(() => {
diff --git a/flake.lock b/flake.lock
index def3031..db7b727 100644
--- a/flake.lock
+++ b/flake.lock
@@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
- "lastModified": 1732837521,
- "narHash": "sha256-jNRNr49UiuIwaarqijgdTR2qLPifxsVhlJrKzQ8XUIE=",
+ "lastModified": 1734424634,
+ "narHash": "sha256-cHar1vqHOOyC7f1+tVycPoWTfKIaqkoe1Q6TnKzuti4=",
"owner": "nixos",
"repo": "nixpkgs",
- "rev": "970e93b9f82e2a0f3675757eb0bfc73297cc6370",
+ "rev": "d3c42f187194c26d9f0309a8ecc469d6c878ce33",
"type": "github"
},
"original": {
diff --git a/flake.nix b/flake.nix
index ac1c5e6..c18de7b 100644
--- a/flake.nix
+++ b/flake.nix
@@ -3,80 +3,49 @@
self,
nixpkgs,
}: let
- inherit (builtins) replaceStrings readFile;
- readVer = file: replaceStrings ["\n"] [""] (readFile file);
-
- system = "x86_64-linux"; # TODO: other architectures
- pkgs = nixpkgs.legacyPackages.${system};
-
- mkPkg = name: src: inputs:
- pkgs.stdenv.mkDerivation {
- nativeBuildInputs = with pkgs; [
- wrapGAppsHook
- gobject-introspection
- meson
- pkg-config
- ninja
- vala
- wayland
- wayland-scanner
- python3
- ];
- propagatedBuildInputs = [pkgs.glib] ++ inputs;
- pname = name;
- version = readVer "${src}/version";
- src = src;
- postUnpack = ''
- cp --remove-destination ${./lib/gir.py} $sourceRoot/gir.py
- '';
- outputs = ["out" "dev"];
- };
+ forAllSystems = nixpkgs.lib.genAttrs ["x86_64-linux" "aarch64-linux"];
in {
- devShells.${system} = import ./nix/devshell.nix {
- inherit self pkgs;
- };
-
lib = {
- mkLuaPackage = import ./nix/lua.nix {
- inherit pkgs;
- astal = self;
- };
+ mkLuaPackage = import ./nix/lua.nix self;
};
- packages.${system} = with pkgs; {
- docs = import ./docs {inherit self pkgs;};
+ packages = forAllSystems (system: let
+ pkgs = nixpkgs.legacyPackages.${system};
+ mkPkg = src:
+ import src {
+ inherit self pkgs;
+ mkAstalPkg = import ./nix/mkAstalPkg.nix pkgs;
+ };
+ in {
default = self.packages.${system}.io;
+ docs = import ./docs {inherit self pkgs;};
- io = mkPkg "astal" ./lib/astal/io [];
- astal3 = mkPkg "astal" ./lib/astal/gtk3 [self.packages.${system}.io gtk3 gtk-layer-shell];
- astal4 = mkPkg "astal" ./lib/astal/gtk4 [self.packages.${system}.io gtk4 gtk4-layer-shell];
- apps = mkPkg "astal-apps" ./lib/apps [json-glib];
- auth = mkPkg "astal-auth" ./lib/auth [pam];
- battery = mkPkg "astal-battery" ./lib/battery [json-glib];
- bluetooth = mkPkg "astal-bluetooth" ./lib/bluetooth [];
- cava = mkPkg "astal-cava" ./lib/cava [(pkgs.callPackage ./nix/libcava.nix {})];
- greet = mkPkg "astal-greet" ./lib/greet [json-glib];
- hyprland = mkPkg "astal-hyprland" ./lib/hyprland [json-glib];
- mpris = mkPkg "astal-mpris" ./lib/mpris [gvfs json-glib];
- network = mkPkg "astal-network" ./lib/network [networkmanager];
- notifd = mkPkg "astal-notifd" ./lib/notifd [json-glib gdk-pixbuf];
- powerprofiles = mkPkg "astal-power-profiles" ./lib/powerprofiles [json-glib];
- river = mkPkg "astal-river" ./lib/river [json-glib];
- tray = mkPkg "astal-tray" ./lib/tray [json-glib (pkgs.callPackage ./nix/appmenu-glib.nix {})];
- wireplumber = mkPkg "astal-wireplumber" ./lib/wireplumber [wireplumber];
+ io = mkPkg ./lib/astal/io;
+ astal3 = mkPkg ./lib/astal/gtk3;
+ astal4 = mkPkg ./lib/astal/gtk4;
+ apps = mkPkg ./lib/apps;
+ auth = mkPkg ./lib/auth;
+ battery = mkPkg ./lib/battery;
+ bluetooth = mkPkg ./lib/bluetooth;
+ cava = mkPkg ./lib/cava;
+ greet = mkPkg ./lib/greet;
+ hyprland = mkPkg ./lib/hyprland;
+ mpris = mkPkg ./lib/mpris;
+ network = mkPkg ./lib/network;
+ notifd = mkPkg ./lib/notifd;
+ powerprofiles = mkPkg ./lib/powerprofiles;
+ river = mkPkg ./lib/river;
+ tray = mkPkg ./lib/tray;
+ wireplumber = mkPkg ./lib/wireplumber;
- gjs = pkgs.stdenvNoCC.mkDerivation {
- src = ./lang/gjs;
- name = "astal-gjs";
- nativeBuildInputs = [
- meson
- ninja
- pkg-config
- self.packages.${system}.io
- self.packages.${system}.astal3
- ];
- };
- };
+ gjs = import ./lang/gjs {inherit self pkgs;};
+ });
+
+ devShells = forAllSystems (system:
+ import ./nix/devshell.nix {
+ inherit self;
+ pkgs = nixpkgs.legacyPackages.${system};
+ });
};
inputs = {
diff --git a/lang/gjs/default.nix b/lang/gjs/default.nix
new file mode 100644
index 0000000..e4ffaf0
--- /dev/null
+++ b/lang/gjs/default.nix
@@ -0,0 +1,16 @@
+{
+ pkgs,
+ self,
+ ...
+}:
+pkgs.stdenvNoCC.mkDerivation {
+ src = ./.;
+ name = "astal-gjs";
+ nativeBuildInputs = [
+ pkgs.meson
+ pkgs.ninja
+ pkgs.pkg-config
+ self.packages.${pkgs.system}.io
+ self.packages.${pkgs.system}.astal3
+ ];
+}
diff --git a/lib/apps/default.nix b/lib/apps/default.nix
new file mode 100644
index 0000000..64466a2
--- /dev/null
+++ b/lib/apps/default.nix
@@ -0,0 +1,15 @@
+{
+ mkAstalPkg,
+ pkgs,
+ ...
+}:
+mkAstalPkg {
+ pname = "astal-apps";
+ src = ./.;
+ packages = [pkgs.json-glib];
+
+ libname = "apps";
+ gir-suffix = "Apps";
+ authors = "Aylur";
+ description = "Application query library";
+}
diff --git a/lib/astal/gtk3/default.nix b/lib/astal/gtk3/default.nix
new file mode 100644
index 0000000..c86f3de
--- /dev/null
+++ b/lib/astal/gtk3/default.nix
@@ -0,0 +1,21 @@
+{
+ mkAstalPkg,
+ pkgs,
+ self,
+}:
+mkAstalPkg {
+ pname = "astal3";
+ src = ./.;
+ packages = [
+ self.packages.${pkgs.system}.io
+ pkgs.gtk3
+ pkgs.gtk-layer-shell
+ ];
+
+ libname = "astal3";
+ gir-suffix = "";
+ authors = "Aylur";
+ description = "Astal GTK3 widget library";
+ dependencies = ["AstalIO-0.1" "Gtk-3.0"];
+ repo-path = "astal/gtk3";
+}
diff --git a/lib/astal/gtk3/src/widget/icon.vala b/lib/astal/gtk3/src/widget/icon.vala
index 9a20359..ee6808c 100644
--- a/lib/astal/gtk3/src/widget/icon.vala
+++ b/lib/astal/gtk3/src/widget/icon.vala
@@ -9,7 +9,21 @@ public class Astal.Icon : Gtk.Image {
private double size { get; set; default = 14; }
public new Gdk.Pixbuf pixbuf { get; set; }
- public GLib.Icon g_icon { get; set; }
+
+ private static bool gicon_warned = false;
+ [Version (deprecated = true, deprecated_since = "0.1.0", replacement = "gicon")]
+ public GLib.Icon g_icon {
+ owned get {
+ return this.gicon;
+ }
+ set {
+ if( !gicon_warned ) {
+ GLib.warning("g-icon is deprecated. Use gicon instead.");
+ gicon_warned = true;
+ }
+ this.gicon = value;
+ }
+ }
/**
* Either a named icon or a path to a file.
@@ -57,7 +71,6 @@ public class Astal.Icon : Gtk.Image {
break;
case IconType.GICON:
pixel_size = (int)size;
- gicon = g_icon;
break;
}
@@ -86,7 +99,7 @@ public class Astal.Icon : Gtk.Image {
display_icon.begin();
});
- notify["g-icon"].connect(() => {
+ notify["gicon"].connect(() => {
type = IconType.GICON;
display_icon.begin();
});
diff --git a/lib/astal/gtk4/default.nix b/lib/astal/gtk4/default.nix
new file mode 100644
index 0000000..0bca3c0
--- /dev/null
+++ b/lib/astal/gtk4/default.nix
@@ -0,0 +1,21 @@
+{
+ mkAstalPkg,
+ pkgs,
+ self,
+}:
+mkAstalPkg {
+ pname = "astal4";
+ src = ./.;
+ packages = [
+ self.packages.${pkgs.system}.io
+ pkgs.gtk4
+ pkgs.gtk4-layer-shell
+ ];
+
+ libname = "astal4";
+ gir-suffix = "";
+ authors = "Aylur";
+ description = "Astal GTK4 widget library";
+ dependencies = ["AstalIO-0.1" "Gtk-4.0"];
+ repo-path = "astal/gtk4";
+}
diff --git a/lib/astal/io/default.nix b/lib/astal/io/default.nix
new file mode 100644
index 0000000..c33132a
--- /dev/null
+++ b/lib/astal/io/default.nix
@@ -0,0 +1,12 @@
+{mkAstalPkg, ...}:
+mkAstalPkg {
+ pname = "astal";
+ src = ./.;
+
+ libname = "io";
+ gir-suffix = "IO";
+ authors = "Aylur";
+ description = "Astal Core library";
+ repo-path = "astal/io";
+ website-path = "io";
+}
diff --git a/lib/auth/default.nix b/lib/auth/default.nix
new file mode 100644
index 0000000..3b8b276
--- /dev/null
+++ b/lib/auth/default.nix
@@ -0,0 +1,15 @@
+{
+ mkAstalPkg,
+ pkgs,
+ ...
+}:
+mkAstalPkg {
+ pname = "astal-auth";
+ src = ./.;
+ packages = [pkgs.pam];
+
+ libname = "auth";
+ gir-suffix = "Auth";
+ authors = "kotontrion";
+ description = "Authentication using pam";
+}
diff --git a/lib/battery/default.nix b/lib/battery/default.nix
new file mode 100644
index 0000000..17bf67a
--- /dev/null
+++ b/lib/battery/default.nix
@@ -0,0 +1,15 @@
+{
+ mkAstalPkg,
+ pkgs,
+ ...
+}:
+mkAstalPkg {
+ pname = "astal-battery";
+ src = ./.;
+ packages = [pkgs.json-glib];
+
+ libname = "battery";
+ authors = "Aylur";
+ gir-suffix = "Battery";
+ description = "DBus proxy for upowerd devices";
+}
diff --git a/lib/bluetooth/default.nix b/lib/bluetooth/default.nix
new file mode 100644
index 0000000..f2d58c8
--- /dev/null
+++ b/lib/bluetooth/default.nix
@@ -0,0 +1,10 @@
+{mkAstalPkg, ...}:
+mkAstalPkg {
+ pname = "astal-bluetooth";
+ src = ./.;
+
+ libname = "bluetooth";
+ authors = "Aylur";
+ gir-suffix = "Bluetooth";
+ description = "DBus proxy for bluez";
+}
diff --git a/lib/cava/default.nix b/lib/cava/default.nix
new file mode 100644
index 0000000..5472e8c
--- /dev/null
+++ b/lib/cava/default.nix
@@ -0,0 +1,56 @@
+{
+ mkAstalPkg,
+ pkgs,
+ ...
+}: let
+ libcava = pkgs.stdenv.mkDerivation rec {
+ pname = "cava";
+ version = "0.10.3";
+
+ src = pkgs.fetchFromGitHub {
+ owner = "LukashonakV";
+ repo = "cava";
+ rev = "0.10.3";
+ hash = "sha256-ZDFbI69ECsUTjbhlw2kHRufZbQMu+FQSMmncCJ5pagg=";
+ };
+
+ buildInputs = with pkgs; [
+ alsa-lib
+ libpulseaudio
+ ncurses
+ iniparser
+ sndio
+ SDL2
+ libGL
+ portaudio
+ jack2
+ pipewire
+ ];
+
+ propagatedBuildInputs = with pkgs; [
+ fftw
+ ];
+
+ nativeBuildInputs = with pkgs; [
+ autoreconfHook
+ autoconf-archive
+ pkgconf
+ meson
+ ninja
+ ];
+
+ preAutoreconf = ''
+ echo ${version} > version
+ '';
+ };
+in
+ mkAstalPkg {
+ pname = "astal-cava";
+ src = ./.;
+ packages = [libcava];
+
+ libname = "cava";
+ authors = "kotontrion";
+ gir-suffix = "Cava";
+ description = "Audio visualization library using cava";
+ }
diff --git a/lib/greet/default.nix b/lib/greet/default.nix
new file mode 100644
index 0000000..22b9456
--- /dev/null
+++ b/lib/greet/default.nix
@@ -0,0 +1,15 @@
+{
+ mkAstalPkg,
+ pkgs,
+ ...
+}:
+mkAstalPkg {
+ pname = "astal-greet";
+ src = ./.;
+ packages = [pkgs.json-glib];
+
+ libname = "greet";
+ authors = "Aylur";
+ gir-suffix = "Greet";
+ description = "IPC client for greetd";
+}
diff --git a/lib/hyprland/default.nix b/lib/hyprland/default.nix
new file mode 100644
index 0000000..6b5e15d
--- /dev/null
+++ b/lib/hyprland/default.nix
@@ -0,0 +1,15 @@
+{
+ mkAstalPkg,
+ pkgs,
+ ...
+}:
+mkAstalPkg {
+ pname = "astal-hyprland";
+ src = ./.;
+ packages = [pkgs.json-glib];
+
+ libname = "hyprland";
+ authors = "Aylur";
+ gir-suffix = "Hyprland";
+ description = "IPC client for Hyprland";
+}
diff --git a/lib/mpris/default.nix b/lib/mpris/default.nix
new file mode 100644
index 0000000..082c647
--- /dev/null
+++ b/lib/mpris/default.nix
@@ -0,0 +1,15 @@
+{
+ mkAstalPkg,
+ pkgs,
+ ...
+}:
+mkAstalPkg {
+ pname = "astal-mpris";
+ src = ./.;
+ packages = with pkgs; [gvfs json-glib];
+
+ libname = "mpris";
+ authors = "Aylur";
+ gir-suffix = "Mpris";
+ description = "Control mpris players";
+}
diff --git a/lib/network/default.nix b/lib/network/default.nix
new file mode 100644
index 0000000..cfa2378
--- /dev/null
+++ b/lib/network/default.nix
@@ -0,0 +1,16 @@
+{
+ mkAstalPkg,
+ pkgs,
+ ...
+}:
+mkAstalPkg {
+ pname = "astal-network";
+ src = ./.;
+ packages = [pkgs.networkmanager];
+
+ libname = "network";
+ authors = "Aylur";
+ gir-suffix = "Network";
+ description = "NetworkManager wrapper library";
+ dependencies = ["NM-1.0"];
+}
diff --git a/lib/notifd/default.nix b/lib/notifd/default.nix
new file mode 100644
index 0000000..e23528c
--- /dev/null
+++ b/lib/notifd/default.nix
@@ -0,0 +1,15 @@
+{
+ mkAstalPkg,
+ pkgs,
+ ...
+}:
+mkAstalPkg {
+ pname = "astal-notifd";
+ src = ./.;
+ packages = with pkgs; [json-glib gdk-pixbuf];
+
+ libname = "notifd";
+ authors = "Aylur";
+ gir-suffix = "Notifd";
+ description = "Notification daemon library";
+}
diff --git a/lib/powerprofiles/default.nix b/lib/powerprofiles/default.nix
new file mode 100644
index 0000000..f35f9e5
--- /dev/null
+++ b/lib/powerprofiles/default.nix
@@ -0,0 +1,15 @@
+{
+ mkAstalPkg,
+ pkgs,
+ ...
+}:
+mkAstalPkg {
+ pname = "astal-powerprofiles";
+ src = ./.;
+ packages = [pkgs.json-glib];
+
+ libname = "powerprofiles";
+ authors = "Aylur";
+ gir-suffix = "PowerProfiles";
+ description = "DBus proxy for upowerd profiles";
+}
diff --git a/lib/river/default.nix b/lib/river/default.nix
new file mode 100644
index 0000000..15c6eb4
--- /dev/null
+++ b/lib/river/default.nix
@@ -0,0 +1,21 @@
+{
+ mkAstalPkg,
+ pkgs,
+ ...
+}:
+mkAstalPkg {
+ pname = "astal-river";
+ src = ./.;
+ packages = [pkgs.json-glib];
+
+ libname = "river";
+ authors = "kotontrion";
+ gir-suffix = "River";
+ description = "IPC client for River";
+
+ postUnpack = ''
+ rm -rf $sourceRoot/subprojects
+ mkdir -p $sourceRoot/subprojects
+ cp -r --remove-destination ${../wayland-glib} $sourceRoot/subprojects/wayland-glib
+ '';
+}
diff --git a/lib/river/include/wayland-source.h b/lib/river/include/wayland-source.h
deleted file mode 100644
index b219589..0000000
--- a/lib/river/include/wayland-source.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef __WAYLAND_SOURCE_H__
-#define __WAYLAND_SOURCE_H__
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-typedef struct _WLSource WLSource;
-
-WLSource* wl_source_new();
-void wl_source_free(WLSource* self);
-struct wl_display* wl_source_get_display(WLSource* source);
-
-G_END_DECLS
-
-#endif /* __WAYLAND_SOURCE_H__ */
diff --git a/lib/river/meson.build b/lib/river/meson.build
index aa5e23b..2f98315 100644
--- a/lib/river/meson.build
+++ b/lib/river/meson.build
@@ -13,6 +13,9 @@ lib_so_version = version_split[0] + '.' + version_split[1]
pkg_config = import('pkgconfig')
gnome = import('gnome')
+wayland_glib = subproject('wayland-glib')
+wayland_glib_dep = wayland_glib.get_variable('wayland_glib')
+
subdir('protocols')
subdir('include')
subdir('src')
diff --git a/lib/river/src/meson.build b/lib/river/src/meson.build
index b7ce20d..9c58e41 100644
--- a/lib/river/src/meson.build
+++ b/lib/river/src/meson.build
@@ -1,7 +1,6 @@
srcs = files(
'river-output.c',
- 'river.c',
- 'wayland-source.c',
+ 'river.c'
)
deps = [
@@ -9,6 +8,7 @@ deps = [
dependency('gio-2.0'),
dependency('wayland-client'),
dependency('json-glib-1.0'),
+ wayland_glib_dep
]
astal_river_lib = library(
diff --git a/lib/river/src/river.c b/lib/river/src/river.c
index 124cb20..6f94c9c 100644
--- a/lib/river/src/river.c
+++ b/lib/river/src/river.c
@@ -6,7 +6,8 @@
#include "river-control-unstable-v1-client.h"
#include "river-private.h"
#include "river-status-unstable-v1-client.h"
-#include "wayland-source.h"
+// #include "wayland-source.h"
+#include <wayland-glib.h>
struct _AstalRiverRiver {
GObject parent_instance;
@@ -22,7 +23,7 @@ typedef struct {
struct wl_registry* wl_registry;
struct wl_seat* seat;
struct wl_display* display;
- WLSource* wl_source;
+ WlGlibWlSource* wl_source;
struct zriver_status_manager_v1* river_status_manager;
struct zriver_control_v1* river_control;
struct zriver_seat_status_v1* river_seat_status;
@@ -340,7 +341,7 @@ static gboolean astal_river_river_initable_init(GInitable* initable, GCancellabl
if (priv->init) return TRUE;
- priv->wl_source = wl_source_new(NULL, NULL);
+ priv->wl_source = wl_glib_wl_source_new();
if (priv->wl_source == NULL) {
g_set_error_literal(error, G_IO_ERROR, G_IO_ERROR_FAILED,
@@ -348,7 +349,7 @@ static gboolean astal_river_river_initable_init(GInitable* initable, GCancellabl
return FALSE;
}
- priv->display = wl_source_get_display(priv->wl_source);
+ priv->display = priv->wl_source->display;
priv->wl_registry = wl_display_get_registry(priv->display);
wl_registry_add_listener(priv->wl_registry, &registry_listener, self);
@@ -449,7 +450,8 @@ static void astal_river_river_finalize(GObject* object) {
if (priv->seat != NULL) wl_seat_destroy(priv->seat);
if (priv->display != NULL) wl_display_flush(priv->display);
- if (priv->wl_source != NULL) wl_source_free(priv->wl_source);
+ // if (priv->wl_source != NULL) wl_source_free(priv->wl_source);
+ if (priv->wl_source != NULL) g_source_unref((GSource*)(priv->wl_source));
g_free(self->focused_view);
g_free(self->focused_output);
diff --git a/lib/river/src/wayland-source.c b/lib/river/src/wayland-source.c
deleted file mode 100644
index 875c32c..0000000
--- a/lib/river/src/wayland-source.c
+++ /dev/null
@@ -1,104 +0,0 @@
-
-#include "wayland-source.h"
-
-#include <errno.h>
-#include <glib.h>
-#include <wayland-client.h>
-
-struct _WLSource {
- GSource source;
- struct wl_display *display;
- gpointer fd;
- int error;
-};
-
-static gboolean wl_source_prepare(GSource *source, gint *timeout) {
- WLSource *self = (WLSource *)source;
-
- *timeout = 0;
- if (wl_display_prepare_read(self->display) != 0)
- return TRUE;
- else if (wl_display_flush(self->display) < 0) {
- self->error = errno;
- return TRUE;
- }
- *timeout = -1;
- return FALSE;
-}
-
-static gboolean wl_source_check(GSource *source) {
- WLSource *self = (WLSource *)source;
-
- if (self->error > 0) return TRUE;
-
- GIOCondition revents;
- revents = g_source_query_unix_fd(source, self->fd);
-
- if (revents & G_IO_IN) {
- if (wl_display_read_events(self->display) < 0) self->error = errno;
- } else
- wl_display_cancel_read(self->display);
-
- return revents > 0;
-}
-
-static gboolean wl_source_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) {
- WLSource *self = (WLSource *)source;
- GIOCondition revents;
-
- revents = g_source_query_unix_fd(source, self->fd);
- if ((self->error > 0) || (revents & (G_IO_ERR | G_IO_HUP))) {
- errno = self->error;
- self->error = 0;
- if (callback != NULL) return callback(user_data);
- return G_SOURCE_REMOVE;
- }
-
- if (wl_display_dispatch_pending(self->display) < 0) {
- if (callback != NULL) return callback(user_data);
- return G_SOURCE_REMOVE;
- }
-
- return G_SOURCE_CONTINUE;
-}
-
-static void wl_source_finalize(GSource *source) {
- WLSource *self = (WLSource *)source;
- wl_display_disconnect(self->display);
-}
-
-static GSourceFuncs wl_source_funcs = {
- .prepare = wl_source_prepare,
- .check = wl_source_check,
- .dispatch = wl_source_dispatch,
- .finalize = wl_source_finalize,
-};
-
-WLSource *wl_source_new() {
- struct wl_display *display;
- WLSource *self;
- GSource *source;
-
- display = wl_display_connect(NULL);
- if (display == NULL) return NULL;
-
- source = g_source_new(&wl_source_funcs, sizeof(WLSource));
- self = (WLSource *)source;
- self->display = display;
-
- self->fd = g_source_add_unix_fd(source, wl_display_get_fd(self->display),
- G_IO_IN | G_IO_ERR | G_IO_HUP);
-
- g_source_attach(source, NULL);
-
- return self;
-}
-
-void wl_source_free(WLSource *self) {
- GSource *source = (GSource *)self;
- g_return_if_fail(source != NULL);
- g_source_destroy(source);
- g_source_unref(source);
-}
-
-struct wl_display *wl_source_get_display(WLSource *self) { return self->display; }
diff --git a/lib/river/subprojects/wayland-glib b/lib/river/subprojects/wayland-glib
new file mode 120000
index 0000000..41372cf
--- /dev/null
+++ b/lib/river/subprojects/wayland-glib
@@ -0,0 +1 @@
+../../wayland-glib \ No newline at end of file
diff --git a/lib/tray/default.nix b/lib/tray/default.nix
new file mode 100644
index 0000000..6dd0d61
--- /dev/null
+++ b/lib/tray/default.nix
@@ -0,0 +1,41 @@
+{
+ mkAstalPkg,
+ pkgs,
+ ...
+}: let
+ vala-panel-appmenu = pkgs.fetchFromGitLab {
+ owner = "vala-panel-project";
+ repo = "vala-panel-appmenu";
+ rev = "24.05";
+ hash = "sha256-8GWauw7r3zKhvGF2TNOI8GDVctUFDhtG/Vy1cNUpsVo=";
+ };
+
+ appmenu-glib-translator = pkgs.stdenv.mkDerivation {
+ pname = "appmenu-glib-translator";
+ version = "24.05";
+
+ src = "${vala-panel-appmenu}/subprojects/appmenu-glib-translator";
+
+ buildInputs = with pkgs; [
+ glib
+ ];
+
+ nativeBuildInputs = with pkgs; [
+ gobject-introspection
+ meson
+ pkg-config
+ ninja
+ vala
+ ];
+ };
+in
+ mkAstalPkg {
+ pname = "astal-tray";
+ src = ./.;
+ packages = [pkgs.json-glib appmenu-glib-translator];
+
+ libname = "tray";
+ authors = "kotontrion";
+ gir-suffix = "Tray";
+ description = "StatusNotifierItem implementation";
+ }
diff --git a/lib/wayland-glib/meson.build b/lib/wayland-glib/meson.build
new file mode 100644
index 0000000..3d93ac0
--- /dev/null
+++ b/lib/wayland-glib/meson.build
@@ -0,0 +1,40 @@
+project(
+ 'wayland-glib',
+ 'vala',
+ 'c',
+ version: run_command('cat', join_paths(meson.project_source_root(), 'version')).stdout().strip(),
+ meson_version: '>= 0.62.0',
+ default_options: [
+ 'warning_level=2',
+ 'werror=false',
+ 'c_std=gnu11',
+ ],
+)
+
+version_split = meson.project_version().split('.')
+
+deps = [
+ dependency('glib-2.0'),
+ dependency('gio-2.0'),
+ dependency('gobject-2.0'),
+ dependency('wayland-client'),
+]
+
+sources = [
+ 'wl-source.vala',
+]
+
+lib = static_library(
+ meson.project_name(),
+ sources,
+ dependencies: deps,
+ vala_header: meson.project_name() + '.h',
+ vala_vapi: meson.project_name() + '.vapi',
+)
+
+wayland_glib = declare_dependency(
+ link_with: lib,
+ include_directories: include_directories('.')
+ )
+
+
diff --git a/lib/wayland-glib/version b/lib/wayland-glib/version
new file mode 100644
index 0000000..6e8bf73
--- /dev/null
+++ b/lib/wayland-glib/version
@@ -0,0 +1 @@
+0.1.0
diff --git a/lib/wayland-glib/wl-source.vala b/lib/wayland-glib/wl-source.vala
new file mode 100644
index 0000000..f8472fb
--- /dev/null
+++ b/lib/wayland-glib/wl-source.vala
@@ -0,0 +1,44 @@
+namespace WlGlib {
+public class WlSource : Source {
+
+ public Wl.Display display;
+ public void* fd;
+ public int error;
+
+ public override bool dispatch(SourceFunc callback) {
+ IOCondition revents = this.query_unix_fd(this.fd);
+ if (this.error > 0 || (revents & (IOCondition.ERR | IOCondition.HUP)) != 0) {
+ errno = this.error;
+ if(callback != null) return callback();
+ return Source.REMOVE;
+ }
+ if (((revents & IOCondition.IN) != 0) && this.display.dispatch() < 0) {
+ if(callback != null) return callback();
+ return Source.REMOVE;
+ }
+ return Source.CONTINUE;
+ }
+
+ public override bool check() {
+ IOCondition revents = this.query_unix_fd(this.fd);
+ return revents > 0;
+ }
+
+ public override bool prepare(out int timeout) {
+ if(this.display.flush() < 0)
+ this.error = errno;
+ timeout = -1;
+ return false;
+ }
+
+ public WlSource() {
+ base();
+ this.display = new Wl.Display.connect(null);
+ if(this.display == null) return;
+ this.fd = this.add_unix_fd(this.display.get_fd(),
+ IOCondition.IN | IOCondition.ERR | IOCondition.HUP);
+ this.attach(null);
+ }
+}
+}
+
diff --git a/lib/wireplumber/default.nix b/lib/wireplumber/default.nix
new file mode 100644
index 0000000..f9eb832
--- /dev/null
+++ b/lib/wireplumber/default.nix
@@ -0,0 +1,16 @@
+{
+ mkAstalPkg,
+ pkgs,
+ ...
+}:
+mkAstalPkg {
+ pname = "astal-wireplumber";
+ src = ./.;
+ packages = [pkgs.wireplumber];
+
+ libname = "wireplumber";
+ authors = "kotontrion";
+ gir-suffix = "Wp";
+ description = "Wrapper library over the wireplumber API";
+ dependencies = ["WP-0.5"];
+}
diff --git a/nix/appmenu-glib.nix b/nix/appmenu-glib.nix
deleted file mode 100644
index 873fb93..0000000
--- a/nix/appmenu-glib.nix
+++ /dev/null
@@ -1,35 +0,0 @@
-{
- stdenv,
- fetchFromGitLab,
- pkg-config,
- meson,
- ninja,
- gobject-introspection,
- vala,
- glib,
-}: let
- vala-panel-appmenu = fetchFromGitLab {
- owner = "vala-panel-project";
- repo = "vala-panel-appmenu";
- rev = "24.05";
- hash = "sha256-8GWauw7r3zKhvGF2TNOI8GDVctUFDhtG/Vy1cNUpsVo=";
- };
-in
- stdenv.mkDerivation {
- pname = "appmenu-glib-translator";
- version = "24.05";
-
- src = "${vala-panel-appmenu}/subprojects/appmenu-glib-translator";
-
- buildInputs = [
- glib
- ];
-
- nativeBuildInputs = [
- gobject-introspection
- meson
- pkg-config
- ninja
- vala
- ];
- }
diff --git a/nix/doc/gi-docgen.patch b/nix/gi-docgen.patch
index 0ecb4bd..0ecb4bd 100644
--- a/nix/doc/gi-docgen.patch
+++ b/nix/gi-docgen.patch
diff --git a/nix/libcava.nix b/nix/libcava.nix
deleted file mode 100644
index 866599d..0000000
--- a/nix/libcava.nix
+++ /dev/null
@@ -1,60 +0,0 @@
-{
- stdenv,
- fetchFromGitHub,
- autoreconfHook,
- autoconf-archive,
- alsa-lib,
- fftw,
- iniparser,
- libpulseaudio,
- portaudio,
- sndio,
- SDL2,
- libGL,
- pipewire,
- jack2,
- ncurses,
- pkgconf,
- meson,
- ninja,
-}:
-stdenv.mkDerivation rec {
- pname = "cava";
- version = "0.10.3";
-
- src = fetchFromGitHub {
- owner = "LukashonakV";
- repo = "cava";
- rev = "0.10.3";
- hash = "sha256-ZDFbI69ECsUTjbhlw2kHRufZbQMu+FQSMmncCJ5pagg=";
- };
-
- buildInputs = [
- alsa-lib
- libpulseaudio
- ncurses
- iniparser
- sndio
- SDL2
- libGL
- portaudio
- jack2
- pipewire
- ];
-
- propagatedBuildInputs = [
- fftw
- ];
-
- nativeBuildInputs = [
- autoreconfHook
- autoconf-archive
- pkgconf
- meson
- ninja
- ];
-
- preAutoreconf = ''
- echo ${version} > version
- '';
-}
diff --git a/nix/lua.nix b/nix/lua.nix
index d4221f1..fc68fdd 100644
--- a/nix/lua.nix
+++ b/nix/lua.nix
@@ -1,6 +1,6 @@
-defaults: {
- pkgs ? defaults.pkgs,
- astal ? defaults.astal,
+self: {
+ pkgs,
+ astal ? self,
name ? "astal-lua",
src,
extraLuaPackages ? (ps: []),
diff --git a/nix/mkAstalPkg.nix b/nix/mkAstalPkg.nix
new file mode 100644
index 0000000..36fcf51
--- /dev/null
+++ b/nix/mkAstalPkg.nix
@@ -0,0 +1,141 @@
+pkgs: let
+ inherit (builtins) replaceStrings readFile;
+ 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 = ${builtins.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";
+ 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
+ ];
+
+ propagatedBuildInputs = [pkgs.glib] ++ packages;
+
+ postUnpack = ''
+ cp --remove-destination ${../lib/gir.py} $sourceRoot/gir.py
+ ${postUnpack}
+ '';
+
+ postInstall = let
+ inherit (builtins) splitVersion elemAt elem;
+ inherit (pkgs.lib.attrsets) filterAttrs;
+
+ ver = splitVersion version;
+ api-ver = "${elemAt ver 0}.${elemAt ver 1}";
+ girName = "Astal${gir-suffix}-${api-ver}";
+
+ 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}
+ '';
+
+ meta = {
+ inherit description;
+ homepage = "https://aylur.github.io/astal";
+ license = pkgs.lib.licenses.lgpl21;
+ };
+ }