Modifying systemd services channel for a specific package

I’m facing an issue while attempting to make use of the unstable version of Duplicati (2.0.7.2) within the services configuration. I’ve installed Duplicati from the unstable channel, since my default channel is the stable one. Here’s the setup I’ve used:

let
  unstable = import <nixos-unstable-small> { config = { allowUnfree = true; }; };
in
{
  environment.systemPackages = with pkgs; [
    # ... other apps ...
    unstable.duplicati
    # ...
  ];

  services.duplicati = {
    enable = true;
    interface = "any";
  };
}

The issue seems to stem from the service utilizing the Duplicati version from the stable channel instead of the unstable version. I suspect this is because the service is defined in this manner (as shown here):

ExecStart = "${pkgs.duplicati}/bin/duplicati-server --webservice-interface=${cfg.interface} --webservice-port=${toString cfg.port} --server-datafolder=${cfg.dataDir}";

and pkgs point to the stable channel.
I’m encountering a warning related to a collision between the two version:

warning: collision between `/nix/store/qz572qn7fhswp6pnxxplsbj3qw1gl9wh-duplicati-2.0.7.1/bin/duplicati-server' and `/nix/store/ks8l3m01im883ddja25dg02x2qk9dl0h-duplicati-2.0.6.3/bin/duplicati-server'

Is there a way to override pkgs so that it references the unstable channel within the services configuration just for duplicati?

Yes, but it’s a bit awkward: https://nixos.org/manual/nixos/stable/#sec-replace-modules

Also consider submitting a PR to nixpkgs to add a package option to the module, like so

Hi @TLATER thanks for the answer. I already tried like that but without success

  disabledModules = [ "services/misc/gogs.nix" "services/backup/duplicati.nix"];
  imports =
    [ # Use services from nixos-unstable channel.
    <nixos-unstable-small/nixos/modules/services/misc/gogs.nix>
    <nixos-unstable-small/nixos/modules/services/backup/duplicati.nix>
    ];

  services.gogs = {
    enable = true;
  };


# Enable and configure duplicati as a service
  services.duplicati = {
    enable = true;
    interface = "any";
  };

Hi @TLATER thanks for the answer. I already tried like that but without success

  disabledModules = [ "services/misc/gogs.nix" "services/backup/duplicati.nix"];
  imports =
    [ # Use services from nixos-unstable channel.
    <nixos-unstable-small/nixos/modules/services/misc/gogs.nix>
    <nixos-unstable-small/nixos/modules/services/backup/duplicati.nix>
    ];

  services.gogs = {
    enable = true;
  };


# Enable and configure duplicati as a service
  services.duplicati = {
    enable = true;
    interface = "any";
  };

I use to do this with gogs because the unstable branch have some fixed I needed for the newer version on the stable, but with duplicati don’t work, still take the version from the stable. Did I miss something?

@ius I’ll open a pr, thanks

The module definition will be from unstable, but the package used will be from stable. You’ll probably need that .package option to make this work.

OK, thanks. I have opened a pull request