From bbddc5e34bcf37b8f55563269ba9f5d417c6430f Mon Sep 17 00:00:00 2001 From: Peter Dragos Date: Thu, 24 Mar 2022 17:13:44 -0400 Subject: [PATCH 1/2] update flake --- agora/Agora/AuthorityToken.hs | 4 +- agora/Agora/Utils.hs | 4 +- flake.lock | 33 ++++++++-- flake.nix | 116 ++++++++++++++++------------------ 4 files changed, 84 insertions(+), 73 deletions(-) diff --git a/agora/Agora/AuthorityToken.hs b/agora/Agora/AuthorityToken.hs index 3a00148..4050348 100644 --- a/agora/Agora/AuthorityToken.hs +++ b/agora/Agora/AuthorityToken.hs @@ -15,14 +15,14 @@ import Plutarch.Api.V1 ( PAddress (..), PCredential (..), PCurrencySymbol (..), - PMap (..), PScriptContext (..), PScriptPurpose (..), PTxInInfo (..), PTxInfo (..), PTxOut (..), - PValue (..), ) +import Plutarch.Api.V1.AssocMap (PMap (PMap)) +import Plutarch.Api.V1.Value (PValue (PValue)) import Plutarch.Builtin (pforgetData) import Plutarch.List (pfoldr') import Plutarch.Monadic qualified as P diff --git a/agora/Agora/Utils.hs b/agora/Agora/Utils.hs index 2afa33a..7cb9825 100644 --- a/agora/Agora/Utils.hs +++ b/agora/Agora/Utils.hs @@ -41,7 +41,6 @@ import Plutarch.Api.V1 ( PCurrencySymbol, PDatum, PDatumHash, - PMap (PMap), PMaybeData (PDJust), PPubKeyHash, PTokenName, @@ -50,8 +49,9 @@ import Plutarch.Api.V1 ( PTxInfo (PTxInfo), PTxOut (PTxOut), PTxOutRef, - PValue (PValue), ) +import Plutarch.Api.V1.AssocMap (PMap (PMap)) +import Plutarch.Api.V1.Value (PValue (PValue)) import Plutarch.Builtin (ppairDataBuiltin) import Plutarch.Internal (punsafeCoerce) import Plutarch.Monadic qualified as P diff --git a/flake.lock b/flake.lock index 713ed75..a5cacae 100644 --- a/flake.lock +++ b/flake.lock @@ -679,7 +679,7 @@ "nixpkgs": [ "apropos-tx", "haskell-nix", - "nixpkgs-2105" + "nixpkgs-unstable" ], "nixpkgs-2003": "nixpkgs-2003", "nixpkgs-2105": "nixpkgs-2105", @@ -731,6 +731,8 @@ "hpc-coveralls": "hpc-coveralls_2", "nix-tools": "nix-tools_2", "nixpkgs": [ + "plutarch", + "haskell-nix", "nixpkgs-2111" ], "nixpkgs-2003": "nixpkgs-2003_2", @@ -1123,6 +1125,22 @@ "type": "github" } }, + "nixpkgs-2111_4": { + "locked": { + "lastModified": 1647902355, + "narHash": "sha256-SySJ8IRaogpc/BPOkysA+kzq9URvXthoeKIemaTKCiM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "31aa631dbc496500efd2507baaed39626f6650f2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-21.11-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs-nixops": { "locked": { "lastModified": 1630248577, @@ -1274,6 +1292,7 @@ "haskell-nix", "nixpkgs-unstable" ], + "nixpkgs-2111": "nixpkgs-2111_4", "plutus": "plutus_2", "protolude": "protolude", "safe-coloured-text": "safe-coloured-text", @@ -1283,17 +1302,17 @@ "validity": "validity" }, "locked": { - "lastModified": 1646941827, - "narHash": "sha256-/TmkSDVOYD0Nsf6/tsyCSWhFUIeefwPn0Lz1oeZ7lyQ=", - "owner": "Plutonomicon", + "lastModified": 1648145467, + "narHash": "sha256-yrq0CJbZPrDmrEeI/RqNmKGHoHasMsnknug7kPLUsRU=", + "owner": "peter-mlabs", "repo": "plutarch", - "rev": "cb29ca64df4ed193d94a062e3fe26aa37e59b7bc", + "rev": "2ddf1d1b6efc43598ca3502471f6ace596f920ec", "type": "github" }, "original": { - "owner": "Plutonomicon", + "owner": "peter-mlabs", + "ref": "liqwid/extra", "repo": "plutarch", - "rev": "cb29ca64df4ed193d94a062e3fe26aa37e59b7bc", "type": "github" } }, diff --git a/flake.nix b/flake.nix index fdf0dd8..87be54c 100644 --- a/flake.nix +++ b/flake.nix @@ -3,6 +3,12 @@ inputs.nixpkgs.follows = "plutarch/nixpkgs"; inputs.haskell-nix.follows = "plutarch/haskell-nix"; + # temporary fix for nix versions that have the transitive follows bug + # see https://github.com/NixOS/nix/issues/6013 + inputs.nixpkgs-2111 = { url = "github:NixOS/nixpkgs/nixpkgs-21.11-darwin"; }; + + inputs.plutarch.url = "github:peter-mlabs/plutarch/liqwid/extra"; + inputs.plutarch.inputs.nixpkgs.follows = "plutarch/haskell-nix/nixpkgs-unstable"; # https://github.com/mlabs-haskell/apropos-tx/pull/28 inputs.apropos-tx.url = @@ -10,48 +16,33 @@ inputs.apropos-tx.inputs.nixpkgs.follows = "plutarch/haskell-nix/nixpkgs-unstable"; - # temporary fix for nix versions that have the transitive follows bug - # see https://github.com/NixOS/nix/issues/6013 - inputs.nixpkgs-2111 = { url = "github:NixOS/nixpkgs/nixpkgs-21.11-darwin"; }; - - inputs.plutarch.url = - "github:Plutonomicon/plutarch?rev=cb29ca64df4ed193d94a062e3fe26aa37e59b7bc"; - inputs.plutarch.inputs.nixpkgs.follows = - "plutarch/haskell-nix/nixpkgs-unstable"; - outputs = inputs@{ self, nixpkgs, haskell-nix, plutarch, ... }: let - supportedSystems = with nixpkgs.lib.systems.supported; - tier1 ++ tier2 ++ tier3; + supportedSystems = with nixpkgs.lib.systems.supported; tier1 ++ tier2 ++ tier3; perSystem = nixpkgs.lib.genAttrs supportedSystems; - nixpkgsFor = system: - import nixpkgs { - inherit system; - overlays = [ haskell-nix.overlay ]; - inherit (haskell-nix) config; - }; - - nixpkgsFor' = system: - import nixpkgs { - inherit system; - inherit (haskell-nix) config; - }; + nixpkgsFor = system: import nixpkgs { inherit system; overlays = [ haskell-nix.overlay ]; inherit (haskell-nix) config; }; + nixpkgsFor' = system: import nixpkgs { inherit system; inherit (haskell-nix) config; }; ghcVersion = "ghc921"; projectFor = system: - let pkgs = nixpkgsFor system; - in let pkgs' = nixpkgsFor' system; - in (nixpkgsFor system).haskell-nix.cabalProject' { + let pkgs = nixpkgsFor system; in + let pkgs' = nixpkgsFor' system; in + (nixpkgsFor system).haskell-nix.cabalProject' { src = ./.; compiler-nix-name = ghcVersion; inherit (plutarch) cabalProjectLocal; extraSources = plutarch.extraSources ++ [ { src = inputs.plutarch; - subdirs = [ "." "plutarch-test" "plutarch-extra" ]; + subdirs = [ + "." + "plutarch-test" + "plutarch-extra" + "plutarch-numeric" + ]; } { src = inputs.apropos-tx; @@ -66,24 +57,28 @@ # We use the ones from Nixpkgs, since they are cached reliably. # Eventually we will probably want to build these with haskell.nix. - nativeBuildInputs = [ - pkgs'.git - pkgs'.haskellPackages.apply-refact - pkgs'.fd - pkgs'.cabal-install - pkgs'.haskell.packages."${ghcVersion}".hlint - pkgs'.haskellPackages.cabal-fmt - pkgs'.nixpkgs-fmt - pkgs'.graphviz - ]; + nativeBuildInputs = with pkgs'; + [ + entr + haskellPackages.apply-refact + git + fd + cabal-install + hlint + haskellPackages.cabal-fmt + nixpkgs-fmt + graphviz + ]; inherit (plutarch) tools; additional = ps: [ ps.plutarch - ps.plutarch-test + ps.tasty-quickcheck ps.apropos-tx ps.plutarch-extra + ps.plutarch-numeric + ps.plutarch-test ]; }; }; @@ -92,45 +87,42 @@ let pkgs = nixpkgsFor system; pkgs' = nixpkgsFor' system; - inherit (pkgs.haskell-nix.tools ghcVersion { - inherit (plutarch.tools) fourmolu hlint; - }) - fourmolu hlint; - in pkgs.runCommand "format-check" { - nativeBuildInputs = [ - pkgs'.git - pkgs'.fd - pkgs'.haskellPackages.cabal-fmt - pkgs'.nixpkgs-fmt - fourmolu - hlint - ]; - } '' + in + pkgs.runCommand "format-check" + { + nativeBuildInputs = [ pkgs'.git pkgs'.fd pkgs'.haskellPackages.cabal-fmt pkgs'.nixpkgs-fmt (pkgs.haskell-nix.tools ghcVersion { inherit (plutarch.tools) fourmolu; }).fourmolu ]; + } '' export LC_CTYPE=C.UTF-8 export LC_ALL=C.UTF-8 export LANG=C.UTF-8 cd ${self} make format_check mkdir $out - ''; - in { + '' + ; + in + { project = perSystem projectFor; flake = perSystem (system: (projectFor system).flake { }); packages = perSystem (system: self.flake.${system}.packages); checks = perSystem (system: - self.flake.${system}.checks // { + self.flake.${system}.checks + // { formatCheck = formatCheckFor system; - }); + } + ); check = perSystem (system: - (nixpkgsFor system).runCommand "combined-test" { - checksss = builtins.attrValues self.checks.${system}; - } '' + (nixpkgsFor system).runCommand "combined-test" + { + checksss = builtins.attrValues self.checks.${system}; + } '' echo $checksss touch $out - ''); + '' + ); devShell = perSystem (system: self.flake.${system}.devShell); - defaultPackage = - perSystem (system: self.flake.${system}.packages."agora:lib:agora"); }; } + + From a9e8f43ca5e004b8455144c2055474a51e71c31b Mon Sep 17 00:00:00 2001 From: Peter Dragos Date: Thu, 24 Mar 2022 19:15:10 -0400 Subject: [PATCH 2/2] upstream Agora `extra`s --- agora.cabal | 3 +- agora/Plutarch/Api/V1/These.hs | 62 ---------------------------------- agora/Plutarch/These.hs | 12 ------- flake.lock | 24 ++++++------- 4 files changed, 13 insertions(+), 88 deletions(-) delete mode 100644 agora/Plutarch/Api/V1/These.hs delete mode 100644 agora/Plutarch/These.hs diff --git a/agora.cabal b/agora.cabal index 8d17d47..65039ad 100644 --- a/agora.cabal +++ b/agora.cabal @@ -95,6 +95,7 @@ common deps , data-default-class , generics-sop , plutarch + , plutarch-extra , plutus-core , plutus-ledger-api , plutus-tx @@ -128,8 +129,6 @@ library other-modules: Agora.Utils Agora.Utils.Value - Plutarch.Api.V1.These - Plutarch.These hs-source-dirs: agora diff --git a/agora/Plutarch/Api/V1/These.hs b/agora/Plutarch/Api/V1/These.hs deleted file mode 100644 index e1ae1ed..0000000 --- a/agora/Plutarch/Api/V1/These.hs +++ /dev/null @@ -1,62 +0,0 @@ -{-# OPTIONS_GHC -Wno-orphans #-} - -module Plutarch.Api.V1.These (PTheseData (..)) where - -import GHC.Generics qualified as GHC -import Generics.SOP -import Plutarch.DataRepr (PIsDataReprInstances (PIsDataReprInstances)) -import Plutarch.Lift ( - PConstantRepr, - PConstanted, - PLifted, - PUnsafeLiftDecl, - pconstantFromRepr, - pconstantToRepr, - ) -import Plutus.V1.Ledger.Api qualified as Plutus -import PlutusTx.These qualified as PlutusThese - -data PTheseData (a :: PType) (b :: PType) (s :: S) - = PDThis (Term s (PDataRecord '["_0" ':= a])) - | PDThat (Term s (PDataRecord '["_0" ':= b])) - | PDThese (Term s (PDataRecord '["_0" ':= a, "_1" ':= b])) - deriving stock (GHC.Generic) - deriving anyclass (Generic, PIsDataRepr) - deriving - (PlutusType, PIsData) - via PIsDataReprInstances (PTheseData a b) - -instance - ( Plutus.ToData (PLifted a) - , Plutus.ToData (PLifted b) - , Plutus.FromData (PLifted a) - , Plutus.FromData (PLifted b) - , PLift a - , PLift b - ) => - PUnsafeLiftDecl (PTheseData a b) - where - type PLifted (PTheseData a b) = PlutusThese.These (PLifted a) (PLifted b) - -{- TODO: Make PTheseData an instance of PConstant: - https://github.com/Plutonomicon/plutarch/pull/355 --} - -instance - ( PLifted (PConstanted a) ~ a - , Plutus.ToData b - , Plutus.FromData b - , Plutus.ToData a - , Plutus.FromData a - , PConstant a - , PLifted (PConstanted b) ~ b - , Plutus.FromData b - , Plutus.ToData b - , PConstant b - ) => - PConstant (PlutusThese.These a b) - where - type PConstantRepr (PlutusThese.These a b) = [(Plutus.Data, Plutus.Data)] - type PConstanted (PlutusThese.These a b) = PTheseData (PConstanted a) (PConstanted b) - pconstantToRepr _t = undefined - pconstantFromRepr _t = undefined diff --git a/agora/Plutarch/These.hs b/agora/Plutarch/These.hs deleted file mode 100644 index f9b225a..0000000 --- a/agora/Plutarch/These.hs +++ /dev/null @@ -1,12 +0,0 @@ -module Plutarch.These (PThese (..)) where - -import GHC.Generics qualified as GHC -import Generics.SOP - --- | Plutus These type with Scott-encoded representation. -data PThese (a :: PType) (b :: PType) (s :: S) - = PThis (Term s a) - | PThat (Term s b) - | PThese (Term s a) (Term s b) - deriving stock (GHC.Generic) - deriving anyclass (Generic, PlutusType) diff --git a/flake.lock b/flake.lock index a5cacae..a8f99c4 100644 --- a/flake.lock +++ b/flake.lock @@ -885,11 +885,11 @@ "iohk-nix_2": { "flake": false, "locked": { - "lastModified": 1646330344, - "narHash": "sha256-EbhMDeneH26wDi+x5kz8nfru/dE9JZ241hJed4a8lz8=", + "lastModified": 1648032999, + "narHash": "sha256-3uCz+gJppvM7z6CUCkBbFSu60WgIE+e3oXwXiAiGWSY=", "owner": "input-output-hk", "repo": "iohk-nix", - "rev": "0a0126d8fb1bdc61ce1fd2ef61cf396de800fdad", + "rev": "5e667b374153327c7bdfdbfab8ef19b1f27d4aac", "type": "github" }, "original": { @@ -1095,11 +1095,11 @@ }, "nixpkgs-2111_2": { "locked": { - "lastModified": 1646844010, - "narHash": "sha256-NRDLmpjmBMNBRr/BiztSsGht5wJYl8WZFzj+b+6LhLk=", + "lastModified": 1647902355, + "narHash": "sha256-SySJ8IRaogpc/BPOkysA+kzq9URvXthoeKIemaTKCiM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "d59edd3833597be12763f1f017c7ad666cf1b810", + "rev": "31aa631dbc496500efd2507baaed39626f6650f2", "type": "github" }, "original": { @@ -1127,11 +1127,11 @@ }, "nixpkgs-2111_4": { "locked": { - "lastModified": 1647902355, - "narHash": "sha256-SySJ8IRaogpc/BPOkysA+kzq9URvXthoeKIemaTKCiM=", + "lastModified": 1644510859, + "narHash": "sha256-xjpVvL5ecbyi0vxtVl/Fh9bwGlMbw3S06zE5nUzFB8A=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "31aa631dbc496500efd2507baaed39626f6650f2", + "rev": "0d1d5d7e3679fec9d07f2eb804d9f9fdb98378d3", "type": "github" }, "original": { @@ -1302,11 +1302,11 @@ "validity": "validity" }, "locked": { - "lastModified": 1648145467, - "narHash": "sha256-yrq0CJbZPrDmrEeI/RqNmKGHoHasMsnknug7kPLUsRU=", + "lastModified": 1648163186, + "narHash": "sha256-UfaSb4nk9HWzsj1Kb8RJuPV+iw1Nl4E2+97KOwIwcao=", "owner": "peter-mlabs", "repo": "plutarch", - "rev": "2ddf1d1b6efc43598ca3502471f6ace596f920ec", + "rev": "0638dbd706bc2c5f48f9f40be7bbe1986a778698", "type": "github" }, "original": {