diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..d56a237 --- /dev/null +++ b/.envrc @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +eval "$(devenv direnvrc)" +use devenv diff --git a/README.md b/README.md index 857b3bc..b23c6db 100644 --- a/README.md +++ b/README.md @@ -47,29 +47,40 @@ Configuration is loaded from the following paths, in order of priority: 3. `$XDG_CONFIG_HOME/rustpolnak.toml` 4. `~/.config/rustpolnak.toml` -## devenv -1. get nix -2. have `devenv` in your PATH or get it via `nix develop` -3. `devenv shell` -4. `devenv up` to run API and RFID services -5. `cargo run` +## Set up your dev environment +Prerequisites - have `nix` and `devenv` in your system: + +`$ nix shell nixpkgs#devenv` to get `devenv` into your `$PATH` in a temporary shell + +OR + +`$ nix profile add nixpkgs#devenv` to install imperatively to your system + +`$ devenv shell` to enter the dev environment + +Optional: automatically enter the environment via `direnv` +- Have [`direnv`](https://direnv.net/docs/installation.html) in your system +- On first `cd` into this repository, you may need to call `direnv allow` to whitelist this path +- On subsequent `cd` into this repository, `direnv` should pick up automatically and drop you into a `devenv shell` + ## Build & Run -```bash -$ dx serve -``` +Run the app: +`$ devenv up dx` +`$ cargo run` Start testing API server: -```bash -$ cd stubs -$ uv run fastapi dev -``` +`$ devenv up api` + +Create virtual serials `stubs/dev/rfid0` and `stubs/dev/rfid1` and begin publishing TAGs: +`$ devenv up rfid` + +Run `rfiddump` to test RFID readers: +`$ devenv up rfiddump` + +Run both API and virtual RFID: +`$ devenv up api rfid` -Run `rfid.py` to create virtual serials `stubs/dev/rfid0` and `stubs/dev/rfid1` and begin publishing TAGs: -```bash -$ cd stubs -$ uv run rfid.py -``` Run `rfiddump` to test RFID readers: ``` diff --git a/devenv.nix b/devenv.nix index 5ec8422..8fdb91d 100644 --- a/devenv.nix +++ b/devenv.nix @@ -31,7 +31,9 @@ in WEBKIT_DISABLE_COMPOSITING_MODE = 1; }; processes = { + dx.exec = "dx serve"; api.exec = "uv --directory stubs run fastapi dev"; rfid.exec = "uv --directory stubs run rfid.py"; + rfiddump.exec = "cargo run --bin rfiddump"; }; } diff --git a/flake.lock b/flake.lock deleted file mode 100644 index 61c423b..0000000 --- a/flake.lock +++ /dev/null @@ -1,26 +0,0 @@ -{ - "nodes": { - "nixpkgs": { - "locked": { - "lastModified": 1759690006, - "narHash": "sha256-FLNogO1NXuXfqxtF/gnwv16/wJ6H8GjPF/NPNATRoag=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "ca9ec63c6c46c1bcc2d66279e383d22d214f4d13", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/flake.nix b/flake.nix deleted file mode 100644 index 4db744f..0000000 --- a/flake.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ - description = "Get devenv via `nix develop`"; - - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs"; - }; - - outputs = { self, nixpkgs }: - let - system = "x86_64-linux"; - pkgs = import nixpkgs { inherit system; }; - in - { - devShells.${system}.default = pkgs.mkShell { - buildInputs = with pkgs; [ - devenv - # optional if we want direnv later - # direnv - ]; - # Automatically run devenv shell when entering nix develop - shellHook = '' - devenv shell - exit - ''; - }; - }; -}