Where is limits.h?

Okay, I’m trying to package this application: janetski/statusnotifier-systray-gtk4 - Codeberg.org for me to use a patch with dwl, opened an issue here: Package request: statusnotifier-systray-gtk4 · Issue #334000 · NixOS/nixpkgs · GitHub and i’ve been trying to package it… but no matter how I do it, it doesn’t find the variables declared in limits.h (although the header file is included)…

here is the package.nix

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

clangStdenv.mkDerivation {
  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 ];

  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;
  };
}


and here is my flake.nix

{
  description = "A very basic flake";

  inputs = {
    statusnotifier-systray-gtk4-src = {
      url = "git+https://codeberg.org/janetski/statusnotifier-systray-gtk4";
      flake = false;
    };

    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
  };

  outputs = { nixpkgs, ... }@inputs:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs { inherit system; };
    in {
      packages.${system}.default = pkgs.callPackage ./package.nix {
        source = inputs.statusnotifier-systray-gtk4-src;
      };

    };
}

here is the compiler complaint:

@nix { "action": "setPhase", "phase": "buildPhase" }
Running phase: buildPhase
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 
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:684:29: error: use of undeclared identifier 'PATH_MAX'
  684 |         if (len != 0 && len + 1 <= PATH_MAX && access(nameorpath, R_OK) == 0) {
      |                                    ^
../src/snitem.c:687:32: error: use of undeclared identifier 'NAME_MAX'
  687 |         } else if (len != 0 && len <= NAME_MAX) {
      |                                       ^
8 errors generated.
[4/12] Compiling C object src/libstatusnotifier-systray-gtk4.so.0.1.0.p/snsystray.c.o
[5/12] Compiling C object src/libstatusnotifier-systray-gtk4.so.0.1.0.p/sndbusmenu.c.o
ninja: build stopped: subcommand failed.

here is the file that it complains about:

am I missing something? the limits.h header file should be in the glibc right?

1 Like

also found this two issues, that didn’t seem to help me… but I could be missing something:

1 Like

If I had to guess this is either a missing #define so you don’t get NAME_MAX and PATH_MAX or another package in the build closure provides a different limits.h.

2 Likes

apparently the code it self is fine, the creator built the project on arch with no issues… so I don’t think it is a bad code problem, but feel free to check and give me some tips, im not a dev so…

The solution was that the C standard was wrongly set in the Meson project file! the author updated it and it built

1 Like