{ description = "Federated Forge Discovery Indexer"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small"; flake-utils.url = "github:numtide/flake-utils"; gomod2nix = { url = "github:tweag/gomod2nix"; inputs.nixpkgs.follows = "nixpkgs"; inputs.flake-utils.follows = "flake-utils"; }; }; outputs = { self, nixpkgs, flake-utils, gomod2nix }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; overlays = [ gomod2nix.overlays.default ]; }; go = pkgs.go_1_27; ffd-indexer = pkgs.buildGoApplication { inherit go; pname = "ffd-indexer"; version = "0.0.1"; src = ./.; modules = ./gomod2nix.toml; }; go-test = pkgs.stdenv.mkDerivation { name = "go-test"; dontBuild = true; src = ./.; doCheck = true; nativeBuildInputs = [ go pkgs.writableTmpDirAsHomeHook ]; checkPhase = '' go test -v ./... ''; installPhase = '' mkdir "$out" ''; }; go-lint = pkgs.stdenv.mkDerivation { name = "go-lint"; dontBuild = true; src = ./.; doCheck = true; nativeBuildInputs = [ pkgs.golangci-lint go pkgs.writableTmpDirAsHomeHook ]; checkPhase = '' golangci-lint run ''; installPhase = '' mkdir "$out" ''; }; in { checks = { inherit go-test go-lint; }; formatter = pkgs.nixfmt-tree; devShells.default = pkgs.mkShell { buildInputs = [ go pkgs.go-tools # staticcheck gomod2nix.packages.${system}.default ]; packages = with pkgs; [ mkcert sqlite # debugging the index db ]; }; packages = { default = ffd-indexer; container = pkgs.dockerTools.buildImage { name = "ffd-indexer"; config = { Cmd = [ "${ffd-indexer}/bin/ffd-indexer" ]; }; }; }; nixosModules.default = import ./option.nix; } ); }