Add nixpkgs-fmt + associated checks

This commit is contained in:
adisbladis 2021-09-24 22:17:06 -05:00
parent 9030f0f8c5
commit 0d3e7c2240
No known key found for this signature in database
GPG key ID: 110BFAD44C6249B7
5 changed files with 40 additions and 19 deletions

View file

@ -12,17 +12,22 @@
let let
filterMesonBuild = dir: builtins.filterSource filterMesonBuild = dir: builtins.filterSource
(path: type: type != "directory" || baseNameOf path != "build") dir; (path: type: type != "directory" || baseNameOf path != "build")
dir;
in in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "nix-eval-jobs"; pname = "nix-eval-jobs";
version = "0.0.1"; version = "0.0.1";
src = if srcDir == null then filterMesonBuild ./. else srcDir; src = if srcDir == null then filterMesonBuild ./. else srcDir;
buildInputs = [ buildInputs = [
nlohmann_json nixFlakes boost nlohmann_json
nixFlakes
boost
]; ];
nativeBuildInputs = [ nativeBuildInputs = [
meson pkg-config ninja meson
pkg-config
ninja
# nlohmann_json can be only discovered via cmake files # nlohmann_json can be only discovered via cmake files
cmake cmake
]; ];

View file

@ -15,15 +15,26 @@
checks = { checks = {
editorconfig = pkgs.runCommand "editorconfig-checks" { editorconfig = pkgs.runCommand "editorconfig-check"
nativeBuildInputs = [ {
pkgs.editorconfig-checker nativeBuildInputs = [
]; pkgs.editorconfig-checker
} '' ];
} ''
editorconfig-checker ${self} editorconfig-checker ${self}
touch $out touch $out
''; '';
nixpkgs-fmt = pkgs.runCommand "fmt-check"
{
nativeBuildInputs = [
pkgs.nixpkgs-fmt
];
} ''
nixpkgs-fmt --check .
touch $out
'';
build = packages.nix-eval-jobs; build = packages.nix-eval-jobs;
}; };
@ -31,5 +42,6 @@
defaultPackage = self.packages.${system}.nix-eval-jobs; defaultPackage = self.packages.${system}.nix-eval-jobs;
devShell = pkgs.callPackage ./shell.nix drvArgs; devShell = pkgs.callPackage ./shell.nix drvArgs;
}); }
);
} }

View file

@ -2,13 +2,15 @@
, srcDir ? null , srcDir ? null
}: }:
(pkgs.callPackage ./default.nix { inherit srcDir; }).overrideAttrs(old: { (pkgs.callPackage ./default.nix { inherit srcDir; }).overrideAttrs (old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ nativeBuildInputs = old.nativeBuildInputs ++ [
pkgs.editorconfig-checker pkgs.editorconfig-checker
(pkgs.python3.withPackages(ps: [ pkgs.nixpkgs-fmt
(pkgs.python3.withPackages (ps: [
ps.pytest ps.pytest
])) ]))

View file

@ -1,5 +1,5 @@
let let
pkgs = import (builtins.getFlake (toString ./.)).inputs.nixpkgs {}; pkgs = import (builtins.getFlake (toString ./.)).inputs.nixpkgs { };
in in
{ {
builtJob = pkgs.writeText "job1" "job1"; builtJob = pkgs.writeText "job1" "job1";

View file

@ -1,12 +1,14 @@
{ {
inputs.nixpkgs.url = "github:NixOS/nixpkgs"; inputs.nixpkgs.url = "github:NixOS/nixpkgs";
outputs = { self, nixpkgs }: let outputs = { self, nixpkgs }:
pkgs = nixpkgs.legacyPackages.x86_64-linux; let
in { pkgs = nixpkgs.legacyPackages.x86_64-linux;
hydraJobs = { in
builtJob = pkgs.writeText "job1" "job1"; {
substitutedJob = pkgs.hello; hydraJobs = {
builtJob = pkgs.writeText "job1" "job1";
substitutedJob = pkgs.hello;
};
}; };
};
} }