Build Error in Package

I’m trying to package wallock, a wallpaper daemon for wlroots compositors, but I’m getting an error during the build process. I’m using the build instructions from the wallock GitHub repository.

# wallock.nix

{
  stdenv,
  fetchFromGitHub,
  cmake,
  cpm-cmake,
  wayland,
  wayland-protocols,
  egl-wayland,
  libxkbcommon,
  mesa,
  mpv,
  cairo,
  fontconfig,
  wget,
  unzip,
}:
stdenv.mkDerivation rec {
  name = "wallock";
  version = "git";

  src = fetchFromGitHub {
    owner = "dpayne";
    repo = "wallock";
    rev = "main";
    sha256 = "sha256-9EcdFGuH2hvtGYGNBbXbERAiALkP3jm7G5KYiAlD/Fk=";
  };

  buildInputs = [
    cmake
    cpm-cmake
    wayland
    wayland-protocols
    egl-wayland
    libxkbcommon
    mesa
    mpv
    cairo
    fontconfig
    wget
    unzip
  ];

  postInstall = ''
    mkdir -p $out/share/fonts
    cp -r $src/fonts/* $out/share/fonts
    fc-cache -fv
  '';

  buildPhase = ''
    mkdir build
    cd build
    cmake -DCMAKE_BUILD_TYPE=Release -B build
    cmake --build build
  '';

  installPhase = ''
    cmake --install build
  '';
}

# packages.nix

environment.systemPackages = let
  wallock = pkgs.callPackage ../../pkgs/wallock.nix {};
in
  with pkgs; [
    wallock
  ];

This is the error I’m getting:

error: builder for '/nix/store/10blf5phnww4y1c3na8lm5kj68yd6aya-wallock.drv' failed with exit code 1;
       last 10 log lines:
       >   CMakeLists.txt:31 (include)
       >
       >
       > CMake Error at cmake/ProjectLibraries.cmake:1 (CPMAddPackage):
       >   Unknown CMake command "CPMAddPackage".
       > Call Stack (most recent call first):
       >   CMakeLists.txt:32 (include)
       >
       >
       > -- Configuring incomplete, errors occurred!
       For full logs, run 'nix log /nix/store/10blf5phnww4y1c3na8lm5kj68yd6aya-wallock.drv'.
error: 1 dependencies of derivation '/nix/store/15difp825c010642lcq12fpg6klm27h3-system-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/6502fngasjqyb8hdml5xyllrkl23wsll-nixos-system-<MY CONFIG NAME HERE OMITTED FOR PRIVACY REASONS>-24.05.20240509.f1010e0.drv' failed to build

Any help will be greatly appreciated.

The CPMAddPackage function is from CPM.cmake and wants to fetch dependencies from the outside, which will not work in a sandboxed Nix build. The CMake files of wallock have to be patched to support using dependencies from Nixpkgs instead of from CPM.

The only instance I could find is the diopster package. It copies sources of the dependencies and replaces the CPMAddPackage calls with add_subdirectory. For wallock, instead of as sub-directories, you might want to patch it to use spdlog and cxxopts from Nixpkgs directly.

2 Likes

Thanks for your reply! Figuring all of that out as a NixOS noob such as myself is unreasonable just for a wallpaper daemon, LOL. I appreciate your explanation, so I will just leave it here in case someone in the future encounters a similar problem and actually decides to do all of that.

1 Like