我可以使用什么 nix 函数来获取文件扩展名?

What nix function can I use to get the file extension?

在构建 haskell 项目时,我 运行 经常遇到使用 hpack 时存在 cabal 文件的错误。

niobiumcoconut.cabal was generated with a newer version of hpack, please upgrade and try again.

所以我想,嘿,一个解决方案是将 cabal 文件排除在推导之外。我找到了 builtins.filterSource 函数。但是我不确定如何使用 nix 从文件中获取文件扩展名(因此我可以排除 *.cabal 个文件。)

有这样的功能吗?它在哪里定义?我该如何使用它?

我认为您正在寻找 hasSuffix 函数。

根据扩展名删除特定文件:

src = pkgs.lib.cleanSourceWith {
    filter = name: type:
      !(pkgs.lib.hasSuffix ".example" name)
    ;
    src = ./.;
  };

此答案由来自 functionalprogramming.slack.com

的“Andika Demas Riyandi”提供