From 51ff21fbc6abaa0c552174c12e215f4f95265842 Mon Sep 17 00:00:00 2001 From: teutat3s <10206665+teutat3s@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:42:01 -0300 Subject: [PATCH] element-{web,desktop}: move to pkgs/by-name, format with `nixfmt-rfc-style` --- .../element/element-web.nix | 85 --------------- .../el/element-desktop}/keytar/default.nix | 0 .../el/element-desktop}/keytar/pin.json | 0 .../el/element-desktop}/keytar/update.sh | 0 .../el/element-desktop/package.nix} | 10 +- .../el/element-desktop}/seshat/default.nix | 0 .../el/element-desktop}/seshat/pin.json | 0 .../el/element-desktop}/seshat/update.sh | 0 .../el/element-web-unwrapped/package.nix | 100 ++++++++++++++++++ .../el/element-web-unwrapped}/pin.nix | 0 .../el/element-web-unwrapped}/update.sh | 4 +- .../el/element-web/package.nix} | 0 pkgs/top-level/aliases.nix | 1 + pkgs/top-level/all-packages.nix | 14 --- 14 files changed, 108 insertions(+), 106 deletions(-) delete mode 100644 pkgs/applications/networking/instant-messengers/element/element-web.nix rename pkgs/{applications/networking/instant-messengers/element => by-name/el/element-desktop}/keytar/default.nix (100%) rename pkgs/{applications/networking/instant-messengers/element => by-name/el/element-desktop}/keytar/pin.json (100%) rename pkgs/{applications/networking/instant-messengers/element => by-name/el/element-desktop}/keytar/update.sh (100%) rename pkgs/{applications/networking/instant-messengers/element/element-desktop.nix => by-name/el/element-desktop/package.nix} (95%) rename pkgs/{applications/networking/instant-messengers/element => by-name/el/element-desktop}/seshat/default.nix (100%) rename pkgs/{applications/networking/instant-messengers/element => by-name/el/element-desktop}/seshat/pin.json (100%) rename pkgs/{applications/networking/instant-messengers/element => by-name/el/element-desktop}/seshat/update.sh (100%) create mode 100644 pkgs/by-name/el/element-web-unwrapped/package.nix rename pkgs/{applications/networking/instant-messengers/element => by-name/el/element-web-unwrapped}/pin.nix (100%) rename pkgs/{applications/networking/instant-messengers/element => by-name/el/element-web-unwrapped}/update.sh (91%) rename pkgs/{applications/networking/instant-messengers/element/element-web-wrapper.nix => by-name/el/element-web/package.nix} (100%) diff --git a/pkgs/applications/networking/instant-messengers/element/element-web.nix b/pkgs/applications/networking/instant-messengers/element/element-web.nix deleted file mode 100644 index 1bfea7162dde8..0000000000000 --- a/pkgs/applications/networking/instant-messengers/element/element-web.nix +++ /dev/null @@ -1,85 +0,0 @@ -{ lib -, stdenv -, fetchFromGitHub -, fetchYarnDeps -, jq -, yarn -, fixup-yarn-lock -, nodejs -, jitsi-meet -}: - -let - pinData = import ./pin.nix; - inherit (pinData.hashes) webSrcHash webYarnHash; - noPhoningHome = { - disable_guests = true; # disable automatic guest account registration at matrix.org - }; -in -stdenv.mkDerivation (finalAttrs: builtins.removeAttrs pinData [ "hashes" ] // { - pname = "element-web"; - - src = fetchFromGitHub { - owner = "element-hq"; - repo = "element-web"; - rev = "v${finalAttrs.version}"; - hash = webSrcHash; - }; - - offlineCache = fetchYarnDeps { - yarnLock = finalAttrs.src + "/yarn.lock"; - sha256 = webYarnHash; - }; - - nativeBuildInputs = [ yarn fixup-yarn-lock jq nodejs ]; - - buildPhase = '' - runHook preBuild - - export VERSION=${finalAttrs.version} - yarn --offline build:res - yarn --offline build:module_system - yarn --offline build:bundle - - runHook postBuild - ''; - - configurePhase = '' - runHook preConfigure - - export HOME=$PWD/tmp - # with the update of openssl3, some key ciphers are not supported anymore - # this flag will allow those codecs again as a workaround - # see https://medium.com/the-node-js-collection/node-js-17-is-here-8dba1e14e382#5f07 - # and https://github.com/element-hq/element-web/issues/21043 - export NODE_OPTIONS=--openssl-legacy-provider - mkdir -p $HOME - - fixup-yarn-lock yarn.lock - yarn config --offline set yarn-offline-mirror $offlineCache - yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive - patchShebangs node_modules - - runHook postConfigure - ''; - - installPhase = '' - runHook preInstall - - cp -R webapp $out - tar --extract --to-stdout --file ${jitsi-meet.src} jitsi-meet/libs/external_api.min.js > $out/jitsi_external_api.min.js - echo "${finalAttrs.version}" > "$out/version" - jq -s '.[0] * $conf' "config.sample.json" --argjson "conf" '${builtins.toJSON noPhoningHome}' > "$out/config.json" - - runHook postInstall - ''; - - meta = { - description = "Glossy Matrix collaboration client for the web"; - homepage = "https://element.io/"; - changelog = "https://github.com/element-hq/element-web/blob/v${finalAttrs.version}/CHANGELOG.md"; - maintainers = lib.teams.matrix.members; - license = lib.licenses.asl20; - platforms = lib.platforms.all; - }; -}) diff --git a/pkgs/applications/networking/instant-messengers/element/keytar/default.nix b/pkgs/by-name/el/element-desktop/keytar/default.nix similarity index 100% rename from pkgs/applications/networking/instant-messengers/element/keytar/default.nix rename to pkgs/by-name/el/element-desktop/keytar/default.nix diff --git a/pkgs/applications/networking/instant-messengers/element/keytar/pin.json b/pkgs/by-name/el/element-desktop/keytar/pin.json similarity index 100% rename from pkgs/applications/networking/instant-messengers/element/keytar/pin.json rename to pkgs/by-name/el/element-desktop/keytar/pin.json diff --git a/pkgs/applications/networking/instant-messengers/element/keytar/update.sh b/pkgs/by-name/el/element-desktop/keytar/update.sh similarity index 100% rename from pkgs/applications/networking/instant-messengers/element/keytar/update.sh rename to pkgs/by-name/el/element-desktop/keytar/update.sh diff --git a/pkgs/applications/networking/instant-messengers/element/element-desktop.nix b/pkgs/by-name/el/element-desktop/package.nix similarity index 95% rename from pkgs/applications/networking/instant-messengers/element/element-desktop.nix rename to pkgs/by-name/el/element-desktop/package.nix index 3bccfdec1d687..4e9c79fd0eeca 100644 --- a/pkgs/applications/networking/instant-messengers/element/element-desktop.nix +++ b/pkgs/by-name/el/element-desktop/package.nix @@ -13,9 +13,7 @@ element-web, sqlcipher, callPackage, - Security, - AppKit, - CoreServices, + darwin, desktopToDarwinBundle, useKeytar ? true, # command line arguments which are always set @@ -23,11 +21,11 @@ }: let - pinData = import ./pin.nix; + pinData = import ../element-web-unwrapped/pin.nix; inherit (pinData.hashes) desktopSrcHash desktopYarnHash; executableName = "element-desktop"; - keytar = callPackage ./keytar { inherit Security AppKit; }; - seshat = callPackage ./seshat { inherit CoreServices; }; + keytar = callPackage ./keytar { inherit (darwin.apple_sdk.frameworks) Security AppKit; }; + seshat = callPackage ./seshat { inherit (darwin.apple_sdk.frameworks) CoreServices; }; electron = electron_33; in stdenv.mkDerivation ( diff --git a/pkgs/applications/networking/instant-messengers/element/seshat/default.nix b/pkgs/by-name/el/element-desktop/seshat/default.nix similarity index 100% rename from pkgs/applications/networking/instant-messengers/element/seshat/default.nix rename to pkgs/by-name/el/element-desktop/seshat/default.nix diff --git a/pkgs/applications/networking/instant-messengers/element/seshat/pin.json b/pkgs/by-name/el/element-desktop/seshat/pin.json similarity index 100% rename from pkgs/applications/networking/instant-messengers/element/seshat/pin.json rename to pkgs/by-name/el/element-desktop/seshat/pin.json diff --git a/pkgs/applications/networking/instant-messengers/element/seshat/update.sh b/pkgs/by-name/el/element-desktop/seshat/update.sh similarity index 100% rename from pkgs/applications/networking/instant-messengers/element/seshat/update.sh rename to pkgs/by-name/el/element-desktop/seshat/update.sh diff --git a/pkgs/by-name/el/element-web-unwrapped/package.nix b/pkgs/by-name/el/element-web-unwrapped/package.nix new file mode 100644 index 0000000000000..5af94dbb4763b --- /dev/null +++ b/pkgs/by-name/el/element-web-unwrapped/package.nix @@ -0,0 +1,100 @@ +{ + lib, + stdenv, + fetchFromGitHub, + fetchYarnDeps, + jq, + yarn, + fixup-yarn-lock, + nodejs, + jitsi-meet, +}: + +let + pinData = import ./pin.nix; + inherit (pinData.hashes) webSrcHash webYarnHash; + noPhoningHome = { + disable_guests = true; # disable automatic guest account registration at matrix.org + }; +in +stdenv.mkDerivation ( + finalAttrs: + builtins.removeAttrs pinData [ "hashes" ] + // { + pname = "element-web"; + + src = fetchFromGitHub { + owner = "element-hq"; + repo = "element-web"; + rev = "v${finalAttrs.version}"; + hash = webSrcHash; + }; + + offlineCache = fetchYarnDeps { + yarnLock = finalAttrs.src + "/yarn.lock"; + sha256 = webYarnHash; + }; + + nativeBuildInputs = [ + yarn + fixup-yarn-lock + jq + nodejs + ]; + + buildPhase = '' + runHook preBuild + + export VERSION=${finalAttrs.version} + yarn --offline build:res + yarn --offline build:module_system + yarn --offline build:bundle + + runHook postBuild + ''; + + configurePhase = '' + runHook preConfigure + + export HOME=$PWD/tmp + # with the update of openssl3, some key ciphers are not supported anymore + # this flag will allow those codecs again as a workaround + # see https://medium.com/the-node-js-collection/node-js-17-is-here-8dba1e14e382#5f07 + # and https://github.com/element-hq/element-web/issues/21043 + export NODE_OPTIONS=--openssl-legacy-provider + mkdir -p $HOME + + fixup-yarn-lock yarn.lock + yarn config --offline set yarn-offline-mirror $offlineCache + yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive + patchShebangs node_modules + + runHook postConfigure + ''; + + installPhase = '' + runHook preInstall + + cp -R webapp $out + tar --extract --to-stdout --file ${jitsi-meet.src} jitsi-meet/libs/external_api.min.js > $out/jitsi_external_api.min.js + echo "${finalAttrs.version}" > "$out/version" + jq -s '.[0] * $conf' "config.sample.json" --argjson "conf" '${builtins.toJSON noPhoningHome}' > "$out/config.json" + + runHook postInstall + ''; + + passthru = { + # run with: nix-shell ./maintainers/scripts/update.nix --argstr package element-web + updateScript = ./update.sh; + }; + + meta = { + description = "Glossy Matrix collaboration client for the web"; + homepage = "https://element.io/"; + changelog = "https://github.com/element-hq/element-web/blob/v${finalAttrs.version}/CHANGELOG.md"; + maintainers = lib.teams.matrix.members; + license = lib.licenses.asl20; + platforms = lib.platforms.all; + }; + } +) diff --git a/pkgs/applications/networking/instant-messengers/element/pin.nix b/pkgs/by-name/el/element-web-unwrapped/pin.nix similarity index 100% rename from pkgs/applications/networking/instant-messengers/element/pin.nix rename to pkgs/by-name/el/element-web-unwrapped/pin.nix diff --git a/pkgs/applications/networking/instant-messengers/element/update.sh b/pkgs/by-name/el/element-web-unwrapped/update.sh similarity index 91% rename from pkgs/applications/networking/instant-messengers/element/update.sh rename to pkgs/by-name/el/element-web-unwrapped/update.sh index 2a4ec5fcdec24..535e452fafe00 100755 --- a/pkgs/applications/networking/instant-messengers/element/update.sh +++ b/pkgs/by-name/el/element-web-unwrapped/update.sh @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#!nix-shell -I nixpkgs=../../../../../ -i bash -p nix wget prefetch-yarn-deps nix-prefetch-github jq +#!nix-shell -i bash -p nix wget prefetch-yarn-deps nix-prefetch-github jq if [ "$#" -gt 1 ] || [[ "$1" == -* ]]; then echo "Regenerates packaging data for the element packages." @@ -22,6 +22,8 @@ version="${version#v}" web_src="https://raw.githubusercontent.com/element-hq/element-web/v$version" web_src_hash=$(nix-prefetch-github element-hq element-web --rev v${version} | jq -r .hash) +cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1 + web_tmpdir=$(mktemp -d) trap 'rm -rf "$web_tmpdir"' EXIT diff --git a/pkgs/applications/networking/instant-messengers/element/element-web-wrapper.nix b/pkgs/by-name/el/element-web/package.nix similarity index 100% rename from pkgs/applications/networking/instant-messengers/element/element-web-wrapper.nix rename to pkgs/by-name/el/element-web/package.nix diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index 74e47c2d0be7c..f296483d5e65f 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -322,6 +322,7 @@ mapAliases { elasticsearch7Plugins = elasticsearchPlugins; # Electron + element-desktop-wayland = element-desktop; # Added 2024-12-17 elixir_ls = elixir-ls; # Added 2023-03-20 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d203cce4a970f..f9cbdba067b0b 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2290,20 +2290,6 @@ with pkgs; electronplayer = callPackage ../applications/video/electronplayer/electronplayer.nix { }; - element-desktop = callPackage ../applications/networking/instant-messengers/element/element-desktop.nix { - inherit (darwin.apple_sdk.frameworks) Security AppKit CoreServices; - }; - element-desktop-wayland = writeScriptBin "element-desktop" '' - #!/bin/sh - NIXOS_OZONE_WL=1 exec ${element-desktop}/bin/element-desktop "$@" - ''; - - element-web-unwrapped = callPackage ../applications/networking/instant-messengers/element/element-web.nix { }; - - element-web = callPackage ../applications/networking/instant-messengers/element/element-web-wrapper.nix { - conf = config.element-web.conf or { }; - }; - elm-github-install = callPackage ../tools/package-management/elm-github-install { }; espanso-wayland = espanso.override {