Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
91 lines (81 loc) · 3.02 KB
/
Copy pathflake.nix
File metadata and controls
91 lines (81 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
{
description = "pi-go, an extensible AI coding agent";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs = { self, nixpkgs }:
let
systems = [ "x86_64-linux" "aarch64-linux" ];
forAllSystems = nixpkgs.lib.genAttrs systems;
in {
packages = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
version = "unstable-${self.shortRev or "dirty"}";
package = pkgs.buildGoModule {
pname = "pi-go";
inherit version;
src = ./.;
vendorHash = "sha256-43goJ21uDYZbTOwELp7V3IqxeGhWi5wmIgP6qLy4G4Q=";
# The repository currently requires Go 1.27, which is not yet
# available in the pinned nixpkgs revision. This is only a module
# directive compatibility patch; the source uses no newer APIs.
#
# This was once accompanied by a second substitution promoting
# google.golang.org/grpc out of the indirect block. main now
# requires it directly, so the pattern no longer matches — and
# because substituteInPlace uses --replace-fail, a stale pattern
# does not degrade to a no-op, it aborts the build.
postPatch = ''
substituteInPlace go.mod \
--replace-fail 'go 1.27.3' 'go 1.26.5'
'';
subPackages = [ "cmd/pi" ];
buildFlags = [ "-mod=mod" ];
ldflags = [
"-s"
"-w"
"-X github.com/dimetron/pi-go/internal/cli.Version=${version}"
"-X github.com/dimetron/pi-go/internal/cli.BuildTag=${self.shortRev or "source"}"
];
meta = {
description = "An extensible AI coding agent";
homepage = "https://github.com/dimetron/pi-go";
license = pkgs.lib.licenses.mit;
mainProgram = "pi";
};
};
in {
default = package;
});
apps = forAllSystems (system: {
default = {
type = "app";
program = "${self.packages.${system}.default}/bin/pi";
};
});
devShells = forAllSystems (system:
let pkgs = import nixpkgs { inherit system; };
in {
default = pkgs.mkShell {
packages = [ pkgs.go_1_26 pkgs.git pkgs.gnumake ];
};
});
nixosModules.default = { config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.pi-go;
in {
options.programs.pi-go = {
enable = mkEnableOption "pi-go";
package = mkOption {
type = types.package;
default = self.packages.${pkgs.system}.default;
defaultText = literalExpression "self.packages.\${pkgs.system}.default";
description = "The pi-go package to install.";
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
};
};
};
}