Skip to content

Commit

Permalink
do not use activation script for script with dependencies
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ibizaman committed Nov 15, 2024
1 parent 6bdd8fe commit 6a3c43d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions modules/blocks/restic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,13 @@ in
mkMerge (flatten (mapAttrsToList mkSettings (enabledInstances // enabledDatabases)));
}
{
system.activationScripts = let
systemd.services = let
mkEnv = name: instance:
nameValuePair "${fullName name instance.settings.repository}_gen"
(shblib.replaceSecrets {
nameValuePair "${fullName name instance.settings.repository}_restore_gen" {
enable = true;
wantedBy = [ "multi-user.target" ];
serviceConfig.Type = "oneshot";
script = (shblib.replaceSecrets {
userConfig = instance.settings.repository.secrets // {
RESTIC_PASSWORD_FILE = instance.settings.passphraseFile;
RESTIC_REPOSITORY = instance.settings.repository.path;
Expand All @@ -375,6 +378,7 @@ in
generator = name: v: pkgs.writeText (fullName name instance.settings.repository) (generators.toINIWithGlobalSection {} { globalSection = v; });
user = instance.request.user;
});
};
in
listToAttrs (flatten (mapAttrsToList mkEnv (cfg.instances // cfg.databases)));
}
Expand Down

0 comments on commit 6a3c43d

Please sign in to comment.