Skip to content
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

Ability to make SDK versions from GitHub releases #6

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
f75bbee
Ability to make SDK versions from GitHub releases
paulyoung Apr 1, 2022
0692551
Expose makeVersionFromGitHubRelease
paulyoung Apr 1, 2022
cee7a77
Try not patching binaries from GitHub releases
paulyoung Apr 1, 2022
7229d60
Fix condition
paulyoung Apr 1, 2022
df3c80e
Revert "Fix condition"
paulyoung Apr 1, 2022
46ad20f
Revert "Try not patching binaries from GitHub releases"
paulyoung Apr 1, 2022
738d6c3
Debugging
paulyoung Apr 1, 2022
ebbdcf8
Debugging
paulyoung Apr 1, 2022
412b54a
Remove echos
paulyoung Apr 1, 2022
7467a29
Change basic example to use latest GitHub release
paulyoung Apr 1, 2022
27b35fe
Try using a newer version of patchelf
paulyoung Apr 1, 2022
1088eea
Revert "Try using a newer version of patchelf"
paulyoung Apr 1, 2022
36dd537
Try updating nixpkgs with newer patchelf instead
paulyoung Apr 1, 2022
0b4014e
Revert "Try updating nixpkgs with newer patchelf instead"
paulyoung Apr 1, 2022
e4aa9df
Don't patch ELF in the fixup phase (on Linux)
paulyoung Apr 1, 2022
b270a94
Update lock file
paulyoung Apr 1, 2022
2ded11e
Skip the fixup phase altogether
paulyoung Apr 1, 2022
f7f2085
Update lock file
paulyoung Apr 1, 2022
b2284e4
Set up matrix of versions
paulyoung Apr 1, 2022
48a27cb
Try not patching unarchived binaries at all
paulyoung Apr 1, 2022
d2d0bef
Update name
paulyoung Apr 1, 2022
d1187b8
Attempt to fix interpolation
paulyoung Apr 1, 2022
23fff93
Qualify version
paulyoung Apr 1, 2022
968e794
Fix name
paulyoung Apr 1, 2022
b6ffaa9
Revert "Try not patching unarchived binaries at all"
paulyoung Apr 1, 2022
d7380a0
Don't patch unarchived binaries in GitHub releases
paulyoung Apr 1, 2022
543c76a
Fix inverted logic
paulyoung Apr 1, 2022
18e68c7
Patch specific versions
paulyoung Apr 1, 2022
f0f5a88
Keep flake example simple, add CI example
paulyoung Apr 1, 2022
23a1868
Try patching unarchived binaries in 0.9.2
paulyoung Apr 1, 2022
9c89a41
Don't cancel other jobs when one fails
paulyoung Apr 1, 2022
98714a6
Remove conditional patching
paulyoung Apr 1, 2022
baa431b
Add other versions to the matrix out of interest
paulyoung Apr 1, 2022
0957dd6
Fix version
paulyoung Apr 1, 2022
3159eef
Change example versions
paulyoung Apr 1, 2022
226ce77
Update SDK versions
paulyoung Apr 1, 2022
07f36b9
Try not patching binaries again
paulyoung Apr 1, 2022
6302e1e
Revert "Try not patching binaries again"
paulyoung Apr 1, 2022
3284a4a
Try methodically patching problematic binaries
paulyoung Apr 1, 2022
bacccf4
Revert "Try methodically patching problematic binaries"
paulyoung Apr 1, 2022
11e33c9
[WIP]
paulyoung Oct 23, 2022
c415157
[WIP]
paulyoung Oct 23, 2022
6a6243a
[WIP]
paulyoung Oct 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ on:
push:
jobs:
nix:
name: Build flake example on ${{ matrix.os }}
name: ${{matrix.version}} on ${{matrix.os}}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
version: [0.8.4, 0.9.3, 0.10.101]
runs-on: ${{matrix.os}}
steps:
- uses: actions/[email protected]
- uses: cachix/install-nix-action@v15
- run: cd examples/flake && nix build --show-trace
- run: cd examples/ci && nix build '.#"${{matrix.version}}"' --show-trace
101 changes: 63 additions & 38 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let
then "x86_64-darwin"
else sdkSystem;

makeVersion = { systems, version }: (
makeVersion = { systems, url, version }: (
if !acceptLicenseAgreement then
error (builtins.concatStringsSep "\n" [
""
Expand All @@ -32,14 +32,7 @@ let
then systems.${resolvedSystem}.sha256
else error ("unsupported system: " + resolvedSystem);
stripRoot = false;
url = builtins.concatStringsSep "/" [
"https://sdk.dfinity.org"
"downloads"
"dfx"
version
"${resolvedSystem}"
"dfx-${version}.tar.gz"
];
url = url;
};
nativeBuildInputs = [
self.makeWrapper
Expand Down Expand Up @@ -81,75 +74,107 @@ let
ln -s $CACHE_DIR/$binary $out/bin/$binary
done

wrapProgram $CACHE_DIR/dfx --set DFX_CONFIG_ROOT $out
wrapProgram $CACHE_DIR/dfx --set DFX_CACHE_ROOT $out --set DFX_CONFIG_ROOT $TMP
rm $out/bin/dfx
ln -s $CACHE_DIR/dfx $out/bin/dfx
'';
dontFixup = true;
system = resolvedSystem;
inherit version;
}
);

sdk-0_6_21 = makeVersion {
systems = {
"x86_64-darwin" = {
sha256 = "0i92rwk5x13q7f7nyrgc896w2mlbk63lkgmlrvmyciwbggjiv4pc";
};
"x86_64-linux" = {
sha256 = "06akn065x7vaqy56v5jn551zbw5a0wfxvn13q0hpskm2iwrwrpnb";
};
};
version = "0.6.21";
};
buildFromGitHub = { commit, ... }@args:
self.lib.fetchFromGitHub {
owner = "dfinity";
repo = "sdk";
rev = "f4e24bfee825b4023f85123583f470fc1846008d";
# sha256 = "FIXME";
sha256 = self.lib.fakeSha256;
}
;

makeVersionFromGitHubRelease = { version, ... }@args:
makeVersion (args // {
url = builtins.concatStringsSep "/" [
"https://github.com"
"dfinity"
"sdk"
"releases"
"download"
version
"dfx-${version}-${resolvedSystem}.tar.gz"
];
})
;

sdk-0_7_0-beta_8 = makeVersion {
makeVersionFromManifest = { version, ... }@args:
makeVersion (args // {
url = builtins.concatStringsSep "/" [
"https://sdk.dfinity.org"
"downloads"
"dfx"
version
"${resolvedSystem}"
"dfx-${version}.tar.gz"
];
})
;

sdk-0_8_4 = makeVersionFromManifest {
systems = {
"x86_64-darwin" = {
sha256 = "19zq8n5ahqmbyp1bvhzv06zfaimxyfgzvanwfkf5px7gb1jcqf0m";
sha256 = "JJzZzUJtrgmKJdxXGVJedhP5t9maxh3YjIq1xhTcvfU=";
};
"x86_64-linux" = {
sha256 = "0nl29155076k23fx1j0zb92cr4p0dh8fk5cnjr67dy3nwlbygh3x";
sha256 = "yht96jUJ8gTK5Ual1ofItyRBnQ+qIrbk0lOlefu/L7I=";
};
};
version = "0.7.0-beta.8";
version = "0.8.4";
};

sdk-0_8_4 = makeVersion {
sdk-0_9_3 = makeVersionFromManifest {
systems = {
"x86_64-darwin" = {
sha256 = "JJzZzUJtrgmKJdxXGVJedhP5t9maxh3YjIq1xhTcvfU=";
sha256 = "NMsETjzuZRVbnZ9slCmlHszB3GVrNGHBTKOZ6Y7EMEg=";
};
"x86_64-linux" = {
sha256 = "yht96jUJ8gTK5Ual1ofItyRBnQ+qIrbk0lOlefu/L7I=";
sha256 = "wuuPDC34nrFc/eUdAownsb/FQ3/C7UXh4phzwZf0yQs=";
};
};
version = "0.8.4";
version = "0.9.3";
};

sdk-0_9_2 = makeVersion {
sdk-0_10_101 = makeVersionFromGitHubRelease {
systems = {
"x86_64-darwin" = {
# sha256 = self.lib.fakeSha256;
sha256 = "UITKzQ9XzlsyO4DU72Ah2VH8736eQeW8GL6hzJHTaYA=";
sha256 = "YspeY5M87yRwm2iild0aMOTpVz75TKDrb5wEl6co7vI=";
};
"x86_64-linux" = {
# sha256 = self.lib.fakeSha256;
sha256 = "41NP4AGp5Ve1Srm9a2jweOEEu6iKDGJEBr+SYtrqUSM=";
sha256 = "OI2m4KHsVEpOnAqZRo6BXB7rK0B8ra+w5f/h1zBtfb0=";
};
};
version = "0.9.2";
version = "0.10.101";
};

# https://sdk.dfinity.org/manifest.json
versions = {
latest = sdk-0_8_4;
"0.6.21" = sdk-0_6_21;
"0.7.0-beta.8" = sdk-0_7_0-beta_8;
#latest = sdk-0_9_3;
latest = sdk-0_10_101;
"0.8.4" = sdk-0_8_4;
"0.9.2" = sdk-0_9_2;
"0.9.3" = sdk-0_9_3;
"0.10.101" = sdk-0_10_101;
};
in
versions // { inherit makeVersion; }
versions // {
inherit
makeVersion
makeVersionFromGitHubRelease
makeVersionFromManifest
;
}
);
in
{
Expand Down
1 change: 1 addition & 0 deletions examples/basic/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(import ./release.nix).build
10 changes: 10 additions & 0 deletions examples/basic/dfx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"version": 1,
"dfx": "0.10.101",
"networks": {
"local": {
"bind": "127.0.0.1:8000",
"type": "ephemeral"
}
}
}
30 changes: 28 additions & 2 deletions examples/basic/release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,33 @@ let
overlays = import ./nix/overlays.nix;
};

shell = { version ? "0.8.4", system ? builtins.currentSystem }:
build = { version ? "0.9.3", system ? builtins.currentSystem }:
let
dfinitySdk = pkgs.dfinity-sdk {
acceptLicenseAgreement = true;
sdkSystem = system;
};
in
pkgs.runCommand "ci" {
nativeBuildInputs = [
pkgs.jq
];
buildInputs = [
dfinitySdk."${version}"
pkgs.nodejs-12_x
];
} ''
trap "dfx stop" EXIT
jq '.dfx = "${version}"' ${./dfx.json} > dfx.json
dfx start --background --host 127.0.0.1:0
WEBSERVER_PORT=$(cat .dfx/webserver-port)
# dfx deploy --network "http://127.0.0.1:$WEBSERVER_PORT"
dfx stop
touch $out
''
;

shell = { version ? "0.9.3", system ? builtins.currentSystem }:
let
dfinitySdk = pkgs.dfinity-sdk {
acceptLicenseAgreement = true;
Expand All @@ -18,5 +44,5 @@ let
};
in
{
inherit shell;
inherit build shell;
}
10 changes: 10 additions & 0 deletions examples/ci/dfx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"version": 1,
"dfx": "0.10.101",
"networks": {
"local": {
"bind": "127.0.0.1:8000",
"type": "ephemeral"
}
}
}
56 changes: 56 additions & 0 deletions examples/ci/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions examples/ci/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/21.11";
flake-utils.url = "github:numtide/flake-utils";
dfinity-sdk = {
# url = "github:paulyoung/nixpkgs-dfinity-sdk";
url = "../../";
flake = false;
};
};

outputs = { self, nixpkgs, flake-utils, dfinity-sdk }:
flake-utils.lib.eachSystem ["aarch64-darwin" "x86_64-darwin" "x86_64-linux"] (
system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
(final: prev: (import dfinity-sdk) final prev)
];
};

dfinitySdk = (pkgs.dfinity-sdk {
acceptLicenseAgreement = true;
sdkSystem = system;
});

mkPackage = version:
pkgs.runCommand "ci" {
nativeBuildInputs = [
pkgs.jq
];
buildInputs = [
dfinitySdk."${version}"
];
} ''
trap "dfx stop" EXIT
jq '.dfx = "${version}"' ${./dfx.json} > dfx.json
dfx start --background --host 127.0.0.1:0
WEBSERVER_PORT=$(cat .dfx/webserver-port)
# dfx deploy --network "http://127.0.0.1:$WEBSERVER_PORT"
dfx stop
touch $out
''
;

drvs =
pkgs.lib.attrsets.filterAttrs
(_name: value: pkgs.lib.attrsets.isDerivation value)
dfinitySdk
;
in
rec {
# `nix build`
defaultPackage = packages."0.10.101";

packages =
pkgs.lib.attrsets.mapAttrs
(name: _value: mkPackage name)
drvs
;

# `nix develop`
devShell = pkgs.mkShell {
buildInputs = [
dfinitySdk.latest
];
};
}
);
}
19 changes: 18 additions & 1 deletion examples/flake/dfx.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
{
"version": 1,
"dfx": "0.8.4",
"dfx": "0.11.2",
"canisters": {
"internet_identity": {
"type": "custom",
"wasm": "result-remote/internet_identity/internet_identity_dev.wasm",
"candid": "result-remote/internet_identity/internet_identity.did",
"remote": {
"id": {
"ic": "rdmx6-jaaaa-aaaaa-aaadq-cai"
}
}
}
},
"ic": {
"providers": [
"https://ic0.app"
]
},
"networks": {
"local": {
"bind": "127.0.0.1:8000",
Expand Down
Loading