tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
zap-chip: init at 2024.09.27
Guillaume Girol
1 year ago
1d1c704b
20499cc1
+144
3 changed files
expand all
collapse all
unified
split
pkgs
by-name
za
zap-chip
dont-download-copyfiles-to-copy-files.patch
dont-get-version-from-git.patch
package.nix
+42
pkgs/by-name/za/zap-chip/dont-download-copyfiles-to-copy-files.patch
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
+
diff --git a/src-script/pack-apack-win-linux.js b/src-script/pack-apack-win-linux.js
2
+
index 0120f9f9..41fcf99c 100644
3
+
--- a/src-script/pack-apack-win-linux.js
4
+
+++ b/src-script/pack-apack-win-linux.js
5
+
@@ -6,12 +6,12 @@ exports.default = async function (context) {
6
+
context.electronPlatformName === 'win32' ||
7
+
context.electronPlatformName === 'linux'
8
+
) {
9
+
- return scriptUtil.executeCmd({}, 'npx', [
10
+
- 'copyfiles',
11
+
- '-V',
12
+
- '-f',
13
+
- path.resolve(context.outDir, '../apack.json'),
14
+
- context.appOutDir
15
+
+ return scriptUtil.executeCmd({}, 'install', [
16
+
+ '-m466',
17
+
+ '-v',
18
+
+ '-Dt',
19
+
+ context.appOutDir,
20
+
+ path.resolve(context.outDir, '../apack.json')
21
+
])
22
+
}
23
+
}
24
+
diff --git a/src-script/script-util.js b/src-script/script-util.js
25
+
index 1897c2b8..9faa5f20 100644
26
+
--- a/src-script/script-util.js
27
+
+++ b/src-script/script-util.js
28
+
@@ -181,11 +181,9 @@ async function rebuildBackendIfNeeded() {
29
+
return scriptUtil
30
+
.executeCmd({}, 'npx', ['tsc', '--build', './tsconfig.json'])
31
+
.then(() =>
32
+
- scriptUtil.executeCmd({}, 'npx', [
33
+
- 'copyfiles',
34
+
- './src-electron/**/*.sql',
35
+
- './src-electron/icons/*',
36
+
- './dist/'
37
+
+ scriptUtil.executeCmd({}, 'bash', [
38
+
+ '-xec',
39
+
+ 'for i in ./src-electron/**/*.sql ./src-electron/icons/*; do install -m 644 -Dt dist/$(dirname $i) $i; done'
40
+
])
41
+
)
42
+
}
+28
pkgs/by-name/za/zap-chip/dont-get-version-from-git.patch
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
+
diff --git a/src-script/script-util.js b/src-script/script-util.js
2
+
index 1897c2b8..aaf9a08b 100644
3
+
--- a/src-script/script-util.js
4
+
+++ b/src-script/script-util.js
5
+
@@ -196,23 +194,6 @@ async function rebuildBackendIfNeeded() {
6
+
* ads the timestamp and saves it into .version.json
7
+
*/
8
+
async function stampVersion() {
9
+
- try {
10
+
- let out = await getStdout('{"hash": null,"date": null}', 'git', [
11
+
- 'log',
12
+
- '-1',
13
+
- '--format={"hash": "%H","timestamp": %ct}'
14
+
- ])
15
+
- let version = JSON.parse(out)
16
+
- let d = new Date(version.timestamp * 1000) // git gives seconds, Date needs milliseconds
17
+
- let result = await setPackageJsonVersion(d, 'real')
18
+
- version.date = d
19
+
- version.zapVersion = result.version
20
+
- let versionFile = path.join(__dirname, '../.version.json')
21
+
- console.log(`🔍 Git commit: ${version.hash} from ${version.date}`)
22
+
- await fsp.writeFile(versionFile, JSON.stringify(version))
23
+
- } catch (err) {
24
+
- console.log(`Error retrieving version: ${err}`)
25
+
- }
26
+
}
27
+
28
+
/**
+74
pkgs/by-name/za/zap-chip/package.nix
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
+
{
2
+
lib,
3
+
buildNpmPackage,
4
+
electron_31,
5
+
fetchFromGitHub,
6
+
writers,
7
+
}:
8
+
9
+
let
10
+
electron = electron_31;
11
+
in
12
+
buildNpmPackage rec {
13
+
pname = "zap-chip";
14
+
version = "2024.09.27";
15
+
16
+
src = fetchFromGitHub {
17
+
owner = "project-chip";
18
+
repo = "zap";
19
+
rev = "v${version}";
20
+
hash = "sha256-Dc5rU4jJ6aJpk8mwL+XNSmtisYxF86VzXd/Aacd4p0o=";
21
+
};
22
+
23
+
npmDepsHash = "sha256-ZFksGwKlXkz6XTs2QdalGB0hR16HfB69XQOFWI9X/KY=";
24
+
25
+
env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
26
+
env.CYPRESS_INSTALL_BINARY = "0";
27
+
28
+
patches = [
29
+
# the build system creates a file `.version.json` from a git command
30
+
# as we don't build from a git repo, we create the file manually in postPatch
31
+
# and this patch disables the logic running git
32
+
./dont-get-version-from-git.patch
33
+
# some files are installed via `npx copyfiles` which tries to download
34
+
# code from the internet. This fails in the sandbox. This patch replaces the
35
+
# logic by running "normal" commands instead of `npx copyfiles`
36
+
./dont-download-copyfiles-to-copy-files.patch
37
+
];
38
+
39
+
postPatch =
40
+
let
41
+
versionJson = {
42
+
hash = version;
43
+
timestamp = 1;
44
+
date = version;
45
+
zapVersion = version;
46
+
};
47
+
in
48
+
''
49
+
cp ${writers.writeJSON "zapversion.json" versionJson} .version.json
50
+
cat .version.json
51
+
'';
52
+
53
+
postBuild = ''
54
+
npm exec electron-builder -- \
55
+
--dir \
56
+
-c.electronDist=${electron.dist} \
57
+
-c.electronVersion=${electron.version}
58
+
'';
59
+
60
+
postInstall = ''
61
+
# this file is also used at runtime
62
+
install -m644 .version.json $out/lib/node_modules/zap/
63
+
# home-assistant chip-* python packages need the executable under the name zap-cli
64
+
ln -s $out/bin/zap $out/bin/zap-cli
65
+
'';
66
+
67
+
meta = {
68
+
description = "Generic generation engine and user interface for applications and libraries based on Zigbee Cluster Library (ZCL)";
69
+
changelog = "https://github.com/project-chip/zap/releases/tag/v${version}";
70
+
license = lib.licenses.asl20;
71
+
maintainers = with lib.maintainers; [ symphorien ];
72
+
mainProgram = "zap-cli";
73
+
};
74
+
}