improve release setup
- use a build flag to turn on static system libraries - generate shell completion scripts - externalise the generate cabal2nix function
This commit is contained in:
parent
2fcb4eae1e
commit
e16a6e42d6
@ -29,6 +29,10 @@ source-repository head
|
||||
type: git
|
||||
location: https://maxwell.ydns.eu/git/rnhmjoj/bisc
|
||||
|
||||
flag static
|
||||
default: False
|
||||
description: Create a statically-linked binary
|
||||
|
||||
executable bisc
|
||||
main-is: Main.hs
|
||||
build-depends: base ==4.* , selda ==0.*,
|
||||
@ -40,4 +44,5 @@ executable bisc
|
||||
optparse-applicative
|
||||
default-language: Haskell2010
|
||||
ghc-options: -Wall
|
||||
extra-libraries: snappy stdc++
|
||||
if flag(static)
|
||||
extra-libraries: snappy stdc++
|
||||
|
45
default.nix
45
default.nix
@ -10,38 +10,31 @@ 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, optparse-applicative
|
||||
}:
|
||||
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
|
||||
optparse-applicative
|
||||
];
|
||||
executableSystemDepends = [ pkgs.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 {});
|
||||
drv = variant (override (ghc.callPackage ./bisc.nix {}));
|
||||
|
||||
override = drv: pkgs.haskell.lib.overrideCabal drv (old: with pkgs.lib; {
|
||||
buildTools = [ pkgs.installShellFiles ];
|
||||
configureFlags = optional static "-f static";
|
||||
buildFlags = optionals static [
|
||||
"--ld-option=-lstdc++"
|
||||
"--ld-option=-lsnappy"
|
||||
];
|
||||
postInstall = ''
|
||||
# generate completion
|
||||
$out/bin/bisc --bash-completion-script "$out/bin/bisc" > bisc.bash
|
||||
$out/bin/bisc --fish-completion-script "$out/bin/bisc" > bisc.fish
|
||||
$out/bin/bisc --zsh-completion-script "$out/bin/bisc" > bisc.zsh
|
||||
|
||||
installShellCompletion bisc.{bash,fish,zsh}
|
||||
'';
|
||||
postFixup = optionalString static "rm -r $out/nix-support";
|
||||
});
|
||||
|
||||
in
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user