From f617a8bf5949c1613d8c8d231385a7bab41402c2 Mon Sep 17 00:00:00 2001 From: Yura Lazarev Date: Fri, 7 Nov 2025 12:39:41 +0100 Subject: [PATCH 1/3] refactor(build): centralize Plutus dependencies in cabal Create plutus-deps common stanza with single version specification to eliminate duplicate declarations across library and executables. Reduces maintenance burden and ensures consistent Plutus versions across all build targets. --- plinth-template.cabal | 89 +++++++++++++++++++++++++++++-------------- 1 file changed, 60 insertions(+), 29 deletions(-) diff --git a/plinth-template.cabal b/plinth-template.cabal index 7334b5d..97f1227 100644 --- a/plinth-template.cabal +++ b/plinth-template.cabal @@ -5,48 +5,79 @@ license: build-type: Simple extra-doc-files: README.md -common options - ghc-options: -Wall - default-language: Haskell2010 +-- These options are supported by GHC and Plinth +common ghc-options + ghc-options: -Wall + default-language: Haskell2010 + default-extensions: + DataKinds + DeriveAnyClass + DeriveGeneric + DerivingStrategies + FlexibleContexts + FlexibleInstances + GeneralizedNewtypeDeriving + ImportQualifiedPost + LambdaCase + MultiParamTypeClasses + NumericUnderscores + OverloadedStrings + PatternSynonyms + RecordWildCards + ScopedTypeVariables + StandaloneDeriving + Strict + TemplateHaskell + TypeApplications + UndecidableInstances + ViewPatterns -library scripts - import: options - hs-source-dirs: src +-- These options are only for GHC builds (not supported by Plinth) +common ghc-only-options + import: ghc-options + default-extensions: GADTs + +-- These options are required for Plinth builds +common plinth-options + import: ghc-options + ghc-options: + -fobject-code -fno-full-laziness -fno-ignore-interface-pragmas + -fno-omit-interface-pragmas -fno-spec-constr -fno-specialise + -fno-strictness -fno-unbox-small-strict-fields + -fno-unbox-strict-fields -fplugin-opt + PlutusTx.Plugin:target-version=1.1.0 + +common plutus-deps + build-depends: + , plutus-core ^>=1.54.0.0 + , plutus-ledger-api ^>=1.54.0.0 + , plutus-tx ^>=1.54.0.0 + , plutus-tx-plugin ^>=1.54.0.0 + +library plinth-validators + import: plinth-options, plutus-deps + hs-source-dirs: src + build-depends: base exposed-modules: AuctionMintingPolicy AuctionValidator - build-depends: - , base - , plutus-core ^>=1.54.0.0 - , plutus-ledger-api ^>=1.54.0.0 - , plutus-tx ^>=1.54.0.0 - , plutus-tx-plugin ^>=1.54.0.0 - executable gen-auction-validator-blueprint - import: options - hs-source-dirs: app - main-is: GenAuctionValidatorBlueprint.hs + import: ghc-only-options, plutus-deps + hs-source-dirs: app + main-is: GenAuctionValidatorBlueprint.hs build-depends: , base , bytestring , containers - , plutus-core ^>=1.54.0.0 - , plutus-ledger-api ^>=1.54.0.0 - , plutus-tx ^>=1.54.0.0 - , plutus-tx-plugin ^>=1.54.0.0 - , scripts + , plinth-validators executable gen-minting-policy-blueprint - import: options - hs-source-dirs: app - main-is: GenMintingPolicyBlueprint.hs + import: ghc-only-options, plutus-deps + hs-source-dirs: app + main-is: GenMintingPolicyBlueprint.hs build-depends: , base , bytestring , containers - , plutus-core ^>=1.54.0.0 - , plutus-ledger-api ^>=1.54.0.0 - , plutus-tx ^>=1.54.0.0 - , plutus-tx-plugin ^>=1.54.0.0 - , scripts + , plinth-validators From 13cc7f63bd3b9d5216a93d3e64f19f3cce2147e4 Mon Sep 17 00:00:00 2001 From: Yura Lazarev Date: Fri, 7 Nov 2025 12:39:52 +0100 Subject: [PATCH 2/3] refactor(build): consolidate GHC options in cabal stanzas Move all compiler flags and language extensions from source files to centralized cabal stanzas for easier maintenance and consistency. Create three stanzas: - ghc-options: Common settings and 21 language extensions - ghc-only-options: GADTs (not supported by PlutusTx) - plinth-options: Plinth-specific compiler optimizations Rename library from 'scripts' to 'plinth-validators' for clarity. --- app/GenAuctionValidatorBlueprint.hs | 13 ------------- app/GenMintingPolicyBlueprint.hs | 18 ------------------ src/AuctionMintingPolicy.hs | 21 --------------------- src/AuctionValidator.hs | 26 -------------------------- 4 files changed, 78 deletions(-) diff --git a/app/GenAuctionValidatorBlueprint.hs b/app/GenAuctionValidatorBlueprint.hs index 8cdc79e..efb54ec 100644 --- a/app/GenAuctionValidatorBlueprint.hs +++ b/app/GenAuctionValidatorBlueprint.hs @@ -1,16 +1,3 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE DerivingStrategies #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE GADTs #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE NumericUnderscores #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeApplications #-} -{-# LANGUAGE UndecidableInstances #-} - module Main where import AuctionValidator diff --git a/app/GenMintingPolicyBlueprint.hs b/app/GenMintingPolicyBlueprint.hs index 5d9b2b9..8546697 100644 --- a/app/GenMintingPolicyBlueprint.hs +++ b/app/GenMintingPolicyBlueprint.hs @@ -1,21 +1,3 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE DeriveAnyClass #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE DerivingStrategies #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE GADTs #-} -{-# LANGUAGE ImportQualifiedPost #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE StandaloneDeriving #-} -{-# LANGUAGE TypeApplications #-} -{-# LANGUAGE UndecidableInstances #-} -{-# LANGUAGE ViewPatterns #-} - module Main where import AuctionMintingPolicy diff --git a/src/AuctionMintingPolicy.hs b/src/AuctionMintingPolicy.hs index e1be0a2..f6baaea 100644 --- a/src/AuctionMintingPolicy.hs +++ b/src/AuctionMintingPolicy.hs @@ -1,24 +1,3 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE DerivingStrategies #-} -{-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE ImportQualifiedPost #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE PatternSynonyms #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE Strict #-} -{-# LANGUAGE TemplateHaskell #-} -{-# LANGUAGE ViewPatterns #-} -{-# OPTIONS_GHC -fno-full-laziness #-} -{-# OPTIONS_GHC -fno-ignore-interface-pragmas #-} -{-# OPTIONS_GHC -fno-omit-interface-pragmas #-} -{-# OPTIONS_GHC -fno-spec-constr #-} -{-# OPTIONS_GHC -fno-specialise #-} -{-# OPTIONS_GHC -fno-strictness #-} -{-# OPTIONS_GHC -fno-unbox-small-strict-fields #-} -{-# OPTIONS_GHC -fno-unbox-strict-fields #-} -{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:target-version=1.1.0 #-} - module AuctionMintingPolicy where import PlutusCore.Version (plcVersion110) diff --git a/src/AuctionValidator.hs b/src/AuctionValidator.hs index 4bd9eac..042f85a 100644 --- a/src/AuctionValidator.hs +++ b/src/AuctionValidator.hs @@ -1,29 +1,3 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE DeriveAnyClass #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE DerivingStrategies #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE ImportQualifiedPost #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE PatternSynonyms #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE Strict #-} -{-# LANGUAGE TemplateHaskell #-} -{-# LANGUAGE TypeApplications #-} -{-# LANGUAGE UndecidableInstances #-} -{-# LANGUAGE ViewPatterns #-} -{-# OPTIONS_GHC -fno-full-laziness #-} -{-# OPTIONS_GHC -fno-ignore-interface-pragmas #-} -{-# OPTIONS_GHC -fno-omit-interface-pragmas #-} -{-# OPTIONS_GHC -fno-spec-constr #-} -{-# OPTIONS_GHC -fno-specialise #-} -{-# OPTIONS_GHC -fno-strictness #-} -{-# OPTIONS_GHC -fno-unbox-small-strict-fields #-} -{-# OPTIONS_GHC -fno-unbox-strict-fields #-} -{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:target-version=1.1.0 #-} - module AuctionValidator where import GHC.Generics (Generic) From 1b499f1a1d2371a3e2c29af5b54413be02012a69 Mon Sep 17 00:00:00 2001 From: Yura Lazarev Date: Fri, 7 Nov 2025 12:40:00 +0100 Subject: [PATCH 3/3] ci: add REPL verification to build workflow Extend build-devcontainer workflow to test cabal REPL loads successfully for lib:plinth-validators after build completes. Ensures REPL functionality is verified on every PR. --- .github/workflows/build-devcontainer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-devcontainer.yml b/.github/workflows/build-devcontainer.yml index 10ae926..96193af 100644 --- a/.github/workflows/build-devcontainer.yml +++ b/.github/workflows/build-devcontainer.yml @@ -20,4 +20,4 @@ jobs: -v ./.:/workspaces/plinth-template \ -w /workspaces/plinth-template \ -i ghcr.io/input-output-hk/devx-devcontainer:x86_64-linux.ghc96-iog \ - bash -ic "cabal update && cabal build all" + bash -ic "cabal update && cabal build all && echo ':q' | cabal repl lib:plinth-validators"