diff --git a/README.md b/README.md index 3be0a808..31edc78f 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ https://github.com/user-attachments/assets/5c054ac3-90bb-483e-a8f2-5af191805f04 * [Debian](#debian) * [Guix](#guix) * [rde](#rde) + * [NixOS](#nixos) * [Other](#other) * [Sway Usage](#sway-usage) * [Run](#run) @@ -189,6 +190,41 @@ But we recommend to use [Guix Home](https://guix.gnu.org/manual/devel/en/html_no (feature-swaynotificationcenter) ``` +### nixOS + +Add it as a flake: +``` +swaync-flake.url = "github:ErikReider/SwayNotificationCenter" # use optional ?ref= to point to a particular version +``` +And in your config: +``` +# https://mynixos.com/home-manager/options/services.swaync +services.swaync = { + enable = true; # Starts the daemon and sets up the service + package = inputs.swaync-flake.packages.${pkgs.system}.default; + + settings = { + positionX = "right"; + positionY = "top"; + control-center-margin-top = 10; + notification-icon-size = 64; + # Add widgets, timeouts, etc. here (full options via the schema link above) + widgets = [ "title" "dnd" "notifications" "mpris" "buttons-grid" ]; + # Example toggle button + "buttons-grid" = { + actions = [ + { + label = "WiFi"; + type = "toggle"; + command = "nmcli radio wifi off"; # Simplified example + } + ]; + }; + }; +}; +``` + + ### Other #### Dependencies diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..10a74143 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1765472234, + "narHash": "sha256-9VvC20PJPsleGMewwcWYKGzDIyjckEz8uWmT0vCDYK0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2fbfb1d73d239d2402a8fe03963e37aab15abe8b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..5426315a --- /dev/null +++ b/flake.nix @@ -0,0 +1,107 @@ +{ + description = "Flake for building SwayNotificationCenter"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + inherit (pkgs) lib; + + swaync = pkgs.stdenv.mkDerivation { + pname = "swaynotificationcenter"; + version = "unstable-${self.shortRev or "dirty"}"; + + src = self; + + nativeBuildInputs = with pkgs; [ + meson + ninja + pkg-config + vala + gettext + blueprint-compiler + sassc + scdoc + cmake + wayland-scanner + git + wrapGAppsHook3 + glib.bin + python3 + libxml2 + ]; + + buildInputs = [ + pkgs.glib.dev + pkgs.gtk4.dev + pkgs.libadwaita.dev + pkgs.pantheon.granite7.dev + pkgs.json-glib.dev + pkgs.libnotify.dev + pkgs.librsvg.dev + pkgs.pango.dev + pkgs.cairo.dev + pkgs.gtk4-layer-shell.dev + pkgs.libevdev + pkgs.libinput + pkgs.libpulseaudio + pkgs.wayland.dev + pkgs.wayland-protocols + ]; + + # Patch the shebang to the Nix python interpreter + postPatch = '' + patchShebangs build-aux/meson/postinstall.py + ''; + + # Configure with meson + configurePhase = '' + runHook preConfigure + meson setup build \ + --prefix=$out \ + --libdir=lib \ + --datadir=share \ + -Dman-pages=true \ + -Dsystemd-service=false + runHook postConfigure + ''; + + # Build with ninja + buildPhase = '' + runHook preBuild + ninja -C build + runHook postBuild + ''; + + # Install with ninja + installPhase = '' + runHook preInstall + ninja -C build install + runHook postInstall + ''; + + doCheck = false; + + meta = with lib; { + description = "A GTK-based notification daemon for Sway"; + homepage = "https://github.com/ErikReider/SwayNotificationCenter"; + license = licenses.mit; + platforms = platforms.linux; + maintainers = with maintainers; [ ]; + }; + }; + in { + packages.default = swaync; + + apps.default = flake-utils.lib.mkApp { + drv = swaync; + # If the binary name is known, set it explicitly: + # program = "${swaync}/bin/swaync"; + }; + }); +}