Skip to content

Instantly share code, notes, and snippets.

@bassmanitram
Created September 17, 2024 09:56
Show Gist options
  • Save bassmanitram/b4f25661fa61b3f4a6c0dbf285fc2f2a to your computer and use it in GitHub Desktop.
Save bassmanitram/b4f25661fa61b3f4a6c0dbf285fc2f2a to your computer and use it in GitHub Desktop.
cross-rs and git - how to make a local ~/.gitconfig and ~/.git-credentials available to a cross-rs container for cross compiling

Move the files to ~/.config/git

mkdir -p ~/.config/git
mv ~/.gitconfig ~/.config/git/config
mv ~/.git-credentials ~/.config/git/credentials
ln -s ~/.config/git/config ~/.gitconfig
ln -s ~/.config/git/credentials ~/.git-credentials

That keeps your current config in place and working while placing your files in a logical place for access (in fact, if you set XDG_CONFIG_HOME to ~/.config you won't need to do the symbolic links).

Create a Cross.toml file somewhere

I put it in my home directory and then set CROSS_CONFIG to point to it - but you'll need to figure out the best approach for you.

Simply add the following lines to that file

[build.env]
passthrough = ["XDG_CONFIG_HOME=/home/your-user-id/.config"]
volumes = ["/home/your-user-id/.config=/home/your-user-id/.config"]

That gives Cross access to your .config folder and sets the XDG_CONFIG_HOME environment variable appropriately within the container, giving GIT access to your host config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment