diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md index f63722383..73062c573 100644 --- a/GETTING_STARTED.md +++ b/GETTING_STARTED.md @@ -31,7 +31,7 @@ cp .env.example .env Start the necessary services using Docker Compose. This inlcudes - temporal-db: Postgres 16.x for required for temporal -- temporal: 1.25.x, it derives the main logic of the application +- temporal: 1.25.x, it drives the main logic of the application - db: Postgres 16.x for the main database ```bash diff --git a/cmd/quantm/queues.go b/cmd/quantm/queues.go index 050c7f67c..9a1772439 100644 --- a/cmd/quantm/queues.go +++ b/cmd/quantm/queues.go @@ -9,6 +9,7 @@ import ( "go.breu.io/quantm/internal/pulse" ) +// q_core sets up the core queue. func q_core() { q := durable.OnCore() @@ -17,38 +18,48 @@ func q_core() { ) if q != nil { + // Register core activities q.RegisterActivity(pulse.PersistRepoEvent) q.RegisterActivity(pulse.PersistChatEvent) + // Register repo workflows and activities q.RegisterWorkflow(repos.RepoWorkflow) q.RegisterActivity(repos.NewRepoActivities()) + // Register branch workflows and activities q.RegisterWorkflow(repos.BranchWorkflow) q.RegisterActivity(repos.NewBranchActivities()) } } +// q_hooks sets up the hooks queue. func q_hooks() { q := durable.OnHooks() q.CreateWorker() if q != nil { + // Register pulse activities q.RegisterActivity(pulse.PersistRepoEvent) q.RegisterActivity(pulse.PersistChatEvent) + // Register github install workflow and activity q.RegisterWorkflow(github.InstallWorkflow) q.RegisterActivity(&github.InstallActivity{}) + // Register github sync repos workflow and activity q.RegisterWorkflow(github.SyncReposWorkflow) q.RegisterActivity(&github.InstallReposActivity{}) + // Register github push workflow and activity q.RegisterWorkflow(github.PushWorkflow) q.RegisterActivity(&github.PushActivity{}) + // Register github ref workflow and activity q.RegisterWorkflow(github.RefWorkflow) q.RegisterActivity(&github.RefActivity{}) + // Register github pull request workflow and activity q.RegisterWorkflow(github.PullRequestWorkflow) q.RegisterActivity(&github.PullRequestActivity{}) } diff --git a/flake.lock b/flake.lock index 149b0363a..63fecb32f 100644 --- a/flake.lock +++ b/flake.lock @@ -1,16 +1,16 @@ { "nodes": { - "breu-go": { + "breu": { "inputs": { "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1736505693, - "narHash": "sha256-C/NnX2Vn7YZVyefN5OYb16diKTUdkWtphjakMBSiNqs=", + "lastModified": 1737012171, + "narHash": "sha256-4nco7OvVRJoUnwM0o/atFtyKYKxDwLB3mtFbiLg7YbI=", "owner": "breuhq", "repo": "flake-go", - "rev": "969e5115aa055cb009175dd32b3f4170f102972f", + "rev": "6c1e9f5fb5976de8a4199a605d329a25579c144f", "type": "github" }, "original": { @@ -55,6 +55,29 @@ "type": "github" } }, + "gomod2nix": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1733668782, + "narHash": "sha256-tPsqU00FhgdFr0JiQUiBMgPVbl1jbPCY5gbFiJycL3I=", + "owner": "nix-community", + "repo": "gomod2nix", + "rev": "514283ec89c39ad0079ff2f3b1437404e4cba608", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "gomod2nix", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1735563628, @@ -89,8 +112,9 @@ }, "root": { "inputs": { - "breu-go": "breu-go", + "breu": "breu", "flake-utils": "flake-utils_2", + "gomod2nix": "gomod2nix", "nixpkgs": "nixpkgs_2" } }, diff --git a/flake.nix b/flake.nix index 40491f491..f1dc8a351 100644 --- a/flake.nix +++ b/flake.nix @@ -4,50 +4,61 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; flake-utils.url = "github:numtide/flake-utils"; + gomod2nix.url = "github:nix-community/gomod2nix"; + gomod2nix.inputs.nixpkgs.follows = "nixpkgs"; + gomod2nix.inputs.flake-utils.follows = "flake-utils"; - breu-go.url = "github:breuhq/flake-go"; + breu.url = "github:breuhq/flake-go"; }; outputs = { nixpkgs, - breu-go, flake-utils, + breu, ... }: flake-utils.lib.eachDefaultSystem ( system: let pkgs = import nixpkgs {inherit system;}; + buildGoModule = pkgs.buildGo123Module; - # Apply the breu-go overlay - pkgs' = pkgs.extend (final: prev: breu-go.overlay.${system} final prev); + setup = breu.setup.${system}; - # Add required dependencies to the base environment - base = pkgs'.setup.base [ + # Base packages required for building and running quantm + base = setup.base [ pkgs.openssl pkgs.http-parser pkgs.zlib - pkgs.python3 # requird for http-parser + pkgs.python3 # required for http-parser in libgit2 pkgs.libgit2 ]; - # Set up the development shell with our base packages - shell = pkgs'.setup.shell base [] {}; + # Development packages for use in the dev shell + dev = [ + pkgs.libpg_query # FIXME: probably not required anymore. + (pkgs.callPackage ./tools/nix/pkgs/sqlc.nix {inherit buildGoModule;}) + ]; + + # Set up the development shell with our base and dev packages + shell = setup.shell base dev {}; + # Build the quantm binary quantm = pkgs.stdenv.mkDerivation { name = "quantm"; - version = "0.1.0"; # Adjust as needed - src = ./.; # Use the directory containing your Go code + src = ./.; nativeBuildInputs = base; buildPhase = '' - export GOROOT="${pkgs.go_1_23}/share/go" - go build -x -tags static,system_libgit2 -o $out/bin/quantm ./cmd/quantm + export GOROOT=${pkgs.go_1_23}/share/go + export GOCACHE="$TEMPDIR/go-cache" + export GOMODCACHE="$TEMPDIR/go-mod-cache" + go build -x -tags static,system_libgit2 -o ./tmp/quantm ./cmd/quantm ''; installPhase = '' mkdir -p $out/bin - cp $out/bin/quantm $out/bin/quantm + cp ./tmp/quantm $out/bin/quantm ''; }; in { diff --git a/tools/nix/pkgs/sqlc.nix b/tools/nix/pkgs/sqlc.nix new file mode 100644 index 000000000..cfc0451fc --- /dev/null +++ b/tools/nix/pkgs/sqlc.nix @@ -0,0 +1,45 @@ +{ + lib, + stdenv, + buildGoModule, + fetchFromGitHub, + installShellFiles, +}: +buildGoModule rec { + pname = "sqlc"; + version = "1.27.0"; + + src = fetchFromGitHub { + owner = "sqlc-dev"; + repo = "sqlc"; + rev = "v${version}"; + hash = "sha256-wxQ+YPsDX0Z6B8whlQ/IaT2dRqapPL8kOuFEc6As1rU="; + }; + + proxyVendor = true; + vendorHash = "sha256-ndOw3uShF5TngpxYNumoK3H3R9v4crfi5V3ZCoSqW90="; + + subPackages = ["cmd/sqlc"]; + + nativeBuildInputs = [installShellFiles]; + + ldflags = [ + "-s" + "-w" + ]; + + postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' + installShellCompletion --cmd sqlc \ + --bash <($out/bin/sqlc completion bash) \ + --fish <($out/bin/sqlc completion fish) \ + --zsh <($out/bin/sqlc completion zsh) + ''; + + meta = { + description = "Generate type-safe code from SQL"; + homepage = "https://sqlc.dev/"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [aaronjheng]; + mainProgram = "sqlc"; + }; +}