summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Aristote <quentin@aristote.fr>2022-09-24 15:48:48 +0200
committerQuentin Aristote <quentin@aristote.fr>2022-09-24 15:48:48 +0200
commit08320539789357e767adb22c3bb2519ac9a5d508 (patch)
tree3f23f1cc06bb82d41c12ae94b6a209187d979cd0
parent3872829cd19bafdd98ebfe3b4b16871238273f50 (diff)
modules: add haskell module
-rw-r--r--modules/default.nix1
-rw-r--r--modules/haskell.nix70
2 files changed, 71 insertions, 0 deletions
diff --git a/modules/default.nix b/modules/default.nix
index 59b128c..ef71bd5 100644
--- a/modules/default.nix
+++ b/modules/default.nix
@@ -6,6 +6,7 @@ in {
imports = [
./coq.nix
./golang.nix
+ ./haskell.nix
./latex.nix
./nix.nix
./ocaml.nix
diff --git a/modules/haskell.nix b/modules/haskell.nix
new file mode 100644
index 0000000..1b8bc45
--- /dev/null
+++ b/modules/haskell.nix
@@ -0,0 +1,70 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+with builtins;
+let
+ cfg = config.haskell;
+
+ spacemacsPackages = haskellPackages:
+ with haskellPackages; [
+ apply-refact
+ hlint
+ stylish-haskell
+ hasktags
+ ];
+ haskellBuildInput = (if cfg.hoogle.enable then
+ cfg.haskellPackages.ghcWithHoogle
+ else
+ cfg.haskellPackages.ghcWithPackages) (haskellPackages:
+ (cfg.packages haskellPackages)
+ ++ optionals cfg.spacemacs.enable (spacemacsPackages haskellPackages)
+ ++ optional cfg.cabal.enable pkgs.cabal-install);
+in {
+ options.haskell = {
+ enable = mkEnableOption { name = "haskell"; };
+ haskellPackages = mkOption {
+ type = with types;
+ addCheck (lazyAttrsOf anything)
+ (packages: lib.hasAttr "ghcWithPackages" packages);
+ default = pkgs.haskellPackages;
+ defaultText = literalExample "pkgs.haskellPackages";
+ description = ''
+ The set of Haskell packages from which to get GHC and its packages.
+ Use this option to set the version of GHC.
+ '';
+ example = literalExample "pkgs.haskell.packages.ghcjs";
+ };
+ packages = mkOption {
+ type = with types; functionTo (listOf package);
+ default = _: [ ];
+ defaultText = literalExample "_ : []";
+ description = ''
+ Haskell packages that will be made available to the environment.
+ '';
+ example = literalExample ''
+ haskellPackages: with haskellPackages; [ async cabal-install ];
+ '';
+ };
+ # Whether to load packages required by Spacemacs layer.
+ spacemacs.enable = mkEnableOption "spacemacs";
+
+ hoogle.enable = mkEnableOption "hoogle";
+
+ cabal = {
+ enable = mkEnableOption "cabal";
+ package = mkOption {
+ type = types.package;
+ default = pkgs.cabal-install;
+ defaultText = defaultText "pkgs.cabal-install";
+ description = "The package for cabal.";
+ };
+ # TODO: add ability to set path to binaries
+ # TODO: explain that here cabal is not loaded with ghc, but as an external package
+ };
+ };
+
+ config = mkIf cfg.enable {
+ buildInputs = [ haskellBuildInput ];
+ envVars.PATH.value = mkIf cfg.cabal.enable "~/.cabal/bin"; # only on linux
+ };
+}