diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..1f1ec81 --- /dev/null +++ b/flake.lock @@ -0,0 +1,41 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1637014545, + "narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "bba5dcc8e0b20ab664967ad83d24d64cb64ec4f4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1637156900, + "narHash": "sha256-nusyaSsL1RLyUEWufUUywDrGKMXw+4ugSSZ3ss8TSuw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "12fc0f19fefa9dff68bc3e0938b815ab8d89df90", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..69c0030 --- /dev/null +++ b/flake.nix @@ -0,0 +1,21 @@ +{ + description = "Samw's APC PDU MQTT bridge"; + + inputs.flake-utils.url = "github:numtide/flake-utils"; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let pkgs = import nixpkgs { inherit system; }; in + rec { + packages.apc2mqtt = pkgs.buildGoModule { + name = "apc2mqtt"; + src = self; + vendorSha256 = "sha256-GlRcuUNrsNnONigXut2xFx0kX+5k80Djn07c3UutCLU="; + ldflags = '' + -X main.version=${if self ? rev then self.rev else "dirty"} + ''; + }; + defaultPackage = packages.apc2mqtt; + } + ); +} diff --git a/main.go b/main.go index 5ee4b8e..6273184 100644 --- a/main.go +++ b/main.go @@ -14,6 +14,8 @@ import ( log "github.com/sirupsen/logrus" ) +var version = "unknown" + // OIDs of interest. // snmptranslate -m PowerNet-MIB -Pu -Tso | less const ( @@ -200,6 +202,7 @@ func spawnTarget(target targetConfig, mqttClient mqtt.Client) { func main() { var configpath = flag.String("conf", "config.toml", "Path to toml config file") flag.Parse() + log.Infof("Starting version %s", version) conf, err := parseConfig(*configpath) check(err)