summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore5
-rw-r--r--Makefile21
-rw-r--r--README2
-rw-r--r--env.nix51
-rw-r--r--shell.nix31
5 files changed, 34 insertions, 76 deletions
diff --git a/.gitignore b/.gitignore
index 36eacc8..3c203cb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1 @@
-*.hi
-*.o
-/.graveyard
-/shell.nix
+/package.nix
diff --git a/Makefile b/Makefile
deleted file mode 100644
index d7ece7f..0000000
--- a/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-.PHONY: _default
-_default: ghci
-
-.PHONY: clean
-clean:
- @find * -type f \( -name \*.o -o -name \*.hi \) -exec rm -v \{\} \;
-
-.PHONY: ghci
-ghci: shell.nix
- nix-shell --argstr compiler ghc801 --command 'exec ghci -Wall -fobject-code -isrc'
-
-.PHONY: install
-install:
- $(error to install run "make result && nix-env -i ./result")
-
-.PHONY: result
-result: shell.nix
- nix-build ./shell.nix
-
-shell.nix: $(wildcard *.cabal)
- cabal2nix --shell . > $@
diff --git a/README b/README
new file mode 100644
index 0000000..74aa051
--- /dev/null
+++ b/README
@@ -0,0 +1,2 @@
+cabal2nix . > package.nix && nix-shell
+cabal run
diff --git a/env.nix b/env.nix
deleted file mode 100644
index 47a9759..0000000
--- a/env.nix
+++ /dev/null
@@ -1,51 +0,0 @@
-{ nixpkgs ? import <nixpkgs> {} }:
-
-let
- pname = "hack";
- version = "2";
-
- buildInputs = with pkgs; [
- hsEnv
- ];
-
- extraCmds = with pkgs; ''
- export MANPATH=$(ls -d $(echo "$PATH" | tr : \\n | sed -n 's:\(^/nix/store/[^/]\+\).*:\1/share/man:p') 2>/dev/null | tr \\n :)
- $(grep export ${hsEnv.outPath}/bin/ghc)
- ${mkExports staticPkgs}
- '';
-
- hsEnv = hsPkgs.ghcWithPackages (self: with self;
- [
- cabal-install
- data-default
- lens
- mtl
- zippers
-
- #threadscope
- ]
- );
-
- hsPkgs = pkgs.haskellngPackages;
-
- pkgs = nixpkgs // staticPkgs;
- staticPkgs = with nixpkgs; {
- };
-
- #{{{ mkExports : set -> string
- # Create shell script that exports a set's attributes.
- mkExports = set: with builtins; with pkgs.lib.strings;
- let
- # XXX attribute names are not escaped, they have to be sane
- # XXX the value should not contain <newline>
- mkExport = k: "export ${k}=${escapeSh (getAttr k set)}";
- escapeSh = stringAsChars (c: "\\${c}");
- in
- concatStringsSep "\n" (map mkExport (attrNames set));
- #}}}
-
-in pkgs.myEnvFun {
- name = "${pname}-${version}";
- inherit buildInputs extraCmds;
-}
-# vim: set fdm=marker :
diff --git a/shell.nix b/shell.nix
new file mode 100644
index 0000000..48d4bf4
--- /dev/null
+++ b/shell.nix
@@ -0,0 +1,31 @@
+{ compiler ? "default"
+, nixpkgs ? import <nixpkgs> {}
+}: let
+
+ inherit (nixpkgs) lib pkgs;
+
+ haskellPackages =
+ if compiler == "default" then
+ pkgs.haskellPackages
+ else
+ pkgs.haskell.packages.${compiler};
+
+ drv = haskellPackages.callPackage (import ./package.nix) {};
+
+in
+
+ lib.overrideDerivation drv.env (oldAttrs: {
+ buildInputs = [
+ pkgs.cabal-install
+ ];
+ shellHook = ''
+ CABAL_BUILD_DIR=$HOME/tmp/cache/${drv.pname}
+ cabal() {
+ command=$1; shift
+ ${pkgs.cabal-install}/bin/cabal \
+ "$command" \
+ --builddir="$CABAL_BUILD_DIR" \
+ "$@"
+ }
+ '';
+ })