Skip to content

Commit

Permalink
Add flake packages (#15)
Browse files Browse the repository at this point in the history
* add flake packages
* add solcPackages collection
  • Loading branch information
hellwolf authored Aug 20, 2024
1 parent d1f3090 commit 9630767
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,15 @@ jobs:
- name: Test Default Shell
run: |
set -x
# test `nix develop`
nix develop .# --command -- bash -c "solc-0.8.26 --version"
# overriding flake input is needed as a workaround to local sub flake with overlapping paths.
# test `nix shell`
nix shell .#solc_0_8_19
# test solc.nix as input to other flakes
# Note: overriding flake input is needed as a workaround to local sub flake with overlapping paths.
nix develop ./test/.# --override-input solc $PWD --command -- bash -c "solc --version"
nix develop ./test/.# --override-input solc $PWD --command -- bash -c "solc-0.8.26 --version"
ci-check-success:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Version: 0.8.19+commit.7dd6d404.Linux.g++
You can also use `nix shell` directly without having to write a nix flake for a project.

```
# Solc packages are listed as "solc_{version}" directly,
nix shell github:hellwolf/solc.nix#solc_0_4_26 github:hellwolf/solc.nix#solc_0_8_19
```

Expand Down
4 changes: 4 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
{
# default shell with the latest solc compiler
devShells.default = pkgs.mkShell { buildInputs = [ pkgs.solc_0_8_26 ]; };

# export all solc packages
packages = pkgs.solcPackages;
solcPackages = pkgs.solcPackages;
}
)
// {
Expand Down
33 changes: 18 additions & 15 deletions mk-solc-pkgs.nix
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
pkgs:
{ solc-macos-amd64-list }:

builtins.foldl' (
all_binaries: binary:
let
pname = "solc_" + (builtins.replaceStrings [ "." ] [ "_" ] binary.version);
maybeSolc = import ./mk-solc-static-pkg.nix (
pkgs
// {
solc_ver = binary.version;
solc_sha256 = binary.sha256;
inherit solc-macos-amd64-list;
}
);
in
if maybeSolc != null then all_binaries // { "${pname}" = maybeSolc; } else all_binaries
) { } (import ./solc-listing.nix)
let
solcPackages = builtins.foldl' (
allBinaries: binary:
let
pname = "solc_" + (builtins.replaceStrings [ "." ] [ "_" ] binary.version);
maybeSolc = import ./mk-solc-static-pkg.nix (
pkgs
// {
solc_ver = binary.version;
solc_sha256 = binary.sha256;
inherit solc-macos-amd64-list;
}
);
in
if maybeSolc != null then allBinaries // { "${pname}" = maybeSolc; } else allBinaries
) { } (import ./solc-listing.nix);
in
solcPackages // { inherit solcPackages; }

0 comments on commit 9630767

Please sign in to comment.