【发布时间】:2017-11-30 10:27:13
【问题描述】:
我正在使用默认的 nixos 17.09 频道,并希望从不稳定的频道安装 unfree 包。
在这种情况下,我使用(import <nixos-unstable> {}).vscode 安装vscode,但我收到了我必须设置...allowUnfree = true; 的错误
该设置似乎仅适用于默认频道。
如何在不稳定的频道上也设置allowFree = true;?
【问题讨论】:
我正在使用默认的 nixos 17.09 频道,并希望从不稳定的频道安装 unfree 包。
在这种情况下,我使用(import <nixos-unstable> {}).vscode 安装vscode,但我收到了我必须设置...allowUnfree = true; 的错误
该设置似乎仅适用于默认频道。
如何在不稳定的频道上也设置allowFree = true;?
【问题讨论】:
我找到了解决方案 (https://github.com/NixOS/nixpkgs/issues/25880#issuecomment-322855573)。
它为具有相同配置的不稳定通道创建别名。
nixpkgs.config =
{
# Allow proprietary packages
allowUnfree = true;
# Create an alias for the unstable channel
packageOverrides = pkgs:
{
unstable = import <nixos-unstable>
{
# pass the nixpkgs config to the unstable alias
# to ensure `allowUnfree = true;` is propagated:
config = config.nixpkgs.config;
};
};
};
然后你可以像unstable.vscode 一样使用它,而不是(import <nixos-unstable> {}).vscode。
【讨论】:
作为替代示例:
{ config, pkgs, ... }:
let
unstable = import <unstable> {
config = config.nixpkgs.config;
};
in
{
environment.systemPackages = with pkgs; [
# google-chrome
unstable.google-chrome
];
nixpkgs.config.allowUnfree = true;
}
【讨论】: