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

问题描述

通常在构建haskell项目时,我会在使用hpack时碰到存在cabal文件错误

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

所以我想,嘿,一种解决方案是将阴谋文件排除在派生之外。我发现了builtins.filterSource函数。但是我不确定如何从使用nix的文件获取文件扩展名(因此我可以排除*.cabal文件。)

是否存在这样的功能?它在哪里定义?以及如何使用它?

解决方法

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

,

要基于扩展名删除特定文件:

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

此答案由来自functionalprogramming.slack.com的“ Andika Demas Riyandi”提供