From 07a03c05788b8f398e0fcea94266ae5394b275b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dav=C3=AD=C3=B0=20Steinn=20Geirsson?= Date: Fri, 20 Mar 2026 12:44:50 +0000 Subject: [PATCH] Add flake.nix for Nix builds and dev shell - Package builds with buildGoModule and CGO_ENABLED=0 - Dev shell provides go_latest, gopls, gotools Co-Authored-By: Claude Opus 4.6 (1M context) --- .gitignore | 1 + flake.lock | 43 +++++++++++++++++++++++++++++++++++++++++++ flake.nix | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index 1295872..dfcb56f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /.apikey /pve-exporter +/result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..f715625 --- /dev/null +++ b/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1773628058, + "narHash": "sha256-hpXH0z3K9xv0fHaje136KY872VT2T5uwxtezlAskQgY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f8573b9c935cfaa162dd62cc9e75ae2db86f85df", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "systems": "systems" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..22ea595 --- /dev/null +++ b/flake.nix @@ -0,0 +1,43 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + systems.url = "github:nix-systems/default"; + }; + + outputs = { + self, + nixpkgs, + systems, + }: let + eachSystem = f: + nixpkgs.lib.genAttrs (import systems) (system: + f (import nixpkgs {inherit system;})); + in { + packages = eachSystem (pkgs: rec { + default = pve-exporter; + pve-exporter = pkgs.buildGoModule { + pname = "pve-exporter"; + version = self.shortRev or self.dirtyShortRev or "dev"; + src = ./.; + vendorHash = "sha256-VC80sdNcahVbxUffNNntlXWOg+ZDalck61d6tL9aWsM="; + env.CGO_ENABLED = 0; + ldflags = ["-s" "-w"]; + doCheck = true; + meta = { + description = "Prometheus exporter for Proxmox VE"; + mainProgram = "pve-exporter"; + }; + }; + }); + + devShells = eachSystem (pkgs: { + default = pkgs.mkShell { + packages = with pkgs; [ + go_latest + gopls + gotools + ]; + }; + }); + }; +}