add Nix expression for static/cross compilation

master 0.3.0
Michele Guerini Rocco 2021-05-11 16:44:43 +02:00
parent 26cdfa7994
commit 74c7db11a8
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450
2 changed files with 47 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,2 +1 @@
dist
default.nix

47
default.nix Normal file
View File

@ -0,0 +1,47 @@
{ nixpkgs ? <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