Something went wrong. Try again.
A Tangled spindle that runs CI on other providers, including ephemeral DigitalOcean droplets.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124{ description = "tack";
inputs = { nixpkgs.url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz"; flake-utils.url = "github:numtide/flake-utils"; };
outputs = { self, nixpkgs, flake-utils, ... }: # Per-system outputs (packages, apps, devShells). nixosModules is # system-independent and is merged in below. flake-utils.lib.eachDefaultSystem ( system: let pkgs = nixpkgs.legacyPackages.${system};
# vendorHash pins the Go module download FOD shared by both builds # below. Update it whenever go.mod / go.sum changes by replacing it # with lib.fakeHash and rebuilding to surface the new hash. vendorHash = "sha256-Vm3uINhhAF4ScKE9L/ulOm4/xetlWxL2Wf29jIKmlbI=";
# The agent the droplet provider serves to its runner droplets. It is # built without cgo so the one static binary runs on whatever image a # droplet boots. DigitalOcean droplets are x86_64, so tack has to be # deployed from an x86_64-linux build for this to match them. tack-runner = pkgs.buildGoModule { pname = "tack-runner"; version = "0.1.0"; src = ./.; inherit vendorHash; proxyVendor = true; subPackages = ["cmd/tack-runner"]; env.CGO_ENABLED = "0"; ldflags = ["-s" "-w"]; };
# The tack binary itself. We use buildGoModule because the module is # a single `main` package at the repo root with internal subpackages. # CGO is required for github.com/mattn/go-sqlite3. tack = pkgs.buildGoModule { pname = "tack"; version = "0.1.0"; src = ./.;
inherit vendorHash;
# The repo ships a stale `tack` binary at the root that gets caught # by `go test ./...`-style discovery; ignore it during the build. subPackages = ["."];
# Fetch modules via the Go module proxy instead of synthesizing a # vendor/ directory. We pull in deps (e.g. tangled.org/core -> # go-redis/cache) whose test files require github.com/onsi/gomega; # `go mod vendor` then refuses to build because gomega is in go.mod # but not marked explicit in vendor/modules.txt. Proxy mode sidesteps # the vendor consistency check entirely. proxyVendor = true;
# mattn/go-sqlite3 needs cgo + a C compiler. env.CGO_ENABLED = "1";
# Workflow discovery uses sparse Git checkouts at runtime. nativeBuildInputs = [pkgs.makeWrapper pkgs.git]; # The droplet provider serves tack-runner to its droplets, so the # binary it reads is pinned here unless the operator overrides it. postInstall = '' wrapProgram $out/bin/tack \ --prefix PATH : ${pkgs.lib.makeBinPath [pkgs.git]} \ --set-default TACK_DIGITALOCEAN_RUNNER_BINARY ${tack-runner}/bin/tack-runner ''; }; in { # `nix fmt` formats the tree with alejandra. CI pins this same # binary via `nix run nixpkgs#alejandra` for the format check. formatter = pkgs.alejandra;
devShells.default = pkgs.mkShell { packages = [ pkgs.go ]; };
packages = { default = tack; tack = tack; tack-runner = tack-runner; };
apps = { default = { type = "app"; program = "${tack}/bin/tack"; }; tack = { type = "app"; program = "${tack}/bin/tack"; }; }; } ) // { # NixOS module. Operators add `imports = [ tack.nixosModules.default ];` # and configure via `services.tangled.tack`. Mirrors the upstream # Tangled module shape (services.tangled.spindle, .knot, …) so the # config namespace is consistent. nixosModules.default = { lib, pkgs, ... }: { imports = [./nix/modules/tack.nix];
services.tangled.tack.package = lib.mkDefault self.packages.${pkgs.stdenv.hostPlatform.system}.tack; }; nixosModules.tack = self.nixosModules.default; };}