在configuration.nix中从nixos-unstable安装virtualbox模块 [英] install virtualbox modules from nixos-unstable in configuration.nix

查看:186
本文介绍了在configuration.nix中从nixos-unstable安装virtualbox模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用此答案中的配置,可以从/etc/nixos/configuration.nix中的nixos-unstable安装软件包..

It is possible to install packages from nixos-unstable in /etc/nixos/configuration.nix using the configuration from this answer.

这是从nixos-unstable安装htop软件包的示例:

Here is an example of installing the htop packages from nixos-unstable:

{ config, pkgs, ... }:

let
  unstableTarball =
    fetchTarball
      https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz;
in
{
  ...

  nixpkgs.config = {
    packageOverrides = pkgs: {
      unstable = import unstableTarball {
        config = config.nixpkgs.config;
      };
    };
  };

  environment.systemPackages = with pkgs; [
    ...
    unstable.htop
  ];

  ...
};

我也希望能够从nixos-unstable安装Virtualbox软件包(以及相关的内核模块).

I would like to be able to install the Virtualbox package (and related kernel modules) from nixos-unstable as well.

天真地将virtualbox软件包添加到environment.systemPackages不会像我期望的那样工作.不会安装与不稳定版本的Virtualbox匹配的Virtualbox模块.这是我的/etc/nixos/configuration.nix的摘录:

Naively adding the virtualbox package to environment.systemPackages doesn't work like I expect it would. The Virtualbox modules matching the unstable version of Virtualbox do not get installed. Here is a snippet from my /etc/nixos/configuration.nix:

  nixpkgs.config.virtualbox.enableExtensionPack = true;
  virtualisation.virtualbox.host.enable = true;
  environment.systemPackages = with pkgs; [
    ...
    unstable.virtualbox
  ];

上面的代码可以从nixos-unstable正确安装virtualbox软件包,但不是 Virtualbox内核模块.

The above will correctly install the virtualbox package from nixos-unstable, but not the Virtualbox kernel modules.

如何从nixos-unstable中获取要安装的Virtualbox内核模块?为何上述方法不起作用?

How can I get the Virtualbox kernel modules to be installed from nixos-unstable as well? And why doesn't the above work?

推荐答案

您的配置不起作用,因为virtualbox模块具有自己对virtualbox包的引用.也许它应该像某些其他模块一样,公开覆盖该软件包的选项,但是现在还没有.向它发出请求请求并不难.

Your configuration does not work, because the virtualbox module has its own reference to the virtualbox package. Perhaps its should expose an option to override the package like some other modules do, but for now it doesn't. It shouldn't be hard to make a pull request for it.

替代方法是替换有问题的模块禁用使用disabledModules,然后使用imports导入替换项.

The alternative is to replace the offending module/modules by disabling the using disabledModules and then importing your replacements with imports.

无论哪种方式,您的里程可能会有所不同.第一种选择对我来说似乎是最干净的,但是您可能要检查发行版中的nixos模块与不稳定版本之间的区别.

Either way, your mileage may vary. The first option seems to be the cleanest to me, but you may want to check the differences between the nixos modules in your release and unstable versions.

这篇关于在configuration.nix中从nixos-unstable安装virtualbox模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆