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