-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from akirak/go
Add Go
- Loading branch information
Showing
5 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Check go | ||
on: | ||
push: | ||
paths: | ||
# Set this to the directory of the template | ||
- go/** | ||
- .github/workflows/check-go.yml | ||
workflow_dispatch: | ||
workflow_call: | ||
concurrency: | ||
group: check-go-${{ github.ref }} | ||
cancel-in-progress: true | ||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: cachix/install-nix-action@v30 | ||
with: | ||
extra_nix_config: | | ||
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | ||
flake-registry = https://raw.githubusercontent.com/akirak/flake-pins/master/registry.json | ||
- uses: cachix/cachix-action@v15 | ||
with: | ||
name: akirak | ||
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' | ||
pushFilter: '-source$' | ||
- uses: actions/checkout@v4 | ||
with: | ||
path: ./tmp | ||
- name: Use the template | ||
run: | | ||
nix flake new -t ./tmp#go work | ||
- run: go version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
inputs = { | ||
# nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
systems.url = "github:nix-systems/default"; | ||
treefmt-nix = { | ||
url = "github:numtide/treefmt-nix"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
}; | ||
|
||
# Configure a binary cache for your executable(s). | ||
nixConfig = { | ||
extra-substituters = | ||
[ | ||
]; | ||
extra-trusted-public-keys = | ||
[ | ||
]; | ||
}; | ||
|
||
outputs = | ||
{ | ||
self, | ||
systems, | ||
nixpkgs, | ||
treefmt-nix, | ||
... | ||
}: | ||
let | ||
inherit (nixpkgs) lib; | ||
eachSystem = f: lib.genAttrs (import systems) (system: f nixpkgs.legacyPackages.${system}); | ||
|
||
treefmtEval = eachSystem (pkgs: treefmt-nix.lib.evalModule pkgs ./treefmt.nix); | ||
in | ||
{ | ||
# Build executables. See https://nixos.org/manual/nixpkgs/stable/#sec-language-go | ||
packages = eachSystem (pkgs: { | ||
# default = pkgs.buildGoModule { | ||
# pname = "squasher"; | ||
# version = builtins.substring 0 8 (self.lastModifiedDate or "19700101"); | ||
# src = self.outPath; | ||
# vendorHash = lib.fakeHash; | ||
# meta = { }; | ||
# }; | ||
}); | ||
|
||
devShells = eachSystem (pkgs: { | ||
default = pkgs.mkShell { | ||
packages = [ | ||
pkgs.go | ||
pkgs.gopls | ||
]; | ||
}; | ||
}); | ||
|
||
formatter = eachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper); | ||
|
||
checks = eachSystem (pkgs: { | ||
formatting = treefmtEval.${pkgs.system}.config.build.check self; | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
projectRootFile = "treefmt.nix"; | ||
|
||
# See https://github.com/numtide/treefmt-nix#supported-programs | ||
|
||
programs.gofmt.enable = true; | ||
|
||
# JSON | ||
programs.biome.enable = true; | ||
|
||
# GitHub Actions | ||
programs.yamlfmt.enable = true; | ||
programs.actionlint.enable = true; | ||
|
||
# Markdown | ||
programs.mdformat.enable = true; | ||
|
||
# Nix | ||
programs.nixfmt.enable = true; | ||
} |