60 lines
1.5 KiB
Nix
60 lines
1.5 KiB
Nix
{
|
|
description = "QRank Go (Gin + GORM) dev env with CGO (NixOS 25.05)";
|
|
|
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
|
|
|
|
outputs = { self, nixpkgs }:
|
|
let
|
|
systems = [ "x86_64-linux" "aarch64-linux" ];
|
|
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f (import nixpkgs { inherit system; }));
|
|
in
|
|
{
|
|
devShells = forAllSystems (pkgs:
|
|
let
|
|
# Pick the Go you want. pkgs.go is fine; change to pkgs.go_1_23 if you prefer a fixed version.
|
|
go = pkgs.go;
|
|
in {
|
|
default = pkgs.mkShell {
|
|
# Tools required for cgo and sqlite
|
|
buildInputs = [
|
|
go
|
|
pkgs.gcc
|
|
pkgs.pkg-config
|
|
pkgs.sqlite
|
|
];
|
|
|
|
# Optional (handy) tools
|
|
nativeBuildInputs = [
|
|
pkgs.git
|
|
];
|
|
|
|
# Enable CGO so mattn/go-sqlite3 works
|
|
CGO_ENABLED = 1;
|
|
|
|
# If you plan static linking, uncomment:
|
|
# hardeningDisable = [ "fortify" ];
|
|
|
|
shellHook = ''
|
|
echo "🔧 Nix dev shell ready (CGO_ENABLED=1)."
|
|
echo "▶ Run: go run ."
|
|
'';
|
|
};
|
|
});
|
|
|
|
# Convenience runner: `nix run`
|
|
apps = forAllSystems (pkgs: {
|
|
default = {
|
|
type = "app";
|
|
program = pkgs.writeShellScriptBin "run-qrank" ''
|
|
set -euo pipefail
|
|
export CGO_ENABLED=1
|
|
exec ${pkgs.go}/bin/go run .
|
|
'' + "/bin/run-qrank";
|
|
};
|
|
});
|
|
|
|
# Optional: formatter for this repo
|
|
formatter = forAllSystems (pkgs: pkgs.nixpkgs-fmt);
|
|
};
|
|
}
|