From 0d3e7c2240890a9e304bd5cf3af6cd0ffa457077 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Fri, 24 Sep 2021 22:17:06 -0500 Subject: [PATCH] Add nixpkgs-fmt + associated checks --- default.nix | 11 ++++++++--- flake.nix | 24 ++++++++++++++++++------ shell.nix | 6 ++++-- tests/assets/ci.nix | 2 +- tests/assets/flake.nix | 16 +++++++++------- 5 files changed, 40 insertions(+), 19 deletions(-) diff --git a/default.nix b/default.nix index 811bdc7..abfcda4 100644 --- a/default.nix +++ b/default.nix @@ -12,17 +12,22 @@ let filterMesonBuild = dir: builtins.filterSource - (path: type: type != "directory" || baseNameOf path != "build") dir; + (path: type: type != "directory" || baseNameOf path != "build") + dir; in stdenv.mkDerivation rec { pname = "nix-eval-jobs"; version = "0.0.1"; src = if srcDir == null then filterMesonBuild ./. else srcDir; buildInputs = [ - nlohmann_json nixFlakes boost + nlohmann_json + nixFlakes + boost ]; nativeBuildInputs = [ - meson pkg-config ninja + meson + pkg-config + ninja # nlohmann_json can be only discovered via cmake files cmake ]; diff --git a/flake.nix b/flake.nix index 5ba3877..6e4dd50 100644 --- a/flake.nix +++ b/flake.nix @@ -15,15 +15,26 @@ checks = { - editorconfig = pkgs.runCommand "editorconfig-checks" { - nativeBuildInputs = [ - pkgs.editorconfig-checker - ]; - } '' + editorconfig = pkgs.runCommand "editorconfig-check" + { + nativeBuildInputs = [ + pkgs.editorconfig-checker + ]; + } '' editorconfig-checker ${self} touch $out ''; + nixpkgs-fmt = pkgs.runCommand "fmt-check" + { + nativeBuildInputs = [ + pkgs.nixpkgs-fmt + ]; + } '' + nixpkgs-fmt --check . + touch $out + ''; + build = packages.nix-eval-jobs; }; @@ -31,5 +42,6 @@ defaultPackage = self.packages.${system}.nix-eval-jobs; devShell = pkgs.callPackage ./shell.nix drvArgs; - }); + } + ); } diff --git a/shell.nix b/shell.nix index 736a1c3..7b97e75 100644 --- a/shell.nix +++ b/shell.nix @@ -2,13 +2,15 @@ , srcDir ? null }: -(pkgs.callPackage ./default.nix { inherit srcDir; }).overrideAttrs(old: { +(pkgs.callPackage ./default.nix { inherit srcDir; }).overrideAttrs (old: { nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.editorconfig-checker - (pkgs.python3.withPackages(ps: [ + pkgs.nixpkgs-fmt + + (pkgs.python3.withPackages (ps: [ ps.pytest ])) diff --git a/tests/assets/ci.nix b/tests/assets/ci.nix index 48bf177..3aa2eca 100644 --- a/tests/assets/ci.nix +++ b/tests/assets/ci.nix @@ -1,5 +1,5 @@ let - pkgs = import (builtins.getFlake (toString ./.)).inputs.nixpkgs {}; + pkgs = import (builtins.getFlake (toString ./.)).inputs.nixpkgs { }; in { builtJob = pkgs.writeText "job1" "job1"; diff --git a/tests/assets/flake.nix b/tests/assets/flake.nix index bbd81a6..c383510 100644 --- a/tests/assets/flake.nix +++ b/tests/assets/flake.nix @@ -1,12 +1,14 @@ { inputs.nixpkgs.url = "github:NixOS/nixpkgs"; - outputs = { self, nixpkgs }: let - pkgs = nixpkgs.legacyPackages.x86_64-linux; - in { - hydraJobs = { - builtJob = pkgs.writeText "job1" "job1"; - substitutedJob = pkgs.hello; + outputs = { self, nixpkgs }: + let + pkgs = nixpkgs.legacyPackages.x86_64-linux; + in + { + hydraJobs = { + builtJob = pkgs.writeText "job1" "job1"; + substitutedJob = pkgs.hello; + }; }; - }; }