how to add NixOS unstable channel declaratively in configuration.nix

前端 未结 1 858
孤城傲影
孤城傲影 2021-01-31 00:13

The NixOS cheatsheet describes how to install packages from unstable in configuration.nix.

It starts off by saying to add the unstable channel

1条回答
  •  时光说笑
    2021-01-31 00:49

    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
      ];
    

    0 讨论(0)
提交回复
热议问题