Merge pull request #119126 from fabaff/pycomfoconnect
[NixPkgs.git] / pkgs / development / interpreters / octave / build-octave-package.nix
blob73a67769d6a6e1110b1e7a3d55cfbe85f76ace14
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.
7 { lib
8 , stdenv
9 , config
10 , octave
11 , texinfo
12 , computeRequiredOctavePackages
13 , writeRequiredOctavePackagesHook
16 # The inner function contains information required to build the individual
17 # libraries.
18 { fullLibName ? "${attrs.pname}-${attrs.version}"
20 , src
22 , dontPatch ? false
23 , patches ? []
24 , patchPhase ? ""
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.
31 , buildInputs ? []
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 ? []
46 , preBuild ? ""
48 , meta ? {}
50 , passthru ? {}
52 , ... } @ attrs:
54 let
55   requiredOctavePackages' = computeRequiredOctavePackages requiredOctavePackages;
57 in stdenv.mkDerivation {
58   packageName = "${fullLibName}";
59   # The name of the octave package ends up being
60   # "octave-version-package-version"
61   name = "${octave.pname}-${octave.version}-${fullLibName}";
63   # This states that any package built with the function that this returns
64   # will be an octave package. This is used for ensuring other octave
65   # packages are installed into octave during the environment building phase.
66   isOctavePackage = true;
68   OCTAVE_HISTFILE = "/dev/null";
70   inherit src;
72   inherit dontPatch patches patchPhase;
74   dontConfigure = true;
76   enableParallelBuilding = enableParallelBuilding;
78   requiredOctavePackages = requiredOctavePackages';
80   nativeBuildInputs = [
81     octave
82     writeRequiredOctavePackagesHook
83   ]
84   ++ nativeBuildInputs;
86   buildInputs = buildInputs ++ requiredOctavePackages';
88   propagatedBuildInputs = propagatedBuildInputs ++ [ texinfo ];
90   preBuild = if preBuild == "" then
91     ''
92       # This trickery is needed because Octave expects a single directory inside
93       # at the top-most level of the tarball.
94       tar --transform 's,^,${fullLibName}/,' -cz * -f ${fullLibName}.tar.gz
95     ''
96              else
97                preBuild;
99   buildPhase = ''
100     runHook preBuild
102     mkdir -p $out
103     octave-cli --eval "pkg build $out ${fullLibName}.tar.gz"
105     runHook postBuild
106   '';
108   # We don't install here, because that's handled when we build the environment
109   # together with Octave.
110   dontInstall = true;
112   inherit meta;