2019-06-16 20:59:06 +01:00
|
|
|
{ stdenv, cleanPackaging, fetchurl }:
|
2018-09-02 22:31:26 +01:00
|
|
|
let lib = stdenv.lib;
|
|
|
|
in {
|
|
|
|
# : string
|
|
|
|
pname
|
|
|
|
# : string
|
|
|
|
, version
|
|
|
|
# : string
|
|
|
|
, sha256
|
|
|
|
# : string
|
|
|
|
, description
|
|
|
|
# : list Platform
|
|
|
|
, platforms ? lib.platforms.all
|
|
|
|
# : list string
|
|
|
|
, outputs ? [ "bin" "lib" "dev" "doc" "out" ]
|
|
|
|
# TODO(Profpatsch): automatically infer most of these
|
|
|
|
# : list string
|
|
|
|
, configureFlags
|
|
|
|
# mostly for moving and deleting files from the build directory
|
|
|
|
# : lines
|
2020-03-22 20:58:11 +00:00
|
|
|
, postInstall
|
2018-09-02 22:31:26 +01:00
|
|
|
# : list Maintainer
|
|
|
|
, maintainers ? []
|
2020-03-22 20:58:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
}:
|
2018-09-02 22:31:26 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
# File globs that can always be deleted
|
|
|
|
commonNoiseFiles = [
|
|
|
|
".gitignore"
|
|
|
|
"Makefile"
|
|
|
|
"INSTALL"
|
|
|
|
"configure"
|
|
|
|
"patch-for-solaris"
|
|
|
|
"src/**/*"
|
|
|
|
"tools/**/*"
|
|
|
|
"package/**/*"
|
|
|
|
"config.mak"
|
|
|
|
];
|
|
|
|
|
|
|
|
# File globs that should be moved to $doc
|
|
|
|
commonMetaFiles = [
|
|
|
|
"COPYING"
|
|
|
|
"AUTHORS"
|
|
|
|
"NEWS"
|
|
|
|
"CHANGELOG"
|
|
|
|
"README"
|
|
|
|
"README.*"
|
|
|
|
];
|
|
|
|
|
2020-03-22 20:58:11 +00:00
|
|
|
in stdenv.mkDerivation {
|
2020-03-22 21:13:51 +00:00
|
|
|
inherit pname version;
|
2020-03-22 20:58:11 +00:00
|
|
|
|
2018-09-04 20:55:47 +01:00
|
|
|
src = fetchurl {
|
|
|
|
url = "https://skarnet.org/software/${pname}/${pname}-${version}.tar.gz";
|
2018-09-02 22:31:26 +01:00
|
|
|
inherit sha256;
|
|
|
|
};
|
|
|
|
|
2020-03-22 20:58:11 +00:00
|
|
|
inherit outputs;
|
|
|
|
|
2018-09-02 22:31:26 +01:00
|
|
|
dontDisableStatic = true;
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
configureFlags = configureFlags ++ [
|
|
|
|
"--enable-absolute-paths"
|
2020-02-10 12:51:50 +00:00
|
|
|
# We assume every nix-based cross target has urandom.
|
|
|
|
# This might not hold for e.g. BSD.
|
|
|
|
"--with-sysdep-devurandom=yes"
|
2018-09-02 22:31:26 +01:00
|
|
|
(if stdenv.isDarwin
|
|
|
|
then "--disable-shared"
|
|
|
|
else "--enable-shared")
|
|
|
|
]
|
|
|
|
# On darwin, the target triplet from -dumpmachine includes version number,
|
|
|
|
# but skarnet.org software uses the triplet to test binary compatibility.
|
|
|
|
# Explicitly setting target ensures code can be compiled against a skalibs
|
|
|
|
# binary built on a different version of darwin.
|
|
|
|
# http://www.skarnet.org/cgi-bin/archive.cgi?1:mss:623:heiodchokfjdkonfhdph
|
|
|
|
++ (lib.optional stdenv.isDarwin
|
|
|
|
"--build=${stdenv.hostPlatform.system}");
|
|
|
|
|
|
|
|
# TODO(Profpatsch): ensure that there is always a $doc output!
|
|
|
|
postInstall = ''
|
|
|
|
echo "Cleaning & moving common files"
|
2019-02-24 13:40:10 +00:00
|
|
|
${cleanPackaging.commonFileActions {
|
|
|
|
noiseFiles = commonNoiseFiles;
|
|
|
|
docFiles = commonMetaFiles;
|
|
|
|
}} $doc/share/doc/${pname}
|
2020-03-22 20:58:11 +00:00
|
|
|
|
|
|
|
${postInstall}
|
|
|
|
'';
|
2018-09-02 22:31:26 +01:00
|
|
|
|
|
|
|
postFixup = ''
|
2019-02-24 13:40:10 +00:00
|
|
|
${cleanPackaging.checkForRemainingFiles}
|
2020-03-22 20:58:11 +00:00
|
|
|
'';
|
2018-09-02 22:31:26 +01:00
|
|
|
|
|
|
|
meta = {
|
|
|
|
homepage = "https://skarnet.org/software/${pname}/";
|
|
|
|
inherit description platforms;
|
|
|
|
license = stdenv.lib.licenses.isc;
|
|
|
|
maintainers = with lib.maintainers;
|
|
|
|
[ pmahoney Profpatsch ] ++ maintainers;
|
2020-03-22 20:58:11 +00:00
|
|
|
};
|
2018-09-02 22:31:26 +01:00
|
|
|
|
2020-03-22 20:58:11 +00:00
|
|
|
}
|