Perhaps I am doing things wrong, but I am struggling to avoid absolute paths because when I use the following config with relative paths (not below), I get:
Have you created a git repository for your config files?
git init
git add flake.nix
git add ./home-manager/modules/cli/git.nix
git add ./home-manager/modules/cli/gitignore_global.ni
The first thing, nix does to read flake.nix, is copy everything from git, to /nix/store/k21jffv6hk8g2245dvns4zn9my3b5aaf-source/
and try to read your config files from there, or it will give you a error just like: error: getting status of '/nix/store/k21jffv6hk8g2245dvns4zn9my3b5aaf-source/home-manager/modules/cli/...': No such file or directory
(k21jffv6hk8g2245dvns4zn9my3b5aaf is a hash that changes everytime you change the content of your config files, that is how we have the rollback feature)
I suppose your structure is: (you forgot to say where is your flake.nix)
./.git # if you don't have a git is your problem
./flake.nix # if you don't add *.nix to git is your problem
./home-manager/modules/cli/git.nix # at least your flake.nix is expecting it like this
./home-manager/modules/cli/gitignore_global.nix
# try in your terminal
find /nix/store/k21jffv6hk8g2245dvns4zn9my3b5aaf-source/
If you added all files to git, your import of gitignore_global.nix is
programs.git.ignores = import ./gitignore_global.nix; # this path is relative to git.nix
Your gitignore_global.nix is missing quotes
[
## MacOS (https://github.com/github/gitignore/blob/4488915eec0b3a45b5c63ead28f286819c0917de/Global/macOS.gitignore)
#### General:
".AppleDouble"
".LSOverride"
### ....
]
It appears everything I path to is re-pathed from
/nix/store/...
, not from my~/.config
directory where I expect home manager to install git in a directory and a gitignores file generated from the file I have pathed to.
Sure it is, that makes your system reproducible
nix (and home-manager) does this:
- Copy all your repo to /nix/store/{hash}-source/
- check the nix code and paths
- build dependencies (ie helix)
- build your code (config in this case) and generate a /nix/store/{hash}-{pkgname} (yes, your configuration is now a package)
- link everything to your profile (ln -s /nix/store/{hash}-{pkgname} /nix/var/profiles/)
- link everything again from profile to your home or create files
You are failing in a step < 6, that is why no file has been created for you.