Skip to content

Commit

Permalink
Add nix flake
Browse files Browse the repository at this point in the history
This will add support for nix flakes. Which really helps with my
development on nixos. This has two basic parts:

1. DEVELOPMENT

After this you can use the following commands on computer with nix and a
patched version of direnv:

direnv allow
devenv up

And it will automatically start and instance of postgresql and mosquitto
for development.

And the environment variables are already configured for teslamate.

So then can start teslamate with:

npm install --prefix ./assets && npm run deploy --prefix ./assets
iex -S mix phx.server

This part is all working as designed. And pretty simple and straight
forward.

2. NIX PACKAGE OF TESLA

This is 99% complete, but some pain points I haven't addressed yet.
Because I don't yet know of good solutions.

* node2nix really does not like having "package.json" refer to file
  installed from mix. For my packages I changed it to pull the files
  from npm. But need to keep the versions in sync with mix. I filled a
  bug report on this: svanderburg/node2nix#323

* node2nix needs to be run every time assets/assets/package-lock.json is
  updated. Yuck.

* There is a checksum in flake.nix that needs to be updated whenever
  mix.lock changes.
  • Loading branch information
brianmay committed Nov 23, 2023
1 parent 40fcda6 commit 190e44c
Show file tree
Hide file tree
Showing 7 changed files with 1,934 additions and 0 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake . --impure
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,5 @@ config/*.env

/priv/plts/*.plt
/priv/plts/*.plt.hash
/.direnv
/.devenv
17 changes: 17 additions & 0 deletions assets/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file has been generated by node2nix 1.11.1. Do not edit!

{pkgs ? import <nixpkgs> {
inherit system;
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs_14"}:

let
nodeEnv = import ./node-env.nix {
inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
inherit pkgs nodejs;
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
};
in
import ./node-packages.nix {
inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
inherit nodeEnv;
}
Loading

0 comments on commit 190e44c

Please sign in to comment.