signal-destop-from-src: 7.14.0 -> 7.16.0
upstream switched from yarn to npm, and for this kind of a package i'll seize the opportunity to use builNpmPackage instead of doing so much manually :-)
This commit is contained in:
@@ -74,7 +74,6 @@
|
|||||||
#
|
#
|
||||||
# HOW TO UPDATE
|
# HOW TO UPDATE
|
||||||
# - `nix run '.#update.pkgs.signal-desktop-from-src'`
|
# - `nix run '.#update.pkgs.signal-desktop-from-src'`
|
||||||
# - delete `env.yarnOfflineCache.hash` and rebuild it
|
|
||||||
# - check signal-desktop's package.json for new ringrtc/nodejs
|
# - check signal-desktop's package.json for new ringrtc/nodejs
|
||||||
# - if sqlcipher fails then update sqlcipherTarball url/hash (rare)
|
# - if sqlcipher fails then update sqlcipherTarball url/hash (rare)
|
||||||
# errors which can be safely ignored:
|
# errors which can be safely ignored:
|
||||||
@@ -89,14 +88,13 @@
|
|||||||
, atk
|
, atk
|
||||||
, autoPatchelfHook
|
, autoPatchelfHook
|
||||||
, bash
|
, bash
|
||||||
|
, buildNpmPackage
|
||||||
, buildPackages
|
, buildPackages
|
||||||
, cups
|
, cups
|
||||||
, electron-bin
|
, electron-bin
|
||||||
, fetchurl
|
, fetchurl
|
||||||
, fetchFromGitHub
|
, fetchFromGitHub
|
||||||
, fetchYarnDeps
|
|
||||||
, flac
|
, flac
|
||||||
, fixup_yarn_lock
|
|
||||||
, gdk-pixbuf
|
, gdk-pixbuf
|
||||||
, git
|
, git
|
||||||
, gitUpdater
|
, gitUpdater
|
||||||
@@ -118,10 +116,9 @@
|
|||||||
, stdenv
|
, stdenv
|
||||||
, wrapGAppsHook
|
, wrapGAppsHook
|
||||||
, xdg-utils
|
, xdg-utils
|
||||||
, yarn
|
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
version = "7.14.0";
|
version = "7.16.0";
|
||||||
|
|
||||||
ringrtcPrebuild = fetchurl {
|
ringrtcPrebuild = fetchurl {
|
||||||
# version is found in signal-desktop's package.json as "@signalapp/ringrtc"
|
# version is found in signal-desktop's package.json as "@signalapp/ringrtc"
|
||||||
@@ -168,18 +165,12 @@ let
|
|||||||
repo = "Signal-Desktop";
|
repo = "Signal-Desktop";
|
||||||
leaveDotGit = true; # signal calculates the release date via `git`
|
leaveDotGit = true; # signal calculates the release date via `git`
|
||||||
rev = "v${version}";
|
rev = "v${version}";
|
||||||
hash = "sha256-lsINz704lEU4W17ZPC0sR40FveUzn19/6B7K7f9B7do=";
|
hash = "sha256-HHpv+Kv7Y+653CBSpRePfWQmeRzznmdmUaU5AIxLQUw=";
|
||||||
};
|
|
||||||
yarnOfflineCache = fetchYarnDeps {
|
|
||||||
yarnLock = "${src}/yarn.lock";
|
|
||||||
hash = "sha256-fAnAnpY+23T+u+HAK230/ebUhJQ+KYHK328HLL49qZA=";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
nodejs' = mkNodeJs pkgs;
|
nodejs' = mkNodeJs pkgs;
|
||||||
buildNodejs = mkNodeJs buildPackages;
|
buildNodejs = mkNodeJs buildPackages;
|
||||||
|
|
||||||
buildYarn = buildPackages.yarn.override { nodejs = buildNodejs; };
|
|
||||||
|
|
||||||
# note that `package.json` locks the electron version, but we seem to not be strictly beholden to that.
|
# note that `package.json` locks the electron version, but we seem to not be strictly beholden to that.
|
||||||
# prefer to use the same electron version as everywhere else, and a `-bin` version to avoid 4hr rebuilds.
|
# prefer to use the same electron version as everywhere else, and a `-bin` version to avoid 4hr rebuilds.
|
||||||
# the non-bin varieties *seem* to ship the wrong `electron.headers` property.
|
# the non-bin varieties *seem* to ship the wrong `electron.headers` property.
|
||||||
@@ -190,10 +181,12 @@ let
|
|||||||
hostNpmArch = if stdenv.hostPlatform.isAarch64 then "arm64" else "x64";
|
hostNpmArch = if stdenv.hostPlatform.isAarch64 then "arm64" else "x64";
|
||||||
crossNpmArchExt = if buildNpmArch == hostNpmArch then "" else "-${hostNpmArch}";
|
crossNpmArchExt = if buildNpmArch == hostNpmArch then "" else "-${hostNpmArch}";
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation rec {
|
buildNpmPackage rec {
|
||||||
pname = "signal-desktop-from-src";
|
pname = "signal-desktop-from-src";
|
||||||
inherit src version;
|
inherit src version;
|
||||||
|
|
||||||
|
npmDepsHash = "sha256-CJTTLjP3eiJSa/ZWoeBP/9S1Krtb7ozsutRdH2HGfe8=";
|
||||||
|
|
||||||
patches = [
|
patches = [
|
||||||
# ./debug.patch
|
# ./debug.patch
|
||||||
# fix bug that signal launches in the background on wayland
|
# fix bug that signal launches in the background on wayland
|
||||||
@@ -220,14 +213,12 @@ stdenv.mkDerivation rec {
|
|||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
autoPatchelfHook
|
autoPatchelfHook
|
||||||
fixup_yarn_lock
|
|
||||||
git # to calculate build date
|
git # to calculate build date
|
||||||
gnused
|
gnused
|
||||||
makeShellWrapper
|
makeShellWrapper
|
||||||
buildNodejs
|
buildNodejs
|
||||||
python3
|
python3
|
||||||
wrapGAppsHook
|
wrapGAppsHook
|
||||||
buildYarn
|
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
@@ -253,28 +244,24 @@ stdenv.mkDerivation rec {
|
|||||||
# sqlcipher
|
# sqlcipher
|
||||||
];
|
];
|
||||||
|
|
||||||
env.yarnOfflineCache = yarnOfflineCache;
|
env.SIGNAL_ENV = "production";
|
||||||
# env.SIGNAL_ENV = "production";
|
# env.NODE_ENV = "production"; #< XXX setting this causes `node_modules/protobufjs-cli/bin/pbjs` to not be fetched...
|
||||||
# env.NODE_ENV = "production";
|
env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
|
||||||
# env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
|
|
||||||
|
|
||||||
dontWrapGApps = true;
|
dontWrapGApps = true;
|
||||||
|
|
||||||
|
npmRebuildFlags = [ "--offline" "--ignore-scripts" ];
|
||||||
|
makeCacheWritable = true;
|
||||||
|
|
||||||
# NIX_DEBUG = 6;
|
# NIX_DEBUG = 6;
|
||||||
|
|
||||||
configurePhase = ''
|
postConfigure = ''
|
||||||
runHook preConfigure
|
|
||||||
|
|
||||||
# XXX: Signal does not let clients connect if they're running a version that's > 90d old.
|
# XXX: Signal does not let clients connect if they're running a version that's > 90d old.
|
||||||
# to calculate the build date, it uses SOURCE_DATE_EPOCH (if set), else `git log`.
|
# to calculate the build date, it uses SOURCE_DATE_EPOCH (if set), else `git log`.
|
||||||
# nixpkgs sets SOURCE_DATE_EPOCH to 1980/01/01 by default, so unset it so Signal falls back to git date.
|
# nixpkgs sets SOURCE_DATE_EPOCH to 1980/01/01 by default, so unset it so Signal falls back to git date.
|
||||||
# see: Signal-Desktop/ts/scripts/get-expire-time.ts
|
# see: Signal-Desktop/ts/scripts/get-expire-time.ts
|
||||||
export SOURCE_DATE_EPOCH=
|
export SOURCE_DATE_EPOCH=
|
||||||
|
|
||||||
export HOME=$NIX_BUILD_TOP
|
|
||||||
yarn config --offline set yarn-offline-mirror $yarnOfflineCache
|
|
||||||
fixup_yarn_lock yarn.lock
|
|
||||||
|
|
||||||
# prevent any attempt at downloading nodejs C headers
|
# prevent any attempt at downloading nodejs C headers
|
||||||
# see: <https://www.electronjs.org/docs/latest/tutorial/using-native-node-modules>
|
# see: <https://www.electronjs.org/docs/latest/tutorial/using-native-node-modules>
|
||||||
tar xzf ${electron'.headers}
|
tar xzf ${electron'.headers}
|
||||||
@@ -283,12 +270,18 @@ stdenv.mkDerivation rec {
|
|||||||
export npm_config_arch=${buildNpmArch}
|
export npm_config_arch=${buildNpmArch}
|
||||||
export npm_config_target_arch=${hostNpmArch}
|
export npm_config_target_arch=${hostNpmArch}
|
||||||
|
|
||||||
# optional flags: --no-progress --non-interactive
|
# npm config set electronDist ${electron'}/libexec/electron
|
||||||
# yarn install creates the node_modules/ directory
|
# npm config set electronVersion ${electron'.version}
|
||||||
# --ignore-scripts tells yarn to not run the "install" or "postinstall" commands mentioned in dependencies' package.json
|
|
||||||
# since many of those require network access
|
# redo parts of npmConfigHook, but with `npm_config_nodedir` properly set:
|
||||||
yarn install --offline --frozen-lockfile --ignore-scripts
|
# prefetchNpmDeps --map-cache
|
||||||
patchShebangs node_modules/
|
# prefetchNpmDeps --fixup-lockfile "$PWD/package-lock.json"
|
||||||
|
npm ci --ignore-scripts $npmInstallFlags "''${npmInstallFlagsArray[@]}" $npmFlags "''${npmFlagsArray[@]}"
|
||||||
|
patchShebangs node_modules
|
||||||
|
npm rebuild $npmRebuildFlags "''${npmRebuildFlagsArray[@]}" $npmFlags "''${npmFlagsArray[@]}"
|
||||||
|
patchShebangs node_modules
|
||||||
|
|
||||||
|
|
||||||
patchShebangs --build --update node_modules/{bufferutil/node_modules/node-gyp-build/,node-gyp-build,utf-8-validate/node_modules/node-gyp-build}
|
patchShebangs --build --update node_modules/{bufferutil/node_modules/node-gyp-build/,node-gyp-build,utf-8-validate/node_modules/node-gyp-build}
|
||||||
# patch these out to remove a runtime reference back to the build bash
|
# patch these out to remove a runtime reference back to the build bash
|
||||||
# (better, perhaps, would be for these build scripts to not be included in the asar...)
|
# (better, perhaps, would be for these build scripts to not be included in the asar...)
|
||||||
@@ -306,21 +299,19 @@ stdenv.mkDerivation rec {
|
|||||||
|
|
||||||
cp ${sqlcipherTarball} node_modules/@signalapp/better-sqlite3/deps/sqlcipher.tar.gz
|
cp ${sqlcipherTarball} node_modules/@signalapp/better-sqlite3/deps/sqlcipher.tar.gz
|
||||||
pushd node_modules/@signalapp/better-sqlite3
|
pushd node_modules/@signalapp/better-sqlite3
|
||||||
# node-gyp isn't consistently linked into better-sqlite's `node_modules` (maybe due to version mismatch with sinal-desktop's node-gyp?)
|
# node-gyp isn't consistently linked into better-sqlite's `node_modules` (maybe due to version mismatch with signal-desktop's node-gyp?)
|
||||||
PATH="$PATH:$(pwd)/../../.bin" yarn --offline build-release
|
PATH="$PATH:$(pwd)/../../.bin" npm --offline run build-release
|
||||||
popd
|
popd
|
||||||
|
|
||||||
pushd node_modules/@signalapp/libsignal-client
|
# pushd node_modules/@signalapp/libsignal-client
|
||||||
yarn node-gyp-build
|
# npx node-gyp rebuild
|
||||||
popd
|
# popd
|
||||||
# there are more dependencies which had install/postinstall scripts, but it seems we can safely ignore them
|
|
||||||
|
|
||||||
# run signal's own `postinstall`:
|
# run signal's own `postinstall`:
|
||||||
yarn build:acknowledgments
|
# npm run build:acknowledgments
|
||||||
yarn patch-package
|
# patch-package
|
||||||
# yarn electron:install-app-deps # not necessary
|
# npm run electron:install-app-deps
|
||||||
|
npm run postinstall || true
|
||||||
runHook postConfigure
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# excerpts from package.json:
|
# excerpts from package.json:
|
||||||
@@ -349,20 +340,21 @@ stdenv.mkDerivation rec {
|
|||||||
# echo 'ignore-engines true' > .yarnrc
|
# echo 'ignore-engines true' > .yarnrc
|
||||||
|
|
||||||
# yarn generate:
|
# yarn generate:
|
||||||
yarn build-module-protobuf --offline --frozen-lockfile
|
npm run build-module-protobuf --offline --frozen-lockfile
|
||||||
yarn build:esbuild --offline --frozen-lockfile
|
npm run build:esbuild --offline --frozen-lockfile
|
||||||
# yarn build:dns-fallback --offline --frozen-lockfile # requires network
|
# npm run build:dns-fallback --offline --frozen-lockfile # requires network
|
||||||
yarn build:icu-types --offline --frozen-lockfile
|
npm run build:icu-types --offline --frozen-lockfile
|
||||||
yarn build:compact-locales --offline --frozen-lockfile
|
npm run build:compact-locales --offline --frozen-lockfile
|
||||||
yarn sass
|
npm run sass
|
||||||
yarn get-expire-time
|
npm run get-expire-time
|
||||||
yarn copy-components
|
npm run copy-components
|
||||||
|
|
||||||
yarn build:esbuild:prod --offline --frozen-lockfile
|
npm run build:esbuild:prod --offline --frozen-lockfile
|
||||||
|
|
||||||
yarn build:release \
|
cp -r ${electron'}/libexec/electron electron-dist
|
||||||
|
npm exec electron-builder -- \
|
||||||
--linux --${hostNpmArch} \
|
--linux --${hostNpmArch} \
|
||||||
-c.electronDist=${electron'}/libexec/electron \
|
-c.electronDist=electron-dist \
|
||||||
-c.electronVersion=${electron'.version} \
|
-c.electronVersion=${electron'.version} \
|
||||||
--dir
|
--dir
|
||||||
|
|
||||||
@@ -374,9 +366,9 @@ stdenv.mkDerivation rec {
|
|||||||
|
|
||||||
# directory structure follows the original `signal-desktop` nix package
|
# directory structure follows the original `signal-desktop` nix package
|
||||||
mkdir -p $out/lib
|
mkdir -p $out/lib
|
||||||
cp -R release/linux${crossNpmArchExt}-unpacked $out/lib/Signal
|
cp -R dist/linux${crossNpmArchExt}-unpacked $out/lib/Signal
|
||||||
# cp -R release/linux-unpacked/resources $out/lib/Signal/resources
|
# cp -R dist/linux-unpacked/resources $out/lib/Signal/resources
|
||||||
# cp -R release/linux-unpacked/locales $out/lib/Signal/locales
|
# cp -R dist/linux-unpacked/locales $out/lib/Signal/locales
|
||||||
|
|
||||||
mkdir $out/bin
|
mkdir $out/bin
|
||||||
|
|
||||||
@@ -410,7 +402,6 @@ stdenv.mkDerivation rec {
|
|||||||
ignoredVersions = "beta";
|
ignoredVersions = "beta";
|
||||||
};
|
};
|
||||||
nodejs = nodejs';
|
nodejs = nodejs';
|
||||||
buildYarn = buildYarn;
|
|
||||||
buildNodejs = buildNodejs;
|
buildNodejs = buildNodejs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user