diff --git a/.gitignore b/.gitignore index 02cbea7..1521c8b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ dist -default.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..35724e6 --- /dev/null +++ b/default.nix @@ -0,0 +1,47 @@ +{ nixpkgs ? +, static ? false +, compiler ? "default" +, doBenchmark ? false +, system ? builtins.currentSystem +}: + +let + + basepkgs = import nixpkgs { inherit system; }; + pkgs = if static then basepkgs.pkgsStatic else basepkgs.pkgs; + + f = { mkDerivation, base, bytestring, configurator, data-default + , directory, exceptions, filepath, leveldb-haskell, mtl, selda + , selda-sqlite , lib, text, snappy + }: + mkDerivation { + pname = "bisc"; + version = "0.3.0.0"; + src = ./.; + isLibrary = false; + isExecutable = true; + executableHaskellDepends = [ + base bytestring configurator data-default directory exceptions + filepath leveldb-haskell mtl selda selda-sqlite text + ]; + executableSystemDepends = [ snappy ]; + buildFlags = lib.optionals static [ + "--ld-option=-lstdc++" + "--ld-option=-lsnappy" + ]; + homepage = "https://maxwell.ydns.eu/git/rnhmjoj/bisc"; + description = "A small tool that clears cookies (and more)"; + license = lib.licenses.gpl3; + }; + + ghc = if static then pkgs.haskell.packages.integer-simple.ghc8104 + else if compiler == "default" then pkgs.haskellPackages + else pkgs.haskell.packages.${compiler}; + + variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id; + + drv = variant (ghc.callPackage f {}); + +in + + if pkgs.lib.inNixShell then drv.env else drv