Nixpkgs: [Question] How to enable a service from a different channel

Created on 29 May 2018  路  6Comments  路  Source: NixOS/nixpkgs

Issue description

How do you enable a service from a different channel, such as nixos-unstable?
(import <nixos-unstable> {}).whatever works for packages, but I can't find a way to do something similar for a service, is this possible?

Steps to reproduce

N/A

Technical details

  • system: "x86_64-linux"
  • host os: Linux 4.14.43, NixOS, 18.03.132507.5f2da7f837e (Impala)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.0.2
  • channels(root): "nixos-18.03, nixos-unstable, nixpkgs"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs
question nixos

Most helpful comment

You need to disable the module and import it from the other channel, i.e.

{ config, pkgs, lib, ... }:

let
  unstable = import <nixos-unstable> { };
in
{
  imports = [ <nixos/modules/services/web-servers/caddy.nix> ];
  disabledModules = [ "services/web-servers/caddy.nix" ];
}

I think it than uses the package from the "normal" channel, so you need to override that aswell (either as in the next example or via an overlay).

If you want to change the channel for an unfree package, you need to allow unfree packages for the unstable channel as well, i.e.

let
  baseconfig = { allowUnfree = true; };
  unstable = import <nixos-unstable> { config = baseconfig; };
in
{
  imports = [ <nixos-unstable/nixos/modules/services/networking/unifi.nix> ];

  disabledModules = [ "services/networking/unifi.nix" ];

  nixpkgs.config = baseconfig // {
    packageOverrides = pkgs: {
      unifi = unstable.unifi;
    }; 
  };
};

All 6 comments

You need to disable the module and import it from the other channel, i.e.

{ config, pkgs, lib, ... }:

let
  unstable = import <nixos-unstable> { };
in
{
  imports = [ <nixos/modules/services/web-servers/caddy.nix> ];
  disabledModules = [ "services/web-servers/caddy.nix" ];
}

I think it than uses the package from the "normal" channel, so you need to override that aswell (either as in the next example or via an overlay).

If you want to change the channel for an unfree package, you need to allow unfree packages for the unstable channel as well, i.e.

let
  baseconfig = { allowUnfree = true; };
  unstable = import <nixos-unstable> { config = baseconfig; };
in
{
  imports = [ <nixos-unstable/nixos/modules/services/networking/unifi.nix> ];

  disabledModules = [ "services/networking/unifi.nix" ];

  nixpkgs.config = baseconfig // {
    packageOverrides = pkgs: {
      unifi = unstable.unifi;
    }; 
  };
};

Ok thanks, that answers my question.

SOLVED

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/add-unstable-options-to-stable-install/6482/4

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/virtualbox-keeps-getting-rebuilt/6612/3

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nixos-module-development-workflow/8217/5

Was this page helpful?
0 / 5 - 0 ratings

Related issues

langston-barrett picture langston-barrett  路  3Comments

grahamc picture grahamc  路  3Comments

edolstra picture edolstra  路  3Comments

chris-martin picture chris-martin  路  3Comments

ghost picture ghost  路  3Comments