From 5e2d9f71df6a675da65ba7657e929030b7d56310 Mon Sep 17 00:00:00 2001 From: "Ricardo (XenGi) Band" Date: Tue, 24 Oct 2023 15:59:04 +0200 Subject: [PATCH] build nix package --- flake.lock | 24 ++++++++++++++++++++++++ flake.nix | 26 ++++++++++++++++++++++---- gomod2nix.toml | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 gomod2nix.toml diff --git a/flake.lock b/flake.lock index fdf2e45..71203a0 100644 --- a/flake.lock +++ b/flake.lock @@ -18,6 +18,29 @@ "type": "github" } }, + "gomod2nix": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1694616124, + "narHash": "sha256-c49BVhQKw3XDRgt+y+uPAbArtgUlMXCET6VxEBmzHXE=", + "owner": "tweag", + "repo": "gomod2nix", + "rev": "f95720e89af6165c8c0aa77f180461fe786f3c21", + "type": "github" + }, + "original": { + "owner": "tweag", + "repo": "gomod2nix", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1697379843, @@ -37,6 +60,7 @@ "root": { "inputs": { "flake-utils": "flake-utils", + "gomod2nix": "gomod2nix", "nixpkgs": "nixpkgs" } }, diff --git a/flake.nix b/flake.nix index 2a4d9b8..95a5ae6 100644 --- a/flake.nix +++ b/flake.nix @@ -3,19 +3,37 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; flake-utils.url = "github:numtide/flake-utils"; + gomod2nix = { + url = "github:tweag/gomod2nix"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-utils.follows = "flake-utils"; + }; }; - outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system: + outputs = { self, nixpkgs, flake-utils, gomod2nix }: flake-utils.lib.eachDefaultSystem (system: let - pkgs = nixpkgs.legacyPackages.${system}; + #pkgs = nixpkgs.legacyPackages.${system}; + pkgs = import nixpkgs { + inherit system; + overlays = [ gomod2nix.overlays.default ]; + }; + sanic = pkgs.buildGoApplication { + pname = "sanic"; + version = "0.0.1"; + src = ./.; + modules = ./gomod2nix.toml; + }; in { devShells.default = pkgs.mkShell { - packages = with pkgs; [ + buildInputs = with pkgs; [ go + gomod2nix.packages.${system}.default + ]; + packages = with pkgs; [ mpd mpc-cli + sanic ]; }; } ); } - diff --git a/gomod2nix.toml b/gomod2nix.toml new file mode 100644 index 0000000..c71e6ea --- /dev/null +++ b/gomod2nix.toml @@ -0,0 +1,33 @@ +schema = 3 + +[mod] + [mod."github.com/labstack/echo/v4"] + version = "v4.11.2" + hash = "sha256-OECk2lBNKKBpzJ58XMhpp8KI/tqE0TnyddWyhI+nHPs=" + [mod."github.com/labstack/gommon"] + version = "v0.4.0" + hash = "sha256-xISAIJEu2xh0hoWsORbgjnz3rDK3ft3hrvmxt0wfHVw=" + [mod."github.com/mattn/go-colorable"] + version = "v0.1.13" + hash = "sha256-qb3Qbo0CELGRIzvw7NVM1g/aayaz4Tguppk9MD2/OI8=" + [mod."github.com/mattn/go-isatty"] + version = "v0.0.19" + hash = "sha256-wYQqGxeqV3Elkmn26Md8mKZ/viw598R4Ych3vtt72YE=" + [mod."github.com/valyala/bytebufferpool"] + version = "v1.0.0" + hash = "sha256-I9FPZ3kCNRB+o0dpMwBnwZ35Fj9+ThvITn8a3Jr8mAY=" + [mod."github.com/valyala/fasttemplate"] + version = "v1.2.2" + hash = "sha256-gp+lNXE8zjO+qJDM/YbS6V43HFsYP6PKn4ux1qa5lZ0=" + [mod."golang.org/x/crypto"] + version = "v0.14.0" + hash = "sha256-UUSt3X/i34r1K0mU+Y5IzljX5HYy07JcHh39Pm1MU+o=" + [mod."golang.org/x/net"] + version = "v0.17.0" + hash = "sha256-qRawHWLSsJ06QNbLhUWPXGVSO1eaioeC9xZlUEWN8J8=" + [mod."golang.org/x/sys"] + version = "v0.13.0" + hash = "sha256-/+RDZ0a0oEfJ0k304VqpJpdrl2ZXa3yFlOxy4mjW7w0=" + [mod."golang.org/x/text"] + version = "v0.13.0" + hash = "sha256-J34dbc8UNVIdRJUZP7jPt11oxuwG8VvrOOylxE7V3oA="