2021-02-05 17:12:51 +00:00
|
|
|
{ lib, stdenv, cleanPackaging, fetchurl }:
|
|
|
|
{
|
2020-04-24 23:36:52 +00:00
|
|
|
# : 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
|
2021-08-22 07:53:02 +00:00
|
|
|
# : string
|
|
|
|
, postConfigure ? null
|
2020-04-24 23:36:52 +00:00
|
|
|
# mostly for moving and deleting files from the build directory
|
|
|
|
# : lines
|
|
|
|
, postInstall
|
|
|
|
# : list Maintainer
|
2022-01-19 23:45:15 +00:00
|
|
|
, maintainers ? [ ]
|
2021-09-28 08:13:01 +00:00
|
|
|
# : passtrhu arguments (e.g. tests)
|
2022-01-19 23:45:15 +00:00
|
|
|
, passthru ? { }
|
2020-04-24 23:36:52 +00: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.*"
|
2021-09-28 08:13:01 +00:00
|
|
|
"DCO"
|
|
|
|
"CONTRIBUTING"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2022-01-19 23:45:15 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
2020-04-24 23:36:52 +00:00
|
|
|
inherit pname version;
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://skarnet.org/software/${pname}/${pname}-${version}.tar.gz";
|
|
|
|
inherit sha256;
|
|
|
|
};
|
|
|
|
|
|
|
|
inherit outputs;
|
|
|
|
|
|
|
|
dontDisableStatic = true;
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
configureFlags = configureFlags ++ [
|
|
|
|
"--enable-absolute-paths"
|
|
|
|
# We assume every nix-based cross target has urandom.
|
|
|
|
# This might not hold for e.g. BSD.
|
|
|
|
"--with-sysdep-devurandom=yes"
|
|
|
|
(if stdenv.isDarwin
|
2022-01-19 23:45:15 +00:00
|
|
|
then "--disable-shared"
|
|
|
|
else "--enable-shared")
|
2020-04-24 23:36:52 +00:00
|
|
|
]
|
|
|
|
# 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
|
2022-01-19 23:45:15 +00:00
|
|
|
"--build=${stdenv.hostPlatform.system}");
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
inherit postConfigure;
|
|
|
|
|
2022-01-19 23:45:15 +00:00
|
|
|
makeFlags = lib.optional stdenv.cc.isClang [ "AR=${stdenv.cc.targetPrefix}ar" "RANLIB=${stdenv.cc.targetPrefix}ranlib" ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# TODO(Profpatsch): ensure that there is always a $doc output!
|
|
|
|
postInstall = ''
|
|
|
|
echo "Cleaning & moving common files"
|
|
|
|
${cleanPackaging.commonFileActions {
|
|
|
|
noiseFiles = commonNoiseFiles;
|
|
|
|
docFiles = commonMetaFiles;
|
|
|
|
}} $doc/share/doc/${pname}
|
|
|
|
|
|
|
|
${postInstall}
|
|
|
|
'';
|
|
|
|
|
|
|
|
postFixup = ''
|
|
|
|
${cleanPackaging.checkForRemainingFiles}
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
homepage = "https://skarnet.org/software/${pname}/";
|
|
|
|
inherit description platforms;
|
2021-02-05 17:12:51 +00:00
|
|
|
license = lib.licenses.isc;
|
2020-04-24 23:36:52 +00:00
|
|
|
maintainers = with lib.maintainers;
|
2021-06-28 23:13:55 +00:00
|
|
|
[ pmahoney Profpatsch qyliss ] ++ maintainers;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-09-28 08:13:01 +00:00
|
|
|
inherit passthru;
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|