cannot use with networking.hostFiles
Opened this issue · 3 comments
age.secrets."hosts" = { file = ./secrets/hosts.age; mode = "777"; };
networking.hostFiles = [config.age.secrets."hosts".path];
Hi,
I'm trying to use this with networking.hostFiles
which creates /etc/hosts by concatenating files.
It says file is not found with agenix encrypted file. Seems like file is not decrypted while evaluating networking.hostFiles. Is there any workaround for this?
This hack worked for me. But hope I could get some help to understand what's going on.
system.activationScripts."homelabhosts" = ''
cat /etc/hosts > /etc/hosts.bak
rm /etc/hosts
cat /etc/hosts.bak "${config.age.secrets."homelabhosts".path}" >> /etc/hosts
'';
I currently have the same problem. I tried your way, and all is correctly written to /etc/hosts
, but the added hosts are fully ignored by the system. I think the evaluation of the hosts is not done from
/etc/hosts`.
Is there a workaround for that?
My fault, the user ssh has no rights for /etc/hosts
. So i added chmod 644 /etc/hosts
to the activation script.
I do not like this approach, it feels so dirty.