该NixOS的cheatsheet介绍如何安装软件包unstable在configuration.nix.
它首先说是添加不稳定的通道,如下所示:
$ sudo nix-channel --add https://nixos.org/channels/nixpkgs-unstable
$ sudo nix-channel --update
Run Code Online (Sandbox Code Playgroud)
然后,很容易使用此通道configuration.nix(因为它现在应该打开NIX_PATH):
nixpkgs.config = {
allowUnfree = true;
packageOverrides = pkgs: {
unstable = import <nixos-unstable> {
config = config.nixpkgs.config;
};
};
};
environment = {
systemPackages = with pkgs; [
unstable.google-chrome
];
};
Run Code Online (Sandbox Code Playgroud)
我不想做手册nix-channel --add和nix-channel --update步骤.
我希望能够安装我的系统,configuration.nix而无需先运行nix-channel --add和nix-channel --update步骤.
有没有办法自动化这个configuration.nix?
我能够通过@EmmanuelRosa的建议使此工作正常进行。
这是我的相关部分/etc/nixos/configuration.nix:
{ config, pkgs, ... }:
let
unstableTarball =
fetchTarball
https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz;
in
{
imports =
[ # Include the results of the hardware scan.
/etc/nixos/hardware-configuration.nix
];
nixpkgs.config = {
packageOverrides = pkgs: {
unstable = import unstableTarball {
config = config.nixpkgs.config;
};
};
};
...
};
Run Code Online (Sandbox Code Playgroud)
这增加了unstable可用于的导数environment.systemPackages。
这是一个使用它htop从nixos-unstable 安装软件包的示例:
environment.systemPackages = with pkgs; [
...
unstable.htop
];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2251 次 |
| 最近记录: |