chore: migrate development environment from Nix flakes to devenv

Replace Nix flake-based development setup with devenv for better
developer experience and more streamlined environment management.

Changes:
  - Remove flake.nix and flake.lock files
  - Add devenv.nix, devenv.yaml, and devenv.lock configuration
  - Update .envrc to use devenv instead of nix develop
  - Remove Docker development setup (compose.dev.yml, docker/mod.just)
  - Expand .gitignore with comprehensive IDE and OS exclusions
  - Remove Docker-related just commands from justfile
This commit is contained in:
Lucien Cartier-Tilet 2025-06-05 18:37:53 +02:00
parent 7cdaa27f3b
commit ab2d80d2f6
Signed by: phundrak
SSH Key Fingerprint: SHA256:CE0HPsbW3L2YiJETx1zYZ2muMptaAqTN2g3498KrMkc
13 changed files with 243 additions and 200 deletions

9
.envrc
View File

@ -1,2 +1,7 @@
use flake export DIRENV_WARN_TIMEOUT=20s
dotenv_if_exists
eval "$(devenv direnvrc)"
# The use_devenv function supports passing flags to the devenv command
# For example: use devenv --impure --option services.postgres.enable:bool true
use devenv

View File

@ -32,16 +32,16 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Install Nix - name: Install Nix
uses: cachix/install-nix-action@v27 uses: cachix/install-nix-action@v31
with: - name: Install devenv
nix_path: nixpkgs=channel:nixos-unstable run: nix profile install nixpkgs#devenv
- name: Migrate database - name: Migrate database
run: nix develop --command -- just migrate run: devenv shell just migrate
- name: Formatting check - name: Formatting check
run: nix develop --command -- just format-check run: devenv shell just format-check
- name: Lint - name: Lint
run: nix develop --command -- just lint run: devenv shell just lint
- name: Audit - name: Audit
run: nix develop --command -- just audit run: devenv shell just audit
- name: Tests - name: Tests
run: nix develop --command -- just test run: devenv shell just test

51
.gitignore vendored
View File

@ -2,3 +2,54 @@
.env .env
/coverage /coverage
/target /target
# Devenv
.devenv*
devenv.local.nix
# direnv
.direnv
# pre-commit
.pre-commit-config.yaml
# Emacs backup files
*~
\#*\#
.\#*
# Vim files
*.swp
*.swo
*~
# VS Code
.vscode/
*.code-workspace
# JetBrains IDEs
.idea/
*.iml
# macOS
.DS_Store
.AppleDouble
.LSOverride
# Windows
Thumbs.db
ehthumbs.db
Desktop.ini
# Linux
*~
# Temporary files
*.tmp
*.temp
*.log
# OS generated files
.Spotlight-V100
.Trashes
._*

4
Cargo.lock generated
View File

@ -415,7 +415,7 @@ dependencies = [
[[package]] [[package]]
name = "georm" name = "georm"
version = "0.1.0" version = "0.1.1"
dependencies = [ dependencies = [
"georm-macros", "georm-macros",
"rand 0.9.0", "rand 0.9.0",
@ -424,7 +424,7 @@ dependencies = [
[[package]] [[package]]
name = "georm-macros" name = "georm-macros"
version = "0.1.0" version = "0.1.1"
dependencies = [ dependencies = [
"deluxe", "deluxe",
"proc-macro2", "proc-macro2",

View File

@ -628,29 +628,31 @@ bacon test
bacon doc bacon doc
``` ```
#### Nix Development Environment (Optional) #### Devenv Development Environment (Optional)
If you use [Nix](https://nixos.org/), you can use the provided flake for a reproducible development environment: If you use [Nix](https://nixos.org/), you can use the provided devenv configuration for a reproducible development environment:
```bash ```bash
# Enter the development shell with all tools pre-installed # Enter the development shell with all tools pre-installed
nix develop devenv shell
# Or use direnv for automatic environment activation # Or use direnv for automatic environment activation
direnv allow direnv allow
``` ```
The Nix flake provides: The devenv configuration provides:
- Exact Rust version (1.81) with required components - Exact Rust version (1.81) with required components
- All development tools (just, cargo-deny, sqlx-cli, bacon) - All development tools (just, cargo-deny, sqlx-cli, bacon)
- LSP support (rust-analyzer) - LSP support (rust-analyzer)
- SQL tooling (sqls for SQL language server) - SQL tooling (sqls for SQL language server)
- PostgreSQL database for development
**Nix flake contents:** **Devenv configuration:**
- **Rust toolchain**: Specified version with rustfmt, clippy, and rust-analyzer - **Rust toolchain**: Specified version with rustfmt, clippy, and rust-analyzer
- **Development tools**: just, cargo-deny, sqlx-cli, bacon - **Development tools**: just, cargo-deny, sqlx-cli, bacon
- **SQL tools**: sqls (SQL language server) - **SQL tools**: sqls (SQL language server)
- **Platform support**: Currently x86_64-linux (can be extended) - **Database**: PostgreSQL with automatic setup
- **Platform support**: Cross-platform (Linux, macOS, etc.)
#### Database Setup for Tests #### Database Setup for Tests

123
devenv.lock Normal file
View File

@ -0,0 +1,123 @@
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1749054588,
"owner": "cachix",
"repo": "devenv",
"rev": "b6be42d9e6f6053be1d180e4a4fb95e0aa9a8424",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1747046372,
"owner": "edolstra",
"repo": "flake-compat",
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"git-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1747372754,
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "80479b6ec16fefd9c1db3ea13aeb038c60530f46",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"git-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1746807397,
"owner": "cachix",
"repo": "devenv-nixpkgs",
"rev": "c5208b594838ea8e6cca5997fbf784b7cca1ca90",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "rolling",
"repo": "devenv-nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"git-hooks": "git-hooks",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": [
"git-hooks"
],
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1749091064,
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "12419593ce78f2e8e1e89a373c6515885e218acb",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

36
devenv.nix Normal file
View File

@ -0,0 +1,36 @@
{ pkgs, nixpkgs, rust-overlay, ... }:
let
overlays = [ (import rust-overlay) ];
system = pkgs.stdenv.system;
rustPkgs = import nixpkgs { inherit system overlays; };
rustVersion = (rustPkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml);
in {
dotenv.enable = true;
packages = with rustPkgs; [
bacon
cargo-deny
just
postgresql
sqls
sqlx-cli
(rustVersion.override {
extensions = [
"rust-src"
"rustfmt"
"clippy"
"rust-analyzer"
];
})
];
services.postgres = {
enable = true;
listen_addresses = "localhost";
initialScript = ''
CREATE USER georm WITH PASSWORD 'georm' SUPERUSER;
CREATE DATABASE georm OWNER georm;
GRANT ALL PRIVILEGES ON DATABASE georm TO georm;
'';
};
}

8
devenv.yaml Normal file
View File

@ -0,0 +1,8 @@
inputs:
rust-overlay:
url: github:oxalica/rust-overlay
inputs:
nixpkgs:
follows: nixpkgs
nixpkgs:
url: github:cachix/devenv-nixpkgs/rolling

View File

@ -1,33 +0,0 @@
services:
db:
image: postgres:16-alpine
restart: unless-stopped
container_name: georm-backend-db
environment:
POSTGRES_PASSWORD: georm
POSTGRES_USER: georm
POSTGRES_DB: georm
ports:
- 127.0.0.1:5432:5432
volumes:
- georm_backend_db_data:/var/lib/postgresql/data
pgadmin:
image: dpage/pgadmin4:8
restart: unless-stopped
container_name: georm-backend-pgadmin
environment:
PGADMIN_DEFAULT_EMAIL: admin@example.com
PGADMIN_DEFAULT_PASSWORD: password
PGADMIN_DISABLE_POSTFIX: true
PGADMIN_CONFIG_SERVER_MODE: 'False'
ports:
- 127.0.0.1:8080:80
volumes:
- georm_backend_pgadmin_data:/var/lib/pgadmin
depends_on:
- db
volumes:
georm_backend_db_data:
georm_backend_pgadmin_data:

View File

@ -1,14 +0,0 @@
default: start
start:
docker compose -f compose.dev.yml up -d
stop:
docker compose -f compose.dev.yml down
logs:
docker compose -f compose.dev.yml logs -f
## Local Variables:
## mode: makefile
## End:

96
flake.lock generated
View File

@ -1,96 +0,0 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1738142207,
"narHash": "sha256-NGqpVVxNAHwIicXpgaVqJEJWeyqzoQJ9oc8lnK9+WC4=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "9d3ae807ebd2981d593cddd0080856873139aa40",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1736320768,
"narHash": "sha256-nIYdTAiKIGnFNugbomgBJR+Xv5F1ZQU+HfaBqJKroC0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "4bc9c909d9ac828a039f288cf872d16d38185db8",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1738290352,
"narHash": "sha256-YKOHUmc0Clm4tMV8grnxYL4IIwtjTayoq/3nqk0QM7k=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "b031b584125d33d23a0182f91ddbaf3ab4880236",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View File

@ -1,37 +0,0 @@
{
description = "Georm, a simple, opiniated SQLx ORM for PostgreSQL";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = { self, nixpkgs, flake-utils, rust-overlay }:
flake-utils.lib.eachSystem ["x86_64-linux"] (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
rustVersion = (pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml);
in {
devShell = with pkgs; mkShell {
buildInputs = [
bacon
cargo
cargo-deny
just
rust-analyzer
(rustVersion.override {
extensions = [
"rust-src"
"rustfmt"
"clippy"
"rust-analyzer"
];
})
sqls
sqlx-cli
];
};
});
}

View File

@ -1,5 +1,3 @@
mod docker
default: lint default: lint
clean: clean: