From 1e130ff5b7af3d39f6c69cf687b2a94d5b1f3d03 Mon Sep 17 00:00:00 2001 From: use-the-fork Date: Tue, 2 Jul 2024 19:48:12 -0400 Subject: [PATCH 01/13] feat(just-integrations): add several new recipes for tasks such as formatting, testing, generating change logs, and managing processes --- .../integrations/just/recipe-module.nix | 43 ++++++ .../integrations/just/recipes/convco.nix | 37 +++++ .../just/recipes/devenv-script.nix | 42 ++++++ .../integrations/just/recipes/devenv-up.nix | 24 ++++ .../integrations/just/recipes/git-cliff.nix | 132 ++++++++++++++++++ .../integrations/just/recipes/rust.nix | 27 ++++ .../integrations/just/recipes/treefmt.nix | 33 +++++ 7 files changed, 338 insertions(+) create mode 100644 src/modules/integrations/just/recipe-module.nix create mode 100644 src/modules/integrations/just/recipes/convco.nix create mode 100644 src/modules/integrations/just/recipes/devenv-script.nix create mode 100644 src/modules/integrations/just/recipes/devenv-up.nix create mode 100644 src/modules/integrations/just/recipes/git-cliff.nix create mode 100644 src/modules/integrations/just/recipes/rust.nix create mode 100644 src/modules/integrations/just/recipes/treefmt.nix diff --git a/src/modules/integrations/just/recipe-module.nix b/src/modules/integrations/just/recipe-module.nix new file mode 100644 index 000000000..c2435c80d --- /dev/null +++ b/src/modules/integrations/just/recipe-module.nix @@ -0,0 +1,43 @@ +{ config, name, lib, pkgs, ... }: +let + inherit (lib) mkOption mkEnableOption types; + +in +{ + options = { + enable = mkEnableOption "this recipe"; + justfile = mkOption { + type = types.either types.str types.path; + description = '' + The justfile representing this recipe. + ''; + apply = x: + if builtins.isPath x then x else + pkgs.writeTextFile { + name = "${name}.just"; + text = x; + }; + }; + package = mkOption { + type = types.nullOr types.package; + default = null; + description = lib.mdDoc + '' + An optional package that provides the recipe. + ''; + }; + outputs.justfile = mkOption { + type = types.str; + readOnly = true; + description = '' + The justfile code for importing this recipe's justfile. + + See https://just.systems/man/en/chapter_53.html + ''; + default = + if config.enable + then "import '${builtins.toString config.justfile}'" + else ""; + }; + }; +} diff --git a/src/modules/integrations/just/recipes/convco.nix b/src/modules/integrations/just/recipes/convco.nix new file mode 100644 index 000000000..4101e144e --- /dev/null +++ b/src/modules/integrations/just/recipes/convco.nix @@ -0,0 +1,37 @@ +{ pkgs, lib, config, ... }: + +let + inherit (lib) types mkOption mkEnableOption; + inherit (import ../utils.nix { inherit lib pkgs; }) recipeModule recipeType; + +in +{ + options.just.recipes.convco = mkOption { + description = "Add the 'changelog' target calling convco"; + type = types.submodule { + imports = [ recipeModule ]; + options.settings = { + file-name = + mkOption { + type = types.str; + description = lib.mdDoc "The name of the file to output the chaneglog to."; + default = "CHANGELOG.md"; + }; + }; + }; + }; + + config.just.recipes.convco = lib.mkIf config.just.enable { + package = lib.mkDefault pkgs.convco; + justfile = + let + binPath = lib.getExe config.just.recipes.convco.package; + fileName = config.just.recipes.convco.settings.file-name; + in + lib.mkDefault '' + # Generate ${fileName} using recent commits + changelog: + ${binPath} changelog -p "" > ${fileName} + ''; + }; +} diff --git a/src/modules/integrations/just/recipes/devenv-script.nix b/src/modules/integrations/just/recipes/devenv-script.nix new file mode 100644 index 000000000..d16212e4d --- /dev/null +++ b/src/modules/integrations/just/recipes/devenv-script.nix @@ -0,0 +1,42 @@ +{ pkgs, lib, config, ... }: + +let + inherit (lib) types mkOption mkEnableOption; + inherit (import ../utils.nix { inherit lib pkgs; }) recipeModule recipeType; + + devenvScriptRecipes = lib.genAttrs (builtins.attrNames config.scripts) (name: + let + script = config.scripts.${name}; + in + mkOption { + description = script.description; + type = types.submodule { + imports = [ recipeModule ]; + }; + }); + +in +{ + options = { + just = { + recipes = devenvScriptRecipes; + }; + }; + + config = lib.mkIf config.just.enable { + just = { + recipes = lib.genAttrs (builtins.attrNames config.scripts) (name: + let + script = config.scripts.${name}; + in + { + enable = lib.mkDefault script.just.enable; + justfile = lib.mkDefault '' + #${script.description} + ${name}: + ${name} + ''; + }); + }; + }; +} diff --git a/src/modules/integrations/just/recipes/devenv-up.nix b/src/modules/integrations/just/recipes/devenv-up.nix new file mode 100644 index 000000000..50ec11cbe --- /dev/null +++ b/src/modules/integrations/just/recipes/devenv-up.nix @@ -0,0 +1,24 @@ +{ pkgs, lib, config, ... }: + +let + inherit (lib) types mkOption mkEnableOption; + inherit (import ../utils.nix { inherit lib pkgs; }) recipeModule recipeType; + +in +{ + options.just.recipes.up = mkOption { + description = "Starts processes in foreground. See http://devenv.sh/processes"; + type = types.submodule { + imports = [ recipeModule ]; + }; + }; + + config.just.recipes.up = lib.mkIf config.just.enable { + enable = lib.mkDefault true; + justfile = lib.mkDefault '' + # Starts processes in foreground. See http://devenv.sh/processes + up: + devenv up + ''; + }; +} diff --git a/src/modules/integrations/just/recipes/git-cliff.nix b/src/modules/integrations/just/recipes/git-cliff.nix new file mode 100644 index 000000000..a3f14046a --- /dev/null +++ b/src/modules/integrations/just/recipes/git-cliff.nix @@ -0,0 +1,132 @@ +{ pkgs, lib, config, ... }: + +let + inherit (lib) types mkOption mkEnableOption; + inherit (import ../utils.nix { inherit lib pkgs; }) recipeModule recipeType; + + cfg = config.just.recipes.git-cliff; + fileName = cfg.settings.file-name; + + git-cliff-config = pkgs.writeTextFile { + name = "cliff.toml"; + text = cfg.settings.config-file; + }; + + git-cliff-entry = pkgs.writeShellScriptBin "git-cliff" '' + ${lib.optionalString cfg.settings.integrations.github.enable '' + # Get the remote URL + REMOTE_URL=$(git config --get remote.origin.url) + + # Extract the owner and repo name from the URL + if [[ $REMOTE_URL =~ ^https://github.com/(.*)/(.*)\.git$ ]]; then + OWNER=''${BASH_REMATCH[1]} + REPO=''${BASH_REMATCH[2]} + elif [[ $REMOTE_URL =~ ^git@github.com:(.*)/(.*)\.git$ ]]; then + OWNER=''${BASH_REMATCH[1]} + REPO=''${BASH_REMATCH[2]} + else + echo "Unsupported remote URL format: $REMOTE_URL" + exit 1 + fi + + # Combine owner and repo name + GITHUB_REPO="$OWNER/$REPO" + ''} + + ${lib.getExe' cfg.package "git-cliff"} \ + --output ${fileName} \ + --config ${git-cliff-config.outPath} + ''; + +in +{ + options.just.recipes.git-cliff = mkOption { + description = "Add the 'changelog' target calling convco"; + type = types.submodule { + imports = [ recipeModule ]; + options.settings = { + file-name = + mkOption { + type = types.str; + description = lib.mdDoc "The name of the file to output the chaneglog to."; + default = "CHANGELOG.md"; + }; + + config-file = mkOption { + type = types.str; + description = '' + The git-cliff config to use. + + See https://git-cliff.org/docs/configuration/ + ''; + default = '' + [changelog] + header = """ + # Changelog\n + All notable changes to this project will be documented in this file.\n + """ + body = """ + {% if version %}\ + ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} + {% else %}\ + ## [unreleased] + {% endif %}\ + {% for group, commits in commits | group_by(attribute="group") %} + ### {{ group | striptags | trim | upper_first }} + {% for commit in commits %} + - {% if commit.scope %}*({{ commit.scope }})* {% endif %}\ + {% if commit.breaking %}[**breaking**] {% endif %}\ + {{ commit.message | upper_first }}\ + {% endfor %} + {% endfor %}\n + """ + # template for the changelog footer + footer = """ + + """ + # remove the leading and trailing s + trim = true + + [git] + conventional_commits = true + filter_unconventional = true + split_commits = false + commit_parsers = [ + { message = "^feat", group = "🚀 Features" }, + { message = "^fix", group = "🐛 Bug Fixes" }, + { message = "^doc", group = "📚 Documentation" }, + { message = "^perf", group = "⚡ Performance" }, + { message = "^refactor", group = "🚜 Refactor" }, + { message = "^style", group = "🎨 Styling" }, + { message = "^test", group = "🧪 Testing" }, + { message = "^chore\\(release\\): prepare for", skip = true }, + { message = "^chore\\(deps.*\\)", skip = true }, + { message = "^chore\\(pr\\)", skip = true }, + { message = "^chore\\(pull\\)", skip = true }, + { message = "^chore|^ci", group = "⚙️ Miscellaneous Tasks" }, + { body = ".*security", group = "🛡️ Security" }, + { message = "^revert", group = "◀️ Revert" }, + ] + protect_breaking_commits = false + filter_commits = false + topo_order = false + sort_commits = "oldest" + ''; + }; + integrations = { + github.enable = mkEnableOption "Enable the GitHub integration. See https://git-cliff.org/docs/integration/github"; + }; + }; + }; + }; + + config.just.recipes.git-cliff = lib.mkIf config.just.enable { + package = lib.mkDefault pkgs.git-cliff; + justfile = lib.mkDefault + '' + # Generate ${fileName} using recent commits + changelog: + ${git-cliff-entry}/bin/git-cliff + ''; + }; +} diff --git a/src/modules/integrations/just/recipes/rust.nix b/src/modules/integrations/just/recipes/rust.nix new file mode 100644 index 000000000..76b427bcc --- /dev/null +++ b/src/modules/integrations/just/recipes/rust.nix @@ -0,0 +1,27 @@ +{ pkgs, lib, config, ... }: + +let + inherit (lib) types mkOption mkEnableOption; + inherit (import ../utils.nix { inherit lib pkgs; }) recipeModule recipeType; + +in +{ + options.just.recipes.rust = mkOption { + description = "Add 'w' and 'test' targets for running cargo"; + type = types.submodule { + imports = [ recipeModule ]; + }; + }; + + config.just.recipes.rust = lib.mkIf config.just.enable { + justfile = lib.mkDefault '' + # Compile and watch the project + w: + cargo watch + + # Run and watch 'cargo test' + test: + cargo watch -s "cargo test" + ''; + }; +} diff --git a/src/modules/integrations/just/recipes/treefmt.nix b/src/modules/integrations/just/recipes/treefmt.nix new file mode 100644 index 000000000..567bf0b15 --- /dev/null +++ b/src/modules/integrations/just/recipes/treefmt.nix @@ -0,0 +1,33 @@ +{ pkgs, lib, config, ... }: + +let + inherit (lib) types mkOption mkEnableOption; + inherit (lib.lists) optionals; + inherit (import ../utils.nix { inherit lib pkgs; }) recipeModule recipeType; + +in +{ + options.just.recipes.treefmt = mkOption { + description = "Add the 'fmt' target to format source tree using treefmt"; + type = types.submodule { + imports = [ recipeModule ]; + }; + }; + + config = lib.mkIf config.just.enable { + warnings = optionals ((lib.filterAttrs (id: value: value.enable) config.treefmt.programs) == { }) [ + '' + You have enabled the Just runner for treefmt but do not have any formatters enabled. + '' + ]; + + just.recipes.treefmt = { + package = lib.mkDefault config.treefmt.build.wrapper; + justfile = lib.mkDefault '' + # Auto-format the source tree using treefmt + fmt: + ${lib.getExe config.just.recipes.treefmt.package} + ''; + }; + }; +} From bb0e23ca2d26f8d6709e9f1e54cee4ee708705e8 Mon Sep 17 00:00:00 2001 From: use-the-fork Date: Tue, 2 Jul 2024 19:34:41 -0400 Subject: [PATCH 02/13] feat(integrations): add just command runner to default.nix --- src/modules/integrations/just/default.nix | 76 +++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/modules/integrations/just/default.nix diff --git a/src/modules/integrations/just/default.nix b/src/modules/integrations/just/default.nix new file mode 100644 index 000000000..d86976eaf --- /dev/null +++ b/src/modules/integrations/just/default.nix @@ -0,0 +1,76 @@ +# This largely inspired by the use of freeformType in +# https://github.com/cachix/git-hooks.nix/blob/master/modules/hooks.nix +# as well as https://github.com/juspay/just-flake/tree/main +{ pkgs, lib, config, ... }: + +let + inherit (lib) types mkOption mkEnableOption attrsets; + inherit (import ./utils.nix { inherit lib pkgs; }) recipeModule recipeType; + + version = lib.fileContents ./../../latest-version; + + # Returns a list of all the entries in a folder + listEntries = path: + map (name: path + "/${name}") (builtins.attrNames (builtins.readDir path)); + + +in +{ + + imports = [{ + options.just.recipes = mkOption { + type = types.submoduleWith { + modules = [{ freeformType = types.attrsOf recipeType; }]; + specialArgs = { inherit pkgs; }; + }; + default = { }; + }; + }] + ++ (listEntries ./recipes); + + options.just = { + enable = mkEnableOption "the just command runner"; + + package = mkOption { + type = types.package; + default = pkgs.just; + defaultText = lib.literalExpression "pkgs.just"; + description = "The just package to use."; + }; + + commonFileName = mkOption { + type = types.str; + default = "just-flake.just"; + description = '' + The name of the common justfile generated by this module. + ''; + }; + + }; + + config = lib.mkIf config.just.enable { + + packages = [ + config.just.package + ]; + + enterShell = + let + commonJustfile = pkgs.writeTextFile { + name = "justfile"; + text = + lib.concatStringsSep "\n" + (lib.mapAttrsToList (name: recipe: recipe.outputs.justfile) config.just.recipes); + }; + in + '' + ln -sf ${builtins.toString commonJustfile} ./${config.just.commonFileName} + + echo + echo "https://devenv.sh (version ${version}): Fast, Declarative, Reproducible, and Composable Developer Environments 🦾🦾" + echo + echo "Run 'just ' to get started" + just --list + ''; + }; +} From 97c73e2b783d484f450f1071b2d04f10ff2a69fa Mon Sep 17 00:00:00 2001 From: use-the-fork Date: Thu, 20 Jun 2024 17:49:11 -0400 Subject: [PATCH 03/13] feat(cli): add justfile to scaffold command description (cherry picked from commit 08880184b1906bcd88971be258df032715f3986d) --- devenv/src/cli.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devenv/src/cli.rs b/devenv/src/cli.rs index ae1a7e8b5..5816deefd 100644 --- a/devenv/src/cli.rs +++ b/devenv/src/cli.rs @@ -107,7 +107,7 @@ impl Default for GlobalOptions { #[derive(Subcommand, Clone)] pub(crate) enum Commands { - #[command(about = "Scaffold devenv.yaml, devenv.nix, .gitignore and .envrc.")] + #[command(about = "Scaffold devenv.yaml, devenv.nix, .gitignore .envrc and justfile.")] Init { target: Option, }, From 3268c608ef99185b6435260ab259f57959ada855 Mon Sep 17 00:00:00 2001 From: use-the-fork Date: Thu, 20 Jun 2024 17:50:09 -0400 Subject: [PATCH 04/13] feat(devenv): add 'justfile' to REQUIRED_FILES array (cherry picked from commit df5d9cfdb30c5cd0c66c5c87ac8221950f6ecfa2) --- devenv/src/devenv.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/devenv/src/devenv.rs b/devenv/src/devenv.rs index 12a0da387..0372226d5 100644 --- a/devenv/src/devenv.rs +++ b/devenv/src/devenv.rs @@ -19,7 +19,13 @@ use std::{ // templates const FLAKE_TMPL: &str = include_str!("flake.tmpl.nix"); -const REQUIRED_FILES: [&str; 4] = ["devenv.nix", "devenv.yaml", ".envrc", ".gitignore"]; +const REQUIRED_FILES: [&str; 5] = [ + "devenv.nix", + "devenv.yaml", + ".envrc", + ".gitignore", + "justfile", +]; const EXISTING_REQUIRED_FILES: [&str; 1] = [".gitignore"]; const PROJECT_DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/init"); // project vars From d7f3aeea5a938e41e81e2d27f87f44646689bfaa Mon Sep 17 00:00:00 2001 From: use-the-fork Date: Thu, 20 Jun 2024 17:50:50 -0400 Subject: [PATCH 05/13] feat(devenv/init): add new justfile for displaying list of recipes (cherry picked from commit c471deb754fcdcb199b9be54f6b698dbcdfc06d2) --- devenv/init/justfile | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 devenv/init/justfile diff --git a/devenv/init/justfile b/devenv/init/justfile new file mode 100644 index 000000000..434376193 --- /dev/null +++ b/devenv/init/justfile @@ -0,0 +1,5 @@ +import 'just-flake.just' + +# Display the list of recipes +default: + @just --list From c0fc5425f89827acb2da6358b8c2c74f1d328854 Mon Sep 17 00:00:00 2001 From: use-the-fork Date: Thu, 20 Jun 2024 20:04:33 -0400 Subject: [PATCH 06/13] feat(scripts.nix): add 'just' option to include script in just runner (cherry picked from commit 13ce3c1200013ec3bf11671f5aab8d1cafa17aac) --- src/modules/scripts.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/modules/scripts.nix b/src/modules/scripts.nix index c74ece408..1727f5374 100644 --- a/src/modules/scripts.nix +++ b/src/modules/scripts.nix @@ -29,6 +29,13 @@ let description = "Description of the script."; default = ""; }; + just = { + enable = lib.mkOption { + type = types.bool; + description = "Include this script in just runner."; + default = true; + }; + }; scriptPackage = lib.mkOption { internal = true; type = types.package; From 3e176f51259e6ff92c20b1334609ac05dccac9a8 Mon Sep 17 00:00:00 2001 From: use-the-fork Date: Thu, 20 Jun 2024 20:04:42 -0400 Subject: [PATCH 07/13] feat(justfile): add new file to display list of recipes (cherry picked from commit 43263eb8ca60796c958c54669da1019e4f94f91b) --- justfile | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 justfile diff --git a/justfile b/justfile new file mode 100644 index 000000000..434376193 --- /dev/null +++ b/justfile @@ -0,0 +1,5 @@ +import 'just-flake.just' + +# Display the list of recipes +default: + @just --list From 4b3fa86943c000760f116ce4178b3ef31bb84fa5 Mon Sep 17 00:00:00 2001 From: use-the-fork Date: Thu, 20 Jun 2024 20:06:52 -0400 Subject: [PATCH 08/13] feat(devenv.nix): enable convco feature manually (cherry picked from commit 6fde521c53cfc1c735898e3000ea234d3d251e0c) --- devenv.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/devenv.nix b/devenv.nix index 40b439716..de131646c 100644 --- a/devenv.nix +++ b/devenv.nix @@ -33,6 +33,9 @@ devcontainer.settings.customizations.vscode.extensions = [ "jnoortheen.nix-ide" ]; difftastic.enable = true; + #enable convco manually. + just.features.convco.enable = true; + dotenv.enable = true; processes = { From fd3686c9c72955e435fbe452b55bc547cd1ce84e Mon Sep 17 00:00:00 2001 From: use-the-fork Date: Wed, 3 Jul 2024 17:23:06 -0400 Subject: [PATCH 09/13] feat(integrations): add new utils.nix module with recipeModule and mkCmdArgs functions --- src/modules/integrations/just/utils.nix | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/modules/integrations/just/utils.nix diff --git a/src/modules/integrations/just/utils.nix b/src/modules/integrations/just/utils.nix new file mode 100644 index 000000000..9dcbbab46 --- /dev/null +++ b/src/modules/integrations/just/utils.nix @@ -0,0 +1,24 @@ +{ lib, pkgs, ... }: +let + inherit (lib) types; + inherit (lib.attrsets) recursiveUpdate; + + recipeModule = { + imports = [ ./recipe-module.nix ]; + config._module.args = { inherit pkgs; }; + }; + recipeType = types.submodule recipeModule; + + mkCmdArgs = predActionList: + lib.concatStringsSep + " " + (builtins.foldl' + (acc: entry: + acc ++ lib.optional (builtins.elemAt entry 0) (builtins.elemAt entry 1)) + [ ] + predActionList); + +in +{ + inherit mkCmdArgs recipeModule recipeType; +} From e4f1ecacc0a9340d7c1e90542c3cf06a2f93a029 Mon Sep 17 00:00:00 2001 From: use-the-fork Date: Wed, 3 Jul 2024 17:23:23 -0400 Subject: [PATCH 10/13] chore(integrations): remove treefmt recipe from Just module --- .../integrations/just/recipes/treefmt.nix | 33 ------------------- 1 file changed, 33 deletions(-) delete mode 100644 src/modules/integrations/just/recipes/treefmt.nix diff --git a/src/modules/integrations/just/recipes/treefmt.nix b/src/modules/integrations/just/recipes/treefmt.nix deleted file mode 100644 index 567bf0b15..000000000 --- a/src/modules/integrations/just/recipes/treefmt.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ pkgs, lib, config, ... }: - -let - inherit (lib) types mkOption mkEnableOption; - inherit (lib.lists) optionals; - inherit (import ../utils.nix { inherit lib pkgs; }) recipeModule recipeType; - -in -{ - options.just.recipes.treefmt = mkOption { - description = "Add the 'fmt' target to format source tree using treefmt"; - type = types.submodule { - imports = [ recipeModule ]; - }; - }; - - config = lib.mkIf config.just.enable { - warnings = optionals ((lib.filterAttrs (id: value: value.enable) config.treefmt.programs) == { }) [ - '' - You have enabled the Just runner for treefmt but do not have any formatters enabled. - '' - ]; - - just.recipes.treefmt = { - package = lib.mkDefault config.treefmt.build.wrapper; - justfile = lib.mkDefault '' - # Auto-format the source tree using treefmt - fmt: - ${lib.getExe config.just.recipes.treefmt.package} - ''; - }; - }; -} From 9ea054923b765252ee4b5c0e7e58234190f5e682 Mon Sep 17 00:00:00 2001 From: use-the-fork Date: Wed, 3 Jul 2024 17:28:10 -0400 Subject: [PATCH 11/13] refactor(scripts): disable script defaults and enable just runner in devenv scripts --- devenv.nix | 13 ++++++++++--- src/modules/scripts.nix | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/devenv.nix b/devenv.nix index de131646c..e813d6151 100644 --- a/devenv.nix +++ b/devenv.nix @@ -33,8 +33,11 @@ devcontainer.settings.customizations.vscode.extensions = [ "jnoortheen.nix-ide" ]; difftastic.enable = true; - #enable convco manually. - just.features.convco.enable = true; + #enable just. + just = { + enable = true; + recipes.convco.enable = true; + }; dotenv.enable = true; @@ -45,6 +48,7 @@ scripts.devenv-test-cli = { description = "Test devenv CLI."; + just.enable = true; exec = '' set -xe set -o pipefail @@ -102,6 +106,7 @@ }; scripts."devenv-generate-doc-options" = { description = "Generate option docs."; + just.enable = true; exec = '' set -e output_file=docs/reference/options.md @@ -115,6 +120,7 @@ }; scripts."devenv-generate-languages-example" = { description = "Generate an example enabling every supported language."; + just.enable = true; exec = '' cat > examples/supported-languages/devenv.nix < docs/services-all.md < Date: Wed, 3 Jul 2024 17:29:58 -0400 Subject: [PATCH 12/13] feat(tests): add new scripts and enable them in devenv.nix and .test.sh --- tests/just/.test.sh | 5 +++++ tests/just/devenv.nix | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tests/just/.test.sh create mode 100644 tests/just/devenv.nix diff --git a/tests/just/.test.sh b/tests/just/.test.sh new file mode 100644 index 000000000..b4cfda711 --- /dev/null +++ b/tests/just/.test.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -ex +just | grep "Generate CHANGELOG.md using recent commits" +just | grep "test hello" +just | grep "Hello Script" diff --git a/tests/just/devenv.nix b/tests/just/devenv.nix new file mode 100644 index 000000000..11c0d6d78 --- /dev/null +++ b/tests/just/devenv.nix @@ -0,0 +1,25 @@ +{ pkgs, ... }: { + just = { + enable = true; + recipes = { + convco.enable = true; + hello = { + enable = true; + justfile = '' + # test hello + hello: + echo Hello World; + ''; + }; + }; + }; + + scripts.hello-scripts = { + exec = '' + echo "Hello Script!" + ''; + description = "Hello Script"; + just.enable = true; + }; + +} From dfcc4b5716ba615768425539d0a5a6f83b312af8 Mon Sep 17 00:00:00 2001 From: use-the-fork Date: Thu, 4 Jul 2024 08:01:41 -0400 Subject: [PATCH 13/13] refactor(integrations): simplify GitHub integration description in git-cliff configuration --- docs/reference/options.md | 805 +++++++++++++++++- .../integrations/just/recipes/git-cliff.nix | 2 +- 2 files changed, 769 insertions(+), 38 deletions(-) diff --git a/docs/reference/options.md b/docs/reference/options.md index 6add637f4..996d4b7dd 100644 --- a/docs/reference/options.md +++ b/docs/reference/options.md @@ -1694,6 +1694,738 @@ attribute set of list of string +## just.enable + + + +Whether to enable the just command runner. + + + +*Type:* +boolean + + + +*Default:* +` false ` + + + +*Example:* +` true ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just) + + + +## just.package + + + +The just package to use. + + + +*Type:* +package + + + +*Default:* +` pkgs.just ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just) + + + +## just.commonFileName + + + +The name of the common justfile generated by this module. + + + +*Type:* +string + + + +*Default:* +` "just-flake.just" ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just) + + + +## just.recipes + + + +This option has no description. + + + +*Type:* +attribute set of (submodule) + + + +*Default:* +` { } ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/rust.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/rust.nix) + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/git-cliff.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/git-cliff.nix) + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/devenv-up.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/devenv-up.nix) + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/devenv-script.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/devenv-script.nix) + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/convco.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/convco.nix) + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just) + + + +## just.recipes.\.enable + + + +Whether to enable this recipe. + + + +*Type:* +boolean + + + +*Default:* +` false ` + + + +*Example:* +` true ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix) + + + +## just.recipes.\.package + + + +An optional package that provides the recipe. + + + +*Type:* +null or package + + + +*Default:* +` null ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix) + + + +## just.recipes.\.justfile + + + +The justfile representing this recipe. + + + +*Type:* +string or path + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix) + + + +## just.recipes.\.outputs.justfile + + + +The justfile code for importing this recipe’s justfile. + +See https://just.systems/man/en/chapter_53.html + + + +*Type:* +string *(read only)* + + + +*Default:* +` "" ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix) + + + +## just.recipes.convco + + + +Add the ‘changelog’ target calling convco + + + +*Type:* +submodule + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/convco.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/convco.nix) + + + +## just.recipes.convco.enable + + + +Whether to enable this recipe. + + + +*Type:* +boolean + + + +*Default:* +` false ` + + + +*Example:* +` true ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix) + + + +## just.recipes.convco.package + + + +An optional package that provides the recipe. + + + +*Type:* +null or package + + + +*Default:* +` null ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix) + + + +## just.recipes.convco.justfile + + + +The justfile representing this recipe. + + + +*Type:* +string or path + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix) + + + +## just.recipes.convco.outputs.justfile + + + +The justfile code for importing this recipe’s justfile. + +See https://just.systems/man/en/chapter_53.html + + + +*Type:* +string *(read only)* + + + +*Default:* +` "" ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix) + + + +## just.recipes.convco.settings.file-name + + + +The name of the file to output the chaneglog to. + + + +*Type:* +string + + + +*Default:* +` "CHANGELOG.md" ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/convco.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/convco.nix) + + + +## just.recipes.git-cliff + + + +Add the ‘changelog’ target calling convco + + + +*Type:* +submodule + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/git-cliff.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/git-cliff.nix) + + + +## just.recipes.git-cliff.enable + + + +Whether to enable this recipe. + + + +*Type:* +boolean + + + +*Default:* +` false ` + + + +*Example:* +` true ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix) + + + +## just.recipes.git-cliff.package + + + +An optional package that provides the recipe. + + + +*Type:* +null or package + + + +*Default:* +` null ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix) + + + +## just.recipes.git-cliff.justfile + + + +The justfile representing this recipe. + + + +*Type:* +string or path + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix) + + + +## just.recipes.git-cliff.outputs.justfile + + + +The justfile code for importing this recipe’s justfile. + +See https://just.systems/man/en/chapter_53.html + + + +*Type:* +string *(read only)* + + + +*Default:* +` "" ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix) + + + +## just.recipes.git-cliff.settings.config-file + + + +The git-cliff config to use. + +See https://git-cliff.org/docs/configuration/ + + + +*Type:* +string + + + +*Default:* + +``` +'' + [changelog] + header = """ + # Changelog\n + All notable changes to this project will be documented in this file.\n + """ + body = """ + {% if version %}\ + ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} + {% else %}\ + ## [unreleased] + {% endif %}\ + {% for group, commits in commits | group_by(attribute="group") %} + ### {{ group | striptags | trim | upper_first }} + {% for commit in commits %} + - {% if commit.scope %}*({{ commit.scope }})* {% endif %}\ + {% if commit.breaking %}[**breaking**] {% endif %}\ + {{ commit.message | upper_first }}\ + {% endfor %} + {% endfor %}\n + """ + # template for the changelog footer + footer = """ + + """ + # remove the leading and trailing s + trim = true + + [git] + conventional_commits = true + filter_unconventional = true + split_commits = false + commit_parsers = [ + { message = "^feat", group = "🚀 Features" }, + { message = "^fix", group = "🐛 Bug Fixes" }, + { message = "^doc", group = "📚 Documentation" }, + { message = "^perf", group = "⚡ Performance" }, + { message = "^refactor", group = "🚜 Refactor" }, + { message = "^style", group = "🎨 Styling" }, + { message = "^test", group = "🧪 Testing" }, + { message = "^chore\\(release\\): prepare for", skip = true }, + { message = "^chore\\(deps.*\\)", skip = true }, + { message = "^chore\\(pr\\)", skip = true }, + { message = "^chore\\(pull\\)", skip = true }, + { message = "^chore|^ci", group = "⚙️ Miscellaneous Tasks" }, + { body = ".*security", group = "🛡️ Security" }, + { message = "^revert", group = "◀️ Revert" }, + ] + protect_breaking_commits = false + filter_commits = false + topo_order = false + sort_commits = "oldest" +'' +``` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/git-cliff.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/git-cliff.nix) + + + +## just.recipes.git-cliff.settings.file-name + + + +The name of the file to output the chaneglog to. + + + +*Type:* +string + + + +*Default:* +` "CHANGELOG.md" ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/git-cliff.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/git-cliff.nix) + + + +## just.recipes.git-cliff.settings.integrations.github.enable + + + +Whether to enable Enable the GitHub integration. See https://git-cliff.org/docs/integration/github. + + + +*Type:* +boolean + + + +*Default:* +` false ` + + + +*Example:* +` true ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/git-cliff.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/git-cliff.nix) + + + +## just.recipes.rust + + + +Add ‘w’ and ‘test’ targets for running cargo + + + +*Type:* +submodule + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/rust.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/rust.nix) + + + +## just.recipes.rust.enable + + + +Whether to enable this recipe. + + + +*Type:* +boolean + + + +*Default:* +` false ` + + + +*Example:* +` true ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix) + + + +## just.recipes.rust.package + + + +An optional package that provides the recipe. + + + +*Type:* +null or package + + + +*Default:* +` null ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix) + + + +## just.recipes.rust.justfile + + + +The justfile representing this recipe. + + + +*Type:* +string or path + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix) + + + +## just.recipes.rust.outputs.justfile + + + +The justfile code for importing this recipe’s justfile. + +See https://just.systems/man/en/chapter_53.html + + + +*Type:* +string *(read only)* + + + +*Default:* +` "" ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix) + + + +## just.recipes.up + +Starts processes in foreground. See http://devenv.sh/processes + + + +*Type:* +submodule + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/devenv-up.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipes/devenv-up.nix) + + + +## just.recipes.up.enable + + + +Whether to enable this recipe. + + + +*Type:* +boolean + + + +*Default:* +` false ` + + + +*Example:* +` true ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix) + + + +## just.recipes.up.package + + + +An optional package that provides the recipe. + + + +*Type:* +null or package + + + +*Default:* +` null ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix) + + + +## just.recipes.up.justfile + + + +The justfile representing this recipe. + + + +*Type:* +string or path + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix) + + + +## just.recipes.up.outputs.justfile + + + +The justfile code for importing this recipe’s justfile. + +See https://just.systems/man/en/chapter_53.html + + + +*Type:* +string *(read only)* + + + +*Default:* +` "" ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix](https://github.com/cachix/devenv/blob/main/src/modules/integrations/just/recipe-module.nix) + + + ## languages.ansible.enable @@ -2370,6 +3102,8 @@ package ## languages.haskell.languageServer + + Haskell language server to use. @@ -4051,8 +4785,6 @@ boolean ## languages.purescript.package - - The PureScript package to use. @@ -4791,6 +5523,8 @@ boolean ## languages.robotframework.python + + The Python package to use. @@ -6931,8 +7665,6 @@ list of string ## pre-commit.hooks.\.types_or - - List of file types to run on, where only a single type needs to match. @@ -7639,6 +8371,8 @@ list of package ## pre-commit.hooks.ansible-lint.fail_fast + + if true pre-commit will stop running hooks if this hook fails. @@ -8849,8 +9583,6 @@ package ## pre-commit.hooks.clippy.packageOverrides.clippy - - The clippy package to use @@ -11160,8 +11892,6 @@ boolean ## pre-commit.hooks.denolint.description - - Description of the hook. Used for metadata purposes only. @@ -13198,8 +13928,6 @@ boolean ## pre-commit.hooks.flake8.settings.binPath - - flake8 binary path. Should be used to specify flake8 binary from your Nix-managed Python environment. @@ -15254,8 +15982,6 @@ submodule ## pre-commit.hooks.isort.enable - - Whether to enable this pre-commit hook. @@ -17418,8 +18144,6 @@ null or package ## pre-commit.hooks.markdownlint.always_run - - if true this hook will run even if there are no matching files. @@ -19484,8 +20208,6 @@ string ## pre-commit.hooks.nixfmt.excludes - - Exclude files that were matched by these patterns. @@ -21540,8 +22262,6 @@ submodule ## pre-commit.hooks.phpcs.enable - - Whether to enable this pre-commit hook. @@ -23705,8 +24425,6 @@ list of string ## pre-commit.hooks.psalm.extraPackages - - Additional packages required to run the hook. These are propagated to ` enabledPackages ` for constructing developer @@ -25806,8 +26524,6 @@ string ## pre-commit.hooks.ripsecrets.entry - - The entry point - the executable to run. ` entry ` can also contain arguments that will not be overridden, such as ` entry = "autopep8 -i"; `. @@ -27878,8 +28594,6 @@ list of string ## pre-commit.hooks.statix.verbose - - forces the output of the hook to be printed even when the hook passes. @@ -30037,8 +30751,6 @@ boolean ## pre-commit.hooks.yamllint.stages - - Confines the hook to run at a particular stage. @@ -30778,6 +31490,27 @@ string +## scripts.\.just.enable + + + +Include this script in just runner. + + + +*Type:* +boolean + + + +*Default:* +` false ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/scripts.nix](https://github.com/cachix/devenv/blob/main/src/modules/scripts.nix) + + + ## services.adminer.enable @@ -31199,7 +31932,7 @@ path *Default:* -` "/home/runner/work/devenv/devenv/.devenv/state/caddy" ` +` "/home/sincore/source/devenv/.devenv/state/caddy" ` *Declared by:* - [https://github.com/cachix/devenv/blob/main/src/modules/services/caddy.nix](https://github.com/cachix/devenv/blob/main/src/modules/services/caddy.nix) @@ -32440,8 +33173,6 @@ boolean ## services.httpbin.bind - - Addresses for httpbin to listen on. @@ -35781,16 +36512,16 @@ unspecified value *(read only)* ``` { bindir = "/nix/store/p4vjvd38l79jsxzxlv9q2hbajm7g2js9-trafficserver-9.2.3/bin"; - cachedir = "/home/runner/work/devenv/devenv/.devenv/state/trafficserver/cache"; - datadir = "/home/runner/work/devenv/devenv/.devenv/state/trafficserver/share"; - exec_prefix = "/home/runner/work/devenv/devenv/.devenv/state/trafficserver"; + cachedir = "/home/sincore/source/devenv/.devenv/state/trafficserver/cache"; + datadir = "/home/sincore/source/devenv/.devenv/state/trafficserver/share"; + exec_prefix = "/home/sincore/source/devenv/.devenv/state/trafficserver"; includedir = "/nix/store/p4vjvd38l79jsxzxlv9q2hbajm7g2js9-trafficserver-9.2.3/include"; libdir = "/nix/store/p4vjvd38l79jsxzxlv9q2hbajm7g2js9-trafficserver-9.2.3/lib"; libexecdir = "/nix/store/p4vjvd38l79jsxzxlv9q2hbajm7g2js9-trafficserver-9.2.3/libexec"; - localstatedir = "/home/runner/work/devenv/devenv/.devenv/state/trafficserver/state"; - logdir = "/home/runner/work/devenv/devenv/.devenv/state/trafficserver/log"; - prefix = "/home/runner/work/devenv/devenv/.devenv/state/trafficserver"; - runtimedir = "/run/user/1001/devenv-0957646/trafficserver"; + localstatedir = "/home/sincore/source/devenv/.devenv/state/trafficserver/state"; + logdir = "/home/sincore/source/devenv/.devenv/state/trafficserver/log"; + prefix = "/home/sincore/source/devenv/.devenv/state/trafficserver"; + runtimedir = "/run/user/1000/devenv-cdc0ceb/trafficserver"; sbindir = "/nix/store/p4vjvd38l79jsxzxlv9q2hbajm7g2js9-trafficserver-9.2.3/bin"; sysconfdir = ; } @@ -35922,7 +36653,7 @@ strings concatenated with “\\n” *Default:* -` "/home/runner/work/devenv/devenv/.devenv/state/trafficserver/cache 256M" ` +` "/home/sincore/source/devenv/.devenv/state/trafficserver/cache 256M" ` diff --git a/src/modules/integrations/just/recipes/git-cliff.nix b/src/modules/integrations/just/recipes/git-cliff.nix index a3f14046a..668b31359 100644 --- a/src/modules/integrations/just/recipes/git-cliff.nix +++ b/src/modules/integrations/just/recipes/git-cliff.nix @@ -114,7 +114,7 @@ in ''; }; integrations = { - github.enable = mkEnableOption "Enable the GitHub integration. See https://git-cliff.org/docs/integration/github"; + github.enable = mkEnableOption "GitHub integration. See https://git-cliff.org/docs/integration/github"; }; }; };