at 25.11-pre 1.6 kB view raw
1{ 2 pkgs, 3 config, 4 lib, 5 ... 6}: 7let 8 cfg = config.services.hologram-agent; 9 10 cfgFile = pkgs.writeText "hologram-agent.json" ( 11 builtins.toJSON { 12 host = cfg.dialAddress; 13 } 14 ); 15in 16{ 17 options = { 18 services.hologram-agent = { 19 enable = lib.mkOption { 20 type = lib.types.bool; 21 default = false; 22 description = "Whether to enable the Hologram agent for AWS instance credentials"; 23 }; 24 25 dialAddress = lib.mkOption { 26 type = lib.types.str; 27 default = "localhost:3100"; 28 description = "Hologram server and port."; 29 }; 30 31 httpPort = lib.mkOption { 32 type = lib.types.str; 33 default = "80"; 34 description = "Port for metadata service to listen on."; 35 }; 36 37 }; 38 }; 39 40 config = lib.mkIf cfg.enable { 41 boot.kernelModules = [ "dummy" ]; 42 43 networking.interfaces.dummy0.ipv4.addresses = [ 44 { 45 address = "169.254.169.254"; 46 prefixLength = 32; 47 } 48 ]; 49 50 systemd.services.hologram-agent = { 51 description = "Provide EC2 instance credentials to machines outside of EC2"; 52 after = [ "network.target" ]; 53 wantedBy = [ "multi-user.target" ]; 54 requires = [ 55 "network-link-dummy0.service" 56 "network-addresses-dummy0.service" 57 ]; 58 preStart = '' 59 /run/current-system/sw/bin/rm -fv /run/hologram.sock 60 ''; 61 serviceConfig = { 62 ExecStart = "${pkgs.hologram}/bin/hologram-agent -debug -conf ${cfgFile} -port ${cfg.httpPort}"; 63 }; 64 }; 65 66 }; 67 68 meta.maintainers = [ ]; 69}