From 119423deb53e52d83f88392ebccd89269041532d Mon Sep 17 00:00:00 2001 From: DavHau Date: Wed, 26 Jul 2023 19:47:59 +0200 Subject: [PATCH] action-checkout: init --- flake-parts/action-checkout/default.nix | 24 ++++++++++++++++++++++++ flake-parts/action-checkout/script.sh | 10 ++++++++++ flake.nix | 1 + 3 files changed, 35 insertions(+) create mode 100644 flake-parts/action-checkout/default.nix create mode 100644 flake-parts/action-checkout/script.sh diff --git a/flake-parts/action-checkout/default.nix b/flake-parts/action-checkout/default.nix new file mode 100644 index 0000000..6b7c397 --- /dev/null +++ b/flake-parts/action-checkout/default.nix @@ -0,0 +1,24 @@ +{ + perSystem = + { config + , pkgs + , ... + }: + let + name = builtins.baseNameOf ./.; + script = config.writers.writePureShellScriptBin + name + [ + pkgs.bash + pkgs.coreutils + pkgs.git + pkgs.openssh + ] + '' + bash ${./script.sh} + ''; + in + { + packages.${name} = script; + }; +} diff --git a/flake-parts/action-checkout/script.sh b/flake-parts/action-checkout/script.sh new file mode 100644 index 0000000..a901eda --- /dev/null +++ b/flake-parts/action-checkout/script.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -euo pipefail + +# load BRANCH variable with default +BRANCH=${BRANCH:-main} + +# load REPO_DIR variable with default +export REPO_DIR=${REPO_DIR:-.} + +git clone --depth 1 --branch $BRANCH $REPO $REPO_DIR diff --git a/flake.nix b/flake.nix index 28537af..379d503 100644 --- a/flake.nix +++ b/flake.nix @@ -42,6 +42,7 @@ imports = [ inputs.treefmt-nix.flakeModule inputs.clan-core.modules.flake-parts.writers + ./flake-parts/action-checkout ./flake-parts/action-flake-update ./flake-parts/action-create-pr ./targets/flake-module.nix