2017-02-01 17:26:55 +01:00
|
|
|
{pkgs, config, lib, ...}:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.hologram-agent;
|
|
|
|
|
|
|
|
cfgFile = pkgs.writeText "hologram-agent.json" (builtins.toJSON {
|
|
|
|
host = cfg.dialAddress;
|
|
|
|
});
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
services.hologram-agent = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Whether to enable the Hologram agent for AWS instance credentials";
|
|
|
|
};
|
|
|
|
|
|
|
|
dialAddress = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "localhost:3100";
|
|
|
|
description = "Hologram server and port.";
|
|
|
|
};
|
|
|
|
|
|
|
|
httpPort = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "80";
|
|
|
|
description = "Port for metadata service to listen on.";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2017-09-20 12:57:54 +02:00
|
|
|
boot.kernelModules = [ "dummy" ];
|
|
|
|
|
2017-12-03 06:02:45 +01:00
|
|
|
networking.interfaces.dummy0.ipv4.addresses = [
|
|
|
|
{ address = "169.254.169.254"; prefixLength = 32; }
|
|
|
|
];
|
2017-02-01 17:26:55 +01:00
|
|
|
|
|
|
|
systemd.services.hologram-agent = {
|
|
|
|
description = "Provide EC2 instance credentials to machines outside of EC2";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2020-04-28 03:50:34 +02:00
|
|
|
requires = [ "network-link-dummy0.service" "network-addresses-dummy0.service" ];
|
2017-02-01 17:26:55 +01:00
|
|
|
preStart = ''
|
2018-12-19 22:41:49 +01:00
|
|
|
/run/current-system/sw/bin/rm -fv /run/hologram.sock
|
2017-02-01 17:26:55 +01:00
|
|
|
'';
|
|
|
|
serviceConfig = {
|
2020-04-28 03:50:34 +02:00
|
|
|
ExecStart = "${pkgs.hologram}/bin/hologram-agent -debug -conf ${cfgFile} -port ${cfg.httpPort}";
|
2017-02-01 17:26:55 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
meta.maintainers = with lib.maintainers; [ nand0p ];
|
|
|
|
}
|