From 14bbca969852f83550105dff5d1218fc62912f81 Mon Sep 17 00:00:00 2001 From: Christian Hoener zu Siederdissen Date: Tue, 17 Dec 2024 08:25:43 -0300 Subject: [PATCH] Quality of life changes * Stylish Haskell configuration included * Disabled nixpkgs-fmt (currently no idea why it breaks in the hook) * nonix pre-commit-hook (not tested myself) --- .gitignore | 1 + .pre-commit-config.yaml.nonix | 80 +++++++++++++++++++++++++++++++++++ .stylish-haskell.yaml | 32 ++++++++++++++ nix/shell.nix | 3 +- 4 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 .pre-commit-config.yaml.nonix create mode 100644 .stylish-haskell.yaml diff --git a/.gitignore b/.gitignore index 462c7c7..dd86fbb 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,4 @@ haddocks/ get-protocol-parameters.sh protocol-parameters-mainnet.json .pre-commit-config.yaml +tags diff --git a/.pre-commit-config.yaml.nonix b/.pre-commit-config.yaml.nonix new file mode 100644 index 0000000..91b3c8f --- /dev/null +++ b/.pre-commit-config.yaml.nonix @@ -0,0 +1,80 @@ +# DO NOT MODIFY +# This file was generated by git-hooks.nix +{ + "default_stages": [ + "pre-commit" + ], + "repos": [ + { + "hooks": [ + { + "always_run": false, + "args": [], + "entry": "/nix/store/l85yyds9b2jzv5swfq4hpjwv21dq7ylr-cabal-fmt-exe-cabal-fmt-0.1.12/bin/cabal-fmt --inplace ", + "exclude": "^$", + "exclude_types": [], + "fail_fast": false, + "files": "\\.(cabal)$", + "id": "cabal-fmt", + "language": "system", + "name": "cabal-fmt", + "pass_filenames": true, + "require_serial": false, + "stages": [ + "pre-commit" + ], + "types": [ + "file" + ], + "types_or": [], + "verbose": false + }, + { + "always_run": false, + "args": [], + "entry": " ", + "exclude": "^$", + "exclude_types": [], + "fail_fast": false, + "files": "", + "id": "nixpkgs-fmt", + "language": "system", + "name": "nixpkgs-fmt", + "pass_filenames": false, + "require_serial": false, + "stages": [ + "pre-commit" + ], + "types": [ + "file" + ], + "types_or": [], + "verbose": false + }, + { + "always_run": false, + "args": [], + "entry": "/nix/store/in4rzg7z6mkblbasxxsg6dik44jkngbj-stylish-haskell-exe-stylish-haskell-0.14.6.0/bin/stylish-haskell --inplace --config .stylish-haskell.yaml ", + "exclude": "^$", + "exclude_types": [], + "fail_fast": false, + "files": "\\.(hs|lhs)$", + "id": "stylish-haskell", + "language": "system", + "name": "stylish-haskell", + "pass_filenames": true, + "require_serial": false, + "stages": [ + "pre-commit" + ], + "types": [ + "file" + ], + "types_or": [], + "verbose": false + } + ], + "repo": "local" + } + ] +} diff --git a/.stylish-haskell.yaml b/.stylish-haskell.yaml new file mode 100644 index 0000000..9bc95c0 --- /dev/null +++ b/.stylish-haskell.yaml @@ -0,0 +1,32 @@ +steps: + + - simple_align: + cases: never + top_level_patterns: never + records: never + multi_way_if: never + + - imports: + align: none + post_qualify: true + + - language_pragmas: + remove_redundant: false + + - trailing_whitespace: {} + +columns: 80 + +newline: native + +language_extensions: + - GeneralizedNewtypeDeriving + - ImportQualifiedPost + - NumericUnderscores + - OverloadedStrings + - BangPatterns ## stylish-haskell reports an error when and expression starts with `!` + - TypeOperators ## stylish-haskell reports an error when importing type operators such as `import Prelude (type (~))` + +# stylish-haskell doesn't understand Cabal common-stanzas, so let's just +# disable it. +cabal: false diff --git a/nix/shell.nix b/nix/shell.nix index 8a79662..badcff7 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -9,6 +9,7 @@ in name = "smart-tokens-plutarch"; packages = [ pkgs.ghcid + pkgs.nixpkgs-fmt ]; env = { }; @@ -21,6 +22,6 @@ in # This step is necessary because `.pre-commit-config.yaml` is ignored by git. cabal-fmt.enable = true; stylish-haskell.enable = true; - nixpkgs-fmt.enable = true; + nixpkgs-fmt.enable = false; }; }