为什么 `nix flake show` 构建 ghc?

why does `nix flake show` builds ghc?

如果我在 M1 计算机上查看 haskell.nix flake 提供的输出,它会开始构建 ghc-8.8.4 等。

❯ nix flake show github:input-output-hk/haskell.nix
github:input-output-hk/haskell.nix/1b54ea01568299a0eda578ae9395e20d5c699ee1
├───checks
│   ├───aarch64-darwin
trace: haskell-nix.haskellLib.cleanGit: /nix/store/jmx2m0ldgrjq7p3gb4yyca47nvbvspfl-source does not seem to be a git repository,
assuming it is a clean checkout.
trace: No index state specified for haskell-project, using the latest index state that we know about (2022-02-07T00:00:00Z)!
trace: No index state specified for haskell-project, using the latest index state that we know about (2022-02-07T00:00:00Z)!
trace: No index state specified for haskell-project, using the latest index state that we know about (2022-02-07T00:00:00Z)!
trace: WARNING: No materialized dummy-ghc-data for ghc-8.8.4-aarch64-darwin.
trace: To make this a fixed-output derivation but not materialized, set `sha256` to the output of the 'calculateMaterializedSha' script in 'passthru'.
trace: To materialize this entirely, pass a writable path as the `materialized` argument and run the 'updateMaterialized' script in 'passthru'.
[1/0/579 built, 0.1 MiB DL] building ghc-8.8.4 (buildPhase):.....

从英特尔 Mac,我得到

❯ nix flake show github:input-output-hk/haskell.nix
github:input-output-hk/haskell.nix/1b54ea01568299a0eda578ae9395e20d5c699ee1
├───checks
│   ├───aarch64-darwin
trace: haskell-nix.haskellLib.cleanGit: /nix/store/jmx2m0ldgrjq7p3gb4yyca47nvbvspfl-source does not seem to be a git repository,
assuming it is a clean checkout.
trace: No index state specified for haskell-project, using the latest index state that we know about (2022-02-07T00:00:00Z)!
trace: No index state specified for haskell-project, using the latest index state that we know about (2022-02-07T00:00:00Z)!
trace: No index state specified for haskell-project, using the latest index state that we know about (2022-02-07T00:00:00Z)!
error: --- Error ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- nix
a 'aarch64-darwin' with features {} is required to build '/nix/store/sc11rh4l348yw3z4q4fy4byw324nm5yz-nix-tools-plan-to-nix-pkgs.drv', but I am a 'x86_64-darwin' with features {benchmark, big-parallel, nixos-test, recursive-nix}
(use '--show-trace' to show detailed location information)

为什么这些 flakes 需要构建任何东西来显示它们的输出?

如果我 运行 在我拥有的其他 flake 上执行此命令,在几次提取后:

❯ nix flake show github:edolstra/dwarffs
github:edolstra/dwarffs/69d73417d83ebeb7711912e33515d87049b39de0
├───checks
│   ├───aarch64-linux
│   │   ├───build: derivation 'dwarffs-0.1.20220128.69d7341'
│   │   └───test: derivation 'vm-test-run-unnamed'
│   ├───i686-linux
│   │   ├───build: derivation 'dwarffs-0.1.20220128.69d7341'
│   │   └───test: derivation 'vm-test-run-unnamed'
│   └───x86_64-linux
│       ├───build: derivation 'dwarffs-0.1.20220128.69d7341'
│       └───test: derivation 'vm-test-run-unnamed'
├───defaultPackage
│   ├───aarch64-linux: package 'dwarffs-0.1.20220128.69d7341'
│   ├───i686-linux: package 'dwarffs-0.1.20220128.69d7341'
│   └───x86_64-linux: package 'dwarffs-0.1.20220128.69d7341'
├───nixosModules
│   └───dwarffs: NixOS module
└───overlay: Nixpkgs overlay

haskell.nix 在很大程度上取决于通常所说的“从派生导入”或 IFD。这些表达式如

foo = import "${mkDerivation bar}/expr.nix";

qux = builtins.readFile (somePackage + "/data.json");

如果不构建 barsomePackage,这些无法评估。

haskell.nix 确实有一个功能可以让您完全避免此类表达式。他们称之为 materialization