From 5d607d9ab619104e1c78f7c428efd2143ea02441 Mon Sep 17 00:00:00 2001 From: Federico Zambelli Date: Wed, 16 Oct 2024 10:57:53 +0200 Subject: [PATCH] feat: improve base and python template - Use Ruff as linter and formatter - Add isort to linting rules - Add script to base template to print available commands - Improve jinja block formatting - Bundle all scripts under single `script` object for readability --- includes/base.nix.jinja | 51 +++++++++++++++---- .../devenv.nix.jinja | 42 +++++++-------- .../pyproject.toml.jinja | 3 +- 3 files changed, 64 insertions(+), 32 deletions(-) diff --git a/includes/base.nix.jinja b/includes/base.nix.jinja index 766cdff..9bc1e60 100644 --- a/includes/base.nix.jinja +++ b/includes/base.nix.jinja @@ -6,22 +6,45 @@ ... }: -{% block variables %}{% endblock %} +{% block variables %}{% endblock -%} + { name = "{{ project_name | replace('_', '-')}}"; # https://devenv.sh/basics/ env = { GREET = "🛠️ Let's hack "; - {% block env %}{% endblock %} + {%- block env %}{% endblock %} }; # https://devenv.sh/scripts/ - scripts.hello.exec = "echo $GREET"; - scripts.cat.exec = '' - bat "$@"; - ''; + scripts = { + hello.exec = "echo $GREET"; + cat.exec = "bat $@"; - {% block script %}{% endblock %} + show = { + # Prints scripts that have a description + # Adapted from https://github.com/cachix/devenv/blob/ef61728d91ad5eb91f86cdbcc16070602e7afa16/examples/scripts/devenv.nix#L34 + exec = '' + GREEN="\033[0;32m"; + YELLOW="\033[33m"; + NC="\033[0m"; + echo + echo -e "✨ Helper scripts you can run to make your development richer:" + echo + ${pkgs.gnused}/bin/sed -e 's| |••|g' -e 's|=| |' <