summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyren223 <kyren223@proton.me>2025-07-30 20:05:58 +0300
committerKyren223 <kyren223@proton.me>2025-07-30 20:05:58 +0300
commitfb8fba2265bd5229ec68da553587132af6c9521f (patch)
treee21443a98b1c99500453e13d29ee99a003f819c5
parent4e1d7e48d7e58ae83e0df0b315e2d0d3f8cdbbff (diff)
Added ci checks for flake.nix
-rw-r--r--flake.nix99
1 files changed, 44 insertions, 55 deletions
diff --git a/flake.nix b/flake.nix
index 527f307..b5b7143 100644
--- a/flake.nix
+++ b/flake.nix
@@ -58,11 +58,30 @@
version = version;
vendorHash = vendorHash;
src = src;
- buildInputs = [ ];
+ buildInputs = [ pkgs.go-tools pkgs.gosec ];
ldflags = ldflags;
modRoot = "./.";
subPackages = [ "cmd/client" ];
doCheck = false;
+ preBuild = ''
+ export HOME=$(mktemp -d) # For staticheck
+
+ echo "running ci..."
+
+ test -z "$(go fmt ./...)"
+ echo "formatting passed"
+
+ ${pkgs.go-tools}/bin/staticcheck ./...
+ echo "static analysis passed"
+
+ go test --cover ./...
+ echo "tests passed"
+
+ ${pkgs.gosec}/bin/gosec ./...
+ echo "gosec passed"
+
+ echo "done"
+ '';
postInstall = ''
mv $out/bin/client $out/bin/eko
'';
@@ -72,11 +91,34 @@
version = version;
vendorHash = vendorHash;
src = src;
- buildInputs = [ ];
+ buildInputs = [ pkgs.goose pkgs.go-tools pkgs.gosec ];
ldflags = ldflags;
modRoot = "./.";
subPackages = [ "cmd/server" ];
doCheck = false;
+ preBuild = ''
+ export HOME=$(mktemp -d) # For staticheck
+
+ echo "running ci..."
+
+ test -z "$(go fmt ./...)"
+ echo "formatting passed"
+
+ ${pkgs.go-tools}/bin/staticcheck ./...
+ echo "static analysis passed"
+
+ go test --cover ./...
+ echo "tests passed"
+
+ ${pkgs.gosec}/bin/gosec ./...
+ echo "gosec passed"
+
+ echo "running migrations..."
+ ${pkgs.goose}/bin/goose fix -dir internal/server/api/migrations
+ echo "migrations passed"
+
+ echo "done"
+ '';
postInstall = ''
mv $out/bin/server $out/bin/eko-server
'';
@@ -110,59 +152,6 @@
default = eko;
};
- # TODO: make my own devshell?
- # devShells = rec {
- # default = pkgs.mkShell {
- # packages = with pkgs;
- # [
- # # golang
- # go
- # delve
- # go-outline
- # golangci-lint
- # gopkgs
- # gopls
- # gotools
- # # nix
- # nixpkgs-fmt
- # # other tools
- # just
- # cobra-cli
- # ];
- #
- # shellHook = ''
- # # The path to this repository
- # shell_nix="''${IN_LORRI_SHELL:-$(pwd)/shell.nix}"
- # workspace_root=$(dirname "$shell_nix")
- # export WORKSPACE_ROOT="$workspace_root"
- #
- # # We put the $GOPATH/$GOCACHE/$GOENV in $TOOLCHAIN_ROOT,
- # # and ensure that the GOPATH's bin dir is on our PATH so tools
- # # can be installed with `go install`.
- # #
- # # Any tools installed explicitly with `go install` will take precedence
- # # over versions installed by Nix due to the ordering here.
- # export TOOLCHAIN_ROOT="$workspace_root/.toolchain"
- # export GOROOT=
- # export GOCACHE="$TOOLCHAIN_ROOT/go/cache"
- # export GOENV="$TOOLCHAIN_ROOT/go/env"
- # export GOPATH="$TOOLCHAIN_ROOT/go/path"
- # export GOMODCACHE="$GOPATH/pkg/mod"
- # export PATH=$(go env GOPATH)/bin:$PATH
- # export CGO_ENABLED=1
- #
- # # Make it easy to test while developing; add the golang and nix
- # # build outputs to the path.
- # export PATH="$workspace_root/bin:$workspace_root/result/bin:$PATH"
- # '';
- #
- # # Need to disable fortify hardening because GCC is not built with -oO,
- # # which means that if CGO_ENABLED=1 (which it is by default) then the golang
- # # debugger fails.
- # # see https://github.com/NixOS/nixpkgs/pull/12895/files
- # hardeningDisable = [ "fortify" ];
- # };
- # };
}
)
// {