diff options
author | tv <tv@krebsco.de> | 2021-08-03 15:44:49 +0200 |
---|---|---|
committer | tv <tv@krebsco.de> | 2021-08-03 15:45:03 +0200 |
commit | 71a3f4e8efa833cc1a8209ab336ac8c454cc2f9b (patch) | |
tree | 799b6b6a7ddbba84673b42342b1428cba9369c39 | |
parent | 288051f52e65857a7946e65c5a454b8b35af981b (diff) |
env.nix -> shell.nix
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | env.nix | 50 | ||||
-rw-r--r-- | regfish.cabal | 26 | ||||
-rw-r--r-- | regfish.nix | 13 | ||||
-rw-r--r-- | shell.nix | 44 |
5 files changed, 86 insertions, 50 deletions
@@ -1,4 +1,7 @@ +/.bash_history +/.ghci_history /.graveyard +/.profile /state *.hi *.o diff --git a/env.nix b/env.nix deleted file mode 100644 index eef085c..0000000 --- a/env.nix +++ /dev/null @@ -1,50 +0,0 @@ -{ nixpkgs ? import <nixpkgs> {} }: - -let - pname = "regfish"; - 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) - ''; - - hsEnv = hsPkgs.ghcWithPackages (self: with self; - [ - acid-state - cabal-install - HandsomeSoup - wreq - ] - ); - - hsPkgs = pkgs.haskellPackages.override { - overrides = self: super: with self; { - }; - }; - - 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/regfish.cabal b/regfish.cabal new file mode 100644 index 0000000..87a8865 --- /dev/null +++ b/regfish.cabal @@ -0,0 +1,26 @@ +name: regfish +version: 2.0.0 +license: MIT +author: tv +maintainer: tv <tv@krebsco.de> +build-type: Simple +cabal-version: >=1.10 + +library + build-depends: base + , HandsomeSoup + , acid-state + , bytestring + , data-default + , http-client + , hxt + , lens + , mtl + , safecopy + , wreq + exposed-modules: Regfish + , Regfish.AcidState + , Regfish.Default + , Regfish.Parser + , Regfish.Types + ghc-options: -O2 -Wall diff --git a/regfish.nix b/regfish.nix new file mode 100644 index 0000000..d0be0c9 --- /dev/null +++ b/regfish.nix @@ -0,0 +1,13 @@ +{ mkDerivation, acid-state, base, bytestring, data-default +, HandsomeSoup, http-client, hxt, lens, lib, mtl, safecopy, wreq +}: +mkDerivation { + pname = "regfish"; + version = "2.0.0"; + src = ./.; + libraryHaskellDepends = [ + acid-state base bytestring data-default HandsomeSoup http-client + hxt lens mtl safecopy wreq + ]; + license = lib.licenses.mit; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..4290cbb --- /dev/null +++ b/shell.nix @@ -0,0 +1,44 @@ +{ nixpkgs ? import <nixpkgs> {} +, compiler ? "default" +, doBenchmark ? false +}: + +let + # cabal2nix . > regfish.nix + packageFile = ./regfish.nix; + + inherit (nixpkgs) lib pkgs; + + haskellPackages = if compiler == "default" + then pkgs.haskellPackages + else pkgs.haskell.packages.${compiler}; + + hoogle = + haskellPackages.callPackage <nixpkgs/pkgs/development/haskell-modules/hoogle.nix> { + packages = + (haskellPackages.callPackage packageFile { + mkDerivation = pkgs.lib.id; + }).executableHaskellDepends; + }; + + variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id; + + drv = variant (haskellPackages.callPackage packageFile { + }); + +in + + pkgs.lib.overrideDerivation drv.env (oldAttrs: { + buildInputs = [ + pkgs.cabal-install + ]; + shellHook = '' + cd ${lib.escapeShellArg (toString ./.)} + alias ghci='ghci -flocal-ghci-history -odir ~/tmp/regfish -hidir ~/tmp/regfish' + export HISTFILE=.bash_history HISTSIZE=100000 + + if test -e .profile; then + . ./.profile + fi + ''; + }) |