separate the package into default.nix so non-flake nix can build and install it
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950{ pkgs ? import <nixpkgs> { }, # baked into the binary as the rpc version string; the flake passes its own # rev, a plain nix-build reports "dev" - mismatches force remote re-uploads rev ? "dev",}:let inherit (pkgs) lib; # non-flake eval has no git-tree filter and the repo collects state that # must not reach the store: the stray root `tobi` binary from `go build` # and the churn-heavy .jj dir of the colocated jj checkout src = lib.cleanSourceWith { src = lib.cleanSource ./.; filter = path: type: !(type == "directory" && baseNameOf path == ".jj") && (type == "directory" || baseNameOf path != "tobi"); };inpkgs.buildGoModule { pname = "tobi"; version = "0.1.0"; inherit src; vendorHash = "sha256-qbOGgVRsO0/F1dB/vIERm6EsUjgWGzT2z938pnKVbcI="; subPackages = [ "." ]; ldflags = [ "-s" "-w" "-X tobi/internal/remote.Version=${rev}" ]; nativeBuildInputs = [ pkgs.zstd ]; postInstall = '' install -Dm644 contrib/tobi.nu $out/share/nushell/vendor/autoload/tobi.nu ''; # cross-compile every carrier slice into a temp dir outside # internal/remote/payloads, so no slice can recursively embed the # slices of earlier loop iterations (same slices as # scripts/build-universal.sh); the host carrier is built last and # embeds all of them preBuild = '' mkdir -p internal/remote/payloads slices=$(mktemp -d) for target in linux/amd64 linux/arm64 darwin/arm64; do os=''${target%%/*} arch=''${target##*/} echo "building carrier slice for $os/$arch" CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -trimpath \ -ldflags="-s -w -X tobi/internal/remote.Version=${rev}" \ -o $slices/tobi-$os-$arch . zstd -19 -q --rm $slices/tobi-$os-$arch done mv $slices/*.zst internal/remote/payloads/ rm -rf $slices '';}8 unmodified lines91011121313141515161718192021222324252627282930313233343536373839404142434445161718199 unmodified lines8 unmodified lines outputs = inp: inp.parts.lib.mkFlake { inputs = inp; } { systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ]; perSystem = { pkgs, ... }: { packages.default = let packages.default = import ./default.nix { inherit pkgs; rev = inp.self.shortRev or inp.self.dirtyShortRev or "dev"; in pkgs.buildGoModule { pname = "tobi"; version = "0.1.0"; src = ./.; vendorHash = "sha256-qbOGgVRsO0/F1dB/vIERm6EsUjgWGzT2z938pnKVbcI="; subPackages = [ "." ]; ldflags = [ "-s" "-w" "-X tobi/internal/remote.Version=${rev}" ]; nativeBuildInputs = [ pkgs.zstd ]; postInstall = '' install -Dm644 contrib/tobi.nu $out/share/nushell/vendor/autoload/tobi.nu ''; # cross-compile every carrier slice into a temp dir outside # internal/remote/payloads, so no slice can recursively embed the # slices of earlier loop iterations (same slices as # scripts/build-universal.sh); the host carrier is built last and # embeds all of them preBuild = '' mkdir -p internal/remote/payloads slices=$(mktemp -d) for target in linux/amd64 linux/arm64 darwin/arm64; do os=''${target%%/*} arch=''${target##*/} echo "building carrier slice for $os/$arch" CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -trimpath \ -ldflags="-s -w -X tobi/internal/remote.Version=${rev}" \ -o $slices/tobi-$os-$arch . zstd -19 -q --rm $slices/tobi-$os-$arch done mv $slices/*.zst internal/remote/payloads/ rm -rf $slices ''; };
devShells.default = pkgs.mkShell { packages = with pkgs; [9 unmodified lines23 unmodified lines242526272829282930313233349 unmodified lines23 unmodified lines
## installation
there is a nix flake so you can use that, just do`nix profile add git+https://tangled.org/ptr.pet/tobi`. otherwise get go andcompile it!`nix profile add git+https://tangled.org/ptr.pet/tobi`.or `nix-env -f . -i tobi` (or `nix profile add -f .`).otherwise get go and compile it!
if you run target tobi to a host that doesn't have it, then tobi will installitself onto the user's `~/.local/bin` (or equivalent) automatically, or upgradean outdated tobi if the one on the target host is a different version.9 unmodified lines