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

(ruby-modules/gem): (refactor) #53525

Merged
merged 6 commits into from Mar 29, 2019
Merged

Conversation

nyarly
Copy link
Contributor

@nyarly nyarly commented Jan 6, 2019

Motivation for this change

Rubygems with a git source use leaveDotGit across the board. The upshot is that many unrelated changes to the upstream git repo (even on a gem that is referred to by ref) will change the fixed output digest and fail builds.

Things done

This PR removes leaveDotGit and replaces it with a series of git commands to recreate the git repo locally during build. The reason for this is that many gems use some variation of git ls-files rather than specifically enumerating their manifests. This is plainly wrong, but that battle is well lost.

  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

I have used this branch to build a relatively complicated gemset.nix that includes git gems. Attempts to use nox-review exhausted the disk on my laptop.

git config user.email nixbld@localhost.none
git config user.name Nix
git add .
git commit -m "Nixpkgs setup for rubygems" || true
Copy link
Member

Choose a reason for hiding this comment

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

I like this idea. Do you know if it's bit-reproducible?

You might be able to reduce a few lines by using --author and also add --date= just in case

Copy link
Member

Choose a reason for hiding this comment

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

You might be able to reduce a few lines by using --author and also add --date= just in case

Those flags only affect the author date, IIRC. You can’t set the committer through flags, although you can use environment variables.

But, shouldn’t git ls-files report all files tracked by git? In that case, is a commit even necessary?

Copy link
Member

Choose a reason for hiding this comment

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

I like this idea. Do you know if it's bit-reproducible?

It could definitely change between git versions. There’s a lot of stuff like initial repository config and sample hooks in a brand new repo.

Something like this could help:

rm -rf .git/logs/ .git/hooks/ .git/index .git/FETCH_HEAD .git/ORIG_HEAD \
.git/refs/remotes/origin/HEAD .git/config

Aside from those, and possibly some other files like info/exclude, I think this would be bit-reproducible, unless the git repository format changed. There’s not really anything we could do about that, and it would already be a big problem for Nixpkgs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Excellent notes. I've removed the commit which removes the requirement for config and added that rm. Retesting on my problem repo still works.

elif [[ "$type" == "git" ]]; then
git init
git add .
rm -rf .git/logs/ .git/hooks/ .git/index .git/FETCH_HEAD .git/ORIG_HEAD .git/refs/remotes/origin/HEAD .git/config
Copy link
Member

Choose a reason for hiding this comment

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

Oh, really, you can remove .git/index? What's left in .git after this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:) I copied your reference above! I experimented directly, and removing the index clobbers the effect of git add (which is obvious in hindsight). Reversing the order fixes it.

elif [[ "$type" == "git" ]]; then
git init
rm -rf .git/logs/ .git/hooks/ .git/index .git/FETCH_HEAD .git/ORIG_HEAD .git/refs/remotes/origin/HEAD .git/config
git add .
Copy link
Member

Choose a reason for hiding this comment

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

what is the purpose of having the files in the staging area?

Copy link
Member

Choose a reason for hiding this comment

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

Adding this at build time can be useful for git ls-files to work.

zimbatm and others added 2 commits January 11, 2019 09:59
Useful comments

Co-Authored-By: nyarly <nyarly@users.noreply.github.com>
Comments are useful

Co-Authored-By: nyarly <nyarly@users.noreply.github.com>
@nyarly
Copy link
Contributor Author

nyarly commented Mar 28, 2019

@alyssais @zimbatm Are we good to merge this, or have I missed a lingering concern?

@zimbatm zimbatm merged commit 704d020 into NixOS:master Mar 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants