【问题标题】:NixOS: Install unfree package using different channelNixOS:使用不同的渠道安装 unfree 包
【发布时间】:2017-11-30 10:27:13
【问题描述】:

我正在使用默认的 nixos 17.09 频道,并希望从不稳定的频道安装 unfree 包。

在这种情况下,我使用(import <nixos-unstable> {}).vscode 安装vscode,但我收到了我必须设置...allowUnfree = true; 的错误 该设置似乎仅适用于默认频道。 如何在不稳定的频道上也设置allowFree = true;

【问题讨论】:

    标签: nix nixos


    【解决方案1】:

    我找到了解决方案 (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 &lt;nixos-unstable&gt; {}).vscode

    【讨论】:

      【解决方案2】:

      作为替代示例:

      { config, pkgs, ... }:
      
      let
        unstable = import <unstable> {
          config = config.nixpkgs.config; 
        };
      in
      {
         environment.systemPackages = with pkgs; [
           # google-chrome
           unstable.google-chrome
         ];
      
          nixpkgs.config.allowUnfree = true;
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-06-01
        • 2017-10-08
        • 2021-08-05
        • 2020-09-28
        • 2017-04-13
        • 2011-02-02
        • 2021-12-02
        • 1970-01-01
        相关资源
        最近更新 更多