2021-05-31 23:19:51 +00:00
|
|
|
{
|
2021-06-01 02:46:25 +00:00
|
|
|
description = "haskell-template's description";
|
2021-05-31 23:19:51 +00:00
|
|
|
inputs = {
|
2022-05-07 00:27:11 +00:00
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
2022-05-21 10:49:02 +00:00
|
|
|
flake-utils.url = "github:numtide/flake-utils/v1.0.0";
|
2022-02-21 00:19:39 +00:00
|
|
|
flake-utils.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
flake-compat.url = "github:edolstra/flake-compat";
|
|
|
|
flake-compat.flake = false;
|
|
|
|
flake-compat.inputs.nixpkgs.follows = "nixpkgs";
|
2021-05-31 23:19:51 +00:00
|
|
|
};
|
2022-04-27 22:55:51 +00:00
|
|
|
|
|
|
|
outputs = inputs:
|
|
|
|
let
|
|
|
|
# Function that produces Flake outputs for the given system.
|
2022-05-10 10:48:58 +00:00
|
|
|
#
|
|
|
|
# We use eachDefaultSystem (see below) to allow other architectures.
|
|
|
|
# cf. https://github.com/NixOS/nix/issues/3843#issuecomment-661720562
|
2022-04-27 22:55:51 +00:00
|
|
|
outputsFor = system:
|
2022-03-23 17:39:20 +00:00
|
|
|
let
|
|
|
|
# Because: https://zimbatm.com/notes/1000-instances-of-nixpkgs
|
2022-04-27 22:55:51 +00:00
|
|
|
pkgs = inputs.nixpkgs.legacyPackages.${system};
|
2022-05-17 18:50:18 +00:00
|
|
|
inherit (pkgs.lib.lists) optionals;
|
2022-03-17 14:16:54 +00:00
|
|
|
|
2022-04-27 22:55:51 +00:00
|
|
|
# Specify GHC version here. To get the appropriate value, run:
|
2022-03-23 17:39:20 +00:00
|
|
|
# nix-env -f "<nixpkgs>" -qaP -A haskell.compiler
|
2022-04-27 22:55:51 +00:00
|
|
|
hp = pkgs.haskellPackages; # Eg: pkgs.haskell.packages.ghc921;
|
|
|
|
|
|
|
|
# Specify your build/dev dependencies here.
|
|
|
|
shellDeps = with hp; [
|
|
|
|
cabal-fmt
|
|
|
|
cabal-install
|
|
|
|
ghcid
|
|
|
|
haskell-language-server
|
|
|
|
fourmolu
|
|
|
|
hlint
|
|
|
|
pkgs.nixpkgs-fmt
|
2022-05-04 20:24:34 +00:00
|
|
|
pkgs.treefmt
|
2022-04-27 22:55:51 +00:00
|
|
|
];
|
2022-03-17 14:16:54 +00:00
|
|
|
|
2022-05-17 18:53:13 +00:00
|
|
|
project =
|
|
|
|
{ returnShellEnv ? false
|
|
|
|
, withHoogle ? false
|
|
|
|
}:
|
2022-03-23 17:39:20 +00:00
|
|
|
hp.developPackage {
|
2022-05-17 18:53:13 +00:00
|
|
|
inherit returnShellEnv withHoogle;
|
2022-03-23 17:39:20 +00:00
|
|
|
name = "haskell-template";
|
2022-04-27 21:42:26 +00:00
|
|
|
root = ./.;
|
2022-03-23 17:39:20 +00:00
|
|
|
overrides = self: super: with pkgs.haskell.lib; {
|
|
|
|
# Use callCabal2nix to override Haskell dependencies here
|
|
|
|
# cf. https://tek.brick.do/K3VXJd8mEKO7
|
|
|
|
# Example:
|
|
|
|
# > NanoID = self.callCabal2nix "NanoID" inputs.NanoID { };
|
|
|
|
# Assumes that you have the 'NanoID' flake input defined.
|
|
|
|
};
|
|
|
|
modifier = drv:
|
2022-05-17 18:46:28 +00:00
|
|
|
pkgs.haskell.lib.overrideCabal drv (oa: {
|
|
|
|
# All the Cabal-specific overrides go here.
|
|
|
|
# For examples on what is possible, see:
|
|
|
|
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/haskell-modules/lib/compose.nix
|
2022-05-17 18:50:18 +00:00
|
|
|
buildTools = (oa.buildTools or [ ]) ++ optionals returnShellEnv shellDeps;
|
2022-05-17 18:46:28 +00:00
|
|
|
});
|
2021-05-31 23:19:51 +00:00
|
|
|
};
|
2022-03-23 17:39:20 +00:00
|
|
|
in
|
|
|
|
{
|
2022-04-27 22:55:51 +00:00
|
|
|
# Used by `nix build ...`
|
|
|
|
packages = {
|
2022-05-17 18:53:13 +00:00
|
|
|
default = project { };
|
2022-04-27 22:55:51 +00:00
|
|
|
};
|
2022-03-25 18:18:42 +00:00
|
|
|
# Used by `nix run ...`
|
2022-03-25 18:09:08 +00:00
|
|
|
apps = {
|
2022-04-27 22:34:53 +00:00
|
|
|
default = {
|
|
|
|
type = "app";
|
2022-04-27 22:55:51 +00:00
|
|
|
program = "${inputs.self.packages.${system}.default}/bin/haskell-template";
|
2022-04-27 22:34:53 +00:00
|
|
|
};
|
2022-03-25 18:09:08 +00:00
|
|
|
};
|
2022-04-27 22:55:51 +00:00
|
|
|
# Used by `nix develop ...`
|
|
|
|
devShells = {
|
2022-05-17 18:53:13 +00:00
|
|
|
default = project { returnShellEnv = true; withHoogle = true; };
|
2022-04-27 22:55:51 +00:00
|
|
|
};
|
2022-04-27 23:46:02 +00:00
|
|
|
# For compatability with older Nix (eg in CI)
|
2022-04-29 05:24:57 +00:00
|
|
|
devShell = inputs.self.devShells.${system}.default;
|
2022-04-27 23:47:58 +00:00
|
|
|
defaultPackage = inputs.self.packages.${system}.default;
|
|
|
|
defaultApp = inputs.self.apps.${system}.default;
|
2022-04-27 22:55:51 +00:00
|
|
|
};
|
|
|
|
in
|
|
|
|
inputs.flake-utils.lib.eachDefaultSystem outputsFor
|
|
|
|
// {
|
2022-03-23 17:39:20 +00:00
|
|
|
# For hercules-CI support,
|
|
|
|
# https://docs.hercules-ci.com/hercules-ci/guides/upgrade-to-agent-0.9/#_upgrade_your_repositories
|
|
|
|
herculesCI.ciSystems = [ "x86_64-linux" ];
|
|
|
|
};
|
2021-05-31 23:19:51 +00:00
|
|
|
}
|