1 # Generic builder for GNU Octave libraries.
2 # This is a file that contains nested functions. The first, outer, function
3 # is the library- and package-wide details, such as the nixpkgs library, any
4 # additional configuration provided, and the namePrefix to use (based on the
5 # pname and version of Octave), the octave package, etc.
12 , computeRequiredOctavePackages
13 , writeRequiredOctavePackagesHook
16 # The inner function contains information required to build the individual
18 { fullLibName ? "${attrs.pname}-${attrs.version}"
26 , enableParallelBuilding ? true
27 # Build-time dependencies for the package, which were compiled for the system compiling this.
28 , nativeBuildInputs ? []
30 # Build-time dependencies for the package, which may not have been compiled for the system compiling this.
33 # Propagate build dependencies so in case we have A -> B -> C,
34 # C can import package A propagated by B
35 # Run-time dependencies for the package.
36 , propagatedBuildInputs ? []
38 # Octave packages that are required at runtime for this one.
39 # These behave similarly to propagatedBuildInputs, where if
40 # package A is needed by B, and C needs B, then C also requires A.
41 # The main difference between these and propagatedBuildInputs is
42 # during the package's installation into octave, where all
43 # requiredOctavePackages are ALSO installed into octave.
44 , requiredOctavePackages ? []
55 requiredOctavePackages' = computeRequiredOctavePackages requiredOctavePackages;
57 # Must use attrs.nativeBuildInputs before they are removed by the removeAttrs
58 # below, or everything fails.
59 nativeBuildInputs' = [
61 writeRequiredOctavePackagesHook
67 ../../../../maintainers/scripts/update-octave-packages
68 (builtins.unsafeGetAttrPos "pname" octave.pkgs.${attrs.pname}).file
73 # This step is required because when
74 # a = { test = [ "a" "b" ]; }; b = { test = [ "c" "d" ]; };
75 # (a // b).test = [ "c" "d" ];
76 # This used to mean that if a package defined extra nativeBuildInputs, it
77 # would override the ones for building an Octave package (the hook and Octave
78 # itself, causing everything to fail.
79 attrs' = builtins.removeAttrs attrs [ "nativeBuildInputs" "passthru" ];
81 in stdenv.mkDerivation ({
82 packageName = "${fullLibName}";
83 # The name of the octave package ends up being
84 # "octave-version-package-version"
85 name = "${octave.pname}-${octave.version}-${fullLibName}";
87 # This states that any package built with the function that this returns
88 # will be an octave package. This is used for ensuring other octave
89 # packages are installed into octave during the environment building phase.
90 isOctavePackage = true;
92 OCTAVE_HISTFILE = "/dev/null";
96 inherit dontPatch patches patchPhase;
100 enableParallelBuilding = enableParallelBuilding;
102 requiredOctavePackages = requiredOctavePackages';
104 nativeBuildInputs = nativeBuildInputs';
106 buildInputs = buildInputs ++ requiredOctavePackages';
108 propagatedBuildInputs = propagatedBuildInputs ++ [ texinfo ];
110 preBuild = if preBuild == "" then
112 # This trickery is needed because Octave expects a single directory inside
113 # at the top-most level of the tarball.
114 tar --transform 's,^,${fullLibName}/,' -cz * -f ${fullLibName}.tar.gz
123 octave-cli --eval "pkg build $out ${fullLibName}.tar.gz"
128 # We don't install here, because that's handled when we build the environment
129 # together with Octave.
132 passthru = passthru';