1{
2 lib,
3 stdenv,
4 buildGo124Module,
5 fetchFromGitHub,
6 fetchNpmDeps,
7 cacert,
8 git,
9 go_1_24,
10 gokrazy,
11 enumer,
12 mockgen,
13 nodejs,
14 npmHooks,
15 nix-update-script,
16 nixosTests,
17}:
18
19let
20 version = "0.207.0";
21
22 src = fetchFromGitHub {
23 owner = "evcc-io";
24 repo = "evcc";
25 tag = version;
26 hash = "sha256-gaTY+9MB3nPRD2bOnWYS+vALRR9eHkFNCrEEMspE5ck=";
27 };
28
29 vendorHash = "sha256-cn7zqhBJblDPl7H8BJtWZ2+ckTKVlqBIwwuXNGwrXdk=";
30
31 commonMeta = with lib; {
32 license = licenses.mit;
33 maintainers = with maintainers; [ hexa ];
34 };
35
36 decorate = buildGo124Module {
37 pname = "evcc-decorate";
38 inherit version src vendorHash;
39
40 subPackages = "cmd/decorate";
41
42 meta = commonMeta // {
43 description = "EVCC decorate helper";
44 homepage = "https://github.com/evcc-io/evcc/tree/master/cmd/decorate";
45 };
46 };
47in
48
49buildGo124Module rec {
50 pname = "evcc";
51 inherit version src vendorHash;
52
53 npmDeps = fetchNpmDeps {
54 inherit src;
55 hash = "sha256-yQ+MnXjixNQfWSVnRzmxRtQAvLecdLMDQSXyuIdzGnU=";
56 };
57
58 nativeBuildInputs = [
59 nodejs
60 npmHooks.npmConfigHook
61 ];
62
63 overrideModAttrs = _: {
64 nativeBuildInputs = [
65 decorate
66 enumer
67 go_1_24
68 gokrazy
69 git
70 cacert
71 mockgen
72 ];
73
74 preBuild = ''
75 make assets
76 '';
77 };
78
79 tags = [
80 "release"
81 "test"
82 ];
83
84 ldflags = [
85 "-X github.com/evcc-io/evcc/util.Version=${version}"
86 "-X github.com/evcc-io/evcc/util.Commit=${src.tag}"
87 "-s"
88 "-w"
89 ];
90
91 preBuild = ''
92 make ui
93 '';
94
95 doCheck = !stdenv.hostPlatform.isDarwin; # darwin sandbox limitations around network access, access to /etc/protocols and likely more
96
97 checkFlags =
98 let
99 skippedTests = [
100 # network access
101 "TestOctopusConfigParse"
102 "TestTemplates"
103 "TestOcpp"
104 ];
105 in
106 [ "-skip=^${lib.concatStringsSep "$|^" skippedTests}$" ];
107
108 passthru = {
109 inherit decorate;
110 tests = {
111 inherit (nixosTests) evcc;
112 };
113 updateScript = nix-update-script { };
114 };
115
116 meta = commonMeta // {
117 description = "EV Charge Controller";
118 homepage = "https://evcc.io";
119 changelog = "https://github.com/evcc-io/evcc/releases/tag/${version}";
120 mainProgram = "evcc";
121 };
122}