-
Notifications
You must be signed in to change notification settings - Fork 13
feat: multi system #4
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
Changes from 15 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
9ef0aa6
add flake; make derivations multi-system
0xPlish ba0faab
add flake
0xPlish 31eecc8
Use oxalica overlay; add packages from local
0xPlish b934b76
formatting
0xPlish 154a68f
chore: formatting
Karrq 00943d2
feat: migrate to crane
Karrq 0ce8905
fix(anchor-cli): patch before dep crate is built
Karrq 874ab45
fix(anchor): pre-patch sources
Karrq 17317e1
fix(solana): restore appended flags
Karrq 4a9a537
fix(platform-tools): avoid stripping rlib files
Karrq 8276511
fix(platform-tools): support all target systems
Karrq 15d5251
feat(anchor-cli): support v0.30.1
Karrq faa0d12
feat(platform-tools): multiversion
Karrq db9a53c
feat(anchor): use appropriate platform-tools ver
Karrq de4ff49
refactor(anchor-cli): versionsDeps
Karrq 539973b
fix(platform-tools): 1.43 hashes
Karrq 6258956
style(tree): nixfmt-tree
Karrq 669a840
deps: match inputs to locked from niv
Karrq ceca6ef
feat: flake-compat
Karrq a46d03d
feat(flake): export overlay
Karrq 1a9aa46
refactor: use flake-compat for pkgs.nix
Karrq 6a356d7
style: remove unnecessary imports
Karrq e5c5300
feat(ci): initial workflow
Karrq d25d43c
fix(ci): run against `master`
Karrq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,65 +1,97 @@ | ||
| { stdenv | ||
| , darwin | ||
| , fetchFromGitHub | ||
| , lib | ||
| , libgcc | ||
| , pkg-config | ||
| , protobuf | ||
| , makeRustPlatform | ||
| , makeWrapper | ||
| , solana-platform-tools | ||
| , rust-bin | ||
| , udev | ||
| }: | ||
| let | ||
| # nixpkgs 24.11 defaults to Rust v1.82.0 | ||
| # Anchor does not declare a rust-toolchain, so we do it here -- the code | ||
| # mentions Rust 1.85.0 at https://github.com/coral-xyz/anchor/blob/c509618412e004415c7b090e469a9e4d5177f642/docs/content/docs/installation.mdx?plain=1#L31 | ||
| rustPlatform = makeRustPlatform { | ||
| cargo = rust-bin.stable."1.85.0".default; | ||
| rustc = rust-bin.stable."1.85.0".default; | ||
| }; | ||
| in | ||
| rustPlatform.buildRustPackage rec { | ||
| { | ||
| stdenv, | ||
| darwin, | ||
| fetchFromGitHub, | ||
| lib, | ||
| pkg-config, | ||
| protobuf, | ||
| makeWrapper, | ||
| solana-platform-tools, | ||
| rust-bin, | ||
| udev, | ||
| crane, | ||
| version ? "0.31.0", | ||
| }: let | ||
| pname = "anchor-cli"; | ||
| version = "0.31.0"; | ||
|
|
||
| doCheck = false; | ||
| versionsDeps = { | ||
| "0.31.0" = { | ||
| hash = "sha256-CaBVdp7RPVmzzEiVazjpDLJxEkIgy1BHCwdH2mYLbGM="; | ||
| rust = rust-bin.stable."1.85.0".default; | ||
| platform-tools = solana-platform-tools.override {version = "1.45";}; | ||
| patches = [./patches/anchor-cli/0.31.0.patch]; | ||
| }; | ||
| "0.30.1" = { | ||
| hash = "sha256-3fLYTJDVCJdi6o0Zd+hb9jcPDKm4M4NzpZ8EUVW/GVw="; | ||
| rust = rust-bin.stable."1.78.0".default; | ||
| platform-tools = solana-platform-tools.override {version = "1.43";}; | ||
| patches = [./patches/anchor-cli/0.30.1.patch]; | ||
| }; | ||
| }; | ||
| versionDeps = versionsDeps.${version}; | ||
|
|
||
| nativeBuildInputs = [ protobuf pkg-config makeWrapper ]; | ||
| buildInputs = [ ] | ||
| ++ lib.optionals stdenv.isLinux [ udev ] | ||
| ++ lib.optional | ||
| stdenv.isDarwin [ | ||
| darwin.apple_sdk.frameworks.CoreFoundation | ||
| ]; | ||
| craneLib = | ||
| crane.overrideToolchain | ||
| versionDeps.rust; | ||
|
|
||
| src = fetchFromGitHub { | ||
| originalSrc = fetchFromGitHub { | ||
| owner = "coral-xyz"; | ||
| repo = "anchor"; | ||
| rev = "v${version}"; | ||
| hash = "sha256-CaBVdp7RPVmzzEiVazjpDLJxEkIgy1BHCwdH2mYLbGM="; | ||
| hash = versionDeps.hash; | ||
| }; | ||
|
|
||
| cargoLock = { | ||
| lockFile = "${src.outPath}/Cargo.lock"; | ||
| allowBuiltinFetchGit = true; | ||
| }; | ||
| src = stdenv.mkDerivation { | ||
| name = "anchor-cli-patched"; | ||
| src = originalSrc; | ||
|
|
||
| # Apply the patch | ||
| phases = ["unpackPhase" "patchPhase" "installPhase"]; | ||
| patches = versionDeps.patches; | ||
|
|
||
| patches = [ | ||
| ./anchor-cli.patch | ||
| ]; | ||
| # Install the patched source as an output | ||
| installPhase = '' | ||
| runHook preInstall | ||
| mkdir -p $out | ||
| cp -r ./* $out/ | ||
| runHook postInstall | ||
| ''; | ||
| }; | ||
|
|
||
| # Ensure anchor has access to Solana's cargo and rust binaries | ||
| postInstall = '' | ||
| rust=${solana-platform-tools}/bin/platform-tools-sdk/sbf/dependencies/platform-tools/rust/bin | ||
| wrapProgram $out/bin/anchor \ | ||
| --prefix PATH : "$rust" | ||
| ''; | ||
| commonArgs = { | ||
| inherit pname version src; | ||
|
|
||
| buildAndTestSubdir = "cli"; | ||
| strictDeps = true; | ||
| doCheck = false; | ||
|
|
||
| meta = { | ||
| description = "Anchor cli"; | ||
| nativeBuildInputs = [protobuf pkg-config makeWrapper]; | ||
| buildInputs = | ||
| [] | ||
| ++ lib.optionals stdenv.isLinux [udev] | ||
| ++ lib.optional stdenv.isDarwin | ||
| [darwin.apple_sdk.frameworks.CoreFoundation]; | ||
| }; | ||
| } | ||
|
|
||
| cargoArtifacts = craneLib.buildDepsOnly commonArgs; | ||
| in | ||
| craneLib.buildPackage (commonArgs | ||
| // { | ||
| inherit cargoArtifacts; | ||
|
|
||
| # Ensure anchor has access to Solana's cargo and rust binaries | ||
| postInstall = '' | ||
| rust=${versionDeps.platform-tools}/bin/platform-tools-sdk/sbf/dependencies/platform-tools/rust/bin | ||
| wrapProgram $out/bin/anchor \ | ||
| --prefix PATH : "$rust" | ||
| ''; | ||
|
|
||
| cargoExtraArgs = "-p ${pname}"; | ||
|
|
||
| meta = { | ||
| description = "Anchor cli"; | ||
| }; | ||
|
|
||
| passthru = { | ||
| otherVersions = builtins.attrNames versionsDeps; | ||
| }; | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| { | ||
| description = "Solana development setup with Nix."; | ||
| inputs = { | ||
| nixpkgs.url = "github:nixos/nixpkgs/c5e2528c7c4ec05ce05a563e3be64f3525b278ad"; | ||
|
Karrq marked this conversation as resolved.
Outdated
|
||
| flake-parts.url = "github:hercules-ci/flake-parts/f4330d22f1c5d2ba72d3d22df5597d123fdb60a9"; | ||
| rust-overlay.url = "github:oxalica/rust-overlay/87f0965f9f5b13fca9f38074eee8369dc767550d"; | ||
| crane.url = "github:ipetkov/crane"; | ||
| }; | ||
| outputs = inputs @ { | ||
| self, | ||
| nixpkgs, | ||
| flake-parts, | ||
| rust-overlay, | ||
| crane, | ||
| }: | ||
| flake-parts.lib.mkFlake {inherit inputs;} { | ||
| systems = [ | ||
| "x86_64-linux" | ||
| "aarch64-linux" | ||
| "x86_64-darwin" | ||
| "aarch64-darwin" | ||
| "x86_64-windows" | ||
|
Karrq marked this conversation as resolved.
|
||
| ]; | ||
| perSystem = { | ||
| config, | ||
| self', | ||
| inputs', | ||
| pkgs, | ||
| system, | ||
| ... | ||
| }: | ||
| with import nixpkgs { | ||
| inherit system; | ||
| overlays = [rust-overlay.overlays.default]; | ||
| }; let | ||
| solana-source = callPackage (import ./solana-source.nix) {}; | ||
| solana-platform-tools = callPackage (import ./solana-platform-tools.nix) { | ||
| inherit solana-source; | ||
| }; | ||
| solana-rust = callPackage (import ./solana-rust.nix) { | ||
| inherit solana-platform-tools; | ||
| }; | ||
| solana-cli = callPackage (import ./solana-cli.nix) { | ||
| inherit solana-platform-tools solana-source; | ||
| crane = crane.mkLib pkgs; | ||
| }; | ||
| anchor-cli = callPackage (import ./anchor-cli.nix) { | ||
| inherit solana-platform-tools; | ||
| crane = crane.mkLib pkgs; | ||
| }; | ||
| in { | ||
| devShells.default = mkShell { | ||
| packages = [anchor-cli solana-cli solana-rust yarn nodejs]; | ||
| }; | ||
|
|
||
| packages = {inherit anchor-cli solana-cli solana-platform-tools solana-rust;}; | ||
| }; | ||
| }; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.