From 3a7bc25dfb62354739a55af8ab8ad5fb9b69f2a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Fri, 23 May 2025 23:17:59 +0200 Subject: [PATCH] Initial commit --- .envrc | 1 + .gitignore | 1 + flake.lock | 27 ++++++++++++++++++++++ flake.nix | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ go.mod | 3 +++ main.go | 9 ++++++++ 6 files changed, 108 insertions(+) create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 go.mod create mode 100644 main.go diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..92b2793 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.direnv diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..d87d5eb --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1747744144, + "narHash": "sha256-W7lqHp0qZiENCDwUZ5EX/lNhxjMdNapFnbErcbnP11Q=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2795c506fe8fb7b03c36ccb51f75b6df0ab2553f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..54f99c4 --- /dev/null +++ b/flake.nix @@ -0,0 +1,67 @@ +{ + description = "Monitoring tool for homelab"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + outputs = + { self, nixpkgs }: + let + allSystems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + forAllSystems = + f: + nixpkgs.lib.genAttrs allSystems ( + system: + f { + pkgs = import nixpkgs { inherit system; }; + } + ); + in + { + overlays.default = final: prev: { + labmon = self.packages.${prev.system}.default; + }; + + packages = forAllSystems ( + { pkgs }: + { + default = + let + src = pkgs.lib.sourceFilesBySuffices ./. [ + "go.mod" + "go.sum" + ".go" + ]; + version = pkgs.lib.strings.removePrefix "v" ( + builtins.elemAt (pkgs.lib.strings.split "\"" ( + pkgs.lib.lists.findFirst (x: pkgs.lib.strings.hasInfix "Version" x) null ( + pkgs.lib.strings.splitString "\n" (builtins.readFile ./main.go) + ) + )) 2 + ); + in + pkgs.buildGoModule { + version = version; + pname = "labmon"; + src = src; + vendorHash = pkgs.lib.fakeHash; + }; + } + ); + devShells = forAllSystems ( + { pkgs }: + { + default = pkgs.mkShell { + packages = with pkgs; [ + go + golangci-lint + ]; + }; + } + ); + }; +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..07522bc --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module git.t-juice.club/torjus/labmon + +go 1.24.3 diff --git a/main.go b/main.go new file mode 100644 index 0000000..186ca41 --- /dev/null +++ b/main.go @@ -0,0 +1,9 @@ +package main + +import "fmt" + +const Version = "0.1.0" + +func main() { + fmt.Println("Hello, World!") +}