diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2be92b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result diff --git a/README.md b/README.md new file mode 100644 index 0000000..511d96a --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ +# LightControl + +A custom lightController for the esp32 + +## Installation via Flakes + +### flake.nix + +```nix +inputs = { + ... + lightcontrol.url = + "git+https://tangled.org/tobinio.dev/light-control"; + ... +}; +``` + +### configuration.nix + +```nix +systemd.services.lightcontrol = { + description = "LightControl"; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + + serviceConfig = { + ExecStart = "${inputs.lightcontrol.packages.${pkgs.system}.backend}/bin/backend"; + + Environment = [ + "STATIC_FILES_DIR=${inputs.lightcontrol.packages.${pkgs.system}.frontend}" + ]; + }; +}; +``` diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c06115a --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1785090369, + "narHash": "sha256-m0pDuRJG7EDo9ri+4Ksu83VsI+PlxNC9lNBfydejce4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "624af665418d3c65d544145b4d34ad696439570e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..c5960fd --- /dev/null +++ b/flake.nix @@ -0,0 +1,60 @@ +{ + description = "LightControl Fullstack (Backend + Frontend)"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = { self, nixpkgs }: + let + system = "x86_64-linux"; + pnpm = pkgs.pnpm_11; + pkgs = import nixpkgs { inherit system; }; + in + { + packages.${system} = rec { + frontend = pkgs.stdenv.mkDerivation (finalAttrs: { + pname = "lightcontrol-frontend"; + version = "0.1.0"; + + src = ./frontend; + + nativeBuildInputs = [ + pkgs.nodejs + pkgs.pnpm.configHook + ]; + + pnpmDeps = pkgs.pnpm.fetchDeps { + inherit (finalAttrs) pname version src; + inherit pnpm; + fetcherVersion = 4; + hash = "sha256-UAHcRZkE/4hlEdbuDTqgP04jyYSB22rXEjvqSw3UhF8="; + }; + + buildPhase = '' + runHook preBuild + pnpm build + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + mkdir -p $out + cp -r dist/* $out/ + runHook postInstall + ''; + }); + + backend = pkgs.rustPlatform.buildRustPackage { + pname = "lightcontrol-backend"; + version = "0.1.0"; + + src = ./.; + cargoRoot = "backend"; + buildAndTestSubdir = "backend"; + + cargoHash = "sha256-0lZ8zww0zeq274JymC9ZYLv/GOzzoStY6AyDAx+HjZ8="; + }; + }; + }; +}