I guess you misunderstood my question, because that won’t work. nix-shell -p git doesn’t provide an isolated operating system. They only isolate programs and libraries. If your native git installation modified something in your home folder, those changes will still be visible inside a nix shell.
I’m not sure what you’re trying to accomplish in those other commands, as they just seem to print out git’s dependencies?
Also, I see you’re actively editing your comment as I’m typing so sorry if you actually post the answer after I hit Reply.
Sounds like you haven’t heard of nix.
The solution to the problem is to install git into a clean system so you can observe what changes it makes.
How would you do this with Nix?
nix-shell -p gitOr some even fancier ones:
nix-store -qR $(nix-build '<nixpkgs>' -A git --no-out-link)or
nix path-info -rSh $(nix-build '<nixpkgs>' -A git --no-out-link)or this command (which nix people avoid generally because it creates files outside of the store):
nix-env -p /tmp/clean-profile -iA nixpkgs.git && nix-store -qR /tmp/clean-profile # then rm /tmp/clean-profile* # to get rid of the temp filesand here’s how I personally implemented a global gitignore on my system. This is a redacted version of my git config:
{ lib, pkgs, ... }: { home.packages = with pkgs; [ diff-so-fancy # git diff with colors git-crypt # git files encryption hub # github command-line client tig # diff and commit view ]; programs.git = { enable = true; settings = { alias = { cm = "commit -m"; ca = "commit -am"; dc = "diff --cached"; rmain = "rebase main"; rc = "rebase --continue"; }; core = { editor = "nvim"; pager = "diff-so-fancy | less --tabs=4 -RFX"; }; init.defaultBranch = "main"; merge = { conflictStyle = "diff3"; tool = "vim_mergetool"; }; pull.rebase = false; push.autoSetupRemote = true; url = { "https://github.com/".insteadOf = "gh:"; "ssh://git@github.com".pushInsteadOf = "gh:"; "https://gitlab.com/".insteadOf = "gl:"; "ssh://git@gitlab.com".pushInsteadOf = "gl:"; }; user = { email = "redacted"; name = "redacted"; }; }; ignores = [ "*.bloop" "*.bsp" "*.metals" "*.metals.sbt" "*metals.sbt" "*.direnv" "*.envrc" "*hie.yaml" "*.mill-version" "*.jvmopts" "build/" ]; signing = { key = "redacted"; signByDefault = true; }; } // (pkgs.sxm.git or { }); }I guess you misunderstood my question, because that won’t work.
nix-shell -p gitdoesn’t provide an isolated operating system. They only isolate programs and libraries. If your native git installation modified something in your home folder, those changes will still be visible inside a nix shell.I’m not sure what you’re trying to accomplish in those other commands, as they just seem to print out git’s dependencies?
Also, I see you’re actively editing your comment as I’m typing so sorry if you actually post the answer after I hit Reply.