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

nic*_*las 4 haskell nix nix-flake

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

\n
\xe2\x9d\xaf nix flake show github:input-output-hk/haskell.nix\ngithub:input-output-hk/haskell.nix/1b54ea01568299a0eda578ae9395e20d5c699ee1\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80checks\n\xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80aarch64-darwin\ntrace: haskell-nix.haskellLib.cleanGit: /nix/store/jmx2m0ldgrjq7p3gb4yyca47nvbvspfl-source does not seem to be a git repository,\nassuming it is a clean checkout.\ntrace: No index state specified for haskell-project, using the latest index state that we know about (2022-02-07T00:00:00Z)!\ntrace: No index state specified for haskell-project, using the latest index state that we know about (2022-02-07T00:00:00Z)!\ntrace: No index state specified for haskell-project, using the latest index state that we know about (2022-02-07T00:00:00Z)!\ntrace: WARNING: No materialized dummy-ghc-data for ghc-8.8.4-aarch64-darwin.\ntrace: To make this a fixed-output derivation but not materialized, set `sha256` to the output of the \'calculateMaterializedSha\' script in \'passthru\'.\ntrace: To materialize this entirely, pass a writable path as the `materialized` argument and run the \'updateMaterialized\' script in \'passthru\'.\n[1/0/579 built, 0.1 MiB DL] building ghc-8.8.4 (buildPhase):.....\n
Run Code Online (Sandbox Code Playgroud)\n

从 Intel Mac 上,我得到

\n
\xe2\x9d\xaf nix flake show github:input-output-hk/haskell.nix\ngithub:input-output-hk/haskell.nix/1b54ea01568299a0eda578ae9395e20d5c699ee1\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80checks\n\xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80aarch64-darwin\ntrace: haskell-nix.haskellLib.cleanGit: /nix/store/jmx2m0ldgrjq7p3gb4yyca47nvbvspfl-source does not seem to be a git repository,\nassuming it is a clean checkout.\ntrace: No index state specified for haskell-project, using the latest index state that we know about (2022-02-07T00:00:00Z)!\ntrace: No index state specified for haskell-project, using the latest index state that we know about (2022-02-07T00:00:00Z)!\ntrace: No index state specified for haskell-project, using the latest index state that we know about (2022-02-07T00:00:00Z)!\nerror: --- Error ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- nix\na \'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}\n(use \'--show-trace\' to show detailed location information)\n
Run Code Online (Sandbox Code Playgroud)\n

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

\n

如果我在几次获取后在其他一些薄片上运行此命令:

\n
\xe2\x9d\xaf nix flake show github:edolstra/dwarffs\ngithub:edolstra/dwarffs/69d73417d83ebeb7711912e33515d87049b39de0\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80checks\n\xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80aarch64-linux\n\xe2\x94\x82   \xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80build: derivation \'dwarffs-0.1.20220128.69d7341\'\n\xe2\x94\x82   \xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80test: derivation \'vm-test-run-unnamed\'\n\xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80i686-linux\n\xe2\x94\x82   \xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80build: derivation \'dwarffs-0.1.20220128.69d7341\'\n\xe2\x94\x82   \xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80test: derivation \'vm-test-run-unnamed\'\n\xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80x86_64-linux\n\xe2\x94\x82       \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80build: derivation \'dwarffs-0.1.20220128.69d7341\'\n\xe2\x94\x82       \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80test: derivation \'vm-test-run-unnamed\'\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80defaultPackage\n\xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80aarch64-linux: package \'dwarffs-0.1.20220128.69d7341\'\n\xe2\x94\x82   \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80i686-linux: package \'dwarffs-0.1.20220128.69d7341\'\n\xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80x86_64-linux: package \'dwarffs-0.1.20220128.69d7341\'\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80nixosModules\n\xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80dwarffs: NixOS module\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80overlay: Nixpkgs overlay\n
Run Code Online (Sandbox Code Playgroud)\n

Rob*_*ing 7

haskell.nix很大程度上取决于通常所说的“衍生导入”或 IFD。这些是诸如

foo = import "${mkDerivation bar}/expr.nix";
Run Code Online (Sandbox Code Playgroud)

或者

qux = builtins.readFile (somePackage + "/data.json");
Run Code Online (Sandbox Code Playgroud)

bar如果不构建和 ,就无法评估这些somePackage

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