NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.33k stars 13.57k forks source link

Package request: statusnotifier-systray-gtk4 #334000

Open Thiago-Assis-T opened 1 month ago

Thiago-Assis-T commented 1 month ago

Project description

Custom widget for GTK4 that represents a system tray. To be used in GTK based desktop panels and other desktop components.

Created by [janetski] (https://codeberg.org/janetski) to have a system tray in the DWL wayland compositor. Api is limited currently.

Metadata


Add a :+1: reaction to issues you find important.

Thiago-Assis-T commented 1 month ago

I tried to take a nag at it, but wasn't able to find a way to make meson and pkg-build to work...

Thiago-Assis-T commented 1 month ago

I'm not a dev yet, but tried to do something here is what i tried:

{
  description = "A very basic flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
    slstatusnotifier-systray-gtk4-src = {
      url = "git+https://codeberg.org/janetski/statusnotifier-systray-gtk4";
      flake = false;
    };
  };

  outputs = { self, nixpkgs, slstatusnotifier-systray-gtk4-src }:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs { inherit system; };

    in {

      packages.${system}.default = pkgs.stdenv.mkDerivation {
        name = "statusnotifier-systray-gtk4";
        src = slstatusnotifier-systray-gtk4-src;
        outputs = [ "out" ];
        nativeBuildInputs = with pkgs; [
          meson
          ninja
          pkg-config
          vala
          gi-docgen
          gobject-introspection
          gdk-pixbuf
          gtk4
        ];
        enableParallelBuilding = true;

      };

    };
}

this is what came out when I ran nix build:

build flags: -j16
[1/12] Compiling C object src/libstatusnotifier-systray-gtk4.so.0.1.0.p/snwatcher.c.o
[2/12] Compiling C object examples/demo.p/demo.c.o
[3/12] Compiling C object src/libstatusnotifier-systray-gtk4.so.0.1.0.p/snitem.c.o
FAILED: src/libstatusnotifier-systray-gtk4.so.0.1.0.p/snitem.c.o 
gcc -Isrc/libstatusnotifier-systray-gtk4.so.0.1.0.p -Isrc -I../src -I/nix/store/wysb3rkzzyldq1r79v846zydz50lhk45-glib-2.80.4-dev/include -I/nix/store/wysb3rkzzyldq1r79v846zydz50lhk45-glib-2.80.4-dev/include/glib-2.0 -I/nix/store/ff27cfibl>
../src/snitem.c:28:32: error: 'PATH_MAX' undeclared here (not in a function)
   28 |         char          iconpath[PATH_MAX];
      |                                ^~~~~~~~
../src/snitem.c:29:32: error: 'NAME_MAX' undeclared here (not in a function)
   29 |         char          iconname[NAME_MAX + 1];
      |                                ^~~~~~~~
../src/snitem.c: In function 'find_cached_icon_path':
../src/snitem.c:156:1: warning: control reaches end of non-void function [-Wreturn-type]
  156 | }
      | ^
../src/snitem.c: In function 'find_cached_icon_name':
../src/snitem.c:165:1: warning: control reaches end of non-void function [-Wreturn-type]
  165 | }
      | ^
At top level:
cc1: note: unrecognized command-line option '-Wno-incompatible-function-pointer-types' may have been intended to silence earlier diagnostics

where should I go from here? can anyone link me some usefull resource?

Thiago-Assis-T commented 1 month ago

Also, if it is relevant: here is the link for the patch that has this as a dependencie: https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/bar-systray

and here is how I'm applying the patches:

    dwl = (pkgs.dwl.overrideAttrs (finalAttrs: previousAttrs: {
      version = "v0.7";
      src = inputs.dwl-src;
      patches = with inputs; [
        dwl-alwayscenter-patch
        dwl-swallow-patch
        dwl-bar-patch
        #dwl-bar-systray-patch
      ];
      buildInputs = previousAttrs.buildInputs ++ [
        pkgs.wlroots_0_18
        pkgs.libdrm
        pkgs.fcft
        pkgs.pixman
        #pkgs.gtk4
        #pkgs.gtk4-layer-shell
      ];
      passthru.providedSessions = [ "dwl" ];
      postInstall = let
        dwlSession = ''
          [Desktop Entry]
          Name=dwl
          Comment=dwm for Wayland
          Exec=slstatus -s | dwl -s "dwlStart <&-"
          Type=Application
        '';
      in ''
        mkdir -p $out/share/wayland-sessions
        echo "${dwlSession}" > $out/share/wayland-sessions/dwl.desktop
      '';
    })).override { configH = ./configs/dwl.h; };

that is inside a nixpkgs.config.packageOverrides = pkgs: { };

i'm supposed to install that package in the dwl source dir... image but I have no clue on how to do it... I was gonna try and package it first.

sorry for the inconvenient ping, but I suppose you would have some relevant input on how to handle this @AndersonTorres

I imagine that this pkg would have to be put as a dependence for dwl and dwl would have to access it as a system lib? like it does wlroots...

Thiago-Assis-T commented 1 month ago

building it as a shared library: image

for it to be a dwl dependence

Thiago-Assis-T commented 1 month ago

Okay, here is the progress I made:

{
  description = "A very basic flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
    slstatusnotifier-systray-gtk4-src = {
      url = "git+https://codeberg.org/janetski/statusnotifier-systray-gtk4";
      flake = false;
    };
  };

  outputs = { self, nixpkgs, slstatusnotifier-systray-gtk4-src }:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs { inherit system; };

    in {

      packages.${system}.default = pkgs.clangStdenv.mkDerivation {
        name = "statusnotifier-systray-gtk4";
        src = slstatusnotifier-systray-gtk4-src;
        outputs = [ "out" ];
        nativeBuildInputs = with pkgs; [
          meson
          ninja
          pkg-config
          vala
          gi-docgen
          gobject-introspection
          gdk-pixbuf
          gtk4
        ];
        enableParallelBuilding = true;
        preBuild = ''
          export PREFIX=$out/usr/local
        '';
        buildPhase = ''
          meson compile 
          meson install 
        '';

      };

    };
}

and the error I'm stoped at:

@nix { "action": "setPhase", "phase": "buildPhase" }
Running phase: buildPhase
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: /nix/store/4mwzwdhdiqviz9bsb4i8ngy5j04qkvf5-ninja-1.12.1/bin/ninja
^M[0/12] Compiling C object src/libstatusnotifier-systray-gtk4.so.0.1.0.p/sndbusmenu.c.o^M[0/12] Compiling C object src/libstatusnotifier-systray-gtk4.so.0.1.0.p/snitem.c.o^M[0/12] Compiling C object src/libstatusnotifier-systray-gtk4.so.>
FAILED: src/libstatusnotifier-systray-gtk4.so.0.1.0.p/snitem.c.o 
clang -Isrc/libstatusnotifier-systray-gtk4.so.0.1.0.p -Isrc -I../src -I/nix/store/wysb3rkzzyldq1r79v846zydz50lhk45-glib-2.80.4-dev/include -I/nix/store/wysb3rkzzyldq1r79v846zydz50lhk45-glib-2.80.4-dev/include/glib-2.0 -I/nix/store/ff27cfi>
../src/snitem.c:28:25: error: use of undeclared identifier 'PATH_MAX'
   28 |         char          iconpath[PATH_MAX];
      |                                ^
../src/snitem.c:29:25: error: use of undeclared identifier 'NAME_MAX'
   29 |         char          iconname[NAME_MAX + 1];
      |                                ^
../src/snitem.c:84:25: error: use of undeclared identifier 'PATH_MAX'
   84 |         char          iconpath[PATH_MAX];
      |                                ^
../src/snitem.c:85:25: error: use of undeclared identifier 'NAME_MAX'
   85 |         char          iconname[NAME_MAX + 1];
      |                                ^
../src/snitem.c:340:25: error: use of undeclared identifier 'NAME_MAX'
  340 |                 if (len == 0 || len > NAME_MAX) {
      |                                       ^
../src/snitem.c:378:17: error: use of undeclared identifier 'PATH_MAX'
  378 |                 if (len + 1 > PATH_MAX) {
      |                               ^
../src/snitem.c:682:29: error: use of undeclared identifier 'PATH_MAX'
  682 |         if (len != 0 && len + 1 <= PATH_MAX && access(nameorpath, R_OK) == 0) {
      |                                    ^
../src/snitem.c:685:32: error: use of undeclared identifier 'NAME_MAX'
  685 |         } else if (len != 0 && len <= NAME_MAX) {
      |                                       ^
8 errors generated.
^M[4/12] Compiling C object src/libstatusnotifier-systray-gtk4.so.0.1.0.p/snsystray.c.o^M[5/12] Compiling C object src/libstatusnotifier-systray-gtk4.so.0.1.0.p/sndbusmenu.c.o
ninja: build stopped: subcommand failed.
Thiago-Assis-T commented 4 weeks ago

I was unable to do it... I'll be waiting on a kind hearted soul to help me

{ lib, clangStdenv, source, gtk4, meson, ninja, pkg-config
, gobject-introspection ? false, vala ? false, gi-docgen ? false }:

clangStdenv.mkDerivation rec {
  pname = "statusnotifier-systray-gtk4";
  version = "0.1.0"; # Update to the correct version

  src = source;
  nativeBuildInputs = [ meson ninja pkg-config vala gi-docgen ];
  buildInputs = [ gtk4 gobject-introspection ];

  # Meson options
  mesonFlags = [ "-Dgir=false" "-Dvala=false" "-Ddocs=false" ];

  meta = with lib; {
    description =
      "A custom GTK4 widget for representing a system tray, designed for GTK-based desktop panels.";
    homepage = "https://codeberg.org/janetski/statusnotifier-systray-gtk4";
    license = licenses.mit; # Check and update if necessary
    maintainers = with maintainers; [ ];
    platforms = platforms.linux;
  };
}
Thiago-Assis-T commented 4 weeks ago

Apparently, this looks like a problem with nixos and the limits.h header file

I have added the package and the patch and they worked fine on my machine. Since I don't know how to make a pr, i'll wait for this to be added. but the systray is working.

nixos-discourse commented 4 weeks ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/where-is-limits-h/50535/1

Thiago-Assis-T commented 4 weeks ago

The problem was a wrongly set c standard in the meson file in the project, the author corrected it and now it builds!