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

doc: document commonly used fetchgit flags #355685

Merged
merged 2 commits into from
Nov 17, 2024

Conversation

Atemu
Copy link
Member

@Atemu Atemu commented Nov 13, 2024

Some important ones like fetchLFS were missing. See
https://discourse.nixos.org/t/how-to-use-git-lfs-with-fetchgit/55975 for a
documented instance where this confused a user.

This still isn't complete but the remaining ones I felt were rather niche and I
am not familiar enough with the to sufficiently document their purpose or usage.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/how-to-use-git-lfs-with-fetchgit/55975/3

@github-actions github-actions bot added 8.has: documentation This PR adds or changes documentation 6.topic: fetch labels Nov 13, 2024
@nix-owners nix-owners bot requested a review from philiptaron November 13, 2024 15:31
@Atemu Atemu mentioned this pull request Nov 14, 2024
13 tasks
@Atemu Atemu force-pushed the doc/fetchgit-common-flags branch from 9142768 to f16fe7b Compare November 14, 2024 19:28
@Atemu
Copy link
Member Author

Atemu commented Nov 14, 2024

This looks a lot nicer now, thanks!

fetchgit

Used with Git. Expects url to a Git repo, rev, and hash. rev in this case can be full the git commit id (SHA1 hash) or a tag name like refs/tags/v1.0.

Additionally, the following optional arguments can be given:

fetchSubmodules (Boolean)

Whether to also fetch the submodules of a repository.

fetchLFS (Boolean)

Whether to fetch LFS objects.

postFetch (String)

Shell code executed after the file has been fetched successfully. This can do things like check or transform the file.

leaveDotGit (Boolean)

Whether the .git directory of the clone should not be removed after checkout.

Be warned though that the git repository format is not stable and this flag is therefore not suitable for actual use by itself. Only use this for testing purposes or in conjunction with removing the .git directory in postFetch.

deepClone (Boolean)

Clone the entire repository as opposing to just creating a shallow clone. This implies leaveDotGit.

sparseCheckout (List of String)

Prevent git from fetching unnecessary blobs from server. This is useful if only parts of the repository are needed.

Example 268. Use sparseCheckout to only include some directories:
{ stdenv, fetchgit }:

stdenv.mkDerivation {
name = "hello";
src = fetchgit {
url = "https://...";
sparseCheckout = [
"directory/to/be/included"
"another/directory"
];
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
};
}


See git sparse-checkout for more information.

Some additional parameters for niche use-cases can be found listed in the function parameters in the declaration of fetchgit: pkgs/build-support/fetchgit/default.nix.
Future parameters additions might also happen without immediately being documented here.

(The example is formatted properly in the actual manual.)

Some important ones like fetchLFS were missing. See
https://discourse.nixos.org/t/how-to-use-git-lfs-with-fetchgit/55975 for a
documented instance where this confused a user.

This still isn't complete but the remaining ones I felt were rather niche and I
am not familiar enough with them to sufficiently document their purpose or
usage.
Many parameters added over the past many years were not documented in the
manual. People likely simple didn't think to do that, so let's nudge them.
@Atemu Atemu force-pushed the doc/fetchgit-common-flags branch from f16fe7b to ee97de3 Compare November 14, 2024 22:50
@Atemu
Copy link
Member Author

Atemu commented Nov 14, 2024

Backporting because this is an improvement without possibility of any breakage and because it's required for this which should also be backported: #355973

@wegank wegank added 12.approvals: 2 This PR was reviewed and approved by two reputable people and removed 12.approvals: 1 This PR was reviewed and approved by one reputable person labels Nov 15, 2024
Copy link
Contributor

@malikwirin malikwirin left a comment

Choose a reason for hiding this comment

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

I was the confused user.
This PR would have saved me some hours if it was already merged

@Atemu Atemu merged commit c5d3db7 into NixOS:master Nov 17, 2024
28 checks passed
@Atemu Atemu deleted the doc/fetchgit-common-flags branch November 17, 2024 16:39
Copy link
Contributor

Backport failed for release-24.05, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release-24.05
git worktree add -d .worktree/backport-355685-to-release-24.05 origin/release-24.05
cd .worktree/backport-355685-to-release-24.05
git switch --create backport-355685-to-release-24.05
git cherry-pick -x 1712d71ea76c317a841d0f1308c8236fc43dee0a ee97de3be97fe96c32489c60fa58c164eae2d0c9

Copy link
Contributor

Successfully created backport PR for release-24.11:

@gador
Copy link
Member

gador commented Nov 17, 2024

This seems to break the manual:

nixos_render_docs.redirects.RedirectsError:
Identifiers present in the source must have a mapping in the redirects file.
    - ex-fetchgit-sparseCheckout

    This can happen when an identifier was added or renamed.
    Please update doc/redirects.json or nixos/doc/manual/redirects.json!

NOTE: If your Manual build passes locally and you see this message in CI, you probably need a rebase.

@gador
Copy link
Member

gador commented Nov 17, 2024

Probably due to #353513 and can be fixed with

diff --git a/doc/redirects.json b/doc/redirects.json
index de640eed00c1..a5a876961848 100644
--- a/doc/redirects.json
+++ b/doc/redirects.json
@@ -1274,6 +1274,9 @@
   "fetchgit": [
     "index.html#fetchgit"
   ],
+  "ex-fetchgit-sparseCheckout": [
+    "index.html#ex-fetchgit-sparseCheckout"
+  ],
   "fetchfossil": [
     "index.html#fetchfossil"
   ],

@fricklerhandwerk
Copy link
Contributor

@gador yes, thanks for your patience. @GetPsyched will soon add a helper command so we don't have to do these things manually.

@Atemu
Copy link
Member Author

Atemu commented Nov 18, 2024

Thanks for the fix @gador.

@fricklerhandwerk @GetPsyched I was not aware that you'd need to do this. You should probably announce the fact that you must do this in the breaking changes for unstable thread.

@Atemu
Copy link
Member Author

Atemu commented Nov 18, 2024

Thinking about this again, I don't think it was necessary to backport this for #355973 because this is just docs whereas the actual important thing for backports is the functionality.

It doesn't hurt to have this aswell as the docs in 24.11 but I won't backport to 24.05.

@GetPsyched
Copy link
Member

@fricklerhandwerk @GetPsyched I was not aware that you'd need to do this. You should probably announce the fact that you must do this in the breaking changes for unstable thread.

I'm unsure how is this a breaking change. The CI will fail if the redirects aren't correct; it didn't fail for this PR simply because the CI on this PR ran before the redirects system was merged into master.

@Atemu
Copy link
Member Author

Atemu commented Nov 18, 2024

I see. Though I think that's all the more reason to announce this as that'd allow those who might be caught by this caveat to notice it in their PRs.

If I knew of this change and that there was the possibility of an integration hazard like this, I'd have checked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: fetch 8.has: documentation This PR adds or changes documentation 10.rebuild-darwin: 1-10 10.rebuild-darwin: 1 10.rebuild-linux: 1-10 10.rebuild-linux: 1 12.approvals: 2 This PR was reviewed and approved by two reputable people backport release-24.11 Backport PR automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants