From 4a61b4dc3db9e8fe8fbb31c2bee655cf826173f4 Mon Sep 17 00:00:00 2001 From: Technofab Date: Mon, 26 Jun 2023 00:26:48 +0200 Subject: [PATCH] chore: add nix flake --- .gitignore | 3 ++- flake.lock | 41 +++++++++++++++++++++++++++++++++++++++++ flake.nix | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index 5358d08..77596a3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .vscode .idea -dist \ No newline at end of file +dist +result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..239e0e2 --- /dev/null +++ b/flake.lock @@ -0,0 +1,41 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1687555006, + "narHash": "sha256-GD2Kqb/DXQBRJcHqkM2qFZqbVenyO7Co/80JHRMg2U0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "33223d479ffde3d05ac16c6dff04ae43cc27e577", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-23.05", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "systems": "systems" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "id": "systems", + "type": "indirect" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..0015767 --- /dev/null +++ b/flake.nix @@ -0,0 +1,34 @@ +{ + description = "Powerproto"; + inputs.nixpkgs.url = "nixpkgs/nixos-23.05"; + + outputs = { self, nixpkgs, systems }: + let + version = "0.4.2"; + forEachSystem = nixpkgs.lib.genAttrs (import systems); + nixpkgsFor = forEachSystem (system: import nixpkgs { inherit system; }); + in { + # Provide some binary packages for selected system types. + packages = forEachSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + in { + powerproto = pkgs.buildGoModule { + pname = "powerproto"; + inherit version; + + src = ./.; + CGO_ENABLED = 0; + + ldflags = [ "-s" "-w" "-X main.Version=${version}" ]; + + vendorSha256 = "sha256-MwL6eA5u7dusWDIgbfyyvNqoP4ZhpSWaQuLsUI+YU9k="; + + doCheck = false; + }; + } + ); + + defaultPackage = forEachSystem (system: self.packages.${system}.powerproto); + }; +}