How to use service definitions from unstable channel?

I’m aware of how to easily get a package from unstable channel:

let
  unstable = import <nixos-unstable> { };
in {
  service.xyz.package = unstable.xyz;
}

As suggested by this post:

But how do I do the same thing for a service definition?
For example, I’ve submitted a PR for syncthing service:

But how can I now use that one service configuration while still using nixos-21.05 channel for everything else?

2 Likes
3 Likes

Ah, lovely, thank you!

For future searchers:

On my system currently based on release-23.05, in which I pass inputs.nixpkgs-unstable to my configuration via specialArgs = {inherit inputs;}; and have an overlay that provides pkgs.unstable, I was unable to import an unstable service as hoped with:

{pkgs, ...}: {
    imports = [
        "${pkgs.unstable.path}/path/to/module.nix"
    ];
}

due to an infinite recursion error. Thankfully the following worked fine:

{pkgs, ...} @ args: {
    imports = [
        "${args.inputs.nixpkgs-unstable}/path/to/module.nix"
    ];
}