Open AleXoundOS opened 2 years ago
This is what I've came up with: default.nix:
{ lib
, electron
, fetchFromGitHub
, fetchYarnDeps
, makeWrapper
, mkYarnPackage
, runCommandLocal
}:
let
pname = "dingtalk";
version = "2.1.13";
src = fetchFromGitHub {
owner = "nashaofu";
repo = "dingtalk";
rev = "v${version}";
sha256 = "0q61cl07vv8syx8y85p9mqdr8jd588b4q6p7fhk7h6vp5yjkji8x";
};
yarnLock = runCommandLocal "fix-yarn.lock" { } ''
sed 's/\.tgz\?[^#]\+/\.tgz/g' ${src + /yarn.lock} > $out
'';
in
mkYarnPackage {
inherit pname version src yarnLock;
nativeBuildInputs = [ makeWrapper ];
packageJSON = runCommandLocal "fix-package-json" {} ''
grep -v -E '"electron-?[^ ]*": ' ${src}/package.json > $out
'';
# yarnFlags = [ "--offline" "--frozen-lockfile" "--production=true" ];
postInstall = ''
makeWrapper ${electron}/bin/electron $out/bin/dingtalk `
`--set NODE_ENV production `
`--run "cd $out/libexec/${pname}/deps/${pname}" `
`--add-flags "$out/libexec/${pname}/deps/${pname}"
'';
dontStrip = true; # no ELF binaries to strip
doDist = false;
offlineCache = fetchYarnDeps {
inherit yarnLock;
sha256 = "0ljfxzswpzx1gr74gja6vrqqjzknm17m7z5mrw099jis9x686qwq";
};
meta = {
description = "DingTalk desktop messaging application";
homepage = "https://www.dingtalk.com/";
license = lib.licenses.mit;
inherit (electron.meta) platforms;
};
}
pkgs.nix based on https://github.com/NixOS/nixpkgs/issues/144200#issuecomment-1016994169:
let
pin = builtins.fetchTarball {
name = "nixpkgs";
url = "https://github.com/NixOS/nixpkgs/archive/d5dae6569ea9952f1ae4e727946d93a71c507821.tar.gz";
sha256 = "1w4wch077d2wgrdaya8y1pa34rzvh26xns6zgzr4kmlfd5g2rhwd";
};
overlay = (_final: prev: {
prefetch-yarn-deps = prev.prefetch-yarn-deps.overrideAttrs (_def: {
postBuild = ''
chmod +w libexec/index.js
cp ${pkgs.path + /pkgs/build-support/node/fetch-yarn-deps/index.js} `
`libexec/index.js
patch -p5 libexec/index.js ${./fetch.patch}
patchShebangs libexec/index.js
'';
});
});
pkgs = import pin { overlays = [ overlay ]; };
in
pkgs
$ nix-build -E '(import ./pkgs.nix).callPackage ./. {}'
But I get:
$ ./result/bin/dingtalk
Error launching app
Unable to find Electron app at /nix/store/mw4fkifnk84ksx050kswbf1wyhmj7il6-dingtalk-2.1.13/libexec/dingtalk/deps/dingtalk
Cannot find module '/nix/store/mw4fkifnk84ksx050kswbf1wyhmj7il6-dingtalk-2.1.13/libexec/dingtalk/deps/dingtalk/dist/main.js'. Please verify that the package.json has a valid "main" entry
DingTalk desktop application uses Electron and its package.json
has a set of commands for packaging it with webpack
and electron-builder
:
"main": "dist/main.js",
"scripts": {
"start": "electron .",
"lint": "eslint --ext .js,.vue src",
"dev": "npm-run-all --parallel dev:main dev:preload dev:renderer",
"postinstall": "electron-builder install-app-deps",
"dev:main": "webpack --config build/main/webpack.dev.conf.js",
"dev:preload": "webpack --config build/preload/webpack.dev.conf.js",
"dev:renderer": "webpack serve --config build/renderer/webpack.dev.conf.js",
"build": "npm-run-all --parallel build:main build:preload build:renderer",
"build:main": "webpack --config build/main/webpack.prod.conf.js",
"build:preload": "webpack --config build/preload/webpack.prod.conf.js",
"build:renderer": "webpack --config build/renderer/webpack.prod.conf.js",
"pack": "electron-builder --dir",
"release": "electron-builder"
}
The problem is that "dist/main.js" does not exist, perhaps, until webpack
& electron-builder
steps are performed. I tried a custom main.js with no success neither (it just draws a blank window).
I couldn't figure out how to package this for nixpkgs. I used various resources as a reference to try to write a proper nixpkgs package:
Temporarily, I use AppImage solution:
{ lib, fetchurl, appimageTools }:
let
pname = "dingtalk";
version = "2.1.13";
name = "${pname}-${version}";
src = fetchurl {
url = "https://github.com/nashaofu/dingtalk/releases/download/v${version}/${name}-latest-x86_64.AppImage";
sha256 = "0z1nli1f3miri3i44b725avxlp6c5pyyxlqqf80mjpkg8y8zv70c";
};
in appimageTools.wrapType2 {
inherit name src;
meta = {
description = "DingTalk desktop messaging application";
homepage = "https://www.dingtalk.com/";
license = lib.licenses.mit;
platforms = [ "x86_64-linux" ];
};
}
Temporarily, I use AppImage solution:
{ lib, fetchurl, appimageTools }: let pname = "dingtalk"; version = "2.1.13"; name = "${pname}-${version}"; src = fetchurl { url = "https://github.com/nashaofu/dingtalk/releases/download/v${version}/${name}-latest-x86_64.AppImage"; sha256 = "0z1nli1f3miri3i44b725avxlp6c5pyyxlqqf80mjpkg8y8zv70c"; }; in appimageTools.wrapType2 { inherit name src; meta = { description = "DingTalk desktop messaging application"; homepage = "https://www.dingtalk.com/"; license = lib.licenses.mit; platforms = [ "x86_64-linux" ]; }; }
DingTalk AppImage can‘t be used anymore, because the web version of dingding has been shut down permanently。
As DingTalk has been offline web version and the source project was developed based on web version,the source project github.com/nashaofu/dingtalk has been unavailable. we could try to build it with offical .deb file
the offical website of dingtalk is follow
Project description DingTalk is a messenger similar to WeChat used in many Asian countries. Some Chinese companies provide support service for their products with the help of it.
Metadata