My NixOS system configuration.
Category | Programs |
---|---|
Terminals | WezTerm |
Code Editors | Helix |
Shells | Fish |
Window Managers | Hyprland |
The configuration files for programs are written using two methods:
Which provides modules for configuring many popular programs.
out-of-store symlinks, using mkOutOfStoreSymlink
This method is especially comfortable for configurations in specific languages
(like lua
for WezTerm
), that way we can write the config in the language we
want (thus leveraging language server support, syntax highlighting, etc.), or
configs that provide hot-reload (like WezTerm
and Hyprland
).
At the time of writing, the mkOutOfStoreSymlink
function lacks any kind of
documentation, so briefly:
Using this function it is possible to make
home.file
create a symlink to a path outside the Nix store. For example, a Home Manager configuration containinghome.file."foo".source = config.lib.file.mkOutOfStoreSymlink ./bar;
would upon activation create a symlink
~/foo
that points to the absolute path of thebar
file relative the configuration file.
The commit message of the commit adding this function
Which means that it will create a symlink to the given path, instead of a read only symlink pointing to a copy of the file in the nix store.
This gives us the ability to edit the config file in the nix configuration
directory, in a way that will be synced immediately with the actual config file
(in ~/.config
for example), without the need of nixos-rebuild switch
.
It's important to notice that if we use flakes (which we are), we need to pass
the path as a string of the absolute path ("/fullpath"
instead of ../file
),
according to this post.
Fortunately, this can be simplified by using a helper function, adapted from
here
from this comment.
The helper is located in the helpers module (modules/common/helpers.nix
), and
can be used like so:
# home/rotemh/common/core/wezterm/default.nix
{
pkgs,
config,
...
}: {
home.packages = with pkgs; [
wezterm
];
xdg.configFile."wezterm" = {
source = config.lib.meta.mkMutableSymlink ./wezterm;
recursive = true;
};
}
Note, the helper uses the flake
field in the hostSpec
set, defined in the
host-spec
module, which is supposed to hold the path to the directory of the
system configuration flake (the directory of this README.md
). Currently, it's
defined as:
flake = lib.mkOption {
type = lib.types.str;
description = "The directory of this flake in the file system (not in store)";
default = let home = config.hostSpec.home; in "${home}/cfg";
};
So if you have the flake somewhere else in your filesystem, override this field.