Move away from numtide

Get rid of the numtide shell, as it doesn't have any good support for
shellHook. Also, directly create the pre-commit check so that we can
leverage its resulting bits in the packages.

We now will have acces to things like pre-commit-config.yaml in the
folder structure
This commit is contained in:
Greg Hellings
2024-10-20 20:50:49 -05:00
parent 0c1b09404b
commit e4c678833b
5 changed files with 52 additions and 110 deletions
+42 -66
View File
@@ -3,7 +3,6 @@
description = "Greg's homepage";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
devshell.url = "github:numtide/devshell";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-root.url = "github:srid/flake-root";
hooks.url = "github:cachix/git-hooks.nix";
@@ -13,15 +12,11 @@
outputs =
{ flake-parts, ... }@inputs:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.devshell.flakeModule
inputs.flake-root.flakeModule
inputs.hooks.flakeModule
];
imports = [ inputs.flake-root.flakeModule ];
flake = {
# Universal things
# final: prev:
overlays.default = _: _: { };
overlays.default = _final: _prev: { };
};
systems = [
"x86_64-linux"
@@ -29,7 +24,7 @@
"aarch64-darwin"
];
perSystem =
{ pkgs, ... }@inputs':
{ pkgs, self', ... }@inputs':
let
naersk-lib = pkgs.callPackage inputs.naersk { };
in
@@ -38,11 +33,10 @@
inherit (inputs') system;
overlays = [ ];
};
# https://numtide.github.io/devshell/intro.html
devshells.default = rec {
devShells.default = pkgs.mkShell rec {
# These commands will be shown in the motd that users read
# upon entering the shell
packages = with pkgs; [
inputsFrom = with pkgs; [
expat
fontconfig
freetype
@@ -57,64 +51,46 @@
libxkbcommon
];
env = [
{
name = "LD_LIBRARY_PATH";
value = builtins.foldl' (a: b: "${a}:${b}/lib") "${pkgs.vulkan-loader}/lib" packages;
}
];
commands = [
{
package = pkgs.cargo;
category = "tools";
help = "Rust build and package tool";
}
{
package = pkgs.rustc;
category = "languages";
help = "Rust compiler";
}
{
package = pkgs.rustfmt;
category = "tools";
help = "Standard Rust formatting tool";
}
{
package = pkgs.clippy;
category = "tools";
help = "Rust linter";
}
{
package = pkgs.stdenv.cc;
category = "languages";
help = "C compiler to help with building native code";
}
{
package = pkgs.pre-commit;
category = "tools";
help = "Tool to help enforce commits make sense";
}
packages = with pkgs; [
cargo
clippy
pre-commit
rustc
rustfmt
stdenv.cc
];
buildInputs = self'.checks.pre-commit.enabledPackages;
shellHook =
let
lib_path = builtins.foldl' (a: b: "${a}:${b}/lib") "${pkgs.vulkan-loader}/lib" packages;
in
''
export LD_LIBRARY_PATH="${lib_path}"
''
+ self'.checks.pre-commit.shellHook;
};
pre-commit = {
check.enable = true;
settings.src = ./.;
settings.hooks = {
check-added-large-files.enable = true;
check-case-conflicts.enable = true;
check-merge-conflicts.enable = true;
check-symlinks.enable = true;
deadnix.enable = true;
end-of-file-fixer.enable = true;
fix-byte-order-marker.enable = true;
mixed-line-endings.enable = true;
nixfmt-rfc-style.enable = true;
trim-trailing-whitespace.enable = true;
# Rust hooks
cargo-check.enable = true;
clippy.enable = true;
rustfmt.enable = true;
checks = {
pre-commit = inputs.hooks.lib.${inputs'.system}.run {
src = ./.;
hooks = {
check-added-large-files.enable = true;
check-case-conflicts.enable = true;
check-merge-conflicts.enable = true;
check-symlinks.enable = true;
deadnix.enable = true;
end-of-file-fixer.enable = true;
fix-byte-order-marker.enable = true;
mixed-line-endings.enable = true;
nixfmt-rfc-style.enable = true;
trim-trailing-whitespace.enable = true;
# Rust hooks
cargo-check.enable = true;
clippy.enable = true;
rustfmt.enable = true;
};
};
};