flake.nix 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. {
  2. description = "OpenCode development flake";
  3. inputs = {
  4. nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
  5. };
  6. outputs =
  7. { self, nixpkgs, ... }:
  8. let
  9. systems = [
  10. "aarch64-linux"
  11. "x86_64-linux"
  12. "aarch64-darwin"
  13. "x86_64-darwin"
  14. ];
  15. forEachSystem = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
  16. rev = self.shortRev or self.dirtyShortRev or "dirty";
  17. in
  18. {
  19. devShells = forEachSystem (pkgs: {
  20. default = pkgs.mkShell {
  21. packages = with pkgs; [
  22. bun
  23. nodejs_20
  24. pkg-config
  25. openssl
  26. git
  27. ];
  28. };
  29. });
  30. overlays = {
  31. default =
  32. final: _prev:
  33. let
  34. node_modules = final.callPackage ./nix/node_modules.nix {
  35. inherit rev;
  36. };
  37. in
  38. rec {
  39. opencode = final.callPackage ./nix/opencode.nix {
  40. inherit node_modules;
  41. };
  42. opencode-desktop = final.callPackage ./nix/desktop.nix {
  43. inherit opencode;
  44. };
  45. };
  46. };
  47. packages = forEachSystem (
  48. pkgs:
  49. let
  50. node_modules = pkgs.callPackage ./nix/node_modules.nix {
  51. inherit rev;
  52. };
  53. in
  54. rec {
  55. default = opencode;
  56. opencode = pkgs.callPackage ./nix/opencode.nix {
  57. inherit node_modules;
  58. };
  59. opencode-desktop = pkgs.callPackage ./nix/desktop.nix {
  60. inherit opencode;
  61. };
  62. # Updater derivation with fakeHash - build fails and reveals correct hash
  63. node_modules_updater = node_modules.override {
  64. hash = pkgs.lib.fakeHash;
  65. };
  66. }
  67. );
  68. };
  69. }