From 9366f27ffe8646e3bbab5405f9950c8e77b34617 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Giraudeau Date: Tue, 30 May 2023 10:39:00 +0200 Subject: [PATCH] Migrate to nix flake --- .github/workflows/bench.yml | 2 +- .github/workflows/gh-pages.yml | 3 +- .github/workflows/haskell.yml | 6 +- .github/workflows/push-specs.yml | 3 +- CONTRIBUTING.md | 48 +- HowToProfileLedger.md | 37 +- README.md | 18 +- cabal.project | 2 +- default.nix | 92 +-- doc/README.md | 17 +- doc/default.nix | 17 - doc/flake.nix | 27 + docs/non-integer-calculations/default.nix | 41 - docs/non-integer-calculations/flake.nix | 64 ++ docs/pool-ranking/default.nix | 44 -- docs/pool-ranking/flake.nix | 66 ++ docs/small-step-semantics/default.nix | 40 - docs/small-step-semantics/flake.nix | 60 ++ eras/alonzo/formal-spec/default.nix | 24 - eras/alonzo/formal-spec/flake.nix | 30 + eras/babbage/formal-spec/default.nix | 24 - eras/babbage/formal-spec/flake.nix | 30 + eras/byron/README.md | 32 +- eras/byron/cddl-spec/README.md | 2 +- eras/byron/cddl-spec/default.nix | 37 - eras/byron/cddl-spec/flake.nix | 49 ++ eras/byron/chain/executable-spec/default.nix | 4 - eras/byron/chain/executable-spec/flake.nix | 13 + .../chain/formal-spec/byron-blockchain.tex | 2 +- eras/byron/chain/formal-spec/default.nix | 38 - eras/byron/chain/formal-spec/flake.nix | 59 ++ eras/byron/ledger/executable-spec/default.nix | 4 - eras/byron/ledger/executable-spec/flake.nix | 13 + eras/byron/ledger/formal-spec/default.nix | 40 - eras/byron/ledger/formal-spec/flake.nix | 60 ++ eras/shelley-ma/formal-spec/default.nix | 24 - eras/shelley-ma/formal-spec/flake.nix | 30 + eras/shelley/design-spec/default.nix | 45 -- eras/shelley/design-spec/flake.nix | 56 ++ eras/shelley/formal-spec/default.nix | 44 -- eras/shelley/formal-spec/flake.nix | 66 ++ flake.lock | 724 +++++++++++++++++- flake.nix | 330 +++++++- libs/cardano-data/default.nix | 4 - libs/cardano-data/flake.nix | 14 + libs/cardano-ledger-binary/default.nix | 4 - libs/cardano-ledger-binary/flake.nix | 14 + .../cardano-ledger-test/benchProperty/Main.hs | 4 +- libs/set-algebra/default.nix | 4 - libs/set-algebra/flake.nix | 13 + libs/small-steps/default.nix | 4 - libs/small-steps/flake.nix | 12 + nix/cardano-mainnet-mirror.nix | 7 - nix/default.nix | 56 -- nix/flake-compat.nix | 11 + nix/haskell.nix | 74 -- nix/latex.nix | 94 +-- nix/pkgs.nix | 14 +- nix/pkgs/cbor-diag/Gemfile | 2 - nix/pkgs/cbor-diag/Gemfile.lock | 27 - nix/pkgs/cbor-diag/default.nix | 19 - nix/pkgs/cbor-diag/gemset.nix | 84 -- nix/pkgs/cddl/default.nix | 9 +- nix/python/sphinx-markdown-tables.nix | 22 - nix/python/sphinxemoji.nix | 22 - nix/sources.json | 65 -- nix/sources.nix | 149 ---- nix/stack-shell.nix | 18 - nix/tullia.nix | 78 -- nix/util.nix | 12 - release.nix | 90 --- scripts/haskell-language-server | 3 +- scripts/stack-cabal_config_check.sh | 34 - shell.nix | 90 +-- 74 files changed, 1820 insertions(+), 1600 deletions(-) delete mode 100644 doc/default.nix create mode 100644 doc/flake.nix delete mode 100644 docs/non-integer-calculations/default.nix create mode 100644 docs/non-integer-calculations/flake.nix delete mode 100644 docs/pool-ranking/default.nix create mode 100644 docs/pool-ranking/flake.nix delete mode 100644 docs/small-step-semantics/default.nix create mode 100644 docs/small-step-semantics/flake.nix delete mode 100644 eras/alonzo/formal-spec/default.nix create mode 100644 eras/alonzo/formal-spec/flake.nix delete mode 100644 eras/babbage/formal-spec/default.nix create mode 100644 eras/babbage/formal-spec/flake.nix delete mode 100644 eras/byron/cddl-spec/default.nix create mode 100644 eras/byron/cddl-spec/flake.nix delete mode 100644 eras/byron/chain/executable-spec/default.nix create mode 100644 eras/byron/chain/executable-spec/flake.nix delete mode 100644 eras/byron/chain/formal-spec/default.nix create mode 100644 eras/byron/chain/formal-spec/flake.nix delete mode 100644 eras/byron/ledger/executable-spec/default.nix create mode 100644 eras/byron/ledger/executable-spec/flake.nix delete mode 100644 eras/byron/ledger/formal-spec/default.nix create mode 100644 eras/byron/ledger/formal-spec/flake.nix delete mode 100644 eras/shelley-ma/formal-spec/default.nix create mode 100644 eras/shelley-ma/formal-spec/flake.nix delete mode 100644 eras/shelley/design-spec/default.nix create mode 100644 eras/shelley/design-spec/flake.nix delete mode 100644 eras/shelley/formal-spec/default.nix create mode 100644 eras/shelley/formal-spec/flake.nix delete mode 100644 libs/cardano-data/default.nix create mode 100644 libs/cardano-data/flake.nix delete mode 100644 libs/cardano-ledger-binary/default.nix create mode 100644 libs/cardano-ledger-binary/flake.nix delete mode 100644 libs/set-algebra/default.nix create mode 100644 libs/set-algebra/flake.nix delete mode 100644 libs/small-steps/default.nix create mode 100644 libs/small-steps/flake.nix delete mode 100644 nix/cardano-mainnet-mirror.nix delete mode 100644 nix/default.nix create mode 100644 nix/flake-compat.nix delete mode 100644 nix/haskell.nix delete mode 100644 nix/pkgs/cbor-diag/Gemfile delete mode 100644 nix/pkgs/cbor-diag/Gemfile.lock delete mode 100644 nix/pkgs/cbor-diag/default.nix delete mode 100644 nix/pkgs/cbor-diag/gemset.nix delete mode 100644 nix/python/sphinx-markdown-tables.nix delete mode 100644 nix/python/sphinxemoji.nix delete mode 100644 nix/sources.json delete mode 100644 nix/sources.nix delete mode 100644 nix/stack-shell.nix delete mode 100644 nix/tullia.nix delete mode 100644 nix/util.nix delete mode 100644 release.nix delete mode 100755 scripts/stack-cabal_config_check.sh diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 1dbbd8af88f..b23b7e9d737 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -22,7 +22,7 @@ jobs: trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= loony-tools:pr9m4BkM/5/eSTZlkQyRt57Jz7OMBxNSUiMC4FkcNfk= substituters = https://cache.iog.io https://cache.nixos.org/ https://cache.zw3rk.com - name: Build benchmarks - run: nix-build -A haskellPackages.cardano-ledger-test.components.benchmarks + run: nix build .#cardano-ledger-test:bench:bench - name: Run benchmark run: | cd libs/cardano-ledger-test diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 1a51cdaddb8..a39366a30d8 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -20,7 +20,7 @@ jobs: trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= loony-tools:pr9m4BkM/5/eSTZlkQyRt57Jz7OMBxNSUiMC4FkcNfk= substituters = https://cache.iog.io https://cache.nixos.org/ https://cache.zw3rk.com - name: Build projects and haddocks - run: nix-shell --command "cabal update && cabal build --enable-documentation all && ./scripts/haddocks.sh" + run: nix develop --command bash -c 'cabal update && cabal build --enable-documentation all && ./scripts/haddocks.sh' - name: Add files run: | git config --local user.name ${{ github.actor }} @@ -37,4 +37,3 @@ jobs: branch: gh-pages force: true directory: . - diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 97db2beb1c4..b2f52b28f17 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -198,7 +198,7 @@ jobs: run: ./scripts/gen-hie.sh nix-build: - name: Build nix derivations and enter nix-shell + name: Build nix required derivations if: ${{ github.event_name == 'schedule' }} runs-on: ubuntu-latest steps: @@ -210,6 +210,4 @@ jobs: trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= loony-tools:pr9m4BkM/5/eSTZlkQyRt57Jz7OMBxNSUiMC4FkcNfk= substituters = https://cache.iog.io https://cache.nixos.org/ https://cache.zw3rk.com - name: nix-build - run: nix-build - - name: nix-shell - run: nix-shell shell.nix + run: nix build .#hydraJobs.required diff --git a/.github/workflows/push-specs.yml b/.github/workflows/push-specs.yml index e1cfb3d3816..68374484091 100644 --- a/.github/workflows/push-specs.yml +++ b/.github/workflows/push-specs.yml @@ -20,7 +20,7 @@ jobs: trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= substituters = https://cache.iog.io https://cache.nixos.org/ - name: Build specs - run: nix-build -A specs -o output/spec + run: nix build .#specs -o output/spec - name: Collect dereferenced docs run: | mkdir -p deref @@ -32,4 +32,3 @@ jobs: uses: ncipollo/release-action@v1 with: artifacts: "deref/*" - diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 503881fbd64..decad830f08 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,10 +38,11 @@ We are transitioning to use GHC 9.2 rather than GHC 8.10. We need to retain 8.10 compatibility until we are sure that the Cardano node can switch over to 9.2 without any problems. At that point we can drop it. -The main `nix-shell` will now give you a GHC 9.2 compiler, but you can get a GHC 8.10 shell by calling +The main `nix develop` shell will now give you a GHC 9.2 compiler, but you can get a GHC 8.10 shell by calling ``` -nix-shell --arg config '{ haskellNix.compiler = "ghc8107"; }' +nix develop .#ghc8107 ``` +(this pattern can also be used to test any supported GHC version) ## Updating dependencies @@ -58,10 +59,10 @@ That typically just means that we need to fix the breakage (and add a lower-boun Note that `cabal` itself keeps track of what index states it knows about, so when you bump the pinned index state you may need call `cabal update` in order for `cabal` to be happy. The Nix code which builds our packages also cares about the index state. -This is represented by inputs managed by `niv`: +This is represented by inputs managed by `nix flake`: You can update these by running: -- `niv update hackage.nix` for Hackage -- `niv update cardano-haskell-packages` for CHaP +- `nix flake lock --update-input haskellNix/hackage` for Hackage +- `nix flake lock --update-input CHaP` for CHaP (Cardano Haskell Packages) If you fail to do this you may get an error like this from Nix: ``` @@ -189,15 +190,15 @@ NIGHTLY=true cabal test cardano-ledger-shelley-test We have support for running [ghcid](https://github.com/ndmitchell/ghcid) -from inside of `nix-shell`. -Enter `nix-shell` from the base directory of the repository, +from inside of `nix develop`. +Enter `nix develop` from the base directory of the repository, change directories to the cabal package that you wish to check, then run `ghcid`. For example: ```shell -nix-shell +nix develop cd eras/shelley/impl/ ghcid ``` @@ -214,12 +215,12 @@ Error: cabal: Cannot open a repl for multiple components at once. The target '' Specifying the component solves this problem: ```shell -nix-shell +nix develop cd libs/cardano-ledger-binary/ ghcid testlib # or `ghcid cardano-ledger-binary` ``` -## nix-build Infrastructure +## nix build Infrastructure The artifacts in this repository can be built and tested using nix. This is additionally used by the Hydra CI to test building, including cross-compilation @@ -231,11 +232,11 @@ To add a new Haskell package, you should do the following: 1. Create the project in the usual way. It should have an appropriate `.cabal` file. 2. Test that you can build your new project by running the following: `nix build - -f default.nix libs.`. If you have executables, then - you may also try building these using the `exes.` - attribute path. A good way to see what's available is to execute `:l - default.nix` in `nix repl`. This will allow you to explore the potential - attribute names by using tab completion on "libs.". + .#:lib:`. If you have executables, then + you may also try building these using the `.#:exe:` + attribute path. A good way to see what's available is to execute `:lf .` + in `nix repl`. This will allow you to explore the potential + attribute names by using tab completion on "packages.". ### To add a new LaTeX specification @@ -246,16 +247,11 @@ from [the Shelley ledger spec](./eras/shelley/formal-spec)). 1. Copy these files into the root of your new LaTeX specification. 2. Modify the `DOCNAME` in the `Makefile`. 3. Update `default.nix` to: - 1. Make sure that the relative path in the first line is pointing to - (default.nix)[./default.nix]. This is used to pin the - `nixpkgs` version used to build the LaTeX specifications. - 2. Update the `buildInputs` to add in any LaTeX packages you need in your + 1. Update the `buildInputs` to add in any LaTeX packages you need in your document, and remove any unneeded ones. - 3. Alter the `meta` description field to reflect the nature of this document. -4. Add a link to the package at the bottom of [default.nix](./default.nix), + 2. Alter the `meta` description field to reflect the nature of this document. +4. Add a link to the package near the bottom of [flake.nix](./flake.nix), following the existing examples. -5. To require that your specification be built in CI, add it at the end of the - list in [default.nix](./default.nix) following the existing examples. ### Additional documentation @@ -357,11 +353,9 @@ cabal configure --enable-profiling --profiling-detail=all-functions ``` Now we need to run a node to build up the dataabase. -This can be done in the cardano-node repository by -opening a nix-shell and running: +This can be done in the cardano-node repository by running: ``` -nix build -f default.nix scripts.mainnet.node -./result/bin/cardano-node-mainnet +nix run .#mainnet/node ``` This will take a very long time. You can stop the node once it is past any slots that you care about. diff --git a/HowToProfileLedger.md b/HowToProfileLedger.md index 939dbef4fdb..790eb7dc7a1 100644 --- a/HowToProfileLedger.md +++ b/HowToProfileLedger.md @@ -23,8 +23,8 @@ greater detail about each step 1. Decide what you want to profile, and arrange the code so this is possible 2. Choreograph the dance between nix, cabal, and ghc. This has two parts - a. Adding stuff to files like cabal.project, cabal.project.local, and nix/haskel.nix - b. Passing the right flags to nix-shell, cabal, and ghc + a. Adding stuff to files like cabal.project, cabal.project.local + b. Passing the right flags to cabal, and ghc, running the right `nix develop` shell, 3. Recompiling everything so it can be profiled. This takes a very long time (greater than 30 minutes when I did it) 4. Start up the profiling. I used "cabal test" with just the right command line arguments. @@ -103,53 +103,55 @@ package plutus-core --------------------- Supposedly this makes things work. But I could never get the nix-shell to complete with this approach. -To get that to happen I had to add the following line to the modules section of the nix/haskell.nix file +To get that to happen I had to add the following line to the modules section of the flake.nix file ----------------------------- packages.plutus-core.components.library.ghcOptions = [ "-fexternal-interpreter" ]; ----------------------------- There are probaly more that a dozen lines just like this, so it is easy to figure out where to put it. -The final step is to pass the right flags to nix-shell, cabal, and ghc. Here is a summary. +The final step is to pass the right flags to cabal, ghc, and running the right `nix develop` shell. Here is a summary. 1) to start nix, we must use - nix-shell --arg config "{ haskellNix.profiling = true; }" + `nix develop .#profiling` 2) to build with cabal, we must use - cabal build --enable-profiling + `cabal build --enable-profiling` 3) to run the test, we must pass extra flags to ghc, so we must use - cabal test --test-options="+RTS -i60 -p" + `cabal test --test-options="+RTS -i60 -p"` How to build the system for profiling Be sure you have set up the files cabal.project.local and nix/haskell.nix as described above. -Exit the nix-shell, if you are running it. Now change directories to the root of the Ledger repository. +Exit the nix shell, if you are running it. Now change directories to the root of the Ledger repository. Now to start nix type +``` +nix develop .#profiling +``` +(or, eg. `nix develop .#ghc8107.profiling` for alternative compiler) -nix-shell --arg config "{ haskellNix.profiling = true; }" - -When the nix-shell completes (this can take a long time, since it must make sure +When the `nix develop` shell completes (this can take a long time, since it must make sure every file in the Ledger is compiled with profiling enabled). This might take a while. Be patient. Take the dogs for a walk. Now change directories to the root directory of the modlue that contains your modified Test file, and type - +``` cabal build --enable-profiling - +``` This might also take a while. Take the dogs for second walk. When this completes you are ready to start profiing! How to run a profile. In the same directory where you did (cabal build --enable-profiling) type - +``` cabal test --test-options="+RTS -i60 -p" - +``` This should take slightly longer than running the test without profiling. When it is done, there will be a file in this same directory with extension .prof When I did it, the file was called cardano-ledger-test.prof . It is a big file Here are the first few lines. - +``` ---------------------------------------------------------------------------------------------------------- Fri May 6 14:02 2022 Time and Allocation Profiling Report (Final) @@ -177,11 +179,10 @@ genKeyHash.\ Test.Cardano.Ledger.Generic.GenState src/Test/Cardano serializeEncoding Cardano.Binary.Serialize src/Cardano/Binary/Serialize.hs:(61,1)-(67,49) 0.8 2.1 toLazyByteString Codec.CBOR.Write src/Codec/CBOR/Write.hs:86:1-49 0.7 4.9 --------------------------------------------------------------------------------------------------------------------- +``` The problem with my test, was that evalScripts was inadvertantly showing a large data structure using tellEvent. This was added when debugging and never removed. After fixing this, we had much better results. I hope you experience is just as rewarding. Don't forget to revert cabal.project.local, nix/haskell.nix and your Test file to their original state. - - diff --git a/README.md b/README.md index 76c61b600a3..eef042b362b 100644 --- a/README.md +++ b/README.md @@ -106,17 +106,17 @@ When using `nix` the documents and Haskell code can be readily built by running: ```shell -nix-build +nix build .#specs ``` -The LaTeX documents will be placed inside directories named `result*`, e.g.: +The LaTeX documents will be placed inside a directory named `result`, e.g.: ```shell -result-2/byron-ledger.pdf -result-3/shelley-delegation.pdf -result-4/non-integer-calculations.pdf -result-5/small-step-semantics.pdf -result-6/shelley-ledger.pdf +result/byron-ledger.pdf +result/shelley-delegation.pdf +result/non-integer-calculations.pdf +result/small-step-semantics.pdf +result/shelley-ledger.pdf result/byron-blockchain.pdf ``` @@ -131,14 +131,14 @@ the Byron release). Then, build the latex document by running: ```shell cd -nix-shell --pure --run make +nix develop --command make ``` For a continuous compilation of the `LaTeX` file run: ```shell cd -nix-shell --pure --run "make watch" +nix develop --command make watch ``` # Testing diff --git a/cabal.project b/cabal.project index 479a1e3a173..80afa523983 100644 --- a/cabal.project +++ b/cabal.project @@ -12,7 +12,7 @@ repository cardano-haskell-packages -- See CONTRIBUTING for some Nix commands you will need to run if you -- update either of these. -index-state: 2023-05-25T00:00:00Z +index-state: 2023-06-25T00:00:00Z index-state: -- Bump this if you need newer packages from Hackage , hackage.haskell.org 2023-06-01T19:11:19Z diff --git a/default.nix b/default.nix index e77540d8e84..cf1c0655e4f 100644 --- a/default.nix +++ b/default.nix @@ -1,82 +1,10 @@ -{ system ? builtins.currentSystem -, crossSystem ? null -# allows to cutomize haskellNix (ghc and profiling, see ./nix/haskell.nix) -, config ? {} -# allows to override dependencies of the project without modifications, -# eg. to test build against local checkout of iohk-nix: -# nix build -f default.nix cardano-node --arg sourcesOverride '{ -# iohk-nix = ../iohk-nix; -# }' -, sourcesOverride ? {} -# pinned version of nixpkgs augmented with overlays (iohk-nix and our packages). -, pkgs ? import ./nix { inherit system crossSystem config sourcesOverride; } -, gitrev ? pkgs.iohkNix.commitIdFromGitRepoOrZero ./.git -}: -with pkgs; with commonLib; - -let - haskellPackages = recRecurseIntoAttrs - # we are only interested in listing the project packages: - (selectProjectPackages cardanoLedgerSpecsHaskellPackages); - - self = { - inherit haskellPackages hydraEvalErrors; - - # `tests` are the test suites which have been built. - tests = collectComponents' "tests" haskellPackages; - # `benchmarks` (only built, not run). - benchmarks = collectComponents' "benchmarks" haskellPackages; - - libs = collectComponents' "library" haskellPackages; - - exes = collectComponents' "exes" haskellPackages; - - checks = recurseIntoAttrs { - # `checks.tests` collect results of executing the tests: - tests = collectChecks' haskellPackages; - }; - - shell = import ./shell.nix { - inherit pkgs; - withHoogle = true; - }; - - roots = cardanoLedgerSpecsHaskellPackages.roots; - - # - # PDF builds of LaTeX documentation. - # - # To download the latest PDF build from Hydra, use this link: - # https://github.com/input-output-hk/cardano-ledger/releases/latest/download/NAME.pdf - # - # To get a shell where you can run pdflatex to build it yourself, use: - # nix-shell default.nix -A specs.NAME - # - # To build all specs locally with Nix: - # nix-build -A specs -o spec - # - specs = recurseIntoAttrs { - byron-ledger = pkgs.callPackage ./eras/byron/ledger/formal-spec/default.nix {}; - byron-chain = pkgs.callPackage ./eras/byron/chain/formal-spec/default.nix {}; - shelley-ledger = pkgs.callPackage ./eras/shelley/formal-spec/default.nix {}; - shelley-ma = pkgs.callPackage ./eras/shelley-ma/formal-spec/default.nix {}; - alonzo-ledger = pkgs.callPackage ./eras/alonzo/formal-spec/default.nix {}; - babbage-ledger = pkgs.callPackage ./eras/babbage/formal-spec/default.nix {}; - delegation-design = pkgs.callPackage ./eras/shelley/design-spec/default.nix {}; - small-step-semantics = pkgs.callPackage ./docs/small-step-semantics/default.nix {}; - pool-ranking = pkgs.callPackage ./docs/pool-ranking/default.nix {}; - non-integer-calculations = pkgs.callPackage ./docs/non-integer-calculations/default.nix {}; - blocks-cddl = pkgs.callPackage ./eras/byron/cddl-spec/default.nix {}; - }; - - doc = { - site = - let - sphinx-markdown-tables = pkgs.python3Packages.callPackage ./nix/python/sphinx-markdown-tables.nix {}; - sphinxemoji = pkgs.python3Packages.callPackage ./nix/python/sphinxemoji.nix {}; - in pkgs.callPackage ./doc { inherit sphinx-markdown-tables sphinxemoji; pythonPackages = pkgs.python3Packages; }; - }; - }; - -in - self +# a non-flake nix compat wrapper using https://github.com/edolstra/flake-compat +# DO NOT EDIT THIS FILE +__trace +'' ************************************************************************************ + Hi there! This project has been moved to nix flakes. You are using the default.nix + compatibility layer. Please consider using flake commands like `nix build .#...`, + `nix repl` with `:lf .` and similar instead. + ************************************************************************************ +'' +(import ./nix/flake-compat.nix).defaultNix diff --git a/doc/README.md b/doc/README.md index 358f52ab3c5..bca78cfbf92 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1,6 +1,6 @@ # Documentation site -This is a sphinx site. You can build it with sphinx from a `nix-shell`: +This is a sphinx site. You can build it with sphinx from a `nix develop` shell: ``` sphinx-build -n . _build @@ -9,7 +9,7 @@ sphinx-build -n . _build Or via nix at the top-level: ``` -nix build -f default.nix docs.site +nix build .#doc.site ``` [Read the Docs](https://cardano-ledger.readthedocs.io/en/latest) is building the site on every PR and publishing it on every merge. @@ -21,19 +21,10 @@ The direct dependencies are specified in `requirements.in`. This file is only us ### Regenerating `requirements.txt` * Update `requirements.in` as desired -* At the top level, enter a nix-shell that includes pip and install pip-tools: - * ``` - nix-shell -p python3Packages.pip - ``` - * ``` - python -m venv .venv && source .venv/bin/activate - ``` - * ``` - python -m pip install pip-tools - ``` +* In `doc`, enter a `nix develop` shell that includes pip-tools: * ``` cd doc + nix develop pip-compile requirements.in ``` This should have modified `requirements.txt` to reflect the changes from `requirements.in` and any necessary changes in transitive dependencies. - diff --git a/doc/default.nix b/doc/default.nix deleted file mode 100644 index f15f556cc83..00000000000 --- a/doc/default.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ stdenv, lib, pythonPackages, sphinx-markdown-tables, sphinxemoji, ... }: -stdenv.mkDerivation { - name = "ledger-docs"; - src = lib.sourceFilesBySuffices ./. [ ".py" ".rst" ".hs" ".png" ]; - buildInputs = with pythonPackages; [ - sphinx - sphinx_rtd_theme - sphinx-markdown-tables - sphinxemoji - recommonmark - ]; - buildPhase = '' - # -n gives warnings on missing link targets, -W makes warnings into errors - sphinx-build -n -W . $out - ''; - dontInstall = true; -} diff --git a/doc/flake.nix b/doc/flake.nix new file mode 100644 index 00000000000..c28787b665d --- /dev/null +++ b/doc/flake.nix @@ -0,0 +1,27 @@ +{ + outputs = inputs: { + packages = + builtins.mapAttrs (_: {nixpkgs, ...}: { + default = with nixpkgs; + stdenv.mkDerivation { + name = "ledger-docs"; + src = lib.sourceFilesBySuffices ./. [".py" ".rst" ".hs" ".png"]; + buildInputs = with python3Packages; [ + sphinx + sphinx_rtd_theme + sphinx-markdown-tables + sphinxemoji + recommonmark + # for regenerating requirements.txt + pip-tools + ]; + buildPhase = '' + # -n gives warnings on missing link targets, -W makes warnings into errors + sphinx-build -n -W . $out + ''; + dontInstall = true; + }; + }) + (inputs.main or (import ../nix/flake-compat.nix).defaultNix).legacyPackages; + }; +} diff --git a/docs/non-integer-calculations/default.nix b/docs/non-integer-calculations/default.nix deleted file mode 100644 index 804d39d2c58..00000000000 --- a/docs/non-integer-calculations/default.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ pkgs ? import ../../nix/default.nix {} }: - -with pkgs; - -latex.buildLatex { - name = "non-integer-calculations-spec"; - texFiles = [ "non-integer-calculations" ]; - meta = with lib; { - description = "Non-integer Calculations Specification"; - license = licenses.asl20; - platforms = platforms.linux; - }; - src = latex.filterLatex ./.; - - texInputs = { - inherit (texlive) - scheme-small - - # libraries - stmaryrd lm-math amsmath extarrows cleveref semantic xcolor appendix paralist cm-super - - # bclogo and dependencies - bclogo mdframed xkeyval etoolbox needspace pgf - - # font libraries `mathpazo` seems to depend on palatino - # , but it isn't pulled. - mathpazo palatino microtype - - # libraries for marginal notes - xargs todonotes - - # build tools - latexmk - - # Referencing - zref - - ; - }; - buildInputs = [ gitMinimal ]; -} diff --git a/docs/non-integer-calculations/flake.nix b/docs/non-integer-calculations/flake.nix new file mode 100644 index 00000000000..74afa8f7bd4 --- /dev/null +++ b/docs/non-integer-calculations/flake.nix @@ -0,0 +1,64 @@ +{ + outputs = inputs: { + packages = + builtins.mapAttrs (_: {nixpkgs, ...}: { + default = with nixpkgs; + buildLatex { + name = "non-integer-calculations-spec"; + texFiles = ["non-integer-calculations"]; + meta = with lib; { + description = "Non-integer Calculations Specification"; + license = licenses.asl20; + platforms = platforms.linux; + }; + src = filterLatex ./.; + + texInputs = { + inherit + (texlive) + scheme-small + # libraries + + stmaryrd + lm-math + amsmath + extarrows + cleveref + semantic + xcolor + appendix + paralist + cm-super + # bclogo and dependencies + + bclogo + mdframed + xkeyval + etoolbox + needspace + pgf + # font libraries `mathpazo` seems to depend on palatino + + # , but it isn't pulled. + + mathpazo + palatino + microtype + # libraries for marginal notes + + xargs + todonotes + # build tools + + latexmk + # Referencing + + zref + ; + }; + buildInputs = [gitMinimal]; + }; + }) + (inputs.main or (import ../../nix/flake-compat.nix).defaultNix).legacyPackages; + }; +} diff --git a/docs/pool-ranking/default.nix b/docs/pool-ranking/default.nix deleted file mode 100644 index 1d1ab903ac4..00000000000 --- a/docs/pool-ranking/default.nix +++ /dev/null @@ -1,44 +0,0 @@ -{ pkgs ? import ../../nix/default.nix {} }: - -with pkgs; - -latex.buildLatex { - name = "pool-ranking"; - texFiles = [ "pool-ranking" ]; - meta = with lib; { - description = "Stake Pool Ranking in Cardano"; - license = licenses.asl20; - platforms = platforms.linux; - }; - src = latex.filterLatex ./.; - - texInputs = { - inherit (texlive) - scheme-small - - # libraries - stmaryrd lm-math amsmath extarrows cleveref semantic xcolor xstring paralist cm-super tocloft - - # bclogo and dependencies - bclogo mdframed xkeyval etoolbox needspace - - # font libraries `mathpazo` seems to depend on palatino, but it isn't pulled. - mathpazo palatino microtype - - # libraries for marginal notes - xargs todonotes - - # Tikz - pgf tikz-cd - - # build tools - latexmk - - # Referencing - zref - - ; - - }; - buildInputs = [ gitMinimal ]; -} diff --git a/docs/pool-ranking/flake.nix b/docs/pool-ranking/flake.nix new file mode 100644 index 00000000000..61645fffb2d --- /dev/null +++ b/docs/pool-ranking/flake.nix @@ -0,0 +1,66 @@ +{ + outputs = inputs: { + packages = + builtins.mapAttrs (_: {nixpkgs, ...}: { + default = with nixpkgs; + buildLatex { + name = "pool-ranking"; + texFiles = ["pool-ranking"]; + meta = with lib; { + description = "Stake Pool Ranking in Cardano"; + license = licenses.asl20; + platforms = platforms.linux; + }; + src = filterLatex ./.; + + texInputs = { + inherit + (texlive) + scheme-small + # libraries + + stmaryrd + lm-math + amsmath + extarrows + cleveref + semantic + xcolor + xstring + paralist + cm-super + tocloft + # bclogo and dependencies + + bclogo + mdframed + xkeyval + etoolbox + needspace + # font libraries `mathpazo` seems to depend on palatino, but it isn't pulled. + + mathpazo + palatino + microtype + # libraries for marginal notes + + xargs + todonotes + # Tikz + + pgf + tikz-cd + # build tools + + latexmk + # Referencing + + zref + ; + }; + buildInputs = [gitMinimal]; + }; + }) + (inputs.main or (import ../../nix/flake-compat.nix).defaultNix).legacyPackages; + }; +} diff --git a/docs/small-step-semantics/default.nix b/docs/small-step-semantics/default.nix deleted file mode 100644 index 7a0a24a21c0..00000000000 --- a/docs/small-step-semantics/default.nix +++ /dev/null @@ -1,40 +0,0 @@ -{ pkgs ? import ../../nix/default.nix {} }: - -with pkgs; - -latex.buildLatex { - name = "small-step-semantics-spec"; - texFiles = [ "small-step-semantics" ]; - meta = with lib; { - description = "Small Step Semantics Specification"; - license = licenses.asl20; - platforms = platforms.linux; - }; - src = latex.filterLatex ./.; - - texInputs = { - inherit (texlive) - scheme-small - - # libraries - stmaryrd lm-math amsmath extarrows cleveref semantic tikz-cd xcolor - - # bclogo and dependencies - bclogo mdframed xkeyval etoolbox needspace pgf - - # font libraries `mathpazo` seems to depend on palatino, but it isn't pulled. - mathpazo palatino microtype - - # libraries for marginal notes - xargs todonotes - - # build tools - latexmk - - # Referencing - zref - ; - - }; - buildInputs = [ gitMinimal ]; -} diff --git a/docs/small-step-semantics/flake.nix b/docs/small-step-semantics/flake.nix new file mode 100644 index 00000000000..5ab8e8fa928 --- /dev/null +++ b/docs/small-step-semantics/flake.nix @@ -0,0 +1,60 @@ +{ + outputs = inputs: { + packages = + builtins.mapAttrs (_: {nixpkgs, ...}: { + default = with nixpkgs; + buildLatex { + name = "small-step-semantics-spec"; + texFiles = ["small-step-semantics"]; + meta = with lib; { + description = "Small Step Semantics Specification"; + license = licenses.asl20; + platforms = platforms.linux; + }; + src = filterLatex ./.; + + texInputs = { + inherit + (texlive) + scheme-small + # libraries + + stmaryrd + lm-math + amsmath + extarrows + cleveref + semantic + tikz-cd + xcolor + # bclogo and dependencies + + bclogo + mdframed + xkeyval + etoolbox + needspace + pgf + # font libraries `mathpazo` seems to depend on palatino, but it isn't pulled. + + mathpazo + palatino + microtype + # libraries for marginal notes + + xargs + todonotes + # build tools + + latexmk + # Referencing + + zref + ; + }; + buildInputs = [gitMinimal]; + }; + }) + (inputs.main or (import ../../nix/flake-compat.nix).defaultNix).legacyPackages; + }; +} diff --git a/eras/alonzo/formal-spec/default.nix b/eras/alonzo/formal-spec/default.nix deleted file mode 100644 index 54fc2a0ee7a..00000000000 --- a/eras/alonzo/formal-spec/default.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ pkgs ? import ../../../nix/default.nix {} }: - -with pkgs; - -latex.buildLatex { - name = "alonzo-spec"; - texFiles = [ "alonzo-ledger" ]; - meta = with lib; { - description = "Goguen ledger specification"; - license = licenses.asl20; - platforms = platforms.linux; - }; - src = latex.filterLatex ./.; - - texInputs = { - inherit (texlive) - scheme-small - collection-latexextra - collection-latexrecommended - collection-mathscience - bclogo - ; - }; -} diff --git a/eras/alonzo/formal-spec/flake.nix b/eras/alonzo/formal-spec/flake.nix new file mode 100644 index 00000000000..7199d424773 --- /dev/null +++ b/eras/alonzo/formal-spec/flake.nix @@ -0,0 +1,30 @@ +{ + outputs = inputs: { + packages = + builtins.mapAttrs (_: {nixpkgs, ...}: { + default = with nixpkgs; + buildLatex { + name = "alonzo-spec"; + texFiles = ["alonzo-ledger"]; + meta = with lib; { + description = "Goguen ledger specification"; + license = licenses.asl20; + platforms = platforms.linux; + }; + src = filterLatex ./.; + + texInputs = { + inherit + (texlive) + scheme-small + collection-latexextra + collection-latexrecommended + collection-mathscience + bclogo + ; + }; + }; + }) + (inputs.main or (import ../../../nix/flake-compat.nix).defaultNix).legacyPackages; + }; +} diff --git a/eras/babbage/formal-spec/default.nix b/eras/babbage/formal-spec/default.nix deleted file mode 100644 index ba0be2d7470..00000000000 --- a/eras/babbage/formal-spec/default.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ pkgs ? import ../../../nix/default.nix {} }: - -with pkgs; - -latex.buildLatex { - name = "babbage-spec"; - texFiles = [ "babbage-ledger" ]; - meta = with lib; { - description = "Babbage ledger specification"; - license = licenses.asl20; - platforms = platforms.linux; - }; - src = latex.filterLatex ./.; - - texInputs = { - inherit (texlive) - scheme-small - collection-latexextra - collection-latexrecommended - collection-mathscience - bclogo - ; - }; -} diff --git a/eras/babbage/formal-spec/flake.nix b/eras/babbage/formal-spec/flake.nix new file mode 100644 index 00000000000..3a443fac963 --- /dev/null +++ b/eras/babbage/formal-spec/flake.nix @@ -0,0 +1,30 @@ +{ + outputs = inputs: { + packages = + builtins.mapAttrs (_: {nixpkgs, ...}: { + default = with nixpkgs; + buildLatex { + name = "babbage-spec"; + texFiles = ["babbage-ledger"]; + meta = with lib; { + description = "Babbage ledger specification"; + license = licenses.asl20; + platforms = platforms.linux; + }; + src = filterLatex ./.; + + texInputs = { + inherit + (texlive) + scheme-small + collection-latexextra + collection-latexrecommended + collection-mathscience + bclogo + ; + }; + }; + }) + (inputs.main or (import ../../../nix/flake-compat.nix).defaultNix).legacyPackages; + }; +} diff --git a/eras/byron/README.md b/eras/byron/README.md index b437cf57eeb..3f5f15ef7f4 100644 --- a/eras/byron/README.md +++ b/eras/byron/README.md @@ -16,13 +16,13 @@ This directory is organized as follows: To build the `LaTeX` document run: ```shell -nix-shell --pure --run make +nix develop --command make ``` For a continuous compilation of the `LaTeX` file run: ```shell -nix-shell --pure --run "make watch" +nix develop --command make watch ``` ## Building the executable specification @@ -34,44 +34,32 @@ To build to go to the directory in which the executable specifications are (e.g. [`ledger/executable-spec`](ledger/executable-spec)) and then run: ```sh -nix-build +nix build ``` -To start a REPL first make sure to run the configure script: - -```sh -nix-shell --pure --run "runhaskell Setup.hs configure" -``` - -then run: - -```sh -nix-shell --pure --run "runhaskell Setup.hs repl" -``` - -To test run: - +To build, or run, tests: ```sh -nix-shell --pure --run "runhaskell Setup.hs test" +nix build .#tests +nix run .#tests ``` ### Development -For running the tests you can use: +For running the tests you can use, in a `nix develop` shell: ```sh -nix-shell --pure --command "cabal new-test " +cabal new-test ``` Example, while in the `byron/ledger/executable-spec` directory one can run: ```sh -nix-shell --pure --run "cabal new-test ledger-delegation-test" +cabal new-test ledger-delegation-test ``` To have the warnings not being treated as errors the `-Wwarn` ghc flag can be used to negate the effect of `-Werror`, e.g.: ```sh -nix-shell --pure --run "cabal new-test ledger-delegation-test --ghc-options='-Wwarn'" +cabal new-test ledger-delegation-test --ghc-options='-Wwarn' ``` diff --git a/eras/byron/cddl-spec/README.md b/eras/byron/cddl-spec/README.md index 4811560010b..11c94828919 100644 --- a/eras/byron/cddl-spec/README.md +++ b/eras/byron/cddl-spec/README.md @@ -4,7 +4,7 @@ The current binary format is specified in `byron.cddl`. You can use this to generate (pseudo-)valid blocks: ```shell -nix-shell +nix develop cddl byron.cddl generate | diag2pretty.rb > test.pretty ``` diff --git a/eras/byron/cddl-spec/default.nix b/eras/byron/cddl-spec/default.nix deleted file mode 100644 index f4b45b00d69..00000000000 --- a/eras/byron/cddl-spec/default.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ pkgs ? import ../../../nix/default.nix {} }: - -with pkgs; - -latex.buildLatex { - name = "blocks-cddl-spec"; - texFiles = [ "byron-binary" ]; - meta = with lib; { - description = "Byron blocks CDDL specification"; - license = licenses.asl20; - platforms = platforms.linux; - }; - src = ./.; - - texInputs = { - inherit (texlive) - scheme-small - - # Fonts - cm-super - - # libraries - unicode-math lm-math amsmath - enumitem bclogo xcolor newunicodechar - appendix syntax - - # build tools - latexmk - ; - }; - buildInputs = [ - gitMinimal - # CBOR scheme specification related tools - cddl - cbor-diag - ]; -} diff --git a/eras/byron/cddl-spec/flake.nix b/eras/byron/cddl-spec/flake.nix new file mode 100644 index 00000000000..52f473b14ae --- /dev/null +++ b/eras/byron/cddl-spec/flake.nix @@ -0,0 +1,49 @@ +{ + outputs = inputs: { + packages = + builtins.mapAttrs (_: {nixpkgs, ...}: { + default = with nixpkgs; + buildLatex { + name = "blocks-cddl-spec"; + texFiles = ["byron-binary"]; + meta = with lib; { + description = "Byron blocks CDDL specification"; + license = licenses.asl20; + platforms = platforms.linux; + }; + src = ./.; + + texInputs = { + inherit + (texlive) + scheme-small + # Fonts + + cm-super + # libraries + + unicode-math + lm-math + amsmath + enumitem + bclogo + xcolor + newunicodechar + appendix + syntax + # build tools + + latexmk + ; + }; + buildInputs = [ + gitMinimal + # CBOR scheme specification related tools + cddl + cbor-diag + ]; + }; + }) + (inputs.main or (import ../../../nix/flake-compat.nix).defaultNix).legacyPackages; + }; +} diff --git a/eras/byron/chain/executable-spec/default.nix b/eras/byron/chain/executable-spec/default.nix deleted file mode 100644 index 705dcc22634..00000000000 --- a/eras/byron/chain/executable-spec/default.nix +++ /dev/null @@ -1,4 +0,0 @@ -let - pkgs = import ../../../default.nix {}; -in - pkgs.libs.byron-spec-chain diff --git a/eras/byron/chain/executable-spec/flake.nix b/eras/byron/chain/executable-spec/flake.nix new file mode 100644 index 00000000000..2b5cd7f6f41 --- /dev/null +++ b/eras/byron/chain/executable-spec/flake.nix @@ -0,0 +1,13 @@ +{ + outputs = inputs: let + main = inputs.main or (import ../../../../nix/flake-compat.nix).defaultNix; + in { + packages = + builtins.mapAttrs (_: {cabalProject, ...}: { + default = cabalProject.hsPkgs.byron-spec-chain.components.library; + test = cabalProject.hsPkgs.byron-spec-chain.components.tests.chain-rules-test; + }) + main.legacyPackages; + inherit (main) devShells; + }; +} diff --git a/eras/byron/chain/formal-spec/byron-blockchain.tex b/eras/byron/chain/formal-spec/byron-blockchain.tex index 06ef01dd231..149223cfdb5 100644 --- a/eras/byron/chain/formal-spec/byron-blockchain.tex +++ b/eras/byron/chain/formal-spec/byron-blockchain.tex @@ -1482,5 +1482,5 @@ \subsection{Header only validation} %%% Local Variables: %%% mode: latex %%% TeX-master: t -%%% LaTeX-command: "nix-shell --run make" +%%% LaTeX-command: "nix develop --command make" %%% End: diff --git a/eras/byron/chain/formal-spec/default.nix b/eras/byron/chain/formal-spec/default.nix deleted file mode 100644 index f381341b2a4..00000000000 --- a/eras/byron/chain/formal-spec/default.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ pkgs ? import ../../../../nix/default.nix {} }: - -with pkgs; - -latex.buildLatex { - name = "byron-chain-spec"; - texFiles = [ "byron-blockchain" ]; - meta = with lib; { - description = "Byron Blockchain Specification"; - license = licenses.asl20; - platforms = platforms.linux; - }; - src = latex.filterLatex ./.; - - texInputs = { - inherit (texlive) - scheme-small - - # libraries - stmaryrd lm-math amsmath extarrows cleveref semantic xcolor appendix - - # bclogo and dependencies - bclogo mdframed xkeyval etoolbox needspace pgf - - # font libraries `mathpazo` seems to depend on palatino - # , but it isn't pulled. - mathpazo palatino microtype - - # libraries for marginal notes - xargs todonotes - - # build tools - latexmk - - ; - }; - buildInputs = [ gitMinimal ]; -} diff --git a/eras/byron/chain/formal-spec/flake.nix b/eras/byron/chain/formal-spec/flake.nix new file mode 100644 index 00000000000..e896b8f85ab --- /dev/null +++ b/eras/byron/chain/formal-spec/flake.nix @@ -0,0 +1,59 @@ +{ + outputs = inputs: { + packages = + builtins.mapAttrs (_: {nixpkgs, ...}: { + default = with nixpkgs; + buildLatex { + name = "byron-chain-spec"; + texFiles = ["byron-blockchain"]; + meta = with lib; { + description = "Byron Blockchain Specification"; + license = licenses.asl20; + platforms = platforms.linux; + }; + src = filterLatex ./.; + + texInputs = { + inherit + (texlive) + scheme-small + # libraries + + stmaryrd + lm-math + amsmath + extarrows + cleveref + semantic + xcolor + appendix + # bclogo and dependencies + + bclogo + mdframed + xkeyval + etoolbox + needspace + pgf + # font libraries `mathpazo` seems to depend on palatino + + # , but it isn't pulled. + + mathpazo + palatino + microtype + # libraries for marginal notes + + xargs + todonotes + # build tools + + latexmk + ; + }; + buildInputs = [gitMinimal]; + }; + }) + (inputs.main or (import ../../../../nix/flake-compat.nix).defaultNix).legacyPackages; + }; +} diff --git a/eras/byron/ledger/executable-spec/default.nix b/eras/byron/ledger/executable-spec/default.nix deleted file mode 100644 index 04ee8c95671..00000000000 --- a/eras/byron/ledger/executable-spec/default.nix +++ /dev/null @@ -1,4 +0,0 @@ -let - pkgs = import ../../../default.nix {}; -in - pkgs.libs.byron-spec-ledger diff --git a/eras/byron/ledger/executable-spec/flake.nix b/eras/byron/ledger/executable-spec/flake.nix new file mode 100644 index 00000000000..ab1b6a77112 --- /dev/null +++ b/eras/byron/ledger/executable-spec/flake.nix @@ -0,0 +1,13 @@ +{ + outputs = inputs: let + main = inputs.main or (import ../../../../nix/flake-compat.nix).defaultNix; + in { + packages = + builtins.mapAttrs (_: {cabalProject, ...}: { + default = cabalProject.hsPkgs.byron-spec-ledger.components.library; + test = cabalProject.hsPkgs.byron-spec-ledger.components.tests.byron-spec-ledger-test; + }) + main.legacyPackages; + inherit (main) devShells; + }; +} diff --git a/eras/byron/ledger/formal-spec/default.nix b/eras/byron/ledger/formal-spec/default.nix deleted file mode 100644 index d67d761785f..00000000000 --- a/eras/byron/ledger/formal-spec/default.nix +++ /dev/null @@ -1,40 +0,0 @@ -{ pkgs ? import ../../../../nix/default.nix {} }: - -with pkgs; - -latex.buildLatex { - name = "byron-ledger-spec"; - texFiles = [ "byron-ledger" ]; - meta = with lib; { - description = "Byron Ledger Specification"; - license = licenses.asl20; - platforms = platforms.linux; - }; - src = latex.filterLatex ./.; - - texInputs = { - inherit (texlive) - scheme-small - - # libraries - stmaryrd lm-math amsmath extarrows cleveref semantic tikz-cd xcolor - - # bclogo and dependencies - bclogo mdframed xkeyval etoolbox needspace pgf - - # font libraries `mathpazo` seems to depend on palatino - # , but it isn't pulled. - mathpazo palatino microtype - - # libraries for marginal notes - xargs todonotes - - # build tools - latexmk - - # Referencing - zref - ; - }; - buildInputs = [ gitMinimal ]; -} diff --git a/eras/byron/ledger/formal-spec/flake.nix b/eras/byron/ledger/formal-spec/flake.nix new file mode 100644 index 00000000000..d1dbc4b1273 --- /dev/null +++ b/eras/byron/ledger/formal-spec/flake.nix @@ -0,0 +1,60 @@ +{ + outputs = inputs: { + packages = + builtins.mapAttrs (_: {nixpkgs, ...}: { + default = with nixpkgs; + buildLatex { + name = "byron-ledger-spec"; + texFiles = ["byron-ledger"]; + meta = with lib; { + description = "Byron Ledger Specification"; + license = licenses.asl20; + platforms = platforms.linux; + }; + src = filterLatex ./.; + + texInputs = { + inherit + (texlive) + scheme-small + # libraries + + stmaryrd + lm-math + amsmath + extarrows + cleveref + semantic + tikz-cd + xcolor + # bclogo and dependencies + + bclogo + mdframed + xkeyval + etoolbox + needspace + pgf + # font libraries `mathpazo` seems to depend on palatino, but it isn't pulled. + + mathpazo + palatino + microtype + # libraries for marginal notes + + xargs + todonotes + # build tools + + latexmk + # Referencing + + zref + ; + }; + buildInputs = [gitMinimal]; + }; + }) + (inputs.main or (import ../../../../nix/flake-compat.nix).defaultNix).legacyPackages; + }; +} diff --git a/eras/shelley-ma/formal-spec/default.nix b/eras/shelley-ma/formal-spec/default.nix deleted file mode 100644 index 9eba3e713d2..00000000000 --- a/eras/shelley-ma/formal-spec/default.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ pkgs ? import ../../../nix/default.nix {} }: - -with pkgs; - -latex.buildLatex { - name = "shelley-ma-spec"; - texFiles = [ "mary-ledger" ]; - meta = with lib; { - description = "Shelley multi-asset specification"; - license = licenses.asl20; - platforms = platforms.linux; - }; - src = latex.filterLatex ./.; - - texInputs = { - inherit (texlive) - scheme-small - collection-latexextra - collection-latexrecommended - collection-mathscience - bclogo - ; - }; -} diff --git a/eras/shelley-ma/formal-spec/flake.nix b/eras/shelley-ma/formal-spec/flake.nix new file mode 100644 index 00000000000..31a35d2d2d8 --- /dev/null +++ b/eras/shelley-ma/formal-spec/flake.nix @@ -0,0 +1,30 @@ +{ + outputs = inputs: { + packages = + builtins.mapAttrs (_: {nixpkgs, ...}: { + default = with nixpkgs; + buildLatex { + name = "shelley-ma-spec"; + texFiles = ["mary-ledger"]; + meta = with lib; { + description = "Shelley multi-asset specification"; + license = licenses.asl20; + platforms = platforms.linux; + }; + src = filterLatex ./.; + + texInputs = { + inherit + (texlive) + scheme-small + collection-latexextra + collection-latexrecommended + collection-mathscience + bclogo + ; + }; + }; + }) + (inputs.main or (import ../../../nix/flake-compat.nix).defaultNix).legacyPackages; + }; +} diff --git a/eras/shelley/design-spec/default.nix b/eras/shelley/design-spec/default.nix deleted file mode 100644 index 060612030ae..00000000000 --- a/eras/shelley/design-spec/default.nix +++ /dev/null @@ -1,45 +0,0 @@ -{ pkgs ? import ../../nix/default.nix {} }: - -with pkgs; - -latex.buildLatex { - name = "delegation-design-spec"; - texFiles = [ "shelley-delegation" ]; - meta = with lib; { - description = "Delegation Design Specification"; - license = licenses.asl20; - platforms = platforms.linux; - }; - src = latex.filterLatex ./.; - - texInputs = { - inherit (texlive) - scheme-small - - # fonts - cm-super - - # libraries - stmaryrd lm-math amsmath - extarrows cleveref - titlesec - - # font libraries `mathpazo` seems to depend on palatino, but it isn't pulled. - mathpazo palatino microtype - - # libraries for marginal notes - xargs todonotes - - # drawing - pgf - - # build tools - latexmk - - # Referencing - zref - ; - - }; - buildInputs = [ gitMinimal ]; -} diff --git a/eras/shelley/design-spec/flake.nix b/eras/shelley/design-spec/flake.nix new file mode 100644 index 00000000000..80f550ea89e --- /dev/null +++ b/eras/shelley/design-spec/flake.nix @@ -0,0 +1,56 @@ +{ + outputs = inputs: { + packages = + builtins.mapAttrs (_: {nixpkgs, ...}: { + default = with nixpkgs; + buildLatex { + name = "delegation-design-spec"; + texFiles = ["shelley-delegation"]; + meta = with lib; { + description = "Delegation Design Specification"; + license = licenses.asl20; + platforms = platforms.linux; + }; + src = filterLatex ./.; + + texInputs = { + inherit + (texlive) + scheme-small + # fonts + + cm-super + # libraries + + stmaryrd + lm-math + amsmath + extarrows + cleveref + titlesec + # font libraries `mathpazo` seems to depend on palatino, but it isn't pulled. + + mathpazo + palatino + microtype + # libraries for marginal notes + + xargs + todonotes + # drawing + + pgf + # build tools + + latexmk + # Referencing + + zref + ; + }; + buildInputs = [gitMinimal]; + }; + }) + (inputs.main or (import ../../../nix/flake-compat.nix).defaultNix).legacyPackages; + }; +} diff --git a/eras/shelley/formal-spec/default.nix b/eras/shelley/formal-spec/default.nix deleted file mode 100644 index 658de239df9..00000000000 --- a/eras/shelley/formal-spec/default.nix +++ /dev/null @@ -1,44 +0,0 @@ -{ pkgs ? import ../../../nix/default.nix {} }: - -with pkgs; - -latex.buildLatex { - name = "shelley-ledger-spec"; - texFiles = [ "shelley-ledger" ]; - meta = with lib; { - description = "Shelley Ledger Specification"; - license = licenses.asl20; - platforms = platforms.linux; - }; - src = latex.filterLatex ./.; - - texInputs = { - inherit (texlive) - scheme-small - - # libraries - stmaryrd lm-math amsmath extarrows cleveref semantic xcolor xstring paralist cm-super tocloft - - # bclogo and dependencies - bclogo mdframed xkeyval etoolbox needspace - - # font libraries `mathpazo` seems to depend on palatino, but it isn't pulled. - mathpazo palatino microtype - - # libraries for marginal notes - xargs todonotes - - # Tikz - pgf tikz-cd - - # build tools - latexmk - - # Referencing - zref - - ; - - }; - buildInputs = [ gitMinimal ]; -} diff --git a/eras/shelley/formal-spec/flake.nix b/eras/shelley/formal-spec/flake.nix new file mode 100644 index 00000000000..efbe7d4ccb4 --- /dev/null +++ b/eras/shelley/formal-spec/flake.nix @@ -0,0 +1,66 @@ +{ + outputs = inputs: { + packages = + builtins.mapAttrs (_: {nixpkgs, ...}: { + default = with nixpkgs; + buildLatex { + name = "shelley-ledger-spec"; + texFiles = ["shelley-ledger"]; + meta = with lib; { + description = "Shelley Ledger Specification"; + license = licenses.asl20; + platforms = platforms.linux; + }; + src = filterLatex ./.; + + texInputs = { + inherit + (texlive) + scheme-small + # libraries + + stmaryrd + lm-math + amsmath + extarrows + cleveref + semantic + xcolor + xstring + paralist + cm-super + tocloft + # bclogo and dependencies + + bclogo + mdframed + xkeyval + etoolbox + needspace + # font libraries `mathpazo` seems to depend on palatino, but it isn't pulled. + + mathpazo + palatino + microtype + # libraries for marginal notes + + xargs + todonotes + # Tikz + + pgf + tikz-cd + # build tools + + latexmk + # Referencing + + zref + ; + }; + buildInputs = [gitMinimal]; + }; + }) + (inputs.main or (import ../../../nix/flake-compat.nix).defaultNix).legacyPackages; + }; +} diff --git a/flake.lock b/flake.lock index 39a6707576c..c99f497618e 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,38 @@ { "nodes": { + "CHaP": { + "flake": false, + "locked": { + "lastModified": 1685707241, + "narHash": "sha256-3vwY0mo8lf+0n+H6g3giXtVLQeXt/l9+FlsOpfi7CwM=", + "owner": "input-output-hk", + "repo": "cardano-haskell-packages", + "rev": "2baceb51b8f3175e05e94fdd4780cc717aeb2a6f", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "ref": "repo", + "repo": "cardano-haskell-packages", + "type": "github" + } + }, + "HTTP": { + "flake": false, + "locked": { + "lastModified": 1451647621, + "narHash": "sha256-oHIyw3x0iKBexEo49YeUDV1k74ZtyYKGR2gNJXXRxts=", + "owner": "phadej", + "repo": "HTTP", + "rev": "9bc0996d412fef1787449d841277ef663ad9a915", + "type": "github" + }, + "original": { + "owner": "phadej", + "repo": "HTTP", + "type": "github" + } + }, "blank": { "locked": { "lastModified": 1625557891, @@ -15,6 +48,106 @@ "type": "github" } }, + "blst": { + "flake": false, + "locked": { + "lastModified": 1656163412, + "narHash": "sha256-xero1aTe2v4IhWIJaEDUsVDOfE77dOV5zKeHWntHogY=", + "owner": "supranational", + "repo": "blst", + "rev": "03b5124029979755c752eec45f3c29674b558446", + "type": "github" + }, + "original": { + "owner": "supranational", + "repo": "blst", + "rev": "03b5124029979755c752eec45f3c29674b558446", + "type": "github" + } + }, + "cabal-32": { + "flake": false, + "locked": { + "lastModified": 1603716527, + "narHash": "sha256-X0TFfdD4KZpwl0Zr6x+PLxUt/VyKQfX7ylXHdmZIL+w=", + "owner": "haskell", + "repo": "cabal", + "rev": "48bf10787e27364730dd37a42b603cee8d6af7ee", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "3.2", + "repo": "cabal", + "type": "github" + } + }, + "cabal-34": { + "flake": false, + "locked": { + "lastModified": 1645834128, + "narHash": "sha256-wG3d+dOt14z8+ydz4SL7pwGfe7SiimxcD/LOuPCV6xM=", + "owner": "haskell", + "repo": "cabal", + "rev": "5ff598c67f53f7c4f48e31d722ba37172230c462", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "3.4", + "repo": "cabal", + "type": "github" + } + }, + "cabal-36": { + "flake": false, + "locked": { + "lastModified": 1669081697, + "narHash": "sha256-I5or+V7LZvMxfbYgZATU4awzkicBwwok4mVoje+sGmU=", + "owner": "haskell", + "repo": "cabal", + "rev": "8fd619e33d34924a94e691c5fea2c42f0fc7f144", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "3.6", + "repo": "cabal", + "type": "github" + } + }, + "cardano-mainnet-mirror": { + "flake": false, + "locked": { + "lastModified": 1557232434, + "narHash": "sha256-2rclcOjIVq0lFCdYAa8S9imzZZHqySn2LZ/O48hUofw=", + "owner": "input-output-hk", + "repo": "cardano-mainnet-mirror", + "rev": "a31ac7534ec855b715b9a6bb6a06861ee94935d9", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "cardano-mainnet-mirror", + "type": "github" + } + }, + "cardano-shell": { + "flake": false, + "locked": { + "lastModified": 1608537748, + "narHash": "sha256-PulY1GfiMgKVnBci3ex4ptk2UNYMXqGjJOxcPy2KYT4=", + "owner": "input-output-hk", + "repo": "cardano-shell", + "rev": "9392c75087cb9a3d453998f4230930dea3a95725", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "cardano-shell", + "type": "github" + } + }, "devshell": { "inputs": { "flake-utils": [ @@ -70,6 +203,39 @@ } }, "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1672831974, + "narHash": "sha256-z9k3MfslLjWQfnjBtEtJZdq3H7kyi2kQtUThfTgdRk0=", + "owner": "input-output-hk", + "repo": "flake-compat", + "rev": "45f2638735f8cdc40fe302742b79f248d23eb368", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "ref": "hkm/gitlab-fix", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_3": { "flake": false, "locked": { "lastModified": 1650374568, @@ -86,6 +252,41 @@ } }, "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1681378341, + "narHash": "sha256-2qUN04W6X9cHHytEsJTM41CmusifPTC0bgTtYsHSNY8=", + "owner": "hamishmack", + "repo": "flake-utils", + "rev": "2767bafdb189cd623354620c2dacbeca8fd58b17", + "type": "github" + }, + "original": { + "owner": "hamishmack", + "ref": "hkm/nested-hydraJobs", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1679360468, + "narHash": "sha256-LGnza3cfXF10Biw3ZTg0u9o9t7s680Ww200t5KkHTh8=", + "owner": "hamishmack", + "repo": "flake-utils", + "rev": "e1ea268ff47ad475443dbabcd54744b4e5b9d4f5", + "type": "github" + }, + "original": { + "owner": "hamishmack", + "ref": "hkm/nested-hydraJobs", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { "locked": { "lastModified": 1653893745, "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", @@ -100,7 +301,7 @@ "type": "github" } }, - "flake-utils_2": { + "flake-utils_4": { "locked": { "lastModified": 1659877975, "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", @@ -115,9 +316,26 @@ "type": "github" } }, + "ghc-8.6.5-iohk": { + "flake": false, + "locked": { + "lastModified": 1600920045, + "narHash": "sha256-DO6kxJz248djebZLpSzTGD6s8WRpNI9BTwUeOf5RwY8=", + "owner": "input-output-hk", + "repo": "ghc", + "rev": "95713a6ecce4551240da7c96b6176f980af75cae", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "ref": "release/8.6.5-iohk", + "repo": "ghc", + "type": "github" + } + }, "gomod2nix": { "inputs": { - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs_3", "utils": "utils" }, "locked": { @@ -134,6 +352,139 @@ "type": "github" } }, + "hackage": { + "flake": false, + "locked": { + "lastModified": 1685924766, + "narHash": "sha256-sq3zvAcp4a4BCEAE4S9Y1lt4jQcpmHl8A+WheImd9OQ=", + "owner": "input-output-hk", + "repo": "hackage.nix", + "rev": "6b0975bd09c166cbd84bfcfe58bfd84c5153ec87", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "hackage.nix", + "type": "github" + } + }, + "haskellNix": { + "inputs": { + "HTTP": "HTTP", + "cabal-32": "cabal-32", + "cabal-34": "cabal-34", + "cabal-36": "cabal-36", + "cardano-shell": "cardano-shell", + "flake-compat": "flake-compat_2", + "flake-utils": "flake-utils_2", + "ghc-8.6.5-iohk": "ghc-8.6.5-iohk", + "hackage": "hackage", + "hls-1.10": "hls-1.10", + "hls-2.0": "hls-2.0", + "hpc-coveralls": "hpc-coveralls", + "hydra": "hydra", + "iserv-proxy": "iserv-proxy", + "nixpkgs": [ + "haskellNix", + "nixpkgs-unstable" + ], + "nixpkgs-2003": "nixpkgs-2003", + "nixpkgs-2105": "nixpkgs-2105", + "nixpkgs-2111": "nixpkgs-2111", + "nixpkgs-2205": "nixpkgs-2205", + "nixpkgs-2211": "nixpkgs-2211", + "nixpkgs-2305": "nixpkgs-2305", + "nixpkgs-unstable": "nixpkgs-unstable", + "old-ghc-nix": "old-ghc-nix", + "stackage": "stackage" + }, + "locked": { + "lastModified": 1685926350, + "narHash": "sha256-d6uK8/U7zYGrFbW3bd/lWupYTygsIa/cf/ECQ/3KSt0=", + "owner": "input-output-hk", + "repo": "haskell.nix", + "rev": "ebef98fdd98b173f336bb7889feb11e2915eca34", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "haskell.nix", + "type": "github" + } + }, + "hls-1.10": { + "flake": false, + "locked": { + "lastModified": 1680000865, + "narHash": "sha256-rc7iiUAcrHxwRM/s0ErEsSPxOR3u8t7DvFeWlMycWgo=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "b08691db779f7a35ff322b71e72a12f6e3376fd9", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "1.10.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.0": { + "flake": false, + "locked": { + "lastModified": 1684398654, + "narHash": "sha256-RW44up2BIyBBYN6tZur5f9kDDR3kr0Rd+TgPbLTfwB4=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "20c6d1e731cd9c0beef7338e2fc7a8126ba9b6fb", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.0.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hpc-coveralls": { + "flake": false, + "locked": { + "lastModified": 1607498076, + "narHash": "sha256-8uqsEtivphgZWYeUo5RDUhp6bO9j2vaaProQxHBltQk=", + "owner": "sevanspowell", + "repo": "hpc-coveralls", + "rev": "14df0f7d229f4cd2e79f8eabb1a740097fdfa430", + "type": "github" + }, + "original": { + "owner": "sevanspowell", + "repo": "hpc-coveralls", + "type": "github" + } + }, + "hydra": { + "inputs": { + "nix": "nix", + "nixpkgs": [ + "haskellNix", + "hydra", + "nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1671755331, + "narHash": "sha256-hXsgJj0Cy0ZiCiYdW2OdBz5WmFyOMKuw4zyxKpgUKm4=", + "owner": "NixOS", + "repo": "hydra", + "rev": "f48f00ee6d5727ae3e488cbf9ce157460853fea8", + "type": "github" + }, + "original": { + "id": "hydra", + "type": "indirect" + } + }, "incl": { "inputs": { "nixlib": [ @@ -156,6 +507,60 @@ "type": "github" } }, + "iohkNix": { + "inputs": { + "blst": "blst", + "nixpkgs": "nixpkgs_2", + "secp256k1": "secp256k1", + "sodium": "sodium" + }, + "locked": { + "lastModified": 1685727458, + "narHash": "sha256-c/pkFYCfzpRb6W2OOKE+EOzOlcw+96vwJGGg8Ir9Qfk=", + "owner": "input-output-hk", + "repo": "iohk-nix", + "rev": "02f42375ee5c2bab1640f14c6389b7e91bbfec8b", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "iohk-nix", + "type": "github" + } + }, + "iserv-proxy": { + "flake": false, + "locked": { + "lastModified": 1670983692, + "narHash": "sha256-avLo34JnI9HNyOuauK5R69usJm+GfW3MlyGlYxZhTgY=", + "ref": "hkm/remote-iserv", + "rev": "50d0abb3317ac439a4e7495b185a64af9b7b9300", + "revCount": 10, + "type": "git", + "url": "https://gitlab.haskell.org/hamishmack/iserv-proxy.git" + }, + "original": { + "ref": "hkm/remote-iserv", + "type": "git", + "url": "https://gitlab.haskell.org/hamishmack/iserv-proxy.git" + } + }, + "lowdown-src": { + "flake": false, + "locked": { + "lastModified": 1633514407, + "narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=", + "owner": "kristapsdz", + "repo": "lowdown", + "rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8", + "type": "github" + }, + "original": { + "owner": "kristapsdz", + "repo": "lowdown", + "type": "github" + } + }, "n2c": { "inputs": { "flake-utils": [ @@ -183,9 +588,30 @@ "type": "github" } }, + "nix": { + "inputs": { + "lowdown-src": "lowdown-src", + "nixpkgs": "nixpkgs", + "nixpkgs-regression": "nixpkgs-regression" + }, + "locked": { + "lastModified": 1661606874, + "narHash": "sha256-9+rpYzI+SmxJn+EbYxjGv68Ucp22bdFUSy/4LkHkkDQ=", + "owner": "NixOS", + "repo": "nix", + "rev": "11e45768b34fdafdcf019ddbd337afa16127ff0f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "2.11.0", + "repo": "nix", + "type": "github" + } + }, "nix-nomad": { "inputs": { - "flake-compat": "flake-compat", + "flake-compat": "flake-compat_3", "flake-utils": [ "tullia", "nix2container", @@ -217,8 +643,8 @@ }, "nix2container": { "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs_3" + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_4" }, "locked": { "lastModified": 1658567952, @@ -268,21 +694,165 @@ }, "nixpkgs": { "locked": { - "lastModified": 1679748960, - "narHash": "sha256-BP8XcYHyj1NxQi04RpyNW8e7KiXSoI+Fy1tXIK2GfdA=", + "lastModified": 1657693803, + "narHash": "sha256-G++2CJ9u0E7NNTAi9n5G8TdDmGJXcIjkJ3NF8cetQB8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "da26ae9f6ce2c9ab380c0f394488892616fc5a6a", + "rev": "365e1b3a859281cf11b94f87231adeabbdd878a2", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-22.11", + "ref": "nixos-22.05-small", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2003": { + "locked": { + "lastModified": 1620055814, + "narHash": "sha256-8LEHoYSJiL901bTMVatq+rf8y7QtWuZhwwpKE2fyaRY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1db42b7fe3878f3f5f7a4f2dc210772fd080e205", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-20.03-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2105": { + "locked": { + "lastModified": 1659914493, + "narHash": "sha256-lkA5X3VNMKirvA+SUzvEhfA7XquWLci+CGi505YFAIs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "022caabb5f2265ad4006c1fa5b1ebe69fb0c3faf", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-21.05-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2111": { + "locked": { + "lastModified": 1659446231, + "narHash": "sha256-hekabNdTdgR/iLsgce5TGWmfIDZ86qjPhxDg/8TlzhE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "eabc38219184cc3e04a974fe31857d8e0eac098d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-21.11-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2205": { + "locked": { + "lastModified": 1682600000, + "narHash": "sha256-ha4BehR1dh8EnXSoE1m/wyyYVvHI9txjW4w5/oxsW5Y=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "50fc86b75d2744e1ab3837ef74b53f103a9b55a0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-22.05-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2211": { + "locked": { + "lastModified": 1685314633, + "narHash": "sha256-8LXBPqTQXl5ofkjpJ18JcbmLJ/lWDoMxtUwiDYv0wro=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c8a17ce7abc03c50cd072e9e6c9b389c5f61836b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-22.11-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-2305": { + "locked": { + "lastModified": 1685338297, + "narHash": "sha256-+Aq4O0Jn1W1q927ZHc3Zn6RO7bwQGmb6O8xYoGy0KrM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6287b47dbfabbb8bfbb9b1b53d198ad58a774de4", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-23.05-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-regression": { + "locked": { + "lastModified": 1643052045, + "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1685347552, + "narHash": "sha256-9woSppRyUFo26yUffORTzttJ+apOt8MmCv6RxpPNTU4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f2f1ec390714d303cf84ba086e34e45b450dd8c4", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } }, "nixpkgs_2": { + "locked": { + "lastModified": 1684171562, + "narHash": "sha256-BMUWjVWAUdyMWKk0ATMC9H0Bv4qAV/TXwwPUvTiC5IQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "55af203d468a6f5032a519cba4f41acf5a74b638", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "release-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { "locked": { "lastModified": 1653581809, "narHash": "sha256-Uvka0V5MTGbeOfWte25+tfRL3moECDh1VwokWSZUdoY=", @@ -298,7 +868,7 @@ "type": "github" } }, - "nixpkgs_3": { + "nixpkgs_4": { "locked": { "lastModified": 1654807842, "narHash": "sha256-ADymZpr6LuTEBXcy6RtFHcUZdjKTBRTMYwu19WOx17E=", @@ -313,7 +883,23 @@ "type": "github" } }, - "nixpkgs_4": { + "nixpkgs_5": { + "locked": { + "lastModified": 1674407282, + "narHash": "sha256-2qwc8mrPINSFdWffPK+ji6nQ9aGnnZyHSItVcYDZDlk=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "ab1254087f4cdf4af74b552d7fc95175d9bdbb49", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_6": { "locked": { "lastModified": 1675940568, "narHash": "sha256-epG6pOT9V0kS+FUqd7R6/CWkgnZx2DMT5Veqo+y6G3c=", @@ -344,6 +930,23 @@ "type": "github" } }, + "old-ghc-nix": { + "flake": false, + "locked": { + "lastModified": 1631092763, + "narHash": "sha256-sIKgO+z7tj4lw3u6oBZxqIhDrzSkvpHtv0Kki+lh9Fg=", + "owner": "angerman", + "repo": "old-ghc-nix", + "rev": "af48a7a7353e418119b6dfe3cd1463a657f342b8", + "type": "github" + }, + "original": { + "owner": "angerman", + "ref": "master", + "repo": "old-ghc-nix", + "type": "github" + } + }, "paisano": { "inputs": { "nixpkgs": [ @@ -398,31 +1001,69 @@ "type": "github" } }, - "parts": { + "root": { "inputs": { - "nixpkgs-lib": [ - "nixpkgs" - ] + "CHaP": "CHaP", + "cardano-mainnet-mirror": "cardano-mainnet-mirror", + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "haskellNix": "haskellNix", + "iohkNix": "iohkNix", + "nixpkgs": [ + "haskellNix", + "nixpkgs-unstable" + ], + "tullia": "tullia" + } + }, + "secp256k1": { + "flake": false, + "locked": { + "lastModified": 1683999695, + "narHash": "sha256-9nJJVENMXjXEJZzw8DHzin1DkFkF8h9m/c6PuM7Uk4s=", + "owner": "bitcoin-core", + "repo": "secp256k1", + "rev": "acf5c55ae6a94e5ca847e07def40427547876101", + "type": "github" }, + "original": { + "owner": "bitcoin-core", + "ref": "v0.3.2", + "repo": "secp256k1", + "type": "github" + } + }, + "sodium": { + "flake": false, "locked": { - "lastModified": 1679737941, - "narHash": "sha256-srSD9CwsVPnUMsIZ7Kt/UegkKUEBcTyU1Rev7mO45S0=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "3502ee99d6dade045bdeaf7b0cd8ec703484c25c", + "lastModified": 1675156279, + "narHash": "sha256-0uRcN5gvMwO7MCXVYnoqG/OmeBFi8qRVnDWJLnBb9+Y=", + "owner": "input-output-hk", + "repo": "libsodium", + "rev": "dbb48cce5429cb6585c9034f002568964f1ce567", "type": "github" }, "original": { - "owner": "hercules-ci", - "repo": "flake-parts", + "owner": "input-output-hk", + "repo": "libsodium", + "rev": "dbb48cce5429cb6585c9034f002568964f1ce567", "type": "github" } }, - "root": { - "inputs": { - "nixpkgs": "nixpkgs", - "parts": "parts", - "tullia": "tullia" + "stackage": { + "flake": false, + "locked": { + "lastModified": 1685923834, + "narHash": "sha256-5oTnK+dXt1elpbLwVUYiyKroFcCMvRzEPz/PBKRtIIA=", + "owner": "input-output-hk", + "repo": "stackage.nix", + "rev": "fe1d92917a72ec690dbe61a81318931052be6179", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "stackage.nix", + "type": "github" } }, "std": { @@ -435,7 +1076,7 @@ "blank": "blank", "devshell": "devshell", "dmerge": "dmerge", - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils_4", "incl": "incl", "makes": [ "tullia", @@ -449,7 +1090,7 @@ ], "n2c": "n2c", "nixago": "nixago", - "nixpkgs": "nixpkgs_4", + "nixpkgs": "nixpkgs_6", "paisano": "paisano", "paisano-tui": "paisano-tui", "yants": "yants" @@ -468,21 +1109,34 @@ "type": "github" } }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "tullia": { "inputs": { "nix-nomad": "nix-nomad", "nix2container": "nix2container", - "nixpkgs": [ - "nixpkgs" - ], + "nixpkgs": "nixpkgs_5", "std": "std" }, "locked": { - "lastModified": 1677666696, - "narHash": "sha256-Oga/fHNJba7dM6HSz83RNv/UrUeGs1WRHUHbI8dCUqc=", + "lastModified": 1684859161, + "narHash": "sha256-wOKutImA7CRL0rN+Ng80E72fD5FkVub7LLP2k9NICpg=", "owner": "input-output-hk", "repo": "tullia", - "rev": "708d1ec45b17923d2452ba8f28795228ba8aafd5", + "rev": "2964cff1a16eefe301bdddb508c49d94d04603d6", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index fb9c6a9990f..e7cd00b52b5 100644 --- a/flake.nix +++ b/flake.nix @@ -1,50 +1,300 @@ { description = "cardano-ledger"; + inputs = { + haskellNix.url = "github:input-output-hk/haskell.nix"; + nixpkgs.follows = "haskellNix/nixpkgs-unstable"; + iohkNix.url = "github:input-output-hk/iohk-nix"; + flake-utils.url = "github:hamishmack/flake-utils/hkm/nested-hydraJobs"; + + CHaP.url = "github:input-output-hk/cardano-haskell-packages?ref=repo"; + CHaP.flake = false; + + cardano-mainnet-mirror.url = "github:input-output-hk/cardano-mainnet-mirror"; + cardano-mainnet-mirror.flake = false; + + # cicero + tullia.url = "github:input-output-hk/tullia"; + + # non-flake nix compatibility + flake-compat.url = "github:edolstra/flake-compat"; + flake-compat.flake = false; + }; + + outputs = inputs: let + supportedSystems = [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-linux" + "aarch64-darwin" + ]; + in + inputs.flake-utils.lib.eachSystem supportedSystems ( + system: let + # setup our nixpkgs with the haskell.nix overlays, and the iohk-nix + # overlays... + nixpkgs = import inputs.nixpkgs { + overlays = [ + # our local packages. + (import ./nix/pkgs.nix) + # iohkNix.overlays.crypto provide libsodium-vrf, libblst and libsecp256k1. + inputs.iohkNix.overlays.crypto + # haskellNix.overlay can be configured by later overlays, so need to come before them. + inputs.haskellNix.overlay + # configure haskell.nix to use iohk-nix crypto librairies. + inputs.iohkNix.overlays.haskell-nix-crypto + ]; + inherit system; + inherit (inputs.haskellNix) config; + }; + inherit (nixpkgs) lib; + + # see flake `variants` below for alternative compilers + defaultCompiler = "ghc927"; + # We use cabalProject' to ensure we don't build the plan for + # all systems. + cabalProject = nixpkgs.haskell-nix.cabalProject' ({config, ...}: { + src = ./.; + name = "cardano-ledger"; + compiler-nix-name = lib.mkDefault defaultCompiler; + + # we also want cross compilation to windows on linux (and only with default compiler). + crossPlatforms = p: + lib.optional (system == "x86_64-linux" && config.compiler-nix-name == defaultCompiler) + p.mingwW64; + + # CHaP input map, so we can find CHaP packages (needs to be more + # recent than the index-state we set!). Can be updated with + # + # nix flake lock --update-input CHaP + # + inputMap = { + "https://input-output-hk.github.io/cardano-haskell-packages" = inputs.CHaP; + }; + # tools we want in our shell, from hackage + shell.tools = + { + cabal = "3.10.1.0"; + ghcid = "0.8.8"; + } + // lib.optionalAttrs (config.compiler-nix-name == defaultCompiler) { + # tools that work only with default compiler + fourmolu = "0.10.1.0"; + hlint = "3.5"; + haskell-language-server = "2.0.0.0"; + }; + # and from nixpkgs or other inputs + shell.nativeBuildInputs = with nixpkgs; + [ + (python3.withPackages (ps: with ps; [sphinx sphinx_rtd_theme recommonmark sphinx-markdown-tables sphinxemoji])) + haskellPackages.implicit-hie + ] + ++ (with inputs.tullia.packages.${system}; [ + tullia + nix-systems + ]); + # disable Hoogle until someone request it + shell.withHoogle = false; + # Skip cross compilers for the shell + shell.crossPlatforms = _: []; + + # package customizations as needed. Where cabal.project is not + # specific enough, or doesn't allow setting these. + modules = [ + ({pkgs, ...}: { + packages.byron-spec-chain.configureFlags = ["--ghc-option=-Werror"]; + packages.byron-spec-ledger.configureFlags = ["--ghc-option=-Werror"]; + packages.delegation.configureFlags = ["--ghc-option=-Werror"]; + packages.non-integral.configureFlags = ["--ghc-option=-Werror"]; + packages.cardano-ledger-shelley.configureFlags = ["--ghc-option=-Werror"]; + packages.cardano-ledger-shelley-ma.configureFlags = ["--ghc-option=-Werror"]; + packages.cardano-ledger-shelley-ma-test.configureFlags = ["--ghc-option=-Werror"]; + packages.small-steps.configureFlags = ["--ghc-option=-Werror"]; + packages.cardano-ledger-byron = { + configureFlags = ["--ghc-option=-Werror"]; + components = { + tests.cardano-ledger-byron-test = { + preCheck = '' + export CARDANO_MAINNET_MIRROR="${inputs.cardano-mainnet-mirror}/epochs" + cp ${./eras/byron/ledger/impl/mainnet-genesis.json} ./mainnet-genesis.json + ''; + testFlags = ["--scenario=ContinuousIntegration"]; + }; + }; + }; + }) + ({pkgs, ...}: + lib.mkIf pkgs.stdenv.hostPlatform.isUnix { + packages.cardano-ledger-shelley-ma-test.components.tests.cardano-ledger-shelley-ma-test.build-tools = [pkgs.cddl pkgs.cbor-diag]; + packages.cardano-ledger-shelley-test.components.tests.cardano-ledger-shelley-test.build-tools = [pkgs.cddl pkgs.cbor-diag]; + packages.cardano-ledger-alonzo-test.components.tests.cardano-ledger-alonzo-test.build-tools = [pkgs.cddl pkgs.cbor-diag]; + packages.cardano-ledger-babbage-test.components.tests.cardano-ledger-babbage-test.build-tools = [pkgs.cddl pkgs.cbor-diag]; + packages.cardano-ledger-conway-test.components.tests.cardano-ledger-conway-test.build-tools = [pkgs.cddl pkgs.cbor-diag]; + }) + ({pkgs, ...}: + lib.mkIf pkgs.stdenv.hostPlatform.isWindows { + packages.set-algebra.components.tests.tests.buildable = lib.mkForce false; + packages.plutus-preprocessor.package.buildable = lib.mkForce false; + packages.cardano-ledger-test.package.buildable = lib.mkForce false; + packages.cardano-ledger-shelley-ma-test.package.buildable = lib.mkForce false; + packages.cardano-ledger-shelley-test.package.buildable = lib.mkForce false; + packages.cardano-ledger-alonzo-test.package.buildable = lib.mkForce false; + packages.cardano-ledger-babbage-test.package.buildable = lib.mkForce false; + packages.cardano-ledger-conway-test.package.buildable = lib.mkForce false; + }) + ]; + }); + # ... and construct a flake from the cabal project + flake = + cabalProject.flake ( + lib.optionalAttrs (system == "x86_64-linux") { + # on linux, build/test other supported compilers + variants = lib.genAttrs ["ghc8107" "ghc961"] (compiler-nix-name: { + inherit compiler-nix-name; + }); + } + ) + # add cicero logic. + // (let + actionCiInputName = "GitHub event"; + in + inputs.tullia.fromSimple system { + tasks = { + ci = { + config, + lib, + ... + }: { + preset = { + nix.enable = true; + github.ci = { + # Tullia tasks can run locally or on Cicero. + # When no facts are present we know that we are running locally and vice versa. + # When running locally, the current directory is already bind-mounted into the container, + # so we don't need to fetch the source from GitHub and we don't want to report a GitHub status. + enable = config.actionRun.facts != {}; + repository = "input-output-hk/cardano-ledger"; + remote = config.preset.github.lib.readRepository actionCiInputName null; + revision = config.preset.github.lib.readRevision actionCiInputName null; + }; + }; + + command.text = '' + # filter out systems that we cannot build for: + systems=$(nix eval .#packages --apply builtins.attrNames --json | + nix-systems -i | + jq -r 'with_entries(select(.value)) | keys | .[]') + targets=$(for s in $systems; do echo .#hydraJobs."$s".required; done) + # shellcheck disable=SC2086 + nix build --keep-going $targets || nix build --keep-going -L $targets + ''; + + memory = 1024 * 8; + nomad.driver = "exec"; + nomad.resources.cpu = 10000; + }; + }; + + actions = { + "cardano-ledger/ci" = { + task = "ci"; + io = '' + // This is a CUE expression that defines what events trigger a new run of this action. + // There is no documentation for this yet. Ask SRE if you have trouble changing this. + let github = { + #input: "${actionCiInputName}" + #repo: "input-output-hk/cardano-ledger" + } + + #lib.merge + #ios: [ + {#lib.io.github_push, github, #default_branch: true}, + {#lib.io.github_pr, github}, + ] + ''; + }; + }; + }); + in + lib.recursiveUpdate flake rec { + # add a required job, that's basically all hydraJobs. + hydraJobs = + nixpkgs.callPackages inputs.iohkNix.utils.ciJobsAggregates + { + ciJobs = + flake.hydraJobs + // { + inherit (legacyPackages) doc specs; + # This ensure hydra send a status for the required job (even if no change other than commit hash) + revision = nixpkgs.writeText "revision" (inputs.self.rev or "dirty"); + }; + }; + legacyPackages = rec { + inherit cabalProject nixpkgs; + # also provide hydraJobs through legacyPackages to allow building without system prefix: + inherit hydraJobs; + doc.site = ((import ./doc/flake.nix).outputs {main = inputs.self;}).packages.${system}.default; + # + # PDF builds of LaTeX documentation. + # + # To download the latest PDF build from Hydra, use this link: + # https://github.com/input-output-hk/cardano-ledger/releases/latest/download/NAME.pdf + # + # To get a shell where you can run pdflatex to build it yourself, use: + # cd + # nix develop + # + # To build all specs locally with Nix: + # nix build .#specs -o spec + # + specs = nixpkgs.symlinkJoin { + name = "cardano-ledger-specs"; + # XXX: make use of flake relative path inputs once this is fixed: https://github.com/NixOS/nix/issues/6352 + # (so that we can ditch flake-compat.nix) + paths = map (d: ((import "${./.}/${d}/flake.nix").outputs {main = inputs.self;}).packages.${system}.default) [ + "eras/byron/ledger/formal-spec" + "eras/byron/chain/formal-spec" + "eras/shelley/formal-spec" + "eras/shelley-ma/formal-spec" + "eras/alonzo/formal-spec" + "eras/babbage/formal-spec" + "eras/shelley/design-spec" + "docs/small-step-semantics" + "docs/pool-ranking" + "docs/non-integer-calculations" + "eras/byron/cddl-spec" + ]; + }; + }; + devShells = let + profillingShell = p: { + # `nix develop .#profiling` (or `.#ghc927.profiling): a shell with profiling enabled + profiling = (p.appendModule {modules = [{enableLibraryProfiling = true;}];}).shell; + }; + in + profillingShell cabalProject + # Additional shells for every GHC version supported by haskell.nix, eg. `nix develop .#ghc927` + // lib.mapAttrs (compiler-nix-name: _: let + p = cabalProject.appendModule {inherit compiler-nix-name;}; + in + p.shell // (profillingShell p)) + nixpkgs.haskell-nix.compiler; + # formatter used by nix fmt + formatter = nixpkgs.alejandra; + } + ); + nixConfig = { - extra-substituters = ["https://cache.iog.io"]; + extra-substituters = [ + "https://cache.iog.io" + # drop this, once we stop needing it; when we have stable aarch64-darwin + # builds + "https://cache.zw3rk.com" + ]; extra-trusted-public-keys = [ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" + "loony-tools:pr9m4BkM/5/eSTZlkQyRt57Jz7OMBxNSUiMC4FkcNfk=" ]; allow-import-from-derivation = true; }; - - inputs = { - nixpkgs.url = github:NixOS/nixpkgs/nixos-22.11; - tullia = { - url = github:input-output-hk/tullia; - inputs.nixpkgs.follows = "nixpkgs"; - }; - parts = { - url = github:hercules-ci/flake-parts; - inputs.nixpkgs-lib.follows = "nixpkgs"; - }; - }; - - outputs = { - self, - parts, - ... - } @ inputs: - parts.lib.mkFlake {inherit inputs;} ({ - config, - lib, - ... - }: { - systems = ["x86_64-linux" "x86_64-darwin"]; - - imports = [nix/tullia.nix]; - - flake.hydraJobs = lib.genAttrs config.systems ( - system: - import ./release.nix { - cardano-ledger-specs = self; - supportedSystems = [system]; - } - ); - - perSystem = {pkgs, ...}: { - formatter = pkgs.alejandra; - }; - }); } diff --git a/libs/cardano-data/default.nix b/libs/cardano-data/default.nix deleted file mode 100644 index 9f3d406147f..00000000000 --- a/libs/cardano-data/default.nix +++ /dev/null @@ -1,4 +0,0 @@ -let - pkgs = import ../../../default.nix {}; -in - pkgs.libs.cardano-data diff --git a/libs/cardano-data/flake.nix b/libs/cardano-data/flake.nix new file mode 100644 index 00000000000..e5308044c76 --- /dev/null +++ b/libs/cardano-data/flake.nix @@ -0,0 +1,14 @@ +{ + outputs = inputs: let + main = inputs.main or (import ../../nix/flake-compat.nix).defaultNix; + in { + packages = + builtins.mapAttrs (_: {cabalProject, ...}: { + default = cabalProject.hsPkgs.cardano-data.components.library; + testlib = cabalProject.hsPkgs.cardano-data.components.sublibs.testlib; + tests = cabalProject.hsPkgs.cardano-data.components.tests.cardano-data-tests; + }) + main.legacyPackages; + inherit (main) devShells; + }; +} diff --git a/libs/cardano-ledger-binary/default.nix b/libs/cardano-ledger-binary/default.nix deleted file mode 100644 index 7263e47d306..00000000000 --- a/libs/cardano-ledger-binary/default.nix +++ /dev/null @@ -1,4 +0,0 @@ -let - pkgs = import ../../../default.nix {}; -in - pkgs.libs.cardano-ledger-binary diff --git a/libs/cardano-ledger-binary/flake.nix b/libs/cardano-ledger-binary/flake.nix new file mode 100644 index 00000000000..ff5f85a634c --- /dev/null +++ b/libs/cardano-ledger-binary/flake.nix @@ -0,0 +1,14 @@ +{ + outputs = inputs: let + main = inputs.main or (import ../../nix/flake-compat.nix).defaultNix; + in { + packages = + builtins.mapAttrs (_: {cabalProject, ...}: { + default = cabalProject.hsPkgs.cardano-ledger-binary.components.library; + testlib = cabalProject.hsPkgs.cardano-ledger-binary.components.sublibs.testlib; + tests = cabalProject.hsPkgs.cardano-ledger-binary.components.tests.tests; + }) + main.legacyPackages; + inherit (main) devShells; + }; +} diff --git a/libs/cardano-ledger-test/benchProperty/Main.hs b/libs/cardano-ledger-test/benchProperty/Main.hs index 6bd834a1956..c9f9cb63e24 100644 --- a/libs/cardano-ledger-test/benchProperty/Main.hs +++ b/libs/cardano-ledger-test/benchProperty/Main.hs @@ -7,7 +7,7 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} {- -nix-shell --arg config "{ haskellNix.profiling = true; }" +nix develop .#profiling -} -- Second set up the cabal.project.local (in the root of the cardano-ledger directory) as follows. {- @@ -32,7 +32,7 @@ package plutus-core -- | This benchmark file is for profiling Property tests. It appears as a benchmark -- but we do not use any of the criterion stuff. We just run main, which is profiled. --- First be sure and start the nix-shell with profiling enabled +-- First be sure and enter the `nix develop .#profiling` shell module Main where import Cardano.Ledger.Alonzo (AlonzoEra) diff --git a/libs/set-algebra/default.nix b/libs/set-algebra/default.nix deleted file mode 100644 index bb1f6ebb0ad..00000000000 --- a/libs/set-algebra/default.nix +++ /dev/null @@ -1,4 +0,0 @@ -let - pkgs = import ../../../default.nix {}; -in - pkgs.libs.set-algebra diff --git a/libs/set-algebra/flake.nix b/libs/set-algebra/flake.nix new file mode 100644 index 00000000000..0f8c833696b --- /dev/null +++ b/libs/set-algebra/flake.nix @@ -0,0 +1,13 @@ +{ + outputs = inputs: let + main = inputs.main or (import ../../nix/flake-compat.nix).defaultNix; + in { + packages = + builtins.mapAttrs (_: {cabalProject, ...}: { + default = cabalProject.hsPkgs.set-algebra.components.library; + tests = cabalProject.hsPkgs.set-algebra.components.tests.tests; + }) + main.legacyPackages; + inherit (main) devShells; + }; +} diff --git a/libs/small-steps/default.nix b/libs/small-steps/default.nix deleted file mode 100644 index ae7236e5c61..00000000000 --- a/libs/small-steps/default.nix +++ /dev/null @@ -1,4 +0,0 @@ -let - pkgs = import ../../../default.nix {}; -in - pkgs.libs.small-steps diff --git a/libs/small-steps/flake.nix b/libs/small-steps/flake.nix new file mode 100644 index 00000000000..04dbce48a97 --- /dev/null +++ b/libs/small-steps/flake.nix @@ -0,0 +1,12 @@ +{ + outputs = inputs: let + main = inputs.main or (import ../../nix/flake-compat.nix).defaultNix; + in { + packages = + builtins.mapAttrs (_: {cabalProject, ...}: { + default = cabalProject.hsPkgs.small-steps.components.library; + }) + main.legacyPackages; + inherit (main) devShells; + }; +} diff --git a/nix/cardano-mainnet-mirror.nix b/nix/cardano-mainnet-mirror.nix deleted file mode 100644 index 52c17d76f71..00000000000 --- a/nix/cardano-mainnet-mirror.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ pkgs, ... }: - -pkgs.fetchgit { - url = "https://github.com/input-output-hk/cardano-mainnet-mirror"; - rev = "a31ac7534ec855b715b9a6bb6a06861ee94935d9"; - sha256 = "1z51ak4f7klz5pv2kjgaj5jv6agn2aph2n172hjssmn8x1q2bdys"; -} diff --git a/nix/default.nix b/nix/default.nix deleted file mode 100644 index 4a4df4eab0b..00000000000 --- a/nix/default.nix +++ /dev/null @@ -1,56 +0,0 @@ -{ system ? builtins.currentSystem -, crossSystem ? null -, config ? {} -, sourcesOverride ? {} -, gitrev ? null -}: -let - sources = import ./sources.nix { inherit pkgs; } - // sourcesOverride; - iohkNixMain = import sources.iohk-nix {}; - haskellNix = (import sources."haskell.nix" - { inherit system; - sourcesOverride = sourcesOverride // { hackage = sources."hackage.nix"; }; - pkgs = import nixpkgs { inherit system; }; - }).nixpkgsArgs; - # use our own nixpkgs if it exists in our sources, - # otherwise use iohkNix default nixpkgs. - nixpkgs = if (sources ? nixpkgs) - then (builtins.trace "Not using IOHK default nixpkgs (use 'niv drop nixpkgs' to use default for better sharing)" - sources.nixpkgs) - else (builtins.trace "Using IOHK default nixpkgs" - iohkNixMain.nixpkgs); - - # for inclusion in pkgs: - overlays = - # Haskell.nix (https://github.com/input-output-hk/haskell.nix) - haskellNix.overlays - # haskell-nix.haskellLib.extra: some useful extra utility functions for haskell.nix - ++ iohkNixMain.overlays.haskell-nix-extra - # iohkNix: nix utilities and niv: - ++ iohkNixMain.overlays.iohkNix - # libsodium fork - ++ iohkNixMain.overlays.crypto - # our own overlays: - ++ [ - (pkgs: _: with pkgs; { - - # commonLib: mix pkgs.lib with iohk-nix utils and our own: - commonLib = lib // iohkNix - // import ./util.nix { inherit haskell-nix; } - # also expose our sources and overlays - // { inherit overlays sources; }; - - # Functions for building LaTeX documents. - latex = import ./latex.nix { inherit (pkgs) stdenv lib texlive; }; - }) - # And, of course, our haskell-nix-ified cabal project: - (import ./pkgs.nix { inherit sources; } ) - ]; - - pkgs = import nixpkgs { - inherit system crossSystem overlays; - config = haskellNix.config // config; - }; - -in pkgs diff --git a/nix/flake-compat.nix b/nix/flake-compat.nix new file mode 100644 index 00000000000..42d684e5c43 --- /dev/null +++ b/nix/flake-compat.nix @@ -0,0 +1,11 @@ +import +( + let + lock = builtins.fromJSON (builtins.readFile ../flake.lock); + in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } +) +{src = ./..;} diff --git a/nix/haskell.nix b/nix/haskell.nix deleted file mode 100644 index 3131780482c..00000000000 --- a/nix/haskell.nix +++ /dev/null @@ -1,74 +0,0 @@ -############################################################################ -# Builds Haskell packages with Haskell.nix -############################################################################ -{ lib -, stdenv -, pkgs -, haskell-nix -, CHaP -, buildPackages -, config ? {} -# GHC attribute name -, compiler ? config.haskellNix.compiler or "ghc927" -# Enable profiling -, profiling ? config.haskellNix.profiling or false -}: -let - - src = haskell-nix.haskellLib.cleanGit { - name = "cardano-ledger"; - src = ../.; - }; - - # The cardano-mainnet-mirror used during testing - cardano-mainnet-mirror = import ./cardano-mainnet-mirror.nix {inherit pkgs;}; - - # This creates the Haskell package set. - # https://input-output-hk.github.io/haskell.nix/user-guide/projects/ - pkgSet = haskell-nix.cabalProject { - inherit src; - inputMap = { "https://input-output-hk.github.io/cardano-haskell-packages" = CHaP; }; - compiler-nix-name = compiler; - modules = [ - { - # Use our forked libsodium from iohk-nix crypto overlay. - packages.cardano-crypto-class.components.library.pkgconfig = lib.mkForce [ [ pkgs.libsodium-vrf pkgs.secp256k1 ] ]; - packages.cardano-crypto-praos.components.library.pkgconfig = lib.mkForce [ [ pkgs.libsodium-vrf pkgs.secp256k1 ] ]; - packages.byron-spec-chain.configureFlags = [ "--ghc-option=-Werror" ]; - packages.byron-spec-ledger.configureFlags = [ "--ghc-option=-Werror" ]; - packages.delegation.configureFlags = [ "--ghc-option=-Werror" ]; - packages.non-integral.configureFlags = [ "--ghc-option=-Werror" ]; - packages.cardano-ledger-shelley.configureFlags = [ "--ghc-option=-Werror" ]; - packages.cardano-ledger-shelley-ma.configureFlags = [ "--ghc-option=-Werror" ]; - packages.cardano-ledger-shelley-ma-test.configureFlags = [ "--ghc-option=-Werror" ]; - packages.cardano-ledger-shelley-ma-test.components.tests.cardano-ledger-shelley-ma-test.build-tools = [pkgs.cddl pkgs.cbor-diag]; - packages.small-steps.configureFlags = [ "--ghc-option=-Werror" ]; - packages.cardano-ledger-shelley-test.components.tests.cardano-ledger-shelley-test.build-tools = [pkgs.cddl pkgs.cbor-diag]; - packages.cardano-ledger-alonzo-test.components.tests.cardano-ledger-alonzo-test.build-tools = [pkgs.cddl pkgs.cbor-diag]; - packages.cardano-ledger-babbage-test.components.tests.cardano-ledger-babbage-test.build-tools = [pkgs.cddl pkgs.cbor-diag]; - packages.cardano-ledger-conway-test.components.tests.cardano-ledger-conway-test.build-tools = [pkgs.cddl pkgs.cbor-diag]; - enableLibraryProfiling = profiling; - # Disable doctests for now (waiting for https://github.com/input-output-hk/haskell.nix/pull/427): - packages.small-steps.components.tests.doctests.buildable = lib.mkForce false; - packages.small-steps-test.components.tests.doctests.buildable = lib.mkForce false; - packages.byron-spec-ledger.components.tests.doctests.buildable = lib.mkForce false; - - packages.cardano-ledger-byron = { - configureFlags = [ "--ghc-option=-Werror" ]; - components = { - tests.cardano-ledger-byron-test = { - preCheck = '' - export CARDANO_MAINNET_MIRROR="${cardano-mainnet-mirror}/epochs" - cp ${../eras/byron/ledger/impl/mainnet-genesis.json} ./mainnet-genesis.json - ''; - build-tools = [ pkgs.makeWrapper ]; - testFlags = [ "--scenario=ContinuousIntegration" ]; - }; - }; - }; - - } - ]; - }; -in - pkgSet diff --git a/nix/latex.nix b/nix/latex.nix index 0c6ed6094de..dd18e324f35 100644 --- a/nix/latex.nix +++ b/nix/latex.nix @@ -1,51 +1,59 @@ -{ stdenv, lib, texlive }: { + stdenv, + lib, + texlive, +}: { # Build a latex derivation using latexmk. buildLatex = { texFiles ? [], # The specific tex files to build, will try and build all of them if absent - texInputs ? { inherit (texlive) scheme-small; }, # Tex dependencies as an attrset + texInputs ? {inherit (texlive) scheme-small;}, # Tex dependencies as an attrset buildInputs ? [], # Additional build inputs - ...}@attrs : + ... + } @ attrs: let + tex = texlive.combine (texInputs // {inherit (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 + 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 + latexmk \ + -outdir=${buildDir} \ + -pdf ${toString texFiles} + runHook postBuild + ''; + installPhase = '' + runHook preInstall + mkdir -p $out + install -t $out ${buildDir}/*.pdf - let - tex = texlive.combine (texInputs // { inherit (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 - 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 - 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 - ''; - }); + 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 + ''; + }); # A typical good filter for latex sources. - filterLatex = src: lib.sourceFilesBySuffices src [ - ".tex" ".bib" ".bst" - ".cls" ".sty" - ".jpg" ".png" - ".pdf" - ".pfb" ".enc" - "TODO" - ]; + filterLatex = src: + lib.sourceFilesBySuffices src [ + ".tex" + ".bib" + ".bst" + ".cls" + ".sty" + ".jpg" + ".png" + ".pdf" + ".pfb" + ".enc" + "TODO" + ]; } diff --git a/nix/pkgs.nix b/nix/pkgs.nix index 4a62654a035..418a1d92aa2 100644 --- a/nix/pkgs.nix +++ b/nix/pkgs.nix @@ -1,12 +1,6 @@ -{ sources }: # our packages overlay -pkgs: _: -with pkgs; { - cardanoLedgerSpecsHaskellPackages = import ./haskell.nix { - inherit config lib stdenv pkgs haskell-nix buildPackages; - CHaP = sources.cardano-haskell-packages; - }; - - cbor-diag = pkgs.callPackage ./pkgs/cbor-diag { }; - cddl = pkgs.callPackage ./pkgs/cddl { }; +prev: final: +import ./latex.nix {inherit (final) stdenv lib texlive;} +// { + cddl = final.callPackage ./pkgs/cddl {}; } diff --git a/nix/pkgs/cbor-diag/Gemfile b/nix/pkgs/cbor-diag/Gemfile deleted file mode 100644 index 798e507460e..00000000000 --- a/nix/pkgs/cbor-diag/Gemfile +++ /dev/null @@ -1,2 +0,0 @@ -source 'https://rubygems.org' -gem 'cbor-diag' diff --git a/nix/pkgs/cbor-diag/Gemfile.lock b/nix/pkgs/cbor-diag/Gemfile.lock deleted file mode 100644 index 452c6458fc3..00000000000 --- a/nix/pkgs/cbor-diag/Gemfile.lock +++ /dev/null @@ -1,27 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - cbor-canonical (0.1.2) - cbor-deterministic (0.1.3) - cbor-diag (0.7.6) - cbor-canonical - cbor-deterministic - cbor-packed - json - neatjson - treetop (~> 1) - cbor-packed (0.1.3) - json (2.6.1) - neatjson (0.9) - polyglot (0.3.5) - treetop (1.6.11) - polyglot (~> 0.3) - -PLATFORMS - ruby - -DEPENDENCIES - cbor-diag - -BUNDLED WITH - 2.3.6 diff --git a/nix/pkgs/cbor-diag/default.nix b/nix/pkgs/cbor-diag/default.nix deleted file mode 100644 index 2104d3016cc..00000000000 --- a/nix/pkgs/cbor-diag/default.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ lib, bundlerApp, bundlerUpdateScript }: - -bundlerApp { - pname = "cbor-diag"; - gemdir = ./.; - exes = [ - "cbor2diag.rb" - "cbor2json.rb" - "cbor2pretty.rb" - "cbor2yaml.rb" - "diag2cbor.rb" - "diag2pretty.rb" - "json2cbor.rb" - "json2pretty.rb" - "pretty2cbor.rb" - "pretty2diag.rb" - "yaml2cbor.rb" - ]; -} diff --git a/nix/pkgs/cbor-diag/gemset.nix b/nix/pkgs/cbor-diag/gemset.nix deleted file mode 100644 index 3991023a8f7..00000000000 --- a/nix/pkgs/cbor-diag/gemset.nix +++ /dev/null @@ -1,84 +0,0 @@ -{ - cbor-canonical = { - groups = ["default"]; - platforms = []; - source = { - remotes = ["https://rubygems.org"]; - sha256 = "1fhj51s5d9b9spw096sb0p92bgilw9hrsay383563dh913j2jn11"; - type = "gem"; - }; - version = "0.1.2"; - }; - cbor-deterministic = { - groups = ["default"]; - platforms = []; - source = { - remotes = ["https://rubygems.org"]; - sha256 = "1w1mg4mn1dhlxlbijxpzja8m8ggrjs0hzkzvnaazw9zm1ji6dpba"; - type = "gem"; - }; - version = "0.1.3"; - }; - cbor-diag = { - dependencies = ["cbor-canonical" "cbor-deterministic" "cbor-packed" "json" "neatjson" "treetop"]; - groups = ["default"]; - platforms = []; - source = { - remotes = ["https://rubygems.org"]; - sha256 = "1r84bf00h6lv05l9bb9sj27jl5kbr466qk4i18z3fimn3z62i908"; - type = "gem"; - }; - version = "0.7.6"; - }; - cbor-packed = { - groups = ["default"]; - platforms = []; - source = { - remotes = ["https://rubygems.org"]; - sha256 = "046vj3i603i0skv80cynlqkh3di5419hbsfi10i69pc08wvggk6l"; - type = "gem"; - }; - version = "0.1.3"; - }; - json = { - groups = ["default"]; - platforms = []; - source = { - remotes = ["https://rubygems.org"]; - sha256 = "1z9grvjyfz16ag55hg522d3q4dh07hf391sf9s96npc0vfi85xkz"; - type = "gem"; - }; - version = "2.6.1"; - }; - neatjson = { - groups = ["default"]; - platforms = []; - source = { - remotes = ["https://rubygems.org"]; - sha256 = "0fa2v7b6433j0iqh5iq9r71v7a5xabgjvqwsbl21vcsac7vf3ncw"; - type = "gem"; - }; - version = "0.9"; - }; - polyglot = { - groups = ["default"]; - platforms = []; - source = { - remotes = ["https://rubygems.org"]; - sha256 = "1bqnxwyip623d8pr29rg6m8r0hdg08fpr2yb74f46rn1wgsnxmjr"; - type = "gem"; - }; - version = "0.3.5"; - }; - treetop = { - dependencies = ["polyglot"]; - groups = ["default"]; - platforms = []; - source = { - remotes = ["https://rubygems.org"]; - sha256 = "0697qz1akblf8r3wi0s2dsjh468hfsd57fb0mrp93z35y2ni6bhh"; - type = "gem"; - }; - version = "1.6.11"; - }; -} diff --git a/nix/pkgs/cddl/default.nix b/nix/pkgs/cddl/default.nix index 96d10684e26..96558432b5a 100644 --- a/nix/pkgs/cddl/default.nix +++ b/nix/pkgs/cddl/default.nix @@ -1,7 +1,10 @@ -{ lib, bundlerApp, bundlerUpdateScript }: - +{ + lib, + bundlerApp, + bundlerUpdateScript, +}: bundlerApp { pname = "cddl"; gemdir = ./.; - exes = [ "cddl" ]; + exes = ["cddl"]; } diff --git a/nix/python/sphinx-markdown-tables.nix b/nix/python/sphinx-markdown-tables.nix deleted file mode 100644 index bcec616b2f7..00000000000 --- a/nix/python/sphinx-markdown-tables.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ lib, buildPythonPackage, fetchPypi, markdown }: - -buildPythonPackage rec { - pname = "sphinx-markdown-tables"; - # For some reason the PyPI source for 0.0.15 seems to be missing - version = "0.0.14"; - - src = fetchPypi { - inherit pname version; - sha256 = "16hsh254zjkb7ayhny69v7xpjim35linggadhiiyrnjx0qy8a16n"; - }; - - propagatedBuildInputs = [ markdown ]; - - doCheck = false; - - meta = with lib; { - homepage = "https://github.com/ryanfox/sphinx-markdown-tables"; - description = ""; - maintainers = with maintainers; [ michaelpj ]; - }; -} diff --git a/nix/python/sphinxemoji.nix b/nix/python/sphinxemoji.nix deleted file mode 100644 index ef04796e183..00000000000 --- a/nix/python/sphinxemoji.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ lib, buildPythonPackage, fetchPypi, sphinx }: - -buildPythonPackage rec { - pname = "sphinxemoji"; - # For some reason the PyPI source for 0.0.15 seems to be missing - version = "0.1.6"; - - src = fetchPypi { - inherit pname version; - sha256 = "1s2w8hn9kfcg371l9msn8vnmdjmhih9pc1mhr9i4l0j54xsrgrwf"; - }; - - propagatedBuildInputs = [ sphinx ]; - - doCheck = false; - - meta = with lib; { - homepage = "https://github.com/sphinx-contrib/emojicodes"; - description = ""; - maintainers = with maintainers; [ michaelpj ]; - }; -} diff --git a/nix/sources.json b/nix/sources.json deleted file mode 100644 index e12ab0c8cc9..00000000000 --- a/nix/sources.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "cardano-haskell-packages": { - "branch": "repo", - "description": "Metadata for Cardano's Haskell package repository", - "homepage": "https://input-output-hk.github.io/cardano-haskell-packages/", - "owner": "input-output-hk", - "repo": "cardano-haskell-packages", - "rev": "68d208531849da23244a16388ec921320383c710", - "sha256": "10fb4dcnng0f06yv38fnvcjbnxn5gd72rcpq942wrmbb9p5xyv7d", - "type": "tarball", - "url": "https://github.com/input-output-hk/cardano-haskell-packages/archive/68d208531849da23244a16388ec921320383c710.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "hackage.nix": { - "branch": "master", - "description": "Automatically generated Nix expressions for Hackage", - "homepage": "", - "owner": "input-output-hk", - "repo": "hackage.nix", - "rev": "0ad8858dba2e9a93738dff55062b572aa69271c1", - "sha256": "1aszirkf9kyaxi9ya962p6j2cb1qahrb25ndk0j6xz3av7ll7rnb", - "type": "tarball", - "url": "https://github.com/input-output-hk/hackage.nix/archive/0ad8858dba2e9a93738dff55062b572aa69271c1.tar.gz", - "url_template": "https://github.com///archive/.tar.gz", - "version": "b3c99d7f13df89a9a918c835ecb7114098912962" - }, - "haskell.nix": { - "branch": "master", - "description": "Alternative Haskell Infrastructure for Nixpkgs", - "homepage": "https://input-output-hk.github.io/haskell.nix", - "owner": "input-output-hk", - "repo": "haskell.nix", - "rev": "3c3decc5989603df52655317c9f484cf25300d2f", - "sha256": "15a7328jmwpx2l68ibqchj7k3s926r6nwxvfdyzv8yvnac4wmm8c", - "type": "tarball", - "url": "https://github.com/input-output-hk/haskell.nix/archive/3c3decc5989603df52655317c9f484cf25300d2f.tar.gz", - "url_template": "https://github.com///archive/.tar.gz", - "version": "962ecfed3a4fb656b5a91d89159291e00ed766bc" - }, - "iohk-nix": { - "branch": "master", - "description": "nix scripts shared across projects", - "homepage": null, - "owner": "input-output-hk", - "repo": "iohk-nix", - "rev": "6f1ca44c8bf714df4866e8bf30030a70f55e64e2", - "sha256": "1639clcr9f0l721v10iv9w25xgiwrkidvgyd179x443pc16hfqkh", - "type": "tarball", - "url": "https://github.com/input-output-hk/iohk-nix/archive/6f1ca44c8bf714df4866e8bf30030a70f55e64e2.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "nixpkgs": { - "branch": "nixpkgs-unstable", - "builtin": true, - "description": "Nix Packages collection", - "homepage": "", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "f5dad40450d272a1ea2413f4a67ac08760649e89", - "sha256": "06nq3rn63csy4bx0dkbg1wzzm2jgf6cnfixq1cx4qikpyzixca6i", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/f5dad40450d272a1ea2413f4a67ac08760649e89.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - } -} diff --git a/nix/sources.nix b/nix/sources.nix deleted file mode 100644 index 954ba5a6b64..00000000000 --- a/nix/sources.nix +++ /dev/null @@ -1,149 +0,0 @@ -# This file has been generated by Niv. - -let - - # - # The fetchers. fetch_ fetches specs of type . - # - - fetch_file = pkgs: spec: - if spec.builtin or true then - builtins_fetchurl { inherit (spec) url sha256; } - else - pkgs.fetchurl { inherit (spec) url sha256; }; - - fetch_tarball = pkgs: name: spec: - let - ok = str: ! builtins.isNull (builtins.match "[a-zA-Z0-9+-._?=]" str); - # sanitize the name, though nix will still fail if name starts with period - name' = stringAsChars (x: if ! ok x then "-" else x) "${name}-src"; - in - if spec.builtin or true then - builtins_fetchTarball { name = name'; inherit (spec) url sha256; } - else - pkgs.fetchzip { name = name'; inherit (spec) url sha256; }; - - fetch_git = spec: - builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; }; - - fetch_builtin-tarball = spec: - builtins.trace - '' - WARNING: - The niv type "builtin-tarball" will soon be deprecated. You should - instead use `builtin = true`. - - $ niv modify -a type=tarball -a builtin=true - '' - builtins_fetchTarball { inherit (spec) url sha256; }; - - fetch_builtin-url = spec: - builtins.trace - '' - WARNING: - The niv type "builtin-url" will soon be deprecated. You should - instead use `builtin = true`. - - $ niv modify -a type=file -a builtin=true - '' - (builtins_fetchurl { inherit (spec) url sha256; }); - - # - # Various helpers - # - - # The set of packages used when specs are fetched using non-builtins. - mkPkgs = sources: - let - sourcesNixpkgs = - import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {}; - hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; - hasThisAsNixpkgsPath = == ./.; - in - if builtins.hasAttr "nixpkgs" sources - then sourcesNixpkgs - else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then - import {} - else - abort - '' - Please specify either (through -I or NIX_PATH=nixpkgs=...) or - add a package called "nixpkgs" to your sources.json. - ''; - - # The actual fetching function. - fetch = pkgs: name: spec: - - if ! builtins.hasAttr "type" spec then - abort "ERROR: niv spec ${name} does not have a 'type' attribute" - else if spec.type == "file" then fetch_file pkgs spec - else if spec.type == "tarball" then fetch_tarball pkgs name spec - else if spec.type == "git" then fetch_git spec - else if spec.type == "builtin-tarball" then fetch_builtin-tarball name - else if spec.type == "builtin-url" then fetch_builtin-url name - else - abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; - - # Ports of functions for older nix versions - - # a Nix version of mapAttrs if the built-in doesn't exist - mapAttrs = builtins.mapAttrs or ( - f: set: with builtins; - listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)) - ); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 - range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 - stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 - stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); - concatStrings = builtins.concatStringsSep ""; - - # fetchTarball version that is compatible between all the versions of Nix - builtins_fetchTarball = { url, name, sha256 }@attrs: - let - inherit (builtins) lessThan nixVersion fetchTarball; - in - if lessThan nixVersion "1.12" then - fetchTarball { inherit name url; } - else - fetchTarball attrs; - - # fetchurl version that is compatible between all the versions of Nix - builtins_fetchurl = { url, sha256 }@attrs: - let - inherit (builtins) lessThan nixVersion fetchurl; - in - if lessThan nixVersion "1.12" then - fetchurl { inherit url; } - else - fetchurl attrs; - - # Create the final "sources" from the config - mkSources = config: - mapAttrs ( - name: spec: - if builtins.hasAttr "outPath" spec - then abort - "The values in sources.json should not have an 'outPath' attribute" - else - spec // { outPath = fetch config.pkgs name spec; } - ) config.sources; - - # The "config" used by the fetchers - mkConfig = - { sourcesFile ? ./sources.json - , sources ? builtins.fromJSON (builtins.readFile sourcesFile) - , pkgs ? mkPkgs sources - }: rec { - # The sources, i.e. the attribute set of spec name to spec - inherit sources; - - # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers - inherit pkgs; - }; -in -mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); } diff --git a/nix/stack-shell.nix b/nix/stack-shell.nix deleted file mode 100644 index e9b7287bcfe..00000000000 --- a/nix/stack-shell.nix +++ /dev/null @@ -1,18 +0,0 @@ -# This is the derivation used by "stack --nix". -# It provides the system dependencies required for a stack build. -with import ./. {}; - -haskell.lib.buildStackProject { - name = "stack-env"; - ghc = (import ../shell.nix { inherit pkgs; }).ghc.baseGhc; - - buildInputs = - # Development libraries which may be necessary for the build. - # Add remove libraries as necessary - [ libsodium zlib gmp ncurses lzma openssl git systemd.dev ] ++ - # MacOS-specific librararies which may be necessary for the build. - (lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Cocoa CoreServices libcxx libiconv ])); - - phases = ["nobuildPhase"]; - nobuildPhase = "mkdir -p $out"; -} diff --git a/nix/tullia.nix b/nix/tullia.nix deleted file mode 100644 index 9e813920c95..00000000000 --- a/nix/tullia.nix +++ /dev/null @@ -1,78 +0,0 @@ -{ - config, - inputs, - ... -}: { - imports = [inputs.tullia.flakePartsModules.default]; - - perSystem = {lib, ...}: { - tullia = let - ciInputName = "GitHub Push or PR"; - repository = "input-output-hk/cardano-ledger"; - in rec { - tasks.ci = { - config, - lib, - pkgs, - ... - }: { - preset = { - nix.enable = true; - - github.ci = { - # Tullia tasks can run locally or on Cicero. - # When no facts are present we know that we are running locally - # and vice versa. - # When running locally, the current directory is already - # bind-mounted into the container, so we don't need to fetch the - # source from GitHub and we don't want to report a GitHub status. - enable = config.actionRun.facts != {}; - inherit repository; - remote = config.preset.github.lib.readRepository ciInputName null; - revision = config.preset.github.lib.readRevision ciInputName null; - }; - }; - - command.text = config.preset.github.status.lib.reportBulk { - bulk.text = '' - nix eval .#hydraJobs --apply __attrNames --json | - nix-systems -i - ''; - each.text = ''nix build -L .#hydraJobs."$1".required''; - skippedDescription = - lib.escapeShellArg - "No nix builder available for this system"; - }; - - memory = 1024 * 8; - - nomad = { - resources.cpu = 10000; - - driver = "exec"; - }; - }; - - actions."cardano-ledger/ci" = { - task = "ci"; - io = '' - // This is a CUE expression that defines what events - // trigger a new run of this action. - // There is no documentation for this yet. - // Ask SRE if you have trouble changing this. - - let github = { - #input: "${ciInputName}" - #repo: "${repository}" - } - - #lib.merge - #ios: [ - {#lib.io.github_push, github, #default_branch: true}, - {#lib.io.github_pr, github}, - ] - ''; - }; - }; - }; -} diff --git a/nix/util.nix b/nix/util.nix deleted file mode 100644 index d8bb27d01bf..00000000000 --- a/nix/util.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ haskell-nix }: - -with haskell-nix.haskellLib; -{ - inherit - selectProjectPackages - collectChecks' - collectComponents'; - - inherit (extra) - recRecurseIntoAttrs; -} diff --git a/release.nix b/release.nix deleted file mode 100644 index 46732304cb7..00000000000 --- a/release.nix +++ /dev/null @@ -1,90 +0,0 @@ -############################################################################ -# -# Hydra release jobset. -# -# The purpose of this file is to select jobs defined in default.nix and map -# them to all supported build platforms. -# -############################################################################ - -# The project sources -{ cardano-ledger-specs ? { outPath = ./.; rev = "abcdef"; } - -# Function arguments to pass to the project -, projectArgs ? { - config = { allowUnfree = false; inHydra = true; }; - gitrev = cardano-ledger-specs.rev; - } - -# The systems that the jobset will be built for. -, supportedSystems ? [ "x86_64-linux" "x86_64-darwin" ] - -# The systems used for cross-compiling -, supportedCrossSystems ? [ "x86_64-linux" ] - -# A Hydra option -, scrubJobs ? true - -# Dependencies overrides -, sourcesOverride ? {} - -# Import pkgs, including IOHK common nix lib -, pkgs ? import ./nix { - inherit sourcesOverride; - system = __head supportedSystems; -} - -}: - -with (import pkgs.iohkNix.release-lib) { - inherit pkgs; - inherit supportedSystems supportedCrossSystems scrubJobs projectArgs; - packageSet = import cardano-ledger-specs; - gitrev = cardano-ledger-specs.rev; -}; - -with pkgs.lib; - -let - testsSupportedSystems = [ "x86_64-linux" ]; - buildSupportedSystems = [ "x86_64-linux" "x86_64-darwin" ]; - # Recurse through an attrset, returning all test derivations in a list. - collectJobs' = systems: ds: filter (d: elem d.system systems) (collect isDerivation ds); - # Adds the package name to the test derivations for windows-testing-bundle.nix - # (passthru.identifier.name does not survive mapTestOn) - collectJobs = systems: ds: concatLists ( - mapAttrsToList (packageName: package: - map (drv: drv // { inherit packageName; }) (collectJobs' systems package) - ) ds); - collectTests = collectJobs testsSupportedSystems; - collectBuild = collectJobs buildSupportedSystems; - jobs = { - native = mapTestOn (__trace (__toJSON (packagePlatforms project)) (packagePlatforms project)); - } // (mkRequiredJob ( - collectBuild jobs.native.libs ++ - collectBuild jobs.native.exes ++ - collectTests jobs.native.checks.tests ++ - collectBuild jobs.native.benchmarks ++ - collectBuild jobs.native.specs - )) - - // { - # Collect all spec PDFs, without system suffix. - specs = removeAttrs project.specs ["recurseForDerivations"]; - # Compatibility with old names - byronLedgerSpec = project.specs.byron-ledger; - byronChainSpec = project.specs.byron-chain; - semanticsSpec = project.specs.small-step-semantics; - shelleyLedgerSpec = project.specs.shelley-ledger; - delegationDesignSpec = project.specs.delegation-design; - nonIntegerCalculations = project.specs.non-integer-calculations; - blocksCDDLSpec = project.specs.blocks-cddl; - # Sphinx doc site - docSite = project.doc.site; - # Ensure everything in the shell is cached - shell = project.shell; - # Ensure that the project's eval-time GC roots are built and cached by Hydra - roots = project.roots; - }; - -in jobs diff --git a/scripts/haskell-language-server b/scripts/haskell-language-server index 8819d8bd6e1..1435ada764c 100755 --- a/scripts/haskell-language-server +++ b/scripts/haskell-language-server @@ -1,4 +1,3 @@ -#!/usr/bin/env nix-shell -#! nix-shell ../shell.nix -i bash +#! /usr/bin/env -S nix develop --accept-flake-config -c bash haskell-language-server "$@" diff --git a/scripts/stack-cabal_config_check.sh b/scripts/stack-cabal_config_check.sh deleted file mode 100755 index 8dc1a866d7c..00000000000 --- a/scripts/stack-cabal_config_check.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -set -euo pipefail - -# This script checks that the `stack.yaml` and `cabal.project` files have -# consistent git hashes for the packages they depend on. We use -# `cardano-repo-tool`'s `update-cabal-project` command which modifies -# `cabal.project` to be consistent with `stack.yaml`s versions. If the -# diff is non-empty, we know they're out of sync. - -# Check that functions are defined. -HELP_TEXT="cardano-repo-tool not found. Please add it to your PATH, either\n\n\ -[1] installing it from \ -https://github.com/input-output-hk/cardano-repo-tool\n\ -[2] (usually for CI) using nix-shell from iohk-ops to bring it in scope: \ -https://github.com/input-output-hk/iohk-nix/blob/\ -91febccdb615c365dbbda03a9adcaffbafa57846/docs/buildkite-scripts.md" -type cardano-repo-tool &>/dev/null || { echo "${HELP_TEXT}"; exit 1; } -HELP_TEXT="git not found. Please add it to your PATH" -type git &>/dev/null || { echo "${HELP_TEXT}"; exit 1; } - -# Update `cabal.project` to be consistent. -cardano-repo-tool update-cabal-project - -# This command exits 1 if the diff is non-empty, and 0 if the -# diff is empty. -HELP_TEXT="\`cabal.project\` and \`stack.yaml\` files are not consistent. If \ -\`stack.yaml\` is correct and \`cabal.project\` is out of date, then running \ -\`cardano-repo-tool update-cabal-project\` locally will modify \ -\`cabal.project\` to be consistent. But if \`cabal.project\` is correct and \ -\`stack.yaml\` is out of date, running the aforementioned command will just \ -overwrite \`cabal.project\` with the outdated version from \`stack.yaml\`. \ -Thus, in this case one must manually copy the git hash from \`cabal.project\` \ -to \`stack.yaml\`." -git diff --exit-code || { echo "ERROR:\n${HELP_TEXT}"; exit 1; } diff --git a/shell.nix b/shell.nix index 7a70e0b36e0..9d2b7ab057e 100644 --- a/shell.nix +++ b/shell.nix @@ -1,81 +1,9 @@ -# This file is used by nix-shell. -{ config ? {} -, sourcesOverride ? {} -, withHoogle ? false -, pkgs ? import ./nix { - inherit config sourcesOverride; - } -}: -with pkgs; -let - # For building the sphinx doc - pyEnv = - # TODO: deduplicate with default.nix - let - sphinx-markdown-tables = pkgs.python3Packages.callPackage ./nix/python/sphinx-markdown-tables.nix {}; - sphinxemoji = pkgs.python3Packages.callPackage ./nix/python/sphinxemoji.nix {}; - in pkgs.python3.withPackages (ps: [ ps.sphinx ps.sphinx_rtd_theme ps.recommonmark sphinx-markdown-tables sphinxemoji ]); - - # This provides a development environment that can be used with nix-shell or - # lorri. See https://input-output-hk.github.io/haskell.nix/user-guide/development/ - shell = cardanoLedgerSpecsHaskellPackages.shellFor { - name = "cabal-dev-shell"; - - # These programs will be available inside the nix-shell. - nativeBuildInputs = with haskellPackages; [ - nix-prefetch-git - niv - pkg-config - hlint - pyEnv - implicit-hie - ]; - - tools = { - cabal = "3.10.1.0"; - ghcid = "0.8.8"; - fourmolu = "0.10.1.0"; - haskell-language-server = "1.9.1.0"; - }; - - # Prevents cabal from choosing alternate plans, so that - # *all* dependencies are provided by Nix. - exactDeps = false; - - inherit withHoogle; - shellHook = '' - DEFAULT_PS1="\n\[\033[1;32m\][nix-shell:\w]\$\[\033[0m\] " - prompt() { - local EXIT="$?" - if [ $EXIT != 0 ]; then - PS1="$DEFAULT_PS1\[\033[1;31m\]($EXIT)\[\033[00m\] " - else - PS1="$DEFAULT_PS1" - fi - } - PROMPT_COMMAND=prompt - export LC_ALL="C.UTF-8" - ''; - }; - - devops = pkgs.stdenv.mkDerivation { - name = "devops-shell"; - buildInputs = [ - niv - ]; - shellHook = '' - echo "DevOps Tools" \ - | ${figlet}/bin/figlet -f banner -c \ - | ${lolcat}/bin/lolcat - - echo "NOTE: you may need to export GITHUB_TOKEN if you hit rate limits with niv" - echo "Commands: - * niv update - update package - - " - ''; - }; - -in - - shell // { inherit devops; } +# a non-flake nix compat wrapper using https://github.com/edolstra/flake-compat +# DO NOT EDIT THIS FILE +__trace +'' ************************************************************************************ + Hi there! This project has been moved to nix flakes. You are using the `nix-shell` + compatibility layer. Please consider using `nix develop` instead. + ************************************************************************************ +'' +(import ./nix/flake-compat.nix).shellNix