flakes
flakes is a way of expression of nix expressions and packages nix flake init
this generates flake.nix
we can pass a template
$ nix flake init -t github:hercules-ci/flake-parts
devenv 使うなら flake-parts + devenv がある
$ nix flake init --template github:cachix/devenv#flake-parts
Flake inputs schema
url like schema
ローカルの flake を参照するには?
相対パスもできるらしいが、うまくいく方法がわからない。絶対パスはできた
参照先に変更を入れても反映されない
参照もとで nix flake update する必要がある
ホットリロード的な仕組みはないのだろうか?
--override-input option が使える。こちらはコマンドに渡すものなので、毎回評価される。
--override-input <name> <url>
Flake output schema
path /nix/store/hoge does not exist的なエラーが出たら
そもそもリポジトリにアクセスできているか?
git add 忘れているファイルはないか?
For flakes in git repos, only files in the working tree will be copied to the store.
Therefore, if you use git for your flake, ensure to git add any project files after you first create them.
commit したくないが flake に認識させたい
nix を使っていないプロジェクトで nix の環境を作るには
nix ファイルは別管理して、symlink 貼る方法が良さそう
flake の場合は、git 管理しないといけないので、うまくいかない
環境構築用の flake を registry に登録して、direnv にそれを参照させる方法があるらしい
nikpkgs.follows
Installabels
flake reference
github:NixOS/nixpkgs#hello のような書き方
# 以降は attribute。すなわち、flake output の attribute を指定することができる。
nix flake update
特定の input だけを update
$ nix flake update --update-input name