Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

basic nix support, builds subkey and provides it to other packages #13713

Closed
wants to merge 2 commits into from

Conversation

dzmitry-lahoda
Copy link

@dzmitry-lahoda dzmitry-lahoda commented Mar 25, 2023

Basic nix support.

  • What does it do?

Builds subkey via nix

  • What important points should reviewers know?

nix run .#subkey, ensure flakes enabled (zero to nix installer is default)

Is there something left for follow-up PRs?
no follow up, so may build other tools if there are later

other usage of nix can be seen here https://github.com/paritytech/zombienet for example

@dzmitry-lahoda dzmitry-lahoda marked this pull request as draft March 25, 2023 18:07
@ggwpez
Copy link
Member

ggwpez commented Mar 25, 2023

Nix usage in the past had the problem that is was got out-dated since there was no CI to check that it still builds.
Maybe a good follow-up would be to add that.

@dzmitry-lahoda dzmitry-lahoda marked this pull request as ready for review March 25, 2023 19:37
@dzmitry-lahoda
Copy link
Author

dzmitry-lahoda commented Mar 25, 2023

@ggwpez as soon as repo will get rust-toolchain.toml will do:

rust-toolchain =
            pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; # by the way, i bet parity breaks people and CI often because toolchain and its components are not in repo

to upgrade cpp deps (clang/protoc/openssl):

nix flake update

any nix run github:paritytech/substrate#subkey or deps via overlays will break as soon as it is outdated, sure I am adding one right now into one chain repo :) so it will be fixed, and that is IF. likely it will not.

likely you used nix before flake, and may be 3 years ago right? that is different these days. and really people use paritytech/substrate/<commit>#subkey inside their flakes, so they will not break as soon as they have it frozen for a while.

and likely subkey will not change its name. and hope will not start doing things like running wasm lightclient with network access:)

also as in PR - gitignore reused.

@dzmitry-lahoda
Copy link
Author

dzmitry-lahoda commented Mar 25, 2023

@ggwpez

I use this in some random project CI. CI will break here.

i doubt modifying parity CI is possible goal now (that needs alignment from parity to them create cachix, etc)

but here it is

env:
  NIX_VERSION: nix-2.13.2
  NIXPKGS_CHANNEL: nixos-22.11
  CACHIX_NAME: paritytech

jobs:
  build-nix:
    name: "build-nix"
    runs-on:
      - ubuntu-latest
    concurrency:
      group: build-nix-${{ github.ref }}
      cancel-in-progress: true
    steps:
      - name: cachix-install-nix-action
        uses: cachix/install-nix-action@be4cef7b776998e97233d6e0b84c538eb8122d76
        with:
          install_url: https://releases.nixos.org/nix/${{ env.NIX_VERSION }}/install
          nix_path: nixpkgs=channel:${{ env.NIXPKGS_CHANNEL }}
          extra_nix_config: |
            sandbox = relaxed
            narinfo-cache-negative-ttl = 0      
            system-features = kvm
            http2 = true
      - name: cachix-cachix-action
        uses: cachix/cachix-action@298387a7aea14d6564aa5d6ead79272878339c8b
        with:
          authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
          name: ${{ env.CACHIX_NAME }}
      - name: nix-channel-env
        run: |  
          nix-channel --add https://nixos.org/channels/${{ env.NIXPKGS_CHANNEL }} nixpkgs
          nix-channel --update
          nix profile install nixpkgs#git
      - uses: actions/checkout@v3
        with:
          ref: ${{ github.event.pull_request.head.sha }}
          persist-credentials: false
      - run: |          
          mkdir out
          nix build .#subkey --print-build-logs --show-trace --no-update-lock-file

also flakes allow to fully evaluate but not build to avoid nix rot, but that is for huge repos. so nix breaks much less these days.

@dzmitry-lahoda
Copy link
Author

dzmitry-lahoda commented Mar 25, 2023

@ggwpez

Follow up likely would be replace in chains which nix substrate/polkadot/cumulus stuff to reuse env/lib/rust setup (hence adding something like pkgs.subnix overlay with it. Long term followup are zombienet networks nixified (sure polkadot/cumulus nodes to be nixified too - already in composable - just no PRed), but that is not where I need solutions now. Really need more smoldot.

@dzmitry-lahoda
Copy link
Author

@ggwpez i am not agains CI PR sure, but that could be out of scope for Parity to merge it now? so nixified subkey tool is nice regardless imho. you can onliner it it on nixos ;)

@ggwpez
Copy link
Member

ggwpez commented Mar 27, 2023

@ggwpez i am not agains CI PR sure, but that could be out of scope for Parity to merge it now? so nixified subkey tool is nice regardless imho. you can onliner it it on nixos ;)

Yes sure it is out of scope.

I personally dont use nix/flake, so cant approve. But maybe @bkchr can 😄

@dzmitry-lahoda
Copy link
Author

oh, there was some #13706 . imho nix should be in root to cover tools too ;)

@bkchr bkchr requested a review from andresilva April 9, 2023 22:49
@stale
Copy link

stale bot commented May 10, 2023

Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the A3-stale label May 10, 2023
@dzmitry-lahoda
Copy link
Author

I will fix it once per comments. Hope Parity will be able to review this time to 2 core devs (I start feeling bearish :( btw, not only this PR but some awesome otherrs ) . Cosmos and Ethereum already awesomly nixified. So unlike them, Substrate is of too high ABI/API fidelity, so cannot make it in outer repo without being all the time broken.

@stale stale bot removed the A3-stale label May 10, 2023
Copy link
Contributor

@andresilva andresilva left a comment

Choose a reason for hiding this comment

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

Thanks for the PR and really sorry for this not getting merged sooner. I started making some suggestions but they became too much to add here, so here's a commit with all my proposed changes: b8c4f7c. Some are just style nits, but some other changes make the definition simpler (like using bindgenHook instead of manually setting up clang), feel free to include whatever you think makes sense.

Comment on lines +57 to +58
cargo = pkgs.rust-bin.beta.latest.default;
rustc = pkgs.rust-bin.beta.latest.default;
Copy link
Contributor

@andresilva andresilva May 17, 2023

Choose a reason for hiding this comment

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

stable works as well, and we could even use the rust toolchain from nixpkgs directly (that's what I use to build subkey on my computer).

@andresilva andresilva added B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. labels May 26, 2023
@andresilva
Copy link
Contributor

@dzmitry-lahoda could you fix the conflicts so that this can be merged? I can't push to your branch.

@stale
Copy link

stale bot commented Jun 25, 2023

Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the A3-stale label Jun 25, 2023
@stale stale bot closed this Jul 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A3-stale B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants