-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108562 from KarlJoad/octave-modules
- Loading branch information
Showing
79 changed files
with
2,757 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
{ stdenv, octave, buildEnv | ||
, makeWrapper, texinfo | ||
, octavePackages | ||
, wrapOctave | ||
, computeRequiredOctavePackages | ||
, extraLibs ? [] | ||
, extraOutputsToInstall ? [] | ||
, postBuild ? "" | ||
, ignoreCollisions ? false | ||
}: | ||
|
||
# Create an octave executable that knows about additional packages | ||
let | ||
packages = computeRequiredOctavePackages extraLibs; | ||
|
||
in buildEnv { | ||
name = "${octave.name}-env"; | ||
paths = extraLibs ++ [ octave ]; | ||
|
||
inherit ignoreCollisions; | ||
extraOutputsToInstall = [ "out" ] ++ extraOutputsToInstall; | ||
|
||
buildInputs = [ makeWrapper texinfo wrapOctave ]; | ||
|
||
# During "build" we must first unlink the /share symlink to octave's /share | ||
# Then, we can re-symlink the all of octave/share, except for /share/octave | ||
# in env/share/octave, re-symlink everything from octave/share/octave and then | ||
# perform the pkg install. | ||
postBuild = '' | ||
. "${makeWrapper}/nix-support/setup-hook" | ||
# The `makeWrapper` used here is the one defined in | ||
# ${makeWrapper}/nix-support/setup-hook | ||
if [ -L "$out/bin" ]; then | ||
unlink $out/bin | ||
mkdir -p "$out/bin" | ||
cd "${octave}/bin" | ||
for prg in *; do | ||
if [ -x $prg ]; then | ||
makeWrapper "${octave}/bin/$prg" "$out/bin/$prg" --set OCTAVE_SITE_INITFILE "$out/share/octave/site/m/startup/octaverc" | ||
fi | ||
done | ||
cd $out | ||
fi | ||
# Remove symlinks to the input tarballs, they aren't needed. | ||
rm $out/*.tar.gz | ||
createOctavePackagesPath $out ${octave} | ||
for path in ${stdenv.lib.concatStringsSep " " packages}; do | ||
if [ -e $path/*.tar.gz ]; then | ||
$out/bin/octave-cli --eval "pkg local_list $out/.octave_packages; \ | ||
pkg prefix $out/${octave.octPkgsPath} $out/${octave.octPkgsPath}; \ | ||
pfx = pkg (\"prefix\"); \ | ||
pkg install -nodeps -local $path/*.tar.gz" | ||
fi | ||
done | ||
# Re-write the octave-wide startup file (share/octave/site/m/startup/octaverc) | ||
# To point to the new local_list in $out | ||
addPkgLocalList $out ${octave} | ||
wrapOctavePrograms "${stdenv.lib.concatStringsSep " " packages}" | ||
'' + postBuild; | ||
|
||
inherit (octave) meta; | ||
|
||
passthru = octave.passthru // { | ||
interpreter = "$out/bin/octave"; | ||
inherit octave; | ||
env = stdenv.mkDerivation { | ||
name = "interactive-${octave.name}-environment"; | ||
|
||
buildCommand = '' | ||
echo >&2 "" | ||
echo >&2 "*** octave 'env' attributes are intended for interactive nix-shell sessions, not for building! ***" | ||
echo >&2 "" | ||
exit 1 | ||
''; | ||
}; | ||
}; | ||
} |
113 changes: 113 additions & 0 deletions
113
pkgs/development/interpreters/octave/build-octave-package.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# Generic builder for GNU Octave libraries. | ||
# This is a file that contains nested functions. The first, outer, function | ||
# is the library- and package-wide details, such as the nixpkgs library, any | ||
# additional configuration provided, and the namePrefix to use (based on the | ||
# pname and version of Octave), the octave package, etc. | ||
|
||
{ lib | ||
, stdenv | ||
, config | ||
, octave | ||
, texinfo | ||
, computeRequiredOctavePackages | ||
, writeRequiredOctavePackagesHook | ||
}: | ||
|
||
# The inner function contains information required to build the individual | ||
# libraries. | ||
{ fullLibName ? "${attrs.pname}-${attrs.version}" | ||
|
||
, src | ||
|
||
, dontPatch ? false | ||
, patches ? [] | ||
, patchPhase ? "" | ||
|
||
, enableParallelBuilding ? true | ||
# Build-time dependencies for the package, which were compiled for the system compiling this. | ||
, nativeBuildInputs ? [] | ||
|
||
# Build-time dependencies for the package, which may not have been compiled for the system compiling this. | ||
, buildInputs ? [] | ||
|
||
# Propagate build dependencies so in case we have A -> B -> C, | ||
# C can import package A propagated by B | ||
# Run-time dependencies for the package. | ||
, propagatedBuildInputs ? [] | ||
|
||
# Octave packages that are required at runtime for this one. | ||
# These behave similarly to propagatedBuildInputs, where if | ||
# package A is needed by B, and C needs B, then C also requires A. | ||
# The main difference between these and propagatedBuildInputs is | ||
# during the package's installation into octave, where all | ||
# requiredOctavePackages are ALSO installed into octave. | ||
, requiredOctavePackages ? [] | ||
|
||
, preBuild ? "" | ||
|
||
, meta ? {} | ||
|
||
, passthru ? {} | ||
|
||
, ... } @ attrs: | ||
|
||
let | ||
requiredOctavePackages' = computeRequiredOctavePackages requiredOctavePackages; | ||
|
||
in stdenv.mkDerivation { | ||
packageName = "${fullLibName}"; | ||
# The name of the octave package ends up being | ||
# "octave-version-package-version" | ||
name = "${octave.pname}-${octave.version}-${fullLibName}"; | ||
|
||
# This states that any package built with the function that this returns | ||
# will be an octave package. This is used for ensuring other octave | ||
# packages are installed into octave during the environment building phase. | ||
isOctavePackage = true; | ||
|
||
OCTAVE_HISTFILE = "/dev/null"; | ||
|
||
inherit src; | ||
|
||
inherit dontPatch patches patchPhase; | ||
|
||
dontConfigure = true; | ||
|
||
enableParallelBuilding = enableParallelBuilding; | ||
|
||
requiredOctavePackages = requiredOctavePackages'; | ||
|
||
nativeBuildInputs = [ | ||
octave | ||
writeRequiredOctavePackagesHook | ||
] | ||
++ nativeBuildInputs; | ||
|
||
buildInputs = buildInputs ++ requiredOctavePackages'; | ||
|
||
propagatedBuildInputs = propagatedBuildInputs ++ [ texinfo ]; | ||
|
||
preBuild = if preBuild == "" then | ||
'' | ||
# This trickery is needed because Octave expects a single directory inside | ||
# at the top-most level of the tarball. | ||
tar --transform 's,^,${fullLibName}/,' -cz * -f ${fullLibName}.tar.gz | ||
'' | ||
else | ||
preBuild; | ||
|
||
buildPhase = '' | ||
runHook preBuild | ||
mkdir -p $out | ||
octave-cli --eval "pkg build $out ${fullLibName}.tar.gz" | ||
runHook postBuild | ||
''; | ||
|
||
# We don't install here, because that's handled when we build the environment | ||
# together with Octave. | ||
dontInstall = true; | ||
|
||
inherit meta; | ||
} |
Oops, something went wrong.