Skip to content

Commit

Permalink
feat: add nix based checks
Browse files Browse the repository at this point in the history
  • Loading branch information
JayRovacsek committed Nov 5, 2024
1 parent 8e5ca00 commit 2e9b691
Show file tree
Hide file tree
Showing 5 changed files with 310 additions and 0 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
12 changes: 12 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: checks

on:
push:

jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: DeterminateSystems/nix-installer-action@main
- run: nix flake check -Lv
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ yarn.lock
/playwright-report/
/blob-report/
/playwright/.cache/
result
184 changes: 184 additions & 0 deletions flake.lock

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

112 changes: 112 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
description = "Nodejs Dev Shell";

inputs = {
devshell.url = "github:numtide/devshell";
flake-utils.url = "github:numtide/flake-utils";
git-hooks = {
inputs.nixpkgs.follows = "nixpkgs";
url = "github:cachix/git-hooks.nix";
};
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";

nix-filter.url = "github:numtide/nix-filter";
};

outputs =
{
devshell,
flake-utils,
git-hooks,
nixpkgs,
nix-filter,
self,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
app-source = nix-filter.lib.filter {
root = ./.;
exclude = [ ];

include = [
"src"
(nix-filter.lib.matchExt "js")
(nix-filter.lib.matchExt "json")
(nix-filter.lib.matchExt "ts")
];
};

pkg-lock = builtins.fromJSON (builtins.readFile ./package.json);

pkgs = import nixpkgs {
overlays = [ devshell.overlays.default ];
inherit system;
};
in
{
checks.git-hooks = git-hooks.lib.${system}.run {
src = self;
hooks = {
actionlint.enable = true;

deadnix = {
enable = true;
settings.edit = true;
};

nixfmt-rfc-style.enable = true;

prettier = {
enable = true;
settings.write = true;
};

statix.enable = true;

statix-write = {
enable = true;
name = "Statix Write";
entry = "${pkgs.statix}/bin/statix fix";
language = "system";
pass_filenames = false;
};

trufflehog-verified = {
enable = pkgs.stdenv.isLinux;
name = "Trufflehog Search";
entry = "${pkgs.trufflehog}/bin/trufflehog git file://. --since-commit HEAD --only-verified --fail --no-update";
language = "system";
pass_filenames = false;
};
};
};

devShells.default = pkgs.devshell.mkShell {
devshell.startup.git-hooks.text = self.checks.${system}.git-hooks.shellHook;
name = "dev-shell";
packages = with pkgs; [
deadnix
nixfmt-rfc-style
nodejs_20
nodePackages.prettier
nodePackages.typescript
statix
];
};

formatter = pkgs.nixfmt-rfc-style;

packages = {
newwwie = pkgs.buildNpmPackage {
inherit (pkg-lock) version;
pname = "newwwie";
src = app-source;
npmDepsHash = "sha256-FGQpZmR5uSh3kLYyRPLG4KlQnnOzUxnJKeVkCVMabZM=";
};
};
}
);

}

0 comments on commit 2e9b691

Please sign in to comment.