dfinity / sns-testing

Testing SNS in local testing environment
Apache License 2.0
9 stars 12 forks source link

support Nix #21

Closed mraszyk closed 1 year ago

mraszyk commented 1 year ago

This PR prepares sns-testing to support Nix:

aterga commented 1 year ago

Notes while trying out the Nix solution:

aterga commented 1 year ago

There's an issue while running the following step inside nix-shell:

[nix-shell:~/sns-testing]$ ./setup_locally.sh
...
sns_swap has no canister id for network 'ic'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 19528  100 19528    0     0   544k      0 --:--:-- --:--:-- --:--:--  544k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 15498  100 15498    0     0   504k      0 --:--:-- --:--:-- --:--:--  504k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  207k    0  207k    0     0   730k      0 --:--:-- --:--:-- --:--:--  730k
error: Found argument '--specified-id' which wasn't expected, or isn't valid in this context

    If you tried to supply `--specified-id` as a value rather than a flag, use `-- --specified-id`

USAGE:
    dfx canister create --network <NETWORK> --no-wallet <CANISTER_NAME>

For more information try --help

Note:

${DFX} --version
dfx 0.13.1

Maybe we need to bump the DFX version?

mraszyk commented 1 year ago

Could you please share what which dfx prints inside the nix-shell. I suspect that you still have dfx 0.13.1 in your bin folder and this take precedence over dfx 0.14.0 pinned by Nix. On the other hand, we cannot remove the bin folder from the PATH in general because it's still required inside Docker. Moreover, the instructions assume that you clone the repository so it sounds weird to say that you make sure the bin folder is empty.

mraszyk commented 1 year ago

Notes while trying out the Nix solution:

  • Entering nix-shell for the first time takes a lot of time (ca. 30 min). This should be indicated in the instructions.
  • The section for Docker should precede the (more experimental) Nix instructions; there should be a forward reference to the Nix instructions for Apple Silicon users.
  • The anchor to #apple-silicon seems broken. The local hyperlink doesn't work.

Fixed.

aterga commented 1 year ago

Could you please share what which dfx prints inside the nix-shell. I suspect that you still have dfx 0.13.1 in your bin folder and this take precedence over dfx 0.14.0 pinned by Nix. On the other hand, we cannot remove the bin folder from the PATH in general because it's still required inside Docker. Moreover, the instructions assume that you clone the repository so it sounds weird to say that you make sure the bin folder is empty.

If I enter a nix-shell, then I get

[nix-shell:~/sns-testing]$ which $DFX

[nix-shell:~/sns-testing]$ which dfx
/nix/store/rp6ql01zkjxkrldl36yhgrd0h2aafvs6-dfx-env/bin/dfx

however, when I run source ./constants.sh normal, I get

[nix-shell:~/sns-testing]$ which $DFX
/home/arshavir/sns-testing/bin/dfx

[nix-shell:~/sns-testing]$ which dfx
/home/arshavir/sns-testing/bin/dfx

Note also that

[nix-shell:~/sns-testing]$ /nix/store/rp6ql01zkjxkrldl36yhgrd0h2aafvs6-dfx-env/bin/dfx --version
dfx 0.14.0

[nix-shell:~/sns-testing]$ /home/arshavir/sns-testing/bin/dfx --version
dfx 0.13.1
mraszyk commented 1 year ago

Could you then please remove all files from the bin folder. Users are not expected to run install.sh when setting up the test env via Nix (and thus users are not expected to have any files in the bin folder when using Nix).

aterga commented 1 year ago

Oops, I made a mistake.

I’ve written my comments about the Nix solution in the comments for this PR. Sorry

Long story short: The Nix solution works (tried it on SPM 22 so far). But the instructions in SNS lifecycle could be improved (which is orthogonal to this PR).

aterga commented 1 year ago

Now trying on apple silicon.

Apple-m1 $ nix-shell
trace: warning: replaceChars is a deprecated alias of replaceStrings, replace usages of it with replaceStrings.
...
copying path '/nix/store/bsssjf1g2dip82is7n9zqbdhirv3f1dj-autoconf-archive-2022.02.11' from 'https://cache.nixos.org'...
error: builder for '/nix/store/27csbm5gnl544nnql2yjyxw68jpwjhnx-nix-shell.drv' failed with exit code 1;
       last 8 log lines:
       > WARNING
       >
       > ****************************************************************************************
       >   It appears there is no prebuilt binaries available for system aarch64-darwin.
       >   Run nix-shell with `--arg force true` if you want to build it from source.
       >   Note that if this is the first time you build it, it can take about an hour to finish.
       > ****************************************************************************************
       >
       For full logs, run 'nix-store -l /nix/store/27csbm5gnl544nnql2yjyxw68jpwjhnx-nix-shell.drv'.
error: build of '/nix/store/0nwihy9i6vpgjwk2bplblbg2kxc8w3cs-cmake-3.24.3.drv', '/nix/store/17y4rckzjqmacjsjdl60drm0r9bdfyj8-cachix-1.3.3.drv', '/nix/store/27csbm5gnl544nnql2yjyxw68jpwjhnx-nix-shell.drv', '/nix/store/7a3wsmc2yh8iyl6l3fz97iir2p1mqh9c-openssl-3.0.8.drv', '/nix/store/bgk253gy4j78g811hajk3z09iz9i81q1-jq-1.6.drv', '/nix/store/h4q71qq63qazizh3qw03v77bi5jbq9k8-pkg-config-wrapper-0.29.2.drv', '/nix/store/j8ydpr0i4rryq0c348xlxyrg3vk0wcln-bc-1.07.1.drv', '/nix/store/n1cszx9yxfr51g7sf5g0zc807b8hbq2n-subnet-id-0.1.0.drv', '/nix/store/p2hd81jixdqgdr5zd8ci7dyjy8w835gf-killall-shell_cmds-187.drv', '/nix/store/rkvndanrnii7d6mlfmb50fbbmaac4fvm-quill.drv', '/nix/store/wbmrp6bchr8vpwph33kv3i96wvq7qw13-rustup-1.25.2.drv' failed

Running nix-shell --arg force true results in the same error. :-(

mraszyk commented 1 year ago

We're not gonna support Nix for sns-testing.