---
Function {
 argument: None,
 arguments: FunctionArguments {
  arguments: [
   FunctionArgument {
    identifier: "pkgs",
    default: None,
   },
   FunctionArgument {
    identifier: "lib",
    default: None,
   },
   FunctionArgument {
    identifier: "config",
    default: None,
   },
  ],
  ellipsis: true,
 },
 definition: With {
  expression: Variable {
   identifier: "lib",
   position: (3, 6),
  },
  target: LetIn {
   bindings: [
    KeyValue(
     AttributePath {
      attributes: [
       Raw {
        content: "cfg",
        position: (6, 3),
       },
      ],
     },
     PropertyAccess {
      expression: Variable {
       identifier: "config",
       position: (6, 9),
      },
      attribute_path: AttributePath {
       attributes: [
        Raw {
         content: "services",
         position: (6, 16),
        },
        Raw {
         content: "telegraf",
         position: (6, 25),
        },
       ],
      },
      default: None,
     },
    ),
    KeyValue(
     AttributePath {
      attributes: [
       Raw {
        content: "settingsFormat",
        position: (8, 3),
       },
      ],
     },
     FunctionApplication {
      function: PropertyAccess {
       expression: Variable {
        identifier: "pkgs",
        position: (8, 20),
       },
       attribute_path: AttributePath {
        attributes: [
         Raw {
          content: "formats",
          position: (8, 25),
         },
         Raw {
          content: "toml",
          position: (8, 33),
         },
        ],
       },
       default: None,
      },
      arguments: [
       Map {
        bindings: [],
        recursive: false,
        position: (8, 38),
       },
      ],
     },
    ),
    KeyValue(
     AttributePath {
      attributes: [
       Raw {
        content: "configFile",
        position: (9, 3),
       },
      ],
     },
     FunctionApplication {
      function: PropertyAccess {
       expression: Variable {
        identifier: "settingsFormat",
        position: (9, 16),
       },
       attribute_path: AttributePath {
        attributes: [
         Raw {
          content: "generate",
          position: (9, 31),
         },
        ],
       },
       default: None,
      },
      arguments: [
       String {
        parts: [
         Raw {
          content: "config.toml",
          position: (9, 41),
         },
        ],
       },
       PropertyAccess {
        expression: Variable {
         identifier: "cfg",
         position: (9, 54),
        },
        attribute_path: AttributePath {
         attributes: [
          Raw {
           content: "extraConfig",
           position: (9, 58),
          },
         ],
        },
        default: None,
       },
      ],
     },
    ),
   ],
   target: Map {
    bindings: [
     KeyValue(
      AttributePath {
       attributes: [
        Raw {
         content: "options",
         position: (12, 3),
        },
       ],
      },
      Map {
       bindings: [
        KeyValue(
         AttributePath {
          attributes: [
           Raw {
            content: "services",
            position: (13, 5),
           },
           Raw {
            content: "telegraf",
            position: (13, 14),
           },
          ],
         },
         Map {
          bindings: [
           KeyValue(
            AttributePath {
             attributes: [
              Raw {
               content: "enable",
               position: (14, 7),
              },
             ],
            },
            FunctionApplication {
             function: Variable {
              identifier: "mkEnableOption",
              position: (14, 16),
             },
             arguments: [
              String {
               parts: [
                Raw {
                 content: "telegraf server",
                 position: (14, 32),
                },
               ],
              },
             ],
            },
           ),
           KeyValue(
            AttributePath {
             attributes: [
              Raw {
               content: "package",
               position: (16, 7),
              },
             ],
            },
            FunctionApplication {
             function: Variable {
              identifier: "mkOption",
              position: (16, 17),
             },
             arguments: [
              Map {
               bindings: [
                KeyValue(
                 AttributePath {
                  attributes: [
                   Raw {
                    content: "default",
                    position: (17, 9),
                   },
                  ],
                 },
                 PropertyAccess {
                  expression: Variable {
                   identifier: "pkgs",
                   position: (17, 19),
                  },
                  attribute_path: AttributePath {
                   attributes: [
                    Raw {
                     content: "telegraf",
                     position: (17, 24),
                    },
                   ],
                  },
                  default: None,
                 },
                ),
                KeyValue(
                 AttributePath {
                  attributes: [
                   Raw {
                    content: "defaultText",
                    position: (18, 9),
                   },
                  ],
                 },
                 FunctionApplication {
                  function: Variable {
                   identifier: "literalExpression",
                   position: (18, 23),
                  },
                  arguments: [
                   String {
                    parts: [
                     Raw {
                      content: "pkgs.telegraf",
                      position: (18, 42),
                     },
                    ],
                   },
                  ],
                 },
                ),
                KeyValue(
                 AttributePath {
                  attributes: [
                   Raw {
                    content: "description",
                    position: (19, 9),
                   },
                  ],
                 },
                 String {
                  parts: [
                   Raw {
                    content: "Which telegraf derivation to use",
                    position: (19, 24),
                   },
                  ],
                 },
                ),
                KeyValue(
                 AttributePath {
                  attributes: [
                   Raw {
                    content: "type",
                    position: (20, 9),
                   },
                  ],
                 },
                 PropertyAccess {
                  expression: Variable {
                   identifier: "types",
                   position: (20, 16),
                  },
                  attribute_path: AttributePath {
                   attributes: [
                    Raw {
                     content: "package",
                     position: (20, 22),
                    },
                   ],
                  },
                  default: None,
                 },
                ),
               ],
               recursive: false,
               position: (16, 26),
              },
             ],
            },
           ),
           KeyValue(
            AttributePath {
             attributes: [
              Raw {
               content: "environmentFiles",
               position: (23, 7),
              },
             ],
            },
            FunctionApplication {
             function: Variable {
              identifier: "mkOption",
              position: (23, 26),
             },
             arguments: [
              Map {
               bindings: [
                KeyValue(
                 AttributePath {
                  attributes: [
                   Raw {
                    content: "type",
                    position: (24, 9),
                   },
                  ],
                 },
                 FunctionApplication {
                  function: PropertyAccess {
                   expression: Variable {
                    identifier: "types",
                    position: (24, 16),
                   },
                   attribute_path: AttributePath {
                    attributes: [
                     Raw {
                      content: "listOf",
                      position: (24, 22),
                     },
                    ],
                   },
                   default: None,
                  },
                  arguments: [
                   PropertyAccess {
                    expression: Variable {
                     identifier: "types",
                     position: (24, 29),
                    },
                    attribute_path: AttributePath {
                     attributes: [
                      Raw {
                       content: "path",
                       position: (24, 35),
                      },
                     ],
                    },
                    default: None,
                   },
                  ],
                 },
                ),
                KeyValue(
                 AttributePath {
                  attributes: [
                   Raw {
                    content: "default",
                    position: (25, 9),
                   },
                  ],
                 },
                 List {
                  elements: [],
                  position: (25, 19),
                 },
                ),
                KeyValue(
                 AttributePath {
                  attributes: [
                   Raw {
                    content: "example",
                    position: (26, 9),
                   },
                  ],
                 },
                 List {
                  elements: [
                   String {
                    parts: [
                     Raw {
                      content: "/run/keys/telegraf.env",
                      position: (26, 22),
                     },
                    ],
                   },
                  ],
                  position: (26, 19),
                 },
                ),
                KeyValue(
                 AttributePath {
                  attributes: [
                   Raw {
                    content: "description",
                    position: (27, 9),
                   },
                  ],
                 },
                 String {
                  parts: [
                   Raw {
                    content: "File to load as environment file. Environment variables from this file\nwill be interpolated into the config file using envsubst with this\nsyntax: <literal>$ENVIRONMENT</literal> or <literal>",
                    position: (28, 1),
                   },
                   Raw {
                    content: "$",
                    position: (30, 63),
                   },
                   Raw {
                    content: "{VARIABLE}</literal>.\nThis is useful to avoid putting secrets into the nix store.\n",
                    position: (30, 66),
                   },
                  ],
                 },
                ),
               ],
               recursive: false,
               position: (23, 35),
              },
             ],
            },
           ),
           KeyValue(
            AttributePath {
             attributes: [
              Raw {
               content: "extraConfig",
               position: (35, 7),
              },
             ],
            },
            FunctionApplication {
             function: Variable {
              identifier: "mkOption",
              position: (35, 21),
             },
             arguments: [
              Map {
               bindings: [
                KeyValue(
                 AttributePath {
                  attributes: [
                   Raw {
                    content: "default",
                    position: (36, 9),
                   },
                  ],
                 },
                 Map {
                  bindings: [],
                  recursive: false,
                  position: (36, 19),
                 },
                ),
                KeyValue(
                 AttributePath {
                  attributes: [
                   Raw {
                    content: "description",
                    position: (37, 9),
                   },
                  ],
                 },
                 String {
                  parts: [
                   Raw {
                    content: "Extra configuration options for telegraf",
                    position: (37, 24),
                   },
                  ],
                 },
                ),
                KeyValue(
                 AttributePath {
                  attributes: [
                   Raw {
                    content: "type",
                    position: (38, 9),
                   },
                  ],
                 },
                 PropertyAccess {
                  expression: Variable {
                   identifier: "settingsFormat",
                   position: (38, 16),
                  },
                  attribute_path: AttributePath {
                   attributes: [
                    Raw {
                     content: "type",
                     position: (38, 31),
                    },
                   ],
                  },
                  default: None,
                 },
                ),
                KeyValue(
                 AttributePath {
                  attributes: [
                   Raw {
                    content: "example",
                    position: (39, 9),
                   },
                  ],
                 },
                 Map {
                  bindings: [
                   KeyValue(
                    AttributePath {
                     attributes: [
                      Raw {
                       content: "outputs",
                       position: (40, 11),
                      },
                      Raw {
                       content: "influxdb",
                       position: (40, 19),
                      },
                     ],
                    },
                    Map {
                     bindings: [
                      KeyValue(
                       AttributePath {
                        attributes: [
                         Raw {
                          content: "urls",
                          position: (41, 13),
                         },
                        ],
                       },
                       List {
                        elements: [
                         String {
                          parts: [
                           Raw {
                            content: "http://localhost:8086",
                            position: (41, 22),
                           },
                          ],
                         },
                        ],
                        position: (41, 20),
                       },
                      ),
                      KeyValue(
                       AttributePath {
                        attributes: [
                         Raw {
                          content: "database",
                          position: (42, 13),
                         },
                        ],
                       },
                       String {
                        parts: [
                         Raw {
                          content: "telegraf",
                          position: (42, 25),
                         },
                        ],
                       },
                      ),
                     ],
                     recursive: false,
                     position: (40, 30),
                    },
                   ),
                   KeyValue(
                    AttributePath {
                     attributes: [
                      Raw {
                       content: "inputs",
                       position: (44, 11),
                      },
                      Raw {
                       content: "statsd",
                       position: (44, 18),
                      },
                     ],
                    },
                    Map {
                     bindings: [
                      KeyValue(
                       AttributePath {
                        attributes: [
                         Raw {
                          content: "service_address",
                          position: (45, 13),
                         },
                        ],
                       },
                       String {
                        parts: [
                         Raw {
                          content: ":8125",
                          position: (45, 32),
                         },
                        ],
                       },
                      ),
                      KeyValue(
                       AttributePath {
                        attributes: [
                         Raw {
                          content: "delete_timings",
                          position: (46, 13),
                         },
                        ],
                       },
                       Variable {
                        identifier: "true",
                        position: (46, 30),
                       },
                      ),
                     ],
                     recursive: false,
                     position: (44, 27),
                    },
                   ),
                  ],
                  recursive: false,
                  position: (39, 19),
                 },
                ),
               ],
               recursive: false,
               position: (35, 30),
              },
             ],
            },
           ),
          ],
          recursive: false,
          position: (13, 25),
         },
        ),
       ],
       recursive: false,
       position: (12, 13),
      },
     ),
     KeyValue(
      AttributePath {
       attributes: [
        Raw {
         content: "config",
         position: (55, 3),
        },
       ],
      },
      FunctionApplication {
       function: Variable {
        identifier: "mkIf",
        position: (55, 12),
       },
       arguments: [
        PropertyAccess {
         expression: Variable {
          identifier: "config",
          position: (55, 17),
         },
         attribute_path: AttributePath {
          attributes: [
           Raw {
            content: "services",
            position: (55, 24),
           },
           Raw {
            content: "telegraf",
            position: (55, 33),
           },
           Raw {
            content: "enable",
            position: (55, 42),
           },
          ],
         },
         default: None,
        },
        Map {
         bindings: [
          KeyValue(
           AttributePath {
            attributes: [
             Raw {
              content: "systemd",
              position: (56, 5),
             },
             Raw {
              content: "services",
              position: (56, 13),
             },
             Raw {
              content: "telegraf",
              position: (56, 22),
             },
            ],
           },
           LetIn {
            bindings: [
             KeyValue(
              AttributePath {
               attributes: [
                Raw {
                 content: "finalConfigFile",
                 position: (57, 7),
                },
               ],
              },
              IfThenElse {
               predicate: BinaryOperation {
                operator: EqualTo,
                operands: [
                 PropertyAccess {
                  expression: Variable {
                   identifier: "config",
                   position: (57, 28),
                  },
                  attribute_path: AttributePath {
                   attributes: [
                    Raw {
                     content: "services",
                     position: (57, 35),
                    },
                    Raw {
                     content: "telegraf",
                     position: (57, 44),
                    },
                    Raw {
                     content: "environmentFiles",
                     position: (57, 53),
                    },
                   ],
                  },
                  default: None,
                 },
                 List {
                  elements: [],
                  position: (57, 73),
                 },
                ],
                position: (57, 70),
               },
               then: Variable {
                identifier: "configFile",
                position: (58, 30),
               },
               else_: String {
                parts: [
                 Raw {
                  content: "/var/run/telegraf/config.toml",
                  position: (59, 31),
                 },
                ],
               },
               position: (57, 25),
              },
             ),
            ],
            target: Map {
             bindings: [
              KeyValue(
               AttributePath {
                attributes: [
                 Raw {
                  content: "description",
                  position: (61, 7),
                 },
                ],
               },
               String {
                parts: [
                 Raw {
                  content: "Telegraf Agent",
                  position: (61, 22),
                 },
                ],
               },
              ),
              KeyValue(
               AttributePath {
                attributes: [
                 Raw {
                  content: "wantedBy",
                  position: (62, 7),
                 },
                ],
               },
               List {
                elements: [
                 String {
                  parts: [
                   Raw {
                    content: "multi-user.target",
                    position: (62, 21),
                   },
                  ],
                 },
                ],
                position: (62, 18),
               },
              ),
              KeyValue(
               AttributePath {
                attributes: [
                 Raw {
                  content: "after",
                  position: (63, 7),
                 },
                ],
               },
               List {
                elements: [
                 String {
                  parts: [
                   Raw {
                    content: "network-online.target",
                    position: (63, 18),
                   },
                  ],
                 },
                ],
                position: (63, 15),
               },
              ),
              KeyValue(
               AttributePath {
                attributes: [
                 Raw {
                  content: "serviceConfig",
                  position: (64, 7),
                 },
                ],
               },
               Map {
                bindings: [
                 KeyValue(
                  AttributePath {
                   attributes: [
                    Raw {
                     content: "EnvironmentFile",
                     position: (65, 9),
                    },
                   ],
                  },
                  PropertyAccess {
                   expression: Variable {
                    identifier: "config",
                    position: (65, 27),
                   },
                   attribute_path: AttributePath {
                    attributes: [
                     Raw {
                      content: "services",
                      position: (65, 34),
                     },
                     Raw {
                      content: "telegraf",
                      position: (65, 43),
                     },
                     Raw {
                      content: "environmentFiles",
                      position: (65, 52),
                     },
                    ],
                   },
                   default: None,
                  },
                 ),
                 KeyValue(
                  AttributePath {
                   attributes: [
                    Raw {
                     content: "ExecStartPre",
                     position: (66, 9),
                    },
                   ],
                  },
                  FunctionApplication {
                   function: PropertyAccess {
                    expression: Variable {
                     identifier: "lib",
                     position: (66, 24),
                    },
                    attribute_path: AttributePath {
                     attributes: [
                      Raw {
                       content: "optional",
                       position: (66, 28),
                      },
                     ],
                    },
                    default: None,
                   },
                   arguments: [
                    BinaryOperation {
                     operator: NotEqualTo,
                     operands: [
                      PropertyAccess {
                       expression: Variable {
                        identifier: "config",
                        position: (66, 38),
                       },
                       attribute_path: AttributePath {
                        attributes: [
                         Raw {
                          content: "services",
                          position: (66, 45),
                         },
                         Raw {
                          content: "telegraf",
                          position: (66, 54),
                         },
                         Raw {
                          content: "environmentFiles",
                          position: (66, 63),
                         },
                        ],
                       },
                       default: None,
                      },
                      List {
                       elements: [],
                       position: (66, 83),
                      },
                     ],
                     position: (66, 80),
                    },
                    FunctionApplication {
                     function: PropertyAccess {
                      expression: Variable {
                       identifier: "pkgs",
                       position: (67, 12),
                      },
                      attribute_path: AttributePath {
                       attributes: [
                        Raw {
                         content: "writeShellScript",
                         position: (67, 17),
                        },
                       ],
                      },
                      default: None,
                     },
                     arguments: [
                      String {
                       parts: [
                        Raw {
                         content: "pre-start",
                         position: (67, 35),
                        },
                       ],
                      },
                      String {
                       parts: [
                        Raw {
                         content: "umask 077\n",
                         position: (68, 1),
                        },
                        Expression {
                         expression: PropertyAccess {
                          expression: Variable {
                           identifier: "pkgs",
                           position: (69, 15),
                          },
                          attribute_path: AttributePath {
                           attributes: [
                            Raw {
                             content: "envsubst",
                             position: (69, 20),
                            },
                           ],
                          },
                          default: None,
                         },
                        },
                        Raw {
                         content: "/bin/envsubst -i \"",
                         position: (69, 29),
                        },
                        Expression {
                         expression: Variable {
                          identifier: "configFile",
                          position: (69, 49),
                         },
                        },
                        Raw {
                         content: "\" > /var/run/telegraf/config.toml\n",
                         position: (69, 60),
                        },
                       ],
                      },
                     ],
                    },
                   ],
                  },
                 ),
                 KeyValue(
                  AttributePath {
                   attributes: [
                    Raw {
                     content: "ExecStart",
                     position: (71, 9),
                    },
                   ],
                  },
                  String {
                   parts: [
                    Expression {
                     expression: PropertyAccess {
                      expression: Variable {
                       identifier: "cfg",
                       position: (71, 22),
                      },
                      attribute_path: AttributePath {
                       attributes: [
                        Raw {
                         content: "package",
                         position: (71, 26),
                        },
                       ],
                      },
                      default: None,
                     },
                    },
                    Raw {
                     content: "/bin/telegraf -config ",
                     position: (71, 34),
                    },
                    Expression {
                     expression: Variable {
                      identifier: "finalConfigFile",
                      position: (71, 58),
                     },
                    },
                   ],
                  },
                 ),
                 KeyValue(
                  AttributePath {
                   attributes: [
                    Raw {
                     content: "ExecReload",
                     position: (72, 9),
                    },
                   ],
                  },
                  String {
                   parts: [
                    Expression {
                     expression: PropertyAccess {
                      expression: Variable {
                       identifier: "pkgs",
                       position: (72, 23),
                      },
                      attribute_path: AttributePath {
                       attributes: [
                        Raw {
                         content: "coreutils",
                         position: (72, 28),
                        },
                       ],
                      },
                      default: None,
                     },
                    },
                    Raw {
                     content: "/bin/kill -HUP $MAINPID",
                     position: (72, 38),
                    },
                   ],
                  },
                 ),
                 KeyValue(
                  AttributePath {
                   attributes: [
                    Raw {
                     content: "RuntimeDirectory",
                     position: (73, 9),
                    },
                   ],
                  },
                  String {
                   parts: [
                    Raw {
                     content: "telegraf",
                     position: (73, 29),
                    },
                   ],
                  },
                 ),
                 KeyValue(
                  AttributePath {
                   attributes: [
                    Raw {
                     content: "User",
                     position: (74, 9),
                    },
                   ],
                  },
                  String {
                   parts: [
                    Raw {
                     content: "telegraf",
                     position: (74, 17),
                    },
                   ],
                  },
                 ),
                 KeyValue(
                  AttributePath {
                   attributes: [
                    Raw {
                     content: "Group",
                     position: (75, 9),
                    },
                   ],
                  },
                  String {
                   parts: [
                    Raw {
                     content: "telegraf",
                     position: (75, 18),
                    },
                   ],
                  },
                 ),
                 KeyValue(
                  AttributePath {
                   attributes: [
                    Raw {
                     content: "Restart",
                     position: (76, 9),
                    },
                   ],
                  },
                  String {
                   parts: [
                    Raw {
                     content: "on-failure",
                     position: (76, 20),
                    },
                   ],
                  },
                 ),
                 KeyValue(
                  AttributePath {
                   attributes: [
                    Raw {
                     content: "AmbientCapabilities",
                     position: (78, 9),
                    },
                   ],
                  },
                  List {
                   elements: [
                    String {
                     parts: [
                      Raw {
                       content: "CAP_NET_RAW",
                       position: (78, 34),
                      },
                     ],
                    },
                   ],
                   position: (78, 31),
                  },
                 ),
                ],
                recursive: false,
                position: (64, 23),
               },
              ),
             ],
             recursive: false,
             position: (60, 8),
            },
            position: (56, 33),
           },
          ),
          KeyValue(
           AttributePath {
            attributes: [
             Raw {
              content: "users",
              position: (82, 5),
             },
             Raw {
              content: "users",
              position: (82, 11),
             },
             Raw {
              content: "telegraf",
              position: (82, 17),
             },
            ],
           },
           Map {
            bindings: [
             KeyValue(
              AttributePath {
               attributes: [
                Raw {
                 content: "uid",
                 position: (83, 7),
                },
               ],
              },
              PropertyAccess {
               expression: Variable {
                identifier: "config",
                position: (83, 13),
               },
               attribute_path: AttributePath {
                attributes: [
                 Raw {
                  content: "ids",
                  position: (83, 20),
                 },
                 Raw {
                  content: "uids",
                  position: (83, 24),
                 },
                 Raw {
                  content: "telegraf",
                  position: (83, 29),
                 },
                ],
               },
               default: None,
              },
             ),
             KeyValue(
              AttributePath {
               attributes: [
                Raw {
                 content: "group",
                 position: (84, 7),
                },
               ],
              },
              String {
               parts: [
                Raw {
                 content: "telegraf",
                 position: (84, 16),
                },
               ],
              },
             ),
             KeyValue(
              AttributePath {
               attributes: [
                Raw {
                 content: "description",
                 position: (85, 7),
                },
               ],
              },
              String {
               parts: [
                Raw {
                 content: "telegraf daemon user",
                 position: (85, 22),
                },
               ],
              },
             ),
            ],
            recursive: false,
            position: (82, 28),
           },
          ),
          KeyValue(
           AttributePath {
            attributes: [
             Raw {
              content: "users",
              position: (88, 5),
             },
             Raw {
              content: "groups",
              position: (88, 11),
             },
             Raw {
              content: "telegraf",
              position: (88, 18),
             },
            ],
           },
           Map {
            bindings: [],
            recursive: false,
            position: (88, 29),
           },
          ),
         ],
         recursive: false,
         position: (55, 49),
        },
       ],
      },
     ),
    ],
    recursive: false,
    position: (10, 4),
   },
   position: (5, 1),
  },
  position: (3, 1),
 },
 position: (1, 1),
}