gpt4 book ai didi

haskell - 使用 Nix,如何在启用分析的情况下指定 Haskell 依赖项?

转载 作者:行者123 更新时间:2023-12-04 12:39:33 25 4
gpt4 key购买 nike

我最初是这样尝试的:

nix-shell -p "haskell.packages.ghc821.ghcWithPackages (p: with p; [text hspec lens])" -j4 --run 'ghc Main.hs -prof

然后GHC告诉我
Main.hs:4:1: error:
Could not find module ‘Control.Lens’
Perhaps you haven't installed the profiling libraries for package ‘lens-4.15.4’?
Use -v to see a list of the files searched for.

在网上搜索我发现了这个: https://github.com/NixOS/nixpkgs/issues/22340

所以看来我将无法从缓存中下载。但这没关系,如果至少我可以在本地构建配置文件的变体。

我可以通过修改赋予 -p 的nix 表达式以某种方式做到这一点吗?轻微地?

然后在写这个问题的时候,我想起了这个资源: https://github.com/NixOS/nixpkgs/blob/bd6ba7/pkgs/development/haskell-modules/lib.nix

我在哪里找到 enableLibraryProfiling .所以我尝试了:
nix-shell -p "haskell.packages.ghc821.ghcWithPackages (p: with p; [text hspec (haskell.lib.enableLibraryProfiling lens)])" -j4 --run 'ghc Main.hs -prof'

这让我遇到了一个新错误:
src/Control/Lens/Internal/Getter.hs:26:1: error:
Could not find module ‘Data.Functor.Contravariant’
Perhaps you haven't installed the profiling libraries for package ‘contravariant-1.4’?
Use -v to see a list of the files searched for.
|
26 | import Data.Functor.Contravariant
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

因此,如果我可以将所有包映射到 enableLibraryProfiling在他们身上,那么我想这可能会奏效。但我的尼克斯知识目前还没有延伸那么远。我怎么能那样做?这甚至是正确的追求之路吗?

最佳答案

进一步窥探nix-repl以及来自 ElvishJerricco 在 FreeNode 的 #reflex-frp 上的一些有用的指示,我能够构建这个,这似乎有效:
$ nix-shell -p "(haskell.packages.ghc821.extend (self: super: {mkDerivation = expr: super.mkDerivation (expr // { enableLibraryProfiling = true; });})).ghcWithPackages (p: with p; [text hspec lens])" -j4 --run 'ghc Main.hs -prof'

关于haskell - 使用 Nix,如何在启用分析的情况下指定 Haskell 依赖项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47636243/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com