From 45407132b53530ddf2241b3fa678ba23025c4dd2 Mon Sep 17 00:00:00 2001 From: Bastien Riviere Date: Sun, 3 Sep 2023 18:12:24 +0200 Subject: [PATCH] chore: add gomod2nix --- flake.lock | 63 +++++++++++++++++++++++++++++++++++++++++++++----- flake.nix | 18 +++++++++++++++ gomod2nix.toml | 3 +++ 3 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 gomod2nix.toml diff --git a/flake.lock b/flake.lock index 9b8269d..a82ebdd 100644 --- a/flake.lock +++ b/flake.lock @@ -17,18 +17,37 @@ "type": "indirect" } }, + "gomod2nix": { + "inputs": { + "nixpkgs": "nixpkgs", + "utils": "utils" + }, + "locked": { + "lastModified": 1677459247, + "narHash": "sha256-JbakfAiPYmCCV224yAMq/XO0udN5coWv/oazblMKdoY=", + "owner": "nix-community", + "repo": "gomod2nix", + "rev": "3cbf3a51fe32e2f57af4c52744e7228bab22983d", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "gomod2nix", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1693663421, - "narHash": "sha256-ImMIlWE/idjcZAfxKK8sQA7A1Gi/O58u5/CJA+mxvl8=", + "lastModified": 1658285632, + "narHash": "sha256-zRS5S/hoeDGUbO+L95wXG9vJNwsSYcl93XiD0HQBXLk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e56990880811a451abd32515698c712788be5720", + "rev": "5342fc6fb59d0595d26883c3cadff16ce58e44f3", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-unstable", + "ref": "master", "repo": "nixpkgs", "type": "github" } @@ -52,6 +71,22 @@ } }, "nixpkgs_2": { + "locked": { + "lastModified": 1693663421, + "narHash": "sha256-ImMIlWE/idjcZAfxKK8sQA7A1Gi/O58u5/CJA+mxvl8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e56990880811a451abd32515698c712788be5720", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { "locked": { "lastModified": 1691654369, "narHash": "sha256-gSILTEx1jRaJjwZxRlnu3ZwMn1FVNk80qlwiCX8kmpo=", @@ -70,13 +105,14 @@ "root": { "inputs": { "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs", + "gomod2nix": "gomod2nix", + "nixpkgs": "nixpkgs_2", "treefmt-nix": "treefmt-nix" } }, "treefmt-nix": { "inputs": { - "nixpkgs": "nixpkgs_2" + "nixpkgs": "nixpkgs_3" }, "locked": { "lastModified": 1693689099, @@ -91,6 +127,21 @@ "repo": "treefmt-nix", "type": "github" } + }, + "utils": { + "locked": { + "lastModified": 1653893745, + "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 757ce8c..16460c2 100644 --- a/flake.nix +++ b/flake.nix @@ -4,6 +4,7 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + gomod2nix.url = "github:nix-community/gomod2nix"; treefmt-nix.url = "github:numtide/treefmt-nix"; }; @@ -21,6 +22,22 @@ system, ... }: { + _module.args.pkgs = import inputs.nixpkgs { + inherit system; + overlays = [ + inputs.gomod2nix.overlays.default + ]; + config = {}; + }; + + packages.default = pkgs.buildGoApplication { + pname = "sealme"; + version = "0.1"; + pwd = ./.; + src = ./.; + modules = ./gomod2nix.toml; + }; + treefmt = { projectRootFile = ".git/config"; programs = { @@ -34,6 +51,7 @@ # Go tools go gopls + gomod2nix ]; }; }; diff --git a/gomod2nix.toml b/gomod2nix.toml new file mode 100644 index 0000000..43cd4cf --- /dev/null +++ b/gomod2nix.toml @@ -0,0 +1,3 @@ +schema = 3 + +[mod]