aqua と比較するために Package Manager としての Nix OS を試す
読む限り
- asdf は package manager ではない、 dependency をインストールしない
- nix os は dependency も管理する。大量のパッケージが存在する。バージョン管理できる。再現性の高い環境を構築できる
dependency の install は便利なこともあれば、余計なこともあるきはするので一長一短
aqua は dependency を管理しない
印象としては nix os は CI 環境では使いにくいし、チームやプロジェクトのツール管理に導入するというのは導入ハードルが高い気はする。小さなチームではできるかもしれないが。
といってもあくまで先入観なので、本当にそうなのか使ってみないとわからない
これを読んでなるほどと思ったが、
宣言的に環境を管理できる
この部分が記事からは読み取れなかった。
aqua.yaml や .tool-versions のように、コードで宣言的に管理されるものなのかと思った
既存のパッケージのコードがよくわからないが、読めないと生きていけない。
aqua の Registry Configuration は読みやすい
nix expressionのデバッグが難しい。
成熟してない。次から次に新しいパッケージの管理ツールがでてくるので学習コストが高め。
aqua と比べて学習コストが高いだろうなとは思う。
開発環境で使うツールはshell.nixファイルを作りnix-shellコマンドを起動して利用します。
これを使えばプロジェクトのツールを管理できるのか?
なるほど。こういうコードを書けばプロジェクトごとにツールを管理できるのかな。
asdf や aqua とかと比べるとだいぶハードルが高い。
Pros
- 多くのパッケージが存在する
- 依存関係を管理できる(これは一長一短ある)
- より再現性の高い環境を作れる
Cons
- 学習コストが高いので、チームやプロジェクトに導入するハードルが高い
- CI などで導入できるか不明・できたとしてもオーバーヘッドが大きそう(要確認)
- ローカル開発と CI でバージョンを揃えるには、 CI でも使えないと困る
- プロジェクト用に conftest をインストールする(多分 package あるだろうけど、なければ他ので試す)
- 自作のツールを nix でインストールできるようにする
- GitHub Actions 上で Nix を使ってツールをインストールする
というのをできれば試したい。
$ sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume --daemon
Switching to the Multi-user Installer
Welcome to the Multi-User Nix Installation
This installation tool will set up your computer with the Nix package
manager. This will happen in a few stages:
1. Make sure your computer doesn't already have Nix. If it does, I
will show you instructions on how to clean up your old install.
2. Show you what we are going to install and where. Then we will ask
if you are ready to continue.
3. Create the system users and groups that the Nix daemon uses to run
builds.
4. Perform the basic installation of the Nix files daemon.
5. Configure your shell to import special Nix Profile files, so you
can use Nix.
6. Start the Nix daemon.
Would you like to see a more detailed list of what we will do?
[y/n] y
We will:
- make sure your computer doesn't already have Nix files
(if it does, I will tell you how to clean them up.)
- create local users (see the list above for the users we'll make)
- create a local group (nixbld)
- install Nix in to /nix
- create a configuration file in /etc/nix
- set up the "default profile" by creating some Nix-related files in
/var/root
- back up /etc/bashrc to /etc/bashrc.backup-before-nix
- update /etc/bashrc to include some Nix configuration
- back up /etc/zshrc to /etc/zshrc.backup-before-nix
- update /etc/zshrc to include some Nix configuration
- create a Nix volume and a LaunchDaemon to mount it
- create a LaunchDaemon (at /Library/LaunchDaemons/org.nixos.nix-daemon.plist) for nix-daemon
Ready to continue?
[y/n]
User, Group を作ったり /etc に設定ファイル置いたりするらしい。
ちょっと嫌なのでまずはコンテナで試したい。
$ podman run --rm -ti nixos/nix
ac7810e056b2:/# nix-env --version
nix-env (Nix) 2.3.12
ac7810e056b2:/# nix-env -qaP git
Killed
ac7810e056b2:/# echo $?
137
あれ、検索できない
ac7810e056b2:/# nix-shell -p hello
these paths will be fetched (60.90 MiB download, 279.81 MiB unpacked):
でかくない?
[nix-shell:/]# hello
Hello, world!
[nix-shell:/]# exit
exit
ac7810e056b2:/# hello
/bin/sh: hello: not found
動いた
ここで検索できる。 conftest もあった。
Channel の追加が必要なのか?でも hello は install できたな
ac7810e056b2:/# nix-env -iA nixos.conftest
error: attribute 'nixos' in selection path 'nixos.conftest' not found
ac7810e056b2:/# nix-channel --list
nixpkgs https://nixos.org/channels/nixpkgs-unstable
既に追加されているな
比較はしたけど、結局用途・目的が違うという話