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

tomlDependencies: pass allRefs=true when fetching a rev #211

Closed
wants to merge 1 commit into from

Conversation

mhuesch
Copy link

@mhuesch mhuesch commented Nov 29, 2021

this allows us to avoid issues when the default branch is not named
master.

I believe this should fix the issues described in:
#149
#140

using this change seems to fix this error I was seeing:

fetching Git repository 'https://github.com/sacredcapital/rep_lang.git'fatal: couldn't find remote ref refs/heads/master
error: program 'git' failed with exit code 128

on a repo which had only a main branch, and no master branch. of note, I was able to work around the issue by creating a dummy master branch, but still using the rev on the main branch.

using this PR seems to enable a successful build, without requiring the dummy master branch which was not actually used.

I reproduced the successful build on multiple machines. however I cannot
be full certain that it works in all cases.

additionally, it seems possible that allRefs = true causes annoying
extra fetching which might be noticeable for repos with many refs...

@mhuesch
Copy link
Author

mhuesch commented Nov 29, 2021

sending this PR in case it is useful. no worries about closing if not 🙂

Copy link
Collaborator

@nmattia nmattia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds sensible, but I'll let @Anderssorby and @blitz have the final word!

Copy link
Member

@blitz blitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, especially if it fixes pain people actually experience.

Not merging right now, because I can't test it at the moment. (Writing this from my phone.) I'll get back to this in a couple of days or maybe in the meantime @Anderssorby can take a look.

lib.nix Show resolved Hide resolved
Copy link
Member

@blitz blitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realize that allRefs is a Nix 2.4 feature.

@mhuesch Is there a way to make this backward compatible to Nix 2.3? Falling back to the old behavior of not specifying the allRefs parameter would be fine.

@mhuesch
Copy link
Author

mhuesch commented Dec 7, 2021

I didn't realize that allRefs is a Nix 2.4 feature.

@mhuesch Is there a way to make this backward compatible to Nix 2.3? Falling back to the old behavior of not specifying the allRefs parameter would be fine.

ah, neither did I! I am not sure how to do version-conditional code in Nix but I will check into it next week when I get back from the trip I'm on 👍

@Anderssorby
Copy link
Collaborator

Hm, this may cause unnecessary data to be downloaded which is not desirable. I remember in another project we solved this by specifying the branch as well in the Cargo.toml

@mhuesch
Copy link
Author

mhuesch commented Dec 18, 2021

perhaps the best way would be to add an optional attr allRefs (which defaults to false) to an input attrset somewhere?

my (not very informed) sense is that it'll be tough to do a kind of "granular enabling of allRefs=true", so maybe just a global (to the Cargo project which is pointed to by src in naersk's buildPackage invocation) enabling? so, adding an optional allRefs attr to buildPackage input attr set and propagating that down.

the reasoning being that many projects won't have this issue and won't notice the change, but for projects that do, downloading some extra data is preferable to not being able to build 🙂

oh, and then sorting out the pre-Nix-2.4 compatibility issue mentioned above.

@jonringer
Copy link

The latest stable release bumped the nix version again, if you push to the branch, it should re-trigger CI to run. Which will probably pass now.

@jonringer
Copy link

21.05 is EOL, may just ask people to pin to a commit before this change if they want to be compatible with nix 2.3

this allows us to avoid issues when the default branch is not named
`master`.

I believe this should fix the issues described in:
nix-community#149
nix-community#140

using this change seems to fix this error I was seeing:
```
fetching Git repository 'https://github.com/sacredcapital/rep_lang.git'fatal: couldn't find remote ref refs/heads/master                                                                            error: program 'git' failed with exit code 128
```
and enables a successful build.

I reproduced the successful build on multiple machines. however I cannot
be full certain that it works in all cases.

additionally, it seems possible that `allRefs = true` causes annoying
extra fetching which might be noticeable for repos with many refs...
@mhuesch
Copy link
Author

mhuesch commented Jan 11, 2022

The latest stable release bumped the nix version again, if you push to the branch, it should re-trigger CI to run. Which will probably pass now.

@jonringer thx. I just rebased and force pushed the branch. however I see:

1 workflow awaiting approval
First-time contributors need a maintainer to approve running workflows.

so perhaps the check will not run.

@blitz blitz mentioned this pull request Feb 4, 2022
@blitz
Copy link
Member

blitz commented Feb 4, 2022

21.05 is EOL, may just ask people to pin to a commit before this change if they want to be compatible with nix 2.3

It's not that easy. Nix 2.3 is for some reason still the default on NixOS 21.11. As long as Nix 2.3 is actively shipped, it's a bit user hostile to require 2.4 by default. We could check builtins.nixVersion and at least politely decline to work when allRefs is set?

@Patryk27
Copy link
Contributor

Hi! Thanks for this merge request - for the time being, I'm going to go with #167, which allows for users to configure whether they want allRefs or not explicitly, and I'll revisit this topic once Nix 2.4 becomes more widely shipped. Thank y'all!

@Patryk27 Patryk27 closed this Mar 28, 2022
@mhuesch
Copy link
Author

mhuesch commented Mar 28, 2022

@Patryk27 good call, thx and yw!

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

Successfully merging this pull request may close these issues.

6 participants