Creating derivation for Urn, a split tracker for speedrunning

Hello, I am fairly new to Nix / NixOS and wanted to install urn a program that tracks ‘splits’ for speedrunning.

I have created few simple derivations and followed the Nix Pills, but I’m at a loss with this one. The Makefile has a lot of references to /usr/share which it doesn’t seem like NixOS has, so i’m not sure what to do in that regard.

The repository seems abandoned so i will likely have to fork it and change some things in the Makefile,
but I am not sure exactly what to do.

I am tracking Nixpkgs 20.03 channel.

Thanks in advance.

I would try to use substituteInPlace inside the preConfigure phase. Something like:

substituteInPlace GNUmakefile --replace \
  "BIN_DIR     = /usr/local/bin" \
  "BIN_DIR     = $out/bin"
1 Like

Thinking better, maybe it’s better to make the Makefile use the DESTDIR variable, like this Practical Makefiles, by example

1 Like

You would use

makeFlags = [
  "BIN_DIR=${placeholder "out"}/bin"
];

plus the other variables but the Makefile hardcodes /usr so some substitution will be necessary. I opened a pull request that will make just the following suffice:

makeFlags = [
  "PREFIX=${placeholder "out"}"
];
1 Like

Thank you and @brogos very much for the help. I will try tomorrow.

It would be a cool case for “hey, upstream, what about some patches?”.

On the other hand, a custom “installPhase” would be better for now.

1 Like

Thank you so much for the help! I got it working by forking the project and apply @jtojnar’s patch.
This is the default.nix i ended up with:

{ stdenv, fetchgit
, pkgconfig, wrapGAppsHook
, xxd, rsync, imagemagick
, glib, gsettings_desktop_schemas, gtk
, jansson
}:

let
  pname = "urn";
  version = "1.0";
in stdenv.mkDerivation {
  inherit pname version;

  src = fetchgit (builtins.fromJSON (builtins.readFile ./source.json));

  nativeBuildInputs = [ pkgconfig wrapGAppsHook ];
  buildInputs = [ 
    # Needed for Makefile
    xxd rsync imagemagick
    # Needed for GSETTINGS_SCHEMAS_PATH
    gsettings_desktop_schemas glib gtk
    # Other dependencies
    jansson
  ];

  makeFlags = [
    "PREFIX=${placeholder "out"}"
  ];

  meta = {
    homepage = "https://github.com/3snowp7im/urn";
    description = "Simple split tracker hacked together by 3snow p7im.";
    license = stdenv.lib.licenses.gpl3;
  };
}
2 Likes

rsync as a build input? That’s weird!

1 Like

https://github.com/NixOS/nixpkgs/pull/108953

:slight_smile:

2 Likes

Good job @fgaz :slight_smile: