diff --git a/flake.nix b/flake.nix index 19d3e76..b86d551 100644 --- a/flake.nix +++ b/flake.nix @@ -9,6 +9,10 @@ path = ./rust; description = "My preferred rust setup."; }; + go = { + path = ./go; + description = "My preferred go setup."; + }; }; } // utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; diff --git a/go/.envrc b/go/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/go/.envrc @@ -0,0 +1 @@ +use flake diff --git a/go/flake.nix b/go/flake.nix new file mode 100644 index 0000000..1649d80 --- /dev/null +++ b/go/flake.nix @@ -0,0 +1,34 @@ +{ + description = "Another cool golang abhorration from samw"; + + inputs.flake-utils.url = "github:numtide/flake-utils"; + inputs.devshell = { + url = "github:numtide/devshell"; + inputs.flake-utils.follows = "flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils, devshell }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ devshell.overlay ]; + }; + in rec { + packages.default = pkgs.buildGoModule { + name = "my-project"; + src = self; + vendorSha256 = ""; + + # Inject the git version if you want + #ldflags = '' + # -X main.version=${if self ? rev then self.rev else "dirty"} + #''; + }; + + apps.default = utils.lib.mkApp { drv = packages.default; }; + + devShell = + pkgs.devshell.mkShell { packages = with pkgs; [ go gopls ]; }; + }); +}