首页 > 其他分享 >NixOS & nixpkg包管理器使用体验

NixOS & nixpkg包管理器使用体验

时间:2022-08-16 23:55:58浏览次数:77  
标签:nixos 管理器 nixpkg NixOS channels nix 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,https,edu
From: https://www.cnblogs.com/jay763190097/p/16593442.html

相关文章

  • 2022.8.14 NPM包管理器与Babel
    04、NPM包管理器4.1、简介官方网站:https://www.npmjs.com/ NPM全称NodePackageManager,是Node.js包管理工具,是全球最大的模块生态系统,里面所有的模块都是开源免费的;也......