My systems always have some portion of config that is local-only. There are various techniques and tools we can use for managing the local system config.
Combine user owned cofing, a
local wrapper and
un-setting nixos-config
. With this combination we get
the benefits of all those solutions only losing out on some of the benefits of
the default cofing location.
Good
sudo
to edit.Bad
nixos-rebuild switch
to edit.nixos-rebuild switch
to maintain separate configs for the
system. Possibly fighting over what config to run.When first installing NixOS, the system configuration is placed in
/etc/nixos/configuration.nix
, and the nixos-rebuild
command looks there by
default for the nixos configuration to build the systems off of.
Good
nixos-rebuild switch
can edit.Bad
sudo
to edit.The system config files can be kept in a user’s directory, where they own the entire directory.
Good
sudo
to edit.Bad
nixos-rebuild switch
to edit.nixos-rebuild switch
to maintain separate configs for the
system. Possibly fighting over what config to run.NIX_PATH
or remembering
-I nixos-config=./foo.nix
with every call to nixos-rebuild
. This can lead
to a user unintentional building config from the default directly.We can provide a shell.nix
file in the local repo with the nix system config
that provides a version of nixos-rebuild
that wraps the nixos-rebuild
command with the -I nixos-config=./configuration.nix
option.
Good
Bad
nixos-config
Un-set nixos-config
system wide.
Good
Bad
nixos-rebuild
(even when its apparent)nixos-rebuild
We might be able to wrap nixos-rebuild
so that when a build is used for the
system (like with the boot
switch
sub commands), the local directory is
linked to /etc/nixos/
(or something like that).
Good
Bad
Users with perms can push directly and everyone can see it. Users without perms can request changes/config is pulled.
Good
Bad
Any deviation from the standard config means that when I use the stock nixos installer to install nixos or recover a system it I will have to try to bring the config back inline with how I want it. Providiing tools like installer images, recovery tools and local config templates could help me deal with that. Such tooling needs to be tested.
Providing a template repo and some tools that help augment local config’s nix shells and build could help too.
Can build config anywhere
nixos-rebuild
can be told to use a different path than the default to find
the default config. This is done by setting the NIX_PATH
variable
nixos-config
to another location. The NIX_PATH
can be manipulated by
prepending a variable+value pair to the environment variable combined by an =
and separated from other variables with a :
.
(ex. NIX_PATH="nixos-config=/home/username/config.nix:${NIX_PATH}"
) or by
running the a nix command with the -I
flag
(ex. nixos-rebuild boot -I nixos-config=/home/username/config.nix
).
“Provide usability tools - Make managing my NixOS configs on my machines easier.
So far this only includes my nixos-rebuild
wrapper, but I plan on adding tools
to make it easier to tests system-specific configs not in this repo while on my
systems.”