NixOS derivation

Nixpkgs package

Install from nixpkgs the package atuin-desktop.

Local derivation

This was written by @dzervas, and shared on our Discord. Update the package to the current version (careful that versions 1.4 and higher require Rust 1.90 which is not yet supported by nixpkgs. See update PR).

{ lib,
  stdenv,
  fetchurl,
  dpkg,
  wrapGAppsHook4,
  dbus,
  zlib,
  fontconfig,
  openssl,
  webkitgtk_4_1,
  gtk3,
  pango,
  cairo,
  gdk-pixbuf,
  libsoup_3,
  glib,
  glib-networking,
  gcc,
  pkg-config,
}:

stdenv.mkDerivation rec {
  pname = "atuin-desktop";
  version = "0.1.0";

  src = fetchurl {
    url = "https://github.com/atuinsh/desktop/releases/download/v${version}/Atuin_Desktop_${version}_amd64.deb";
    sha256 = "sha256-P7FjtavGq2jpoMO8GYNejlDDKN+gIfAjdgjLkF4ZjRg=";
  };

  nativeBuildInputs = [
    dpkg
    wrapGAppsHook4
    pkg-config
  ];

  buildInputs = [
    # System libraries
    dbus
    zlib
    fontconfig

    # GTK and related libraries
    webkitgtk_4_1
    gtk3
    pango
    cairo
    gdk-pixbuf

    # Network and utility libraries
    libsoup_3

    # GLib libraries
    glib
    glib-networking

    # Runtime dependencies
    gcc.cc.lib  # For libgcc_s.so.1

    openssl
  ];

  unpackPhase = ''
    dpkg-deb -x $src .
  '';

  installPhase = ''
    mkdir -p $out
    cp -r usr/* $out/ || true

    # Ensure desktop files exist and are properly configured
    if [ -d $out/share/applications ]; then
      for desktop in $out/share/applications/*.desktop; do
        if [ -f "$desktop" ]; then
          substituteInPlace "$desktop" \
            --replace "Exec=/usr/bin/" "Exec=$out/bin/"
        fi
      done
    fi
  '';

  preFixup = ''
    gappsWrapperArgs+=(
      # Ensure the binary can find all required libraries
      --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs}
    )
  '';

  postFixup = ''
    echo "=== Debugging binary ==="
    if [ -f "$out/bin/atuin-desktop" ]; then
      echo "Binary exists"
      file "$out/bin/atuin-desktop"
      ldd "$out/bin/atuin-desktop" || echo "ldd failed"
      readelf -l "$out/bin/atuin-desktop" | grep interpreter || echo "No interpreter found"
    else
      echo "Binary not found, listing contents:"
      find "$out" -name "*atuin*" -type f
    fi
    echo "=== End debugging ==="
    find $out/bin -type f -executable | while read -r bin; do
      echo "Patching binary: $bin"

      # Check if it's an ELF binary
      if file "$bin" | grep -q "ELF"; then
        echo "  Setting interpreter..."
        patchelf --set-interpreter ${stdenv.cc.bintools.dynamicLinker} "$bin" || echo "  Failed to set interpreter"

        echo "  Setting rpath..."
        patchelf --set-rpath ${lib.makeLibraryPath buildInputs} "$bin" || echo "  Failed to set rpath"

        echo "  Shrinking rpath..."
        patchelf --shrink-rpath "$bin" || echo "  Failed to shrink rpath"
      fi
    done
  '';

  meta = with lib; {
    description = "Atuin Desktop";
    homepage = "https://atuin.sh";
    license = licenses.asl20;
    maintainers = [];
    platforms = ["x86_64-linux"];
  };
}

Known issues

  1. Context menu does not open correctly
  2. Missing icons (again?)
5 Likes

THANK YOU! I just asked Ellie on Mastodon about this and, while I am not shocked someone already did this, I was almost expecting to do it myself. EITHER WAY, so happy.

2 Likes

Updated to patch the elf instead of residing to nix-ld for the dynamic libs

1 Like

Awesome! Thanks for maintaining this one!

glib-networking is not included in the buildInputs, adding this back in fixed the icons for me.

3 Likes

right! fixed it, thanks!

1 Like

Going to ask a stupid question, again.

@dzervas the download link i have in the email I got for the closed beta doesn’t seem to work. Where are you getting updated links?

Additionally, I assume you are using nix-hash to generate the hash value for the package?

@ellie can help with the link

regarding the hash: nix-prefetch-url if I’m not mistaken

@randoneering, I just DMd you a link to the deb download :slight_smile:

Perfect-thank you to the both of you. I will attempt to build tonight

Derivation update: Added OpenSSL since it seems to be a dependency now

2 Likes

hey! update for everyone here!

we’re now open source - and our releases are on GitHub. What’s needed to update the derivation here to work with that?

1 Like

Yes please! I’m a NixOS user, and very excited to try desktop. But I definitely shouldn’t be trusted to figure this one out.

A recommended starting point would be greatly appreciated. Is the code in the original post still valid? What download url should I use from the github release?

Hey. For now, just use the derivation from above, and include the package in your packages list. As source, it downloads the deb package from releases on GitHub. I am trying to make compiling from source work, but there are still some issues to solve.

1 Like

Hey, Ellie. I am trying to make Atuin Desktop compile from source. In the meantime, as a quick and dirty fix, I modified the original post with a working derivation for Atuin Desktop utilizing the existing .deb package from GitHub releases (filling in the previously empty `src = FILL ME IN` link). When the compilation from source works, we can package this derivation upstream in nixpkgs, so that everyone using Nix can run Atuin Desktop without having to fiddle with these derivations themselves.

1 Like

That’s awesome, thank you so much! I don’t use nix so won’t be able to help there, but lmk if you are facing any weird compilation issues you think I can help with :folded_hands:

@Adda

I just opened this:

If you find something I did wrong or need to change, let me know. I was able to build the package just fine and run it. I did notice an issue with the “Window” tab but I need to validate that its not a linux version issue, a missing dependency in the package, or something else.

@dzervas Just pinging you since you did all the hard work. I would love to have you as a fellow maintainer but you absolutely don’t have to. I am using this as a way to learn nix outside of nixos and flakes. Even if you do not want to maintain, I’d love for some help or guidance if I run into issues. No expectations. Thank you for getting this together!

@randoneering oh yes please! and thank you for opening a PR

I’ll try to work on the source building derivation too

1 Like

Awesome!

I know @Adda mentioned here and in the PR they were looking at it too.

Could you provide your GitHub details?

GitHub username and ID

Your name you wish to be identified by in the maintainers list

And your email! You can dm me if you wish to not put it out there in this forum.

1 Like