From: Skullheadx Date: Sat, 16 May 2026 19:17:10 +0000 (-0400) Subject: Nix flake for go dev X-Git-Url: http://git.skullheadx.com/phil/index.html?a=commitdiff_plain;h=689302214cbca42d766af3a8ef9cba8a5cfd7f06;p=monopoly-web.git Nix flake for go dev --- 689302214cbca42d766af3a8ef9cba8a5cfd7f06 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c4a847d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..452d045 --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1778869304, + "narHash": "sha256-30sZNZoA1cqF5JNO9fVX+wgiQYjB7HJqqJ4ztCDeBZE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d233902339c02a9c334e7e593de68855ad26c4cb", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..c74001c --- /dev/null +++ b/flake.nix @@ -0,0 +1,46 @@ +{ + description = "Monopoly web game"; + inputs = { + nixpkgs.url = "nixpkgs/nixos-unstable"; + }; + + outputs = + { self, nixpkgs }: + let + version = "0.1"; + system = "x86_64-linux"; + pkgs = import nixpkgs {inherit system;}; + in + { + packages.${system}.default = pkgs.buildGoModule { + pname = "monopoly-web"; + inherit version; + src = ./.; + + # This hash locks the dependencies of this package. It is + # necessary because of how Go requires network access to resolve + # VCS. See https://www.tweag.io/blog/2021-03-04-gomod2nix/ for + # details. Normally one can build with a fake hash and rely on native Go + # mechanisms to tell you what the hash should be or determine what + # it should be "out-of-band" with other tooling (eg. gomod2nix). + # To begin with it is recommended to set this, but one must + # remember to bump this hash when your dependencies change. + # vendorHash = pkgs.lib.fakeHash; + + vendorHash = null; + }; + + # Add dependencies that are only needed for development + devShells.${system} = { + default = pkgs.mkShell { + buildInputs = with pkgs; [ + go + gopls + gotools + go-tools + ]; + }; + }; + }; + +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..ec172c9 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module skullheadx.com/monopoly-web + +go 1.26.2 diff --git a/main.go b/main.go new file mode 100644 index 0000000..1db730d --- /dev/null +++ b/main.go @@ -0,0 +1,21 @@ +package main + +import ( + + "fmt" + "io" + "log" + "net/http" + +); + +func main() { + fmt.Println("ur mom") + + helloHandler:= func(w http.ResponseWriter, req *http.Request) { + io.WriteString(w, "Hello ur mom!\n") + } + + http.HandleFunc("/hello", helloHandler) + log.Fatal(http.ListenAndServe(":8080",nil)) +}