Skip to content

Commit bf4b66e

Browse files
committed
nix: use devenv
Signed-off-by: Patrizio Bekerle <[email protected]>
1 parent c38d72b commit bf4b66e

File tree

9 files changed

+199
-49
lines changed

9 files changed

+199
-49
lines changed

.envrc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
use nix
1+
export DIRENV_WARN_TIMEOUT=20s
2+
3+
eval "$(devenv direnvrc)"
4+
5+
use devenv

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,13 @@
2020
.phpunit.result.cache
2121
###< phpunit/phpunit ###
2222
.phpunit.cache
23+
24+
# Devenv
25+
.devenv*
26+
devenv.local.nix
27+
28+
# direnv
29+
.direnv
30+
31+
# pre-commit
32+
.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": 1744588088,
7+
"owner": "cachix",
8+
"repo": "devenv",
9+
"rev": "1e6c06a058dae3791c0303eb99636cee9605c8d9",
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": 1733328505,
23+
"owner": "edolstra",
24+
"repo": "flake-compat",
25+
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
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": 1742649964,
44+
"owner": "cachix",
45+
"repo": "git-hooks.nix",
46+
"rev": "dcf5072734cb576d2b0c59b2ac44f5050b5eac82",
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": 1744463964,
78+
"owner": "NixOS",
79+
"repo": "nixpkgs",
80+
"rev": "2631b0b7abcea6e640ce31cd78ea58910d31e650",
81+
"type": "github"
82+
},
83+
"original": {
84+
"owner": "NixOS",
85+
"ref": "nixos-unstable",
86+
"repo": "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: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
pkgs,
3+
lib,
4+
config,
5+
inputs,
6+
...
7+
}:
8+
9+
{
10+
# https://devenv.sh/supported-languages/php/
11+
languages.php = {
12+
enable = true;
13+
version = "8.3";
14+
ini = ''
15+
memory_limit = 256M
16+
'';
17+
fpm.pools.web = {
18+
settings = {
19+
"pm" = "dynamic";
20+
"pm.max_children" = 5;
21+
"pm.start_servers" = 2;
22+
"pm.min_spare_servers" = 1;
23+
"pm.max_spare_servers" = 5;
24+
};
25+
phpEnv = {
26+
MATOMO_URL = "https://p.qownnotes.org";
27+
};
28+
};
29+
};
30+
31+
services.caddy.enable = true;
32+
services.caddy.virtualHosts."http://localhost:8000" = {
33+
extraConfig = ''
34+
root * public
35+
php_fastcgi unix/${config.languages.php.fpm.pools.web.socket}
36+
file_server
37+
'';
38+
};
39+
40+
# https://devenv.sh/basics/
41+
env.GREET = "devenv";
42+
43+
# https://devenv.sh/packages/
44+
packages = with pkgs; [
45+
git
46+
symfony-cli
47+
just # task runner
48+
zellij # smart terminal workspace
49+
lazygit # git terminal
50+
fzf # fuzzy finder
51+
52+
# Packages for treefmt
53+
nodePackages.prettier
54+
nixfmt-rfc-style
55+
shfmt
56+
statix
57+
taplo
58+
php83Packages.php-cs-fixer
59+
];
60+
61+
# https://devenv.sh/git-hooks/
62+
# git-hooks.hooks.shellcheck.enable = true;
63+
git-hooks.hooks.treefmt.enable = true;
64+
65+
# https://devenv.sh/integrations/dotenv/
66+
dotenv.enable = true;
67+
dotenv.filename = [
68+
".env"
69+
".env.local"
70+
];
71+
72+
# See full reference at https://devenv.sh/reference/options/
73+
}

devenv.yaml

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

justfile

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ alias fmt := format
1616

1717
# Open a terminal with the qownnotes-api session
1818
[group('dev')]
19-
term:
19+
term: term-kill
2020
zellij --layout term.kdl attach {{ sessionName }} -c
2121

2222
# Kill the qownnotes-api session
@@ -41,16 +41,6 @@ git-apply-patch:
4141
git diff --no-ext-diff --staged --binary > {{ transferDir }}/{{ sessionName }}.patch
4242
ls -l1t {{ transferDir }}/ | head -2
4343

44-
# Format all justfiles
45-
[group('linter')]
46-
just-format:
47-
#!/usr/bin/env bash
48-
# Find all files named "justfile" recursively and run just --fmt --unstable on them
49-
find . -type f -name "justfile" -print0 | while IFS= read -r -d '' file; do
50-
echo "Formatting $file"
51-
just --fmt --unstable -f "$file"
52-
done
53-
5444
# Format all files
5545
[group('linter')]
5646
format args='':

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.

term.kdl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ layout {
1010
focus true
1111
}
1212
pane split_direction="horizontal" {
13-
pane cwd="docker" command="docker" {
14-
args "compose" "up"
13+
pane command="devenv" {
14+
args "processes" "up"
1515
start_suspended false
1616
}
1717
pane command="composer" {

0 commit comments

Comments
 (0)