From 8b6ee9a76d568348b22aef2719b2582c431319ae Mon Sep 17 00:00:00 2001 From: staticvoid Date: Wed, 29 Jun 2022 21:29:48 +0300 Subject: [PATCH] Use devShells instead of ./scripts --- flake.nix | 69 +++++++++++++++++++++++++++++++++++++++++++++- scripts/develop.sh | 11 -------- 2 files changed, 68 insertions(+), 12 deletions(-) delete mode 100755 scripts/develop.sh diff --git a/flake.nix b/flake.nix index 5b57ef7..340100d 100644 --- a/flake.nix +++ b/flake.nix @@ -61,6 +61,7 @@ unordered-containers ]; license = nixpkgs.lib.licenses.gpl3Plus; + passthru = { inherit pkgs; }; }; thisNative = this "ghc922"; in @@ -72,6 +73,72 @@ program = "${thisNative}/bin/4r"; }; - devShells.default = thisNative.env; + devShells = + let unwords = nixpkgs'.lib.concatStringsSep " "; + options = [ + "-Wall" + "-Wcompat" + "-Wincomplete-uni-patterns" + "-Wredundant-constraints" + "-Wmissing-export-lists" + "-Wincomplete-record-updates" + "-Wmissing-deriving-strategies" + ]; + extensions = [ + "-XNoImplicitPrelude" + "-XNoFieldSelectors" + "-XOverloadedRecordDot" + "-XDuplicateRecordFields" + "-XBangPatterns" + "-XBinaryLiterals" + "-XBlockArguments" + "-XConstraintKinds" + "-XDataKinds" + "-XDeriveFunctor" + "-XDeriveGeneric" + "-XDerivingStrategies" + "-XFlexibleContexts" + "-XFlexibleInstances" + "-XGADTs" + "-XGeneralizedNewtypeDeriving" + "-XHexFloatLiterals" + "-XImportQualifiedPost" + "-XInstanceSigs" + "-XKindSignatures" + "-XLambdaCase" + "-XMultiParamTypeClasses" + "-XNumericUnderscores" + "-XOverloadedStrings" + "-XScopedTypeVariables" + "-XStandaloneDeriving" + "-XTupleSections" + "-XTypeApplications" + "-XTypeOperators" + "-XTypeSynonymInstances" + "-XUndecidableInstances" + ]; + findFiles = "$(find app -name '*.hs')"; + in + rec { + default = + thisNative.env.overrideAttrs (a: { + nativeBuildInputs = a.nativeBuildInputs ++ [ thisNative.passthru.pkgs.fourmolu ]; + }); + ghci = default.overrideAttrs (_: { + shellHook = '' + ghci ${unwords (options ++ extensions)} ${findFiles} + exit $? + ''; + }); + fourmolu = default.overrideAttrs (_: { + shellHook = '' + fourmolu --mode inplace \ + --indentation 2 --check-idempotence --import-export-comma-style leading \ + ${unwords (map (e: "-o ${e}") (options ++ extensions))} \ + ${findFiles} + exit $? + ''; + }); + }; }); } diff --git a/scripts/develop.sh b/scripts/develop.sh deleted file mode 100755 index 89cbb39..0000000 --- a/scripts/develop.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -set -x - -OPTS="-Wall -Wcompat -Wincomplete-uni-patterns -Wredundant-constraints -Wmissing-export-lists -Wincomplete-record-updates -Wmissing-deriving-strategies" - -EXTS="-XNoImplicitPrelude -XNoFieldSelectors -XOverloadedRecordDot -XDuplicateRecordFields -XBangPatterns -XBinaryLiterals -XBlockArguments -XConstraintKinds -XDataKinds -XDeriveFunctor -XDeriveGeneric -XDerivingStrategies -XFlexibleContexts -XFlexibleInstances -XGADTs -XGeneralizedNewtypeDeriving -XHexFloatLiterals -XImportQualifiedPost -XInstanceSigs -XKindSignatures -XLambdaCase -XMultiParamTypeClasses -XNumericUnderscores -XOverloadedStrings -XScopedTypeVariables -XStandaloneDeriving -XTupleSections -XTypeApplications -XTypeOperators -XTypeSynonymInstances -XUndecidableInstances" - -FILES=$(find app -name '*.hs') - -nix develop -c ghci $OPTS $EXTS $FILES