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 git@github.com:swebra/dotfiles.git ~/.dotfiles
nix run home-manager -- switch -b backup --flake ~/.dotfiles#default
Note 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.hooksPath
globally to point to your hooks. This overrides the default$GIT_DIR/hooks
value however, so for any local hooks to execute, you have to call them from your global hooks. - Setting
init.templateDir
globally 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 init
will 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 install
will "cowardly refuse" to install hooks ifcore.hooksPath
is 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-templatedir
command to generate hooks without settingcore.hooksPath
, warnings aboutinit.templateDir
not being set can be ignored:pre-commit init-templatedir --no-allow-missing-config .git
- Husky will locally set
core.hooksPath
to 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/hooks
and setcore.hooksPath
locally. This can be worked around by just unsetting the local config:git config --unset core.hooksPath