push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,111 @@
{
lib,
stdenv,
octave,
buildEnv,
makeWrapper,
locale,
texinfo,
glibcLocalesUtf8,
wrapOctave,
computeRequiredOctavePackages,
extraLibs ? [ ],
extraOutputsToInstall ? [ ],
postBuild ? "",
ignoreCollisions ? false,
}:
# Create an octave executable that knows about additional packages
let
packages = computeRequiredOctavePackages extraLibs;
# glibcLocalesUtf8 is null on darwin
localeArchiveArgs = lib.optionalString (glibcLocalesUtf8 != null) ''
--set LOCALE_ARCHIVE "${glibcLocalesUtf8}/lib/locale/locale-archive"
'';
in
buildEnv {
name = "${octave.name}-env";
paths = extraLibs ++ [ octave ];
inherit ignoreCollisions;
extraOutputsToInstall = [ "out" ] ++ extraOutputsToInstall;
nativeBuildInputs = [ makeWrapper ];
buildInputs = [
locale
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 = ''
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" \
${localeArchiveArgs}
fi
done
cd $out
fi
# Remove symlinks to the input tarballs, they aren't needed, use -f so it
# will not fail if no .tar.gz symlinks are there - for example if
# sommething which is not a tarball used as a package
rm -f $out/*.tar.gz
createOctavePackagesPath $out ${octave}
# Create the file even if the loop afterwards has no packages to run over
touch $out/.octave_packages
for path in ${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 "${lib.concatStringsSep " " packages}"
# We also need to modify the Exec= line of the desktop file, so it will point
# to the wrapper we generated above.
rm $out/share/applications # should be a symlink to ${octave}/share/applications
mkdir $out/share/applications
substitute \
${octave}/share/applications/org.octave.Octave.desktop \
$out/share/applications/org.octave.Octave.desktop \
--replace-fail ${octave}/bin/octave $out/bin/octave
''
+ postBuild;
inherit (octave) meta version;
passthru = (removeAttrs octave.passthru [ "tests" ]) // {
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
'';
};
};
}

View File

@@ -0,0 +1,154 @@
# 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,
callPackage,
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;
# Must use attrs.nativeBuildInputs before they are removed by the removeAttrs
# below, or everything fails.
nativeBuildInputs' = [
octave
writeRequiredOctavePackagesHook
]
++ nativeBuildInputs;
# This step is required because when
# a = { test = [ "a" "b" ]; }; b = { test = [ "c" "d" ]; };
# (a // b).test = [ "c" "d" ];
# This used to mean that if a package defined extra nativeBuildInputs, it
# would override the ones for building an Octave package (the hook and Octave
# itself, causing everything to fail.
attrs' = removeAttrs attrs [
"nativeBuildInputs"
"passthru"
];
in
stdenv.mkDerivation (
finalAttrs:
{
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 = 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;
passthru = {
updateScript = [
../../../../maintainers/scripts/update-octave-packages
(builtins.unsafeGetAttrPos "pname" octave.pkgs.${attrs.pname}).file
];
}
// passthru
// {
tests = {
testOctaveBuildEnv = (octave.withPackages (os: [ finalAttrs.finalPackage ])).overrideAttrs (old: {
name = "${finalAttrs.name}-pkg-install";
});
testOctavePkgTests = callPackage ./run-pkg-test.nix { } finalAttrs.finalPackage;
}
// passthru.tests or { };
};
inherit meta;
}
// attrs'
)

View File

@@ -0,0 +1,247 @@
{
stdenv,
pkgs,
lib,
fetchurl,
gfortran,
ncurses,
perl,
flex,
testers,
texinfo,
qhull,
libsndfile,
portaudio,
libX11,
graphicsmagick,
pcre2,
pkg-config,
libGL,
libGLU,
fltk,
# Both are needed for discrete Fourier transform
fftw,
fftwSinglePrec,
zlib,
curl,
rapidjson,
blas,
lapack,
# These 3 should use the same lapack and blas as the above, see code prepending
qrupdate,
arpack,
suitesparse,
# If set to true, the above 5 deps are overridden to use the blas and lapack
# with 64 bit indexes support. If all are not compatible, the build will fail.
use64BitIdx ? false,
libwebp,
gl2ps,
ghostscript,
hdf5,
glpk,
gnuplot,
# - Include support for GNU readline:
enableReadline ? true,
readline,
# - Build Java interface:
enableJava ? true,
jdk,
python3,
sundials,
# - Packages required for building extra packages.
newScope,
callPackage,
makeSetupHook,
makeWrapper,
# - Build Octave Qt GUI:
enableQt ? false,
libsForQt5,
libiconv,
}:
let
# Not always evaluated
blas' =
if use64BitIdx then
blas.override {
isILP64 = true;
}
else
blas;
lapack' =
if use64BitIdx then
lapack.override {
isILP64 = true;
}
else
lapack;
qrupdate' = qrupdate.override {
# If use64BitIdx is false, this override doesn't evaluate to a new
# derivation, as blas and lapack are not overridden.
blas = blas';
lapack = lapack';
};
arpack' = arpack.override {
blas = blas';
lapack = lapack';
};
# We keep the option to not enable suitesparse support by putting it null
suitesparse' =
if suitesparse != null then
suitesparse.override {
blas = blas';
lapack = lapack';
}
else
null;
# To avoid confusion later in passthru
allPkgs = pkgs;
in
stdenv.mkDerivation (finalAttrs: {
version = "10.3.0";
pname = "octave";
src = fetchurl {
url = "mirror://gnu/octave/octave-${finalAttrs.version}.tar.gz";
sha256 = "sha256-L8s43AYuRA8eBsBpu8qEDtRtzI+YPkc+FVj8w4OE7ms=";
};
postPatch = ''
patchShebangs --build build-aux/*.pl
'';
buildInputs = [
readline
ncurses
flex
qhull
graphicsmagick
pcre2
fltk
zlib
curl
rapidjson
blas'
lapack'
libsndfile
fftw
fftwSinglePrec
portaudio
qrupdate'
arpack'
libwebp
gl2ps
ghostscript
hdf5
glpk
suitesparse'
sundials
gnuplot
python3
]
++ lib.optionals enableQt [
libsForQt5.qtbase
libsForQt5.qtsvg
libsForQt5.qscintilla
]
++ lib.optionals enableJava [
jdk
]
++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
libGL
libGLU
libX11
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
libiconv
];
nativeBuildInputs = [
perl
pkg-config
gfortran
texinfo
]
++ lib.optionals enableQt [
libsForQt5.wrapQtAppsHook
libsForQt5.qtscript
libsForQt5.qttools
];
doCheck = !stdenv.hostPlatform.isDarwin;
enableParallelBuilding = true;
# Fix linker error on Darwin (see https://trac.macports.org/ticket/61865)
NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin "-lobjc";
# See https://savannah.gnu.org/bugs/?50339
F77_INTEGER_8_FLAG = lib.optionalString use64BitIdx "-fdefault-integer-8";
configureFlags = [
"--with-blas=blas"
"--with-lapack=lapack"
(if use64BitIdx then "--enable-64" else "--disable-64")
]
++ lib.optionals enableReadline [ "--enable-readline" ]
++ lib.optionals stdenv.hostPlatform.isDarwin [ "--with-x=no" ]
++ lib.optionals enableQt [ "--with-qt=5" ];
# Keep a copy of the octave tests detailed results in the output
# derivation, because someone may care
postInstall = ''
cp test/fntests.log $out/share/octave/octave-${finalAttrs.version}-fntests.log || true
'';
passthru = rec {
sitePath = "share/octave/${finalAttrs.version}/site";
octPkgsPath = "share/octave/octave_packages";
blas = blas';
lapack = lapack';
qrupdate = qrupdate';
arpack = arpack';
suitesparse = suitesparse';
octavePackages = import ../../../top-level/octave-packages.nix {
pkgs = allPkgs;
inherit
lib
stdenv
fetchurl
newScope
;
octave = finalAttrs.finalPackage;
};
wrapOctave = callPackage ./wrap-octave.nix {
octave = finalAttrs.finalPackage;
inherit (allPkgs) makeSetupHook makeWrapper;
};
inherit fftw fftwSinglePrec;
inherit portaudio;
inherit jdk;
python = python3;
inherit enableQt enableReadline enableJava;
buildEnv = callPackage ./build-env.nix {
octave = finalAttrs.finalPackage;
inherit wrapOctave;
inherit (octavePackages) computeRequiredOctavePackages;
};
withPackages = import ./with-packages.nix { inherit buildEnv octavePackages; };
pkgs = octavePackages;
interpreter = "${finalAttrs.finalPackage}/bin/octave";
tests = {
wrapper = testers.testVersion {
package = finalAttrs.finalPackage.withPackages (ps: [ ps.doctest ]);
command = "octave --version";
};
};
};
meta = {
homepage = "https://www.gnu.org/software/octave/";
license = lib.licenses.gpl3Plus;
maintainers = with lib.maintainers; [
raskin
doronbehar
];
description = "Scientific Programming Language";
};
})

View File

@@ -0,0 +1,10 @@
# Hooks for building Octave packages.
{
makeSetupHook,
}:
{
writeRequiredOctavePackagesHook = makeSetupHook {
name = "write-required-octave-packages-hook";
} ./write-required-octave-packages-hook.sh;
}

View File

@@ -0,0 +1,17 @@
# Setup hook for writing octave packages that are run-time dependencies for
# another package to a nix-support file.
# `echo`s the full path name to the package derivation that is required.
echo "Sourcing write-required-octave-packages-hook.sh"
writeRequiredOctavePackagesPhase() {
echo "Executing writeRequiredOctavePackagesPhase"
mkdir -p $out/nix-support
echo ${requiredOctavePackages} > $out/nix-support/required-octave-packages
}
# Yes its a bit long...
if [ -z "${dontWriteRequiredOctavePackagesPhase-}" ]; then
echo "Using writeRequiredOctavePackagesPhase"
appendToVar preDistPhases writeRequiredOctavePackagesPhase
fi

View File

@@ -0,0 +1,25 @@
{
octave,
runCommand,
}:
package:
runCommand "${package.name}-pkg-test"
{
nativeBuildInputs = [
(octave.withPackages (os: [ package ]))
];
}
''
{ octave-cli --eval 'pkg test ${package.pname}' || touch FAILED_ERRCODE; } \
|& tee >( grep --quiet '^Failure Summary:$' && touch FAILED_OUTPUT || : ; cat >/dev/null )
if [[ -f FAILED_ERRCODE ]]; then
echo >&2 "octave-cli returned with non-zero exit code."
false
elif [[ -f FAILED_OUTPUT ]]; then
echo >&2 "Test failures detected in output."
false
else
touch $out
fi
''

View File

@@ -0,0 +1,10 @@
{ buildEnv, octavePackages }:
# Takes the buildEnv defined for Octave and the set of octavePackages, and returns
# a function, which when given a function whose return value is a list of extra
# packages to install, builds and returns that environment.
f:
let
packages = f octavePackages;
in
buildEnv.override { extraLibs = packages; }

View File

@@ -0,0 +1,16 @@
{
octave,
makeSetupHook,
makeWrapper,
}:
# Defined in trivial-builders
# Imported as wrapOctave in octave/default.nix and passed to octave's buildEnv
# as nativeBuildInput
# Each of the substitutions is available in the wrap.sh script as @thingSubstituted@
makeSetupHook {
name = "${octave.name}-pkgs-setup-hook";
propagatedBuildInputs = [ makeWrapper ];
substitutions.executable = octave.interpreter;
substitutions.octave = octave;
} ./wrap.sh

View File

@@ -0,0 +1,132 @@
# Unlinks a directory (given as the first argument), and re-creates that
# directory as an actual directory. Then descends into the directory of
# the same name in the origin (arg_2/arg_3) and symlinks the contents of
# that directory into the passed end-location.
unlinkDirReSymlinkContents() {
local dirToUnlink="$1"
local origin="$2"
local contentsLocation="$3"
unlink $dirToUnlink/$contentsLocation
mkdir -p $dirToUnlink/$contentsLocation
for f in $origin/$contentsLocation/*; do
ln -s -t "$dirToUnlink/$contentsLocation" "$f"
done
}
# Using unlinkDirReSymlinkContents, un-symlinks directories down to
# $out/share/octave, and then creates the octave_packages directory.
createOctavePackagesPath() {
local desiredOut=$1
local origin=$2
if [ -L "$out/share" ]; then
unlinkDirReSymlinkContents "$desiredOut" "$origin" "share"
fi
if [ -L "$out/share/octave" ]; then
unlinkDirReSymlinkContents "$desiredOut" "$origin" "share/octave"
fi
# Now that octave_packages has a path rather than symlinks, create the
# octave_packages directory for installed packages.
mkdir -p "$desiredOut/share/octave/octave_packages"
}
# First, descends down to $out/share/octave/site/m/startup/octaverc, and
# copies that start-up file. Once done, it performs a `chmod` to allow
# writing. Lastly, it `echo`s the location of the locally installed packages
# to the startup file, allowing octave to discover installed packages.
addPkgLocalList() {
local desiredOut=$1
local origin=$2
local octaveSite="share/octave/site"
local octaveSiteM="$octaveSite/m"
local octaveSiteStartup="$octaveSiteM/startup"
local siteOctavercStartup="$octaveSiteStartup/octaverc"
unlinkDirReSymlinkContents "$desiredOut" "$origin" "$octaveSite"
unlinkDirReSymlinkContents "$desiredOut" "$origin" "$octaveSiteM"
unlinkDirReSymlinkContents "$desiredOut" "$origin" "$octaveSiteStartup"
unlink "$out/$siteOctavercStartup"
cp "$origin/$siteOctavercStartup" "$desiredOut/$siteOctavercStartup"
chmod u+w "$desiredOut/$siteOctavercStartup"
echo "pkg local_list $out/.octave_packages" >> "$desiredOut/$siteOctavercStartup"
}
# Wrapper function for wrapOctaveProgramsIn. Takes one argument, a
# space-delimited string of packages' paths that will be installed.
wrapOctavePrograms() {
wrapOctaveProgramsIn "$out/bin" "$out" "$@"
}
# Wraps all octave programs in $out/bin with all the propagated inputs that
# a particular package requires. $1 is the directory to look for binaries in
# to wrap. $2 is the path to the octave ENVIRONMENT. $3 is the space-delimited
# string of packages.
wrapOctaveProgramsIn() {
local dir="$1"
local octavePath="$2"
local pkgs="$3"
local f
buildOctavePath "$octavePath" "$pkgs"
# Find all regular files in the output directory that are executable.
if [ -d "$dir" ]; then
find "$dir" -type f -perm -0100 -print0 | while read -d "" f; do
echo "wrapping \`$f'..."
local -a wrap_args=("$f"
--prefix PATH ':' "$program_PATH"
)
local -a wrapProgramArgs=("${wrap_args[@]}")
wrapProgram "${wrapProgramArgs[@]}"
done
fi
}
# Build the PATH environment variable by walking through the closure of
# dependencies. Starts by constructing the `program_PATH` variable with the
# environment's path, then adding the original octave's location, and marking
# them in `octavePathsSeen`.
buildOctavePath() {
local octavePath="$1"
local packages="$2"
local pathsToSearch="$octavePath $packages"
# Create an empty table of Octave paths.
declare -A octavePathsSeen=()
program_PATH=
octavePathsSeen["$out"]=1
octavePathsSeen["@octave@"]=1
addToSearchPath program_PATH "$out/bin"
addToSearchPath program_PATH "@octave@/bin"
echo "program_PATH to change to is: $program_PATH"
for path in $pathsToSearch; do
echo "Recurse to propagated-build-input: $path"
_addToOctavePath $path
done
}
# Adds the bin directories to the program_PATH variable.
# Recurses on any paths declared in `propagated-build-inputs`, while avoiding
# duplicating paths by flagging the directires it has seen in `octavePathsSeen`.
_addToOctavePath() {
local dir="$1"
# Stop if we've already visited this path.
if [ -n "${octavePathsSeen[$dir]}" ]; then return; fi
octavePathsSeen[$dir]=1
# addToSearchPath is defined in stdenv/generic/setup.sh. It has the effect
# of calling `export X=$dir/...:$X`.
addToSearchPath program_PATH $dir/bin
# Inspect the propagated inputs (if they exist) and recur on them.
local prop="$dir/nix-support/propagated-build-inputs"
if [ -e $prop ]; then
for new_path in $(cat $prop); do
_addToOctavePath $new_path
done
fi
}