Something went wrong. Try again.
clone
Something went wrong. Try again.
simple-inserts-language-server flake.nix
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250{ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; systems.url = "github:nix-systems/default"; devenv.url = "github:cachix/devenv"; };
nixConfig = { extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="; extra-substituters = "https://devenv.cachix.org"; };
outputs = { devenv, nixpkgs, self, systems, ... } @ inputs: let forEachSystem = nixpkgs.lib.genAttrs (import systems); in { checks = forEachSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; src = ./.; doCheck = true; dontBuild = true; setup = '' export HOME=$(pwd) mkdir "$out" cd "$src" ''; in { test = pkgs.stdenvNoCC.mkDerivation { inherit src doCheck dontBuild; name = "test"; nativeBuildInputs = with pkgs; [go_1_25 gotestsum coreutils]; checkPhase = '' ${setup} ${pkgs.gotestsum}/bin/gotestsum ./... | ${pkgs.coreutils}/bin/tee $out/output ''; };
lint = pkgs.stdenvNoCC.mkDerivation { inherit src doCheck dontBuild; name = "lint"; nativeBuildInputs = with pkgs; [go_1_25 golangci-lint coreutils]; checkPhase = '' ${setup} ${pkgs.golangci-lint}/bin/golangci-lint run ./... | ${pkgs.coreutils}/bin/tee $out/output ''; }; });
packages = forEachSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; in { devenv-up = self.devShells.${system}.default.config.procfileScript; devenv-test = self.devShells.${system}.default.config.test; default = pkgs.callPackage ./. {}; });
devShells = forEachSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; golang = pkgs.go_1_25; in { default = devenv.lib.mkShell { inherit inputs pkgs; modules = with pkgs; [ { languages = { go = { enable = true; package = golang; };
nix.enable = true; };
# https://devenv.sh/reference/options/ packages = [ alejandra gotestsum golangci-lint golangci-lint-langserver hut reflex ];
scripts = { run-rename-project = { description = "After copying template, rename the project"; exec = '' if [[ -z "$1" ]]; then echo "Usage: run-rename-project NEW_NAME" exit fi
${gnused}/bin/sed -i -e "s@golang-template@$1@g" \ .builds/build.yml \ .gitignore \ README.md \ go.mod ''; };
run-mod = { description = "Install and verify dependencies"; exec = '' ${golang}/bin/go mod tidy -compat=$(go mod edit -json | jq -r .Go) ${golang}/bin/go mod verify ${golang}/bin/go mod vendor ''; };
run-update-dependencies = { description = "Update dependencies"; exec = '' ${golang}/bin/go get -u -v ./... run-mod ''; };
run-fmt = { description = "Ensure all source files are formatted correctly"; exec = '' ${golang}/bin/go fmt ./... ''; };
run-vet = { description = "Catch common gotchas"; exec = '' run-fmt ${golang}/bin/go vet ./... ''; };
run-lint = { description = "Lint source code"; exec = '' ${golangci-lint}/bin/golangci-lint run $@ ./... ''; };
run-lint-watch = { description = "Lint source code on filesystem changes"; exec = '' ${reflex}/bin/reflex --decoration=none -r '\.go' -R '^vendor/' -G 'tags*' -- run-lint ''; };
run-test = { description = "Tun tests"; exec = '' mkdir -p tmp/ gotestsum \ --post-run-command=run-coverage \ $1 \ -- \ -coverprofile=tmp/cover.out \ ./... ''; };
run-publish-artifacts = { description = "build and push artifacts. only meant to run on CI"; exec = # bash '' for GOOS in darwin linux; do for GOARCH in amd64 arm64; do ARTIFACT="/tmp/''${NAME}-''${GOOS}-''${GOARCH}-''${TAG}"
CGO_ENABLED=0 \ GOOS=$GOOS \ GOARCH=$GOARCH \ go build -o "''${ARTIFACT}"
hut git artifact upload "''${ARTIFACT}" --rev "''${TAG}" done done ''; };
run-release = { description = "Release"; exec = '' set -x git fetch --tags new_version="$(${pkgs.svu}/bin/svu next --tag-prefix "" --always | echo "0.0.1")"
echo "''${new_version}" >version.txt git add version.txt git commit --sign -m "chore: update to version ''${new_version}"
git tag --sign -a v''${new_version} git push -o skip-ci git push --tags ''; };
run-test-watch = { description = "Run tests on filesystem changes"; exec = '' run-test --watch ''; };
run-coverage = { description = "Write test coverage data"; exec = '' ${golang}/bin/go tool cover -html=tmp/cover.out -o tmp/coverage.html ${golang}/bin/go tool cover -func tmp/cover.out ''; };
show-help = { description = "Show this message"; exec = '' echo echo Available helper scripts: echo ${pkgs.gnused}/bin/sed -e 's| |••|g' -e 's|=| |' <<EOF | \ ${pkgs.util-linuxMinimal}/bin/column -t | \ ${pkgs.gnused}/bin/sed -e 's|••| |g' ${pkgs.lib.generators.toKeyValue {} (pkgs.lib.mapAttrs (name: value: value.description) self.devShells.${system}.default.config.scripts)} EOF echo echo To start services, run "devenv up" echo ''; }; };
git-hooks.hooks.commitizen.enable = true;
enterShell = '' show-help ''; } ]; }; }); };}