flake.nix 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. opencode = final.callPackage ./nix/opencode.nix {
  38. inherit node_modules;
  39. };
  40. desktop = final.callPackage ./nix/desktop.nix {
  41. inherit opencode;
  42. };
  43. in
  44. {
  45. inherit opencode;
  46. opencode-desktop = desktop;
  47. };
  48. };
  49. packages = forEachSystem (
  50. pkgs:
  51. let
  52. node_modules = pkgs.callPackage ./nix/node_modules.nix {
  53. inherit rev;
  54. };
  55. opencode = pkgs.callPackage ./nix/opencode.nix {
  56. inherit node_modules;
  57. };
  58. desktop = pkgs.callPackage ./nix/desktop.nix {
  59. inherit opencode;
  60. };
  61. in
  62. {
  63. default = opencode;
  64. inherit opencode desktop;
  65. # Updater derivation with fakeHash - build fails and reveals correct hash
  66. node_modules_updater = node_modules.override {
  67. hash = pkgs.lib.fakeHash;
  68. };
  69. }
  70. );
  71. };
  72. }