aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhongheng Liu <z.liu@outlook.com.gr>2024-10-20 22:21:31 +0300
committerZhongheng Liu <z.liu@outlook.com.gr>2024-10-20 22:21:31 +0300
commit5dd1cc25e9212ac348fb8d4f2fa1c68688ba1058 (patch)
treecf86c0655b730181b3b8cf3af1a593f28a542dc4
downloadrulmarc-5dd1cc25e9212ac348fb8d4f2fa1c68688ba1058.tar.gz
rulmarc-5dd1cc25e9212ac348fb8d4f2fa1c68688ba1058.tar.bz2
rulmarc-5dd1cc25e9212ac348fb8d4f2fa1c68688ba1058.zip
feat: init project with some starter Go code
-rw-r--r--.devcontainer.json12
-rw-r--r--.envrc3
-rw-r--r--.github/workflows/test.yml26
-rw-r--r--.gitignore33
-rw-r--r--README.md1
-rw-r--r--devenv.lock183
-rw-r--r--devenv.nix84
-rw-r--r--devenv.yaml10
-rw-r--r--go.mod10
-rw-r--r--go.sum6
-rw-r--r--hello.go14
11 files changed, 382 insertions, 0 deletions
diff --git a/.devcontainer.json b/.devcontainer.json
new file mode 100644
index 0000000..2f69206
--- /dev/null
+++ b/.devcontainer.json
@@ -0,0 +1,12 @@
+{
+ "customizations": {
+ "vscode": {
+ "extensions": [
+ "mkhl.direnv"
+ ]
+ }
+ },
+ "image": "ghcr.io/cachix/devenv:latest",
+ "overrideCommand": false,
+ "updateContentCommand": "devenv test"
+}
diff --git a/.envrc b/.envrc
new file mode 100644
index 0000000..247a291
--- /dev/null
+++ b/.envrc
@@ -0,0 +1,3 @@
+source_url "https://raw.githubusercontent.com/cachix/devenv/95f329d49a8a5289d31e0982652f7058a189bfca/direnvrc" "sha256-d+8cBpDfDBj41inrADaJt+bDWhOktwslgoP5YiGJ1v0="
+
+use devenv
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..0bac655
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,26 @@
+name: "Test"
+
+on:
+ pull_request:
+ push:
+ branches:
+ - main
+
+jobs:
+ tests:
+ strategy:
+ matrix:
+ os: [ubuntu-latest, macos-latest]
+ runs-on: ${{ matrix.os }}
+
+ steps:
+ - uses: actions/checkout@v4
+ - uses: cachix/install-nix-action@v26
+ - uses: cachix/cachix-action@v14
+ with:
+ name: devenv
+ - name: Install devenv.sh
+ run: nix profile install nixpkgs#devenv
+
+ - name: Build the devenv shell and run any pre-commit hooks
+ run: devenv test
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..215663c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,33 @@
+### Go ###
+# If you prefer the allow list template instead of the deny list, see community template:
+# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
+#
+# Binaries for programs and plugins
+*.exe
+*.exe~
+*.dll
+*.so
+*.dylib
+
+# Test binary, built with `go test -c`
+*.test
+
+# Output of the go coverage tool, specifically when used with LiteIDE
+*.out
+
+# Dependency directories (remove the comment below to include it)
+# vendor/
+
+# Go workspace file
+go.work
+### devenv ###
+devenv.local.nix
+.devenv.flake.nix
+.devenv
+
+# pre-commit
+.pre-commit-config.yaml
+
+### direnv ###
+.direnv
+
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..382dd5e
--- /dev/null
+++ b/README.md
@@ -0,0 +1 @@
+# ai_game
diff --git a/devenv.lock b/devenv.lock
new file mode 100644
index 0000000..a8ac094
--- /dev/null
+++ b/devenv.lock
@@ -0,0 +1,183 @@
+{
+ "nodes": {
+ "devenv": {
+ "locked": {
+ "dir": "src/modules",
+ "lastModified": 1729445229,
+ "owner": "cachix",
+ "repo": "devenv",
+ "rev": "006016cf4191c34c17cfdb6669e0690e24302ac0",
+ "type": "github"
+ },
+ "original": {
+ "dir": "src/modules",
+ "owner": "cachix",
+ "repo": "devenv",
+ "type": "github"
+ }
+ },
+ "flake-compat": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1696426674,
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
+ "type": "github"
+ },
+ "original": {
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "type": "github"
+ }
+ },
+ "flake-utils": {
+ "inputs": {
+ "systems": "systems"
+ },
+ "locked": {
+ "lastModified": 1726560853,
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "gitignore": {
+ "inputs": {
+ "nixpkgs": [
+ "pre-commit-hooks",
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1709087332,
+ "owner": "hercules-ci",
+ "repo": "gitignore.nix",
+ "rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
+ "type": "github"
+ },
+ "original": {
+ "owner": "hercules-ci",
+ "repo": "gitignore.nix",
+ "type": "github"
+ }
+ },
+ "mk-shell-bin": {
+ "locked": {
+ "lastModified": 1677004959,
+ "owner": "rrbutani",
+ "repo": "nix-mk-shell-bin",
+ "rev": "ff5d8bd4d68a347be5042e2f16caee391cd75887",
+ "type": "github"
+ },
+ "original": {
+ "owner": "rrbutani",
+ "repo": "nix-mk-shell-bin",
+ "type": "github"
+ }
+ },
+ "nix2container": {
+ "inputs": {
+ "flake-utils": "flake-utils",
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1729339656,
+ "owner": "nlewo",
+ "repo": "nix2container",
+ "rev": "cc96df7c3747c61c584d757cfc083922b4f4b33e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nlewo",
+ "repo": "nix2container",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1729265718,
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "ccc0c2126893dd20963580b6478d1a10a4512185",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixpkgs-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "nixpkgs-stable": {
+ "locked": {
+ "lastModified": 1729181673,
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "4eb33fe664af7b41a4c446f87d20c9a0a6321fa3",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixos-24.05",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "pre-commit-hooks": {
+ "inputs": {
+ "flake-compat": "flake-compat",
+ "gitignore": "gitignore",
+ "nixpkgs": [
+ "nixpkgs"
+ ],
+ "nixpkgs-stable": "nixpkgs-stable"
+ },
+ "locked": {
+ "lastModified": 1729104314,
+ "owner": "cachix",
+ "repo": "pre-commit-hooks.nix",
+ "rev": "3c3e88f0f544d6bb54329832616af7eb971b6be6",
+ "type": "github"
+ },
+ "original": {
+ "owner": "cachix",
+ "repo": "pre-commit-hooks.nix",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "devenv": "devenv",
+ "mk-shell-bin": "mk-shell-bin",
+ "nix2container": "nix2container",
+ "nixpkgs": "nixpkgs",
+ "pre-commit-hooks": "pre-commit-hooks"
+ }
+ },
+ "systems": {
+ "locked": {
+ "lastModified": 1681028828,
+ "owner": "nix-systems",
+ "repo": "default",
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-systems",
+ "repo": "default",
+ "type": "github"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/devenv.nix b/devenv.nix
new file mode 100644
index 0000000..645bf9d
--- /dev/null
+++ b/devenv.nix
@@ -0,0 +1,84 @@
+{
+ pkgs,
+ lib,
+ config,
+ inputs,
+ ...
+}:
+
+{
+ name = "ai-game";
+ # https://devenv.sh/basics/
+ env = {
+ GREET = "🛠️ Let's hack ";
+ };
+
+ # https://devenv.sh/scripts/
+ scripts = {
+ hello.exec = "echo $GREET";
+ cat.exec = "bat $@";
+
+ show = {
+ # Prints scripts that have a description
+ # Adapted from https://github.com/cachix/devenv/blob/ef61728d91ad5eb91f86cdbcc16070602e7afa16/examples/scripts/devenv.nix#L34
+ exec = ''
+ GREEN="\033[0;32m";
+ YELLOW="\033[33m";
+ NC="\033[0m";
+ echo
+ echo -e "✨ Helper scripts you can run to make your development richer:"
+ echo
+ ${pkgs.gnused}/bin/sed -e 's| |••|g' -e 's|=| |' <<EOF | ${pkgs.util-linuxMinimal}/bin/column -t | ${pkgs.gnused}/bin/sed -e "s|^\([^ ]*\)|$(printf "$GREEN")\1$(printf "$NC"): |" -e "s|^|$(printf "$YELLOW*$NC") |" -e 's|••| |g'
+ ${lib.generators.toKeyValue { } (
+ lib.mapAttrs (name: value: value.description) (
+ lib.filterAttrs (_: value: value.description != "") config.scripts
+ )
+ )}
+ EOF
+ echo
+ '';
+ description = "Print this message and exit.";
+ };
+
+ };
+
+ # https://devenv.sh/packages/
+ packages = with pkgs; [
+ nixfmt-rfc-style
+ bat
+ jq
+ tealdeer
+ gopls
+ air
+ ];
+
+ languages = {
+ go.enable = true;
+
+ };
+
+ enterShell = ''
+ hello
+ show'';
+
+ # https://devenv.sh/pre-commit-hooks/
+ pre-commit.hooks = {
+ nixfmt-rfc-style = {
+ enable = true;
+ excludes = [ ".devenv.flake.nix" ];
+ };
+ yamllint = {
+ enable = true;
+ settings.preset = "relaxed";
+ };
+ };
+
+ # Make diffs fantastic
+ difftastic.enable = true;
+
+ # https://devenv.sh/integrations/dotenv/
+ dotenv.enable = true;
+
+ # https://devenv.sh/integrations/codespaces-devcontainer/
+ devcontainer.enable = true;
+}
diff --git a/devenv.yaml b/devenv.yaml
new file mode 100644
index 0000000..b5babeb
--- /dev/null
+++ b/devenv.yaml
@@ -0,0 +1,10 @@
+inputs:
+ nix2container:
+ url: github:nlewo/nix2container
+ inputs:
+ nixpkgs:
+ follows: nixpkgs
+ mk-shell-bin:
+ url: github:rrbutani/nix-mk-shell-bin
+ nixpkgs:
+ url: github:NixOS/nixpkgs/nixpkgs-unstable
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..1304b27
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,10 @@
+module test/hello
+
+go 1.23.2
+
+require rsc.io/quote v1.5.2
+
+require (
+ golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c // indirect
+ rsc.io/sampler v1.3.0 // indirect
+)
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..4a8bcd7
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,6 @@
+golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:qgOY6WgZOaTkIIMiVjBQcw93ERBE4m30iBm00nkL0i8=
+golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+rsc.io/quote v1.5.2 h1:w5fcysjrx7yqtD/aO+QwRjYZOKnaM9Uh2b40tElTs3Y=
+rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0=
+rsc.io/sampler v1.3.0 h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4=
+rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
diff --git a/hello.go b/hello.go
new file mode 100644
index 0000000..82c645c
--- /dev/null
+++ b/hello.go
@@ -0,0 +1,14 @@
+package main
+
+import "fmt"
+import "rsc.io/quote"
+
+func greet(name string) string {
+ msg := fmt.Sprintf("Good day to you, %v!", name)
+ return msg
+}
+
+func main() {
+ greet("Steven")
+ fmt.Println(quote.Glass())
+}