From 4cea94dab279e7a3f6c8828844846ca75e0aff72 Mon Sep 17 00:00:00 2001 From: Filip Hoffmann Date: Sun, 21 Dec 2025 21:48:31 +0100 Subject: [PATCH] add go example --- .../.direnv/bin/nix-direnv-reload | 19 +++++++++++++ examples/your_first_go_bot/.envrc | 1 + examples/your_first_go_bot/flake.lock | 26 +++++++++++++++++ examples/your_first_go_bot/flake.nix | 28 +++++++++++++++++++ 4 files changed, 74 insertions(+) create mode 100755 examples/your_first_go_bot/.direnv/bin/nix-direnv-reload create mode 100644 examples/your_first_go_bot/.envrc create mode 100644 examples/your_first_go_bot/flake.lock create mode 100644 examples/your_first_go_bot/flake.nix diff --git a/examples/your_first_go_bot/.direnv/bin/nix-direnv-reload b/examples/your_first_go_bot/.direnv/bin/nix-direnv-reload new file mode 100755 index 0000000..c4909f3 --- /dev/null +++ b/examples/your_first_go_bot/.direnv/bin/nix-direnv-reload @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -e +if [[ ! -d "/home/folo/grom/examples/your_first_go_bot" ]]; then + echo "Cannot find source directory; Did you move it?" + echo "(Looking for "/home/folo/grom/examples/your_first_go_bot")" + echo 'Cannot force reload with this script - use "direnv reload" manually and then try again' + exit 1 +fi + +# rebuild the cache forcefully +_nix_direnv_force_reload=1 direnv exec "/home/folo/grom/examples/your_first_go_bot" true + +# Update the mtime for .envrc. +# This will cause direnv to reload again - but without re-building. +touch "/home/folo/grom/examples/your_first_go_bot/.envrc" + +# Also update the timestamp of whatever profile_rc we have. +# This makes sure that we know we are up to date. +touch -r "/home/folo/grom/examples/your_first_go_bot/.envrc" "/home/folo/grom/examples/your_first_go_bot/.direnv"/*.rc diff --git a/examples/your_first_go_bot/.envrc b/examples/your_first_go_bot/.envrc new file mode 100644 index 0000000..8392d15 --- /dev/null +++ b/examples/your_first_go_bot/.envrc @@ -0,0 +1 @@ +use flake \ No newline at end of file diff --git a/examples/your_first_go_bot/flake.lock b/examples/your_first_go_bot/flake.lock new file mode 100644 index 0000000..eab7cbe --- /dev/null +++ b/examples/your_first_go_bot/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1766070988, + "narHash": "sha256-G/WVghka6c4bAzMhTwT2vjLccg/awmHkdKSd2JrycLc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c6245e83d836d0433170a16eb185cefe0572f8b8", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/examples/your_first_go_bot/flake.nix b/examples/your_first_go_bot/flake.nix new file mode 100644 index 0000000..96da941 --- /dev/null +++ b/examples/your_first_go_bot/flake.nix @@ -0,0 +1,28 @@ +{ + description = "Just a go flake for a devshell"; + + inputs.nixpkgs.url = "nixpkgs/nixos-unstable"; + + outputs = {nixpkgs, ...}: let + forAllSystems = function: + nixpkgs.lib.genAttrs [ + "aarch64-darwin" + "aarch64-linux" + "x86_64-darwin" + "x86_64-linux" + ] (system: + function (import nixpkgs { + inherit system; + })); + in { + devShells = forAllSystems (pkgs: { + default = pkgs.mkShell { + buildInputs = with pkgs; [ + go + gopls + go-tools + ]; + }; + }); + }; +} -- 2.51.2