feat: enable pre-commit checks

This commit is contained in:
Michael Mandl 2024-07-10 13:40:41 +02:00
parent c2afb2c5d1
commit a13a15cbd9
Signed by: mandlm
GPG key ID: 088ED38F036C7AF2
12 changed files with 110 additions and 26 deletions

8
.envrc Normal file
View file

@ -0,0 +1,8 @@
use flake .nix
if on_git_branch; then
echo
git status --short --branch
echo
git fetch
fi

1
.gitignore vendored
View file

@ -2,4 +2,3 @@
# Ignore build outputs from performing a nix-build or `nix build` command
result
result-*

25
.nix/flake.lock Normal file
View file

@ -0,0 +1,25 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1720418205,
"narHash": "sha256-cPJoFPXU44GlhWg4pUk9oUPqurPlCFZ11ZQPk21GTPU=",
"rev": "655a58a72a6601292512670343087c2d75d859c1",
"revCount": 650378,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.650378%2Brev-655a58a72a6601292512670343087c2d75d859c1/019095fe-96b2-7a7c-ad7c-2131b3fb6fa7/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/NixOS/nixpkgs/0.1.%2A.tar.gz"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

32
.nix/flake.nix Normal file
View file

@ -0,0 +1,32 @@
{
description = "A flake editing flake";
inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz";
outputs = { nixpkgs, ... }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
pkgs = import nixpkgs { inherit system; };
});
in
{
devShells = forEachSupportedSystem ({ pkgs }: {
default = pkgs.mkShell.override
{
# Override stdenv in order to change compiler:
# stdenv = pkgs.clangStdenv;
}
{
packages = with pkgs; [
pre-commit
commitizen
];
shellHook = ''
pre-commit install --allow-missing-config --hook-type pre-commit --hook-type commit-msg
'';
};
});
};
}

27
.pre-commit-config.yaml Normal file
View file

@ -0,0 +1,27 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: detect-private-key
- id: mixed-line-ending
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.27.0
hooks:
- id: commitizen
stages: [commit-msg]
- repo: local
hooks:
- id: home-manager-check
name: Home Manager Config Check
entry: home-manager switch --dry-run
language: system
pass_filenames: false
exclude: ^docs/

View file

@ -1,2 +1 @@
# home-manager

View file

@ -82,7 +82,7 @@
uri=''${1}
dir=''${2}
if [[ -z ''${dir} ]]; then
if [[ -z ''${dir} ]]; then
dir=''$(basename ''${1} .git)
fi
@ -102,17 +102,17 @@
'')
(writeShellScriptBin "git-make-relative" ''
gitfile=''${1}
if [[ -z ''${gitfile} ]]; then
if [[ -z ''${gitfile} ]]; then
gitfile=".git"
fi
fi
if [[ ! -f ''${gitfile} ]]; then
if [[ ! -f ''${gitfile} ]]; then
echo "file ''${gitfile} does not exist"
exit 1
fi
exit 1
fi
gitdir=$(grep "gitdir:" ''${gitfile} | cut -d: -f2 | xargs)
rel_gitdir=$(realpath -s --relative-to=. ''${gitdir})
@ -123,4 +123,3 @@
'')
];
}

View file

@ -62,4 +62,3 @@
};
};
}

View file

@ -2,8 +2,8 @@
{
programs.zsh.initExtra = ''
if [ -f $HOME/.nix-profile/etc/profile.d/nix.sh ];
then
source $HOME/.nix-profile/etc/profile.d/nix.sh
then
source $HOME/.nix-profile/etc/profile.d/nix.sh
fi
function sc-log {
@ -24,16 +24,16 @@
if [ -z ''${update_file} ]; then
update_file=$(find build/tmp/deploy/images -name "*.swu" -type f | fzf --select-1)
fi
fi
if [ -z ''${update_file} ]; then
echo "no file selected"
return 1
echo "no file selected"
return 1
fi
if [ ! -f ''${update_file} ]; then
echo "file \"''${update_file}\" does not exist"
return 2
echo "file \"''${update_file}\" does not exist"
return 2
fi
echo "flashing ''${update_file} to device..."

View file

@ -1,6 +1,6 @@
{ pkgs, theme, ... }:
{
# symlink for a stable path
# symlink for a stable path
home.file.".vscode-extensions/vscode-lldb".source = pkgs.vscode-extensions.vadimcn.vscode-lldb;
programs = {
@ -16,14 +16,14 @@
vim-bbye
ansible-vim
# ui
# ui
dressing-nvim
# session handling
project-nvim
auto-session
# escape handling
# escape handling
better-escape-nvim
nvim-treesitter.withAllGrammars
@ -82,7 +82,7 @@
nvim-dap
nvim-dap-ui
# neorg
# neorg
neorg
neorg-telescope
];
@ -169,5 +169,3 @@
};
};
}

View file

@ -5,4 +5,3 @@
enableZshIntegration = true;
};
}

View file

@ -6,4 +6,3 @@
enableZshIntegration = true;
};
}