From d97d5abb66c35b0b818bbe9e7c84b94101b9f081 Mon Sep 17 00:00:00 2001 From: Shaw Vrana Date: Tue, 29 Aug 2023 15:07:57 -0700 Subject: [PATCH] Add default package to flake So we can pull the package in more easily from other projects since it's not in nixpkgs. --- flake.lock | 46 +++++++++++++++++++++++++++++++++++----------- flake.nix | 31 ++++++++++++++++++++++++++----- gomod2nix.toml | 21 +++++++++++++++++++++ 3 files changed, 82 insertions(+), 16 deletions(-) create mode 100644 gomod2nix.toml diff --git a/flake.lock b/flake.lock index a5239e4..04558fc 100644 --- a/flake.lock +++ b/flake.lock @@ -1,20 +1,25 @@ { "nodes": { - "flake-utils": { + "gomod2nix": { "inputs": { - "systems": "systems" + "nixpkgs": [ + "nixpkgs" + ], + "utils": [ + "utils" + ] }, "locked": { - "lastModified": 1687709756, - "narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7", + "lastModified": 1677459247, + "narHash": "sha256-JbakfAiPYmCCV224yAMq/XO0udN5coWv/oazblMKdoY=", + "owner": "tweag", + "repo": "gomod2nix", + "rev": "3cbf3a51fe32e2f57af4c52744e7228bab22983d", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "tweag", + "repo": "gomod2nix", "type": "github" } }, @@ -36,8 +41,9 @@ }, "root": { "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "gomod2nix": "gomod2nix", + "nixpkgs": "nixpkgs", + "utils": "utils" } }, "systems": { @@ -54,6 +60,24 @@ "repo": "default", "type": "github" } + }, + "utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1692799911, + "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 19182f8..a97e8d1 100644 --- a/flake.nix +++ b/flake.nix @@ -1,17 +1,38 @@ { description = "geniveev dev shell"; - inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - inputs.flake-utils.url = "github:numtide/flake-utils"; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + utils.url = "github:numtide/flake-utils"; + gomod2nix = { + url = "github:tweag/gomod2nix"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.utils.follows = "utils"; + }; + }; - outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem (system: let - pkgs = nixpkgs.legacyPackages.${system}; + outputs = { self, nixpkgs, utils, gomod2nix }: + utils.lib.eachDefaultSystem (system: + let pkgs = import nixpkgs { + inherit system; + overlays = [ + gomod2nix.overlays.default + ]; + }; in { + packages.default = pkgs.buildGoApplication { + pname = "geniveev"; + version = "0.1.1"; + pwd = ./.; + src = ./.; + modules = ./gomod2nix.toml; + }; + devShells.default = pkgs.mkShell { packages = [ pkgs.bashInteractive pkgs.go_1_20 pkgs.goreleaser + gomod2nix.packages.${system}.default ]; }; }); diff --git a/gomod2nix.toml b/gomod2nix.toml new file mode 100644 index 0000000..3b58f02 --- /dev/null +++ b/gomod2nix.toml @@ -0,0 +1,21 @@ +schema = 3 + +[mod] + [mod."github.com/inconshreveable/mousetrap"] + version = "v1.1.0" + hash = "sha256-XWlYH0c8IcxAwQTnIi6WYqq44nOKUylSWxWO/vi+8pE=" + [mod."github.com/pelletier/go-toml/v2"] + version = "v2.0.8" + hash = "sha256-wWxswr/lTq+McYbScmJM1ECKQ6eNJ5m44SM7TmrHThM=" + [mod."github.com/spf13/afero"] + version = "v1.9.5" + hash = "sha256-+XECQxkx0P+ZaQDm4dQ6ItMtHMj+2uNemEC18dsdor0=" + [mod."github.com/spf13/cobra"] + version = "v1.7.0" + hash = "sha256-bom9Zpnz8XPwx9IVF+GAodd3NVQ1dM1Uwxn8sy4Gmzs=" + [mod."github.com/spf13/pflag"] + version = "v1.0.5" + hash = "sha256-w9LLYzxxP74WHT4ouBspH/iQZXjuAh2WQCHsuvyEjAw=" + [mod."golang.org/x/text"] + version = "v0.10.0" + hash = "sha256-pt4Ce9+Bvf7f0Vo8oUZ71F1aSCcCxsx6Lg0cvanq7x8="