Advice sought for Nix packaging

Hello, I’m trying to compile my very first Nix package, which downloads and installs an Openbox theme from Gitlab:
Nord Openbox Theme

All I need to do is copy the openbox-3 directory into $out/share/themes in the package.

I get the error

error: function ‘anonymous lambda’ called without required argument ‘lib’

Disclaimer - I’m not the author, just a user who wants to use his theme on NixOS Openbox

Here is the Nix code. Some was derived from code generated by Google Gemini AI

Thank you for advice.

{ pkgs ? import <nixpkgs> {}, stdenv, lib, ... }:

stdenv.mkDerivation rec {
  pname = "nord-openbox-theme";
  version = "master"; # no version number in repository

  src = pkgs.fetchgit {
    url = "gitlab.com/the-zero885/${pname}";
    # rev = "1818f7a1ba4f397cceb9023f7e14b35201e597f1";
    hash = "sha256-oaZ+YZOCIUzetCYs0BVXzmbGn96qKiJcRS/kCi2nyQY=";
  };

  installPhase = ''
    runHook preInstall

    mkdir -p $out/share/themes/${pname}/
    cp -ar openbox-3/ $out/share/themes/${pname}/

    runHook postInstall
  '';

  meta = with lib; {
    description = "Openbox Nordic theme by César Salazar";
    longDescription = "This Openbox theme can also complement the `nordic` Nix package";
    homepage = "https://gitlab.com/the-zero885/${pname}";
    license = licenses.mit;
    maintainers = with maintainers; [ to-be-added ];
  };
}

I cleaned up the code a little:

{ pkgs, stdenv, ... }:

stdenv.mkDerivation rec {
  pname = "nord-openbox-theme";
  version = "master";

  src = pkgs.fetchgit {
    url = "https://gitlab.com/the-zero885/${pname}";
    rev = "1818f7a1ba4f397cceb9023f7e14b35201e597f1";
    hash = "sha256-oaZ+YZOCIUzetCYs0BVXzmbGn96qKiJcRS/kCi2nyQY=";
  };

  installPhase = ''
    mkdir -p $out/share/themes/${pname}/
    cp -ar openbox-3/ $out/share/themes/${pname}/
  '';
}

To test it, I ran

$ nix-build -E "with import <nixpkgs> {}; callPackage ./package.nix {}"

Then I checked in the result directory symlink:

$ ls result/share/themes/nord-openbox-theme/openbox-3/
bullet.xbm	   desk_toggled_hover.xbm  max_pressed.xbm	    shade_toggled_hover.xbm
close_hover.xbm    desk.xbm		   max_toggled_hover.xbm    shade.xbm
close_pressed.xbm  iconify_hover.xbm	   max_toggled_pressed.xbm  themerc
close.xbm	   iconify_pressed.xbm	   max.xbm
desk_hover.xbm	   iconify.xbm		   shade_hover.xbm
desk_pressed.xbm   max_hover.xbm	   shade_pressed.xbm

Does this look right to you?

1 Like

Thank you for your kind assistrance! The only change I had to make was to include the lib in the parameter set on the first line, to include the meta attributes. And thank you again!