From 9141ee4eb34296a5dd94d0bda9dd62e2a51eee22 Mon Sep 17 00:00:00 2001 From: Joscha Feth Date: Thu, 21 Nov 2024 11:11:03 +0000 Subject: [PATCH] chore: devenv environment --- .envrc | 3 ++ .gitignore | 11 +++- devenv.lock | 152 ++++++++++++++++++++++++++++++++++++++++++++++++++++ devenv.nix | 57 ++++++++++++++++++++ devenv.yaml | 8 +++ 5 files changed, 230 insertions(+), 1 deletion(-) create mode 100644 .envrc create mode 100644 devenv.lock create mode 100644 devenv.nix create mode 100644 devenv.yaml diff --git a/.envrc b/.envrc new file mode 100644 index 0000000000..894571bf43 --- /dev/null +++ b/.envrc @@ -0,0 +1,3 @@ +source_url "https://raw.githubusercontent.com/cachix/devenv/82c0147677e510b247d8b9165c54f73d32dfd899/direnvrc" "sha256-7u4iDd1nZpxL4tCzmPG0dQgC5V+/44Ba+tHkPob1v2k=" + +use devenv diff --git a/.gitignore b/.gitignore index c88a0f5844..ebbc6803ba 100644 --- a/.gitignore +++ b/.gitignore @@ -143,4 +143,13 @@ tmp local_cache/ # test file for examples are generated and should not be committed -docs/examples/**/test*.py \ No newline at end of file +docs/examples/**/test*.py +# 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 0000000000..425445b0be --- /dev/null +++ b/devenv.lock @@ -0,0 +1,152 @@ +{ + "nodes": { + "devenv": { + "locked": { + "dir": "src/modules", + "lastModified": 1732121232, + "owner": "cachix", + "repo": "devenv", + "rev": "6ff1e5f92c0d74bbb12f7454a239ca2f02e05ea1", + "type": "github" + }, + "original": { + "dir": "src/modules", + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-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": 1716977621, + "owner": "cachix", + "repo": "devenv-nixpkgs", + "rev": "4267e705586473d3e5c8d50299e71503f16a6fb6", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "rolling", + "repo": "devenv-nixpkgs", + "type": "github" + } + }, + "nixpkgs-python": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1730716553, + "owner": "cachix", + "repo": "nixpkgs-python", + "rev": "8fcdb8ec34a1c2bae3f5326873a41b310e948ccc", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "nixpkgs-python", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1731797254, + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e8c38b73aeb218e27163376a2d617e61a2ad9b59", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat_2", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1732021966, + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "3308484d1a443fc5bc92012435d79e80458fe43c", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "nixpkgs": "nixpkgs", + "nixpkgs-python": "nixpkgs-python", + "pre-commit-hooks": "pre-commit-hooks" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 0000000000..1f9a9df992 --- /dev/null +++ b/devenv.nix @@ -0,0 +1,57 @@ +{ pkgs, lib, config, inputs, ... }: + +{ + # https://devenv.sh/packages/ + packages = [ + pkgs.git + pkgs.gnumake + ]; + + # https://devenv.sh/languages/ + languages.python.enable = true; + languages.python.poetry.enable = true; + languages.python.poetry.activate.enable = true; + # languages.python.version = "3.8"; + + # https://devenv.sh/scripts/ + scripts.hello.exec = '' + echo "Run 'setup' to prepare this repository for development" + ''; + scripts.setup.exec = '' + make dev + make help + ''; + + enterShell = '' + hello + ''; + + # https://devenv.sh/tests/ + enterTest = '' + echo "Running tests" + git --version | grep --color=auto "${pkgs.git.version}" + make has-poetry + ''; + + # https://devenv.sh/pre-commit-hooks/ + git-hooks.hooks.lint = { + enable = true; + + # The name of the hook (appears on the report table): + name = "Lint"; + + # The command to execute (mandatory): + entry = "make lint"; + + # The language of the hook - tells pre-commit + # how to install the hook (default: "system") + # see also https://pre-commit.com/#supported-languages + language = "system"; + + # Set this to false to not pass the changed files + # to the command (default: true): + pass_filenames = false; + }; + + # See full reference at https://devenv.sh/reference/options/ +} diff --git a/devenv.yaml b/devenv.yaml new file mode 100644 index 0000000000..22d56b8cbe --- /dev/null +++ b/devenv.yaml @@ -0,0 +1,8 @@ +inputs: + nixpkgs-python: + url: github:cachix/nixpkgs-python + inputs: + nixpkgs: + follows: nixpkgs + nixpkgs: + url: github:cachix/devenv-nixpkgs/rolling