From 796f73735fb493238334265296dec8a99ea60cbd Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Thu, 5 Jun 2025 18:37:53 +0200 Subject: [PATCH] chore: switch from flake to devenv --- .envrc | 9 +++- .gitignore | 10 ++++ devenv.lock | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++ devenv.nix | 33 +++++++++++++ devenv.yaml | 8 +++ flake.lock | 96 ----------------------------------- flake.nix | 36 -------------- 7 files changed, 198 insertions(+), 134 deletions(-) create mode 100644 devenv.lock create mode 100644 devenv.nix create mode 100644 devenv.yaml delete mode 100644 flake.lock delete mode 100644 flake.nix diff --git a/.envrc b/.envrc index a96880d..e3c2943 100644 --- a/.envrc +++ b/.envrc @@ -1,2 +1,7 @@ -use flake -dotenv_if_exists +export DIRENV_WARN_TIMEOUT=20s + +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 diff --git a/.gitignore b/.gitignore index 753d933..cada9fb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,13 @@ .env /coverage /target + +# Devenv +.devenv* +devenv.local.nix + +# direnv +.direnv + +# pre-commit +.pre-commit-config.yaml diff --git a/devenv.lock b/devenv.lock new file mode 100644 index 0000000..0f6b877 --- /dev/null +++ b/devenv.lock @@ -0,0 +1,140 @@ +{ + "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" + } + }, + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1749105720, + "owner": "nix-community", + "repo": "fenix", + "rev": "fd217600040e0e7c7ea844af027f3dc1f4b35e6c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "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", + "fenix": "fenix", + "git-hooks": "git-hooks", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": [ + "git-hooks" + ] + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1749033758, + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "55b733103efa59f3504e308629b59d49da69bd9a", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 0000000..269a120 --- /dev/null +++ b/devenv.nix @@ -0,0 +1,33 @@ +{ pkgs, lib, config, inputs, ... }: + +{ + dotenv.enable = true; + + packages = with pkgs; [ + bacon + cargo-deny + just + postgresql + sqls + sqlx-cli + ]; + + # https://devenv.sh/languages/ + languages.rust = { + enable = true; + channel = "stable"; + }; + + services.postgres = { + enable = true; + initialScript = '' + CREATE USER georm WITH PASSWORD 'georm'; + CREATE DATABASE georm OWNER georm; + GRANT ALL PRIVILEGES ON DATABASE georm TO georm; + \c georm; + GRANT ALL ON SCHEMA public TO georm; + GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO georm; + GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO georm; +''; + }; +} diff --git a/devenv.yaml b/devenv.yaml new file mode 100644 index 0000000..1d18075 --- /dev/null +++ b/devenv.yaml @@ -0,0 +1,8 @@ +inputs: + fenix: + url: github:nix-community/fenix + inputs: + nixpkgs: + follows: nixpkgs + nixpkgs: + url: github:cachix/devenv-nixpkgs/rolling diff --git a/flake.lock b/flake.lock deleted file mode 100644 index 265e37c..0000000 --- a/flake.lock +++ /dev/null @@ -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 -} diff --git a/flake.nix b/flake.nix deleted file mode 100644 index b00068c..0000000 --- a/flake.nix +++ /dev/null @@ -1,36 +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-deny - just - rust-analyzer - (rustVersion.override { - extensions = [ - "rust-src" - "rustfmt" - "clippy" - "rust-analyzer" - ]; - }) - sqls - sqlx-cli - ]; - }; - }); -}