Skip to content

Moves nix-tools standard templates into iohk-nix #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Feb 4, 2019

Conversation

angerman
Copy link
Contributor

@angerman angerman commented Jan 23, 2019

As such we can now define:

let
  localLib = import ./lib.nix;
in
{ pkgs, ... }@args
localLib.nix-tools.default-nix ./nix/pkgs.nix args // {
    # additional non-haskell packages we want to build on CI.
    byronLedgerSpec = import ./specs/ledger/latex {};
    byronChainSpec = import ./specs/chain/latex {};
    semanticsSpec = import ./specs/semantics/latex {};
}

as default.nix

and

let
  localLib = import ./lib.nix;
in
localLib.nix-tools.release-nix {
  package-set-path = ./.;

  # packages from our stack.yaml or plan file (via nix/pkgs.nix) we
  # are intereted in building on CI via nix-tools.
  packages = [ "cardano-chain" "cs-ledger" "small-steps" "cs-blockchain" ];

  # The set of jobs we consider crutial for each CI run.
  # if a single one of these fails, the build will be marked
  # as failed.
  #
  # The names can be looked up on hydra when in doubt.
  #
  # custom jobs will follow their name as set forth in
  # other-packages.
  #
  # nix-tools packages withh be prefixed with nix-tools and
  # follow the following naming convention:
  #
  #   namespace                      optional cross compilation prefix                 build machine
  #   .-------.                              .-----------------.                .--------------------------.
  #   nix-tools.{libs,exes,tests,benchmarks}.{x86_64-pc-mingw-,}$pkg.$component.{x86_64-linux,x86_64-darwin}
  #             '--------------------------'                    '-------------'
  #                 component type                          cabal pkg and component*
  #
  # * note that for libs, $component is empty, as cabal only
  # provides a single library for packages right now.
  #
  # Example:
  #
  #   libs.cardano-chain.x86_64-darwin -- will build the cardano-chain library on and for macOS
  #   libs.cardano-chain.x86_64-linux -- will build the cardano-chain library on and for linux
  #   libs.x86_64-pc-mingw32-cardano-chain.x86_64-linux -- will build the cardano-chain library on linux for windows.
  #   tests.cs-ledger.ledger-delegation-test.x86_64-linux -- will build and run the ledger-delegation-test from the
  #                                                          cs-ledger package on linux.
  #
  required-name = "cardano-chain-required-checks";
  required-targets = jobs: [
    jobs.byronLedgerSpec
    jobs.byronChainSpec
    jobs.semanticsSpec

    jobs.nix-tools.libs.cs-blockchain.x86_64-darwin
    # ...

    # windows cross compilation targets
    jobs.nix-tools.libs.x86_64-pc-mingw32-cardano-chain.x86_64-linux
    # ...
  ];
}

as release.nix.

@angerman angerman force-pushed the feature/nix-tools-generators branch from f8797f4 to a2c9a3a Compare January 23, 2019 09:39
default.nix Outdated
# default and release templates that abstract
# over the details for CI.
default-nix = import ./nix-tools-default.nix commonLib;
release-nix = import ./nix-tools-release.nix commonLib;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these usable as part of a larger default.nix or release.nix? For example, in the Plutus repo we also have a bunch of latex that's buildable via our top-level default.nix and included in release.nix.

Also, writing a little about how to use these in a README or similar would be good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be perfectly fine to use the default-nix template and just merge it with custom package definitions. The release-nix will still rely on the default.nix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michaelpj does the example (See the PR message atop) suite your needs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good example, do put them somewhere in the actual repository so they're available for future people!

@angerman angerman force-pushed the feature/nix-tools-generators branch from 40ee24c to 420910d Compare January 24, 2019 01:52
@michaelpj
Copy link
Contributor

default.nix example

I'd rather do something like this, does that work?

let localLib = import ./lib.nix;
in {
    nix-tools = import localLib.nix-tools.default-nix ./nix/pkgs.nix {};
    # other stuff
    ...
}

Similarly for the release.nix. Basically, I don't like the inversion of control: if I want to have other non-Haskell stuff I have to pass it in to the nix-tools template. I'd much rather have it be a plain attribute set or something that I can just use normally.

@angerman
Copy link
Contributor Author

angerman commented Jan 24, 2019

@michaelpj maybe I'm misreading you...

if I want to have other non-Haskell stuff I have to pass it in to the nix-tools template. I'd much rather have it be a plain attribute set or something that I can just use normally.

{ pkgs, ... }@args:
localLib.nix-tools.default-nix ./nix/pkgs.nix args // {
    # additional non-haskell packages we want to build on CI.
    byronLedgerSpec = import ./specs/ledger/latex {};
    byronChainSpec = import ./specs/chain/latex {};
    semanticsSpec = import ./specs/semantics/latex {};
}

This is equivalent to

{ pkgs, ... }@args:
{
    inherit (localLib.nix-tools.default-nix ./nix/pkgs.nix args) nix-tools;

    # additional non-haskell packages we want to build on CI.
    byronLedgerSpec = import ./specs/ledger/latex {};
    byronChainSpec = import ./specs/chain/latex {};
    semanticsSpec = import ./specs/semantics/latex {};
}

The slightly annoying but important part is that we pass args to the nix-tools template. Otherwise cross compilation would not work as hydra through release.nix, which will call default.nix with arguments, provides the right arguments and pkgs configuration for cross compilation to work.


Alright, I lied. It's technically equivalent to inherit (localLib.nix-tools.default-nix ./nix/pkgs.nix args) nix-tools _lib;

@michaelpj
Copy link
Contributor

Okay, seems fine, but I'd like to have both documented.

Have a look at the Plutus default.nix to see how much stuff there is in there. Ideally this would replace the haskellPackages bit and leave the rest much the same.

@michaelpj
Copy link
Contributor

Looks like you're still working on this - let me know if you'd like me to have another look.

@jbgi
Copy link
Contributor

jbgi commented Jan 28, 2019

@angerman Should we also include packaging of remote-iserv and friends with this PR? I think it would make sense.

@angerman angerman force-pushed the feature/nix-tools-generators branch from 4dd072e to 340e2ef Compare January 30, 2019 02:48
@angerman
Copy link
Contributor Author

@angerman Should we also include packaging of remote-iserv and friends with this PR? I think it would make sense.

@jbgi yes! yes, we should. Was added in c101f9f.

Copy link
Contributor

@michaelpj michaelpj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine, examples would be great!

As such we can now define:

```
let
  localLib = import ./lib.nix;
in
localLib.nix-tools.default-nix ./nix/pkgs.nix
```
as `default.nix`

and

```
let
  localLib = import ./lib.nix;
in
localLib.nix-tools.release-nix {
  packages = [ "cardano-chain" "cs-ledger" "small-steps" "cs-blockchain" ];
  required-name = "cardano-chain-required-checks";
  other-packages = {
    byronLedgerSpec = import ./specs/ledger/latex {};
    byronChainSpec = import ./specs/chain/latex {};
    semanticsSpec = import ./specs/semantics/latex {};
  };
  package-set-path = ./.;
}
```
as `release.nix`.
This should remove the datadir mismatch when using component builds
with cabal.
@angerman angerman force-pushed the feature/nix-tools-generators branch from 1310a07 to 917e491 Compare February 4, 2019 08:09
@disassembler
Copy link
Collaborator

@angerman good with this, but can we as a follow-up add bors since we're adding CI checks now?

@disassembler disassembler merged commit f9a1654 into master Feb 4, 2019
@disassembler disassembler deleted the feature/nix-tools-generators branch February 4, 2019 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants