diff --git a/default.nix b/default.nix index 74164e1..e72dd52 100644 --- a/default.nix +++ b/default.nix @@ -145,6 +145,7 @@ with rec # version from `package.yaml` and create a dummy module that we inject in the # `ghci` command. niv-devshell = haskellPackages.shellFor { + buildInputs = [ pkgs.nixpkgs-fmt ]; packages = ps: [ ps.niv ]; shellHook = '' repl_for() { diff --git a/nix/default.nix b/nix/default.nix index 144718e..a4d3eee 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -2,6 +2,7 @@ import sources.nixpkgs { overlays = [ (_: pkgs: { inherit sources; }) + (_: pkgs: { nixpkgs-fmt = import pkgs.sources.nixpkgs-fmt {}; }) (_: pkgs: { termtosvg = pkgs.callPackage ./termtosvg.nix {}; }) ]; config = {}; diff --git a/nix/sources.json b/nix/sources.json index a4b32f6..4204651 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -11,6 +11,18 @@ "url": "https://github.com/NixOS/nixpkgs-channels/archive/d85e435b7bded2596d7b201bcd938c94d8a921c1.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, + "nixpkgs-fmt": { + "branch": "master", + "description": "Nix code formatter for nixpkgs [maintainer=@zimbatm]", + "homepage": "https://nix-community.github.io/nixpkgs-fmt/", + "owner": "nix-community", + "repo": "nixpkgs-fmt", + "rev": "2a64f4b6a597d0d62004ffcec3ae4fd83cd1efc8", + "sha256": "01kx4y1d4c5fjvpcffk92pk9hdbgg5j9h2ryqy2hfm54s7mb0k63", + "type": "tarball", + "url": "https://github.com/nix-community/nixpkgs-fmt/archive/2a64f4b6a597d0d62004ffcec3ae4fd83cd1efc8.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, "termtosvg": { "branch": "develop", "description": "Record terminal sessions as SVG animations", diff --git a/script/test b/script/test index cc623aa..381f293 100755 --- a/script/test +++ b/script/test @@ -2,6 +2,7 @@ #!nix-shell -i bash #!nix-shell -I nixpkgs=./nix #!nix-shell -p nix +#!nix-shell -p nixpkgs-fmt #!nix-shell --pure unset NIX_SSL_CERT_FILE @@ -32,4 +33,11 @@ fi # Build and create a root nix-build ${nixargs[@]} +echo "Formatting" +if ! nixpkgs-fmt --check . ; then + echo + echo 'run `nixpkgs-fmt .` to fix this issue' + exit 1 +fi + echo "all good"