From dd882e1ebcd4ce3afc77351d3109ee3e54699836 Mon Sep 17 00:00:00 2001 From: kiana-S Date: Sat, 12 Mar 2022 18:13:25 -0500 Subject: [PATCH] Initial commit --- flake.nix | 13 ++++++++++++ template/Main.hs | 4 ++++ template/flake.nix | 48 ++++++++++++++++++++++++++++++++++++++++++ template/project.cabal | 16 ++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 flake.nix create mode 100644 template/Main.hs create mode 100644 template/flake.nix create mode 100644 template/project.cabal diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..8a5e03c --- /dev/null +++ b/flake.nix @@ -0,0 +1,13 @@ +{ + description = "A simple haskell template"; + + outputs = { self }: { + + templates.haskell = { + description = "A haskell executable"; + path = ./template; + }; + + defaultTemplate = self.templates.haskell; + }; +} diff --git a/template/Main.hs b/template/Main.hs new file mode 100644 index 0000000..c2e4af9 --- /dev/null +++ b/template/Main.hs @@ -0,0 +1,4 @@ +module Main where + +main :: IO () +main = undefined diff --git a/template/flake.nix b/template/flake.nix new file mode 100644 index 0000000..628da55 --- /dev/null +++ b/template/flake.nix @@ -0,0 +1,48 @@ +{ + description = "A haskell executable"; + + outputs = { self, nixpkgs, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + overlays = []; + pkgs = import nixpkgs { inherit system overlays; config.allowBroken = true; }; + + # package/executable name + packageName = ""; + execName = packageName; + + # version of ghc used + hp = pkgs.haskellPackages; + + project = returnShellEnv: + hp.developPackage { + inherit returnShellEnv; + name = packageName; + root = ./.; + withHoogle = false; + 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: + pkgs.haskell.lib.addBuildTools drv (with hp; [ + # Specify your build/dev dependencies here. + ]); + }; + in + { + # Used by `nix build` & `nix run` (prod exe) + defaultPackage = project false; + + defaultApp = { + type = "app"; + program = "${self.defaultPackage.${system}}/bin/${execName}"; + }; + + # Used by `nix develop` (dev shell) + devShell = project true; + }); +} diff --git a/template/project.cabal b/template/project.cabal new file mode 100644 index 0000000..9187f17 --- /dev/null +++ b/template/project.cabal @@ -0,0 +1,16 @@ +cabal-version: 2.4 +name: +version: 0.0 +synopsis: +author: +license: +build-type: Simple + +library + build-depends: + exposed-modules: + +executable + main-is: Main.hs + other-modules: + build-depends: