Package Nix pour Ğcli

Je suis en train d’essayer de build un package Nix de Ğcli, parce que j’ai cru que ce serait facile.

Cela permettrait d’installer Ğcli rapidement sur des anciennes versions de Linux avec Devbox ou Nix.
Et sûrement d’autres cas d’usage que je ne connais pas.

J’ai pris un fichier flake.nix et je l’ai modifié. J’ai corrigé des erreurs, mais là je bloque sur la crate age dont le source semble introuvable lors du cargo build via Nix.

J’ai mis le dépôt github de age dans Cargo.toml, mais sans succès…

Je précise que j’ai réussi à build Ğcli localement sans problème et qu’il fonctionne.

Si le projet intéresse @immae ou d’autres, je peux pousser une MR sur le dépôt de Ğcli pour investiguer…

Les logs de la commande nix build :

error: builder for '/nix/store/raz92b1d9zzfpsnbdcp1srp4f2c7bjdb-gcli.drv' failed with exit code 101;
       last 25 log lines:
       > Validating consistency between /build/r61zjcv8c2l391yslm7vbxa0dr4daqh6-source/Cargo.lock and /build/cargo-vendor-dir/Cargo.lock
       > Finished cargoSetupPostPatchHook
       > configuring
       > building
       > Executing cargoBuildHook
       > ++ env CC_x86_64-unknown-linux-gnu=/nix/store/061ybr50r1m2jnvih4vvpgmgwb37df3r-gcc-wrapper-12.2.0/bin/cc CXX_x86_64-unknown-linux-gnu=/nix/store/061ybr50r1m2jnvih4vvpgmgwb37df3r-gcc-wrapper-12.2.0/bin/c++ CC_x86_64-unknown-linux-gnu=/nix/store/061ybr50r1m2jnvih4vvpgmgwb37df3r-gcc-wrapper-12.2.0/bin/cc CXX_x86_64-unknown-linux-gnu=/nix/store/061ybr50r1m2jnvih4vvpgmgwb37df3r-gcc-wrapper-12.2.0/bin/c++ cargo build -j 4 --target x86_64-unknown-linux-gnu --frozen --release
       > error: failed to get `age` as a dependency of package `gcli v0.2.9 (/build/r61zjcv8c2l391yslm7vbxa0dr4daqh6-source)`
       >
       > Caused by:
       >   failed to load source for dependency `age`
       >
       > Caused by:
       >   Unable to update registry `crates-io`
       >
       > Caused by:
       >   failed to update replaced source registry `crates-io`
       >
       > Caused by:
       >   failed to parse manifest at `/build/cargo-vendor-dir/sp-tracing-16.0.0/Cargo.toml`
       >
       > Caused by:
       >   error inheriting `lints` from workspace root manifest's `workspace.lints`
       >
       > Caused by:
       >   failed to find a workspace root
       For full logs, run 'nix log /nix/store/raz92b1d9zzfpsnbdcp1srp4f2c7bjdb-gcli.drv'.
1 Like

Suite de mes aventures avec nix build :

Ce qui me donne :

{ pkgs ? import <nixpkgs> { } }:
pkgs.rustPlatform.buildRustPackage rec {
  pname = "gcli";
  version = "0.2.9";
  cargoLock.lockFile = ./Cargo.lock;
  src = pkgs.lib.cleanSource ./.;
cargoLock.outputHashes = {
    "ark-secret-scalar-0.0.2" = "sha256-91sODxaj0psMw0WqigMCGO5a7+NenAsRj5ZmW6C7lvc=";
    "common-0.1.0" = "sha256-LHz2dK1p8GwyMimlR7AxHLz1tjTYolPwdjP7pxork1o=";
    "fflonk-0.1.0" = "sha256-+BvZ03AhYNP0D8Wq9EMsP+lSgPA6BBlnWkoxTffVLwo=";
    "simple-mermaid-0.1.0" = "sha256-IekTldxYq+uoXwGvbpkVTXv2xrcZ0TQfyyE2i2zH+6w=";
    "sp-application-crypto-23.0.0" = "sha256-Ju+VoWSw/KLF1dnTbgxw+ezwTUQV+tUTYuehD7G8M+k=";
    "sp-ark-bls12-381-0.4.2" = "sha256-nNr0amKhSvvI9BlsoP+8v6Xppx/s7zkf0l9Lm3DW8w8=";
    "sp-crypto-ec-utils-0.10.0" = "sha256-OVoNzvupbqpQSEz1bYcrhkGxfyKoUsQ6/w+kQgFlk/o=";
    "subxt-0.34.0" = "sha256-i6yIRBllVedBIh57x1Ye6gDtQ08VlV08uwwnd1bjgzI=";
  };
}

Le build avance bien mieux !

…jusqu’au drame :

       >    Compiling sp-runtime v24.0.0 (https://github.com/duniter/duniter-polkadot-sdk.git?branch=duniter-substrate-v1.6.0#c84530c5)
       >    Compiling dirs-sys v0.4.1
       > error: couldn't read /build/cargo-vendor-dir/sp-runtime-24.0.0/src/generic/../../../../../docs/mermaid/extrinsics.mmd: No such file or directory (os error 2)
       >   --> /build/cargo-vendor-dir/sp-runtime-24.0.0/src/generic/unchecked_extrinsic.rs:60:35
       >    |
       > 60 | #[cfg_attr(feature = "std", doc = simple_mermaid::mermaid!("../../../../../docs/mermaid/extrinsics.mmd"))]
       >    |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       >    |
       >    = note: this error originates in the macro `include_str` which comes from the expansion of the macro `simple_mermaid::mermaid` (in Nightly builds, run with -Z macro-backtrace for more info)
       >
       > error: could not compile `sp-runtime` (lib) due to 1 previous error
       > warning: build failed, waiting for other jobs to finish...
       For full logs, run 'nix log /nix/store/nc57rnbc5lq3jzc3yxn4kvz9b9k68bh2-gcli-0.2.9.drv'.

Bon ben je suis bloqué parce qu’il ne trouve pas une doc ! Rognetudju ! :triumph:

A suivre…

1 Like

Si un détail dans une dépendance cause un problème bloquant, tu peux ajouter une section patch pour remplacer la dépendance (même transitive) par un fork.

Dans ce cas-là peut-être qu’il faut juste faire cargo doc avant pour que ça marche ? C’est bizarre.

cargo doc n’a pas résolu le problème… snif. Je vais regarder la solution du patch… Merci !

Le problème ne vient pas de nix mais de la dépendence simple-mermaid je pense.

J’ai testé en remplaçant import <nixpkgs> par import <nixos-unstable> sinon ça plante car il faut une version de rustc >= 1.75, et mon channel nixpkgs fourni la version 1.74.
Bref, ça build mais j’ai la même erreur :

 Compiling scale-value v0.13.0
   Compiling age-core v0.10.0
   Compiling dirs-sys v0.4.1
   Compiling sp-runtime v24.0.0 (https://github.com/duniter/duniter-polkadot-sdk.git?branch=duniter-substrate-v1.6.0#c84530c5)
error: couldn't read /build/cargo-vendor-dir/sp-runtime-24.0.0/src/generic/../../../../../docs/mermaid/extrinsics.mmd: No such file or directory (os error 2)
  --> /build/cargo-vendor-dir/sp-runtime-24.0.0/src/generic/unchecked_extrinsic.rs:60:35
   |
60 | #[cfg_attr(feature = "std", doc = simple_mermaid::mermaid!("../../../../../docs/mermaid/extrinsics.mmd"))]
   |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `include_str` which comes from the expansion of the macro `simple_mermaid::mermaid` (in Nightly builds, run with -Z macro-backtrace for more info)

   Compiling directories v4.0.1
   Compiling i18n-embed-fl v0.7.0
   Compiling scrypt v0.11.0
   Compiling crossterm v0.25.0
error: could not compile `sp-runtime` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: builder for '/nix/store/yz67l8671060vlxnxsf5ffcqd2wdimy7-gcli-0.2.9.drv' failed with exit code 101;
       last 10 log lines:
       >    |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       >    |
       >    = note: this error originates in the macro `include_str` which comes from the expansion of the macro `simple_mermaid::mermaid` (in Nightly builds, run with -Z macro-backtrace for more info)
       >
       >    Compiling directories v4.0.1
       >    Compiling i18n-embed-fl v0.7.0
       >    Compiling scrypt v0.11.0
       >    Compiling crossterm v0.25.0
       > error: could not compile `sp-runtime` (lib) due to 1 previous error
       > warning: build failed, waiting for other jobs to finish...
       For full logs, run 'nix log /nix/store/yz67l8671060vlxnxsf5ffcqd2wdimy7-gcli-0.2.9.drv'.

@vit pour avoir le hash c’est tout simple, tu laisse une chaine vide, et nix plante mais te retourne le hash : "simple-mermaid-0.1.0" = "";

Du coup, comme il y a une version 0.1.1, j’ai essayé mais nix plante le build, comme si cette version n’existait pas. :

❯ nix-build default.nix
error:
       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'gcli-0.2.9'
         whose name attribute is located at /nix/store/3r643hm4q1l4dj1yw0hlaya8gkbbn235-nixos-unstable/nixos-unstable/pkgs/stdenv/generic/make-derivation.nix:331:7

       … while evaluating attribute 'cargoDeps' of derivation 'gcli-0.2.9'

         at /nix/store/3r643hm4q1l4dj1yw0hlaya8gkbbn235-nixos-unstable/nixos-unstable/pkgs/build-support/rust/build-rust-package/default.nix:101:10:

          100| } // {
          101|   inherit buildAndTestSubdir cargoDeps;
             |          ^
          102|

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: A hash was specified for simple-mermaid-0.1.1, but there is no corresponding git dependency.

Voilà, je ne sais pas trop non plus quoi faire de plus…

La dépendance simple-memaid dans cargo.lock viendrait de duniter-polkadot-sdk :

[[package]]
name = "sp-runtime"
version = "24.0.0"
source = "git+https://github.com/duniter/duniter-polkadot-sdk.git?branch=duniter-substrate-v1.6.0#c84530c57a6f9ab808a92f6b5d29338acf1c6e4f"
dependencies = [
 "docify",
 "either",
 "hash256-std-hasher",
 "impl-trait-for-tuples",
 "log",
 "parity-scale-codec",
 "paste",
 "rand",
 "scale-info",
 "serde",
 "simple-mermaid",
 "sp-application-crypto",
 "sp-arithmetic",
 "sp-core",
 "sp-io",
 "sp-std 8.0.0",
 "sp-weights",
]
1 Like