Nix Flakes
[!quote] - getting started with flakes - Godot export tunnelvr/flake.nix - GitHub - macalimlim/godot-rust-template - nix flake
- Flakes 是 Nix 的实验功能,已被广泛采用。
启用 Flake
- 使用 nix-unstable-installer 安装 unstable Nix
- 在
/home/user/.config/nix/nix.conf启用命令
基本命令
初始化项目
使用模板创建 flake,模板是指在 flake.nix 的输出中包含 templates
nix flake init -t github:nix-community/templates#<name>
nix flake new -t github:nix-community/templates#<name> ./project
Profile
- profile 是 flake 中的概念。profile 是一系列的包。
~/.nix-profile链接到/nix/var/nix/profiles/per-user/username/profile~/.nix-profile/bin应在PATH中
查看用户的所有 profiles
查看当前 profile 安装的包
升级 profile 中的包
- install an installable expression
nix profile install --impure --expr 'with builtins.getFlake "nixpkgs"; with legacyPackages.${builtins.currentPlatform}; haskellPackages.ghcWithPackages (ps: [ ps.tidal ps.haskell-language-server])'
- 安装包
nix profile install nixpkgs#hello
- 移除包
nix profile remove nixpkgs#hellonix profile remove packages.x86_64-linux.hello
- 移除所有包
nix profile remove '.*'
- 移除指定 path
nix profile remove /nix/store/rr3y0c6zyk7kjjl8y19s4lsrhn4aiq1z-hello-2.10