Skip to content

Commit

Permalink
feat: enable pre-commit checks
Browse files Browse the repository at this point in the history
  • Loading branch information
cfcosta committed Sep 11, 2024
1 parent bfdbfc1 commit 5d9dad2
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/result
/.direnv
/.luarc.json
/.pre-commit-config.yaml
79 changes: 79 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 36 additions & 7 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";

home-manager = {
url = "github:nix-community/home-manager/master";
inputs.nixpkgs.follows = "nixpkgs";
};
gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs = {
nixpkgs.follows = "nixpkgs";
gitignore.follows = "gitignore";
};
};

aider = {
url = "github:joshuavial/aider.nvim";
Expand Down Expand Up @@ -191,13 +201,17 @@
};

outputs =
inputs@{
nixpkgs,
{
self,
flake-utils,
home-manager,
nixpkgs,
pre-commit-hooks,
...
}:
let
inherit (self) inputs;

hmModule =
{
config,
Expand Down Expand Up @@ -245,16 +259,31 @@
(
{ pkgs, ... }:
{
home.username = "nightvim";
home.homeDirectory = if pkgs.stdenv.isLinux then "/home/nightvim" else "/Users/nightvim";

home.stateVersion = "23.05";
home = {
username = "nightvim";
homeDirectory = if pkgs.stdenv.isLinux then "/home/nightvim" else "/Users/nightvim";
stateVersion = "24.11";
};
}
)
];
}).activation-script;

checks.pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;

hooks = {
deadnix.enable = true;
nixfmt-rfc-style.enable = true;
statix.enable = true;

luacheck.enable = true;
stylua.enable = true;
};
};

devShell = pkgs.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
packages = with pkgs; [
stylua
nixfmt-rfc-style
Expand Down
40 changes: 31 additions & 9 deletions hm-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,26 @@ in
type = listOf (submodule {
options = {
name = mkOption { type = str; };

src = mkOption { type = path; };
depends = mkOption { type = listOf str; };
inputs = mkOption { type = listOf attrs; };

depends = mkOption {
type = listOf str;
default = [ ];
};

inputs = mkOption {
type = listOf attrs;
default = [ ];
};

config = mkOption { type = str; };
module = mkOption { type = str; };
lazy = mkOption { type = bool; };

lazy = mkOption {
type = bool;
default = false;
};
};
});
default = [ ];
Expand All @@ -31,6 +45,14 @@ in

config =
let
inherit (builtins)
concatStringsSep
foldl'
map
readFile
;
inherit (lib) mkIf;

quoteString = d: ''"${d}"'';
listToLua = list: ''
{${builtins.concatStringsSep " , " (builtins.map quoteString list)}}
Expand All @@ -49,22 +71,22 @@ in
end
)'';
in
(lib.mkIf cfg.enable {
mkIf cfg.enable {
programs.neovim.enable = true;

home.packages = builtins.foldl' (acc: p: acc ++ p.inputs) [ ] cfg.plugins;
home.packages = foldl' (acc: p: acc ++ p.inputs) [ ] cfg.plugins;

xdg.configFile = pluginFolders // {
"nvim/init.lua".text = ''
${builtins.readFile ./nv.lua}
${readFile ./nv.lua}
_nv_init()
${builtins.concatStringsSep "\n" (builtins.map mapSpec cfg.plugins)}
${concatStringsSep "\n" (map mapSpec cfg.plugins)}
${cfg.extraConfig}
${cfg.extraConfig}
_nv_finish()'';
};
});
};
}

0 comments on commit 5d9dad2

Please sign in to comment.