aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore5
-rw-r--r--flake.lock149
-rw-r--r--flake.nix101
3 files changed, 254 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 5da920295..57a3c0e0b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,7 @@
/TAGS
/bench-*
!.circleci/**
+!.envrc
!.editorconfig
!.gitattributes
!.github/**
@@ -30,9 +31,11 @@
!Setup.hs
!cabal.project
!changelog.md
-!default.nix
!pandoc.cabal
!hie.yaml
+!flake.nix
+!flake.lock
+!default.nix
!release.nix
!shell.nix
!stack.yaml
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 000000000..a3771e4b5
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,149 @@
+{
+ "nodes": {
+ "flake-parts": {
+ "inputs": {
+ "nixpkgs-lib": "nixpkgs-lib"
+ },
+ "locked": {
+ "lastModified": 1677714448,
+ "narHash": "sha256-Hq8qLs8xFu28aDjytfxjdC96bZ6pds21Yy09mSC156I=",
+ "owner": "hercules-ci",
+ "repo": "flake-parts",
+ "rev": "dc531e3a9ce757041e1afaff8ee932725ca60002",
+ "type": "github"
+ },
+ "original": {
+ "owner": "hercules-ci",
+ "repo": "flake-parts",
+ "type": "github"
+ }
+ },
+ "flake-root": {
+ "locked": {
+ "lastModified": 1671378805,
+ "narHash": "sha256-yqGxyzMN2GuppwG3dTWD1oiKxi+jGYP7D1qUSc5vKhI=",
+ "owner": "srid",
+ "repo": "flake-root",
+ "rev": "dc7ba6166e478804a9da6881aa48c45d300075cf",
+ "type": "github"
+ },
+ "original": {
+ "owner": "srid",
+ "repo": "flake-root",
+ "type": "github"
+ }
+ },
+ "haskell-flake": {
+ "locked": {
+ "lastModified": 1678224654,
+ "narHash": "sha256-HZKnkkDKXvcK45KPVISzioyGjRfg7Ee0jmxUPjOvmRg=",
+ "owner": "srid",
+ "repo": "haskell-flake",
+ "rev": "b1f266999065443a2a038a0bf17b3a836e64d245",
+ "type": "github"
+ },
+ "original": {
+ "owner": "srid",
+ "repo": "haskell-flake",
+ "type": "github"
+ }
+ },
+ "mission-control": {
+ "locked": {
+ "lastModified": 1675195908,
+ "narHash": "sha256-nQv35C7svZFluwy2uoZFxwPqiT16XoKAoMlIQYmvg3A=",
+ "owner": "Platonic-Systems",
+ "repo": "mission-control",
+ "rev": "feb06872ac4dc977f70f6388c87d36fc3c3c3693",
+ "type": "github"
+ },
+ "original": {
+ "owner": "Platonic-Systems",
+ "repo": "mission-control",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1678268259,
+ "narHash": "sha256-q+ZWNJfXKgIKwsZBir0yXrmIV/4tOv5BflxDAfGISps=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "90ef5c3c337d8d9f0c97e7641ece70a41f6c16a2",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "ref": "nixpkgs-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "nixpkgs-140774-workaround": {
+ "locked": {
+ "lastModified": 1677708284,
+ "narHash": "sha256-syAhlmvVlVDwgoKS6b3EfrQKfaeCY3zjT2q7VBk/yx8=",
+ "owner": "srid",
+ "repo": "nixpkgs-140774-workaround",
+ "rev": "5fe054e8560cf474b3c89622c1ea7688023425c1",
+ "type": "github"
+ },
+ "original": {
+ "owner": "srid",
+ "repo": "nixpkgs-140774-workaround",
+ "type": "github"
+ }
+ },
+ "nixpkgs-lib": {
+ "locked": {
+ "dir": "lib",
+ "lastModified": 1677407201,
+ "narHash": "sha256-3blwdI9o1BAprkvlByHvtEm5HAIRn/XPjtcfiunpY7s=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "7f5639fa3b68054ca0b062866dc62b22c3f11505",
+ "type": "github"
+ },
+ "original": {
+ "dir": "lib",
+ "owner": "NixOS",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "flake-parts": "flake-parts",
+ "flake-root": "flake-root",
+ "haskell-flake": "haskell-flake",
+ "mission-control": "mission-control",
+ "nixpkgs": "nixpkgs",
+ "nixpkgs-140774-workaround": "nixpkgs-140774-workaround",
+ "treefmt-nix": "treefmt-nix"
+ }
+ },
+ "treefmt-nix": {
+ "inputs": {
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1678277086,
+ "narHash": "sha256-fQ1G72KhLWWf2z+ug9+4ErTEayvlcVQMul0qusKKBgk=",
+ "owner": "numtide",
+ "repo": "treefmt-nix",
+ "rev": "ec39cfa24342fdf0b04ae44592a191c4765f9c74",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "treefmt-nix",
+ "type": "github"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 000000000..ea7f4c08b
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,101 @@
+{
+ description = "srid/haskell-template: Nix template for Haskell projects";
+ inputs = {
+ nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
+ flake-parts.url = "github:hercules-ci/flake-parts";
+ haskell-flake.url = "github:srid/haskell-flake";
+ treefmt-nix.url = "github:numtide/treefmt-nix";
+ treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
+ flake-root.url = "github:srid/flake-root";
+ mission-control.url = "github:Platonic-Systems/mission-control";
+
+ nixpkgs-140774-workaround.url = "github:srid/nixpkgs-140774-workaround";
+ };
+
+ outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
+ flake-parts.lib.mkFlake { inherit inputs; } {
+ systems = nixpkgs.lib.systems.flakeExposed;
+ imports = [
+ inputs.haskell-flake.flakeModule
+ inputs.treefmt-nix.flakeModule
+ inputs.flake-root.flakeModule
+ inputs.mission-control.flakeModule
+ ];
+ perSystem = { self', system, lib, config, pkgs, ... }: {
+ # The "main" project. You can have multiple projects, but this template
+ # has only one.
+ haskellProjects.main = {
+ imports = [
+ inputs.nixpkgs-140774-workaround.haskellFlakeProjectModules.default
+ ];
+ # packages.haskell-template.root = ./.; # Auto-discovered by haskell-flake
+ overrides = self: super: { };
+ devShell = {
+ tools = hp: {
+ treefmt = config.treefmt.build.wrapper;
+ } // config.treefmt.build.programs;
+ hlsCheck.enable = true;
+ };
+ };
+
+ # Auto formatters. This also adds a flake check to ensure that the
+ # source tree was auto formatted.
+ treefmt.config = {
+ inherit (config.flake-root) projectRootFile;
+ package = pkgs.treefmt;
+
+ programs.ormolu.enable = true;
+ programs.nixpkgs-fmt.enable = true;
+ programs.cabal-fmt.enable = true;
+ programs.hlint.enable = true;
+
+ # We use fourmolu
+ programs.ormolu.package = pkgs.haskellPackages.fourmolu;
+ settings.formatter.ormolu = {
+ options = [
+ "--ghc-opt"
+ "-XImportQualifiedPost"
+ ];
+ };
+ };
+
+ # Dev shell scripts.
+ mission-control.scripts = {
+ docs = {
+ description = "Start Hoogle server for project dependencies";
+ exec = ''
+ echo http://127.0.0.1:8888
+ hoogle serve -p 8888 --local
+ '';
+ category = "Dev Tools";
+ };
+ repl = {
+ description = "Start the cabal repl";
+ exec = ''
+ cabal repl "$@"
+ '';
+ category = "Dev Tools";
+ };
+ fmt = {
+ description = "Format the source tree";
+ exec = "${lib.getExe config.treefmt.build.wrapper}";
+ category = "Dev Tools";
+ };
+ run = {
+ description = "Run the project with ghcid auto-recompile";
+ exec = ''
+ ghcid -c "cabal repl exe:haskell-template" --warnings -T :main
+ '';
+ category = "Primary";
+ };
+ };
+
+ # Default package.
+ packages.default = self'.packages.main-haskell-template;
+
+ # Default shell.
+ devShells.default =
+ config.mission-control.installToDevShell self'.devShells.main;
+ };
+ };
+}