How would you handle the following scenario?:
Note: it looks ugly but it’s what I came up with.
When I nixos-install
my flake based nixos-config by running a setup-bashscript(partitioning,…). I have to set a nixosSystem
's specialArgs
variable use-agenix to false before running nixos-install. This variable is used inside the module to disable certain parts because agenix can’t be used before there is a ssh-key and it’s added and re-keyed.
- user password hash vs empty
- wifi passwords vs disable wifi
- mail password vs disable host status mails
All running hosts have it set to true and use agenix.
I could do:
sed 's| use-agenix = true;| use-agenix = false;|g' -i "/mnt/nixcfg/flake.nix"
But there are multiple entries/hosts. I could change them all and later overwrite it again or bash my way through the file and find the use-agenix for that specific hostname and change it.
Is there an easy bash way
to do this?
Is it possible/safe to read/edit it as json?
......
nixosConfigurations = { } // mkSystem rec {
inherit overlays;
hostname = "sl-think";
system = "x86_64-linux";
stateVersion = "22.05";
use-agenix = true;
modules = [
{
}
];
} // mkSystem rec {
inherit overlays;
hostname = "host-12345";
stateVersion = "22.11";
use-agenix = true;
modules = [
{
}
];
} // mkSystem rec {
inherit overlays;
hostname = "host-abc";
stateVersion = "22.11";
use-agenix = true;
modules = [
{
}
];
} // mkSystem rec {
inherit overlays;
hostname = "host-zzzz";
stateVersion = "22.11";
use-agenix = true;
......