From 71a3f4e8efa833cc1a8209ab336ac8c454cc2f9b Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 3 Aug 2021 15:44:49 +0200 Subject: env.nix -> shell.nix --- .gitignore | 3 +++ env.nix | 50 -------------------------------------------------- regfish.cabal | 26 ++++++++++++++++++++++++++ regfish.nix | 13 +++++++++++++ shell.nix | 44 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 86 insertions(+), 50 deletions(-) delete mode 100644 env.nix create mode 100644 regfish.cabal create mode 100644 regfish.nix create mode 100644 shell.nix diff --git a/.gitignore b/.gitignore index cd57d17..c42c311 100644 --- a/.gitignore +++ b/.gitignore @@ -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 {} }: - -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 - 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 +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 {} +, 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 { + 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 + ''; + }) -- cgit v1.2.3