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

Allow .git directory to be fully included in local path #121

Closed
isd-project opened this issue Jan 30, 2025 · 2 comments
Closed

Allow .git directory to be fully included in local path #121

isd-project opened this issue Jan 30, 2025 · 2 comments

Comments

@isd-project
Copy link

isd-project commented Jan 30, 2025

Hey 👋

Thank you soo much for improving the nix + Python ecosystem ❤️

I have a rather specific request and fully understand if it is currently outside the scope of the project.

In short, I would like to use a package that uses versioningit.
This build plugin uses the Git history to derive the package's version number during build time.

The current uv2nix tooling does not include the full git history, and I don't know where to extend the nix code to do so.

You can try and view the minimal reproducible example here:

In short, building it with uv build works as expected but running nix build .# does not, as it cannot read the entire .git directory to find the associated Git tag.

Thanks!

@adisbladis
Copy link
Member

Most build systems that attempt to extract version metadata from git has a mode where you can fake version metadata using an environment variable.
Versioningit has an open issue for that: jwodder/versioningit#45.

In the mean time one workaround could be to create a git repo in the build and tag a version:

      pyprojectOverrides = final: prev: {
        minimal-versioningit = prev.minimal-versioningit.overrideAttrs(old: {
          nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.git ];
          preBuild = ''
            export HOME=$(mktemp -d)
            git init
            git config --global user.email "[email protected]"
            git config --global user.name "Your Name"
            git add *
            git commit -m 'fake'
            git tag "$version"
          '';
        });
      };

@isd-project
Copy link
Author

I see. I thought that it should be possible to include the entire git history such that the version can be extracted during runtime in a "wrapping" derivation. But I see that there are quite a few issues with this approach.
Thank you for also providing a work around!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants