mirror of
https://github.com/nmasur/dotfiles
synced 2025-07-06 19:00:14 +00:00
add haskell programming template
This commit is contained in:
54
templates/haskell/flake.nix
Normal file
54
templates/haskell/flake.nix
Normal file
@ -0,0 +1,54 @@
|
||||
# Derived from: https://github.com/jonascarpay/template-haskell
|
||||
# More info here: https://jonascarpay.com/posts/2021-01-28-haskell-project-template.html
|
||||
|
||||
{
|
||||
description = "hello";
|
||||
|
||||
inputs.haskellNix.url = "github:input-output-hk/haskell.nix";
|
||||
inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable";
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, haskellNix }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
overlay = self: _: {
|
||||
hsPkgs = self.haskell-nix.project' rec {
|
||||
src = ./.;
|
||||
compiler-nix-name = "ghc8107";
|
||||
shell = {
|
||||
tools = {
|
||||
cabal = "latest";
|
||||
ghcid = "latest";
|
||||
haskell-language-server = "latest";
|
||||
hlint = "latest";
|
||||
# See https://github.com/input-output-hk/haskell.nix/issues/1337
|
||||
ormolu = {
|
||||
version = "latest";
|
||||
modules = [
|
||||
({ lib, ... }: {
|
||||
options.nonReinstallablePkgs =
|
||||
lib.mkOption { apply = lib.remove "Cabal"; };
|
||||
})
|
||||
];
|
||||
};
|
||||
};
|
||||
## ormolu that uses ImportQualifiedPost.
|
||||
## To use, remove ormolu from the shell.tools section above, and uncomment the following lines.
|
||||
# buildInputs =
|
||||
# let
|
||||
# ormolu = pkgs.haskell-nix.tool compiler-nix-name "ormolu" "latest";
|
||||
# ormolu-wrapped = pkgs.writeShellScriptBin "ormolu" ''
|
||||
# ${ormolu}/bin/ormolu --ghc-opt=-XImportQualifiedPost $@
|
||||
# '';
|
||||
# in
|
||||
# [ ormolu-wrapped ];
|
||||
};
|
||||
};
|
||||
};
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ haskellNix.overlay overlay ];
|
||||
};
|
||||
flake = pkgs.hsPkgs.flake { };
|
||||
in flake // { defaultPackage = flake.packages."hello:exe:hello-exe"; });
|
||||
}
|
Reference in New Issue
Block a user