summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2015-10-17 18:44:53 +0200
committertv <tv@shackspace.de>2015-10-17 19:25:29 +0200
commit0911b937dc829b2c9ca67f8636499cad2fc4f632 (patch)
treee9eba735b90a883b63af89f198b80596bd167a95 /Makefile
parentef344c57945d455c6752c2032c701d7f9315f69b (diff)
init Makefile
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile37
1 files changed, 37 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..7960aab
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,37 @@
+# Makefile for Cabal packages in stockholm[0].
+# [0]: http://cgit.cd.krebsco.de/stockholm
+
+pkg-name := $(basename $(wildcard *.cabal))
+
+ifneq ($(words $(pkg-name)),1)
+$(error pkg-name is not a single word but '$(pkg-name)')
+endif
+
+.ONESHELL:
+.SHELLFLAGS := -efu -c
+
+export STOCKHOLM := $(HOME)/stockholm
+nix-shell-flags := -I nixpkgs="$$STOCKHOLM"
+
+# make V=1 to enable verbose output
+ifeq ($(V),1)
+nix-shell-flags += -v
+endif
+
+# This is basically what load-env[1] did, which is mostly dead. Eventually
+# this should also become a wrapper for entering a development environment.
+# Notice that setting HOME is required for project-local GHCi history[2]. And
+# as we have to do it anyway, we're also reusing it for other stuff.
+# [1]: http://cgit.cd.krebsco.de/load-env
+# [2]: https://ghc.haskell.org/trac/ghc/ticket/9089
+.PHONY: shell
+shell: shell.nix
+ @verbose() { echo "$$*" >&2; "$$@"; }
+ verbose export HOME="$$HOME"/.env-home/$(pkg-name)
+ test -d "$$HOME" || verbose mkdir -p -m 0700 "$$HOME"
+ ! test -f "$$HOME"/profile || verbose . "$$HOME"/profile
+ export HISTFILE="$$HOME"/histfile HISTSIZE=100000
+ verbose nix-shell $(nix-shell-flags) --command 'exec ghci'
+
+shell.nix: $(pkg-name).cabal
+ cabal2nix --shell . > $@