flake.nix 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. packages = forEachSystem (
  31. pkgs:
  32. let
  33. node_modules = pkgs.callPackage ./nix/node_modules.nix {
  34. inherit rev;
  35. };
  36. opencode = pkgs.callPackage ./nix/opencode.nix {
  37. inherit node_modules;
  38. };
  39. desktop = pkgs.callPackage ./nix/desktop.nix {
  40. inherit opencode;
  41. };
  42. in
  43. {
  44. default = opencode;
  45. inherit opencode desktop;
  46. # Updater derivation with fakeHash - build fails and reveals correct hash
  47. node_modules_updater = node_modules.override {
  48. hash = pkgs.lib.fakeHash;
  49. };
  50. }
  51. );
  52. };
  53. }