For personal use, but feel free to use it for inspiration.
git clone
this repo into /etc/nixos/
. After building and creating a user,
remember to sudo chown -R USER:
the nixos
folder, so the git repo doesn't
require sudo-privileges.
Souce: https://www.youtube.com/watch?v=20BN4gqHwaQ
-
Configure git username/email (in home-manager)
-
Configure SSH: Either copy existing private and public ssh-key to
.ssh
and add the public SSH-key touser.users.<username>.openssh.authorizedKeys.keys = []
inconfiguration.nix
, or create a new key withssh-keygen
, and add the public key to Github (or what else you are using). -
Make
.git
folder:sudo mkdir .git
in/etc/nixos
-
Remove
sudo
requirement:sudo chown <user-name>:users .git
(replace<user-name>
with the system's username). -
Run
git init
. -
Add
progams.git.extraConfig.safe.directory = "/etc/nixos";
in home-manager. -
Make an empty repo (on Github, or another site).
-
git remote add <remote-name> <link-to-repo>
Note1:<remote-name>
is oftenorigin
, but it can be more descriptive, likegithub
. Note2: If using SSH on Github,<link-to-repo>
is of the form[email protected]:<github-username>/<git-repo-name>.git
. -
git push <remote-name> main
, and you're done!
Alternative git push <remote-name> master
, (github-syntax)and you're done!
- Optional: Add
programs.git.extraConfig.init.defaultBranch = "main";
to home-manager.
Alternative: Add programs.git.extraConfig.init.defaultBranch = "master";
to home-manager.
Make sure to add (and commit) everything to the git repo, and it should be fine. Comes up when you import a file (in configuration.nix, or likewise), but the file is not added to your git repo. Is to make sure, that there are no errors when cloning the repo, and building from it.