Skip to content

Commit eefdcd4

Browse files
committed
devenv: add tooling
Signed-off-by: Patrizio Bekerle <patrizio@bekerle.com>
1 parent dce5e15 commit eefdcd4

10 files changed

Lines changed: 211 additions & 39 deletions

File tree

.envrc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
use nix
1+
export DIRENV_WARN_TIMEOUT=20s
2+
3+
eval "$(devenv direnvrc)"
4+
5+
# The use_devenv function supports passing flags to the devenv command
6+
# For example: use devenv --impure --option services.postgres.enable:bool true
7+
use devenv

.github/workflows/format-check.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: 📄 Check formatting
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- release
7+
tags-ignore:
8+
- "*"
9+
pull_request:
10+
workflow_dispatch:
11+
12+
jobs:
13+
format-check:
14+
name: 📄 Check code formatting with "just fmt"
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: 🧰 Checkout code
18+
uses: actions/checkout@v5
19+
- name: ⚙️ Install Nix
20+
uses: cachix/install-nix-action@v31
21+
with:
22+
nix_path: nixpkgs=channel:nixos-unstable
23+
- name: 🔒 Cache dependencies
24+
uses: cachix/cachix-action@v16
25+
with:
26+
name: devenv
27+
- name: 🔧 Install devenv.sh
28+
run: nix profile install nixpkgs#devenv
29+
- name: 🌳 Format code
30+
run: devenv shell "just format-all"

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,13 @@ docker/owncloud/certificates/*
77
*.db*
88
*.cache
99
vendor
10+
11+
# Devenv
12+
.devenv*
13+
devenv.local.nix
14+
15+
# direnv
16+
.direnv
17+
18+
# pre-commit
19+
.pre-commit-config.yaml

devenv.lock

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
{
2+
"nodes": {
3+
"devenv": {
4+
"locked": {
5+
"dir": "src/modules",
6+
"lastModified": 1755798632,
7+
"owner": "cachix",
8+
"repo": "devenv",
9+
"rev": "e70f1e0a7da7ab9e74f2ed300cbf05f407fb107b",
10+
"type": "github"
11+
},
12+
"original": {
13+
"dir": "src/modules",
14+
"owner": "cachix",
15+
"repo": "devenv",
16+
"type": "github"
17+
}
18+
},
19+
"flake-compat": {
20+
"flake": false,
21+
"locked": {
22+
"lastModified": 1747046372,
23+
"owner": "edolstra",
24+
"repo": "flake-compat",
25+
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
26+
"type": "github"
27+
},
28+
"original": {
29+
"owner": "edolstra",
30+
"repo": "flake-compat",
31+
"type": "github"
32+
}
33+
},
34+
"git-hooks": {
35+
"inputs": {
36+
"flake-compat": "flake-compat",
37+
"gitignore": "gitignore",
38+
"nixpkgs": [
39+
"nixpkgs"
40+
]
41+
},
42+
"locked": {
43+
"lastModified": 1755446520,
44+
"owner": "cachix",
45+
"repo": "git-hooks.nix",
46+
"rev": "4b04db83821b819bbbe32ed0a025b31e7971f22e",
47+
"type": "github"
48+
},
49+
"original": {
50+
"owner": "cachix",
51+
"repo": "git-hooks.nix",
52+
"type": "github"
53+
}
54+
},
55+
"gitignore": {
56+
"inputs": {
57+
"nixpkgs": [
58+
"git-hooks",
59+
"nixpkgs"
60+
]
61+
},
62+
"locked": {
63+
"lastModified": 1709087332,
64+
"owner": "hercules-ci",
65+
"repo": "gitignore.nix",
66+
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
67+
"type": "github"
68+
},
69+
"original": {
70+
"owner": "hercules-ci",
71+
"repo": "gitignore.nix",
72+
"type": "github"
73+
}
74+
},
75+
"nixpkgs": {
76+
"locked": {
77+
"lastModified": 1755783167,
78+
"owner": "cachix",
79+
"repo": "devenv-nixpkgs",
80+
"rev": "4a880fb247d24fbca57269af672e8f78935b0328",
81+
"type": "github"
82+
},
83+
"original": {
84+
"owner": "cachix",
85+
"ref": "rolling",
86+
"repo": "devenv-nixpkgs",
87+
"type": "github"
88+
}
89+
},
90+
"root": {
91+
"inputs": {
92+
"devenv": "devenv",
93+
"git-hooks": "git-hooks",
94+
"nixpkgs": "nixpkgs",
95+
"pre-commit-hooks": [
96+
"git-hooks"
97+
]
98+
}
99+
}
100+
},
101+
"root": "root",
102+
"version": 7
103+
}

devenv.nix

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
pkgs,
3+
...
4+
}:
5+
6+
{
7+
# https://devenv.sh/supported-languages/php/
8+
languages.php.enable = true;
9+
10+
# https://devenv.sh/packages/
11+
packages = with pkgs; [
12+
just
13+
zellij
14+
];
15+
16+
enterShell = ''
17+
echo "🛠️ QOwnNotesAPI dev shell"
18+
echo "🐘 PHP version: $(php --version | head -n 1)"
19+
'';
20+
21+
# https://devenv.sh/git-hooks/
22+
git-hooks.hooks = {
23+
# https://devenv.sh/reference/options/#git-hookshookstreefmt
24+
# https://github.com/numtide/treefmt
25+
# https://github.com/numtide/treefmt-nix
26+
treefmt = {
27+
enable = true;
28+
settings.formatters = with pkgs; [
29+
nodePackages.prettier
30+
shfmt
31+
nixfmt-rfc-style
32+
statix
33+
taplo
34+
php83Packages.php-cs-fixer
35+
];
36+
};
37+
38+
# https://devenv.sh/reference/options/#git-hookshooksdeadnix
39+
# https://github.com/astro/deadnix
40+
deadnix = {
41+
enable = true;
42+
settings = {
43+
edit = true; # Allow to edit the file if it is not formatted
44+
};
45+
};
46+
};
47+
48+
# See full reference at https://devenv.sh/reference/options/
49+
}

devenv.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json
2+
inputs:
3+
nixpkgs:
4+
url: github:cachix/devenv-nixpkgs/rolling

docker/justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ bash-root:
4545

4646
# Run a sidecar container with more debugging tools
4747
slim-shell:
48-
slim debug --target {{ containerName }}
48+
nix-shell -p docker-slim --run "slim debug --target {{ containerName }}"
4949

5050
# Turn off maintenance mode
5151
maintenance-mode-off:

justfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ git-apply-patch:
4343
# Run the GitHub Actions test workflow locally with act
4444
[group('dev')]
4545
github-run-test:
46-
act -W .github/workflows/test.yml
46+
nix-shell -p act --run "act -W .github/workflows/test.yml"
4747

4848
# Open the project in the browser
4949
[group('dev')]
@@ -63,7 +63,12 @@ just-format:
6363
# Format all files
6464
[group('linter')]
6565
format args='':
66-
nix-shell -p treefmt nodePackages.prettier shfmt nixfmt-rfc-style statix taplo php83Packages.php-cs-fixer --run "treefmt {{ args }}"
66+
treefmt {{ args }}
67+
68+
# Format all files using pre-commit
69+
[group('linter')]
70+
format-all args='':
71+
pre-commit run --all-files {{ args }}
6772

6873
# Add git commit hashes to the .git-blame-ignore-revs file
6974
[group('linter')]

scripts/pre-commit.sh

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

shell.nix

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

0 commit comments

Comments
 (0)