From 5e2d9f71df6a675da65ba7657e929030b7d56310 Mon Sep 17 00:00:00 2001 From: "Ricardo (XenGi) Band" Date: Tue, 24 Oct 2023 15:59:04 +0200 Subject: [PATCH 1/5] 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=" From 3d4055854a9a2d0e405e3bbec923e82d8554e7b3 Mon Sep 17 00:00:00 2001 From: "Ricardo (XenGi) Band" Date: Tue, 24 Oct 2023 16:25:01 +0200 Subject: [PATCH 2/5] cleanup --- flake.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/flake.nix b/flake.nix index 95a5ae6..ade1064 100644 --- a/flake.nix +++ b/flake.nix @@ -11,7 +11,6 @@ }; outputs = { self, nixpkgs, flake-utils, gomod2nix }: flake-utils.lib.eachDefaultSystem (system: let - #pkgs = nixpkgs.legacyPackages.${system}; pkgs = import nixpkgs { inherit system; overlays = [ gomod2nix.overlays.default ]; From 2a856f4ecc3be45e403838f1bba4c1af7c733589 Mon Sep 17 00:00:00 2001 From: "Ricardo (XenGi) Band" Date: Tue, 24 Oct 2023 17:01:19 +0200 Subject: [PATCH 3/5] update --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 71203a0..8edcf61 100644 --- a/flake.lock +++ b/flake.lock @@ -43,11 +43,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1697379843, - "narHash": "sha256-RcnGuJgC2K/UpTy+d32piEoBXq2M+nVFzM3ah/ZdJzg=", + "lastModified": 1697915759, + "narHash": "sha256-WyMj5jGcecD+KC8gEs+wFth1J1wjisZf8kVZH13f1Zo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "12bdeb01ff9e2d3917e6a44037ed7df6e6c3df9d", + "rev": "51d906d2341c9e866e48c2efcaac0f2d70bfd43e", "type": "github" }, "original": { From 024df2bb9fa5f7e723c091e479c5e72521d9a64d Mon Sep 17 00:00:00 2001 From: "Ricardo (XenGi) Band" Date: Tue, 24 Oct 2023 17:08:45 +0200 Subject: [PATCH 4/5] update flake --- .gitignore | 2 ++ flake.nix | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8ddc10e..aca1950 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +result + # Created by https://www.toptal.com/developers/gitignore/api/linux,windows,macos,vim,goland+all,go,direnv # Edit at https://www.toptal.com/developers/gitignore?templates=linux,windows,macos,vim,goland+all,go,direnv diff --git a/flake.nix b/flake.nix index ade1064..e9c2495 100644 --- a/flake.nix +++ b/flake.nix @@ -22,15 +22,16 @@ modules = ./gomod2nix.toml; }; in { + defaultPackage = sanic; devShells.default = pkgs.mkShell { buildInputs = with pkgs; [ go gomod2nix.packages.${system}.default + sanic ]; packages = with pkgs; [ mpd mpc-cli - sanic ]; }; } From d4a4c0ab6ea986d72b1a09810c78ad81c03b54e6 Mon Sep 17 00:00:00 2001 From: "Ricardo (XenGi) Band" Date: Tue, 24 Oct 2023 17:09:51 +0200 Subject: [PATCH 5/5] update readme --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 91d24bc..c7fd935 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,14 @@ chaos music control inspired by [relaxx player][relaxx] - add music from other sources like youtube (`youtube-dl`) - add playlists from internet radios (`*.m3u`) +## development + +Build nix flake: + +```shell +nix build +``` + --- Made with ❤️ and 🐍.