diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 37 |
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 . > $@ |