Skip to content

Commit bf82940

Browse files
fix: force PermitRootLogin override and add flake check workflow
1 parent df09250 commit bf82940

6 files changed

Lines changed: 135 additions & 3 deletions

File tree

.github/workflows/check.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Check
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
- develop
9+
10+
jobs:
11+
nix-check:
12+
name: Nix flake check
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: cachix/install-nix-action@v27
18+
with:
19+
extra_nix_config: |
20+
experimental-features = nix-command flakes
21+
22+
- name: Check flake evaluation
23+
run: |
24+
nix flake check --no-build
25+
nix eval .#nixosConfigurations.csf-node.config.system.nixos.label
26+
nix eval .#nixosConfigurations.csf-node-arm64.config.system.nixos.label
27+
28+
- name: Run pre-commit hooks
29+
run: nix develop --command pre-commit run --all-files

flake.lock

Lines changed: 61 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,35 @@
33

44
inputs = {
55
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
6+
pre-commit-hooks.url = "github:cachix/git-hooks.nix";
7+
pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
68
};
79

8-
outputs = { self, nixpkgs }: let
10+
outputs = { self, nixpkgs, pre-commit-hooks }: let
911
versions = import ./versions.nix;
12+
system = "x86_64-linux";
13+
pkgs = nixpkgs.legacyPackages.${system};
1014

1115
mkSystem = { system, modules }: nixpkgs.lib.nixosSystem {
1216
inherit system;
1317
specialArgs = { inherit versions; };
1418
modules = modules;
1519
};
1620
in {
21+
checks.${system}.pre-commit = pre-commit-hooks.lib.${system}.run {
22+
src = ./.;
23+
hooks = {
24+
nixpkgs-fmt.enable = true;
25+
statix.enable = true;
26+
deadnix.enable = true;
27+
};
28+
};
29+
30+
devShells.${system}.default = pkgs.mkShell {
31+
inherit (self.checks.${system}.pre-commit) shellHook;
32+
packages = [ pkgs.nixpkgs-fmt pkgs.statix pkgs.deadnix ];
33+
};
34+
1735
nixosModules = {
1836
csf-agent = import ./modules/csf-agent.nix;
1937
csf-cp = import ./modules/csf-cp.nix;

modules/csf-setup.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ in
5252
services.openssh = {
5353
enable = true;
5454
settings = {
55-
PermitRootLogin = "no";
55+
PermitRootLogin = lib.mkForce "no";
5656
PasswordAuthentication = false;
5757
KbdInteractiveAuthentication = false;
5858
};

scripts/hooks/pre-commit

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
set -e
3+
4+
if ! command -v nix > /dev/null 2>&1; then
5+
exit 0
6+
fi
7+
8+
echo "nix: checking flake evaluation..."
9+
nix flake check --no-build 2>&1 || {
10+
echo "nix flake check failed — commit aborted"
11+
exit 1
12+
}
13+
echo "nix: ok"

scripts/install-hooks.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
set -e
3+
4+
HOOKS_DIR="$(git rev-parse --show-toplevel)/.git/hooks"
5+
SCRIPTS_DIR="$(git rev-parse --show-toplevel)/scripts/hooks"
6+
7+
for hook in "$SCRIPTS_DIR"/*; do
8+
name=$(basename "$hook")
9+
cp "$hook" "$HOOKS_DIR/$name"
10+
chmod +x "$HOOKS_DIR/$name"
11+
echo "installed: .git/hooks/$name"
12+
done

0 commit comments

Comments
 (0)