derivation
Nixにおけるbuildの単位である
Nixにおけるbuildの仕様書のようなもの
どんな入力から、どんなビルド手順で、何を作るかを完全に記述した純粋なデータ構造のこと
その記述から決定的に /nix/store/<hash>-<name> というパスが計算される
雑に捉えるなら
Nixが利用するpackageはderivationの形式で提供、共有される
3段階あるが、これらをふわっと全部「derivation」と呼びがち
https://gyazo.com/fbb90b5bb61bac3c9671ed8e6448a3f3 https://stackoverflow.com/a/58243537
① Nix式
人間がNix式で書くやつ
これが本物のderivationmrsekut.icon*2
Nix式で書かれたものを、完全に展開・固定された低レベルの仕様
/nix/store/xxxx-foo.drv に置かれる
ビルド成果物
新しくderivationを定義する
3つの必須項目を指定しさえすればderivationを作れる
code:nix-repl
nix-repl> d = derivation { name = "myname"; builder = "mybuilder"; system = "mysystem"; }
nix-repl> d
«derivation /nix/store/z3hhlxbckx4g3n9sw91nnvlkjvyw754p-myname.drv»
具体例
derivationのattributes
code:nix-repl
nix-repl> d = builtins.derivation {..}
nix-repl> builtins.attrNames d
name
builder
system
all
drvAttrs
builder, name, systemの基本事項
drvPath
.drvfileのpath
/nix/store/<hash-name>.drv
out
自分自身
d == d.out
outPath
nix store上のbuild path
/nix/store/<hash-name>
outputName
type
type = "derivation"というNix内で特別扱いされるfieldになっている
このsetsがderivationであることを表す
参考