From fbfab906ad85a97a54ab811fc8815f60f5ed0750 Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 16 Jan 2025 19:59:27 +0100 Subject: [PATCH 01/14] wip --- flake.lock | 255 ++---------------- flake.nix | 30 +-- nix/agda-with-stdlib.nix | 123 +++++++++ nix/build-latex-doc.nix | 6 +- nix/build-latex.nix | 13 +- nix/latex-documents.nix | 142 +++++----- nix/metatheory-site.nix | 64 +++++ nix/{ => old_nix}/agda.nix | 40 +-- nix/old_nix/build-latex-doc.nix | 42 +++ nix/old_nix/build-latex.nix | 51 ++++ nix/old_nix/latex-documents.nix | 87 ++++++ nix/old_nix/outputs.nix | 85 ++++++ .../plutus-metatheory-site2.nix} | 20 +- nix/old_nix/project.nix | 141 ++++++++++ nix/old_nix/r-with-packages.nix | 14 + nix/old_nix/shell.nix | 115 ++++++++ nix/old_nix/unraveling-recursion-paper.nix | 52 ++++ nix/outputs.nix | 220 +++++++++------ nix/pkgs.nix | 13 + nix/project.nix | 54 ++-- nix/r-with-packages.nix | 2 +- nix/shell.nix | 152 ++++++----- nix/unraveling-recursion-paper.nix | 20 +- nix/utils.nix | 19 ++ 24 files changed, 1210 insertions(+), 550 deletions(-) create mode 100644 nix/agda-with-stdlib.nix create mode 100644 nix/metatheory-site.nix rename nix/{ => old_nix}/agda.nix (83%) create mode 100644 nix/old_nix/build-latex-doc.nix create mode 100644 nix/old_nix/build-latex.nix create mode 100644 nix/old_nix/latex-documents.nix create mode 100644 nix/old_nix/outputs.nix rename nix/{plutus-metatheory-site.nix => old_nix/plutus-metatheory-site2.nix} (89%) create mode 100644 nix/old_nix/project.nix create mode 100644 nix/old_nix/r-with-packages.nix create mode 100644 nix/old_nix/shell.nix create mode 100644 nix/old_nix/unraveling-recursion-paper.nix create mode 100644 nix/pkgs.nix create mode 100644 nix/utils.nix diff --git a/flake.lock b/flake.lock index fda5da8524b..6b857c65aa9 100644 --- a/flake.lock +++ b/flake.lock @@ -117,24 +117,6 @@ "type": "github" } }, - "easy-purescript-nix": { - "inputs": { - "flake-utils": "flake-utils" - }, - "locked": { - "lastModified": 1710161569, - "narHash": "sha256-lcIRIOFCdIWEGyKyG/tB4KvxM9zoWuBRDxW+T+mvIb0=", - "owner": "justinwoo", - "repo": "easy-purescript-nix", - "rev": "117fd96acb69d7d1727df95b6fde9d8715e031fc", - "type": "github" - }, - "original": { - "owner": "justinwoo", - "repo": "easy-purescript-nix", - "type": "github" - } - }, "flake-compat": { "flake": false, "locked": { @@ -153,21 +135,6 @@ } }, "flake-compat_2": { - "locked": { - "lastModified": 1733328505, - "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-compat_3": { "flake": false, "locked": { "lastModified": 1696426674, @@ -187,24 +154,6 @@ "inputs": { "systems": "systems" }, - "locked": { - "lastModified": 1685518550, - "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_2": { - "inputs": { - "systems": "systems_2" - }, "locked": { "lastModified": 1731533236, "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", @@ -219,24 +168,6 @@ "type": "github" } }, - "flake-utils_3": { - "inputs": { - "systems": "systems_3" - }, - "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "ghc-8.6.5-iohk": { "flake": false, "locked": { @@ -257,8 +188,7 @@ "gitignore": { "inputs": { "nixpkgs": [ - "iogx", - "pre-commit-hooks-nix", + "pre-commit-hooks", "nixpkgs" ] }, @@ -556,59 +486,21 @@ "type": "indirect" } }, - "iogx": { - "inputs": { - "CHaP": [ - "CHaP" - ], - "easy-purescript-nix": "easy-purescript-nix", - "flake-compat": "flake-compat_2", - "flake-utils": "flake-utils_2", - "hackage": [ - "hackage" - ], - "haskell-nix": [ - "haskell-nix" - ], - "iohk-nix": "iohk-nix", - "nix2container": "nix2container", - "nixpkgs": [ - "nixpkgs" - ], - "nixpkgs-stable": "nixpkgs-stable", - "pre-commit-hooks-nix": "pre-commit-hooks-nix", - "sphinxcontrib-haddock": "sphinxcontrib-haddock" - }, - "locked": { - "lastModified": 1733738060, - "narHash": "sha256-uZZB/JE7ED7QWfsj9UOQriu3E5kDCtgWMvLCVujnqAo=", - "owner": "input-output-hk", - "repo": "iogx", - "rev": "507209c0acf0aaf607626d73b1711ea0afde7108", - "type": "github" - }, - "original": { - "owner": "input-output-hk", - "repo": "iogx", - "type": "github" - } - }, "iohk-nix": { "inputs": { "blst": "blst", "nixpkgs": [ - "iogx", "nixpkgs" ], "secp256k1": "secp256k1", "sodium": "sodium" }, "locked": { - "lastModified": 1732287300, - "narHash": "sha256-lURsE6HdJX0alscWhbzCWyLRK8GpAgKuXeIgX31Kfqg=", + "lastModified": 1734618971, + "narHash": "sha256-5StB/VhWHOj3zlBxshqVFa6cwAE0Mk/wxRo3eEfcy74=", "owner": "input-output-hk", "repo": "iohk-nix", - "rev": "262cb2aec2ddd914124bab90b06fe24a1a74d02c", + "rev": "dc900a3448e805243b0ed196017e8eb631e32240", "type": "github" }, "original": { @@ -671,25 +563,6 @@ "type": "github" } }, - "nix2container": { - "inputs": { - "flake-utils": "flake-utils_3", - "nixpkgs": "nixpkgs_2" - }, - "locked": { - "lastModified": 1730479402, - "narHash": "sha256-79NLeNjpCa4mSasmFsE3QA6obURezF0TUO5Pm+1daog=", - "owner": "nlewo", - "repo": "nix2container", - "rev": "5fb215a1564baa74ce04ad7f903d94ad6617e17a", - "type": "github" - }, - "original": { - "owner": "nlewo", - "repo": "nix2container", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1657693803, @@ -850,38 +723,6 @@ "type": "github" } }, - "nixpkgs-stable": { - "locked": { - "lastModified": 1690680713, - "narHash": "sha256-NXCWA8N+GfSQyoN7ZNiOgq/nDJKOp5/BHEpiZP8sUZw=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "b81af66deb21f73a70c67e5ea189568af53b1e8c", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "b81af66deb21f73a70c67e5ea189568af53b1e8c", - "type": "github" - } - }, - "nixpkgs-stable_2": { - "locked": { - "lastModified": 1730741070, - "narHash": "sha256-edm8WG19kWozJ/GqyYx2VjW99EdhjKwbY3ZwdlPAAlo=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "d063c1dd113c91ab27959ba540c0d9753409edf3", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-24.05", - "repo": "nixpkgs", - "type": "github" - } - }, "nixpkgs-unstable": { "locked": { "lastModified": 1729980323, @@ -899,21 +740,6 @@ } }, "nixpkgs_2": { - "locked": { - "lastModified": 1712920918, - "narHash": "sha256-1yxFvUcJfUphK9V91KufIQom7gCsztza0H4Rz2VCWUU=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "92323443a56f4e9fc4e4b712e3119f66d0969297", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_3": { "locked": { "lastModified": 1730768919, "narHash": "sha256-8AKquNnnSaJRXZxc5YmF/WfmxiHX6MMZZasRP6RRQkE=", @@ -946,41 +772,38 @@ "type": "github" } }, - "pre-commit-hooks-nix": { + "pre-commit-hooks": { "inputs": { - "flake-compat": "flake-compat_3", + "flake-compat": "flake-compat_2", "gitignore": "gitignore", - "nixpkgs": "nixpkgs_3", - "nixpkgs-stable": "nixpkgs-stable_2" + "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1733318908, - "narHash": "sha256-SVQVsbafSM1dJ4fpgyBqLZ+Lft+jcQuMtEL3lQWx2Sk=", + "lastModified": 1737043064, + "narHash": "sha256-I/OuxGwXwRi5gnFPsyCvVR+IfFstA+QXEpHu1hvsgD8=", "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "rev": "6f4e2a2112050951a314d2733a994fbab94864c6", + "repo": "git-hooks.nix", + "rev": "94ee657f6032d913fe0ef49adaa743804635b0bb", "type": "github" }, "original": { "owner": "cachix", - "repo": "pre-commit-hooks.nix", + "repo": "git-hooks.nix", "type": "github" } }, "root": { "inputs": { "CHaP": "CHaP", + "flake-utils": "flake-utils", "hackage": "hackage", "haskell-nix": "haskell-nix", - "iogx": "iogx", + "iohk-nix": "iohk-nix", "nixpkgs": [ "haskell-nix", - "nixpkgs-unstable" + "nixpkgs" ], - "nixpkgs-2405": [ - "haskell-nix", - "nixpkgs-2405" - ] + "pre-commit-hooks": "pre-commit-hooks" } }, "secp256k1": { @@ -1017,22 +840,6 @@ "type": "github" } }, - "sphinxcontrib-haddock": { - "flake": false, - "locked": { - "lastModified": 1594136664, - "narHash": "sha256-O9YT3iCUBHP3CEF88VDLLCO2HSP3HqkNA2q2939RnVY=", - "owner": "michaelpj", - "repo": "sphinxcontrib-haddock", - "rev": "f3956b3256962b2d27d5a4e96edb7951acf5de34", - "type": "github" - }, - "original": { - "owner": "michaelpj", - "repo": "sphinxcontrib-haddock", - "type": "github" - } - }, "stackage": { "flake": false, "locked": { @@ -1063,36 +870,6 @@ "repo": "default", "type": "github" } - }, - "systems_2": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "systems_3": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 858647c425c..d9cf3faa340 100644 --- a/flake.nix +++ b/flake.nix @@ -3,16 +3,7 @@ inputs = { - iogx = { - url = "github:input-output-hk/iogx"; - inputs.hackage.follows = "hackage"; - inputs.CHaP.follows = "CHaP"; - inputs.haskell-nix.follows = "haskell-nix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - - nixpkgs.follows = "haskell-nix/nixpkgs-unstable"; - nixpkgs-2405.follows = "haskell-nix/nixpkgs-2405"; + nixpkgs.follows = "haskell-nix/nixpkgs"; hackage = { url = "github:input-output-hk/hackage.nix"; @@ -28,16 +19,21 @@ url = "github:input-output-hk/haskell.nix"; inputs.hackage.follows = "hackage"; }; - }; - outputs = inputs: - inputs.iogx.lib.mkFlake { - inherit inputs; - repoRoot = ./.; - systems = [ "x86_64-darwin" "x86_64-linux" "aarch64-darwin" ]; - outputs = import ./nix/outputs.nix; + iohk-nix = { + url = "github:input-output-hk/iohk-nix"; + inputs.nixpkgs.follows = "nixpkgs"; }; + flake-utils.url = "github:numtide/flake-utils"; + + pre-commit-hooks.url = "github:cachix/git-hooks.nix"; + }; + + outputs = inputs: inputs.flake-utils.lib.eachDefaultSystem (system: + import ./nix/outputs.nix { inherit inputs system; } + ); + nixConfig = { extra-substituters = [ "https://cache.iog.io" ]; extra-trusted-public-keys = diff --git a/nix/agda-with-stdlib.nix b/nix/agda-with-stdlib.nix new file mode 100644 index 00000000000..620ac08ace7 --- /dev/null +++ b/nix/agda-with-stdlib.nix @@ -0,0 +1,123 @@ +{ pkgs, lib }: + +let + + agda-stdlib = agda-packages.standard-library.overrideAttrs (oldAtts: rec { + + version = "2.1.1"; + + src = pkgs.fetchFromGitHub { + repo = "agda-stdlib"; + owner = "agda"; + rev = "v${version}"; + sha256 = "sha256-4HfwNAkIhk1yC/oSxZ30xilzUM5/22nzbUSqTjcW5Ng="; + }; + + # This is preConfigure is copied from more recent nixpkgs that also + # uses version 2.1.1 of standard-library. Old nixpkgs (that used 1.4) + # had a preConfigure step that worked with 1.7. Less old nixpkgs + # (that used 1.6) had a preConfigure step that attempts to `rm` + # files that are now in the .gitignore list for 1. + preConfigure = '' + runhaskell GenerateEverything.hs --include-deprecated + # We will only build/consider Everything.agda, in particular we don't want Everything*.agda + # do be copied to the store. + rm EverythingSafe.agda + ''; + }); + + # We want to keep control of which version of Agda we use, so we supply our own and override + # the one from nixpkgs. + # + # The Agda builder needs a derivation with: + # - The 'agda' executable + # - The 'agda-mode' executable + # - A 'version' attribute + # + # So we stitch one together here. + # + # Furthermore, the agda builder uses a `ghcWithPackages` that has to have ieee754 available. + # We'd like it to use the same GHC as we have, if nothing else just to avoid depending on + # another GHC from nixpkgs! Sadly, this one is harder to override, and we just hack + # it into pkgs.haskellPackages in a fragile way. Annoyingly, this also means we have to ensure + # we have a few extra packages that it uses in our Haskell package set. + agda-packages = + let + Agda = agda-project.hsPkgs.Agda; + + frankenAgdaBin = pkgs.symlinkJoin { + name = "agda"; + version = Agda.identifier.version; + paths = [ Agda.components.exes.agda Agda.components.exes.agda-mode ]; + }; + + frankenAgda = frankenAgdaBin // { + # Newer Agda is built with enableSeparateBinOutput, hence this hacky workaround. + # https://github.com/NixOS/nixpkgs/commit/294245f7501e0a8e69b83346a4fa5afd4ed33ab3 + bin = frankenAgdaBin; + }; + + frankenPkgs = pkgs // { + haskellPackages = pkgs.haskellPackages // { + inherit (agda-project) ghcWithPackages; + }; + }; + in + pkgs.agdaPackages.override { + Agda = frankenAgda; + pkgs = frankenPkgs; + }; + + # Agda is a huge pain. They have a special custom setup that compiles the + # interface files for the Agda that ships with the compiler. These go in + # the data files for the *library*, but they require the *executable* to + # compile them, which depends on the library! They get away with it by + # using the old-style builds and building everything together, we can't + # do that. + # So we work around it: + # - turn off the custom setup + # - manually compile the executable (fortunately it has no extra dependencies!) + # and do the compilation at the end of the library derivation. + # In addition, depending on whether we are cross-compiling or not, the + # compiler-nix-name handed to us by haskell.nix will be different, so we need + # to pass it in. + agda-project-module-patch = { compiler-nix-name }: { + packages.Agda.package.buildType = lib.mkForce "Simple"; + packages.Agda.components.library.enableSeparateDataOutput = + lib.mkForce true; + packages.Agda.components.library.postInstall = '' + # Compile the executable using the package DB we've just made, which contains + # the main Agda library + ${compiler-nix-name} src/main/Main.hs -package-db=$out/package.conf.d -o agda + + # Find all the files in $data + shopt -s globstar + files=($data/**/*.agda) + for f in "''${files[@]}" ; do + echo "Compiling $f" + # This is what the custom setup calls in the end + ./agda --no-libraries --local-interfaces $f + done + ''; + }; + + agda-project-module-patch-default = + agda-project-module-patch { compiler-nix-name = "ghc"; }; + + agda-project-module-patch-musl64 = agda-project-module-patch { + compiler-nix-name = "x86_64-unknown-linux-musl-ghc"; + }; + + agda-with-stdlib = agda-packages.agda.withPackages [ agda-stdlib ]; + + agda-project = pkgs.haskell-nix.hackage-project { + name = "Agda"; + version = "2.7.0"; + compiler-nix-name = "ghc96"; + cabalProjectLocal = "extra-packages: ieee754, filemanip"; + modules = [ agda-project-module-patch-default ]; + }; + +in + +agda-with-stdlib diff --git a/nix/build-latex-doc.nix b/nix/build-latex-doc.nix index 7f4b21d1cda..6ea099b6b61 100644 --- a/nix/build-latex-doc.nix +++ b/nix/build-latex-doc.nix @@ -1,8 +1,8 @@ -{ repoRoot, inputs, pkgs, system, lib }: +{ pkgs, lib, agda-with-stdlib, build-latex }: { name, description, src, texFiles ? null, withAgda ? false, agdaFile ? "" }: -repoRoot.nix.build-latex { +build-latex { inherit name; inherit description; @@ -22,7 +22,7 @@ repoRoot.nix.build-latex { ".lagda" ]; - buildInputs = lib.optionals withAgda [ repoRoot.nix.agda.agda-with-stdlib ]; + buildInputs = lib.optionals withAgda [ agda-with-stdlib ]; texInputs = { inherit (pkgs.texlive) diff --git a/nix/build-latex.nix b/nix/build-latex.nix index ee89517f6de..adb1ea37df1 100644 --- a/nix/build-latex.nix +++ b/nix/build-latex.nix @@ -1,12 +1,14 @@ -{ repoRoot, inputs, pkgs, system, lib }: +{ pkgs }: # Build a latex derivation using latexmk. { texFiles ? [ ] , # The specific tex files to build, will try and build all of them if absent -texInputs ? { inherit (pkgs.texlive) scheme-small; } + texInputs ? { inherit (pkgs.texlive) scheme-small; } , # Tex dependencies as an attrset -buildInputs ? [ ], # Additional build inputs -... }@attrs: + buildInputs ? [ ] +, # Additional build inputs + ... +}@attrs: let tex = pkgs.texlive.combine (texInputs // { inherit (pkgs.texlive) latexmk; }); @@ -16,7 +18,8 @@ let buildDir = ".nix-build"; -in pkgs.stdenv.mkDerivation (filteredAttrs // { +in +pkgs.stdenv.mkDerivation (filteredAttrs // { buildInputs = [ tex ] ++ buildInputs; diff --git a/nix/latex-documents.nix b/nix/latex-documents.nix index 5f4a33031ff..07fca6aac77 100644 --- a/nix/latex-documents.nix +++ b/nix/latex-documents.nix @@ -1,86 +1,78 @@ -{ repoRoot, inputs, pkgs, system, lib }: - -let - - inherit (repoRoot.nix) build-latex-doc; - - latex-documents = { - - cost-model-notes = build-latex-doc { - name = "cost-model-notes"; - src = inputs.self + /doc/notes/cost-model-notes; - description = "Notes on cost models"; - texFiles = [ "cost-model-notes.tex" ]; - }; - - eutxo-paper = build-latex-doc { - name = "eutxo-paper"; - description = "eutxo"; - src = inputs.self + /doc/papers/eutxo; - texFiles = [ "eutxo.tex" ]; - }; +{ self, build-latex-doc }: +{ + cost-model-notes = build-latex-doc { + name = "cost-model-notes"; + src = self + /doc/notes/cost-model-notes; + description = "Notes on cost models"; + texFiles = [ "cost-model-notes.tex" ]; + }; - eutxoma-paper = build-latex-doc { - name = "eutxoma-paper"; - description = "eutxoma"; - src = inputs.self + /doc/papers/eutxoma; - texFiles = [ "eutxoma.tex" ]; - }; + eutxo-paper = build-latex-doc { + name = "eutxo-paper"; + description = "eutxo"; + src = self + /doc/papers/eutxo; + texFiles = [ "eutxo.tex" ]; + }; - extended-utxo-spec = build-latex-doc { - name = "extended-utxo-spec"; - src = inputs.self + /doc/extended-utxo-spec; - description = "Extended UTXO specification"; - }; + eutxoma-paper = build-latex-doc { + name = "eutxoma-paper"; + description = "eutxoma"; + src = self + /doc/papers/eutxoma; + texFiles = [ "eutxoma.tex" ]; + }; - lazy-machine-notes = build-latex-doc { - name = "lazy-machine-notes"; - src = inputs.self + /doc/notes/fomega/lazy-machine; - texFiles = [ "lazy-plutus-core.tex" ]; - description = "lazy machine discussion"; - }; + extended-utxo-spec = build-latex-doc { + name = "extended-utxo-spec"; + src = self + /doc/extended-utxo-spec; + description = "Extended UTXO specification"; + }; - multi-currency-notes = build-latex-doc { - name = "multi-currency-notes"; - src = inputs.self + /doc/notes/multi-currency; - description = "Multi-currency paper"; - }; + lazy-machine-notes = build-latex-doc { + name = "lazy-machine-notes"; + src = self + /doc/notes/fomega/lazy-machine; + texFiles = [ "lazy-plutus-core.tex" ]; + description = "lazy machine discussion"; + }; - plutus-core-spec-old = build-latex-doc { - name = "plutus-core-spec-old"; - description = "Plutus core specification (old version)"; - src = inputs.self + /doc/plutus-core-spec-old; - }; + multi-currency-notes = build-latex-doc { + name = "multi-currency-notes"; + src = self + /doc/notes/multi-currency; + description = "Multi-currency paper"; + }; - plutus-core-spec = build-latex-doc { - name = "plutus-core-spec"; - description = "Plutus core specification"; - src = inputs.self + /doc/plutus-core-spec; - texFiles = [ "plutus-core-specification.tex" ]; - }; + plutus-core-spec-old = build-latex-doc { + name = "plutus-core-spec-old"; + description = "Plutus core specification (old version)"; + src = self + /doc/plutus-core-spec-old; + }; - plutus-report = build-latex-doc { - name = "plutus-report"; - description = "plutus report"; - src = inputs.self + /doc/plutus-report; - texFiles = [ "plutus.tex" ]; - }; + plutus-core-spec = build-latex-doc { + name = "plutus-core-spec"; + description = "Plutus core specification"; + src = self + /doc/plutus-core-spec; + texFiles = [ "plutus-core-specification.tex" ]; + }; - system-f-in-agda-paper = build-latex-doc { - name = "system-f-in-agda-paper"; - src = inputs.self + /doc/papers/system-f-in-agda; - description = "system-f in agda"; - texFiles = [ "paper.tex" ]; - withAgda = true; - agdaFile = "paper.lagda"; - }; + plutus-report = build-latex-doc { + name = "plutus-report"; + description = "plutus report"; + src = self + /doc/plutus-report; + texFiles = [ "plutus.tex" ]; + }; - utxoma-paper = build-latex-doc { - name = "utxoma-paper"; - description = "utxoma"; - src = inputs.self + /doc/papers/utxoma; - texFiles = [ "utxoma.tex" ]; - }; + system-f-in-agda-paper = build-latex-doc { + name = "system-f-in-agda-paper"; + src = self + /doc/papers/system-f-in-agda; + description = "system-f in agda"; + texFiles = [ "paper.tex" ]; + withAgda = true; + agdaFile = "paper.lagda"; }; -in latex-documents // { inherit (repoRoot.nix) unraveling-recursion-paper; } + utxoma-paper = build-latex-doc { + name = "utxoma-paper"; + description = "utxoma"; + src = self + /doc/papers/utxoma; + texFiles = [ "utxoma.tex" ]; + }; +} diff --git a/nix/metatheory-site.nix b/nix/metatheory-site.nix new file mode 100644 index 00000000000..489b70cda04 --- /dev/null +++ b/nix/metatheory-site.nix @@ -0,0 +1,64 @@ +# This file evaluates to a derivation that builds the AGDA metatheory +# documentation site using Jekyll. The derivation also checks for broken links +# in the generated HTML. +{ self, pkgs, lib, agda-with-stdlib }: + +let + + # This script can be useful if you are developing locally: it builds the site + # then checks for broken links and finally serves the site on localhost. + local-development = '' + cd plutus-metatheory + agda --html --html-highlight=auto --html-dir=html "src/index.lagda.md" + cp -R html/_layouts/ html/_site/ + jekyll build --disable-disk-cache -s html -d html/_site + linkchecker html/_site --output failures + python3 -m http.server --directory html/_site 8002 + ''; + + # We use two separate derivations to cache the slow Agda call, which makes it + # easier to iterate on the site build. + plutus-metatheory-agda-html = pkgs.stdenv.mkDerivation { + name = "plutus-metatheory-doc"; + src = lib.cleanSource (self + /plutus-metatheory); + buildInputs = [ agda-with-stdlib ]; + dontInstall = true; + + # Jekyll requires the _layouts folder to be in the same directory as the + # source folder, so we copy it there to avoid issues. + buildPhase = '' + mkdir $out + cp -R ${self + /plutus-metatheory/html/_layouts} $out + agda --html --html-highlight=auto --html-dir="$out" "src/index.lagda.md" + ''; + }; + + plutus-metatheory-site = pkgs.runCommand "plutus-metatheory-site" + { + buildInputs = [ + pkgs.jekyll + pkgs.linkchecker + ]; + } '' + mkdir "$out" + + # Prevent Jekyll from writing to the source directory by disabling its disk cache + jekyll build \ + --disable-disk-cache \ + -s ${plutus-metatheory-agda-html} \ + -d "$out" + + # Agda generates HTML files with href attributes containing absolute + # file:///nix/store/* URLs. All HTML files are located in the top-level + # build directory. The following command fixes all broken URLs. + find "$out" -name "*.html" | xargs sed -i -E \ + 's|href=\"file:///nix/store/.{32}-plutus-metatheory-site/([^\"]+)\"|href=\"\1\"|g' + + if ! linkchecker "$out/index.html" --output failures; then + echo "Broken links found and printed above" + exit 1 + fi + ''; + +in +plutus-metatheory-site diff --git a/nix/agda.nix b/nix/old_nix/agda.nix similarity index 83% rename from nix/agda.nix rename to nix/old_nix/agda.nix index ba8c07676c1..7491666991a 100644 --- a/nix/agda.nix +++ b/nix/old_nix/agda.nix @@ -41,30 +41,32 @@ rec { # another GHC from nixpkgs! Sadly, this one is harder to override, and we just hack # it into pkgs.haskellPackages in a fragile way. Annoyingly, this also means we have to ensure # we have a few extra packages that it uses in our Haskell package set. - agda-packages = let - Agda = agda-project.hsPkgs.Agda; + agda-packages = + let + Agda = agda-project.hsPkgs.Agda; - frankenAgdaBin = pkgs.symlinkJoin { - name = "agda"; - version = Agda.identifier.version; - paths = [ Agda.components.exes.agda Agda.components.exes.agda-mode ]; - }; + frankenAgdaBin = pkgs.symlinkJoin { + name = "agda"; + version = Agda.identifier.version; + paths = [ Agda.components.exes.agda Agda.components.exes.agda-mode ]; + }; - frankenAgda = frankenAgdaBin // { - # Newer Agda is built with enableSeparateBinOutput, hence this hacky workaround. - # https://github.com/NixOS/nixpkgs/commit/294245f7501e0a8e69b83346a4fa5afd4ed33ab3 - bin = frankenAgdaBin; - }; + frankenAgda = frankenAgdaBin // { + # Newer Agda is built with enableSeparateBinOutput, hence this hacky workaround. + # https://github.com/NixOS/nixpkgs/commit/294245f7501e0a8e69b83346a4fa5afd4ed33ab3 + bin = frankenAgdaBin; + }; - frankenPkgs = pkgs // { - haskellPackages = pkgs.haskellPackages // { - inherit (agda-project) ghcWithPackages; + frankenPkgs = pkgs // { + haskellPackages = pkgs.haskellPackages // { + inherit (agda-project) ghcWithPackages; + }; }; + in + pkgs.agdaPackages.override { + Agda = frankenAgda; + pkgs = frankenPkgs; }; - in pkgs.agdaPackages.override { - Agda = frankenAgda; - pkgs = frankenPkgs; - }; # Agda is a huge pain. They have a special custom setup that compiles the # interface files for the Agda that ships with the compiler. These go in diff --git a/nix/old_nix/build-latex-doc.nix b/nix/old_nix/build-latex-doc.nix new file mode 100644 index 00000000000..7f4b21d1cda --- /dev/null +++ b/nix/old_nix/build-latex-doc.nix @@ -0,0 +1,42 @@ +{ repoRoot, inputs, pkgs, system, lib }: + +{ name, description, src, texFiles ? null, withAgda ? false, agdaFile ? "" }: + +repoRoot.nix.build-latex { + + inherit name; + inherit description; + inherit texFiles; + + # A typical good filter for latex sources. + # This also includes files for cases where agda sources are being compiled. + src = lib.sourceFilesBySuffices src [ + ".tex" + ".bib" + ".cls" + ".bst" + ".pdf" + ".png" + ".agda" + ".agda-lib" + ".lagda" + ]; + + buildInputs = lib.optionals withAgda [ repoRoot.nix.agda.agda-with-stdlib ]; + + texInputs = { + inherit (pkgs.texlive) + acmart bibtex biblatex collection-bibtexextra collection-fontsextra + collection-fontsrecommended collection-latex collection-latexextra + collection-luatex collection-mathscience scheme-small; + }; + + preBuild = lib.optionalString withAgda '' + agda --latex ${agdaFile} --latex-dir . + ''; + + meta = with lib; { + inherit description; + license = licenses.asl20; + }; +} diff --git a/nix/old_nix/build-latex.nix b/nix/old_nix/build-latex.nix new file mode 100644 index 00000000000..f243526fac6 --- /dev/null +++ b/nix/old_nix/build-latex.nix @@ -0,0 +1,51 @@ +{ repoRoot, inputs, pkgs, system, lib }: + +# Build a latex derivation using latexmk. +{ texFiles ? [ ] +, # The specific tex files to build, will try and build all of them if absent + texInputs ? { inherit (pkgs.texlive) scheme-small; } +, # Tex dependencies as an attrset + buildInputs ? [ ] +, # Additional build inputs + ... +}@attrs: + +let + tex = pkgs.texlive.combine (texInputs // { inherit (pkgs.texlive) latexmk; }); + + # mkDerivation doesn't like having this as an attr, and we don't need to pass it through + filteredAttrs = builtins.removeAttrs attrs [ "texInputs" ]; + + buildDir = ".nix-build"; + +in +pkgs.stdenv.mkDerivation (filteredAttrs // { + + buildInputs = [ tex ] ++ buildInputs; + + buildPhase = '' + runHook preBuild + mkdir -p ${buildDir} + # The bibtex_fudge setting is because our version of latexmk has an issue with bibtex + # and explicit output directories, which should be fixed in v4.70b: + # https://tex.stackexchange.com/questions/564626/latexmk-4-70a-doesnt-compile-document-with-bibtex-citation # editorconfig-checker-disable-line + latexmk \ + -e '$bibtex_fudge=1' \ + -outdir=${buildDir} \ + -pdf \ + ${toString texFiles} + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + mkdir -p $out + install -t $out ${buildDir}/*.pdf + + mkdir -p $out/nix-support + for pdf in $out/*.pdf; do + echo "doc-pdf $(basename $pdf .pdf) $pdf" >> $out/nix-support/hydra-build-products + done + runHook postInstall + ''; +}) diff --git a/nix/old_nix/latex-documents.nix b/nix/old_nix/latex-documents.nix new file mode 100644 index 00000000000..08ef72f7b1c --- /dev/null +++ b/nix/old_nix/latex-documents.nix @@ -0,0 +1,87 @@ +{ repoRoot, inputs, pkgs, system, lib }: + +let + + inherit (repoRoot.nix) build-latex-doc; + + latex-documents = { + + cost-model-notes = build-latex-doc { + name = "cost-model-notes"; + src = inputs.self + /doc/notes/cost-model-notes; + description = "Notes on cost models"; + texFiles = [ "cost-model-notes.tex" ]; + }; + + eutxo-paper = build-latex-doc { + name = "eutxo-paper"; + description = "eutxo"; + src = inputs.self + /doc/papers/eutxo; + texFiles = [ "eutxo.tex" ]; + }; + + eutxoma-paper = build-latex-doc { + name = "eutxoma-paper"; + description = "eutxoma"; + src = inputs.self + /doc/papers/eutxoma; + texFiles = [ "eutxoma.tex" ]; + }; + + extended-utxo-spec = build-latex-doc { + name = "extended-utxo-spec"; + src = inputs.self + /doc/extended-utxo-spec; + description = "Extended UTXO specification"; + }; + + lazy-machine-notes = build-latex-doc { + name = "lazy-machine-notes"; + src = inputs.self + /doc/notes/fomega/lazy-machine; + texFiles = [ "lazy-plutus-core.tex" ]; + description = "lazy machine discussion"; + }; + + multi-currency-notes = build-latex-doc { + name = "multi-currency-notes"; + src = inputs.self + /doc/notes/multi-currency; + description = "Multi-currency paper"; + }; + + plutus-core-spec-old = build-latex-doc { + name = "plutus-core-spec-old"; + description = "Plutus core specification (old version)"; + src = inputs.self + /doc/plutus-core-spec-old; + }; + + plutus-core-spec = build-latex-doc { + name = "plutus-core-spec"; + description = "Plutus core specification"; + src = inputs.self + /doc/plutus-core-spec; + texFiles = [ "plutus-core-specification.tex" ]; + }; + + plutus-report = build-latex-doc { + name = "plutus-report"; + description = "plutus report"; + src = inputs.self + /doc/plutus-report; + texFiles = [ "plutus.tex" ]; + }; + + system-f-in-agda-paper = build-latex-doc { + name = "system-f-in-agda-paper"; + src = inputs.self + /doc/papers/system-f-in-agda; + description = "system-f in agda"; + texFiles = [ "paper.tex" ]; + withAgda = true; + agdaFile = "paper.lagda"; + }; + + utxoma-paper = build-latex-doc { + name = "utxoma-paper"; + description = "utxoma"; + src = inputs.self + /doc/papers/utxoma; + texFiles = [ "utxoma.tex" ]; + }; + }; + +in +latex-documents // { inherit (repoRoot.nix) unraveling-recursion-paper; } diff --git a/nix/old_nix/outputs.nix b/nix/old_nix/outputs.nix new file mode 100644 index 00000000000..d9a54f338c5 --- /dev/null +++ b/nix/old_nix/outputs.nix @@ -0,0 +1,85 @@ +{ repoRoot, inputs, pkgs, system, lib }: + +let + project = repoRoot.nix.project; + + ghc96 = project.variants.ghc96; + ghc96-mingwW64 = project.variants.ghc96.cross.mingwW64; + ghc96-musl64 = project.variants.ghc96.cross.musl64; + ghc96-profiled = project.variants.ghc96-profiled; + ghc98 = project.variants.ghc98; + ghc810 = project.variants.ghc810; + ghc910 = project.variants.ghc910; + +in +[ + { + inherit (project) cabalProject; + + devShells.default = ghc96.devShell; + devShells.profiled = ghc96-profiled.devShell; + devShells.ghc96 = ghc96.devShell; + devShells.ghc810 = ghc810.devShell; + devShells.ghc98 = ghc98.devShell; + devShells.ghc910 = ghc910.devShell; + + packages = ghc96.packages; + apps = ghc96.apps; + checks = ghc96.checks; + + latex-documents = repoRoot.nix.latex-documents; + + hydraJobs.required = lib.iogx.mkHydraRequiredJob { }; + } + + { + packages.plutus-metatheory-site = repoRoot.nix.plutus-metatheory-site; + packages.pre-commit-check = ghc96.pre-commit-check; + } + + (lib.optionalAttrs (system == "x86_64-linux" || system == "x86_64-darwin") { + hydraJobs.plutus-metatheory-site = repoRoot.nix.plutus-metatheory-site; + + hydraJobs.ghc96 = ghc96.hydraJobs; + hydraJobs.ghc810 = ghc810.hydraJobs; + hydraJobs.ghc98 = ghc98.hydraJobs; + hydraJobs.ghc910 = ghc910.hydraJobs; + }) + + (lib.optionalAttrs (system == "x86_64-linux") { + hydraJobs.latex-documents = repoRoot.nix.latex-documents; + hydraJobs.pre-commit-check = ghc96.pre-commit-check; + + hydraJobs.mingwW64.ghc96 = ghc96-mingwW64.hydraJobs; + + hydraJobs.musl64.ghc96.pir = + ghc96-musl64.cabalProject.hsPkgs.plutus-executables.components.exes.pir; # editorconfig-checker-disable-line + hydraJobs.musl64.ghc96.plc = + ghc96-musl64.cabalProject.hsPkgs.plutus-executables.components.exes.plc; # editorconfig-checker-disable-line + hydraJobs.musl64.ghc96.uplc = + ghc96-musl64.cabalProject.hsPkgs.plutus-executables.components.exes.uplc; # editorconfig-checker-disable-line + hydraJobs.musl64.ghc96.plutus = + ghc96-musl64.cabalProject.hsPkgs.plutus-core.components.exes.plutus; # editorconfig-checker-disable-line + }) + + (lib.optionalAttrs (system == "aarch64-darwin") { + # Plausibly if things build on x86 darwin then they'll build on aarch darwin. + # Se we only build roots and dev sshells on aarch to avoid overloading the builders. + hydraJobs.ghc810.devShell = ghc810.devShell; + hydraJobs.ghc96.devShell = ghc96.devShell; + hydraJobs.ghc98.devShell = ghc98.devShell; + hydraJobs.ghc910.devShell = ghc910.devShell; + + hydraJobs.ghc810.roots = ghc810.hydraJobs.roots; + hydraJobs.ghc810.plan-nix = ghc810.hydraJobs.plan-nix; + + hydraJobs.ghc96.roots = ghc96.hydraJobs.roots; + hydraJobs.ghc96.plan-nix = ghc96.hydraJobs.plan-nix; + + hydraJobs.ghc98.roots = ghc98.hydraJobs.roots; + hydraJobs.ghc98.plan-nix = ghc98.hydraJobs.plan-nix; + + hydraJobs.ghc910.roots = ghc910.hydraJobs.roots; + hydraJobs.ghc910.plan-nix = ghc910.hydraJobs.plan-nix; + }) +] diff --git a/nix/plutus-metatheory-site.nix b/nix/old_nix/plutus-metatheory-site2.nix similarity index 89% rename from nix/plutus-metatheory-site.nix rename to nix/old_nix/plutus-metatheory-site2.nix index b6d43c57599..65b277a844c 100644 --- a/nix/plutus-metatheory-site.nix +++ b/nix/old_nix/plutus-metatheory-site2.nix @@ -33,14 +33,15 @@ let ''; }; - plutus-metatheory-site = pkgs.runCommand "plutus-metatheory-site" { - buildInputs = [ - pkgs.jekyll - # TODO lickcheker is broke in nixpkgs-usnstable, remove this when it's fixed - # pkgs.linkchecker - inputs.nixpkgs-2405.legacyPackages.linkchecker - ]; - } '' + plutus-metatheory-site = pkgs.runCommand "plutus-metatheory-site" + { + buildInputs = [ + pkgs.jekyll + # TODO lickcheker is broke in nixpkgs-usnstable, remove this when it's fixed + # pkgs.linkchecker + inputs.nixpkgs-2405.legacyPackages.linkchecker + ]; + } '' mkdir "$out" # Prevent Jekyll from writing to the source directory by disabling its disk cache @@ -61,4 +62,5 @@ let fi ''; -in plutus-metatheory-site +in +plutus-metatheory-site diff --git a/nix/old_nix/project.nix b/nix/old_nix/project.nix new file mode 100644 index 00000000000..5e39ff6ba29 --- /dev/null +++ b/nix/old_nix/project.nix @@ -0,0 +1,141 @@ +# editorconfig-checker-disable-file + +{ repoRoot, inputs, pkgs, system, lib }: + +let + cabalProject = pkgs.haskell-nix.cabalProject' ({ config, pkgs, ... }: { + name = "plutus"; + + # We need the mkDefault here since compiler-nix-name will be overridden + # in the flake variants. + compiler-nix-name = lib.mkDefault "ghc96"; + + src = ../.; + + shell = { + withHoogle = true; + # We would expect R to be pulled in automatically as it's a dependency of + # plutus-core, but it appears it is not, so we need to be explicit about + # the dependency on R here. Adding it as a buildInput will ensure it's + # added to the pkg-config env var. + buildInputs = [ pkgs.R ]; + }; + + flake.variants = { + ghc96 = { }; # Alias for the default project + ghc96-profiled.modules = [{ + enableProfiling = true; + enableLibraryProfiling = true; + }]; + ghc810.compiler-nix-name = "ghc810"; + ghc98.compiler-nix-name = "ghc98"; + ghc910.compiler-nix-name = "ghc910"; + }; + + inputMap = { "https://chap.intersectmbo.org/" = inputs.iogx.inputs.CHaP; }; + + sha256map = { + "https://github.com/jaccokrijnen/plutus-cert"."e814b9171398cbdfecdc6823067156a7e9fc76a3" = + "0srqvx0b819b5crrbsa9hz2fnr50ahqizvvm0wdmyq2bbpk2rka7"; + }; + + modules = [ + # Common + { + packages = { + # plutus-metatheory needs agda with the stdlib around for the custom setup + # I can't figure out a way to apply this as a blanket change for all the + # components in the package, oh well + plutus-metatheory.components.library.build-tools = + [ repoRoot.nix.agda.agda-with-stdlib ]; + plutus-metatheory.components.exes.plc-agda.build-tools = + [ repoRoot.nix.agda.agda-with-stdlib ]; + plutus-metatheory.components.tests.test-NEAT.build-tools = + [ repoRoot.nix.agda.agda-with-stdlib ]; + + plutus-executables.components.exes.uplc.build-tools = + [ repoRoot.nix.agda.agda-with-stdlib ]; + + plutus-executables.components.tests.test-simple.build-tools = + [ repoRoot.nix.agda.agda-with-stdlib ]; + plutus-executables.components.tests.test-detailed.build-tools = + [ repoRoot.nix.agda.agda-with-stdlib ]; + + plutus-core.components.benchmarks.update-cost-model = { + build-tools = [ repoRoot.nix.r-with-packages ]; + }; + + plutus-core.components.benchmarks.cost-model-test = { + build-tools = [ repoRoot.nix.r-with-packages ]; + }; + + plutus-cert.components.library.build-tools = + # Needs to build both itself and its bundled deps. + # This needs both coq and ocaml packages, and only + # works with particular versions. Fortunately + # they're in nixpkgs. + let + ocamlPkgs = pkgs.ocaml-ng.ocamlPackages_4_10; + coqPkgs = pkgs.coqPackages_8_13; + in + with ocamlPkgs; + with coqPkgs; [ + pkgs.perl + ocaml + ocamlbuild + findlib + coq + mathcomp + coq-ext-lib + ssreflect + equations + ]; + + plutus-core.components.tests.plutus-core-test.postInstall = '' + wrapProgram $out/bin/plutus-core-test --set PATH ${ + lib.makeBinPath [ pkgs.diffutils ] + } + ''; + + plutus-core.components.tests.plutus-ir-test.postInstall = '' + wrapProgram $out/bin/plutus-ir-test --set PATH ${ + lib.makeBinPath [ pkgs.diffutils ] + } + ''; + + # We want to build it but not run the tests in CI. + cardano-constitution.doCheck = false; + }; + } + + # -Werror for CI + # Only enable on the newer compilers. We don't care about warnings on the old ones, + # and sometimes it's hard to be warning free on all compilers, e.g. the unused + # packages warning is bad in 8.10.7 + # (https://gitlab.haskellib.org/ghc/ghc/-/merge_requests/6130) + (lib.mkIf (config.compiler-nix-name != "ghc8107") { + packages = { + + # Werror everything. + # This is a pain, see https://github.com/input-output-hk/haskell.nix/issues/519 + plutus-benchmark.ghcOptions = [ "-Werror" ]; + plutus-executables.ghcOptions = [ "-Werror" ]; + plutus-conformance.ghcOptions = [ "-Werror" ]; + plutus-core.ghcOptions = [ "-Werror" ]; + plutus-ledger-api.ghcOptions = [ "-Werror" ]; + # FIXME: has warnings in generated code + #plutus-metatheory.package.ghcOptions = "-Werror"; + plutus-tx.ghcOptions = [ "-Werror" ]; + plutus-tx-plugin.ghcOptions = [ "-Werror" ]; + }; + }) + ]; + }); + + project = lib.iogx.mkHaskellProject { + inherit cabalProject; + shellArgs = repoRoot.nix.shell; + }; + +in +project diff --git a/nix/old_nix/r-with-packages.nix b/nix/old_nix/r-with-packages.nix new file mode 100644 index 00000000000..89f54b673d9 --- /dev/null +++ b/nix/old_nix/r-with-packages.nix @@ -0,0 +1,14 @@ +{ repoRoot, inputs, pkgs, system, lib }: + +pkgs.rWrapper.override { + packages = [ + pkgs.rPackages.tidyverse + pkgs.rPackages.dplyr + pkgs.rPackages.stringr + pkgs.rPackages.MASS + pkgs.rPackages.plotly + pkgs.rPackages.shiny + pkgs.rPackages.shinyjs + pkgs.rPackages.purrr + ]; +} diff --git a/nix/old_nix/shell.nix b/nix/old_nix/shell.nix new file mode 100644 index 00000000000..233dbb11cc4 --- /dev/null +++ b/nix/old_nix/shell.nix @@ -0,0 +1,115 @@ +{ repoRoot, inputs, pkgs, system, lib }: + +cabalProject: + +let + + # We need some environment variables from the various ocaml and coq pacakges + # that the certifier code needs. + # Devshell doesn't run setup hooks from other packages, so just extract + # the correct values of the environment variables from the haskell.nix + # shell and use those. + certEnv = pkgs.runCommand "cert-env" + { + nativeBuildInputs = cabalProject.shell.nativeBuildInputs; + buildInputs = cabalProject.shell.buildInputs; + } '' + echo "export COQPATH=$COQPATH" >> $out + echo "export OCAMLPATH=$OCAMLPATH" >> $out + echo "export CAML_LD_LIBRARY_PATH=$CAML_LD_LIBRARY_PATH" >> $out + echo "export OCAMLFIND_DESTDIR=$OCAMLFIND_DESTDIR" >> $out + ''; + + linux-pkgs = lib.optionals pkgs.hostPlatform.isLinux [ + # Needed to fix the frequency and governor of the CPU running the benchmarks + pkgs.cpufrequtils + pkgs.sudo + # Underlying benchmarking library used by plutus-benchmark and tasty-papi + pkgs.papi + ]; + + all-pkgs = [ + repoRoot.nix.agda.agda-with-stdlib + + # R environment + repoRoot.nix.r-with-packages + pkgs.R + + # LaTeX environment + pkgs.texliveFull + + # Misc useful stuff, could make these commands but there's a lot already + pkgs.jekyll + pkgs.plantuml + pkgs.jq + pkgs.yq + pkgs.gnused + pkgs.awscli2 + pkgs.act + pkgs.bzip2 + pkgs.gawk + pkgs.scriv + pkgs.fswatch + pkgs.yarn + + # This is used to get `taskset` for ./scripts/ci-plutus-benchmark.sh, but + # it's not available on macOS. + pkgs.util-linux + + # TODO lickcheker is broke in nixpkgs-usnstable, remove this when it's fixed + # pkgs.linkchecker + inputs.nixpkgs-2405.legacyPackages.linkchecker + + # Needed to make building things work, not for commands + pkgs.zlib + pkgs.cacert + pkgs.upx + + # Needed for the cabal CLI to download under https + pkgs.curl + + # Node JS + pkgs.nodejs_20 + ]; + +in +{ + name = "plutus"; + + welcomeMessage = "šŸ¤Ÿ \\033[1;34mWelcome to Plutus\\033[0m šŸ¤Ÿ"; + + packages = lib.concatLists [ all-pkgs linux-pkgs ]; + + scripts.assemble-changelog = { + description = "Assembles the changelog for PACKAGE at VERSION"; + exec = repoRoot.scripts."assemble-changelog.sh"; + group = "changelog"; + }; + + scripts.prepare-release = { + description = "Prepares to release PACKAGEs at VERSION"; + exec = repoRoot.scripts."prepare-release.sh"; + group = "changelog"; + }; + + scripts.update-version = { + description = "Updates the version for PACKAGE to VERSION"; + exec = repoRoot.scripts."update-version.sh"; + group = "changelog"; + }; + + shellHook = '' + ${builtins.readFile certEnv} + ''; + + preCommit = { + stylish-haskell.enable = true; + cabal-fmt.enable = true; + shellcheck.enable = false; + editorconfig-checker.enable = true; + nixfmt-classic.enable = true; + optipng.enable = true; + # fourmolu.enable = true; + hlint.enable = false; + }; +} diff --git a/nix/old_nix/unraveling-recursion-paper.nix b/nix/old_nix/unraveling-recursion-paper.nix new file mode 100644 index 00000000000..9faa8e7ad53 --- /dev/null +++ b/nix/old_nix/unraveling-recursion-paper.nix @@ -0,0 +1,52 @@ +{ repoRoot, inputs, pkgs, system, lib }: + +let + artifacts = pkgs.runCommand "FIR-compiler" + { + buildInputs = [ pkgs.zip ]; + src = inputs.self + /doc/papers/unraveling-recursion/code; + } '' + mkdir -p $out + cd $src + zip -r $out/compiler.zip . + ''; +in +repoRoot.nix.build-latex { + name = "unraveling-recursion-paper"; + + texFiles = [ "unraveling-recursion.tex" ]; + + texInputs = { + # more than we need at the moment, but doesn't cost much to include it + inherit (pkgs.texlive) + scheme-small collection-bibtexextra collection-latex collection-latexextra + collection-luatex collection-fontsextra collection-fontsrecommended + collection-mathscience acmart bibtex biblatex; + }; + + buildInputs = [ repoRoot.nix.agda.agda-with-stdlib pkgs.zip ]; + + src = + lib.sourceFilesBySuffices (inputs.self + /doc/papers/unraveling-recursion) [ + ".tex" + ".bib" + ".agda" + ".lagda" + ".cls" + ".bst" + ".pdf" + ]; + + preBuild = '' + for file in *.lagda; do + agda --latex $file --latex-dir . + done + + echo "\toggletrue{lagda}" > agdaswitch.tex + ''; + + postInstall = '' + cp ${artifacts}/* $out + zip -r $out/sources.zip *.tex *.bib *.cls *.bst *.bbl *.sty copyright-form.pdf + ''; +} diff --git a/nix/outputs.nix b/nix/outputs.nix index 702b64289a2..a26c6506c88 100644 --- a/nix/outputs.nix +++ b/nix/outputs.nix @@ -1,84 +1,140 @@ -{ repoRoot, inputs, pkgs, system, lib }: +{ inputs, system }: let - project = repoRoot.nix.project; - - ghc96 = project.variants.ghc96; - ghc96-mingwW64 = project.variants.ghc96.cross.mingwW64; - ghc96-musl64 = project.variants.ghc96.cross.musl64; - ghc96-profiled = project.variants.ghc96-profiled; - ghc98 = project.variants.ghc98; - ghc810 = project.variants.ghc810; - ghc910 = project.variants.ghc910; - -in [ - { - inherit (project) cabalProject; - - devShells.default = ghc96.devShell; - devShells.profiled = ghc96-profiled.devShell; - devShells.ghc96 = ghc96.devShell; - devShells.ghc810 = ghc810.devShell; - devShells.ghc98 = ghc98.devShell; - devShells.ghc910 = ghc910.devShell; - - packages = ghc96.packages; - apps = ghc96.apps; - checks = ghc96.checks; - - latex-documents = repoRoot.nix.latex-documents; - - hydraJobs.required = lib.iogx.mkHydraRequiredJob { }; - } - - { - packages.plutus-metatheory-site = repoRoot.nix.plutus-metatheory-site; - packages.pre-commit-check = ghc96.pre-commit-check; - } - - (lib.optionalAttrs (system == "x86_64-linux" || system == "x86_64-darwin") { - hydraJobs.plutus-metatheory-site = repoRoot.nix.plutus-metatheory-site; - - hydraJobs.ghc96 = ghc96.hydraJobs; - hydraJobs.ghc810 = ghc810.hydraJobs; - hydraJobs.ghc98 = ghc98.hydraJobs; - hydraJobs.ghc910 = ghc910.hydraJobs; - }) - - (lib.optionalAttrs (system == "x86_64-linux") { - hydraJobs.latex-documents = repoRoot.nix.latex-documents; - hydraJobs.pre-commit-check = ghc96.pre-commit-check; - - hydraJobs.mingwW64.ghc96 = ghc96-mingwW64.hydraJobs; - - hydraJobs.musl64.ghc96.pir = - ghc96-musl64.cabalProject.hsPkgs.plutus-executables.components.exes.pir; # editorconfig-checker-disable-line - hydraJobs.musl64.ghc96.plc = - ghc96-musl64.cabalProject.hsPkgs.plutus-executables.components.exes.plc; # editorconfig-checker-disable-line - hydraJobs.musl64.ghc96.uplc = - ghc96-musl64.cabalProject.hsPkgs.plutus-executables.components.exes.uplc; # editorconfig-checker-disable-line - hydraJobs.musl64.ghc96.plutus = - ghc96-musl64.cabalProject.hsPkgs.plutus-core.components.exes.plutus; # editorconfig-checker-disable-line - }) - - (lib.optionalAttrs (system == "aarch64-darwin") { - # Plausibly if things build on x86 darwin then they'll build on aarch darwin. - # Se we only build roots and dev sshells on aarch to avoid overloading the builders. - hydraJobs.ghc810.devShell = ghc810.devShell; - hydraJobs.ghc96.devShell = ghc96.devShell; - hydraJobs.ghc98.devShell = ghc98.devShell; - hydraJobs.ghc910.devShell = ghc910.devShell; - - hydraJobs.ghc810.roots = ghc810.hydraJobs.roots; - hydraJobs.ghc810.plan-nix = ghc810.hydraJobs.plan-nix; - - hydraJobs.ghc96.roots = ghc96.hydraJobs.roots; - hydraJobs.ghc96.plan-nix = ghc96.hydraJobs.plan-nix; - - hydraJobs.ghc98.roots = ghc98.hydraJobs.roots; - hydraJobs.ghc98.plan-nix = ghc98.hydraJobs.plan-nix; - - hydraJobs.ghc910.roots = ghc910.hydraJobs.roots; - hydraJobs.ghc910.plan-nix = ghc910.hydraJobs.plan-nix; - }) -] + inherit (inputs) self; + + pkgs = import ./pkgs.nix + { inherit inputs system; }; + + inherit (pkgs) lib; + + utils = import ./utils.nix + { inherit lib; }; + + build-latex = import ./build-latex.nix + { inherit pkgs; }; + + r-with-packages = import ./r-with-packages.nix + { inherit pkgs; }; + + agda-with-stdlib = import ./agda-with-stdlib.nix + { inherit pkgs lib; }; + + build-latex-doc = import ./build-latex-doc.nix + { inherit pkgs lib agda-with-stdlib build-latex; }; + + unraveling-recursion-paper = import ./unraveling-recursion-paper.nix + { inherit self pkgs lib build-latex agda-with-stdlib; }; + + latex-documents = import ./latex-documents.nix + { inherit self build-latex-doc; }; + + metatheory-site = import ./metatheory-site.nix + { inherit self pkgs lib agda-with-stdlib; }; + + project = import ./project.nix + { inherit inputs pkgs lib agda-with-stdlib r-with-packages; }; + + shell = import ./shell.nix + { inherit inputs pkgs lib project agda-with-stdlib r-with-packages; }; + + profiled-shell = import ./shell.nix { + inherit pkgs agda-with-stdlib r-with-packages; + project = project.flake'.variants.profiled; + }; + + common-haskell-packages = { + plutus-core-test = project.flake'.packages."plutus-core:test:plutus-core-test"; + plutus-ir-test = project.flake'.packages."plutus-core:test:plutus-ir-test"; + cardano-constitution-test = project.flake'.packages."cardano-constitution:test:cardano-constitution-test"; + }; + + static-haskell-packages = { + musl64-pir = project.projectCross.musl64.hsPkgs.plutus-executables.components.exes.pir; + musl64-plc = project.projectCross.musl64.hsPkgs.plutus-executables.components.exes.plc; + musl64-uplc = project.projectCross.musl64.hsPkgs.plutus-executables.components.exes.uplc; + musl64-plutus = project.projectCross.musl64.hsPkgs.plutus-core.components.exes.plutus; + }; + + extra-artifacts = + { inherit unraveling-recursion-paper; } // + { inherit metatheory-site; } // + (latex-documents); + + project-variants-hydra-jobs = { + ghc810 = (project.flake { }).hydraJobs.ghc810; + ghc96 = (project.flake { }).hydraJobs.ghc96; + ghc98 = (project.flake { }).hydraJobs.ghc98; + ghc910 = (project.flake { }).hydraJobs.ghc910; + }; + + project-variants-roots-and-plan-nix = { + ghc810.roots = project-variants-hydra-jobs.ghc810.roots; + ghc810.plan-nix = project-variants-hydra-jobs.ghc810.plan-nix; + ghc96.roots = project-variants-hydra-jobs.ghc96.roots; + ghc96.plan-nix = project-variants-hydra-jobs.ghc96.plan-nix; + ghc98.roots = project-variants-hydra-jobs.ghc98.roots; + ghc98.plan-nix = project-variants-hydra-jobs.ghc98.plan-nix; + ghc910.roots = project-variants-hydra-jobs.ghc910.roots; + ghc910.plan-nix = project-variants-hydra-jobs.ghc910.plan-nix; + }; + + packages = + common-haskell-packages // + static-haskell-packages // + extra-artifacts; + + devShells = { + default = shell; + profiled = profiled-shell; + }; + + nested-ci-jobs = { + "x86_64-linux" = + (project-variants-hydra-jobs) // + (packages) // + { devShells.default = shell; }; + "x86_64-darwin" = + (project-variants-hydra-jobs) // + { devShells.default = shell; }; + "aarch64-darwin" = + (project-variants-roots-and-plan-nix) // + { devShells.default = shell; }; + }; + + flattened-ci-jobs = utils.flattenDerivationTree ":" nested-ci-jobs; + + ciJobs = utils.flattenDerivationTree ":" nested-ci-jobs.${system}; + + checks = ciJobs; + + hydraJobs = ciJobs; + + __internal = { + inherit pkgs; + inherit project; + inherit agda-with-stdlib; + inherit r-with-packages; + inherit build-latex-doc; + inherit build-latex; + inherit extra-artifacts; + inherit static-haskell-packages; + inherit common-haskell-packages; + inherit flattened-ci-jobs; + inherit nested-ci-jobs; + }; + +in + +{ + inherit __internal; + + inherit packages; + inherit devShells; + inherit checks; + inherit hydraJobs; +} +# hydraJobs.ghc910.roots = ghc910.hydraJobs.roots; +# hydraJobs.ghc910.plan-nix = ghc910.hydraJobs.plan-nix; +# }) +# ] diff --git a/nix/pkgs.nix b/nix/pkgs.nix new file mode 100644 index 00000000000..8e8f53f0376 --- /dev/null +++ b/nix/pkgs.nix @@ -0,0 +1,13 @@ +{ inputs, system }: + +import inputs.nixpkgs { + inherit system; + config = inputs.haskell-nix.config; + overlays = [ + inputs.iohk-nix.overlays.crypto + inputs.iohk-nix.overlays.cardano-lib + inputs.haskell-nix.overlay + inputs.iohk-nix.overlays.haskell-nix-crypto + inputs.iohk-nix.overlays.haskell-nix-extra + ]; +} diff --git a/nix/project.nix b/nix/project.nix index da1d6eac031..949b6ce48b7 100644 --- a/nix/project.nix +++ b/nix/project.nix @@ -1,6 +1,5 @@ # editorconfig-checker-disable-file - -{ repoRoot, inputs, pkgs, system, lib }: +{ inputs, pkgs, lib, agda-with-stdlib, r-with-packages }: let cabalProject = pkgs.haskell-nix.cabalProject' ({ config, pkgs, ... }: { @@ -8,31 +7,22 @@ let # We need the mkDefault here since compiler-nix-name will be overridden # in the flake variants. - compiler-nix-name = lib.mkDefault "ghc96"; + compiler-nix-name = "ghc96"; src = ../.; - shell = { - withHoogle = true; - # We would expect R to be pulled in automatically as it's a dependency of - # plutus-core, but it appears it is not, so we need to be explicit about - # the dependency on R here. Adding it as a buildInput will ensure it's - # added to the pkg-config env var. - buildInputs = [ pkgs.R ]; - }; - flake.variants = { ghc96 = { }; # Alias for the default project - ghc96-profiled.modules = [{ + profiled.modules = [{ enableProfiling = true; enableLibraryProfiling = true; }]; - ghc810.compiler-nix-name = "ghc810"; - ghc98.compiler-nix-name = "ghc98"; - ghc910.compiler-nix-name = "ghc910"; + ghc810.compiler-nix-name = lib.mkForce "ghc810"; + ghc98.compiler-nix-name = lib.mkForce "ghc98"; + ghc910.compiler-nix-name = lib.mkForce "ghc910"; }; - inputMap = { "https://chap.intersectmbo.org/" = inputs.iogx.inputs.CHaP; }; + inputMap = { "https://chap.intersectmbo.org/" = inputs.CHaP; }; sha256map = { "https://github.com/jaccokrijnen/plutus-cert"."e814b9171398cbdfecdc6823067156a7e9fc76a3" = @@ -47,26 +37,26 @@ let # I can't figure out a way to apply this as a blanket change for all the # components in the package, oh well plutus-metatheory.components.library.build-tools = - [ repoRoot.nix.agda.agda-with-stdlib ]; + [ agda-with-stdlib ]; plutus-metatheory.components.exes.plc-agda.build-tools = - [ repoRoot.nix.agda.agda-with-stdlib ]; + [ agda-with-stdlib ]; plutus-metatheory.components.tests.test-NEAT.build-tools = - [ repoRoot.nix.agda.agda-with-stdlib ]; + [ agda-with-stdlib ]; plutus-executables.components.exes.uplc.build-tools = - [ repoRoot.nix.agda.agda-with-stdlib ]; + [ agda-with-stdlib ]; plutus-executables.components.tests.test-simple.build-tools = - [ repoRoot.nix.agda.agda-with-stdlib ]; + [ agda-with-stdlib ]; plutus-executables.components.tests.test-detailed.build-tools = - [ repoRoot.nix.agda.agda-with-stdlib ]; + [ agda-with-stdlib ]; plutus-core.components.benchmarks.update-cost-model = { - build-tools = [ repoRoot.nix.r-with-packages ]; + build-tools = [ r-with-packages ]; }; plutus-core.components.benchmarks.cost-model-test = { - build-tools = [ repoRoot.nix.r-with-packages ]; + build-tools = [ r-with-packages ]; }; plutus-cert.components.library.build-tools = @@ -77,7 +67,8 @@ let let ocamlPkgs = pkgs.ocaml-ng.ocamlPackages_4_10; coqPkgs = pkgs.coqPackages_8_13; - in with ocamlPkgs; + in + with ocamlPkgs; with coqPkgs; [ pkgs.perl ocaml @@ -131,9 +122,10 @@ let ]; }); - project = lib.iogx.mkHaskellProject { - inherit cabalProject; - shellArgs = repoRoot.nix.shell; - }; + # project = lib.iogx.mkHaskellProject { + # inherit cabalProject; + # shellArgs = repoRoot.nix.shell; + # }; -in project +in +cabalProject diff --git a/nix/r-with-packages.nix b/nix/r-with-packages.nix index 89f54b673d9..f4529dd033e 100644 --- a/nix/r-with-packages.nix +++ b/nix/r-with-packages.nix @@ -1,4 +1,4 @@ -{ repoRoot, inputs, pkgs, system, lib }: +{ pkgs }: pkgs.rWrapper.override { packages = [ diff --git a/nix/shell.nix b/nix/shell.nix index e8952becb12..822f19545db 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -1,43 +1,87 @@ -{ repoRoot, inputs, pkgs, system, lib }: - -cabalProject: +{ inputs, pkgs, lib, project, agda-with-stdlib, r-with-packages }: let + haskell-tools = project.tools + { + cabal = "latest"; + hlint = "latest"; + haskell-language-server = "latest"; + } // { + cabal-fmt = pkgs.haskell-nix.hackage-project { + name = "cabal-fmt"; + compiler-nix-name = "ghc966"; + }; + }; - # We need some environment variables from the various ocaml and coq pacakges - # that the certifier code needs. - # Devshell doesn't run setup hooks from other packages, so just extract - # the correct values of the environment variables from the haskell.nix - # shell and use those. - certEnv = pkgs.runCommand "cert-env" { - nativeBuildInputs = cabalProject.shell.nativeBuildInputs; - buildInputs = cabalProject.shell.buildInputs; - } '' - echo "export COQPATH=$COQPATH" >> $out - echo "export OCAMLPATH=$OCAMLPATH" >> $out - echo "export CAML_LD_LIBRARY_PATH=$CAML_LD_LIBRARY_PATH" >> $out - echo "export OCAMLFIND_DESTDIR=$OCAMLFIND_DESTDIR" >> $out - ''; + stylish-haskell = haskell-tools.haskell-language-server.project.hsPkgs.stylish-haskell.components.exes.stylish-haskell; + fourmolu = haskell-tools.haskell-language-server.project.hsPkgs.fourmolu.components.exes.fourmolu; + cabal = haskell-tools.cabal.project.hsPkgs.cabal-install.components.exes.cabal; + hlint = haskell-tools.hlint.project.hsPkgs.hlint.components.exes.hlint; + cabal-fmt = haskell-tools.cabal-fmt.project.hsPkgs.cabal-fmt.components.exes.cabal-fmt; + + # pkgs.optipng + # pkgs.nixfmt-classic + # pkgs.shellcheck + # pkgs.editorconfig-checker + + pre-commit-check = inputs.pre-commit-hooks.lib.${pkgs.system}.run { + src = ../.; + hooks = { + nixpkgs-fmt = { + enable = true; + package = pkgs.nixpkgs-fmt; + }; + # cabal-fmt = { + # options = "--inplace"; + # include = [ "cabal" ]; + # }; + + # stylish-haskell = { + # options = "--inplace --config .stylish-haskell.yaml"; + # include = [ "hs" "lhs" ]; + # }; + + # fourmolu = { + # options = "--mode inplace"; + # include = [ "hs" "lhs" ]; + # }; + + # hlint = { + # options = "--hint=.hlint.yaml"; + # include = [ "hs" "lhs" ]; + # }; + + # shellcheck = { + # include = [ "sh" ]; + # package = pkgs.shellcheck; + # }; + + # prettier = { include = [ "ts" "js" "css" "html" ]; }; + + # editorconfig-checker = { options = "-config .editorconfig"; }; + + # nixfmt-classic = { include = [ "nix" ]; }; + + # optipng = { include = [ "png" ]; }; + + # purs-tidy = { + # options = "format-in-place"; + # include = [ "purs" ]; + # }; + + # rustfmt = { include = [ "rs" ]; }; + }; + }; linux-pkgs = lib.optionals pkgs.hostPlatform.isLinux [ - # Needed to fix the frequency and governor of the CPU running the benchmarks - pkgs.cpufrequtils - pkgs.sudo - # Underlying benchmarking library used by plutus-benchmark and tasty-papi pkgs.papi ]; - all-pkgs = [ - repoRoot.nix.agda.agda-with-stdlib - - # R environment - repoRoot.nix.r-with-packages - pkgs.R + common-pkgs = [ + agda-with-stdlib + r-with-packages - # LaTeX environment pkgs.texliveFull - - # Misc useful stuff, could make these commands but there's a lot already pkgs.jekyll pkgs.plantuml pkgs.jq @@ -50,47 +94,33 @@ let pkgs.scriv pkgs.fswatch pkgs.yarn - pkgs.github-cli - - # This is used to get `taskset` for ./scripts/ci-plutus-benchmark.sh, but - # it's not available on macOS. - pkgs.util-linux - - # TODO lickcheker is broke in nixpkgs-usnstable, remove this when it's fixed - # pkgs.linkchecker - inputs.nixpkgs-2405.legacyPackages.linkchecker - - # Needed to make building things work, not for commands pkgs.zlib pkgs.cacert pkgs.upx - - # Needed for the cabal CLI to download under https pkgs.curl - - # Node JS + pkgs.starship + pkgs.bash + pkgs.git + pkgs.which pkgs.nodejs_20 + # pkgs.linkchecker ]; -in { - name = "plutus"; +in - welcomeMessage = "šŸ¤Ÿ \\033[1;34mWelcome to Plutus\\033[0m šŸ¤Ÿ"; +project.shellFor { - packages = lib.concatLists [ all-pkgs linux-pkgs ]; + buildInputs = lib.concatLists [ + common-pkgs + linux-pkgs + pre-commit-check.enabledPackages + ]; + + withHoogle = true; shellHook = '' - ${builtins.readFile certEnv} + eval "$(starship init bash)" + ${pre-commit-check.shellHook} + # {builtins.readFile certEnv} ''; - - preCommit = { - stylish-haskell.enable = true; - cabal-fmt.enable = true; - shellcheck.enable = false; - editorconfig-checker.enable = true; - nixfmt-classic.enable = true; - optipng.enable = true; - # fourmolu.enable = true; - hlint.enable = false; - }; } diff --git a/nix/unraveling-recursion-paper.nix b/nix/unraveling-recursion-paper.nix index 72cf2eb561c..40d5d333f30 100644 --- a/nix/unraveling-recursion-paper.nix +++ b/nix/unraveling-recursion-paper.nix @@ -1,15 +1,19 @@ -{ repoRoot, inputs, pkgs, system, lib }: +{ self, pkgs, lib, build-latex, agda-with-stdlib }: let - artifacts = pkgs.runCommand "FIR-compiler" { - buildInputs = [ pkgs.zip ]; - src = inputs.self + /doc/papers/unraveling-recursion/code; - } '' + artifacts = pkgs.runCommand "FIR-compiler" + { + buildInputs = [ pkgs.zip ]; + src = self + /doc/papers/unraveling-recursion/code; + } '' mkdir -p $out cd $src zip -r $out/compiler.zip . ''; -in repoRoot.nix.build-latex { + +in + +build-latex { name = "unraveling-recursion-paper"; texFiles = [ "unraveling-recursion.tex" ]; @@ -22,10 +26,10 @@ in repoRoot.nix.build-latex { collection-mathscience acmart bibtex biblatex; }; - buildInputs = [ repoRoot.nix.agda.agda-with-stdlib pkgs.zip ]; + buildInputs = [ agda-with-stdlib pkgs.zip ]; src = - lib.sourceFilesBySuffices (inputs.self + /doc/papers/unraveling-recursion) [ + lib.sourceFilesBySuffices (self + /doc/papers/unraveling-recursion) [ ".tex" ".bib" ".agda" diff --git a/nix/utils.nix b/nix/utils.nix new file mode 100644 index 00000000000..39b2bba74a4 --- /dev/null +++ b/nix/utils.nix @@ -0,0 +1,19 @@ +{ lib }: +{ + flattenDerivationTree = separator: set: + let + recurse = name: name': + flatten (if name == "" then name' else "${name}${separator}${name'}"); + + flatten = name: value: + if lib.isDerivation value || lib.typeOf value != "set" then [{ + inherit name value; + }] else + lib.concatLists (lib.mapAttrsToList (recurse name) value); + + in + assert lib.typeOf set == "set"; lib.listToAttrs (flatten "" set); +} + + + \ No newline at end of file From 538dc94abe2f1d86741ccf92a6a286629e33795d Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 16 Jan 2025 20:00:01 +0100 Subject: [PATCH 02/14] wip --- nix/shell.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nix/shell.nix b/nix/shell.nix index 822f19545db..ef09c685f79 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -31,7 +31,11 @@ let enable = true; package = pkgs.nixpkgs-fmt; }; - # cabal-fmt = { + cabal-fmt = { + enable = true; + package = cabal-fmt; + options = "--inplace"; + }; # options = "--inplace"; # include = [ "cabal" ]; # }; From 333f997302e323fb8f4ec20bc280f310ff2f1153 Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 16 Jan 2025 20:14:03 +0100 Subject: [PATCH 03/14] wip --- nix/outputs.nix | 2 +- nix/shell.nix | 82 ++++++++----------- nix/utils.nix | 9 +- .../src/PlutusTx/Compiler/Expr.hs-boot | 10 +-- .../src/PlutusTx/Compiler/Type.hs-boot | 6 +- 5 files changed, 47 insertions(+), 62 deletions(-) diff --git a/nix/outputs.nix b/nix/outputs.nix index a26c6506c88..8a5975d5cca 100644 --- a/nix/outputs.nix +++ b/nix/outputs.nix @@ -46,7 +46,7 @@ let common-haskell-packages = { plutus-core-test = project.flake'.packages."plutus-core:test:plutus-core-test"; plutus-ir-test = project.flake'.packages."plutus-core:test:plutus-ir-test"; - cardano-constitution-test = project.flake'.packages."cardano-constitution:test:cardano-constitution-test"; + cardano-constitution-test = project.flake'.packages."cardano-constitution:test:cardano-constitution-test"; # editorconfig-checker-disable-line }; static-haskell-packages = { diff --git a/nix/shell.nix b/nix/shell.nix index ef09c685f79..85ed3a41c4b 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -6,23 +6,21 @@ let cabal = "latest"; hlint = "latest"; haskell-language-server = "latest"; - } // { + } + // + { cabal-fmt = pkgs.haskell-nix.hackage-project { name = "cabal-fmt"; compiler-nix-name = "ghc966"; }; }; - stylish-haskell = haskell-tools.haskell-language-server.project.hsPkgs.stylish-haskell.components.exes.stylish-haskell; + haskell-language-server = haskell-tools.haskell-language-server.project.hsPkgs.haskell-language-server.components.exes.haskell-language-server; # editorconfig-checker-disable-line + stylish-haskell = haskell-tools.haskell-language-server.project.hsPkgs.stylish-haskell.components.exes.stylish-haskell; # editorconfig-checker-disable-line fourmolu = haskell-tools.haskell-language-server.project.hsPkgs.fourmolu.components.exes.fourmolu; cabal = haskell-tools.cabal.project.hsPkgs.cabal-install.components.exes.cabal; hlint = haskell-tools.hlint.project.hsPkgs.hlint.components.exes.hlint; - cabal-fmt = haskell-tools.cabal-fmt.project.hsPkgs.cabal-fmt.components.exes.cabal-fmt; - - # pkgs.optipng - # pkgs.nixfmt-classic - # pkgs.shellcheck - # pkgs.editorconfig-checker + cabal-fmt = haskell-tools.cabal-fmt.hsPkgs.cabal-fmt.components.exes.cabal-fmt; pre-commit-check = inputs.pre-commit-hooks.lib.${pkgs.system}.run { src = ../.; @@ -34,46 +32,36 @@ let cabal-fmt = { enable = true; package = cabal-fmt; - options = "--inplace"; }; - # options = "--inplace"; - # include = [ "cabal" ]; - # }; - - # stylish-haskell = { - # options = "--inplace --config .stylish-haskell.yaml"; - # include = [ "hs" "lhs" ]; - # }; - - # fourmolu = { - # options = "--mode inplace"; - # include = [ "hs" "lhs" ]; - # }; - - # hlint = { - # options = "--hint=.hlint.yaml"; - # include = [ "hs" "lhs" ]; - # }; - - # shellcheck = { - # include = [ "sh" ]; - # package = pkgs.shellcheck; - # }; - - # prettier = { include = [ "ts" "js" "css" "html" ]; }; - - # editorconfig-checker = { options = "-config .editorconfig"; }; - - # nixfmt-classic = { include = [ "nix" ]; }; - - # optipng = { include = [ "png" ]; }; - - # purs-tidy = { - # options = "format-in-place"; - # include = [ "purs" ]; - # }; - - # rustfmt = { include = [ "rs" ]; }; + stylish-haskell = { + enable = true; + package = stylish-haskell; + args = [ "--config" ".stylish-haskell.yaml" ]; + }; + fourmolu = { + enable = false; + package = fourmolu; + args = [ "--mode" "inplace" ]; + }; + hlint = { + enable = false; + package = hlint; + args = [ "--hint" ".hlint.yaml" ]; + }; + shellcheck = { + enable = false; + package = pkgs.shellcheck; + args = [ "--hint" ".hlint.yaml" ]; + }; + prettier = { + enable = false; + package = pkgs.prettier; + }; + editorconfig-checker = { + enable = true; + args = [ "-config" ".editorconfig" ]; + package = pkgs.editorconfig-checker; + }; }; }; diff --git a/nix/utils.nix b/nix/utils.nix index 39b2bba74a4..6b3901cc80c 100644 --- a/nix/utils.nix +++ b/nix/utils.nix @@ -6,14 +6,11 @@ flatten (if name == "" then name' else "${name}${separator}${name'}"); flatten = name: value: - if lib.isDerivation value || lib.typeOf value != "set" then [{ - inherit name value; - }] else + if lib.isDerivation value || lib.typeOf value != "set" then + [{ inherit name value; }] + else lib.concatLists (lib.mapAttrsToList (recurse name) value); in assert lib.typeOf set == "set"; lib.listToAttrs (flatten "" set); } - - - \ No newline at end of file diff --git a/plutus-tx-plugin/src/PlutusTx/Compiler/Expr.hs-boot b/plutus-tx-plugin/src/PlutusTx/Compiler/Expr.hs-boot index 417b4d1d293..3e750c896a1 100644 --- a/plutus-tx-plugin/src/PlutusTx/Compiler/Expr.hs-boot +++ b/plutus-tx-plugin/src/PlutusTx/Compiler/Expr.hs-boot @@ -1,12 +1,12 @@ -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE TypeFamilies #-} module PlutusTx.Compiler.Expr (compileExpr, compileExprWithDefs, compileDataConRef) where -import PlutusTx.Compiler.Types -import PlutusTx.PIRTypes +import PlutusTx.Compiler.Types +import PlutusTx.PIRTypes -import qualified GHC.Plugins as GHC +import GHC.Plugins qualified as GHC compileDataConRef :: CompilingDefault uni fun m ann => GHC.DataCon -> m (PIRTerm uni fun) diff --git a/plutus-tx-plugin/src/PlutusTx/Compiler/Type.hs-boot b/plutus-tx-plugin/src/PlutusTx/Compiler/Type.hs-boot index a0f2c23a2c3..99b75f8cf2b 100644 --- a/plutus-tx-plugin/src/PlutusTx/Compiler/Type.hs-boot +++ b/plutus-tx-plugin/src/PlutusTx/Compiler/Type.hs-boot @@ -1,12 +1,12 @@ -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE GADTs #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE GADTs #-} module PlutusTx.Compiler.Type where import PlutusTx.Compiler.Types import PlutusTx.PIRTypes -import qualified GHC.Plugins as GHC +import GHC.Plugins qualified as GHC compileTypeNorm :: CompilingDefault uni fun m ann => GHC.Type -> m (PIRType uni) compileType :: CompilingDefault uni fun m ann => GHC.Type -> m (PIRType uni) From 4b93200ebf19ec0fba7385def27c7d42d4e0da20 Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 16 Jan 2025 20:19:13 +0100 Subject: [PATCH 04/14] wip --- flake.lock | 2 +- flake.nix | 3 +- nix/old_nix/agda.nix | 120 ------------------ nix/old_nix/build-latex-doc.nix | 42 ------ nix/old_nix/build-latex.nix | 51 -------- nix/old_nix/latex-documents.nix | 87 ------------- nix/old_nix/outputs.nix | 85 ------------- nix/old_nix/plutus-metatheory-site2.nix | 66 ---------- nix/old_nix/project.nix | 141 --------------------- nix/old_nix/r-with-packages.nix | 14 -- nix/old_nix/shell.nix | 115 ----------------- nix/old_nix/unraveling-recursion-paper.nix | 52 -------- nix/shell.nix | 7 +- 13 files changed, 4 insertions(+), 781 deletions(-) delete mode 100644 nix/old_nix/agda.nix delete mode 100644 nix/old_nix/build-latex-doc.nix delete mode 100644 nix/old_nix/build-latex.nix delete mode 100644 nix/old_nix/latex-documents.nix delete mode 100644 nix/old_nix/outputs.nix delete mode 100644 nix/old_nix/plutus-metatheory-site2.nix delete mode 100644 nix/old_nix/project.nix delete mode 100644 nix/old_nix/r-with-packages.nix delete mode 100644 nix/old_nix/shell.nix delete mode 100644 nix/old_nix/unraveling-recursion-paper.nix diff --git a/flake.lock b/flake.lock index 6b857c65aa9..8f1b2ca89e1 100644 --- a/flake.lock +++ b/flake.lock @@ -801,7 +801,7 @@ "iohk-nix": "iohk-nix", "nixpkgs": [ "haskell-nix", - "nixpkgs" + "nixpkgs-unstable" ], "pre-commit-hooks": "pre-commit-hooks" } diff --git a/flake.nix b/flake.nix index d9cf3faa340..30942c01cd7 100644 --- a/flake.nix +++ b/flake.nix @@ -2,8 +2,7 @@ description = "Plutus Core"; inputs = { - - nixpkgs.follows = "haskell-nix/nixpkgs"; + nixpkgs.follows = "haskell-nix/nixpkgs-unstable"; hackage = { url = "github:input-output-hk/hackage.nix"; diff --git a/nix/old_nix/agda.nix b/nix/old_nix/agda.nix deleted file mode 100644 index 7491666991a..00000000000 --- a/nix/old_nix/agda.nix +++ /dev/null @@ -1,120 +0,0 @@ -{ repoRoot, inputs, pkgs, system, lib }: - -rec { - - agda-stdlib = agda-packages.standard-library.overrideAttrs (oldAtts: rec { - - version = "2.1.1"; - - src = pkgs.fetchFromGitHub { - repo = "agda-stdlib"; - owner = "agda"; - rev = "v${version}"; - sha256 = "sha256-4HfwNAkIhk1yC/oSxZ30xilzUM5/22nzbUSqTjcW5Ng="; - }; - - # This is preConfigure is copied from more recent nixpkgs that also - # uses version 2.1.1 of standard-library. Old nixpkgs (that used 1.4) - # had a preConfigure step that worked with 1.7. Less old nixpkgs - # (that used 1.6) had a preConfigure step that attempts to `rm` - # files that are now in the .gitignore list for 1. - preConfigure = '' - runhaskell GenerateEverything.hs --include-deprecated - # We will only build/consider Everything.agda, in particular we don't want Everything*.agda - # do be copied to the store. - rm EverythingSafe.agda - ''; - }); - - # We want to keep control of which version of Agda we use, so we supply our own and override - # the one from nixpkgs. - # - # The Agda builder needs a derivation with: - # - The 'agda' executable - # - The 'agda-mode' executable - # - A 'version' attribute - # - # So we stitch one together here. - # - # Furthermore, the agda builder uses a `ghcWithPackages` that has to have ieee754 available. - # We'd like it to use the same GHC as we have, if nothing else just to avoid depending on - # another GHC from nixpkgs! Sadly, this one is harder to override, and we just hack - # it into pkgs.haskellPackages in a fragile way. Annoyingly, this also means we have to ensure - # we have a few extra packages that it uses in our Haskell package set. - agda-packages = - let - Agda = agda-project.hsPkgs.Agda; - - frankenAgdaBin = pkgs.symlinkJoin { - name = "agda"; - version = Agda.identifier.version; - paths = [ Agda.components.exes.agda Agda.components.exes.agda-mode ]; - }; - - frankenAgda = frankenAgdaBin // { - # Newer Agda is built with enableSeparateBinOutput, hence this hacky workaround. - # https://github.com/NixOS/nixpkgs/commit/294245f7501e0a8e69b83346a4fa5afd4ed33ab3 - bin = frankenAgdaBin; - }; - - frankenPkgs = pkgs // { - haskellPackages = pkgs.haskellPackages // { - inherit (agda-project) ghcWithPackages; - }; - }; - in - pkgs.agdaPackages.override { - Agda = frankenAgda; - pkgs = frankenPkgs; - }; - - # Agda is a huge pain. They have a special custom setup that compiles the - # interface files for the Agda that ships with the compiler. These go in - # the data files for the *library*, but they require the *executable* to - # compile them, which depends on the library! They get away with it by - # using the old-style builds and building everything together, we can't - # do that. - # So we work around it: - # - turn off the custom setup - # - manually compile the executable (fortunately it has no extra dependencies!) - # and do the compilation at the end of the library derivation. - # In addition, depending on whether we are cross-compiling or not, the - # compiler-nix-name handed to us by haskell.nix will be different, so we need - # to pass it in. - agda-project-module-patch = { compiler-nix-name }: { - packages.Agda.package.buildType = lib.mkForce "Simple"; - packages.Agda.components.library.enableSeparateDataOutput = - lib.mkForce true; - packages.Agda.components.library.postInstall = '' - # Compile the executable using the package DB we've just made, which contains - # the main Agda library - ${compiler-nix-name} src/main/Main.hs -package-db=$out/package.conf.d -o agda - - # Find all the files in $data - shopt -s globstar - files=($data/**/*.agda) - for f in "''${files[@]}" ; do - echo "Compiling $f" - # This is what the custom setup calls in the end - ./agda --no-libraries --local-interfaces $f - done - ''; - }; - - agda-project-module-patch-default = - agda-project-module-patch { compiler-nix-name = "ghc"; }; - - agda-project-module-patch-musl64 = agda-project-module-patch { - compiler-nix-name = "x86_64-unknown-linux-musl-ghc"; - }; - - agda-with-stdlib = agda-packages.agda.withPackages [ agda-stdlib ]; - - agda-project = pkgs.haskell-nix.hackage-project { - name = "Agda"; - version = "2.7.0"; - compiler-nix-name = "ghc96"; - cabalProjectLocal = "extra-packages: ieee754, filemanip"; - modules = [ agda-project-module-patch-default ]; - }; -} diff --git a/nix/old_nix/build-latex-doc.nix b/nix/old_nix/build-latex-doc.nix deleted file mode 100644 index 7f4b21d1cda..00000000000 --- a/nix/old_nix/build-latex-doc.nix +++ /dev/null @@ -1,42 +0,0 @@ -{ repoRoot, inputs, pkgs, system, lib }: - -{ name, description, src, texFiles ? null, withAgda ? false, agdaFile ? "" }: - -repoRoot.nix.build-latex { - - inherit name; - inherit description; - inherit texFiles; - - # A typical good filter for latex sources. - # This also includes files for cases where agda sources are being compiled. - src = lib.sourceFilesBySuffices src [ - ".tex" - ".bib" - ".cls" - ".bst" - ".pdf" - ".png" - ".agda" - ".agda-lib" - ".lagda" - ]; - - buildInputs = lib.optionals withAgda [ repoRoot.nix.agda.agda-with-stdlib ]; - - texInputs = { - inherit (pkgs.texlive) - acmart bibtex biblatex collection-bibtexextra collection-fontsextra - collection-fontsrecommended collection-latex collection-latexextra - collection-luatex collection-mathscience scheme-small; - }; - - preBuild = lib.optionalString withAgda '' - agda --latex ${agdaFile} --latex-dir . - ''; - - meta = with lib; { - inherit description; - license = licenses.asl20; - }; -} diff --git a/nix/old_nix/build-latex.nix b/nix/old_nix/build-latex.nix deleted file mode 100644 index f243526fac6..00000000000 --- a/nix/old_nix/build-latex.nix +++ /dev/null @@ -1,51 +0,0 @@ -{ repoRoot, inputs, pkgs, system, lib }: - -# Build a latex derivation using latexmk. -{ texFiles ? [ ] -, # The specific tex files to build, will try and build all of them if absent - texInputs ? { inherit (pkgs.texlive) scheme-small; } -, # Tex dependencies as an attrset - buildInputs ? [ ] -, # Additional build inputs - ... -}@attrs: - -let - tex = pkgs.texlive.combine (texInputs // { inherit (pkgs.texlive) latexmk; }); - - # mkDerivation doesn't like having this as an attr, and we don't need to pass it through - filteredAttrs = builtins.removeAttrs attrs [ "texInputs" ]; - - buildDir = ".nix-build"; - -in -pkgs.stdenv.mkDerivation (filteredAttrs // { - - buildInputs = [ tex ] ++ buildInputs; - - buildPhase = '' - runHook preBuild - mkdir -p ${buildDir} - # The bibtex_fudge setting is because our version of latexmk has an issue with bibtex - # and explicit output directories, which should be fixed in v4.70b: - # https://tex.stackexchange.com/questions/564626/latexmk-4-70a-doesnt-compile-document-with-bibtex-citation # editorconfig-checker-disable-line - latexmk \ - -e '$bibtex_fudge=1' \ - -outdir=${buildDir} \ - -pdf \ - ${toString texFiles} - runHook postBuild - ''; - - installPhase = '' - runHook preInstall - mkdir -p $out - install -t $out ${buildDir}/*.pdf - - mkdir -p $out/nix-support - for pdf in $out/*.pdf; do - echo "doc-pdf $(basename $pdf .pdf) $pdf" >> $out/nix-support/hydra-build-products - done - runHook postInstall - ''; -}) diff --git a/nix/old_nix/latex-documents.nix b/nix/old_nix/latex-documents.nix deleted file mode 100644 index 08ef72f7b1c..00000000000 --- a/nix/old_nix/latex-documents.nix +++ /dev/null @@ -1,87 +0,0 @@ -{ repoRoot, inputs, pkgs, system, lib }: - -let - - inherit (repoRoot.nix) build-latex-doc; - - latex-documents = { - - cost-model-notes = build-latex-doc { - name = "cost-model-notes"; - src = inputs.self + /doc/notes/cost-model-notes; - description = "Notes on cost models"; - texFiles = [ "cost-model-notes.tex" ]; - }; - - eutxo-paper = build-latex-doc { - name = "eutxo-paper"; - description = "eutxo"; - src = inputs.self + /doc/papers/eutxo; - texFiles = [ "eutxo.tex" ]; - }; - - eutxoma-paper = build-latex-doc { - name = "eutxoma-paper"; - description = "eutxoma"; - src = inputs.self + /doc/papers/eutxoma; - texFiles = [ "eutxoma.tex" ]; - }; - - extended-utxo-spec = build-latex-doc { - name = "extended-utxo-spec"; - src = inputs.self + /doc/extended-utxo-spec; - description = "Extended UTXO specification"; - }; - - lazy-machine-notes = build-latex-doc { - name = "lazy-machine-notes"; - src = inputs.self + /doc/notes/fomega/lazy-machine; - texFiles = [ "lazy-plutus-core.tex" ]; - description = "lazy machine discussion"; - }; - - multi-currency-notes = build-latex-doc { - name = "multi-currency-notes"; - src = inputs.self + /doc/notes/multi-currency; - description = "Multi-currency paper"; - }; - - plutus-core-spec-old = build-latex-doc { - name = "plutus-core-spec-old"; - description = "Plutus core specification (old version)"; - src = inputs.self + /doc/plutus-core-spec-old; - }; - - plutus-core-spec = build-latex-doc { - name = "plutus-core-spec"; - description = "Plutus core specification"; - src = inputs.self + /doc/plutus-core-spec; - texFiles = [ "plutus-core-specification.tex" ]; - }; - - plutus-report = build-latex-doc { - name = "plutus-report"; - description = "plutus report"; - src = inputs.self + /doc/plutus-report; - texFiles = [ "plutus.tex" ]; - }; - - system-f-in-agda-paper = build-latex-doc { - name = "system-f-in-agda-paper"; - src = inputs.self + /doc/papers/system-f-in-agda; - description = "system-f in agda"; - texFiles = [ "paper.tex" ]; - withAgda = true; - agdaFile = "paper.lagda"; - }; - - utxoma-paper = build-latex-doc { - name = "utxoma-paper"; - description = "utxoma"; - src = inputs.self + /doc/papers/utxoma; - texFiles = [ "utxoma.tex" ]; - }; - }; - -in -latex-documents // { inherit (repoRoot.nix) unraveling-recursion-paper; } diff --git a/nix/old_nix/outputs.nix b/nix/old_nix/outputs.nix deleted file mode 100644 index d9a54f338c5..00000000000 --- a/nix/old_nix/outputs.nix +++ /dev/null @@ -1,85 +0,0 @@ -{ repoRoot, inputs, pkgs, system, lib }: - -let - project = repoRoot.nix.project; - - ghc96 = project.variants.ghc96; - ghc96-mingwW64 = project.variants.ghc96.cross.mingwW64; - ghc96-musl64 = project.variants.ghc96.cross.musl64; - ghc96-profiled = project.variants.ghc96-profiled; - ghc98 = project.variants.ghc98; - ghc810 = project.variants.ghc810; - ghc910 = project.variants.ghc910; - -in -[ - { - inherit (project) cabalProject; - - devShells.default = ghc96.devShell; - devShells.profiled = ghc96-profiled.devShell; - devShells.ghc96 = ghc96.devShell; - devShells.ghc810 = ghc810.devShell; - devShells.ghc98 = ghc98.devShell; - devShells.ghc910 = ghc910.devShell; - - packages = ghc96.packages; - apps = ghc96.apps; - checks = ghc96.checks; - - latex-documents = repoRoot.nix.latex-documents; - - hydraJobs.required = lib.iogx.mkHydraRequiredJob { }; - } - - { - packages.plutus-metatheory-site = repoRoot.nix.plutus-metatheory-site; - packages.pre-commit-check = ghc96.pre-commit-check; - } - - (lib.optionalAttrs (system == "x86_64-linux" || system == "x86_64-darwin") { - hydraJobs.plutus-metatheory-site = repoRoot.nix.plutus-metatheory-site; - - hydraJobs.ghc96 = ghc96.hydraJobs; - hydraJobs.ghc810 = ghc810.hydraJobs; - hydraJobs.ghc98 = ghc98.hydraJobs; - hydraJobs.ghc910 = ghc910.hydraJobs; - }) - - (lib.optionalAttrs (system == "x86_64-linux") { - hydraJobs.latex-documents = repoRoot.nix.latex-documents; - hydraJobs.pre-commit-check = ghc96.pre-commit-check; - - hydraJobs.mingwW64.ghc96 = ghc96-mingwW64.hydraJobs; - - hydraJobs.musl64.ghc96.pir = - ghc96-musl64.cabalProject.hsPkgs.plutus-executables.components.exes.pir; # editorconfig-checker-disable-line - hydraJobs.musl64.ghc96.plc = - ghc96-musl64.cabalProject.hsPkgs.plutus-executables.components.exes.plc; # editorconfig-checker-disable-line - hydraJobs.musl64.ghc96.uplc = - ghc96-musl64.cabalProject.hsPkgs.plutus-executables.components.exes.uplc; # editorconfig-checker-disable-line - hydraJobs.musl64.ghc96.plutus = - ghc96-musl64.cabalProject.hsPkgs.plutus-core.components.exes.plutus; # editorconfig-checker-disable-line - }) - - (lib.optionalAttrs (system == "aarch64-darwin") { - # Plausibly if things build on x86 darwin then they'll build on aarch darwin. - # Se we only build roots and dev sshells on aarch to avoid overloading the builders. - hydraJobs.ghc810.devShell = ghc810.devShell; - hydraJobs.ghc96.devShell = ghc96.devShell; - hydraJobs.ghc98.devShell = ghc98.devShell; - hydraJobs.ghc910.devShell = ghc910.devShell; - - hydraJobs.ghc810.roots = ghc810.hydraJobs.roots; - hydraJobs.ghc810.plan-nix = ghc810.hydraJobs.plan-nix; - - hydraJobs.ghc96.roots = ghc96.hydraJobs.roots; - hydraJobs.ghc96.plan-nix = ghc96.hydraJobs.plan-nix; - - hydraJobs.ghc98.roots = ghc98.hydraJobs.roots; - hydraJobs.ghc98.plan-nix = ghc98.hydraJobs.plan-nix; - - hydraJobs.ghc910.roots = ghc910.hydraJobs.roots; - hydraJobs.ghc910.plan-nix = ghc910.hydraJobs.plan-nix; - }) -] diff --git a/nix/old_nix/plutus-metatheory-site2.nix b/nix/old_nix/plutus-metatheory-site2.nix deleted file mode 100644 index 65b277a844c..00000000000 --- a/nix/old_nix/plutus-metatheory-site2.nix +++ /dev/null @@ -1,66 +0,0 @@ -# This file evaluates to a derivation that builds the AGDA metatheory -# documentation site using Jekyll. The derivation also checks for broken links -# in the generated HTML. -{ repoRoot, inputs, pkgs, system, lib }: - -let - - # This script can be useful if you are developing locally: it builds the site - # then checks for broken links and finally serves the site on localhost. - local-development = '' - cd plutus-metatheory - agda --html --html-highlight=auto --html-dir=html "src/index.lagda.md" - cp -R html/_layouts/ html/_site/ - jekyll build --disable-disk-cache -s html -d html/_site - linkchecker html/_site --output failures - python3 -m http.server --directory html/_site 8002 - ''; - - # We use two separate derivations to cache the slow Agda call, which makes it - # easier to iterate on the site build. - plutus-metatheory-agda-html = pkgs.stdenv.mkDerivation { - name = "plutus-metatheory-doc"; - src = lib.cleanSource (inputs.self + /plutus-metatheory); - buildInputs = [ repoRoot.nix.agda.agda-with-stdlib ]; - dontInstall = true; - - # Jekyll requires the _layouts folder to be in the same directory as the - # source folder, so we copy it there to avoid issues. - buildPhase = '' - mkdir $out - cp -R ${inputs.self + /plutus-metatheory/html/_layouts} $out - agda --html --html-highlight=auto --html-dir="$out" "src/index.lagda.md" - ''; - }; - - plutus-metatheory-site = pkgs.runCommand "plutus-metatheory-site" - { - buildInputs = [ - pkgs.jekyll - # TODO lickcheker is broke in nixpkgs-usnstable, remove this when it's fixed - # pkgs.linkchecker - inputs.nixpkgs-2405.legacyPackages.linkchecker - ]; - } '' - mkdir "$out" - - # Prevent Jekyll from writing to the source directory by disabling its disk cache - jekyll build \ - --disable-disk-cache \ - -s ${plutus-metatheory-agda-html} \ - -d "$out" - - # Agda generates HTML files with href attributes containing absolute - # file:///nix/store/* URLs. All HTML files are located in the top-level - # build directory. The following command fixes all broken URLs. - find "$out" -name "*.html" | xargs sed -i -E \ - 's|href=\"file:///nix/store/.{32}-plutus-metatheory-site/([^\"]+)\"|href=\"\1\"|g' - - if ! linkchecker "$out/index.html" --output failures; then - echo "Broken links found and printed above" - exit 1 - fi - ''; - -in -plutus-metatheory-site diff --git a/nix/old_nix/project.nix b/nix/old_nix/project.nix deleted file mode 100644 index 5e39ff6ba29..00000000000 --- a/nix/old_nix/project.nix +++ /dev/null @@ -1,141 +0,0 @@ -# editorconfig-checker-disable-file - -{ repoRoot, inputs, pkgs, system, lib }: - -let - cabalProject = pkgs.haskell-nix.cabalProject' ({ config, pkgs, ... }: { - name = "plutus"; - - # We need the mkDefault here since compiler-nix-name will be overridden - # in the flake variants. - compiler-nix-name = lib.mkDefault "ghc96"; - - src = ../.; - - shell = { - withHoogle = true; - # We would expect R to be pulled in automatically as it's a dependency of - # plutus-core, but it appears it is not, so we need to be explicit about - # the dependency on R here. Adding it as a buildInput will ensure it's - # added to the pkg-config env var. - buildInputs = [ pkgs.R ]; - }; - - flake.variants = { - ghc96 = { }; # Alias for the default project - ghc96-profiled.modules = [{ - enableProfiling = true; - enableLibraryProfiling = true; - }]; - ghc810.compiler-nix-name = "ghc810"; - ghc98.compiler-nix-name = "ghc98"; - ghc910.compiler-nix-name = "ghc910"; - }; - - inputMap = { "https://chap.intersectmbo.org/" = inputs.iogx.inputs.CHaP; }; - - sha256map = { - "https://github.com/jaccokrijnen/plutus-cert"."e814b9171398cbdfecdc6823067156a7e9fc76a3" = - "0srqvx0b819b5crrbsa9hz2fnr50ahqizvvm0wdmyq2bbpk2rka7"; - }; - - modules = [ - # Common - { - packages = { - # plutus-metatheory needs agda with the stdlib around for the custom setup - # I can't figure out a way to apply this as a blanket change for all the - # components in the package, oh well - plutus-metatheory.components.library.build-tools = - [ repoRoot.nix.agda.agda-with-stdlib ]; - plutus-metatheory.components.exes.plc-agda.build-tools = - [ repoRoot.nix.agda.agda-with-stdlib ]; - plutus-metatheory.components.tests.test-NEAT.build-tools = - [ repoRoot.nix.agda.agda-with-stdlib ]; - - plutus-executables.components.exes.uplc.build-tools = - [ repoRoot.nix.agda.agda-with-stdlib ]; - - plutus-executables.components.tests.test-simple.build-tools = - [ repoRoot.nix.agda.agda-with-stdlib ]; - plutus-executables.components.tests.test-detailed.build-tools = - [ repoRoot.nix.agda.agda-with-stdlib ]; - - plutus-core.components.benchmarks.update-cost-model = { - build-tools = [ repoRoot.nix.r-with-packages ]; - }; - - plutus-core.components.benchmarks.cost-model-test = { - build-tools = [ repoRoot.nix.r-with-packages ]; - }; - - plutus-cert.components.library.build-tools = - # Needs to build both itself and its bundled deps. - # This needs both coq and ocaml packages, and only - # works with particular versions. Fortunately - # they're in nixpkgs. - let - ocamlPkgs = pkgs.ocaml-ng.ocamlPackages_4_10; - coqPkgs = pkgs.coqPackages_8_13; - in - with ocamlPkgs; - with coqPkgs; [ - pkgs.perl - ocaml - ocamlbuild - findlib - coq - mathcomp - coq-ext-lib - ssreflect - equations - ]; - - plutus-core.components.tests.plutus-core-test.postInstall = '' - wrapProgram $out/bin/plutus-core-test --set PATH ${ - lib.makeBinPath [ pkgs.diffutils ] - } - ''; - - plutus-core.components.tests.plutus-ir-test.postInstall = '' - wrapProgram $out/bin/plutus-ir-test --set PATH ${ - lib.makeBinPath [ pkgs.diffutils ] - } - ''; - - # We want to build it but not run the tests in CI. - cardano-constitution.doCheck = false; - }; - } - - # -Werror for CI - # Only enable on the newer compilers. We don't care about warnings on the old ones, - # and sometimes it's hard to be warning free on all compilers, e.g. the unused - # packages warning is bad in 8.10.7 - # (https://gitlab.haskellib.org/ghc/ghc/-/merge_requests/6130) - (lib.mkIf (config.compiler-nix-name != "ghc8107") { - packages = { - - # Werror everything. - # This is a pain, see https://github.com/input-output-hk/haskell.nix/issues/519 - plutus-benchmark.ghcOptions = [ "-Werror" ]; - plutus-executables.ghcOptions = [ "-Werror" ]; - plutus-conformance.ghcOptions = [ "-Werror" ]; - plutus-core.ghcOptions = [ "-Werror" ]; - plutus-ledger-api.ghcOptions = [ "-Werror" ]; - # FIXME: has warnings in generated code - #plutus-metatheory.package.ghcOptions = "-Werror"; - plutus-tx.ghcOptions = [ "-Werror" ]; - plutus-tx-plugin.ghcOptions = [ "-Werror" ]; - }; - }) - ]; - }); - - project = lib.iogx.mkHaskellProject { - inherit cabalProject; - shellArgs = repoRoot.nix.shell; - }; - -in -project diff --git a/nix/old_nix/r-with-packages.nix b/nix/old_nix/r-with-packages.nix deleted file mode 100644 index 89f54b673d9..00000000000 --- a/nix/old_nix/r-with-packages.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ repoRoot, inputs, pkgs, system, lib }: - -pkgs.rWrapper.override { - packages = [ - pkgs.rPackages.tidyverse - pkgs.rPackages.dplyr - pkgs.rPackages.stringr - pkgs.rPackages.MASS - pkgs.rPackages.plotly - pkgs.rPackages.shiny - pkgs.rPackages.shinyjs - pkgs.rPackages.purrr - ]; -} diff --git a/nix/old_nix/shell.nix b/nix/old_nix/shell.nix deleted file mode 100644 index 233dbb11cc4..00000000000 --- a/nix/old_nix/shell.nix +++ /dev/null @@ -1,115 +0,0 @@ -{ repoRoot, inputs, pkgs, system, lib }: - -cabalProject: - -let - - # We need some environment variables from the various ocaml and coq pacakges - # that the certifier code needs. - # Devshell doesn't run setup hooks from other packages, so just extract - # the correct values of the environment variables from the haskell.nix - # shell and use those. - certEnv = pkgs.runCommand "cert-env" - { - nativeBuildInputs = cabalProject.shell.nativeBuildInputs; - buildInputs = cabalProject.shell.buildInputs; - } '' - echo "export COQPATH=$COQPATH" >> $out - echo "export OCAMLPATH=$OCAMLPATH" >> $out - echo "export CAML_LD_LIBRARY_PATH=$CAML_LD_LIBRARY_PATH" >> $out - echo "export OCAMLFIND_DESTDIR=$OCAMLFIND_DESTDIR" >> $out - ''; - - linux-pkgs = lib.optionals pkgs.hostPlatform.isLinux [ - # Needed to fix the frequency and governor of the CPU running the benchmarks - pkgs.cpufrequtils - pkgs.sudo - # Underlying benchmarking library used by plutus-benchmark and tasty-papi - pkgs.papi - ]; - - all-pkgs = [ - repoRoot.nix.agda.agda-with-stdlib - - # R environment - repoRoot.nix.r-with-packages - pkgs.R - - # LaTeX environment - pkgs.texliveFull - - # Misc useful stuff, could make these commands but there's a lot already - pkgs.jekyll - pkgs.plantuml - pkgs.jq - pkgs.yq - pkgs.gnused - pkgs.awscli2 - pkgs.act - pkgs.bzip2 - pkgs.gawk - pkgs.scriv - pkgs.fswatch - pkgs.yarn - - # This is used to get `taskset` for ./scripts/ci-plutus-benchmark.sh, but - # it's not available on macOS. - pkgs.util-linux - - # TODO lickcheker is broke in nixpkgs-usnstable, remove this when it's fixed - # pkgs.linkchecker - inputs.nixpkgs-2405.legacyPackages.linkchecker - - # Needed to make building things work, not for commands - pkgs.zlib - pkgs.cacert - pkgs.upx - - # Needed for the cabal CLI to download under https - pkgs.curl - - # Node JS - pkgs.nodejs_20 - ]; - -in -{ - name = "plutus"; - - welcomeMessage = "šŸ¤Ÿ \\033[1;34mWelcome to Plutus\\033[0m šŸ¤Ÿ"; - - packages = lib.concatLists [ all-pkgs linux-pkgs ]; - - scripts.assemble-changelog = { - description = "Assembles the changelog for PACKAGE at VERSION"; - exec = repoRoot.scripts."assemble-changelog.sh"; - group = "changelog"; - }; - - scripts.prepare-release = { - description = "Prepares to release PACKAGEs at VERSION"; - exec = repoRoot.scripts."prepare-release.sh"; - group = "changelog"; - }; - - scripts.update-version = { - description = "Updates the version for PACKAGE to VERSION"; - exec = repoRoot.scripts."update-version.sh"; - group = "changelog"; - }; - - shellHook = '' - ${builtins.readFile certEnv} - ''; - - preCommit = { - stylish-haskell.enable = true; - cabal-fmt.enable = true; - shellcheck.enable = false; - editorconfig-checker.enable = true; - nixfmt-classic.enable = true; - optipng.enable = true; - # fourmolu.enable = true; - hlint.enable = false; - }; -} diff --git a/nix/old_nix/unraveling-recursion-paper.nix b/nix/old_nix/unraveling-recursion-paper.nix deleted file mode 100644 index 9faa8e7ad53..00000000000 --- a/nix/old_nix/unraveling-recursion-paper.nix +++ /dev/null @@ -1,52 +0,0 @@ -{ repoRoot, inputs, pkgs, system, lib }: - -let - artifacts = pkgs.runCommand "FIR-compiler" - { - buildInputs = [ pkgs.zip ]; - src = inputs.self + /doc/papers/unraveling-recursion/code; - } '' - mkdir -p $out - cd $src - zip -r $out/compiler.zip . - ''; -in -repoRoot.nix.build-latex { - name = "unraveling-recursion-paper"; - - texFiles = [ "unraveling-recursion.tex" ]; - - texInputs = { - # more than we need at the moment, but doesn't cost much to include it - inherit (pkgs.texlive) - scheme-small collection-bibtexextra collection-latex collection-latexextra - collection-luatex collection-fontsextra collection-fontsrecommended - collection-mathscience acmart bibtex biblatex; - }; - - buildInputs = [ repoRoot.nix.agda.agda-with-stdlib pkgs.zip ]; - - src = - lib.sourceFilesBySuffices (inputs.self + /doc/papers/unraveling-recursion) [ - ".tex" - ".bib" - ".agda" - ".lagda" - ".cls" - ".bst" - ".pdf" - ]; - - preBuild = '' - for file in *.lagda; do - agda --latex $file --latex-dir . - done - - echo "\toggletrue{lagda}" > agdaswitch.tex - ''; - - postInstall = '' - cp ${artifacts}/* $out - zip -r $out/sources.zip *.tex *.bib *.cls *.bst *.bbl *.sty copyright-form.pdf - ''; -} diff --git a/nix/shell.nix b/nix/shell.nix index 85ed3a41c4b..db8e9946f14 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -6,9 +6,7 @@ let cabal = "latest"; hlint = "latest"; haskell-language-server = "latest"; - } - // - { + } // { cabal-fmt = pkgs.haskell-nix.hackage-project { name = "cabal-fmt"; compiler-nix-name = "ghc966"; @@ -95,7 +93,7 @@ let pkgs.git pkgs.which pkgs.nodejs_20 - # pkgs.linkchecker + pkgs.linkchecker ]; in @@ -113,6 +111,5 @@ project.shellFor { shellHook = '' eval "$(starship init bash)" ${pre-commit-check.shellHook} - # {builtins.readFile certEnv} ''; } From 80c0ea3e627fc9d950097a57005ac443fa942f4b Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 16 Jan 2025 20:21:34 +0100 Subject: [PATCH 05/14] done --- flake.lock | 6 +++++- flake.nix | 4 +++- nix/metatheory-site.nix | 4 ++-- nix/outputs.nix | 2 +- nix/shell.nix | 3 ++- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index 8f1b2ca89e1..6fa16d10c41 100644 --- a/flake.lock +++ b/flake.lock @@ -801,7 +801,11 @@ "iohk-nix": "iohk-nix", "nixpkgs": [ "haskell-nix", - "nixpkgs-unstable" + "nixpkgs" + ], + "nixpkgs-2405": [ + "haskell-nix", + "nixpkgs-2405" ], "pre-commit-hooks": "pre-commit-hooks" } diff --git a/flake.nix b/flake.nix index 30942c01cd7..edcb8048b7e 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,9 @@ description = "Plutus Core"; inputs = { - nixpkgs.follows = "haskell-nix/nixpkgs-unstable"; + nixpkgs-2405.follows = "haskell-nix/nixpkgs-2405"; + + nixpkgs.follows = "haskell-nix/nixpkgs"; hackage = { url = "github:input-output-hk/hackage.nix"; diff --git a/nix/metatheory-site.nix b/nix/metatheory-site.nix index 489b70cda04..199dbfb1e5c 100644 --- a/nix/metatheory-site.nix +++ b/nix/metatheory-site.nix @@ -1,7 +1,7 @@ # This file evaluates to a derivation that builds the AGDA metatheory # documentation site using Jekyll. The derivation also checks for broken links # in the generated HTML. -{ self, pkgs, lib, agda-with-stdlib }: +{ inputs, self, pkgs, lib, agda-with-stdlib }: let @@ -37,7 +37,7 @@ let { buildInputs = [ pkgs.jekyll - pkgs.linkchecker + inputs.nixpkgs-2405.legacyPackages.${pkgs.system}.linkchecker ]; } '' mkdir "$out" diff --git a/nix/outputs.nix b/nix/outputs.nix index 8a5975d5cca..ad7ce69ddc1 100644 --- a/nix/outputs.nix +++ b/nix/outputs.nix @@ -30,7 +30,7 @@ let { inherit self build-latex-doc; }; metatheory-site = import ./metatheory-site.nix - { inherit self pkgs lib agda-with-stdlib; }; + { inherit inputs self pkgs lib agda-with-stdlib; }; project = import ./project.nix { inherit inputs pkgs lib agda-with-stdlib r-with-packages; }; diff --git a/nix/shell.nix b/nix/shell.nix index db8e9946f14..4e5c2d0f113 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -70,6 +70,7 @@ let common-pkgs = [ agda-with-stdlib r-with-packages + inputs.nixpkgs-2405.legacyPackages.${pkgs.system}.linkchecker pkgs.texliveFull pkgs.jekyll @@ -93,7 +94,7 @@ let pkgs.git pkgs.which pkgs.nodejs_20 - pkgs.linkchecker + ]; in From c7bff8cab487cf7d9403ce82b4f786ca4f48c039 Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 16 Jan 2025 20:24:34 +0100 Subject: [PATCH 06/14] wip --- nix/outputs.nix | 4 ---- nix/project.nix | 5 ----- 2 files changed, 9 deletions(-) diff --git a/nix/outputs.nix b/nix/outputs.nix index ad7ce69ddc1..fad48f5c7da 100644 --- a/nix/outputs.nix +++ b/nix/outputs.nix @@ -134,7 +134,3 @@ in inherit checks; inherit hydraJobs; } -# hydraJobs.ghc910.roots = ghc910.hydraJobs.roots; -# hydraJobs.ghc910.plan-nix = ghc910.hydraJobs.plan-nix; -# }) -# ] diff --git a/nix/project.nix b/nix/project.nix index 949b6ce48b7..e1d767078d6 100644 --- a/nix/project.nix +++ b/nix/project.nix @@ -122,10 +122,5 @@ let ]; }); - # project = lib.iogx.mkHaskellProject { - # inherit cabalProject; - # shellArgs = repoRoot.nix.shell; - # }; - in cabalProject From b7b6f0e0a7226ace3585b66396860730183a4a3c Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 16 Jan 2025 20:26:55 +0100 Subject: [PATCH 07/14] wip --- nix/outputs.nix | 2 ++ nix/shell.nix | 1 + 2 files changed, 3 insertions(+) diff --git a/nix/outputs.nix b/nix/outputs.nix index fad48f5c7da..b68fca921f4 100644 --- a/nix/outputs.nix +++ b/nix/outputs.nix @@ -100,6 +100,8 @@ let "aarch64-darwin" = (project-variants-roots-and-plan-nix) // { devShells.default = shell; }; + "aarch64-linux" = + { }; }; flattened-ci-jobs = utils.flattenDerivationTree ":" nested-ci-jobs; diff --git a/nix/shell.nix b/nix/shell.nix index 4e5c2d0f113..0a49de6f73a 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -71,6 +71,7 @@ let agda-with-stdlib r-with-packages inputs.nixpkgs-2405.legacyPackages.${pkgs.system}.linkchecker + haskell-language-server pkgs.texliveFull pkgs.jekyll From e20dd866289966219126ef7475eac991ef73f099 Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 16 Jan 2025 20:48:10 +0100 Subject: [PATCH 08/14] wip --- garnix.yaml | 5 +++++ nix/outputs.nix | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 garnix.yaml diff --git a/garnix.yaml b/garnix.yaml new file mode 100644 index 00000000000..c36133d5b4e --- /dev/null +++ b/garnix.yaml @@ -0,0 +1,5 @@ +builds: + # TODO once we have fully migrated from hydra to garnix, refactor nix/output.nix + # by removing all references to hydraJobs and populating this `include` section. + include: + - 'checks.*.*' \ No newline at end of file diff --git a/nix/outputs.nix b/nix/outputs.nix index b68fca921f4..ec39de3719e 100644 --- a/nix/outputs.nix +++ b/nix/outputs.nix @@ -39,7 +39,7 @@ let { inherit inputs pkgs lib project agda-with-stdlib r-with-packages; }; profiled-shell = import ./shell.nix { - inherit pkgs agda-with-stdlib r-with-packages; + inherit inputs pkgs agda-with-stdlib r-with-packages; project = project.flake'.variants.profiled; }; From 07882e5c1478b61dbdebf32ac486aafc965a73f5 Mon Sep 17 00:00:00 2001 From: zeme Date: Fri, 17 Jan 2025 08:14:25 +0100 Subject: [PATCH 09/14] wip --- nix/outputs.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nix/outputs.nix b/nix/outputs.nix index ec39de3719e..906d6fd8ee4 100644 --- a/nix/outputs.nix +++ b/nix/outputs.nix @@ -97,11 +97,11 @@ let "x86_64-darwin" = (project-variants-hydra-jobs) // { devShells.default = shell; }; + "aarch64-linux" = + { }; "aarch64-darwin" = (project-variants-roots-and-plan-nix) // { devShells.default = shell; }; - "aarch64-linux" = - { }; }; flattened-ci-jobs = utils.flattenDerivationTree ":" nested-ci-jobs; From 660e6e77b67f79f299f34cc8ff06a1fb419088cb Mon Sep 17 00:00:00 2001 From: zeme Date: Sun, 19 Jan 2025 00:56:16 +0100 Subject: [PATCH 10/14] wip --- nix/shell.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/nix/shell.nix b/nix/shell.nix index 0a49de6f73a..feecc5c51c5 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -95,7 +95,6 @@ let pkgs.git pkgs.which pkgs.nodejs_20 - ]; in From e30f25094faa35ce1eb3510ddcd152f4da3f2db6 Mon Sep 17 00:00:00 2001 From: zeme Date: Wed, 29 Jan 2025 15:08:57 +0100 Subject: [PATCH 11/14] wip --- nix/project.nix | 8 ++++---- nix/shell.nix | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/nix/project.nix b/nix/project.nix index e1d767078d6..c6df7d6aaa8 100644 --- a/nix/project.nix +++ b/nix/project.nix @@ -7,7 +7,7 @@ let # We need the mkDefault here since compiler-nix-name will be overridden # in the flake variants. - compiler-nix-name = "ghc96"; + compiler-nix-name = lib.mkDefault "ghc96"; src = ../.; @@ -17,9 +17,9 @@ let enableProfiling = true; enableLibraryProfiling = true; }]; - ghc810.compiler-nix-name = lib.mkForce "ghc810"; - ghc98.compiler-nix-name = lib.mkForce "ghc98"; - ghc910.compiler-nix-name = lib.mkForce "ghc910"; + ghc810.compiler-nix-name = "ghc810"; + ghc98.compiler-nix-name = "ghc98"; + ghc910.compiler-nix-name = "ghc910"; }; inputMap = { "https://chap.intersectmbo.org/" = inputs.CHaP; }; diff --git a/nix/shell.nix b/nix/shell.nix index feecc5c51c5..4b26037e005 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -49,7 +49,6 @@ let shellcheck = { enable = false; package = pkgs.shellcheck; - args = [ "--hint" ".hlint.yaml" ]; }; prettier = { enable = false; From 4ca269a4558022ae8aea062feec46320917c2b84 Mon Sep 17 00:00:00 2001 From: zeme Date: Wed, 29 Jan 2025 15:36:18 +0100 Subject: [PATCH 12/14] Done --- nix/shell.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nix/shell.nix b/nix/shell.nix index 4b26037e005..f2a9b20abbf 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -3,7 +3,7 @@ let haskell-tools = project.tools { - cabal = "latest"; + cabal = "3.12.1.0"; # TODO 3.14.1.1 breaks haddock, update when fixed hlint = "latest"; haskell-language-server = "latest"; } // { @@ -71,6 +71,11 @@ let r-with-packages inputs.nixpkgs-2405.legacyPackages.${pkgs.system}.linkchecker haskell-language-server + stylish-haskell + fourmolu + cabal + hlint + cabal-fmt pkgs.texliveFull pkgs.jekyll @@ -111,5 +116,6 @@ project.shellFor { shellHook = '' eval "$(starship init bash)" ${pre-commit-check.shellHook} + echo -e "\nšŸ¤Ÿ Welcome to Plutus šŸ¤Ÿ" ''; } From 40aee8c45314b50daca285b53684d0f064a8b658 Mon Sep 17 00:00:00 2001 From: zeme Date: Wed, 29 Jan 2025 18:44:30 +0100 Subject: [PATCH 13/14] wip --- .github/workflows/metatheory-site.yml | 2 +- .github/workflows/papers-and-specs.yml | 2 +- nix/outputs.nix | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/metatheory-site.yml b/.github/workflows/metatheory-site.yml index ec2e00e8636..18d8bcfb31b 100644 --- a/.github/workflows/metatheory-site.yml +++ b/.github/workflows/metatheory-site.yml @@ -66,7 +66,7 @@ jobs: - name: Build Site run: | - nix build --accept-flake-config .#plutus-metatheory-site + nix build --accept-flake-config .#metatheory-site mkdir _metatheory cp -RL result/* _metatheory diff --git a/.github/workflows/papers-and-specs.yml b/.github/workflows/papers-and-specs.yml index 3a4c5aa7cdd..c1a3f5c7ff3 100644 --- a/.github/workflows/papers-and-specs.yml +++ b/.github/workflows/papers-and-specs.yml @@ -37,7 +37,7 @@ jobs: ) mkdir -p _resources for target in "${TARGETS[@]}"; do - nix build --no-warn-dirty --accept-flake-config .#latex-documents.x86_64-linux.${target} + nix build --no-warn-dirty --accept-flake-config .#${target} cp -fr ./result/*.pdf _resources/${target}.pdf done diff --git a/nix/outputs.nix b/nix/outputs.nix index 906d6fd8ee4..05c3867067d 100644 --- a/nix/outputs.nix +++ b/nix/outputs.nix @@ -43,10 +43,11 @@ let project = project.flake'.variants.profiled; }; - common-haskell-packages = { + exposed-haskell-packages = { plutus-core-test = project.flake'.packages."plutus-core:test:plutus-core-test"; plutus-ir-test = project.flake'.packages."plutus-core:test:plutus-ir-test"; cardano-constitution-test = project.flake'.packages."cardano-constitution:test:cardano-constitution-test"; # editorconfig-checker-disable-line + cost-model-budgeting-bench = project.flake'.packages."plutus-core:exe:cost-model-budgeting-bench"; # editorconfig-checker-disable-line }; static-haskell-packages = { @@ -80,7 +81,7 @@ let }; packages = - common-haskell-packages // + exposed-haskell-packages // static-haskell-packages // extra-artifacts; @@ -121,7 +122,7 @@ let inherit build-latex; inherit extra-artifacts; inherit static-haskell-packages; - inherit common-haskell-packages; + inherit exposed-haskell-packages; inherit flattened-ci-jobs; inherit nested-ci-jobs; }; From e118605189f2186b2218d2489ef26d1131a8f1fd Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 30 Jan 2025 15:29:49 +0100 Subject: [PATCH 14/14] wip --- nix/shell.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/shell.nix b/nix/shell.nix index f2a9b20abbf..48234e14dab 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -3,7 +3,7 @@ let haskell-tools = project.tools { - cabal = "3.12.1.0"; # TODO 3.14.1.1 breaks haddock, update when fixed + cabal = "latest"; hlint = "latest"; haskell-language-server = "latest"; } // {