Repository navigation
Release 0.3.1: Packaging & QEMU fix #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sylvinus
wants to merge
5
commits into
main
Choose a base branch
from
0.3.1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| { | ||
| description = "agent-vm: AI coding agents in a disposable Linux VM per project"; | ||
|
|
||
| inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | ||
|
|
||
| outputs = | ||
| { self, nixpkgs }: | ||
| let | ||
| # Linux only for now: on macOS the binary needs cgo, the SDK and the | ||
| # virtualization entitlement (nixpkgs' lima signs it with | ||
| # darwin.sigtool), none of which this build sets up. | ||
| systems = [ | ||
| "x86_64-linux" | ||
| "aarch64-linux" | ||
| ]; | ||
| forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system}); | ||
|
|
||
| # The version, the build tags and Lima's version are the Makefile's and | ||
| # third_party/SOURCES's: there is one place to change each. | ||
| linesOf = file: builtins.filter builtins.isString (builtins.split "\n" (builtins.readFile file)); | ||
| lineWith = | ||
| file: prefix: | ||
| builtins.head ( | ||
| builtins.filter (l: builtins.substring 0 (builtins.stringLength prefix) l == prefix) (linesOf file) | ||
| ); | ||
| makeVar = | ||
| name: | ||
| let | ||
| prefix = "${name} := "; | ||
| in | ||
| builtins.substring (builtins.stringLength prefix) (-1) (lineWith ./Makefile prefix); | ||
| # lima <upstream> <commit> <version> <left out> | ||
| limaVersion = builtins.elemAt (builtins.filter (s: builtins.isString s && s != "") ( | ||
| builtins.split " +" (lineWith ./third_party/SOURCES "lima ") | ||
| )) 3; | ||
| in | ||
| { | ||
| packages = forAllSystems (pkgs: rec { | ||
| agent-vm = pkgs.buildGoModule { | ||
| pname = "agent-vm"; | ||
| version = makeVar "NEXT_VERSION"; | ||
| src = self; | ||
|
|
||
| # The downloaded modules only: a vendor folder would hold | ||
| # third_party/ too (go.mod's replaces), and change with each patch. | ||
| proxyVendor = true; | ||
| # Changes with go.mod and go.sum: set pkgs.lib.fakeHash here, build, | ||
| # and nix prints the new one. release.sh refuses a release when | ||
| # this checksum of `cat go.mod go.sum` is not the current one: | ||
| # update it with the hash. | ||
| # go.mod+go.sum: 0d831936e2c268c65229802f0d5026b4aba48507157f9b6a034225b64408a24e | ||
| vendorHash = "sha256-zfAasYQEKqcrGi4OI3UKJyq3VoUCmNE5lU4JKPtJDmc="; | ||
|
|
||
| subPackages = [ "cmd/agent-vm" ]; | ||
| tags = pkgs.lib.splitString "," (makeVar "TAGS"); | ||
| env.CGO_ENABLED = "0"; | ||
| ldflags = [ | ||
| "-s" | ||
| "-w" | ||
| "-X github.com/sylvinus/agent-vm/internal/version.Version=${makeVar "NEXT_VERSION"}" | ||
| "-X github.com/lima-vm/lima/v2/pkg/version.Version=${limaVersion}" | ||
| # QEMU comes with it, first on its PATH (cmd/agent-vm/main.go), as | ||
| # nixpkgs' lima does with a wrapper: a wrapped binary would make | ||
| # `agent-vm install` link past the wrapper. qemu_kvm, this host's | ||
| # architecture only, is a third smaller than qemu. ssh is the | ||
| # system's. | ||
| "-X main.extraPath=${pkgs.lib.makeBinPath [ pkgs.qemu_kvm ]}" | ||
| ]; | ||
|
|
||
| nativeBuildInputs = [ pkgs.gzip ]; | ||
|
|
||
| # go.mod names the Go the project is developed with, and nixpkgs | ||
| # has it a few days after a release: the build uses nixpkgs' (the | ||
| # sandbox cannot download a toolchain). | ||
| postPatch = '' | ||
| sed -i 's/^go [0-9.]*$/go ${pkgs.go.version}/' go.mod | ||
| ''; | ||
|
|
||
| # What the Makefile's `assets` target does: the guest agent runs in | ||
| # the Linux guest, of this machine's architecture, and is embedded | ||
| # in the binary with Lima's templates. | ||
| preBuild = | ||
| let | ||
| guestArch = if pkgs.stdenv.hostPlatform.isAarch64 then "aarch64" else "x86_64"; | ||
| assets = "internal/limaembed/assets"; | ||
| in | ||
| '' | ||
| go build -trimpath -ldflags "-s -w -X github.com/lima-vm/lima/v2/pkg/version.Version=${limaVersion}" \ | ||
| -o ${assets}/lima-guestagent.Linux-${guestArch} github.com/lima-vm/lima/v2/cmd/lima-guestagent | ||
| gzip -9 -n -f ${assets}/lima-guestagent.Linux-${guestArch} | ||
| rm -rf ${assets}/templates | ||
| cp -R third_party/lima/templates ${assets}/templates | ||
| ''; | ||
|
|
||
| # The module download shares preBuild with the build, and has no | ||
| # modules to build the guest agent from yet. | ||
| overrideModAttrs = _: { | ||
| preBuild = ""; | ||
| }; | ||
|
|
||
| # The tests run in CI, on the three platforms. | ||
| doCheck = false; | ||
|
|
||
| meta = { | ||
| description = "Run AI coding agents in a disposable Linux VM per project"; | ||
| homepage = "https://www.agent-vm.org/"; | ||
| license = pkgs.lib.licenses.mit; | ||
| mainProgram = "agent-vm"; | ||
| platforms = systems; | ||
| }; | ||
| }; | ||
| default = agent-vm; | ||
| }); | ||
|
|
||
| apps = forAllSystems (pkgs: { | ||
| default = { | ||
| type = "app"; | ||
| program = "${self.packages.${pkgs.stdenv.hostPlatform.system}.agent-vm}/bin/agent-vm"; | ||
| }; | ||
| }); | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.