Flake-based NixOS/home-manager configuration.
Assuming nix is installed and flakes are enabled, apply the default configuration with the following:
nix run home-manager -- switch -b backup --flake github:swebra/dotfiles#default
# or
git clone [email protected]:swebra/dotfiles.git ~/.dotfiles
nix run home-manager -- switch -b backup --flake ~/.dotfiles#defaultNote the user is expected to match home.username in hosts/default/home.nix, which is eric by default.
If selecting a different configuration that references private values (see below), access to the private repo through SSH will also be required.
Sensitive configuration is stored in a private repo and referenced here through a flake input called private.
The top-level default.nix files in the home-manager/ and nixos/ dirs programmatically import all sibling/child files and generates their enable options using recursiveOptionedImport. See the function's definition in myLib/ for more details, but also note that traditional, explicit imports of these files (imports = [ ./path/to/file ]) would still work.
There are two ways to manage global git hooks:
- (What is done here) Setting
core.hooksPathglobally to point to your hooks. This overrides the default$GIT_DIR/hooksvalue however, so for any local hooks to execute, you have to call them from your global hooks. - Setting
init.templateDirglobally to point to a template directory with your global hooks. Your hooks will then be automatically copied into the local$GIT_DIR/hooks(.git/hooks) directory of any newly created repos, and existing repos can be updated by rerunninggit init. Rerunninggit initwill not overwrite any files however, so if you already had local hooks or if you ever update your global hook, you have to manually copy.
Unfortunately both methods can temporarily broken by in-repo hook management tools such as pre-commit or husky. For method 1:
pre-commit installwill "cowardly refuse" to install hooks ifcore.hooksPathis set anywhere (locally or globally, even if it's set to the default value of.git/hooks), and a proposed override for this behavior was rejected. This can be worked around by using theinit-templatedircommand to generate hooks without settingcore.hooksPath, warnings aboutinit.templateDirnot being set can be ignored:pre-commit init-templatedir --no-allow-missing-config .git
- Husky will locally set
core.hooksPathto its directory of hooks, which points git away from your global hooks. This can be worked around by un-setting the local path and symlinking the husky hooks to the default hook location so the global hooks still call the local hooks:git config --unset core.hooksPath rm -r .git/hooks # Symlink the husky hooks to the default location # A full path must be used, hence $(pwd) ln -s $(pwd)/<path/to/husky/hooks/> .git/hooks
- Other tools like git-hooks.nix simply populate
.git/hooksand setcore.hooksPathlocally. This can be worked around by just unsetting the local config:git config --unset core.hooksPath