From 0911b937dc829b2c9ca67f8636499cad2fc4f632 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 17 Oct 2015 18:44:53 +0200 Subject: init Makefile --- Makefile | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Makefile 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 . > $@ -- cgit v1.2.3