Do not use activation script for script with dependencies (#348)
The issue with activation script is the order is alphabetical, meaning the order the script is assembled is not really set in stone. Here, because the script had a name starting with `restic`, it was ran before the `sops` secret generation script. And since the restic script was trying to use the secrets, it failed. And if the activation script fails, you get a kernel panic.
This commit is contained in:
parent
6bdd8febe3
commit
4726593ea9
1 changed files with 7 additions and 3 deletions
|
|
@ -363,10 +363,13 @@ in
|
||||||
mkMerge (flatten (mapAttrsToList mkSettings (enabledInstances // enabledDatabases)));
|
mkMerge (flatten (mapAttrsToList mkSettings (enabledInstances // enabledDatabases)));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
system.activationScripts = let
|
systemd.services = let
|
||||||
mkEnv = name: instance:
|
mkEnv = name: instance:
|
||||||
nameValuePair "${fullName name instance.settings.repository}_gen"
|
nameValuePair "${fullName name instance.settings.repository}_restore_gen" {
|
||||||
(shblib.replaceSecrets {
|
enable = true;
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
serviceConfig.Type = "oneshot";
|
||||||
|
script = (shblib.replaceSecrets {
|
||||||
userConfig = instance.settings.repository.secrets // {
|
userConfig = instance.settings.repository.secrets // {
|
||||||
RESTIC_PASSWORD_FILE = instance.settings.passphraseFile;
|
RESTIC_PASSWORD_FILE = instance.settings.passphraseFile;
|
||||||
RESTIC_REPOSITORY = instance.settings.repository.path;
|
RESTIC_REPOSITORY = instance.settings.repository.path;
|
||||||
|
|
@ -375,6 +378,7 @@ in
|
||||||
generator = name: v: pkgs.writeText (fullName name instance.settings.repository) (generators.toINIWithGlobalSection {} { globalSection = v; });
|
generator = name: v: pkgs.writeText (fullName name instance.settings.repository) (generators.toINIWithGlobalSection {} { globalSection = v; });
|
||||||
user = instance.request.user;
|
user = instance.request.user;
|
||||||
});
|
});
|
||||||
|
};
|
||||||
in
|
in
|
||||||
listToAttrs (flatten (mapAttrsToList mkEnv (cfg.instances // cfg.databases)));
|
listToAttrs (flatten (mapAttrsToList mkEnv (cfg.instances // cfg.databases)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue