NixOS & nixpkg包管理器使用体验
2022/8/17 6:23:09
本文主要是介绍NixOS & nixpkg包管理器使用体验,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
更换国内镜像
NixOS
以优先选择镜像,备选源站为例,选择以下配置之一:
-
单独安装的 Nix:编辑配置文件添加或修改如下项(通常系统配置在
/etc/nix/nix.conf
,用户配置在~/.config/nix/nix.conf
):substituters = https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store https://cache.nixos.org/
-
NixOS 21.11 及之前的版本在
configuration.nix
中使用如下配置(https://cache.nixos.org 会被自动添加)nix.binaryCaches = [ "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store" ];
-
NixOS 22.05 及之后的版本在
configuration.nix
中使用如下配置(https://cache.nixos.org 会被自动添加):nix.settings.substituters = [ "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store" ];
Nixpkgs channel
Channel 的镜像位于 https://mirrors.tuna.tsinghua.edu.cn/nix-channels/ 目录下,使用方式与 https://nixos.org/channels/ 相同。
单独安装的 Nix 替换 nixpkgs-unstable
命令如下:
$ nix-channel --add https://mirrors.tuna.tsinghua.edu.cn/nix-channels/nixpkgs-unstable nixpkgs $ nix-channel --update
替换 NixOS channel 命令如下(以 root 执行,将 19.09
替换为系统版本):
# nix-channel --add https://mirrors.tuna.tsinghua.edu.cn/nix-channels/nixos-19.09 nixos # nix-channel --update
升级系统
sudo nixos-rebuild switch --upgrade
安装应用
常规标准方式
使用configuration或者Home Manager来安装
搜索网站地址:https://search.nixos.org/options
- Search and use a exists module to install your packages
- Search and install a single package
修改/etc/nixos/configuration.nix
在environment.systemPackages属性下增加包名
然后运行
sudo nixos-rebuild switch
临时使用某个包
nix-shell
命令行管理包
nix profile install nixpkgs#<packagename>
尽量不要用nix-env https://stop-using-nix-env.privatevoid.net/
这篇关于NixOS & nixpkg包管理器使用体验的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-15鸿蒙生态设备数量超8亿台
- 2024-05-13TiDB + ES:转转业财系统亿级数据存储优化实践
- 2024-05-09“2024鸿蒙零基础快速实战-仿抖音App开发(ArkTS版)”实战课程已上线
- 2024-05-09聊聊如何通过arthas-tunnel-server来远程管理所有需要arthas监控的应用
- 2024-05-09log4j2这么配就对了
- 2024-05-09nginx修改Content-Type
- 2024-05-09Redis多数据源,看这篇就够了
- 2024-05-09Google Chrome驱动程序 124.0.6367.62(正式版本)去哪下载?
- 2024-05-09有没有大佬知道这种数据应该怎么抓取呀?
- 2024-05-09这种运行结果里的10.100000001,怎么能最快改成10.1?