-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
78 lines (67 loc) · 2.37 KB
/
flake.nix
File metadata and controls
78 lines (67 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{
description = "Bole - Manage all package managers on your system";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
outputs = { nixpkgs, ... }: let
forAllSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
in {
devShells = forAllSystems (system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
default = pkgs.mkShellNoCC {
packages = with pkgs; [ typos ];
shellHook = ''
echo "Bole development environment"
if [ -d .git ]; then
mkdir -p .git/hooks
HOOK_PATH=.git/hooks/commit-msg
HOOK_TMP=.git/hooks/commit-msg.tmp
cat > "$HOOK_TMP" << 'EOF'
#!/usr/bin/env bash
set -euo pipefail
msg=$(head -1 "$1" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
if [[ ! "$msg" =~ ^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\([a-z0-9-]+\))?(!)?:[[:space:]].+ ]]; then
echo "✗ Invalid commit format. Use: <type>[scope][!]: <description>" >&2
echo " Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert" >&2
exit 1
fi
if [ ''${#msg} -gt 72 ]; then
echo "✗ Commit message too long (''${#msg}/72 chars)" >&2
exit 1
fi
echo "✓ Conventional commit format valid"
EOF
if [ ! -f "$HOOK_PATH" ] || ! cmp -s "$HOOK_TMP" "$HOOK_PATH"; then
mv -f "$HOOK_TMP" "$HOOK_PATH"
chmod +x "$HOOK_PATH"
echo "Git commit-msg hook all settled"
else
rm -f "$HOOK_TMP"
fi
fi
'';
};
});
# Simple check command for CI
checks = forAllSystems (system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
lint = pkgs.writeShellApplication {
name = "bole-lint";
runtimeInputs = with pkgs; [ cargo rustc rustfmt clippy typos ];
text = ''
set -euo pipefail
echo "Running format check..."
cargo fmt --all -- --check
echo "Running clippy..."
cargo clippy --all-targets --all-features --frozen -D warnings
echo "Running tests..."
cargo test --all-targets --all-features --frozen
echo "Running spell check..."
typos
echo "All checks passed!"
'';
};
});
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra);
};
}