10
flake.nix
10
flake.nix
@@ -46,6 +46,7 @@
|
|||||||
hostname: let
|
hostname: let
|
||||||
syncthingOverlay = import ./overlays/syncthing-darwin.nix;
|
syncthingOverlay = import ./overlays/syncthing-darwin.nix;
|
||||||
syncthingModule = (syncthingOverlay null {}).darwinSyncthingModule;
|
syncthingModule = (syncthingOverlay null {}).darwinSyncthingModule;
|
||||||
|
opencodeOverlay = import ./overlays/opencode.nix;
|
||||||
in
|
in
|
||||||
inputs.darwin.lib.darwinSystem {
|
inputs.darwin.lib.darwinSystem {
|
||||||
system = "aarch64-darwin";
|
system = "aarch64-darwin";
|
||||||
@@ -60,7 +61,7 @@
|
|||||||
syncthingModule
|
syncthingModule
|
||||||
|
|
||||||
{
|
{
|
||||||
nixpkgs.overlays = [syncthingOverlay];
|
nixpkgs.overlays = [syncthingOverlay opencodeOverlay];
|
||||||
|
|
||||||
nix-homebrew = {
|
nix-homebrew = {
|
||||||
inherit user;
|
inherit user;
|
||||||
@@ -79,7 +80,9 @@
|
|||||||
);
|
);
|
||||||
|
|
||||||
flake.nixosConfigurations = inputs.nixpkgs.lib.genAttrs nixosHosts (
|
flake.nixosConfigurations = inputs.nixpkgs.lib.genAttrs nixosHosts (
|
||||||
hostname:
|
hostname: let
|
||||||
|
opencodeOverlay = import ./overlays/opencode.nix;
|
||||||
|
in
|
||||||
inputs.nixpkgs.lib.nixosSystem {
|
inputs.nixpkgs.lib.nixosSystem {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
specialArgs =
|
specialArgs =
|
||||||
@@ -89,6 +92,9 @@
|
|||||||
};
|
};
|
||||||
modules = [
|
modules = [
|
||||||
inputs.home-manager.nixosModules.home-manager
|
inputs.home-manager.nixosModules.home-manager
|
||||||
|
{
|
||||||
|
nixpkgs.overlays = [opencodeOverlay];
|
||||||
|
}
|
||||||
./hosts/nixos/${hostname}
|
./hosts/nixos/${hostname}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
home-manager = {
|
home-manager = {
|
||||||
|
useGlobalPkgs = true;
|
||||||
users.${user} = {
|
users.${user} = {
|
||||||
pkgs,
|
pkgs,
|
||||||
config,
|
config,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
with pkgs; [
|
with pkgs; [
|
||||||
(callPackage ./bin/open-project.nix {})
|
(callPackage ./bin/open-project.nix {})
|
||||||
age
|
age
|
||||||
|
lsof
|
||||||
alejandra
|
alejandra
|
||||||
delta
|
delta
|
||||||
docker
|
docker
|
||||||
|
|||||||
108
overlays/opencode.nix
Normal file
108
overlays/opencode.nix
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
final: prev: {
|
||||||
|
opencode = prev.opencode.overrideAttrs (oldAttrs: rec {
|
||||||
|
version = "0.5.12";
|
||||||
|
|
||||||
|
src = prev.fetchFromGitHub {
|
||||||
|
owner = "sst";
|
||||||
|
repo = "opencode";
|
||||||
|
tag = "v${version}";
|
||||||
|
hash = "sha256-iPv6rATpIpf2j81Ud4OSWOt0ZSR0sAYBhBRrQpOH1Bs=";
|
||||||
|
};
|
||||||
|
|
||||||
|
tui = prev.buildGoModule {
|
||||||
|
pname = "opencode-tui";
|
||||||
|
inherit version src;
|
||||||
|
modRoot = "packages/tui";
|
||||||
|
vendorHash = "sha256-acDXCL7ZQYW5LnEqbMgDwpTbSgtf4wXnMMVtQI1Dv9s=";
|
||||||
|
subPackages = ["cmd/opencode"];
|
||||||
|
|
||||||
|
env.CGO_ENABLED = 0;
|
||||||
|
|
||||||
|
ldflags = [
|
||||||
|
"-s"
|
||||||
|
"-X=main.Version=${version}"
|
||||||
|
];
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
install -Dm755 $GOPATH/bin/opencode $out/bin/tui
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
node_modules = prev.stdenvNoCC.mkDerivation {
|
||||||
|
pname = "opencode-node_modules";
|
||||||
|
inherit version src;
|
||||||
|
|
||||||
|
impureEnvVars =
|
||||||
|
prev.lib.fetchers.proxyImpureEnvVars
|
||||||
|
++ [
|
||||||
|
"GIT_PROXY_COMMAND"
|
||||||
|
"SOCKS_SERVER"
|
||||||
|
];
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
prev.bun
|
||||||
|
prev.writableTmpDirAsHomeHook
|
||||||
|
];
|
||||||
|
|
||||||
|
dontConfigure = true;
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
|
||||||
|
export BUN_INSTALL_CACHE_DIR=$(mktemp -d)
|
||||||
|
|
||||||
|
# Disable post-install scripts to avoid shebang issues
|
||||||
|
bun install \
|
||||||
|
--filter=opencode \
|
||||||
|
--force \
|
||||||
|
--frozen-lockfile \
|
||||||
|
--ignore-scripts \
|
||||||
|
--no-progress \
|
||||||
|
--production
|
||||||
|
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
|
||||||
|
mkdir -p $out/node_modules
|
||||||
|
cp -R ./node_modules $out
|
||||||
|
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
|
||||||
|
dontFixup = true;
|
||||||
|
|
||||||
|
outputHash = "sha256-hznCg/7c9uNV7NXTkb6wtn3EhJDkGI7yZmSIA2SqX7g=";
|
||||||
|
outputHashAlgo = "sha256";
|
||||||
|
outputHashMode = "recursive";
|
||||||
|
};
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
|
||||||
|
bun build \
|
||||||
|
--define OPENCODE_TUI_PATH="'${oldAttrs.tui}/bin/tui'" \
|
||||||
|
--define OPENCODE_VERSION="'${version}'" \
|
||||||
|
--compile \
|
||||||
|
--target=${
|
||||||
|
{
|
||||||
|
"aarch64-darwin" = "bun-darwin-arm64";
|
||||||
|
"aarch64-linux" = "bun-linux-arm64";
|
||||||
|
"x86_64-darwin" = "bun-darwin-x64";
|
||||||
|
"x86_64-linux" = "bun-linux-x64";
|
||||||
|
}.${
|
||||||
|
prev.stdenvNoCC.hostPlatform.system
|
||||||
|
}
|
||||||
|
} \
|
||||||
|
--outfile=opencode \
|
||||||
|
./packages/opencode/src/index.ts \
|
||||||
|
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user