我正在使用默认的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;
}