首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将nixpkgs.config.allowUnfree传递给本地nixpkgs存储库

如何将nixpkgs.config.allowUnfree传递给本地nixpkgs存储库
EN

Stack Overflow用户
提问于 2018-04-18 17:54:25
回答 2查看 2.2K关注 0票数 1

我想用局部nixpkgs存储库的哈伯斯包,

代码语言:javascript
复制
let
  # pass config so that packages use correct allowUnfree for example
  nixpkgs-local = import /home/bjorn/projects/nixpkgs { inherit config; };
in

rec {
  config.allowUnfree = true;

  config.packageOverrides = old: {

    # packages from local nixpkgs
    inherit (nixpkgs-local) safeeyes hubstaff;
....

但是它不自由的包,所以抛出不自由的包错误。

代码语言:javascript
复制
$ sudo nixos-rebuild dry-build
building the system configuration...
error: Package ‘hubstaff-1.3.1-ff75f26’ in /home/bjorn/projects/nixpkgs/pkgs/applications/misc/hubstaff/default.nix:60 has an unfree license (‘unfree’), refusing to evaluate.

据我所知,我需要通过nixpkgs.config.allowUnfree = true,但上面的import /home/bjorn/projects/nixpkgs { inherit config; };不起作用

附注:

我的另一个问题是,我试图窥探我在config.nixpkgs.allowUnfree 这里中传递的价值。

代码语言:javascript
复制
{ config, pkgs, lib, ... }:

let r = {
  imports = [
    ./hardware-configuration.nix
    ./hardware-configuration-override.nix
    ./hardware-programs.nix
    /home/bjorn/projects/nixpkgs/nixos/modules/services/misc/safeeyes.nix
  ];

  ....
};

in
builtins.seq (lib.debug.showVal config.nixpkgs.allowUnfree) r

但我得到了无限递归误差,也许有人知道怎么做?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-04-18 20:35:25

Tnx到tilpner

我传递了错误的配置

也就是说,这是import /home/bjorn/projects/nixpkgs期望的配置。

代码语言:javascript
复制
nix-repl> c = import <nixpkgs/nixos> {}

nix-repl> c.config.nixpkgs
{ config = { ... }; overlays = [ ... ]; pkgs = { ... }; system = "x86_64-linux"; }

这就是我路过的地方

代码语言:javascript
复制
nix-repl> c.config
{ _module = { ... }; assertions = [ ... ]; boot = { ... }; config = { ... }; containers = { ... }; dysnomia = { ... }; ec2 = { ... }; environment = { ... }; fileSystems = { ... }; fonts = { ... }; gnu = false; hardware = { ... }; i18n = { ... }; ids = { ... }; jobs = «error: The option `jobs' is used but not defined.»; kde = { ... }; krb5 = { ... }; lib = { ... }; meta = { ... }; nesting = { ... }; networking = { ... }; nix = { ... }; nixpkgs = { ... }; passthru = «error: The option `passthru' is used but not defined.»; power = { ... }; powerManagement = { ... }; programs = { ... }; security = { ... }; services = { ... }; sound = { ... }; swapDevices = [ ... ]; system = {

它是传递给/etc/nixos/的

修正:

代码语言:javascript
复制
{ config, pkgs }:

let
  # pass config so that packages use correct allowUnfree for example
  unfreeConfig = config.nixpkgs.config // {
    allowUnfree = true;
  };
  nixpkgs-local = import /home/bjorn/projects/nixpkgs { config = unfreeConfig; };
in
票数 1
EN

Stack Overflow用户

发布于 2018-04-19 10:46:56

回答你的第二个“P.S”问题是,这是为什么和建议做什么代替。

出现无限递归是因为模块系统需要计算每个模块的“根”和一些属性(如imports ),以构建表示config根的术语。

在调用seq时,您正在计算config的一个属性,此时config本身仍在计算中。

从技术上讲,您可以通过将seq调用添加到属性而不是整个模块来解决这个问题。这样,可以在不评估config调用的情况下评估seq

查看配置的一个更简单的方法可能是在nix repl中导入它。

代码语言:javascript
复制
nix-repl> c = import <nixpkgs/nixos> { configuration = ./nixos/root/default.nix; /* or the file usually called configuration.nix */ }

nix-repl> c.config.nixpkgs.config.allowUnfree
true

您可以在迭代时使用:r命令重新加载所有文件。Nix喜欢缓存它们,因为实现面向批处理执行。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49906076

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档