all repos — x @ 0c6fc79fef8f3fd2d2e7360528cf918fb7dd55b5

Experiments and stuff

use flake for dev shell

Alan Pearce
commit

0c6fc79fef8f3fd2d2e7360528cf918fb7dd55b5

parent

434bbe77faa4b87eace015c800bf3cfdfe39042a

1 file changed, 64 insertions(+), 0 deletions(-)

changed files
A flake.nix
@@ -0,0 +1,64 @@
+{ + description = "A basic gomod2nix flake"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + pre-commit-hooks.url = "github:cachix/git-hooks.nix"; + pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = + { + self, + nixpkgs, + pre-commit-hooks, + }: + let + supportedSystems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + in + { + checks = forAllSystems ( + system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + pre-commit-check = pre-commit-hooks.lib.${system}.run { + src = ./.; + hooks = { + go-mod-tidy = { + enable = true; + name = "go-mod-tidy"; + description = "Run `go mod tidy`"; + types_or = [ + "go" + "go-mod" + ]; + entry = "${pkgs.go}/bin/go mod tidy"; + pass_filenames = false; + }; + }; + }; + } + ); + devShells = forAllSystems (system: { + default = nixpkgs.legacyPackages.${system}.mkShell { + inherit (self.checks.${system}.pre-commit-check) shellHook; + packages = with nixpkgs.legacyPackages.${system}; [ + go + go-licenses + gotools + just + ]; + }; + }); + }; +}