Skip to content
Snippets Groups Projects
Commit 11ef7d39 authored by Jean-Paul Calderone's avatar Jean-Paul Calderone
Browse files

A minimally functional flake utility library for Haskell projects

This is based heavily on
https://github.com/JonathanLorimer/templates/blob/main/template/haskell/flake.nix
but I like libraries a lot more than I like code generation.

There's some more pieces that are probably useful commented out.
parents
No related branches found
No related tags found
No related merge requests found
{
description = "a Nix flake library for Haskell projects";
inputs = {
flake-utils.url = github:numtide/flake-utils;
flake-utils.inputs.nixpkgs.follows = "nixpkgs";
pre-commit-hooks.url = github:cachix/pre-commit-hooks.nix;
pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
pre-commit-hooks.inputs.flake-utils.follows = "flake-utils";
};
outputs = {
self,
nixpkgs,
pre-commit-hooks,
flake-utils,
}: {
lib = import ./lib.nix {
inherit self nixpkgs pre-commit-hooks flake-utils;
};
};
}
lib.nix 0 → 100644
# Define a library of functionality for constructing Flakes.
{ pre-commit-hooks, flake-utils, ... }:
{ pkgs
# ^ A nixpkgs to use.
, src
# ^ The source of the Haskell library/project to customize the library for.
, compilerVersion
# ^ A string giving the version of ghc and related packages to use.
, packageName
# ^ A string giving the name of the project/package being packaged.
}:
let
hsPkgs = pkgs.haskell.packages.${compilerVersion}.override {
overrides = hfinal: hprev: {
${packageName} = hfinal.callCabal2nix packageName src {};
};
};
in
rec {
checks = { }: {
pre-commit-check = preCommitCheck { };
};
preCommitCheck = { }:
pre-commit-hooks.lib.${pkgs.system}.run {
inherit src;
hooks = {
alejandra.enable = true;
fourmolu.enable = true;
cabal-fmt.enable = true;
};
};
devShells = { }: {
default = hsPkgs.shellFor {
inherit (preCommitCheck { }) shellHook;
packages = p: [
];
buildInputs = with pkgs;
[
cabal2nix
# haskellPackages.cabal-fmt
haskellPackages.cabal-install
# haskellPackages.fourmolu
# haskellPackages.ghcid
# hsPkgs.haskell-language-server
# nodePackages.serve
];
};
};
packages = { }: flake-utils.lib.flattenTree rec {
default = hsPkgs.${packageName};
${packageName} = default;
};
# haskellDevShell = { pkgs, system, haskellPackageName, src }:
# let
# hsPkgs' = hsPkgs {
# inherit pkgs compilerVersion haskellPackageName src;
# };
# in hsPkgs'.shellFor {
# inherit (preCommitCheck { inherit system src; }) shellHook;
# withHoogle = true;
# packages = p: [
# p.${haskellPackageName} # tahoe-lafs-immutable-uploader
# ];
# buildInputs = with pkgs;
# [
# cabal2nix
# haskellPackages.cabal-fmt
# haskellPackages.cabal-install
# haskellPackages.fourmolu
# haskellPackages.ghcid
# hsPkgs.haskell-language-server
# nodePackages.serve
# ]
# ++ (builtins.attrValues (import ./scripts.nix {
# s = pkgs.writeShellScriptBin;
# }));
# };
}
{...}: {
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment