nix: use buildGoModule in favor of gomod2nix
Anirudh Oppiliappan x@icyphox.sh
Mon, 27 May 2024 13:56:09 +0300
6 files changed,
52 insertions(+),
159 deletions(-)
M
flake.lock
→
flake.lock
@@ -1,91 +1,23 @@
{ "nodes": { - "flake-utils": { - "locked": { - "lastModified": 1678901627, - "narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "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": 1658285632, - "narHash": "sha256-zRS5S/hoeDGUbO+L95wXG9vJNwsSYcl93XiD0HQBXLk=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "5342fc6fb59d0595d26883c3cadff16ce58e44f3", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "master", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1678898370, - "narHash": "sha256-xTICr1j+uat5hk9FyuPOFGxpWHdJRibwZC+ATi0RbtE=", - "owner": "NixOS", + "lastModified": 1716807034, + "narHash": "sha256-AQwfMBtC8tiDZHEgLssOU4qUiRhC2nO+YdxAvZXeW7o=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "ac718d02867a84b42522a0ece52d841188208f2c", + "rev": "e751fce87c5d9a8c9375b59d5b508a34a76b5623", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "nixos-unstable", + "owner": "nixos", "repo": "nixpkgs", "type": "github" } }, "root": { "inputs": { - "flake-utils": "flake-utils", - "gomod2nix": "gomod2nix", - "nixpkgs": "nixpkgs_2" - } - }, - "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" + "nixpkgs": "nixpkgs" } } },
M
flake.nix
→
flake.nix
@@ -1,26 +1,48 @@
{ description = "a fast and minimal static site generator"; - inputs = + inputs.nixpkgs.url = "github:nixos/nixpkgs"; + + outputs = + { self + , nixpkgs + , + }: + let + supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); + in { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - gomod2nix.url = "github:nix-community/gomod2nix"; - }; - - outputs = { self, nixpkgs, flake-utils, gomod2nix }: - (flake-utils.lib.eachDefaultSystem - (system: + overlay = final: prev: { + vite = self.packages.${prev.system}.gostart; + }; + nixosModule = import ./module.nix; + packages = forAllSystems (system: let - pkgs = import nixpkgs { - inherit system; - overlays = [ gomod2nix.overlays.default ]; + pkgs = nixpkgsFor.${system}; + in + { + vite = pkgs.buildGoModule { + name = "vite"; + rev = "master"; + src = ./.; + + vendorHash = "sha256-aHPT3Vl0is+NYaHqkdDjDjEVjvXnwCqK7Bbgm5FhBT0="; }; + }); + defaultPackage = forAllSystems (system: self.packages.${system}.vite); + devShells = forAllSystems (system: + let + pkgs = nixpkgsFor.${system}; in { - packages.default = pkgs.callPackage ./. { }; - devShells.default = import ./shell.nix { inherit pkgs; }; - }) - ); + default = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + go + ]; + }; + }); + }; }
M
go.mod
→
go.mod
@@ -1,11 +1,16 @@
module git.icyphox.sh/vite -go 1.15 +go 1.21 require ( - git.icyphox.sh/grayfriday v0.0.0-20221126034429-23c704183914 // indirect + git.icyphox.sh/grayfriday v0.0.0-20221126034429-23c704183914 github.com/adrg/frontmatter v0.2.0 github.com/alecthomas/chroma v0.10.0 + gopkg.in/yaml.v2 v2.3.0 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b - icyphox.sh/grayfriday v0.0.0-20221130034322-1ea518786419 +) + +require ( + github.com/BurntSushi/toml v0.3.1 // indirect + github.com/dlclark/regexp2 v1.4.0 // indirect )
M
go.sum
→
go.sum
@@ -23,5 +23,3 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -icyphox.sh/grayfriday v0.0.0-20221130034322-1ea518786419 h1:NfLEP+eVHytaObWE5ffsidoe7G1RQnEc2l9YZorYK8k= -icyphox.sh/grayfriday v0.0.0-20221130034322-1ea518786419/go.mod h1:9o5/tCXAQ8RPfaRdo7087zucRyJoQHE+T5YCRxGaBzE=
D
gomod2nix.toml
@@ -1,42 +0,0 @@
-schema = 3 - -[mod] - [mod."git.icyphox.sh/grayfriday"] - version = "v0.0.0-20221126034429-23c704183914" - hash = "sha256-cwTiK30/ZNbp1/R6x/DojxVlgnL0vy3vBiklNJi6wUE=" - [mod."github.com/BurntSushi/toml"] - version = "v0.3.1" - hash = "sha256-Rqak1dE/Aj/+Kx1/pl3Hifgt+Q3OzuZ5fJR+/x3nTbo=" - [mod."github.com/adrg/frontmatter"] - version = "v0.2.0" - hash = "sha256-WJsVcdCpkIkjqUz5fJOFStZYwQlrcFzQ6+mZatZiimo=" - [mod."github.com/alecthomas/chroma"] - version = "v0.10.0" - hash = "sha256-p721vddVTv4iv1O0/dqpdk5xF6x9iLIHcrfh8JEVnqQ=" - [mod."github.com/davecgh/go-spew"] - version = "v1.1.1" - hash = "sha256-nhzSUrE1fCkN0+RL04N4h8jWmRFPPPWbCuDc7Ss0akI=" - [mod."github.com/dlclark/regexp2"] - version = "v1.4.0" - hash = "sha256-Pk/S2x2rX7xnGFLyoHEw09CoNQimvz/msdPRsxLaLsc=" - [mod."github.com/pmezard/go-difflib"] - version = "v1.0.0" - hash = "sha256-/FtmHnaGjdvEIKAJtrUfEhV7EVo5A/eYrtdnUkuxLDA=" - [mod."github.com/stretchr/objx"] - version = "v0.1.0" - hash = "sha256-az0Vd4MG3JXfaYbj0Q6AOmNkrXgmXDeQm8+BBiDXmdA=" - [mod."github.com/stretchr/testify"] - version = "v1.7.0" - hash = "sha256-t1I9uCrn9vSUu/z5IZuNyGShmbOcJ6UGc2f75ZBrHzE=" - [mod."gopkg.in/check.v1"] - version = "v0.0.0-20161208181325-20d25e280405" - hash = "sha256-1w5mgYaZUC52uzDnpXXVqle/9AVkH4WePSrQFOVANUw=" - [mod."gopkg.in/yaml.v2"] - version = "v2.3.0" - hash = "sha256-8tPC5nMGvUFs97W6+JXsxJLjU6EpDmPG9tXo1DyFoNU=" - [mod."gopkg.in/yaml.v3"] - version = "v3.0.0-20210107192922-496545a6307b" - hash = "sha256-j8yDji+vqsitpRZirpb4w/Em8nstgf28wpwkcrOlxBk=" - [mod."icyphox.sh/grayfriday"] - version = "v0.0.0-20221130034322-1ea518786419" - hash = "sha256-+mS2SbGUSAtgo9sOlpldHrH23AiBT+2OosRz44pDqbg="
D
shell.nix
@@ -1,22 +0,0 @@
-{ pkgs ? ( - let - inherit (builtins) fetchTree fromJSON readFile; - inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs gomod2nix; - in - import (fetchTree nixpkgs.locked) { - overlays = [ - (import "${fetchTree gomod2nix.locked}/overlay.nix") - ]; - } - ) -}: - -let - goEnv = pkgs.mkGoEnv { pwd = ./.; }; -in -pkgs.mkShell { - packages = [ - goEnv - pkgs.gomod2nix - ]; -}