Skip to content

Commit 1c514aa

Browse files
authored
refactor: expose justix module system (#8)
1 parent 461c546 commit 1c514aa

File tree

16 files changed

+506
-444
lines changed

16 files changed

+506
-444
lines changed

.envrc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
# .envrc is used by direnv (if installed) to automatically load the devshell
1+
# .envrc is used by direnv (if installed) to automatically load the development environment.
2+
3+
# Reload environment when these directories/files change.
24
watch_dir "dev_shells"
35
watch_file "flake.nix"
46
watch_file "flake.lock"
57

8+
# Load the Nix development shell.
9+
USER_SHELL="$SHELL"
610
use flake . --impure
11+
export SHELL="$USER_SHELL"

.github/workflows/ci.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
push:
66
branches: ["main"]
77
schedule:
8-
- cron: '0 06 * * MON'
8+
- cron: "0 06 * * MON"
99
workflow_dispatch:
1010
concurrency:
1111
cancel-in-progress: true
@@ -17,7 +17,6 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v6
1919
- uses: DeterminateSystems/nix-installer-action@v21
20-
- uses: DeterminateSystems/magic-nix-cache-action@v13
2120
- uses: DeterminateSystems/flake-checker-action@v12
2221
- name: Check flake
2322
run: nix flake check --impure
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Update Automated Pull Requests
2+
on:
3+
push:
4+
branches: ["main"]
5+
workflow_dispatch:
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
9+
jobs:
10+
update-pull-requests:
11+
name: Update automated pull requests
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v6
15+
with:
16+
fetch-depth: 0
17+
token: ${{ secrets.PR_BOT_PERSONAL_ACCESS_TOKEN }}
18+
- name: Configure Git user
19+
run: |
20+
git config --global user.name "github-actions[bot]"
21+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
22+
- name: Update pull requests with automated label
23+
env:
24+
GH_TOKEN: ${{ secrets.PR_BOT_PERSONAL_ACCESS_TOKEN }}
25+
run: |
26+
prs=$(gh pr list --label automated --json number,headRefName,baseRefName --jq '.[] | "\(.number)|\(.headRefName)|\(.baseRefName)"')
27+
28+
if [ -z "$prs" ]; then
29+
echo "No automated pull requests to update"
30+
exit 0
31+
fi
32+
33+
echo "$prs" | while IFS='|' read -r pr_number branch base_branch; do
34+
echo "Updating PR #$pr_number (merging $base_branch into $branch)"
35+
36+
git fetch origin "$branch" "$base_branch" || {
37+
echo "Failed to fetch branches for PR #$pr_number. Skipping."
38+
continue
39+
}
40+
41+
git checkout -B "$branch" "origin/$branch" || {
42+
echo "Failed to checkout $branch for PR #$pr_number. Skipping."
43+
continue
44+
}
45+
46+
if git merge "origin/$base_branch" --no-edit; then
47+
echo "Successfully merged $base_branch into $branch"
48+
git push origin "$branch"
49+
else
50+
echo "Merge conflict detected for PR #$pr_number. Skipping."
51+
git merge --abort
52+
fi
53+
done

.github/workflows/update_dependencies.yaml

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,47 @@ concurrency:
77
group: ${{ github.workflow }}-${{ github.ref }}
88
cancel-in-progress: true
99
jobs:
10-
nix-flake:
11-
name: Update Nix flake dependencies
10+
development:
11+
name: Update development dependencies
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v6
1515
- uses: DeterminateSystems/nix-installer-action@v21
16-
- uses: DeterminateSystems/magic-nix-cache-action@v13
1716
- name: Update flake.lock
17+
id: update
1818
uses: DeterminateSystems/update-flake-lock@v28
1919
with:
20-
pr-title: "deps: update Nix flake dependencies"
20+
branch: "update_flake_lock_development"
21+
inputs: devenv flake-parts import-tree nixpkgs snekcheck treefmt-nix
22+
pr-title: "deps: update development dependencies"
2123
pr-labels: |
2224
automated
2325
dependencies
24-
nix
2526
token: ${{ secrets.PR_BOT_PERSONAL_ACCESS_TOKEN }}
27+
- name: Enable auto-merge
28+
if: steps.update.outputs.pull-request-number != ''
29+
env:
30+
GH_TOKEN: ${{ secrets.PR_BOT_PERSONAL_ACCESS_TOKEN }}
31+
run: gh pr merge ${{ steps.update.outputs.pull-request-number }} --auto --squash
32+
build:
33+
name: Update build dependencies
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v6
37+
- uses: DeterminateSystems/nix-installer-action@v21
38+
- name: Update flake.lock
39+
id: update
40+
uses: DeterminateSystems/update-flake-lock@v28
41+
with:
42+
branch: "update_flake_lock_build"
43+
inputs: nixpkgs-just
44+
pr-title: "deps: update build dependencies"
45+
pr-labels: |
46+
automated
47+
dependencies
48+
token: ${{ secrets.PR_BOT_PERSONAL_ACCESS_TOKEN }}
49+
- name: Enable auto-merge
50+
if: steps.update.outputs.pull-request-number != ''
51+
env:
52+
GH_TOKEN: ${{ secrets.PR_BOT_PERSONAL_ACCESS_TOKEN }}
53+
run: gh pr merge ${{ steps.update.outputs.pull-request-number }} --auto --squash

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
![License](https://img.shields.io/github/license/jtrrll/justix?label=license&logo=googledocs&logoColor=white)
77
<!-- markdownlint-enable MD013 -->
88

9-
Build Justfiles with Nix!
9+
Build justfiles with Nix!

dev_shells/default.nix

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{ inputs, self, ... }:
22
{
33
imports = [ inputs.devenv.flakeModule ];
4+
45
perSystem =
56
{
67
inputs',
@@ -9,11 +10,10 @@
910
}:
1011
{
1112
devenv = {
12-
modules = [
13+
modules = (lib.attrValues self.modules.devenv) ++ [
1314
{
1415
containers = lib.mkForce { }; # Workaround to remove containers from flake checks.
1516
}
16-
self.devenvModules.default
1717
];
1818
shells.default =
1919
{ lib, pkgs, ... }:
@@ -42,7 +42,7 @@
4242

4343
justix = {
4444
enable = true;
45-
justfile.config = {
45+
config = {
4646
recipes = {
4747
default = {
4848
attributes = {
@@ -62,7 +62,7 @@
6262
elif [ -d "$path" ]; then \
6363
while IFS= read -r -d "" file; do \
6464
files+=("$file"); \
65-
done < <(find "$path" ! -path '*/.*' ! -path '*/node_modules/*' -type f -print0); \
65+
done < <(find "$path" ! -path '*/.*' -type f -print0); \
6666
fi; \
6767
done; \
6868
[ ''${#files[@]} -gt 0 ] && ${lib.getExe inputs'.snekcheck.packages.default} --fix "''${files[@]}"
@@ -74,23 +74,11 @@
7474
};
7575
};
7676

77-
languages = {
78-
javascript = {
79-
bun.enable = true;
80-
enable = true;
81-
};
82-
nix = {
83-
enable = true;
84-
lsp.package = pkgs.nixd;
85-
};
86-
typescript.enable = true;
77+
languages.nix = {
78+
enable = true;
79+
lsp.package = pkgs.nixd;
8780
};
8881

89-
packages = [
90-
inputs'.bun2nix.packages.bun2nix
91-
pkgs.vtsls
92-
];
93-
9482
git-hooks = {
9583
default_stages = [ "pre-push" ];
9684
hooks = {

devenv_modules/default.nix

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)