-
Notifications
You must be signed in to change notification settings - Fork 997
Expand file tree
/
Copy pathpackage.nix
More file actions
116 lines (101 loc) 路 3.33 KB
/
Copy pathpackage.nix
File metadata and controls
116 lines (101 loc) 路 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
{ ... }:
{
perSystem =
{ lib
, pkgs
, system
, ...
}:
let
beamPackages = pkgs.beam.packagesWith pkgs.beam.interpreters.erlang_28;
elixir = beamPackages.elixir_1_19;
rebar3 = beamPackages.rebar3;
src = ../..;
version = builtins.readFile "${src}/VERSION";
pname = "teslamate";
mixFodDeps = beamPackages.fetchMixDeps {
TOP_SRC = src;
pname = "${pname}-mix-deps";
inherit src version;
hash = "sha256-85fMFg+NY4WsdGIRaZ3+/VJI4VJd5RXJMOg185SVxtM="; # if you change the mix deps, you need to update this hash
# hash = pkgs.lib.fakeHash;
};
nodejs = pkgs.nodejs;
nodePackages = pkgs.buildNpmPackage {
name = "${pname}-assets";
src = "${src}/assets";
npmDepsHash = "sha256-CD0IaoMxaBcoAHMJusIn0e0mDo962wLKp6lWjFIb/gI="; # if you change the npm deps, you need to update this hash
# npmDepsHash = pkgs.lib.fakeHash;
dontNpmBuild = true;
inherit nodejs;
installPhase = ''
mkdir $out
cp -r node_modules $out
ln -s $out/node_modules/.bin $out/bin
rm $out/node_modules/phoenix
ln -s ${mixFodDeps}/phoenix $out/node_modules
rm $out/node_modules/phoenix_html
ln -s ${mixFodDeps}/phoenix_html $out/node_modules
rm $out/node_modules/phoenix_live_view
ln -s ${mixFodDeps}/phoenix_live_view $out/node_modules
'';
};
cldr = pkgs.fetchFromGitHub {
owner = "elixir-cldr";
repo = "cldr";
rev = "v2.47.4"; # this must match the version in the mix file
sha256 = "sha256-LIQK6pZRAW1T3Ej2XAjnuPo82hPJ2KiMPWYmHWgx008="; # if you change the cldr version in the mix file, you need to update this hash
# sha256 = pkgs.lib.fakeHash;
};
teslamate = beamPackages.mixRelease {
TOP_SRC = src;
inherit
pname
version
elixir
src
mixFodDeps
;
# set the environment variables for the build
SKIP_LOCALE_DOWNLOAD = "true"; # do not download locales during build as they are already included in the cldr package from github
LOCALES = "${cldr}/priv/cldr";
postBuild = ''
ln -sf ${mixFodDeps}/deps deps
ln -sf ${nodePackages}/node_modules assets/node_modules
export PATH="${pkgs.nodejs}/bin:${nodePackages}/bin:$PATH"
${nodejs}/bin/npm run deploy --prefix ./assets
# for external task you need a workaround for the no deps check flag
# https://github.com/phoenixframework/phoenix/issues/2690
mix do deps.loadpaths --no-deps-check, phx.digest
mix phx.digest --no-deps-check
'';
meta = {
mainProgram = "teslamate";
};
};
in
{
options = {
teslamate.cldr = lib.mkOption {
type = lib.types.package;
readOnly = true;
};
teslamate.elixir = lib.mkOption {
type = lib.types.package;
readOnly = true;
};
teslamate.rebar3 = lib.mkOption {
type = lib.types.package;
readOnly = true;
};
};
config = {
teslamate = {
inherit cldr elixir rebar3;
};
packages = {
default = teslamate;
};
};
};
}