Johan Rong 1 lună în urmă
comite
373f3ea597
6 a modificat fișierele cu 55 adăugiri și 0 ștergeri
  1. 19 0
      .direnv/bin/nix-direnv-reload
  2. 1 0
      .envrc
  3. 28 0
      flake.nix
  4. 0 0
      go.mod
  5. 0 0
      go.sum
  6. 7 0
      main.go

+ 19 - 0
.direnv/bin/nix-direnv-reload

@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+set -e
+if [[ ! -d "/home/johron/Projects/go/moose" ]]; then
+  echo "Cannot find source directory; Did you move it?"
+  echo "(Looking for "/home/johron/Projects/go/moose")"
+  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/johron/Projects/go/moose" true
+
+# Update the mtime for .envrc.
+# This will cause direnv to reload again - but without re-building.
+touch "/home/johron/Projects/go/moose/.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/johron/Projects/go/moose/.envrc" "/home/johron/Projects/go/moose/.direnv"/*.rc

+ 1 - 0
.envrc

@@ -0,0 +1 @@
+use flake

+ 28 - 0
flake.nix

@@ -0,0 +1,28 @@
+{
+  description = "Go Development Environment";
+
+  inputs = {
+    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
+  };
+
+  outputs = { self, nixpkgs }:
+    let
+      system = "x86_64-linux";
+      pkgs = import nixpkgs { inherit system; };
+    in
+    {
+      devShells.${system}.default = pkgs.mkShell {
+        buildInputs = with pkgs; [
+          go
+          gotools
+          golangci-lint
+          gopls
+        ];
+
+        shellHook = ''
+          echo "Go Development Environment Loaded!"
+          export GOPATH="$PWD/.nix-go"
+        '';
+      };
+    };
+}

+ 0 - 0
go.mod


+ 0 - 0
go.sum


+ 7 - 0
main.go

@@ -0,0 +1,7 @@
+package main
+
+import "fmt"
+
+func main() {
+    fmt.Println("hello world")
+}