ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

NixOS & nixpkg包管理器使用体验

2022-08-17 00:03:54  阅读:169  来源: 互联网

标签:nixos 管理器 nixpkg NixOS channels nix tsinghua https edu


更换国内镜像

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

  1. Search and use a exists module to install your packages
  2. 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,NixOS,channels,nix,tsinghua,https,edu
来源: https://www.cnblogs.com/jay763190097/p/16593442.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有