From 6b507c849ac93c7f16cd1000e95b6e876b61ab8a Mon Sep 17 00:00:00 2001 From: cato-001 Date: Fri, 2 Jan 2026 11:14:20 +0100 Subject: [PATCH] feat: add default and golang nix templates --- templates/default/.envrc | 5 ++ templates/default/.gitignore | 6 ++ templates/default/devshell.nix | 7 ++ templates/default/flake.nix | 14 ++++ templates/golang/.envrc | 5 ++ templates/golang/.gitignore | 6 ++ templates/golang/devshell.nix | 10 +++ templates/golang/flake.lock | 119 ++++++++++++++++++++++++++++ templates/golang/flake.nix | 22 +++++ templates/golang/package.nix | 8 ++ templates/golang/src/gomod2nix.toml | 0 templates/golang/src/main.go | 7 ++ 12 files changed, 209 insertions(+) create mode 100644 templates/default/.envrc create mode 100644 templates/default/.gitignore create mode 100644 templates/default/devshell.nix create mode 100644 templates/default/flake.nix create mode 100644 templates/golang/.envrc create mode 100644 templates/golang/.gitignore create mode 100644 templates/golang/devshell.nix create mode 100644 templates/golang/flake.lock create mode 100644 templates/golang/flake.nix create mode 100644 templates/golang/package.nix create mode 100644 templates/golang/src/gomod2nix.toml create mode 100644 templates/golang/src/main.go diff --git a/templates/default/.envrc b/templates/default/.envrc new file mode 100644 index 0000000..f244228 --- /dev/null +++ b/templates/default/.envrc @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +watch_file flake.nix flake.lock devshell.nix +use flake +source_env_if_exists .envrc.local diff --git a/templates/default/.gitignore b/templates/default/.gitignore new file mode 100644 index 0000000..12731de --- /dev/null +++ b/templates/default/.gitignore @@ -0,0 +1,6 @@ +# direnv +.direnv/ + +# nix +result +result-* diff --git a/templates/default/devshell.nix b/templates/default/devshell.nix new file mode 100644 index 0000000..25f1a84 --- /dev/null +++ b/templates/default/devshell.nix @@ -0,0 +1,7 @@ +{ pkgs }: + +pkgs.mkShell { + packages = [ ]; + + env = { }; +} diff --git a/templates/default/flake.nix b/templates/default/flake.nix new file mode 100644 index 0000000..6532e25 --- /dev/null +++ b/templates/default/flake.nix @@ -0,0 +1,14 @@ +{ + description = "TODO: please replace"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-25.11"; + + blueprint = { + url = "github:numtide/blueprint"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = inputs: inputs.blueprint { inherit inputs; }; +} diff --git a/templates/golang/.envrc b/templates/golang/.envrc new file mode 100644 index 0000000..f244228 --- /dev/null +++ b/templates/golang/.envrc @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +watch_file flake.nix flake.lock devshell.nix +use flake +source_env_if_exists .envrc.local diff --git a/templates/golang/.gitignore b/templates/golang/.gitignore new file mode 100644 index 0000000..12731de --- /dev/null +++ b/templates/golang/.gitignore @@ -0,0 +1,6 @@ +# direnv +.direnv/ + +# nix +result +result-* diff --git a/templates/golang/devshell.nix b/templates/golang/devshell.nix new file mode 100644 index 0000000..f65f2d3 --- /dev/null +++ b/templates/golang/devshell.nix @@ -0,0 +1,10 @@ +{ pkgs, perSystem, ... }: + +pkgs.mkShell { + packages = [ + pkgs.go + perSystem.gomod2nix.default + ]; + + env = { }; +} diff --git a/templates/golang/flake.lock b/templates/golang/flake.lock new file mode 100644 index 0000000..80d5054 --- /dev/null +++ b/templates/golang/flake.lock @@ -0,0 +1,119 @@ +{ + "nodes": { + "blueprint": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "systems": "systems" + }, + "locked": { + "lastModified": 1763308703, + "narHash": "sha256-O9Y+Wer8wOh+N+4kcCK5p/VLrXyX+ktk0/s3HdZvJzk=", + "owner": "numtide", + "repo": "blueprint", + "rev": "5a9bba070f801d63e2af3c9ef00b86b212429f4f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "blueprint", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gomod2nix": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1767019875, + "narHash": "sha256-NodN+lhWTD59b44Q2bPjE1edINfjfRkQYdZsrxifCeU=", + "owner": "nix-community", + "repo": "gomod2nix", + "rev": "49662a44272806ff785df2990a420edaaca15db4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "gomod2nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1767047869, + "narHash": "sha256-tzYsEzXEVa7op1LTnrLSiPGrcCY6948iD0EcNLWcmzo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "89dbf01df72eb5ebe3b24a86334b12c27d68016a", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-25.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "blueprint": "blueprint", + "gomod2nix": "gomod2nix", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "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" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/templates/golang/flake.nix b/templates/golang/flake.nix new file mode 100644 index 0000000..ba4e347 --- /dev/null +++ b/templates/golang/flake.nix @@ -0,0 +1,22 @@ +{ + description = "TODO: please replace"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-25.11"; + + blueprint = { + url = "github:numtide/blueprint"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + gomod2nix = { + url = "github:nix-community/gomod2nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = inputs: inputs.blueprint { + inherit inputs; + nixpkgs.overlays = [ inputs.gomod2nix.overlays.default ]; + }; +} diff --git a/templates/golang/package.nix b/templates/golang/package.nix new file mode 100644 index 0000000..a34e1ab --- /dev/null +++ b/templates/golang/package.nix @@ -0,0 +1,8 @@ +{ pkgs, ... }: + +pkgs.buildGoApplication { + pname = ""; + version = "0.0.1"; + src = ./src; + modules = ./src/gomod2nix.toml; +} diff --git a/templates/golang/src/gomod2nix.toml b/templates/golang/src/gomod2nix.toml new file mode 100644 index 0000000..e69de29 diff --git a/templates/golang/src/main.go b/templates/golang/src/main.go new file mode 100644 index 0000000..44ee7ea --- /dev/null +++ b/templates/golang/src/main.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("Hello!") +}