mirror of
https://github.com/teslamate-org/teslamate.git
synced 2026-01-24 21:06:08 +08:00
* fix(nix): skip duplicate cldr download to fix build on darwin and improve reproducibility fixes: #4761 * docs: update changelog * fix: correct env format to skip duplicate locale download * chore: remove production environment variable from build settings as it defaults to prod
112 lines
3.0 KiB
Nix
112 lines
3.0 KiB
Nix
{ ... }:
|
|
{
|
|
perSystem =
|
|
{ lib
|
|
, pkgs
|
|
, system
|
|
, ...
|
|
}:
|
|
let
|
|
elixir = pkgs.beam.packages.erlang_26.elixir_1_17;
|
|
beamPackages = pkgs.beam.packagesWith pkgs.beam.interpreters.erlang_26;
|
|
|
|
src = ../..;
|
|
version = builtins.readFile "${src}/VERSION";
|
|
pname = "teslamate";
|
|
|
|
mixFodDeps = beamPackages.fetchMixDeps {
|
|
TOP_SRC = src;
|
|
pname = "${pname}-mix-deps";
|
|
inherit src version;
|
|
hash = "sha256-aAHunhPGKRtLQuCGXahcsTajjc6RiizyV1NV71NloHU=";
|
|
# hash = pkgs.lib.fakeHash;
|
|
};
|
|
|
|
nodejs = pkgs.nodejs;
|
|
nodePackages = pkgs.buildNpmPackage {
|
|
name = "${pname}-assets";
|
|
src = "${src}/assets";
|
|
npmDepsHash = "sha256-5bnoGjuFC4jPUkrIsXBHUPCy4nWY7h5fWEWMDoZqaC8=";
|
|
# 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.42.0";
|
|
sha256 = "sha256-FLGUKfAKAKL2nqf/7YXQuuuEvVuSy2RVhZves9XOI1Q=";
|
|
# 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;
|
|
};
|
|
};
|
|
|
|
config = {
|
|
teslamate = {
|
|
inherit cldr elixir;
|
|
};
|
|
|
|
packages = {
|
|
default = teslamate;
|
|
};
|
|
};
|
|
};
|
|
}
|