diff --git a/.gitignore b/.gitignore index 29963da..11129db 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ /.direnv/ +/.go/ +*~ +*_templ.go \ No newline at end of file diff --git a/flake.lock b/flake.lock index ca0a864..d8ba0cb 100644 --- a/flake.lock +++ b/flake.lock @@ -18,6 +18,82 @@ "type": "github" } }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "templ", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1694102001, + "narHash": "sha256-vky6VPK1n1od6vXbqzOXnekrQpTL4hbPAwUhT5J9c9E=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "9e21c80adf67ebcb077d75bd5e7d724d21eeafd6", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "gomod2nix": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "templ", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1705314449, + "narHash": "sha256-yfQQ67dLejP0FLK76LKHbkzcQqNIrux6MFe32MMFGNQ=", + "owner": "nix-community", + "repo": "gomod2nix", + "rev": "30e3c3a9ec4ac8453282ca7f67fca9e1da12c3e6", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "gomod2nix", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1710097495, @@ -33,10 +109,27 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1701282334, + "narHash": "sha256-MxCVrXY6v4QmfTwIysjjaX0XUhqBbxTWWB4HXtDYsdk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "057f9aecfb71c4437d2b27d3323df7f93c010b7e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "23.11", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "templ": "templ" } }, "systems": { @@ -53,6 +146,64 @@ "repo": "default", "type": "github" } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "templ": { + "inputs": { + "gitignore": "gitignore", + "gomod2nix": "gomod2nix", + "nixpkgs": "nixpkgs_2", + "xc": "xc" + }, + "locked": { + "lastModified": 1709917943, + "narHash": "sha256-zDQxUFSmG/VX+xtK+nZ3ObRMVcMjjx+EUAxHLNcHHF8=", + "owner": "a-h", + "repo": "templ", + "rev": "df2a32403bb4a8e4745ac10ddc8b3e77386d8045", + "type": "github" + }, + "original": { + "owner": "a-h", + "repo": "templ", + "type": "github" + } + }, + "xc": { + "inputs": { + "flake-utils": "flake-utils_3", + "nixpkgs": [ + "templ", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1703164129, + "narHash": "sha256-kCcCqqwvjN07H8FPG4tXsRVRcMqT8dUNt9pwW1kKAe8=", + "owner": "joerdav", + "repo": "xc", + "rev": "0655cccfcf036556aeaddfb8f45dc7e8dd1b3680", + "type": "github" + }, + "original": { + "owner": "joerdav", + "repo": "xc", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 11744c9..05cdf9e 100644 --- a/flake.nix +++ b/flake.nix @@ -1,22 +1,22 @@ -{ +rec { description = "templ-practice"; - inputs.nixpkgs.url = "github:nixos/nixpkgs"; - inputs.flake-utils.url = "github:numtide/flake-utils"; - - outputs = { self, nixpkgs, flake-utils }: + inputs = { + nixpkgs.url = "github:nixos/nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + templ.url = "github:a-h/templ"; + }; + + outputs = { self, nixpkgs, flake-utils, templ }: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; + templPkg = templ.packages.${system}.templ; in { devShells.default = pkgs.mkShell { - buildInputs = [ - pkgs.go - pkgs.wgo - pkgs.semgrep - pkgs.gopls - pkgs.gnumake - ]; + buildInputs = + [ pkgs.go pkgs.wgo pkgs.semgrep pkgs.gopls pkgs.gnumake templPkg ]; shellHook = '' - export SOME_SHELL_VAR=ITS_VALUE + export GOPATH=$PWD/.go + export PATH=$GOPATH/bin:$PATH ''; }; }); diff --git a/go.mod b/go.mod index eef8b4b..798174e 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module sunshine.industries/temp-exercise go 1.21.7 + +require github.com/a-h/templ v0.2.598 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..55b8a53 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/a-h/templ v0.2.598 h1:6jMIHv6wQZvdPxTuv87erW4RqN/FPU0wk7ZHN5wVuuo= +github.com/a-h/templ v0.2.598/go.mod h1:SA7mtYwVEajbIXFRh3vKdYm/4FYyLQAtPH1+KxzGPA8= diff --git a/hello.templ b/hello.templ new file mode 100644 index 0000000..5df3590 --- /dev/null +++ b/hello.templ @@ -0,0 +1,5 @@ +package main + +templ hello(name string) { +
Hello, {name}
+} \ No newline at end of file diff --git a/main.go b/main.go new file mode 100644 index 0000000..68d9e1e --- /dev/null +++ b/main.go @@ -0,0 +1,16 @@ +package main + +import ( + "fmt" + "github.com/a-h/templ" + "net/http" +) + +func main() { + component := hello("some name") + + http.Handle("/", templ.Handler(component)) + + fmt.Println("starting to serve on :3000") + http.ListenAndServe(":3000", nil) +}