libreoffice: run the update-script's side-effect at runtime instead of eval

time
This commit is contained in:
Thibault Gagnaux 2022-05-31 10:03:40 +02:00
parent 4c23cbcc15
commit d7ccd36aa0
No known key found for this signature in database
GPG key ID: 44BD0764ACAE8E25
3 changed files with 28 additions and 13 deletions

View file

@ -52,26 +52,24 @@ stdenvNoCC.mkDerivation {
passthru.updateScript =
let
inherit (import ./update-utils.nix { inherit lib; })
getLatestStableVersion
getSha256;
newVersion = getLatestStableVersion;
newAarch64Sha256 = getSha256 dist."aarch64-darwin".url version newVersion;
newX86_64Sha256 = getSha256 dist."x86_64-darwin".url version newVersion;
currentFile = builtins.toString ./default.nix;
defaultNixFile = builtins.toString ./default.nix;
updateNix = builtins.toString ./update.nix;
aarch64Url = dist."aarch64-darwin".url;
x86_64Url = dist."x86_64-darwin".url;
in
writeScript "update-libreoffice.sh"
''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p common-updater-scripts
#!nix-shell -i bash --argstr aarch64Url ${aarch64Url} --argstr x86_64Url ${x86_64Url} --argstr version ${version} ${updateNix}
set -eou pipefail
# reset version first so that both platforms are always updated and in sync
update-source-version libreoffice-bin 0 ${lib.fakeSha256} --file=${currentFile} --system=aarch64-darwin
update-source-version libreoffice-bin ${newVersion} ${newAarch64Sha256} --file=${currentFile} --system=aarch64-darwin
update-source-version libreoffice-bin 0 ${lib.fakeSha256} --file=${currentFile} --system=x86_64-darwin
update-source-version libreoffice-bin ${newVersion} ${newX86_64Sha256} --file=${currentFile} --system=x86_64-darwin
update-source-version libreoffice-bin 0 ${lib.fakeSha256} --file=${defaultNixFile} --system=aarch64-darwin
update-source-version libreoffice-bin $newVersion $newAarch64Sha256 --file=${defaultNixFile} --system=aarch64-darwin
update-source-version libreoffice-bin 0 ${lib.fakeSha256} --file=${defaultNixFile} --system=x86_64-darwin
update-source-version libreoffice-bin $newVersion $newX86_64Sha256 --file=${defaultNixFile} --system=x86_64-darwin
'';
meta = with lib; {
description = "Comprehensive, professional-quality productivity suite, a variant of openoffice.org";
homepage = "https://libreoffice.org/";

View file

@ -1,4 +1,3 @@
# Impure functions, for passthru.updateScript only
{ lib }:
let
# extractLatestVersionFromHtml :: String -> String

View file

@ -0,0 +1,18 @@
# Impure functions, for passthru.updateScript runtime only
{ aarch64Url
, x86_64Url
, version
, pkgs ? import ../../../../../default.nix { }
,
}:
let
inherit (import ./update-utils.nix { inherit (pkgs) lib; })
getLatestStableVersion
getSha256;
in
pkgs.mkShell rec {
buildInputs = [ pkgs.common-updater-scripts ];
newVersion = getLatestStableVersion;
newAarch64Sha256 = getSha256 aarch64Url version newVersion;
newX86_64Sha256 = getSha256 x86_64Url version newVersion;
}