mirror of
https://github.com/nmasur/dotfiles
synced 2025-07-06 19:00:14 +00:00
initial refactoring
This commit is contained in:
37
platforms/nixos/modules/services/identity.nix
Normal file
37
platforms/nixos/modules/services/identity.nix
Normal file
@ -0,0 +1,37 @@
|
||||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.services.wait-for-identity;
|
||||
in
|
||||
{
|
||||
|
||||
options.services.wait-for-identity = {
|
||||
enable = lib.mkEnableOption "Wait for identity file oneshot";
|
||||
identityFile = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
# Wait for secret to be placed on the machine
|
||||
systemd.services.wait-for-identity = {
|
||||
description = "Wait until identity file exists on the machine";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
};
|
||||
script = ''
|
||||
for i in $(seq 1 10); do
|
||||
if [ -f ${builtins.toString cfg.identityFile} ]; then
|
||||
echo "Identity file found."
|
||||
exit 0
|
||||
fi
|
||||
sleep 6
|
||||
done
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user