mirror of
https://github.com/teslamate-org/teslamate.git
synced 2026-01-24 21:06:08 +08:00
* flake.lock: Update
Flake lock file updates:
• Updated input 'devenv':
'github:cachix/devenv/6599a8c6d02c1d37fe5b7804f70a39c262298729?narHash=sha256-045veG11u/fdRjYI%2B9dc19/u/14j7UFitwKWisE11Iw%3D' (2025-04-18)
→ 'github:cachix/devenv/c7f2256ee4a4a4ee9cbf1e82a6e49b253c374995?narHash=sha256-tk2mRZAf8C5uOkMVJHemJ3ld09CYVp/z94/lHqsQ8ZA%3D' (2025-05-20)
• Updated input 'devenv/cachix':
'github:cachix/cachix/a624d3eaf4b1d225f918de8543ed739f2f574203?narHash=sha256-D0gP8srrX0qj%2BwNYNPdtVJsQuFzIng3q43thnHXQ/es%3D' (2025-03-15)
→ 'github:cachix/cachix/8a60090640b96f9df95d1ab99e5763a586be1404?narHash=sha256-pb5aYkE8FOoa4n123slgHiOf1UbNSnKe5pEZC%2BxXD5g%3D' (2025-04-09)
• Updated input 'devenv/git-hooks':
'github:cachix/git-hooks.nix/dcf5072734cb576d2b0c59b2ac44f5050b5eac82?narHash=sha256-DwOTp7nvfi8mRfuL1escHDXabVXFGT1VlPD1JHrtrco%3D' (2025-03-22)
→ 'github:cachix/git-hooks.nix/fa466640195d38ec97cf0493d6d6882bc4d14969?narHash=sha256-Wb2xeSyOsCoTCTj7LOoD6cdKLEROyFAArnYoS%2BnoCWo%3D' (2025-05-06)
• Updated input 'devenv/nix':
'github:domenkozar/nix/f3f44b2baaf6c4c6e179de8cbb1cc6db031083cd?narHash=sha256-E3j%2B3MoY8Y96mG1dUIiLFm2tZmNbRvSiyN7CrSKuAVg%3D' (2025-03-12)
→ 'github:domenkozar/nix/b455edf3505f1bf0172b39a735caef94687d0d9c?narHash=sha256-bYyjarS3qSNqxfgc89IoVz8cAFDkF9yPE63EJr%2Bh50s%3D' (2025-04-29)
• Updated input 'devenv/nixpkgs':
'github:cachix/devenv-nixpkgs/7bd9e84d0452f6d2e63b6e6da29fe73fac951857?narHash=sha256-qamMCz5mNpQmgBwc8SB5tVMlD5sbwVIToVZtSxMph9s%3D' (2024-12-06)
→ 'github:cachix/devenv-nixpkgs/c5208b594838ea8e6cca5997fbf784b7cca1ca90?narHash=sha256-zU2z0jlkJGWLhdNr/8AJSxqK8XD0IlQgHp3VZcP56Aw%3D' (2025-05-09)
• Updated input 'nixpkgs':
'github:NixOS/nixpkgs/26d499fc9f1d567283d5d56fcf367edd815dba1d?narHash=sha256-FHlSkNqFmPxPJvy%2B6fNLaNeWnF1lZSgqVCl/eWaJRc4%3D' (2025-04-12)
→ 'github:NixOS/nixpkgs/2baa12ff69913392faf0ace833bc54bba297ea95?narHash=sha256-U4HaNZ1W26cbOVm0Eb5OdGSnfQVWQKbLSPrSSa78KC0%3D' (2025-05-21)
• Updated input 'treefmt-nix':
'github:numtide/treefmt-nix/8d404a69efe76146368885110f29a2ca3700bee6?narHash=sha256-aRmUh0AMwcbdjJHnytg1e5h5ECcaWtIFQa6d9gI85AI%3D' (2025-04-18)
→ 'github:numtide/treefmt-nix/020cb423808365fa3f10ff4cb8c0a25df35065a3?narHash=sha256-XgxghfND8TDypxsMTPU2GQdtBEsHTEc3qWE6RVEk8O0%3D' (2025-05-22)
* style: linter findings
* feat(nix): use nixos-25.05
* chore(nix): update treefmt-nix dependency
* feat(nix): use postgreSQL 17 in devenv
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jakob Lichterfeld <jakob-lichterfeld@gmx.de>
103 lines
3.1 KiB
Nix
103 lines
3.1 KiB
Nix
{ inputs, ... }:
|
|
{
|
|
imports = [
|
|
inputs.devenv.flakeModule
|
|
];
|
|
|
|
perSystem =
|
|
{ config
|
|
, pkgs
|
|
, lib
|
|
, ...
|
|
}:
|
|
# legacy
|
|
let
|
|
inherit (lib) optional optionals;
|
|
|
|
elixir = config.teslamate.elixir;
|
|
|
|
nodejs = pkgs.nodejs;
|
|
|
|
postgres_port = 7000;
|
|
mosquitto_port = 7001;
|
|
process_compose_port = 7002;
|
|
|
|
psql = pkgs.writeShellScriptBin "teslamate_psql" ''
|
|
exec "${pkgs.postgresql}/bin/psql" --host "$DATABASE_HOST" --user "$DATABASE_USER" --port "$DATABASE_PORT" "$DATABASE_NAME" "$@"
|
|
'';
|
|
mosquitto_sub = pkgs.writeShellScriptBin "teslamate_sub" ''
|
|
exec "${pkgs.mosquitto}/bin/mosquitto_sub" -h "$MQTT_HOST" -p "$MQTT_PORT" -u "$MQTT_USERNAME" -P "$MQTT_PASSWORD" "$@"
|
|
'';
|
|
|
|
devenv = {
|
|
containers = lib.mkForce { }; # https://github.com/cachix/devenv/issues/760
|
|
devenv.root =
|
|
let
|
|
devenvRootFileContent = builtins.readFile inputs.devenv-root.outPath;
|
|
in
|
|
pkgs.lib.mkIf (devenvRootFileContent != "") devenvRootFileContent;
|
|
packages =
|
|
with pkgs; [
|
|
elixir
|
|
elixir_ls
|
|
node2nix
|
|
nodejs
|
|
prefetch-npm-deps
|
|
# for dashboard scripts
|
|
jq
|
|
psql
|
|
mosquitto
|
|
mosquitto_sub
|
|
config.treefmt.build.wrapper
|
|
]
|
|
++ builtins.attrValues config.treefmt.build.programs
|
|
++ optionals stdenv.isLinux [
|
|
inotify-tools
|
|
glibcLocales
|
|
]
|
|
++ optional stdenv.isDarwin terminal-notifier;
|
|
enterShell = ''
|
|
export LOCALES="${config.teslamate.cldr}/priv/cldr";
|
|
export PORT="4000"
|
|
export ENCRYPTION_KEY="your_secure_encryption_key_here"
|
|
export DATABASE_USER="teslamate"
|
|
export DATABASE_PASS="your_secure_password_here"
|
|
export DATABASE_NAME="teslamate"
|
|
export DATABASE_HOST="127.0.0.1"
|
|
export DATABASE_PORT="${toString postgres_port}"
|
|
export MQTT_HOST="127.0.0.1"
|
|
export MQTT_PORT="${toString mosquitto_port}"
|
|
export RELEASE_COOKIE="1234567890123456789"
|
|
export TZDATA_DIR="$PWD/tzdata"
|
|
export MIX_REBAR3="${pkgs.rebar3}/bin/rebar3";
|
|
mix deps.get
|
|
'';
|
|
enterTest = ''
|
|
mix test
|
|
'';
|
|
processes.mqtt = {
|
|
exec = "${pkgs.mosquitto}/bin/mosquitto -p ${toString mosquitto_port}";
|
|
};
|
|
process.managers.process-compose = {
|
|
port = process_compose_port;
|
|
tui.enable = true;
|
|
};
|
|
services.postgres = {
|
|
enable = true;
|
|
package = pkgs.postgresql;
|
|
listen_addresses = "127.0.0.1";
|
|
port = postgres_port;
|
|
initialDatabases = [{ name = "teslamate"; }];
|
|
initialScript = ''
|
|
CREATE USER teslamate with encrypted password 'your_secure_password_here';
|
|
GRANT ALL PRIVILEGES ON DATABASE teslamate TO teslamate;
|
|
ALTER USER teslamate WITH SUPERUSER;
|
|
'';
|
|
};
|
|
};
|
|
in
|
|
{
|
|
devenv.shells.default = devenv;
|
|
};
|
|
}
|