digital-asset / daml-finance

Apache License 2.0
17 stars 16 forks source link

get daml from Artifactory when needed #1166

Closed garyverhaegen-da closed 10 months ago

jsjoedin commented 10 months ago

@garyverhaegen-da, I have tried to get this branch to work locally but have failed (I see it is currently failing on the CI as well).

My problem seems to be that I can’t get the environment variables into the daml.nix script, i.e., impureEnvVars = [ "ARTIFACTORY_USERNAME" "ARTIFACTORY_PASSWORD" ]; gives me empty values. They are available outside though, if I echo "Username: $ARTIFACTORY_USERNAME" from the command line I see a value. The curl commands also work if I run them using my credentials.

Do you know if I need to enable impure variables somehow for nix or what the issue might be?

when I ask chatGPT I get: In nix-build: For nix-build, which is used for more reproducible builds, the environment is much more controlled and pure, meaning it does not import environment variables from the user's environment by default. impureEnvVars does not have the same effect in this context.

garyverhaegen-da commented 10 months ago

@jsjoedin can you share the error message you get? The CI failure does not seem to be related to env vars.

johan-da commented 10 months ago

@jsjoedin can you share the error message you get? The CI failure does not seem to be related to env vars. here is the error message:

~/repos  cd daml-finance                                                                                     Tue Nov 28 11:23:25 2023
direnv: loading ~/repos/daml-finance/.envrc
direnv: loading ~/repos/daml-finance/.envrc.private
direnv: using nix
direnv: ([/usr/local/bin/direnv export fish]) is taking a while to execute. Use CTRL-C to give up.
these 2 derivations will be built:
/nix/store/xzhmmj58ghc2dga5g11jpbyg5v73y9g1-daml-tarball-2.8.0-snapshot.20231125.12402.0.v9caae0b1.drv
/nix/store/p76c3bkqw1az65vxypn7a5hcbk1pc4pv-daml-sdk-2.8.0-snapshot.20231125.12402.0.v9caae0b1.drv
building '/nix/store/xzhmmj58ghc2dga5g11jpbyg5v73y9g1-daml-tarball-2.8.0-snapshot.20231125.12402.0.v9caae0b1.drv'...
unpacking sources
unpacking source archive /nix/store/xm86ni7dqkp3ymv7x1clhlskx7f998d4-daml-finance
source root is daml-finance
unpackPhase completed in 36 seconds
patching sources
configuring
no configure script, doing nothing
building
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
0     9    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 404
ARTIFACTORY_USERNAME and ARTIFACTORY_PASSWORD must be set.
error: builder for '/nix/store/xzhmmj58ghc2dga5g11jpbyg5v73y9g1-daml-tarball-2.8.0-snapshot.20231125.12402.0.v9caae0b1.drv' failed with exit code 1;
last 10 log lines:
unpackPhase completed in 36 seconds
patching sources
configuring
no configure script, doing nothing
building
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     9    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 404
ARTIFACTORY_USERNAME and ARTIFACTORY_PASSWORD must be set.
For full logs, run 'nix log /nix/store/xzhmmj58ghc2dga5g11jpbyg5v73y9g1-daml-tarball-2.8.0-snapshot.20231125.12402.0.v9caae0b1.drv'.
error: 1 dependencies of derivation '/nix/store/p76c3bkqw1az65vxypn7a5hcbk1pc4pv-daml-sdk-2.8.0-snapshot.20231125.12402.0.v9caae0b1.drv' failed to build
direnv: export +ARTIFACTORY_PASSWORD +ARTIFACTORY_TOKEN +ARTIFACTORY_USERNAME ~PATH

regarding the CI error, it appears nix doesn't like different SDK versions. I got it working here: https://github.com/digital-asset/daml-finance/pull/1169

johan-da commented 10 months ago

As pointed out by @garyverhaegen-da:

  1. the issue I was facing ^ seems to be related to our multi-user nix installation. It was fixed by this commit: https://github.com/digital-asset/daml-finance/pull/1166/commits/bc40a3b2a9d3b6238a55ca30af09fc6c10e0f433
  2. If sdk-version or daml-version is changed (in the daml.yaml file), please run bin/update-daml-hashes to keep shell.nix in sync (CI will notice & fail). You may need to comment out daml from the buildInputs list to get your Nix shell to run while you update the hashes.