This commit is contained in:
2026-02-05 16:04:00 +01:00
parent 53cf49f158
commit 4ac16cedc4
5 changed files with 151 additions and 22 deletions

60
flake.lock generated
View File

@@ -83,6 +83,22 @@
"type": "github" "type": "github"
} }
}, },
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1767039857,
"narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=",
"owner": "NixOS",
"repo": "flake-compat",
"rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": { "flake-parts": {
"inputs": { "inputs": {
"nixpkgs-lib": [ "nixpkgs-lib": [
@@ -138,6 +154,49 @@
"type": "github" "type": "github"
} }
}, },
"git-hooks": {
"inputs": {
"flake-compat": "flake-compat_2",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1769939035,
"narHash": "sha256-Fok2AmefgVA0+eprw2NDwqKkPGEI5wvR+twiZagBvrg=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "a8ca480175326551d6c4121498316261cbb5b260",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"git-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"home-manager": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@@ -579,6 +638,7 @@
"colmena": "colmena", "colmena": "colmena",
"disko": "disko", "disko": "disko",
"firefox-addons": "firefox-addons", "firefox-addons": "firefox-addons",
"git-hooks": "git-hooks",
"home-manager": "home-manager", "home-manager": "home-manager",
"nix-on-droid": "nix-on-droid", "nix-on-droid": "nix-on-droid",
"nix-secrets": "nix-secrets", "nix-secrets": "nix-secrets",

View File

@@ -43,16 +43,20 @@
url = "github:zhaofengli/colmena"; url = "github:zhaofengli/colmena";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
git-hooks = {
url = "github:cachix/git-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
}; };
outputs = outputs =
{ { self
self, , nixpkgs
nixpkgs, , home-manager
home-manager, , nix-on-droid
nix-on-droid, , nixgl
nixgl, , git-hooks
... , ...
}@inputs: }@inputs:
let let
inherit (self) outputs; inherit (self) outputs;
@@ -73,7 +77,12 @@
system = import ./hosts/${host}/system.nix; system = import ./hosts/${host}/system.nix;
modules = [ ./hosts/${host} ]; modules = [ ./hosts/${host} ];
specialArgs = { specialArgs = {
inherit inputs outputs dotsPath; inherit
inputs
outputs
dotsPath
self
;
}; };
} }
)) ))
@@ -128,6 +137,33 @@
; ;
}; };
checks.${system}.pre-commit-check = git-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixpkgs-fmt.enable = true;
statix.enable = true;
};
};
apps.${system}.pre-commit-install =
let
hooks = git-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixpkgs-fmt.enable = true;
statix.enable = true;
};
};
in
{
type = "app";
program = toString (
pkgs.writeShellScript "install-hooks" ''
${hooks.shellHook}
''
);
};
images.sd-image-aarch64 = self.nixosConfigurations.sd-image-aarch64.config.system.build.sdImage; images.sd-image-aarch64 = self.nixosConfigurations.sd-image-aarch64.config.system.build.sdImage;
}; };
} }

View File

@@ -1,10 +1,10 @@
{ { lib
lib, , inputs
inputs, , outputs
outputs, , self
config, , config
pkgs, , pkgs
... , ...
}: }:
let let
username = "h"; username = "h";
@@ -38,6 +38,7 @@ in
(import ../../modules/secrets { inherit lib inputs config; }) (import ../../modules/secrets { inherit lib inputs config; })
../../modules/docker ../../modules/docker
../../modules/syncthing ../../modules/syncthing
../../modules/git-hooks
]; ];
home-manager.users.${username} = import ../../home/hosts/andromache { home-manager.users.${username} = import ../../home/hosts/andromache {
@@ -99,6 +100,11 @@ in
]; ];
services = { services = {
git-hooks = {
enable = true;
flake-path = self;
};
xserver = { xserver = {
videoDrivers = [ "nvidia" ]; videoDrivers = [ "nvidia" ];
}; };

View File

@@ -1,10 +1,10 @@
{ { lib
lib, , inputs
inputs, , outputs
outputs, , self
config, , config
pkgs, , pkgs
... , ...
}: }:
let let
username = "h"; username = "h";
@@ -40,6 +40,7 @@ in
(import ../../modules/secrets { inherit lib inputs config; }) (import ../../modules/secrets { inherit lib inputs config; })
../../modules/docker ../../modules/docker
../../modules/syncthing ../../modules/syncthing
../../modules/git-hooks
]; ];
home-manager.users.${username} = import ../../home/hosts/astyanax { home-manager.users.${username} = import ../../home/hosts/astyanax {
@@ -97,6 +98,10 @@ in
boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
services = { services = {
git-hooks = {
enable = true;
flake-path = self;
};
fwupd.enable = true; fwupd.enable = true;
openssh = { openssh = {
enable = true; enable = true;

View File

@@ -0,0 +1,22 @@
{ config, lib, ... }:
{
options.services.git-hooks = {
enable = lib.mkEnableOption "Install git hooks for Nix flake";
flake-path = lib.mkOption {
type = lib.types.path;
description = "Path to Nix flake repository";
};
};
config = lib.mkIf config.services.git-hooks.enable {
system.activationScripts.git-hooks = lib.stringAfter [ "users" ] ''
if [ -d "${config.services.git-hooks.flake-path}/.git" ]; then
echo "🪝 Installing git hooks..."
cd ${config.services.git-hooks.flake-path}
nix run .#apps.x86_64-linux.pre-commit-install || true
echo " Done"
fi
'';
};
}