[Solved] How can I install locales and gsettings schemas on a nixpkg?

I’be been trying to package my application to the NUR but I’m struggling to find documentation on how exactly to install locales and gsettings schemas when my package is installed. However, the closest I’ve gotten is following how the shortwave package.nix does it but it does not show how it does it since it uses ninja to build the application and I’m using rustPlatform. Is there any guidance or documentation on how to accomplish this?

{
  gtk4,
  glib,
  fetchFromGitHub,
  rustPlatform,
  lib,
  pkg-config,
  wrapGAppsHook4,
  ffmpeg,
  sqlite,
  openssl,
  gsettings-desktop-schemas
}:

rustPlatform.buildRustPackage rec {
  pname = "waytrogen";
  version = "0.5.5";
  preferLocalBuild = true;

  src = fetchFromGitHub {
    owner = "nikolaizombie1";
    repo = pname;
    rev = "cfedddbed9a957f5b1fe99af0e3bab0557ef1008";
    hash = "sha256-sDlxufSTXRyX+Cqs4CRUSITpN0IVRwlQTba+YsTWvi0=";
  };

  

  nativeBuildInputs = [ pkg-config glib wrapGAppsHook4 sqlite ];
  buildInputs = [ glib gtk4 ffmpeg sqlite openssl gsettings-desktop-schemas ];
  env = {
    OPENSSL_NO_VENDOR = 1;
  };
  
  cargoHash = "sha256-/UVK0Jv36R0sKnMM+dzC0u/N7diK+8Es72sOMuO72nY=";

  meta = {
    description = "A lightning fast wallpaper setter for Wayland.";
    longDescription = "A GUI wallpaper setter for Wayland that is a spiritual successor for the minimalistic wallpaper changer for X11 nitrogen. Written purely in the Rust programming language. Supports hyprpaper, swaybg, mpvpaper and swww wallpaper changers.";
    homepage = "https://github.com/nikolaizombie1/waytrogen";
    license = lib.licenses.unlicense;
    maintainers = [ ];
  };
}

Cargo does not support installing extra files, which is why some other build system is needed. For GNOME-adjacent apps, Meson is the build system of choice.

You could build the files manually with msgfmt and glib-compile-schemas in postBuild and then copy the locales to $out/share/locale and the compiled schema to $out/share/glib-2.0/schemas in postInstall. But it is preferred to do that in upstream build system so that each distro does not need to duplicate this work.

Once you get that, see the GNOME section of the Nixpkgs manual.

Thank you so much. I’ll look into meson. I thought it was a C++ thing.

The Rust support is still a bit underwhelming – if you want to use crates, you need to run Cargo yourself – but Shortwave is a Rust program and it uses Meson.

There is also a template repo: World / Rust / gtk-rust-template · GitLab

1 Like

That template is a godsend. Thank you very much.