Vscode & GitHub Help Needed: Uploading NixOS Changes to GitHub Using VSCode

Hello everyone,

I’m reaching out because I could really use some help setting up my VSCode to work smoothly with GitHub on my NixOS. I’ve cloned my repository but that simply downloads everything and am able to edit and commit to Github, but that doesn’t edit the configuration files in my /etc/nixos.

Here’s what I’m trying to do:

  1. GitHub : I have my project on GitHub at this link: https://github.com/tolgaerok/NixOS-tolga
  2. Branch : I want to put my changes into the main branch.
  3. Folder Target: More specifically, I’m working with some NixOS configuration files on my computer in the /etc/nixos folder. I want these files to automatically go into the nixos folder in my GitHub.

My goal is that whenever I modify my NixOS files on my computer, these changes will get sent automatically/commit/push to the right spot in my GitHub folder: https://github.com/tolgaerok/NixOS-tolga/nixos

Here’s where I’m running into issues:

  1. Getting it Set Up: I’m not quite sure how to set up everything in VSCode and the Git/GitHub stuff so that everything goes where it’s supposed to.
  2. Commit / Push: I’d love for my changes to just zip over to the nixos folder on GitHub whenever I make a change locally, but I’m a bit lost on how to make that happen.

If you’ve got any experience with this kind of thing or can break down how to set up VSCode, Git, and GitHub in simple steps, I’d really appreciate your help. Any guidance, tips, or resources you can share would be much appreciated.

Cheers
Tolga :innocent:

It sounds to me like you need to go through some of the git tutorials to first get a handle on how to work with git. Your questions really don’t have anything to do with NixOS (or github for that matter) - that comes later.

Github has some good git tutorials (obviously skewed towards github), which might be a place to start.

I understand the fundamental of the git procedures.

Im after how to get vscode to upload my changes into the nixos folder in the github tree (nixos folder)

You can write a script that uses inotifywait or similar to watch /etc/nixos, copies the files in there to your local git repo, runs something like git commit -am 'Automated changes, no comments available' and then runs a git push. Can even write it as a systemd service, I think you can make it trigger a script when a directory changes, but somehow I’ve never actually used this feature.

I’d suggest moving the nixos config directory to a user-owned path by rebuilding with nixos-rebuild -I nixos-config=/home/tolgaerok/Projects/NixOS-tolga/nixos or something too, then you can save yourself the trouble of copying and figuring out the permission problems.

I agree with @peterhoeg that this is rather unorthodox, though, you’re basically using github as a cloud storage solution and completely ignoring git if you do this. You may find some off-the shelf projects that do this too, plenty of people abuse GitHub as public cloud storage.