Skip to content

Nix build fails due to sandbox #146

@es-sai-fi

Description

@es-sai-fi

Error

gitv> warning: gitv-tui@0.4.3: Could not initialize the http client
gitv> warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_BRANCH
gitv> warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_COMMIT_AUTHOR_EMAIL
gitv> warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_COMMIT_AUTHOR_NAME
gitv> warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_COMMIT_COUNT
gitv> warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_COMMIT_DATE
gitv> warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_COMMIT_MESSAGE
gitv> warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_COMMIT_TIMESTAMP
gitv> warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_DESCRIBE
gitv> warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_SHA
gitv> warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_DIRTY
gitv> error: environment variable `VERGEN_GIT_DESCRIBE` not defined at compile time
gitv>    --> src/app/cli.rs:131:5
gitv>     |
gitv> 131 |     env!("VERGEN_GIT_DESCRIBE"),
gitv>     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
gitv>     |
gitv>     = help: use `std::env::var("VERGEN_GIT_DESCRIBE")` to read the variable at run time
gitv> warning: gitv-tui@0.4.3: Could not initialize the http client
gitv> warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_BRANCH
gitv> warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_COMMIT_AUTHOR_EMAIL
gitv> warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_COMMIT_AUTHOR_NAME
gitv> warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_COMMIT_COUNT
gitv> warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_COMMIT_DATE
gitv> warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_COMMIT_MESSAGE
gitv> warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_COMMIT_TIMESTAMP
gitv> warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_DESCRIBE
gitv> warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_SHA
gitv> warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_DIRTY
gitv> error: could not compile `gitv-tui` (lib) due to 1 previous error
error: builder for '/nix/store/hlf8z83m1vj74878qvqhadncaky62gk2-gitv.drv' failed with exit code 101;
       last 25 log lines:
       > warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_COMMIT_MESSAGE
       > warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_COMMIT_TIMESTAMP
       > warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_DESCRIBE
       > warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_SHA
       > warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_DIRTY
       > error: environment variable `VERGEN_GIT_DESCRIBE` not defined at compile time
       >    --> src/app/cli.rs:131:5
       >     |
       > 131 |     env!("VERGEN_GIT_DESCRIBE"),
       >     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
       >     |
       >     = help: use `std::env::var("VERGEN_GIT_DESCRIBE")` to read the variable at run time
       >
       > warning: gitv-tui@0.4.3: Could not initialize the http client
       > warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_BRANCH
       > warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_COMMIT_AUTHOR_EMAIL
       > warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_COMMIT_AUTHOR_NAME
       > warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_COMMIT_COUNT
       > warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_COMMIT_DATE
       > warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_COMMIT_MESSAGE
       > warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_COMMIT_TIMESTAMP
       > warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_DESCRIBE
       > warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_SHA
       > warning: gitv-tui@0.4.3: Unable to set VERGEN_GIT_DIRTY
       > error: could not compile `gitv-tui` (lib) due to 1 previous error

Possible Fix

Add the following to package.nix:

rustPlatform.buildRustPackage (finalAttrs: {
  ...
  version = "dev";
  ...
  env = {
    VERGEN_GIT_DESCRIBE = finalAttrs.version;
    VERGEN_BUILD_DATE = "unknown";
  };
  ...
});

This would make the version message look like this:

gitv-tui 0.4.3-dev (1980-01-01)

Author: JayanAXHF <sunil.chdry@gmail.com>

Data directory: /home/es-sai-fi/.local/share/gitv-tui

The pattern used above is how this issue is typically handled in nixpkgs, or at least from what I've seen while grepping through the codebase. It works there because package maintainers manually update the version and build date env var whenever upstream publishes a new release.

In our case, however, we are building directly from latest git revision rather than packaging a fixed upstream release, so there is no real release version to expose automatically.

What are your thoughts @JayanAXHF? Do you care strongly about having -V / --version display fully accurate build metadata? Personally, I do not think it matters much in this case since anyone using the Nix package provided here would already understand they are building a dev release rather than an official release.

I'm also considering eventually submitting this project to nixpkgs, which introduces the following tradeoff:

  • Build directly from source using the package provided here, but have inaccurate version/build-date metadata in -V and --version
  • Build from a fixed upstream release using the package provided in nixpkgs, which gives accurate metadata but loses access to unreleased changes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions