diff options
author | Aylur <[email protected]> | 2024-12-21 21:25:29 +0100 |
---|---|---|
committer | Aylur <[email protected]> | 2024-12-21 21:25:29 +0100 |
commit | e0a6b7fc5ae38f13e5c110956bb94ac3b41bfb14 (patch) | |
tree | aebfe3e620372efdd595f6479268bc551e4c519a | |
parent | fcef5cea5ca84fa06a74e69de34e84b4d0842fcc (diff) | |
parent | 0507a6bf1035ddbe72fdb64c0fb5dc1c991faeaf (diff) |
Merge branch 'main' into feat/wayland-glib
31 files changed, 557 insertions, 409 deletions
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(() => { @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1729256560, - "narHash": "sha256-/uilDXvCIEs3C9l73JTACm4quuHUsIHcns1c+cHUJwA=", + "lastModified": 1734424634, + "narHash": "sha256-cHar1vqHOOyC7f1+tVycPoWTfKIaqkoe1Q6TnKzuti4=", "owner": "nixos", "repo": "nixpkgs", - "rev": "4c2fcb090b1f3e5b47eaa7bd33913b574a11e0a0", + "rev": "d3c42f187194c26d9f0309a8ecc469d6c878ce33", "type": "github" }, "original": { @@ -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..99f09dd --- /dev/null +++ b/lib/river/default.nix @@ -0,0 +1,15 @@ +{ + mkAstalPkg, + pkgs, + ... +}: +mkAstalPkg { + pname = "astal-river"; + src = ./.; + packages = [pkgs.json-glib]; + + libname = "river"; + authors = "kotontrion"; + gir-suffix = "River"; + description = "IPC client for River"; +} 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/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; + }; + } |