6e6c8b7338
The reason for this change is explained in the long comment I added. Here's a simple example of the problem: let pkgs = import <nixpkgs> { crossSystem.system = "aarch64-linux"; }; in pkgs.callPackage ({ stdenv, s6-rc }: stdenv.mkDerivation { name = "s6-rc-compiled"; nativeBuildInputs = [ s6-rc ]; buildCommand = '' mkdir in s6-rc-compile $out in ''; }) {} We're cross compiling for aarch64 here, so we'd expect the scripts generated by this derivation to be things we could run on aarch64. But when I build this on my x86_64 machine, without this change applied, $out/servicedirs/s6rc-oneshot-runner/run gets generated full of references to x86_64 non-cross store paths for execline, s6, and s6-rc. With this change applied, the scripts generated by the above expression now refer to the cross-compiled aarch64 store paths for execline, s6, and s6-rc.
109 lines
2.5 KiB
Nix
109 lines
2.5 KiB
Nix
{ lib, stdenv, cleanPackaging, fetchurl }:
|
|
{
|
|
# : 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
|
|
# : string
|
|
, postConfigure ? null
|
|
# mostly for moving and deleting files from the build directory
|
|
# : lines
|
|
, postInstall
|
|
# : list Maintainer
|
|
, maintainers ? []
|
|
|
|
|
|
}:
|
|
|
|
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.*"
|
|
];
|
|
|
|
in stdenv.mkDerivation {
|
|
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
|
|
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}");
|
|
|
|
inherit postConfigure;
|
|
|
|
# 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;
|
|
license = lib.licenses.isc;
|
|
maintainers = with lib.maintainers;
|
|
[ pmahoney Profpatsch qyliss ] ++ maintainers;
|
|
};
|
|
|
|
}
|