From 5e5c9d005dd25fa00c8ca2f309031a9e5238d423 Mon Sep 17 00:00:00 2001 From: Drazen Popovic Date: Sun, 15 Oct 2023 12:24:41 +0200 Subject: [PATCH] Migrates Purescript prelude stack to flake-parts --- extras/build.nix | 17 +++ extras/flake-purescript.nix | 10 +- extras/haskell-data.nix | 3 +- extras/lbf-nix/build.nix | 3 + extras/lbf-nix/lbf-haskell.nix | 4 +- extras/lbf-nix/lbf-plutus-purescript.nix | 28 ++++ extras/lbf-nix/lbf-prelude-purescript.nix | 29 ++++ extras/lbf-nix/lbf-purescript-plutus.nix | 22 --- extras/lbf-nix/lbf-purescript.nix | 126 +++++++++++------- flake.nix | 41 +----- lambda-buffers-codegen/app/Main.hs | 2 +- .../LambdaBuffers/Codegen/Purescript/Print.hs | 8 +- libs/build.nix | 18 +++ runtimes/haskell/lbr-plutus/build.nix | 3 +- runtimes/haskell/lbr-prelude/build.nix | 3 +- runtimes/purescript/lbr-prelude/build.nix | 57 +++++--- testsuites/lbt-plutus/golden/build.nix | 3 +- testsuites/lbt-prelude/api/build.nix | 6 + testsuites/lbt-prelude/golden/build.nix | 10 +- .../lbt-prelude-purescript/build.nix | 84 ++++++------ 20 files changed, 294 insertions(+), 183 deletions(-) create mode 100644 extras/build.nix create mode 100644 extras/lbf-nix/lbf-plutus-purescript.nix create mode 100644 extras/lbf-nix/lbf-prelude-purescript.nix delete mode 100644 extras/lbf-nix/lbf-purescript-plutus.nix diff --git a/extras/build.nix b/extras/build.nix new file mode 100644 index 00000000..06343c17 --- /dev/null +++ b/extras/build.nix @@ -0,0 +1,17 @@ +# TODO(bladyjoker): Using overlayAttrs here as a hack to share functions -.- Do this properly. +{ inputs, ... }: { + imports = [ + inputs.flake-parts.flakeModules.easyOverlay # Adds perSystem.overlayAttrs + ]; + perSystem = { pkgs, config, ... }: + { + + overlayAttrs = { + extras = { + purescriptFlake = import ./flake-purescript.nix pkgs; + haskellData = import ./haskell-data.nix pkgs; + }; + }; + + }; +} diff --git a/extras/flake-purescript.nix b/extras/flake-purescript.nix index 0a32dde0..fe080064 100644 --- a/extras/flake-purescript.nix +++ b/extras/flake-purescript.nix @@ -1,7 +1,13 @@ -pursProjOpts: +pkgs: pursProjOpts: let mkFlake = projectName: purs: { packages = { + "purescript:${projectName}:src" = pkgs.stdenv.mkDerivation { + name = "lbr-prelude-src"; + inherit (pursProjOpts) src; + phases = "installPhase"; + installPhase = "ln -s $src $out"; + }; "purescript:${projectName}:lib" = purs.compiled; "purescript:${projectName}:node-modules" = purs.nodeModules; "purescript:${projectName}:bundle" = purs.bundlePursProject { main = "Test.Main"; entrypoint = "app/index.js"; bundledModuleName = "dist/output.js"; }; @@ -16,4 +22,4 @@ let devShell = purs.devShell; }; in -mkFlake pursProjOpts.projectName (pursProjOpts.pkgs.purescriptProject pursProjOpts) +mkFlake pursProjOpts.projectName (pkgs.purescriptProject pursProjOpts) diff --git a/extras/haskell-data.nix b/extras/haskell-data.nix index 9d2a7bd9..97991d22 100644 --- a/extras/haskell-data.nix +++ b/extras/haskell-data.nix @@ -1,4 +1,5 @@ -{ pkgs, srcs, cabalDataPatterns, cabalPackageName, cabalPackageVersion ? "0.1.0.0" }: +# Makes a Cabal package with just a 'data' directory with proper 'data-filers' stanza +pkgs: { srcs, cabalDataPatterns, cabalPackageName, cabalPackageVersion ? "0.1.0.0" }: let cabalTemplate = pkgs.writeTextFile { name = "haskell-data.nix-cabal-template"; diff --git a/extras/lbf-nix/build.nix b/extras/lbf-nix/build.nix index 542a8634..e7ba25fe 100644 --- a/extras/lbf-nix/build.nix +++ b/extras/lbf-nix/build.nix @@ -11,6 +11,9 @@ lbfHaskell = import ./lbf-haskell.nix pkgs config.packages.lbf config.packages.lbg-haskell; lbfPreludeHaskell = import ./lbf-prelude-hs.nix pkgs config.packages.lbf config.packages.lbg-haskell; lbfPlutusHaskell = import ./lbf-plutus-hs-plutustx.nix pkgs config.packages.lbf config.packages.lbg-haskell; + lbfPurescript = import ./lbf-purescript.nix pkgs config.packages.lbf config.packages.lbg-purescript; + lbfPreludePurescript = import ./lbf-prelude-purescript.nix pkgs config.packages.lbf config.packages.lbg-purescript; + lbfPlutusPurescript = import ./lbf-plutus-purescript.nix pkgs config.packages.lbf config.packages.lbg-purescript; }; }; diff --git a/extras/lbf-nix/lbf-haskell.nix b/extras/lbf-nix/lbf-haskell.nix index 95ac6e46..22ed279c 100644 --- a/extras/lbf-nix/lbf-haskell.nix +++ b/extras/lbf-nix/lbf-haskell.nix @@ -1,4 +1,4 @@ -# Base API for constructing Haskell Cabal packages given .lbf schemas +# Base API for constructing Haskell Cabal packages given .lbf schemas # Nixpkgs pkgs: @@ -23,7 +23,7 @@ let # Classes for which to generate implementations for (default lbf-prelude classes). , classes ? [ ] , # Dependencies to include in the Cabal's `build-depends` stanza. - # examples: dependencies = [ "lbf-prelude" "lbr-prelude" ] + # examples: dependencies = [ "lbf-prelude" ] dependencies ? [ ] , configs ? [ ] , # Name of the package and also the name of the Cabal package. diff --git a/extras/lbf-nix/lbf-plutus-purescript.nix b/extras/lbf-nix/lbf-plutus-purescript.nix new file mode 100644 index 00000000..4f602ef9 --- /dev/null +++ b/extras/lbf-nix/lbf-plutus-purescript.nix @@ -0,0 +1,28 @@ +# Build .lbf schemas that use LB Plutus (and by extension LB Prelude) package and targets Purescript's CTL library. +pkgs: lbf: lbg-purescript: lbfPurescriptOpts: +let + utils = import ./utils.nix pkgs; + + lbfPurs = import ./lbf-prelude-purescript.nix pkgs lbf lbg-purescript; + lbfPurescriptOptsForPlutus = utils.overrideAttrs + { + imports = { + default = [ ]; + override = libs: libs ++ [ ../../libs/lbf-plutus ]; + }; + dependencies = { + default = [ ]; + override = deps: deps ++ [ "lbf-plutus" ]; + }; + classes = { + default = [ ]; + override = cls: cls ++ [ "Plutus.V1.PlutusData" ]; + }; + configs = { + default = [ ]; + override = cfgs: cfgs ++ [ ../../lambda-buffers-codegen/data/purescript-plutus-ctl.json ]; + }; + } + lbfPurescriptOpts; +in +lbfPurs lbfPurescriptOptsForPlutus diff --git a/extras/lbf-nix/lbf-prelude-purescript.nix b/extras/lbf-nix/lbf-prelude-purescript.nix new file mode 100644 index 00000000..42255dbb --- /dev/null +++ b/extras/lbf-nix/lbf-prelude-purescript.nix @@ -0,0 +1,29 @@ +# Build .lbf schemas that use LB Prelude package and targets Purescript's prelude (and friends) library. +pkgs: lbf: lbg-purescript: lbfPurescriptOpts: +let + utils = import ./utils.nix pkgs; + + lbfPurs = import ./lbf-purescript.nix pkgs lbf lbg-purescript; + lbfPurescriptOptsForPrelude = utils.overrideAttrs + { + imports = { + default = [ ]; + override = libs: libs ++ [ ../../libs/lbf-prelude ]; + }; + dependencies = { + default = [ ]; + override = deps: deps ++ [ "lbf-prelude" ]; + }; + classes = { + default = [ ]; + override = cls: cls ++ [ "Prelude.Eq" "Prelude.Json" ]; + }; + configs = { + default = [ ]; + override = cfgs: cfgs ++ [ ../../lambda-buffers-codegen/data/purescript-prelude-base.json ]; + }; + } + lbfPurescriptOpts; + +in +lbfPurs lbfPurescriptOptsForPrelude diff --git a/extras/lbf-nix/lbf-purescript-plutus.nix b/extras/lbf-nix/lbf-purescript-plutus.nix deleted file mode 100644 index 792ba956..00000000 --- a/extras/lbf-nix/lbf-purescript-plutus.nix +++ /dev/null @@ -1,22 +0,0 @@ -pkgs: -let - utils = import ./utils.nix pkgs; -in -lbf: lbg-purescript: lbfPurescriptOpts: (import ./lbf-purescript.nix) lbf lbg-purescript (utils.overrideAttrs -{ - "imports" = { - default = [ ]; - override = imps: imps ++ [ ../../libs/lbf-plutus ../../libs/lbf-prelude ]; - }; - "dependencies" = { - default = [ ]; - override = deps: deps ++ [ "lbf-prelude" "lbr-prelude" "lbf-plutus" "lbr-plutus" ]; - }; - # TODO(https://github.com/mlabs-haskell/lambda-buffers/issues/98): Add Prelude.Json once the issue is resolved - "classes" = { - default = [ ]; - override = classes: classes ++ [ "Plutus.V1.PlutusData" "Prelude.Eq" ]; - }; -} - lbfPurescriptOpts -) diff --git a/extras/lbf-nix/lbf-purescript.nix b/extras/lbf-nix/lbf-purescript.nix index f3ba95af..5a492eef 100644 --- a/extras/lbf-nix/lbf-purescript.nix +++ b/extras/lbf-nix/lbf-purescript.nix @@ -1,58 +1,84 @@ +# Base API for constructing Purescript packages given .lbf schemas + +# Nixpkgs +pkgs: # LambdaBuffers Frontend lbf: # LambdaBuffers Purescript Codegen lbg-purescript: -{ - # Nixpkgs - pkgs -, # Source that is passed to `lbf` as the `--import-path` flag and used to find `files`. - # Examples: src = ./api - src -, # Additional sources that are passed to `lbf` as the `--import-path` flag. - # Examples: imports = [ lbf-prelude ] - imports ? [ ] -, # .lbf files in `src` to compile and codegen. - # Examples: files = [ "Foo.lbf" "Foo/Bar.lbf" ] - files - # Classes for which to generate implementations for. -, classes ? [ "Prelude.Eq" "Prelude.Json" ] -, # TODO(bladyjoker): Dependencies to include in the `build` output - # examples: dependencies = [ "lbf-prelude" "lbr-prelude" ] - dependencies ? [ ] -, # Package name. - # Examples: name = "lbf-myproject" - name -, # Package version. - # Examples: version = "0.1.0.0" - version ? "0.1.0.0" -}: let utils = import ./utils.nix pkgs; -in -pkgs.stdenv.mkDerivation { - inherit src version; - pname = name; - outputs = [ "out" "build" ]; - buildInputs = [ - pkgs.cabal-install - lbf - pkgs.jq - ]; - buildPhase = '' - mkdir autogen - mkdir .work - lbf build ${utils.mkFlags "import-path" imports} ${utils.mkFlags "gen-class" classes} \ - --work-dir .work \ - --gen ${lbg-purescript}/bin/lbg-purescript \ - --gen-dir autogen \ - ${builtins.concatStringsSep " " files} - cat autogen/build.json - ''; + lbfPurescriptOpts = + { + # Source that is passed to `lbf` as the `--import-path` flag and used to find `files`. + # Examples: src = ./api + src + , # Additional sources that are passed to `lbf` as the `--import-path` flag. + # Examples: imports = [ lbf-prelude ] + imports ? [ ] + , # .lbf files in `src` to compile and codegen. + # Examples: files = [ "Foo.lbf" "Foo/Bar.lbf" ] + files + # Classes for which to generate implementations for (default lbf-prelude classes). + , classes ? [ ] + , # Dependencies to include in the Cabal's `build-depends` stanza. + # examples: dependencies = [ "lbf-prelude" ] + dependencies ? [ ] + , configs ? [ ] + , # Name of the package and also the name of the Cabal package. + # Examples: name = "lbf-myproject" + name + , # Version of the package and also the version of the Cabal package. + # Examples: version = "0.1.0.0" + version ? "0.1.0.0" + }: { inherit src imports files classes dependencies configs name version; }; + + lbf-build = import ./lbf-build.nix pkgs lbf; + + lbfBuild = opts: with (lbfPurescriptOpts opts); + lbf-build.build + { + inherit src; + opts = { + inherit files; + import-paths = imports; + gen = "${lbg-purescript}/bin/lbg-purescript"; + gen-classes = classes; + gen-dir = "autogen"; + gen-opts = builtins.map (c: "--config=${c}") configs; # WARN(bladyjoker): If I put quotes here everything breaks. + work-dir = ".work"; + }; + }; - installPhase = '' - mkdir -p $out/src; - cp -r autogen/* $out/src - mv autogen/build.json $build; - ''; -} + build = opts: with (lbfPurescriptOpts opts); + let + lbfBuilt = lbfBuild opts; + in + pkgs.stdenv.mkDerivation { + inherit src version; + pname = name; + outputs = [ "out" "buildjson" ]; + buildInputs = [ + pkgs.cabal-install + pkgs.jq + ]; + buildPhase = '' + ln -s ${lbfBuilt} autogen; + ln -s ${lbfBuilt.workdir} .work-dir; + ln -s ${lbfBuilt.buildjson} build.json; + ''; + + installPhase = '' + cp build.json $buildjson; + echo "Dependencies collected" + cat $buildjson; + + mkdir -p $out/src; + cp -r autogen/* $out/src + echo "Files generated" + find $out/; + ''; + }; +in +build diff --git a/flake.nix b/flake.nix index 4ce15d93..a36281ec 100644 --- a/flake.nix +++ b/flake.nix @@ -22,13 +22,16 @@ (import ./hercules-ci.nix) (import ./pre-commit.nix) (import ./docs/build.nix) + (import ./extras/build.nix) (import ./extras/lbf-nix/build.nix) (import ./libs/build.nix) (import ./runtimes/haskell/lbr-prelude/build.nix) (import ./runtimes/haskell/lbr-plutus/build.nix) + (import ./runtimes/purescript/lbr-prelude/build.nix) (import ./testsuites/lbt-prelude/api/build.nix) (import ./testsuites/lbt-prelude/golden/build.nix) (import ./testsuites/lbt-prelude/lbt-prelude-haskell/build.nix) + (import ./testsuites/lbt-prelude/lbt-prelude-purescript/build.nix) (import ./testsuites/lbt-plutus/api/build.nix) (import ./testsuites/lbt-plutus/golden/build.nix) (import ./testsuites/lbt-plutus/lbt-plutus-haskell/build.nix) @@ -174,17 +177,6 @@ # Runtimes - ## Prelude runtime - lbr-prelude - - ### Purescript - - lbrPreludePurs = pursFlake ( - import ./runtimes/purescript/lbr-prelude/build.nix { - inherit pkgs commonTools; - shellHook = config.pre-commit.installationScript; - } - ); - ## Plutus runtime - lbr-plutus ### Purescript @@ -200,14 +192,6 @@ lbfLibs = { - lbf-prelude-purs = lbfPurescript { - inherit pkgs; - name = "lbf-prelude"; - src = ./libs/lbf-prelude; - files = [ "Prelude.lbf" ]; - dependencies = [ "lbr-prelude" ]; - }; - lbf-plutus-purs = lbfPurescript { inherit pkgs; name = "lbf-plutus"; @@ -239,13 +223,6 @@ }; }; - lbtPreludePursFlake = pursFlake ( - import ./testsuites/lbt-prelude/lbt-prelude-purescript/build.nix { - inherit pkgs commonTools shellHook lbfPurescript; - inherit (lbrPurs) lbr-prelude-purs; - inherit (lbfLibs) lbf-prelude-purs; - } - ); ## Plutus test suite - lbt-plutus @@ -269,10 +246,6 @@ // compilerFlake.packages // frontendFlake.packages // codegenFlake.packages - // lbrPreludePurs.packages - // lbrPlutusPurs.packages - // lbtPreludePursFlake.packages - // lbtPlutusPursFlake.packages // clis // lbfLibs; @@ -282,20 +255,12 @@ dev-compiler = compilerFlake.devShell; dev-frontend = frontendFlake.devShell; dev-codegen = codegenFlake.devShell; - dev-lbr-prelude-purescript = lbrPreludePurs.devShell; - dev-lbr-plutus-purescript = lbrPlutusPurs.devShell; - dev-lbt-prelude-purescript = lbtPreludePursFlake.devShell; - dev-lbt-plutus-purescript = lbtPlutusPursFlake.devShell; lb = lbEnv; }; # nix flake check checks = devShells // packages // - lbrPreludePurs.checks // - lbrPlutusPurs.checks // - lbtPreludePursFlake.checks // - lbtPlutusPursFlake.checks // renameAttrs (n: "check-${n}") ( compilerFlake.checks // frontendFlake.checks // diff --git a/lambda-buffers-codegen/app/Main.hs b/lambda-buffers-codegen/app/Main.hs index e3075d61..63d90398 100644 --- a/lambda-buffers-codegen/app/Main.hs +++ b/lambda-buffers-codegen/app/Main.hs @@ -1,6 +1,6 @@ module Main (main) where -import Control.Applicative (Alternative (many), optional, (<**>)) +import Control.Applicative (Alternative (many), (<**>)) import GHC.IO.Encoding (setLocaleEncoding, utf8) import LambdaBuffers.Codegen.Cli.Gen (GenOpts (GenOpts)) import LambdaBuffers.Codegen.Cli.GenHaskell qualified as Haskell diff --git a/lambda-buffers-codegen/src/LambdaBuffers/Codegen/Purescript/Print.hs b/lambda-buffers-codegen/src/LambdaBuffers/Codegen/Purescript/Print.hs index 7f22b27a..6e78f5e1 100644 --- a/lambda-buffers-codegen/src/LambdaBuffers/Codegen/Purescript/Print.hs +++ b/lambda-buffers-codegen/src/LambdaBuffers/Codegen/Purescript/Print.hs @@ -113,7 +113,13 @@ printDerive iTyDefs d = do classes <- asks (view $ Print.ctxConfig . C.cfgClasses) case Map.lookup qcn classes of Nothing -> throwInternalError (d ^. #constraint . #sourceInfo) ("Missing capability to print " <> show qcn) - Just pqcns -> for pqcns (\pqcn -> printPursQClassImpl mn iTyDefs pqcn d) + Just pqcns -> + for + pqcns + ( \pqcn -> do + Print.importClass pqcn + printPursQClassImpl mn iTyDefs pqcn d + ) printPursQClassImpl :: MonadPrint m => PC.ModuleName -> PC.TyDefs -> Purs.QClassName -> PC.Derive -> m (Doc ann) printPursQClassImpl mn iTyDefs hqcn d = diff --git a/libs/build.nix b/libs/build.nix index f0d502fc..81f99b5a 100644 --- a/libs/build.nix +++ b/libs/build.nix @@ -13,6 +13,14 @@ configs = [ ../lambda-buffers-codegen/data/haskell-prelude-base.json ]; }; + lbf-prelude-purescript = config.overlayAttrs.lbf-nix.lbfPurescript { + name = "lbf-prelude"; + src = ./lbf-prelude; + files = [ "Prelude.lbf" ]; + classes = [ "Prelude.Eq" "Prelude.Json" ]; + configs = [ ../lambda-buffers-codegen/data/purescript-prelude-base.json ]; + }; + lbf-plutus-haskell = config.overlayAttrs.lbf-nix.lbfHaskell { name = "lbf-plutus"; src = ./lbf-plutus; @@ -23,6 +31,16 @@ configs = [ ../lambda-buffers-codegen/data/haskell-prelude-base.json ../lambda-buffers-codegen/data/haskell-plutus-plutustx.json ]; }; + lbf-plutus-purescript = config.overlayAttrs.lbf-nix.lbfPurescript { + name = "lbf-plutus"; + src = ./lbf-plutus; + imports = [ ./lbf-prelude ]; + files = [ "Plutus/V1.lbf" "Plutus/V2.lbf" ]; + classes = [ "Prelude.Eq" "Prelude.Json" "Plutus.V1.PlutusData" ]; + dependencies = [ "lbf-prelude" ]; + configs = [ ../lambda-buffers-codegen/data/purescript-prelude-base.json ../lambda-buffers-codegen/data/purescript-plutus-ctl.json ]; + }; + }; }; diff --git a/runtimes/haskell/lbr-plutus/build.nix b/runtimes/haskell/lbr-plutus/build.nix index 1f6bc388..39fd015e 100644 --- a/runtimes/haskell/lbr-plutus/build.nix +++ b/runtimes/haskell/lbr-plutus/build.nix @@ -60,7 +60,8 @@ self@{ inputs, ... }: lbr-plutus-haskell-src = pkgs.stdenv.mkDerivation { name = "lbr-plutus-haskell-src"; src = ./.; - installPhase = ''mkdir $out; cp -r $src/* $out;''; + phases = "installPhase"; + installPhase = "ln -s $src $out"; }; lbr-plutus-haskell-lib = hsNixFlake.packages."lbr-plutus:lib:lbr-plutus"; diff --git a/runtimes/haskell/lbr-prelude/build.nix b/runtimes/haskell/lbr-prelude/build.nix index a0e80c9c..56bf7f6a 100644 --- a/runtimes/haskell/lbr-prelude/build.nix +++ b/runtimes/haskell/lbr-prelude/build.nix @@ -59,7 +59,8 @@ self@{ inputs, ... }: lbr-prelude-haskell-src = pkgs.stdenv.mkDerivation { name = "lbr-prelude-haskell-src"; src = ./.; - installPhase = ''mkdir $out; cp -r $src/* $out;''; + phases = "installPhase"; + installPhase = "ln -s $src $out"; }; } // hsNixFlake.packages; diff --git a/runtimes/purescript/lbr-prelude/build.nix b/runtimes/purescript/lbr-prelude/build.nix index d7fd2595..532e4e58 100644 --- a/runtimes/purescript/lbr-prelude/build.nix +++ b/runtimes/purescript/lbr-prelude/build.nix @@ -1,24 +1,37 @@ -{ pkgs, commonTools, shellHook }: +{ inputs, lib, ... }: { - inherit pkgs; - src = ./.; - projectName = "lbr-prelude"; - strictComp = true; - packageJson = ./package.json; - packageLock = ./package-lock.json; - shell = { - withRuntime = false; - packageLockOnly = true; - packages = builtins.attrValues commonTools ++ [ - pkgs.nodejs_16 - pkgs.bashInteractive - pkgs.fd - ]; - shellHook = '' - export LC_CTYPE=C.UTF-8 - export LC_ALL=C.UTF-8 - export LANG=C.UTF-8 - ${shellHook} - ''; - }; + perSystem = { pkgs, system, inputs', config, ... }: + + let + pursFlake = config.overlayAttrs.extras.purescriptFlake { + inherit pkgs; + src = ./.; + projectName = "lbr-prelude"; + strictComp = true; + packageJson = ./package.json; + packageLock = ./package-lock.json; + shell = { + withRuntime = false; + packageLockOnly = true; + packages = #builtins.attrValues commonTools ++ [ + [ + pkgs.nodejs_16 + pkgs.bashInteractive + pkgs.fd + ]; + shellHook = '' + export LC_CTYPE=C.UTF-8; + export LC_ALL=C.UTF-8; + export LANG=C.UTF-8; + ${config.pre-commit.installationScript} + ''; + }; + }; + in + { + + devShells.dev-lbr-prelude-purescript = pursFlake.devShell; + inherit (pursFlake) packages checks; + + }; } diff --git a/testsuites/lbt-plutus/golden/build.nix b/testsuites/lbt-plutus/golden/build.nix index 95afb797..c047a4f6 100644 --- a/testsuites/lbt-plutus/golden/build.nix +++ b/testsuites/lbt-plutus/golden/build.nix @@ -3,8 +3,7 @@ perSystem = { pkgs, system, inputs', config, ... }: { packages = { - lbt-plutus-golden-haskell = import ../../../extras/haskell-data.nix { - inherit pkgs; + lbt-plutus-golden-haskell = config.overlayAttrs.extras.haskellData { srcs = [ ./. ]; cabalDataPatterns = [ "**/*.json" ]; cabalPackageName = "lbt-plutus-golden-data"; diff --git a/testsuites/lbt-prelude/api/build.nix b/testsuites/lbt-prelude/api/build.nix index df05dc3f..91a1e6c8 100644 --- a/testsuites/lbt-prelude/api/build.nix +++ b/testsuites/lbt-prelude/api/build.nix @@ -7,6 +7,12 @@ files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ]; }; + packages.lbf-prelude-golden-api-purescript = config.overlayAttrs.lbf-nix.lbfPreludePurescript { + name = "lbf-prelude-golden-api"; + src = ./.; + files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ]; + }; + }; } diff --git a/testsuites/lbt-prelude/golden/build.nix b/testsuites/lbt-prelude/golden/build.nix index f507ac77..1b445c99 100644 --- a/testsuites/lbt-prelude/golden/build.nix +++ b/testsuites/lbt-prelude/golden/build.nix @@ -5,12 +5,18 @@ devShells.dev-lbt-prelude-golden = config.devShells.dev-pre-commit; packages = { - lbt-prelude-golden-haskell = import ../../../extras/haskell-data.nix { - inherit pkgs; + lbt-prelude-golden-haskell = config.overlayAttrs.extras.haskellData { srcs = [ ./. ]; cabalDataPatterns = [ "**/*.json" ]; cabalPackageName = "lbt-prelude-golden-data"; }; + + lbt-prelude-golden-purescript = pkgs.stdenv.mkDerivation { + name = "lbt-prelude-golden-data"; + src = ./.; + phases = "installPhase"; + installPhase = "ln -s $src $out"; + }; }; }; diff --git a/testsuites/lbt-prelude/lbt-prelude-purescript/build.nix b/testsuites/lbt-prelude/lbt-prelude-purescript/build.nix index 3140e9ad..4473cccd 100644 --- a/testsuites/lbt-prelude/lbt-prelude-purescript/build.nix +++ b/testsuites/lbt-prelude/lbt-prelude-purescript/build.nix @@ -1,43 +1,51 @@ -{ pkgs, lbfPurescript, lbf-prelude-purs, lbr-prelude-purs, commonTools, shellHook }: +{ inputs, lib, ... }: { - inherit pkgs; - src = ./.; - projectName = "lbt-prelude"; - strictComp = true; - packageJson = ./package.json; - packageLock = ./package-lock.json; + perSystem = { pkgs, system, inputs', config, ... }: - extraSources = [ - (lbfPurescript { - inherit pkgs; - name = "lbf-golden"; - src = ./../api; - files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ]; - imports = [ ../../../libs/lbf-prelude ]; - }) - lbf-prelude-purs - lbr-prelude-purs - ]; - data = [ + let + pursFlake = config.overlayAttrs.extras.purescriptFlake { + src = ./.; + projectName = "lbt-prelude"; + strictComp = true; + packageJson = ./package.json; + packageLock = ./package-lock.json; + + extraSources = [ + config.packages.lbf-prelude-golden-api-purescript + config.packages.lbf-prelude-purescript + config.packages."purescript:lbr-prelude:src" + ]; + data = [ + { + name = "lbt-prelude-golden-data"; + path = config.packages.lbt-prelude-golden-purescript; + } + ]; + + shell = { + withRuntime = false; + packageLockOnly = true; + packages = #builtins.attrValues commonTools ++ [ + [ + pkgs.nodejs_16 + pkgs.bashInteractive + pkgs.fd + ]; + shellHook = '' + export LC_CTYPE=C.UTF-8; + export LC_ALL=C.UTF-8; + export LANG=C.UTF-8; + ${config.pre-commit.installationScript} + ''; + }; + + }; + in { - name = "lbt-prelude-golden-data"; - path = ../golden; - } - ]; - shell = { - withRuntime = false; - packageLockOnly = true; - packages = builtins.attrValues commonTools ++ [ - pkgs.nodejs_16 - pkgs.bashInteractive - pkgs.fd - ]; - shellHook = '' - export LC_CTYPE=C.UTF-8 - export LC_ALL=C.UTF-8 - export LANG=C.UTF-8 - ${shellHook} - ''; - }; + devShells.dev-lbt-prelude-purescript = pursFlake.devShell; + + inherit (pursFlake) packages checks; + + }; }