Skip to content

Commit

Permalink
fix: fix _agenix_generation being empty if readlink fails
Browse files Browse the repository at this point in the history
  • Loading branch information
teatwig committed Sep 11, 2024
1 parent f6291c5 commit 2e80d9d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions modules/age-home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ with lib; let
ageBin = lib.getExe config.age.package;

newGeneration = ''
_agenix_generation="$(basename "$(readlink "${cfg.secretsDir}")" || echo 0)"
_agenix_generation="$(basename "$(readlink "${cfg.secretsDir}" || echo 0)")"
(( ++_agenix_generation ))
echo "[agenix] creating new generation in ${cfg.secretsMountPoint}/$_agenix_generation"
mkdir -p "${cfg.secretsMountPoint}"
Expand Down Expand Up @@ -73,7 +73,7 @@ with lib; let
cfg.identityPaths;

cleanupAndLink = ''
_agenix_generation="$(basename "$(readlink "${cfg.secretsDir}")" || echo 0)"
_agenix_generation="$(basename "$(readlink "${cfg.secretsDir}" || echo 0)")"
(( ++_agenix_generation ))
echo "[agenix] symlinking new secrets to ${cfg.secretsDir} (generation $_agenix_generation)..."
ln -sfT "${cfg.secretsMountPoint}/$_agenix_generation" "${cfg.secretsDir}"
Expand Down
4 changes: 2 additions & 2 deletions modules/age.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ with lib; let
mount -t ramfs none "${cfg.secretsMountPoint}" -o nodev,nosuid,mode=0751
'';
newGeneration = ''
_agenix_generation="$(basename "$(readlink ${cfg.secretsDir})" || echo 0)"
_agenix_generation="$(basename "$(readlink "${cfg.secretsDir}" || echo 0)")"
(( ++_agenix_generation ))
echo "[agenix] creating new generation in ${cfg.secretsMountPoint}/$_agenix_generation"
mkdir -p "${cfg.secretsMountPoint}"
Expand Down Expand Up @@ -100,7 +100,7 @@ with lib; let
cfg.identityPaths;

cleanupAndLink = ''
_agenix_generation="$(basename "$(readlink ${cfg.secretsDir})" || echo 0)"
_agenix_generation="$(basename "$(readlink "${cfg.secretsDir}" || echo 0)")"
(( ++_agenix_generation ))
echo "[agenix] symlinking new secrets to ${cfg.secretsDir} (generation $_agenix_generation)..."
ln -sfT "${cfg.secretsMountPoint}/$_agenix_generation" ${cfg.secretsDir}
Expand Down

0 comments on commit 2e80d9d

Please sign in to comment.