how to add NixOS unstable channel declaratively in configuration.nix

本小妞迷上赌 提交于 2019-12-02 19:37:11

I was able to get this working with a suggestion by @EmmanuelRosa.

Here are the relevant parts of my /etc/nixos/configuration.nix:

{ config, pkgs, ... }:

let
  unstableTarball =
    fetchTarball
      https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz;
in
{
  imports =
    [ # Include the results of the hardware scan.
      /etc/nixos/hardware-configuration.nix
    ];

  nixpkgs.config = {
    packageOverrides = pkgs: {
      unstable = import unstableTarball {
        config = config.nixpkgs.config;
      };
    };
  };

  ...
};

This adds an unstable derivative that can be used in environment.systemPackages.

Here is an example of using it to install the htop package from nixos-unstable:

  environment.systemPackages = with pkgs; [
    ...
    unstable.htop
  ];
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!