diff --git a/pkgs/applications/office/libreoffice/README.md b/pkgs/applications/office/libreoffice/README.md deleted file mode 100644 index ffad72092805..000000000000 --- a/pkgs/applications/office/libreoffice/README.md +++ /dev/null @@ -1,19 +0,0 @@ -LibreOffice -=========== - -Here are instructions how to update libreoffice. In the below commands and -instructions, $VARIANT is either `still` or `fresh`. - -1. Update the necessary version parts in `src-$VARIANT/primary.nix`. -2. Run the following command: - -```bash -nix-shell gen-shell.nix --argstr variant VARIANT --run generate -``` - -3. It will fail initially, due to hash mismatch in the main `src` attribute. - Fix the hash according to the failure. -4. Run the command from step 2 again, now it will take a while. -5. Zero-out the hashes of the translations and help attributes in - `src-$VARIANT/primary.nix`. -6. Update the hashes above by building `libreoffice-$VARIANT`. diff --git a/pkgs/applications/office/libreoffice/default.nix b/pkgs/applications/office/libreoffice/default.nix index e397136b02e1..497cdea9ef43 100644 --- a/pkgs/applications/office/libreoffice/default.nix +++ b/pkgs/applications/office/libreoffice/default.nix @@ -145,29 +145,33 @@ let }; importVariant = f: import (./. + "/src-${variant}/${f}"); - - primary-src = importVariant "primary.nix" { inherit fetchurl; }; - - inherit (primary-src) major minor version; - - langsSpaces = concatStringsSep " " langs; - + # Update these files with: + # nix-shell maintainers/scripts/update.nix --argstr package libreoffice-$VARIANT.unwrapped + version = importVariant "version.nix"; + srcsAttributes = { + main = importVariant "main.nix"; + help = importVariant "help.nix"; + translations = importVariant "translations.nix"; + deps = (importVariant "deps.nix") ++ [ + # TODO: Why is this needed? + (rec { + name = "unowinreg.dll"; + url = "https://dev-www.libreoffice.org/extern/${md5name}"; + sha256 = "1infwvv1p6i21scywrldsxs22f62x85mns4iq8h6vr6vlx3fdzga"; + md5 = "185d60944ea767075d27247c3162b3bc"; + md5name = "${md5}-${name}"; + }) + ]; + }; srcs = { - primary = primary-src; - third_party = - map (x: ((fetchurl { inherit (x) url sha256 name; }) // { inherit (x) md5name md5; })) - (importVariant "download.nix" ++ [ - (rec { - name = "unowinreg.dll"; - url = "https://dev-www.libreoffice.org/extern/${md5name}"; - sha256 = "1infwvv1p6i21scywrldsxs22f62x85mns4iq8h6vr6vlx3fdzga"; - md5 = "185d60944ea767075d27247c3162b3bc"; - md5name = "${md5}-${name}"; - }) - ]); - - translations = primary-src.translations; - help = primary-src.help; + third_party = map (x: + (fetchurl { + inherit (x) url sha256 name; + }) // { + inherit (x) md5name md5; + }) srcsAttributes.deps; + translations = fetchurl srcsAttributes.translations; + help = fetchurl srcsAttributes.help; }; # See `postPatch` for details @@ -188,8 +192,7 @@ let in stdenv.mkDerivation (finalAttrs: { pname = "libreoffice"; inherit version; - - inherit (primary-src) src; + src = fetchurl srcsAttributes.main; env.NIX_CFLAGS_COMPILE = toString ([ "-I${librdf_rasqal}/include/rasqal" # librdf_redland refers to rasqal.h instead of rasqal/rasqal.h @@ -276,7 +279,7 @@ in stdenv.mkDerivation (finalAttrs: { preConfigure = '' configureFlagsArray=( "--with-parallelism=$NIX_BUILD_CORES" - "--with-lang=${langsSpaces}" + "--with-lang=${concatStringsSep " " langs}" ); chmod a+x ./bin/unpack-sources @@ -609,6 +612,13 @@ in stdenv.mkDerivation (finalAttrs: { passthru = { inherit srcs; jdk = jre'; + updateScript = [ + ./update.sh + # Pass it this file name as argument + (builtins.unsafeGetAttrPos "pname" finalAttrs.finalPackage).file + # And the variant + variant + ]; inherit kdeIntegration; # For the wrapper.nix inherit gtk3; diff --git a/pkgs/applications/office/libreoffice/download-list-builder.sh b/pkgs/applications/office/libreoffice/download-list-builder.sh deleted file mode 100644 index 31cab28fd82e..000000000000 --- a/pkgs/applications/office/libreoffice/download-list-builder.sh +++ /dev/null @@ -1,4 +0,0 @@ -if [ -e .attrs.sh ]; then source .attrs.sh; fi -source $stdenv/setup - -tar --extract --file=$src libreoffice-$version/download.lst -O > $out diff --git a/pkgs/applications/office/libreoffice/gen-shell.nix b/pkgs/applications/office/libreoffice/gen-shell.nix deleted file mode 100644 index 7429bb0cb382..000000000000 --- a/pkgs/applications/office/libreoffice/gen-shell.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ pkgs ? (import {}), variant }: - -with pkgs; - -let - - primary-src = callPackage (./. + "/src-${variant}/primary.nix") {}; - -in - -stdenv.mkDerivation { - name = "generate-libreoffice-srcs-shell"; - - buildCommand = "exit 1"; - - downloadList = stdenv.mkDerivation { - name = "libreoffice-${primary-src.version}-download-list"; - inherit (primary-src) src version; - builder = ./download-list-builder.sh; - }; - - buildInputs = [ python3 ]; - - shellHook = '' - function generate { - python3 generate-libreoffice-srcs.py ${variant} > src-${variant}/download.nix - } - ''; -} diff --git a/pkgs/applications/office/libreoffice/src-fresh/download.nix b/pkgs/applications/office/libreoffice/src-fresh/deps.nix similarity index 100% rename from pkgs/applications/office/libreoffice/src-fresh/download.nix rename to pkgs/applications/office/libreoffice/src-fresh/deps.nix diff --git a/pkgs/applications/office/libreoffice/src-fresh/help.nix b/pkgs/applications/office/libreoffice/src-fresh/help.nix new file mode 100644 index 000000000000..b1e726bfd696 --- /dev/null +++ b/pkgs/applications/office/libreoffice/src-fresh/help.nix @@ -0,0 +1,4 @@ +{ + sha256 = "sha256-qQ+THdMjjrZOb2WWTqj5DlrM2a0Qkl1aYMevaqWFwfE="; + url = "https://download.documentfoundation.org/libreoffice/src/7.5.4/libreoffice-help-7.5.4.2.tar.xz"; +} diff --git a/pkgs/applications/office/libreoffice/src-fresh/main.nix b/pkgs/applications/office/libreoffice/src-fresh/main.nix new file mode 100644 index 000000000000..9bc26459f3ef --- /dev/null +++ b/pkgs/applications/office/libreoffice/src-fresh/main.nix @@ -0,0 +1,4 @@ +{ + sha256 = "sha256-dWE7yXldkiEnsJOxfxyZ9p05eARqexgRRgNV158VVF4="; + url = "https://download.documentfoundation.org/libreoffice/src/7.5.4/libreoffice-7.5.4.2.tar.xz"; +} diff --git a/pkgs/applications/office/libreoffice/src-fresh/primary.nix b/pkgs/applications/office/libreoffice/src-fresh/primary.nix deleted file mode 100644 index e9dc428749bb..000000000000 --- a/pkgs/applications/office/libreoffice/src-fresh/primary.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ fetchurl }: - -rec { - fetchSrc = {name, hash}: fetchurl { - url = "https://download.documentfoundation.org/libreoffice/src/${subdir}/libreoffice-${name}-${version}.tar.xz"; - sha256 = hash; - }; - - major = "7"; - minor = "5"; - patch = "4"; - tweak = "1"; - - subdir = "${major}.${minor}.${patch}"; - - version = "${subdir}${if tweak == "" then "" else "."}${tweak}"; - - src = fetchurl { - url = "https://download.documentfoundation.org/libreoffice/src/${subdir}/libreoffice-${version}.tar.xz"; - hash = "sha256-dWE7yXldkiEnsJOxfxyZ9p05eARqexgRRgNV158VVF4="; - }; - - # FIXME rename - translations = fetchSrc { - name = "translations"; - hash = "sha256-dv3L8DtdxZcwmeXnqtTtwIpOvwZg3aH3VvJBiiZzbh0="; - }; - - # the "dictionaries" archive is not used for LO build because we already build hunspellDicts packages from - # it and LibreOffice can use these by pointing DICPATH environment variable at the hunspell directory - - help = fetchSrc { - name = "help"; - hash = "sha256-2CrGEyK5AQEAo1Qz1ACmvMH7BaOubW5BNLWv3fDEdOY="; - }; -} diff --git a/pkgs/applications/office/libreoffice/src-fresh/translations.nix b/pkgs/applications/office/libreoffice/src-fresh/translations.nix new file mode 100644 index 000000000000..2a1f52baa6a0 --- /dev/null +++ b/pkgs/applications/office/libreoffice/src-fresh/translations.nix @@ -0,0 +1,4 @@ +{ + sha256 = "sha256-frJkws1m8CiDFTW+wNP837aH+uTet30gDP5ANMo6EK0="; + url = "https://download.documentfoundation.org/libreoffice/src/7.5.4/libreoffice-translations-7.5.4.2.tar.xz"; +} diff --git a/pkgs/applications/office/libreoffice/src-fresh/version.nix b/pkgs/applications/office/libreoffice/src-fresh/version.nix new file mode 100644 index 000000000000..b6114fc26cdb --- /dev/null +++ b/pkgs/applications/office/libreoffice/src-fresh/version.nix @@ -0,0 +1 @@ +"7.5.4.2" diff --git a/pkgs/applications/office/libreoffice/src-still/download.nix b/pkgs/applications/office/libreoffice/src-still/deps.nix similarity index 100% rename from pkgs/applications/office/libreoffice/src-still/download.nix rename to pkgs/applications/office/libreoffice/src-still/deps.nix diff --git a/pkgs/applications/office/libreoffice/src-still/help.nix b/pkgs/applications/office/libreoffice/src-still/help.nix new file mode 100644 index 000000000000..90d69dc99e20 --- /dev/null +++ b/pkgs/applications/office/libreoffice/src-still/help.nix @@ -0,0 +1,4 @@ +{ + sha256 = "sha256-vcQWE3mBZx2sBQ9KzTh6zM7277mK9twfvyESTzTiII8="; + url = "https://download.documentfoundation.org/libreoffice/src/7.4.7/libreoffice-help-7.4.7.2.tar.xz"; +} diff --git a/pkgs/applications/office/libreoffice/src-still/main.nix b/pkgs/applications/office/libreoffice/src-still/main.nix new file mode 100644 index 000000000000..7a1947b77d23 --- /dev/null +++ b/pkgs/applications/office/libreoffice/src-still/main.nix @@ -0,0 +1,4 @@ +{ + sha256 = "sha256-dD2R8qE4png4D6eo7LWyQB2ZSwZ7MwdQ8DrY9SOi+yA="; + url = "https://download.documentfoundation.org/libreoffice/src/7.4.7/libreoffice-7.4.7.2.tar.xz"; +} diff --git a/pkgs/applications/office/libreoffice/src-still/primary.nix b/pkgs/applications/office/libreoffice/src-still/primary.nix deleted file mode 100644 index e0cbdc5da9af..000000000000 --- a/pkgs/applications/office/libreoffice/src-still/primary.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ fetchurl }: - -rec { - fetchSrc = {name, hash}: fetchurl { - url = "https://download.documentfoundation.org/libreoffice/src/${subdir}/libreoffice-${name}-${version}.tar.xz"; - inherit hash; - }; - - major = "7"; - minor = "4"; - patch = "7"; - tweak = "2"; - - subdir = "${major}.${minor}.${patch}"; - - version = "${subdir}${if tweak == "" then "" else "."}${tweak}"; - - src = fetchurl { - url = "https://download.documentfoundation.org/libreoffice/src/${subdir}/libreoffice-${version}.tar.xz"; - hash = "sha256-dD2R8qE4png4D6eo7LWyQB2ZSwZ7MwdQ8DrY9SOi+yA="; - }; - - # FIXME rename - translations = fetchSrc { - name = "translations"; - hash = "sha256-7wea0EClmvwcPvgQDGagkOF7eBVvYTZScCEEpirdXnE="; - }; - - # the "dictionaries" archive is not used for LO build because we already build hunspellDicts packages from - # it and LibreOffice can use these by pointing DICPATH environment variable at the hunspell directory - - help = fetchSrc { - name = "help"; - hash = "sha256-vcQWE3mBZx2sBQ9KzTh6zM7277mK9twfvyESTzTiII8="; - }; -} diff --git a/pkgs/applications/office/libreoffice/src-still/translations.nix b/pkgs/applications/office/libreoffice/src-still/translations.nix new file mode 100644 index 000000000000..2aedb0bd4677 --- /dev/null +++ b/pkgs/applications/office/libreoffice/src-still/translations.nix @@ -0,0 +1,4 @@ +{ + sha256 = "sha256-7wea0EClmvwcPvgQDGagkOF7eBVvYTZScCEEpirdXnE="; + url = "https://download.documentfoundation.org/libreoffice/src/7.4.7/libreoffice-translations-7.4.7.2.tar.xz"; +} diff --git a/pkgs/applications/office/libreoffice/src-still/version.nix b/pkgs/applications/office/libreoffice/src-still/version.nix new file mode 100644 index 000000000000..9e4cf6e86c07 --- /dev/null +++ b/pkgs/applications/office/libreoffice/src-still/version.nix @@ -0,0 +1 @@ +"7.4.7.1" diff --git a/pkgs/applications/office/libreoffice/update.sh b/pkgs/applications/office/libreoffice/update.sh new file mode 100755 index 000000000000..a04e668e8188 --- /dev/null +++ b/pkgs/applications/office/libreoffice/update.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p python3 pup curl jq nix + +set -euo pipefail +echoerr() { echo "$@" 1>&2; } + +fname="$1" +echoerr got fname $fname +shift + +variant="$1" +# See comment near version_major variable +if [[ $variant == fresh ]]; then + head_tail=head +elif [[ $variant == still ]]; then + head_tail=tail +else + echoerr got unknown variant $variant + exit 3 +fi +echoerr got variant $variant +shift + +# Not totally needed, but makes it easy to run the update in case tis folder is +# deleted. +mkdir -p "$(dirname $fname)/src-$variant" +cd "$(dirname $fname)/src-$variant" + +# The pup command prints both fresh and still versions one after another, and +# we use either head -1 or tail -1 to get the right version, per the if elif +# above. +version_major="$(curl --silent https://www.libreoffice.org/download/download-libreoffice/ |\ + pup '.dl_version_number text{}' | $head_tail -1)" +echoerr got from website ${variant}_version $version_major +baseurl=https://download.documentfoundation.org/libreoffice/src/$version_major +tarballs=($(curl --silent $baseurl/ |\ + pup 'table json{}' |\ + jq --raw-output '.. | .href? | strings' |\ + grep "$version_major.*.tar.xz$")) + +full_version="$(echo ${tarballs[0]} | sed -e 's/^libreoffice-//' -e 's/.tar.xz$//')" +echoerr full version is $full_version +echo \"$full_version\" > version.nix + +for t in help translations; do + echo "{" > $t.nix + echo " sha256 = "\"$(nix-prefetch-url $baseurl/libreoffice-$t-$full_version.tar.xz)'";' >> $t.nix + echo " url = "\"$baseurl/libreoffice-$t-$full_version.tar.xz'";' >> $t.nix + echo "}" >> $t.nix +done + +# Out of loop nix-prefetch-url, because there is no $t, and we want the output +# path as well, to get the download.lst file from there afterwards. +main_path_hash=($(nix-prefetch-url --print-path $baseurl/libreoffice-$full_version.tar.xz)) +echo "{" > main.nix +echo " sha256 = "\"${main_path_hash[0]}'";' >> main.nix +echo " url = "\"$baseurl/libreoffice-$full_version.tar.xz'";' >> main.nix +echo "}" >> main.nix +echoerr got filename ${main_path_hash[1]} + +# Environment variable required by ../generate-libreoffice-srcs.py +export downloadList=/tmp/nixpkgs-libreoffice-update-download-$full_version.lst +# Need to extract the file only if it doesn't exist, otherwise spare time be +# skipping this. +if [[ ! -f "$downloadList" ]]; then + tar --extract \ + --file=${main_path_hash[1]} \ + libreoffice-$full_version/download.lst \ + -O > $downloadList +else + echoerr relying on previously downloaded downloadList file +fi +cd .. +python3 ./generate-libreoffice-srcs.py > src-$variant/deps.nix diff --git a/pkgs/applications/office/libreoffice/wrapper.nix b/pkgs/applications/office/libreoffice/wrapper.nix index 1f4059b2adfc..b44fc71c3d84 100644 --- a/pkgs/applications/office/libreoffice/wrapper.nix +++ b/pkgs/applications/office/libreoffice/wrapper.nix @@ -19,7 +19,9 @@ }: let - inherit (unwrapped.srcs.primary) major minor; + inherit (unwrapped) version; + major = lib.versions.major version; + minor = lib.versions.minor version; makeWrapperArgs = builtins.concatStringsSep " " ([ "--set" "GDK_PIXBUF_MODULE_FILE" "${librsvg}/${gdk-pixbuf.moduleDir}.cache"