A few weeks ago I ran nix flake update to get the latest versions of CLI tools that I regularly use from nixos-unstable.

atuin is one of those tools which I started using relatively recently and quickly became a huge fan of.

I run it on all of my machines, and I can’t overstate how amazing it is to have all of my shell history across all of my machines synced. I also self-host the atuin server, because why not?

While I typically install my CLI tools from nixos-unstable, with services that I self-host I tend to be a little more conservative and run them from the latest stable release, which is currenly nixos-23.11.

The atuin CLI tool had some database migrations as part of the v18 release that made it incompatible with servers running v17, which is what my self-hosted atuin server is running from nixos-23.11.

Usually this would be a non-issue since most service modules in Nixpkgs have a package option that lets you override the package used for a service. However, unfortunately for the atuin service on nixos-23.11 this is not the case (though a package override has now been added in nixos-unstable!)

As long as you have nixos-unstable as an input on your flake (hint: all my NixOS starter templates have this!) it’s possible for you to grab a single service module from nixos-unstable while keeping the rest of your services running against nixos-23.11 (or whatever the latest stable release is when you’re reading this).

{
    pkgs, 
    inputs, 
    ...,
}: {
  # first we need to disable the service module coming from nixpkgs
  # the path we give here is relative to the nixos/modules/ dir
  disabledModules = [
    "services/misc/atuin.nix"
  ];

  # then we add an import of the same module from nixpkgs-unstable
  imports = [
    "${inputs.nixpkgs-unstable}/nixos/modules/services/misc/atuin.nix"
  ]
  
  # now this service definition block refers to the module as defined in
  # inputs.nixos-unstable! pretty cool!
  services.atuin = {
    enable = true;
    package = pkgs.unstable.atuin;
    openRegistration = false;
  };

}

If you’re interested in what I read to come up with solutions like this one, you can subscribe to my Software Development RSS feed.

If you’d like to watch me writing code while explaining what I’m doing, you can also subscribe to my YouTube channel.

If you found this content valuable, or if you are a happy user of the komorebi tiling window manager or my NixOS starter templates, please consider sponsoring me on GitHub or tipping me on Ko-fi.