ci: move CI tasks into Nushell scripts and update dependencies weekly

Replace the shell scripts in flake.nix with Nushell scripts in ci/, exposed
as flake apps in nix/ci-tasks.nix, so every workflow command is a plain nix
call. Build the workspace dependencies in a step of their own, upload to
Cachix only after the builds, and run the formatting check through the
pre-commit hooks.

Automated pushes, tags and pull requests now use the wvhulle-bot account.
A weekly cron updates Cargo.lock and flake.lock and opens or updates one
pull request from bot/dependency-updates.

Claude-Session: https://claude.ai/code/session_01D8dLLgYd8cfR2aQfA5eZXa
This commit is contained in:
Willem Vanhulle committed 2026-11-05 19:59:06 +01:00
1 parent a81cc849b5
commit f9f68b2a68
11 files changed
+519 -173

No files matched your search

+85
View File
@@ -0,0 +1,85 @@
when:
- repo: wvhulle/bootvine
event: [pull_request, push, manual]
variables:
- &nix_config
NIX_CONFIG: |
experimental-features = nix-command flakes
build-users-group =
accept-flake-config = true
- &after_dependency_step
- status: [success, failure]
steps:
- name: prepare-build-dependencies
image: nixos/nix:latest
depends_on: []
environment: *nix_config
commands:
- nix run --quiet .#build-unless-cached -- .#packages.x86_64-linux.workspace-dependencies
- name: build-and-test-bootvine
image: nixos/nix:latest
depends_on: [prepare-build-dependencies]
when: *after_dependency_step
environment: *nix_config
commands:
- nix run --quiet .#import-exported-paths
- nix run --quiet .#build-and-export-paths -- .#checks.x86_64-linux.bootvine-build
- name: build-repo-tasks
image: nixos/nix:latest
depends_on: [prepare-build-dependencies]
when: *after_dependency_step
environment: *nix_config
commands:
- nix run --quiet .#import-exported-paths
- nix run --quiet .#build-and-export-paths -- .#checks.x86_64-linux.repo-tasks-build
- name: lint-with-clippy
image: nixos/nix:latest
depends_on: [prepare-build-dependencies]
when: *after_dependency_step
environment: *nix_config
commands:
- nix run --quiet .#import-exported-paths
- nix build --quiet --print-build-logs .#checks.x86_64-linux.clippy-lints
- name: upload-builds-to-cachix
image: nixos/nix:latest
depends_on: [build-and-test-bootvine, build-repo-tasks]
when:
- event: [push, manual]
branch: main
status: [success, failure]
environment:
<<: *nix_config
CACHIX_AUTH_TOKEN:
from_secret: cachix_auth_token
commands:
- nix run --quiet .#upload-exported-paths
- name: run-pre-commit-hooks
image: nixos/nix:latest
depends_on: [prepare-build-dependencies]
when: *after_dependency_step
environment: *nix_config
commands:
- nix run --quiet .#run-pre-commit-hooks
- name: evaluate-flake-outputs
image: nixos/nix:latest
depends_on: []
environment: *nix_config
commands:
- nix flake check --quiet --no-build
- name: check-commit-messages
image: nixos/nix:latest
depends_on: []
when:
- event: pull_request
environment: *nix_config
commands:
- nix run --quiet .#check-commit-messages -- --fetch-target-branch FETCH_HEAD..HEAD
+28
View File
@@ -0,0 +1,28 @@
when:
- repo: wvhulle/bootvine
event: cron
cron: weekly-dependency-update
clone:
- name: clone-with-history
image: woodpeckerci/plugin-git
settings:
depth: 0
partial: false
steps:
- name: open-dependency-update-pr
image: nixos/nix:latest
environment:
NIX_CONFIG: |
experimental-features = nix-command flakes
build-users-group =
accept-flake-config = true
GIT_AUTHOR_NAME: wvhulle-bot
GIT_AUTHOR_EMAIL: willemvanhulle@protonmail.com
GIT_COMMITTER_NAME: wvhulle-bot
GIT_COMMITTER_EMAIL: willemvanhulle@protonmail.com
CODEBERG_TOKEN:
from_secret: bot_token
commands:
- nix run --quiet .#open-dependency-update-pr -- --cargo-lock --flake-lock
@@ -4,10 +4,10 @@ when:
branch: main branch: main
depends_on: depends_on:
- rust-and-flake-checks - checks
clone: clone:
- name: clone-with-history-and-tags - name: clone-with-history
image: woodpeckerci/plugin-git image: woodpeckerci/plugin-git
settings: settings:
depth: 0 depth: 0
@@ -25,21 +25,19 @@ variables:
GIT_COMMITTER_NAME: release-plz GIT_COMMITTER_NAME: release-plz
GIT_COMMITTER_EMAIL: willemvanhulle@protonmail.com GIT_COMMITTER_EMAIL: willemvanhulle@protonmail.com
CODEBERG_TOKEN: CODEBERG_TOKEN:
from_secret: codeberg_token from_secret: bot_token
CARGO_REGISTRY_TOKEN: CARGO_REGISTRY_TOKEN:
from_secret: cargo_registry_token from_secret: cargo_registry_token
steps: steps:
- name: publish-crate-and-tag-release - name: publish-unreleased-crate-version
image: nixos/nix:latest image: nixos/nix:latest
environment: *release_env environment: *release_env
commands: commands:
- git remote set-url origin "https://wvhulle:$${CODEBERG_TOKEN}@codeberg.org/$${CI_REPO}.git" - nix run --quiet .#publish-unreleased-crate-version
- git checkout -B main "$${CI_COMMIT_SHA}"
- nix run .#release-plz-release
- name: update-release-pr - name: open-or-update-release-pr
image: nixos/nix:latest image: nixos/nix:latest
environment: *release_env environment: *release_env
commands: commands:
- nix run .#release-plz-release-pr - nix run --quiet .#open-or-update-release-pr
-87
View File
@@ -1,87 +0,0 @@
when:
- repo: wvhulle/bootvine
event: [pull_request, push, manual]
variables:
- &nix_config
NIX_CONFIG: |
experimental-features = nix-command flakes
build-users-group =
accept-flake-config = true
- &cache_writing_env
<<: *nix_config
CACHIX_AUTH_TOKEN:
from_secret: cachix_auth_token
- &on_main_branch
- event: [push, manual]
branch: main
- &off_main_branch
- event: pull_request
- event: [push, manual]
branch:
exclude: main
- &on_pull_requests
- event: pull_request
steps:
- name: build-test-and-cache-bootvine
image: nixos/nix:latest
depends_on: []
when: *on_main_branch
environment: *cache_writing_env
commands:
- nix run .#build-and-push-to-cachix -- .#checks.x86_64-linux.bootvine-build
- name: build-and-test-bootvine
image: nixos/nix:latest
depends_on: []
when: *off_main_branch
environment: *nix_config
commands:
- nix build --print-build-logs .#checks.x86_64-linux.bootvine-build
- name: build-and-cache-repo-tasks
image: nixos/nix:latest
depends_on: []
when: *on_main_branch
environment: *cache_writing_env
commands:
- nix run .#build-and-push-to-cachix -- .#checks.x86_64-linux.repo-tasks-build
- name: build-repo-tasks
image: nixos/nix:latest
depends_on: []
when: *off_main_branch
environment: *nix_config
commands:
- nix build --print-build-logs .#checks.x86_64-linux.repo-tasks-build
- name: lint-rust-with-clippy
image: nixos/nix:latest
depends_on: []
environment: *nix_config
commands:
- nix build --print-build-logs .#checks.x86_64-linux.clippy-lints
- name: check-rust-formatting
image: nixos/nix:latest
depends_on: []
environment: *nix_config
commands:
- nix build --print-build-logs .#checks.x86_64-linux.rustfmt-formatting
- name: evaluate-flake-outputs
image: nixos/nix:latest
depends_on: []
environment: *nix_config
commands:
- nix flake check --no-build
- name: check-conventional-commit-messages
image: nixos/nix:latest
depends_on: []
when: *on_pull_requests
environment: *nix_config
commands:
- git fetch --quiet origin "$${CI_COMMIT_TARGET_BRANCH}"
- nix run .#check-conventional-commits -- FETCH_HEAD..HEAD
+64
View File
@@ -0,0 +1,64 @@
#!/usr/bin/env nu
const CODEBERG_USER = "wvhulle-bot"
const TEA_LOGIN_NAME = "codeberg"
const UPDATE_BRANCH = "bot/dependency-updates"
const UPDATE_COMMIT_MESSAGE = "chore(deps): update lock files"
const PULL_REQUEST_DESCRIPTION = "Opened by the weekly dependency update job. The checks on this pull request are the trial build. Commits pushed to this branch by hand stop further automatic updates until it is merged."
def open-pull-request-heads []: nothing -> list<string> {
^tea pulls list --login $TEA_LOGIN_NAME --repo $env.CI_REPO --state open --fields head --output simple
| lines
| str trim
}
def remote-update-branch-commits []: nothing -> list<string> {
^git ls-remote --heads origin $"refs/heads/($UPDATE_BRANCH)"
| parse "{commit_id}\t{ref_name}"
| get commit_id
}
def update-branch-has-hand-written-commits []: nothing -> bool {
^git fetch --quiet origin $"+refs/heads/($UPDATE_BRANCH):refs/remotes/origin/($UPDATE_BRANCH)"
^git log --format=%an $"origin/main..origin/($UPDATE_BRANCH)"
| lines
| any {|commit_author| $commit_author != $env.GIT_AUTHOR_NAME }
}
def "main open-dependency-update-pr" [
--cargo-lock
--flake-lock
]: nothing -> nothing {
^git remote set-url origin $"https://($CODEBERG_USER):($env.CODEBERG_TOKEN)@codeberg.org/($env.CI_REPO).git"
^tea login add --name $TEA_LOGIN_NAME --url $env.CI_FORGE_URL --token $env.CODEBERG_TOKEN
^git fetch --quiet origin +refs/heads/main:refs/remotes/origin/main
let remote_commits = remote-update-branch-commits
let remote_commit = $remote_commits | str join
let pull_request_is_open = $UPDATE_BRANCH in (open-pull-request-heads)
if ($remote_commits | is-not-empty) and $pull_request_is_open and (update-branch-has-hand-written-commits) {
print $"Leaving ($UPDATE_BRANCH) alone because it contains hand-written commits"
return
}
^git checkout -B $UPDATE_BRANCH origin/main
if $cargo_lock {
^cargo update
}
if $flake_lock {
^nix flake update
}
if (^git diff --name-only | is-empty) {
print "Dependencies are up to date"
return
}
^git commit --all --message $UPDATE_COMMIT_MESSAGE
^git push $"--force-with-lease=($UPDATE_BRANCH):($remote_commit)" origin $UPDATE_BRANCH
if $pull_request_is_open {
print $"Updated the open pull request from ($UPDATE_BRANCH)"
} else {
^tea pulls create --login $TEA_LOGIN_NAME --repo $env.CI_REPO --head $UPDATE_BRANCH --base main --title $UPDATE_COMMIT_MESSAGE --description $PULL_REQUEST_DESCRIPTION
}
}
def main []: nothing -> nothing {
print "Run a subcommand, for example: open-dependency-update-pr --cargo-lock --flake-lock"
}
+79
View File
@@ -0,0 +1,79 @@
#!/usr/bin/env nu
const EXPORT_DIRECTORY_NAME = ".nix-built-paths"
const PATH_LIST_FILE_NAME = "paths.txt"
const CACHIX_CACHE_NAME = "wvhulle"
const CACHIX_CACHE_URL = "https://wvhulle.cachix.org"
def export-directory []: nothing -> path {
$env.CI_WORKSPACE | path join $EXPORT_DIRECTORY_NAME
}
def store-paths-from-lines []: string -> list<string> {
lines | compact --empty
}
def exported-store-paths []: nothing -> list<string> {
let path_list_file = export-directory | path join $PATH_LIST_FILE_NAME
if ($path_list_file | path exists) {
open --raw $path_list_file | store-paths-from-lines
} else {
[]
}
}
def nix-config-with-hook [existing_config: string, hook_program: string]: nothing -> string {
$"($existing_config)\npost-build-hook = ($hook_program)"
}
def "main export-built-paths-hook" []: nothing -> nothing {
let built_paths = $env.OUT_PATHS | split row " " | compact --empty
let directory = export-directory
mkdir $directory
^nix copy --quiet --to $"file://($directory)?compression=zstd" ...$built_paths
$built_paths | each {|built_path| $"($built_path)\n" } | str join | save --append ($directory | path join $PATH_LIST_FILE_NAME)
}
def --wrapped "main build-and-export-paths" [
...build_arguments: string
]: nothing -> nothing {
let hook_config = nix-config-with-hook ($env.NIX_CONFIG? | default "") $env.EXPORT_HOOK_PROGRAM
with-env {NIX_CONFIG: $hook_config} {
^nix build --quiet --print-build-logs ...$build_arguments
}
}
def "main build-unless-cached" [
installable: string
]: nothing -> nothing {
let built_output = ^nix eval --quiet --raw $"($installable).outPath"
let cache_lookup = do { ^nix path-info --quiet --store $CACHIX_CACHE_URL $built_output } | complete
if $cache_lookup.exit_code == 0 {
print $"($built_output) is already in Cachix"
} else {
main build-and-export-paths $installable
}
}
def "main import-exported-paths" []: nothing -> nothing {
let exported_paths = exported-store-paths
if ($exported_paths | is-empty) {
print "No exported paths to import"
} else {
^nix copy --quiet --no-check-sigs --from $"file://(export-directory)" ...$exported_paths
}
}
def "main upload-exported-paths" []: nothing -> nothing {
let exported_paths = exported-store-paths
if ($exported_paths | is-empty) {
print "No newly built paths to upload"
} else {
main import-exported-paths
^cachix push $CACHIX_CACHE_NAME ...$exported_paths
}
}
def main []: nothing -> nothing {
print "Run a subcommand, for example: build-and-export-paths"
}
+69
View File
@@ -0,0 +1,69 @@
#!/usr/bin/env nu
const CODEBERG_USER = "wvhulle-bot"
const TEA_LOGIN_NAME = "codeberg"
const RELEASE_ARCHIVE_PATTERN = "*.tar.gz"
const CHECKSUM_FILE_NAME = "sha256sum.txt"
def checksum-line [archive_digest: string, archive_name: string]: nothing -> string {
$"($archive_digest) ($archive_name)\n"
}
def run-release-plz [subcommand: string]: nothing -> nothing {
^release-plz $subcommand --forge gitea --git-token $env.CODEBERG_TOKEN
}
def "main authenticate-git-origin" []: nothing -> nothing {
^git remote set-url origin $"https://($CODEBERG_USER):($env.CODEBERG_TOKEN)@codeberg.org/($env.CI_REPO).git"
}
def "main publish-unreleased-crate-version" []: nothing -> nothing {
main authenticate-git-origin
^git checkout -B main $env.CI_COMMIT_SHA
^git fetch origin main:refs/remotes/origin/main
^git branch --set-upstream-to=origin/main main
run-release-plz release
}
def "main open-or-update-release-pr" []: nothing -> nothing {
run-release-plz release-pr
}
def "main collect-release-archives" [
build_result: path
dist_directory: path
]: nothing -> nothing {
mkdir $dist_directory
for archive_path in (glob ($build_result | path join $RELEASE_ARCHIVE_PATTERN)) {
cp $archive_path $dist_directory
}
}
def "main upload-release-assets" [
dist_directory: path
]: nothing -> nothing {
let archive_paths = glob ($dist_directory | path join $RELEASE_ARCHIVE_PATTERN) | sort
let checksum_file = $dist_directory | path join $CHECKSUM_FILE_NAME
$archive_paths
| each {|archive_path|
checksum-line (open --raw $archive_path | hash sha256) ($archive_path | path basename)
}
| str join
| save --force $checksum_file
^tea login add --name $TEA_LOGIN_NAME --url $env.CI_FORGE_URL --token $env.CODEBERG_TOKEN
^tea releases assets create --login $TEA_LOGIN_NAME --repo $env.CI_REPO $env.CI_COMMIT_TAG ...$archive_paths $checksum_file
}
def "main check-commit-messages" [
--fetch-target-branch
...revision_ranges: string
]: nothing -> nothing {
if $fetch_target_branch {
^git fetch --quiet origin $env.CI_COMMIT_TARGET_BRANCH
}
^convco check ...$revision_ranges
}
def main []: nothing -> nothing {
print "Run a subcommand, for example: check-commit-messages"
}
+20 -10
View File
@@ -34,25 +34,26 @@ Commit messages follow [Conventional Commits](https://www.conventionalcommits.or
jj does not run git hooks, so check the commits you are about to push with: jj does not run git hooks, so check the commits you are about to push with:
```sh ```sh
nix run .#check-conventional-commits -- origin/main..HEAD nix run .#check-commit-messages -- origin/main..HEAD
``` ```
Git users can install the same commit-message check and a formatting check as Git users can install the same commit-message check and a formatting check as
hooks with `prek install` ([prek](https://github.com/j178/prek), from the dev hooks with `prek install` ([prek](https://github.com/j178/prek), from the dev
shell) or `pre-commit install` ([pre-commit](https://pre-commit.com)). shell) or `pre-commit install` ([pre-commit](https://pre-commit.com)). CI runs
the formatting hook with `nix run .#run-pre-commit-hooks`.
## Continuous integration ## Continuous integration
`.woodpecker/rust-and-flake-checks.yaml` runs on Codeberg's `.woodpecker/checks.yaml` runs on Codeberg's
[Woodpecker CI](https://woodpecker-ci.org) for every push and pull request: the bootvine build with its tests, the xtask build, clippy, [Woodpecker CI](https://woodpecker-ci.org) for every push and pull request: the bootvine build with its tests, the xtask build, clippy,
rustfmt, an evaluation of every flake output, and the commit-message check on the pre-commit hooks, an evaluation of every flake output, and the commit-message check on
pull requests. Builds on `main` are pushed to the `wvhulle` [Cachix](https://www.cachix.org) cache, which pull requests. The workspace dependencies are built or fetched in a step of their own. Builds on `main` are pushed to the `wvhulle` [Cachix](https://www.cachix.org) cache, which
`nixConfig` in `flake.nix` offers as a substituter. The two VM checks need KVM, `nixConfig` in `flake.nix` offers as a substituter. CI tasks are Nushell scripts in `ci/`, exposed as flake apps in `nix/ci-tasks.nix`. The two VM checks need KVM,
which Codeberg's runners lack, so they only run locally. which Codeberg's runners lack, so they only run locally.
## Releases ## Releases
`.woodpecker/release-pr-and-publish.yaml` runs `.woodpecker/publish-release-and-update-pr.yaml` runs
[release-plz](https://release-plz.dev) after the checks pass on `main`. It [release-plz](https://release-plz.dev) after the checks pass on `main`. It
keeps a pull request labelled `release` open on Codeberg that bumps the version keeps a pull request labelled `release` open on Codeberg that bumps the version
in `Cargo.toml` and adds the new commits to `CHANGELOG.md`. Only `feat`, `fix` in `Cargo.toml` and adds the new commits to `CHANGELOG.md`. Only `feat`, `fix`
@@ -61,11 +62,20 @@ minor version while bootvine is below 1.0. Merging that pull request publishes
the crate to crates.io, tags the merge `v<version>` and creates a Codeberg the crate to crates.io, tags the merge `v<version>` and creates a Codeberg
release with the changelog. Settings are in `release-plz.toml`. release with the changelog. Settings are in `release-plz.toml`.
The pipeline needs two Woodpecker secrets: `codeberg_token`, a Codeberg access The pipeline needs two Woodpecker secrets: `bot_token`, an access token of the
token with repository write access, and `cargo_registry_token`, a crates.io `wvhulle-bot` Codeberg account, which has write access to the repository, and
token that may publish new crates and updates. Preview the next release `cargo_registry_token`, a crates.io token that may publish new crates and updates. Preview the next release
locally from the dev shell with `release-plz update`. locally from the dev shell with `release-plz update`.
## Dependency updates
The `weekly-dependency-update` cron runs `.woodpecker/dependency-update-pr.yaml`,
which updates `Cargo.lock` and `flake.lock` and opens or updates one pull request
from the `bot/dependency-updates` branch as `wvhulle-bot`. The checks on that pull
request are the trial build. Commits pushed to the branch by hand stop further
automatic updates until it is merged. Updates that need changes to `Cargo.toml`
stay manual.
## Testing ## Testing
| What | Command | | What | Command |
+51 -63
View File
@@ -61,6 +61,7 @@
{ {
default = builds.bootvine; default = builds.bootvine;
inherit (builds) bootvine scripted-demos repo-tasks; inherit (builds) bootvine scripted-demos repo-tasks;
workspace-dependencies = builds.cargoArtifacts;
sample-unit-files = pkgs.callPackage ./vm-tests/slow-services/sample-unit-files.nix { sample-unit-files = pkgs.callPackage ./vm-tests/slow-services/sample-unit-files.nix {
inherit (vmTests) sampleUnits; inherit (vmTests) sampleUnits;
}; };
@@ -86,12 +87,29 @@
... ...
}: }:
let let
shellScriptApp = name: description: scriptArgs: { mkApp = drv: {
type = "app"; type = "app";
meta.description = description; program = lib.getExe drv;
program = lib.getExe (pkgs.writeShellApplication ({ inherit name; } // scriptArgs));
}; };
repoTaskApp =
name: description: xtaskArguments: runtimeInputs:
mkApp (
pkgs.runCommand name
{
nativeBuildInputs = [ pkgs.makeBinaryWrapper ];
meta.mainProgram = name;
}
''
makeWrapper ${lib.getExe builds.repo-tasks} $out/bin/${name} \
--add-flags ${lib.escapeShellArg xtaskArguments} \
--prefix PATH : ${lib.makeBinPath runtimeInputs}
''
)
// {
meta.description = description;
};
sampleMachineApps = lib.mapAttrs' ( sampleMachineApps = lib.mapAttrs' (
machineName: machineDescription: machineName: machineDescription:
lib.nameValuePair "sample-vm-${machineName}" { lib.nameValuePair "sample-vm-${machineName}" {
@@ -101,80 +119,50 @@
} }
) vmTests.machineDescriptions; ) vmTests.machineDescriptions;
releasePlzOnCodeberg = ciTaskApps = import ./nix/ci-tasks.nix {
subcommand: description: inherit pkgs mkApp;
shellScriptApp "release-plz-${subcommand}" description { cargoToolchain = rustToolchain;
runtimeInputs = [ preCommitInputs = [ rustToolchain ];
pkgs.release-plz extraReleaseInputs = [
pkgs.gitMinimal pkgs.pkg-config
pkgs.pkg-config pkgs.stdenv.cc
pkgs.stdenv.cc ];
rustToolchain releaseWrapperArgs = [
]; "--set"
runtimeEnv.PKG_CONFIG_PATH = "PKG_CONFIG_PATH"
lib.makeSearchPathOutput "dev" "lib/pkgconfig" (lib.makeSearchPathOutput "dev" "lib/pkgconfig" builds.bootvine.buildInputs)
builds.bootvine.buildInputs; ];
text = ''exec release-plz ${subcommand} --forge gitea --git-token "$CODEBERG_TOKEN"''; };
};
in in
sampleMachineApps sampleMachineApps
// ciTaskApps
// { // {
release-plz-release = releasePlzOnCodeberg "release" "Publish unpublished versions to crates.io and tag them with a Codeberg release";
release-plz-release-pr = releasePlzOnCodeberg "release-pr" "Open or update the Codeberg pull request that bumps the version and changelog";
record-screencasts = record-screencasts =
shellScriptApp "record-screencasts" repoTaskApp "record-screencasts"
"Re-record the scripted demo animations and the sample machine recordings into recordings/; publish them with publish-recordings" "Re-record the scripted demo animations and the sample machine recordings into recordings/; publish them with publish-recordings"
{ "record-screencasts --vm-check-outputs ${
runtimeInputs = [ pkgs.linkFarm "vm-check-outputs" (
pkgs.vhs lib.mapAttrs (machineName: _: self.checks.${system}."vm-${machineName}") vmTests.machines
pkgs.libwebp )
builds.scripted-demos }"
builds.repo-tasks [
]; pkgs.vhs
text = "exec xtask record-screencasts --vm-check-outputs ${ pkgs.libwebp
pkgs.linkFarm "vm-check-outputs" ( builds.scripted-demos
lib.mapAttrs (machineName: _: self.checks.${system}."vm-${machineName}") vmTests.machines ];
)
}";
};
publish-recordings = publish-recordings =
shellScriptApp "publish-recordings" repoTaskApp "publish-recordings"
"Replace the recordings branch on origin with a single commit holding recordings/" "Replace the recordings branch on origin with a single commit holding recordings/"
{ "publish-recordings"
runtimeInputs = [ [ pkgs.gitMinimal ];
pkgs.gitMinimal
builds.repo-tasks
];
text = "exec xtask publish-recordings";
};
build-and-push-to-cachix =
shellScriptApp "build-and-push-to-cachix"
"Build flake outputs and push everything built to the wvhulle Cachix cache"
{
runtimeInputs = [ pkgs.cachix ];
text = ''exec cachix watch-exec wvhulle -- nix build --print-build-logs "$@"'';
};
check-conventional-commits =
shellScriptApp "check-conventional-commits"
"Check that the commit messages in a git revision range are conventional commits"
{
runtimeInputs = [
pkgs.convco
pkgs.gitMinimal
];
text = ''exec convco check "$@"'';
};
} }
); );
checks = forEachSystem ( checks = forEachSystem (
{ pkgs, builds, ... }: { pkgs, builds, ... }:
{ {
inherit (builds) rustfmt-formatting clippy-lints; inherit (builds) clippy-lints;
bootvine-build = builds.bootvine; bootvine-build = builds.bootvine;
repo-tasks-build = builds.repo-tasks; repo-tasks-build = builds.repo-tasks;
} }
+115
View File
@@ -0,0 +1,115 @@
{
pkgs,
mkApp,
cargoToolchain,
preCommitInputs,
extraReleaseInputs ? [ ],
releaseWrapperArgs ? [ ],
}:
let
inherit (pkgs) lib;
nuScriptTool =
{
script,
name,
runtimeInputs ? [ ],
wrapperArgs ? [ ],
}:
pkgs.runCommand name
{
nativeBuildInputs = [ pkgs.makeBinaryWrapper ];
meta.mainProgram = name;
}
''
makeWrapper ${lib.getExe pkgs.nushell} $out/bin/${name} \
--add-flags ${script} \
--add-flags ${name} \
${lib.optionalString (runtimeInputs != [ ]) "--prefix PATH : ${lib.makeBinPath runtimeInputs}"} \
${lib.escapeShellArgs wrapperArgs}
'';
nixBuiltPathsTool = toolArgs: nuScriptTool (toolArgs // { script = ../ci/nix-built-paths.nu; });
exportBuiltPathsHook = nixBuiltPathsTool { name = "export-built-paths-hook"; };
exportingBuildApp =
name:
mkApp (nixBuiltPathsTool {
inherit name;
wrapperArgs = [
"--set"
"EXPORT_HOOK_PROGRAM"
(lib.getExe exportBuiltPathsHook)
];
});
releasePlzApp =
name:
mkApp (nuScriptTool {
inherit name;
script = ../ci/release-tasks.nu;
runtimeInputs = [
cargoToolchain
pkgs.release-plz
pkgs.gitMinimal
]
++ extraReleaseInputs;
wrapperArgs = releaseWrapperArgs;
});
releaseTaskApps =
lib.mapAttrs
(
name: runtimeInputs:
mkApp (nuScriptTool {
inherit name runtimeInputs;
script = ../ci/release-tasks.nu;
})
)
{
authenticate-git-origin = [ pkgs.gitMinimal ];
collect-release-archives = [ ];
upload-release-assets = [ pkgs.tea ];
check-commit-messages = [
pkgs.convco
pkgs.gitMinimal
];
};
preCommitHooksTool =
pkgs.runCommand "run-pre-commit-hooks"
{
nativeBuildInputs = [ pkgs.makeBinaryWrapper ];
meta.mainProgram = "run-pre-commit-hooks";
}
''
makeWrapper ${lib.getExe pkgs.prek} $out/bin/run-pre-commit-hooks \
--add-flags "run --all-files --show-diff-on-failure" \
--prefix PATH : ${lib.makeBinPath ([ pkgs.gitMinimal ] ++ preCommitInputs)}
'';
in
releaseTaskApps
// {
publish-unreleased-crate-version = releasePlzApp "publish-unreleased-crate-version";
open-or-update-release-pr = releasePlzApp "open-or-update-release-pr";
open-dependency-update-pr = mkApp (nuScriptTool {
name = "open-dependency-update-pr";
script = ../ci/dependency-updates.nu;
runtimeInputs = [
cargoToolchain
pkgs.gitMinimal
pkgs.tea
];
});
run-pre-commit-hooks = mkApp preCommitHooksTool;
build-and-export-paths = exportingBuildApp "build-and-export-paths";
build-unless-cached = exportingBuildApp "build-unless-cached";
import-exported-paths = mkApp (nixBuiltPathsTool {
name = "import-exported-paths";
});
upload-exported-paths = mkApp (nixBuiltPathsTool {
name = "upload-exported-paths";
runtimeInputs = [ pkgs.cachix ];
});
}
+1 -4
View File
@@ -30,10 +30,7 @@ let
args: craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; } // args); args: craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; } // args);
in in
{ {
rustfmt-formatting = craneLib.cargoFmt { inherit cargoArtifacts;
inherit (commonArgs) src pname version;
cargoExtraArgs = "--all";
};
clippy-lints = craneLib.cargoClippy ( clippy-lints = craneLib.cargoClippy (
commonArgs commonArgs