Closed bladyjoker closed 1 year ago
pre-commit-hook.nix
provides its ownflake-parts
module, here an example of how to use it. Again, what you did is not wrong but you are not properly exploitingflake-parts
.
Check out https://github.com/mlabs-haskell/lambda-buffers/pull/82/commits/31d38ac5e548cd6394484d19014a964b1e095e21 where I tried to do a module on pre-commit stuff.
You define a
pkgs
at line 27 when you havepkgs
asperSystem
's argument. You probably do this because you need apkgs
"instance" with some overlays applied but this means that you would need to redo this in every module. I faced the same problem in the past and I came up with something like the following. It's also a nice example on how to useflake-parts
idiomatically.
Ok, that looks proper. I still don't know exactly how I would extract 'common' stuff into a new module, concretely:
pkgs
,pre-commit
installationScript
to their shellHook
compiler
and index-state
I imagine I need to create a small module with default options and then instantiate such a module.
If you look at all the build.nix
files in haskell directories you'll see:
{ pkgs
, haskell-nix
, mlabs-tooling
, compiler-nix-name
, index-state
, compilerHsPb
, commonTools
, shellHook
}:
let
inherit pkgs;
project = {
src = ./.;
name = "lambda-buffers-compiler";
inherit compiler-nix-name index-state;
extraHackage = [
"${compilerHsPb}"
];
modules = [
(_: {
packages = {
allComponent.doHoogle = true;
allComponent.doHaddock = true;
# Enable strict compilation
lambda-buffers-compiler.configureFlags = [ "-f-dev" ];
};
})
];
shell = {
withHoogle = true;
exactDeps = true;
nativeBuildInputs = [ pkgs.swiPrologWithGui ] ++ builtins.attrValues commonTools;
tools = {
cabal = { };
haskell-language-server = { };
};
shellHook = ''
export LC_CTYPE=C.UTF-8
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
${shellHook}
'';
};
};
in
{
hsNixProj = haskell-nix.cabalProject' [
mlabs-tooling.lib.mkHackageMod
project
];
}
which is tedious to maintain. I'd ideally refactor all that in a module and then have my build.nix files just specify the 'uncommon' stuff, here that would be:
project = {
name = "lambda-buffers-compiler";
nativeBuildInputs = [ pkgs.swiPrologWithGui ] ++ builtins.attrValues commonTools;
}
Thanks @aciceri
DONE
flake-parts
update-flake
action