diff --git a/pkgs/development/interpreters/octave/build-octave-package.nix b/pkgs/development/interpreters/octave/build-octave-package.nix index 43760c6c511e..a040eb49b206 100644 --- a/pkgs/development/interpreters/octave/build-octave-package.nix +++ b/pkgs/development/interpreters/octave/build-octave-package.nix @@ -64,12 +64,19 @@ let writeRequiredOctavePackagesHook ] ++ nativeBuildInputs; - passthru' = { - updateScript = [ - ../../../../maintainers/scripts/update-octave-packages - (builtins.unsafeGetAttrPos "pname" octave.pkgs.${attrs.pname}).file - ]; - } // passthru; + passthru' = + { + updateScript = [ + ../../../../maintainers/scripts/update-octave-packages + (builtins.unsafeGetAttrPos "pname" octave.pkgs.${attrs.pname}).file + ]; + } + // passthru + // { + tests = { + testOctaveBuildEnv = octave.withPackages (ps: [ self ]); + } // passthru.tests or { }; + }; # This step is required because when # a = { test = [ "a" "b" ]; }; b = { test = [ "c" "d" ]; }; @@ -82,63 +89,64 @@ let "passthru" ]; + self = 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 = 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 = passthru'; + + inherit meta; + } + // attrs' + ); 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 = 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 = passthru'; - - inherit meta; - } - // attrs' -) +self