| 1 | { |
| 2 | inputs = { |
| 3 | nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; |
| 4 | fenix = { |
| 5 | url = "github:nix-community/fenix"; |
| 6 | inputs.nixpkgs.follows = "nixpkgs"; |
| 7 | }; |
| 8 | }; |
| 9 | |
| 10 | outputs = |
| 11 | { |
| 12 | self, |
| 13 | fenix, |
| 14 | ... |
| 15 | }@inputs: |
| 16 | let |
| 17 | systems = [ |
| 18 | "x86_64-linux" |
| 19 | "aarch64-linux" |
| 20 | "x86_64-darwin" |
| 21 | "aarch64-darwin" |
| 22 | ]; |
| 23 | forEachSystem = |
| 24 | f: |
| 25 | inputs.nixpkgs.lib.genAttrs systems ( |
| 26 | system: |
| 27 | f { |
| 28 | inherit system; |
| 29 | pkgs = import inputs.nixpkgs { |
| 30 | inherit system; |
| 31 | overlays = [ |
| 32 | inputs.self.overlays.default |
| 33 | ]; |
| 34 | }; |
| 35 | } |
| 36 | ); |
| 37 | rev = self.shortRev or self.dirtyShortRev or "dirty"; |
| 38 | in |
| 39 | { |
| 40 | packages = forEachSystem ( |
| 41 | { pkgs, system }: |
| 42 | let |
| 43 | codewhale = pkgs.callPackage ./nix/package.nix { |
| 44 | inherit rev; |
| 45 | rustPlatform = pkgs.makeRustPlatform { |
| 46 | cargo = pkgs.rustToolchain; |
| 47 | rustc = pkgs.rustToolchain; |
| 48 | }; |
| 49 | }; |
| 50 | in |
| 51 | { |
| 52 | default = codewhale; |
| 53 | codewhale = codewhale; |
| 54 | # Compatibility alias for existing Nix users during the rename. |
| 55 | deepseek-tui = codewhale; |
| 56 | } |
| 57 | ); |
| 58 | |
| 59 | overlays.default = final: prev: { |
| 60 | rustToolchain = |
| 61 | with fenix.packages.${prev.stdenv.hostPlatform.system}; |
| 62 | combine ( |
| 63 | with stable; |
| 64 | [ |
| 65 | rustc |
| 66 | cargo |
| 67 | clippy |
| 68 | rustfmt |
| 69 | rust-src |
| 70 | ] |
| 71 | ); |
| 72 | }; |
| 73 | |
| 74 | devShells = forEachSystem ( |
| 75 | { pkgs, system }: |
| 76 | { |
| 77 | default = pkgs.mkShell { |
| 78 | packages = [ |
| 79 | pkgs.rustToolchain |
| 80 | pkgs.rust-analyzer |
| 81 | pkgs.lldb |
| 82 | pkgs.pkg-config |
| 83 | pkgs.openssl |
| 84 | pkgs.python3 |
| 85 | self.formatter.${system} |
| 86 | ] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [ |
| 87 | pkgs.dbus |
| 88 | ]; |
| 89 | |
| 90 | env = { |
| 91 | # Required by rust-analyzer |
| 92 | RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library"; |
| 93 | } // pkgs.lib.optionalAttrs pkgs.stdenv.isLinux { |
| 94 | LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath ( |
| 95 | with pkgs; |
| 96 | [ |
| 97 | openssl |
| 98 | dbus |
| 99 | ] |
| 100 | ); |
| 101 | }; |
| 102 | }; |
| 103 | } |
| 104 | ); |
| 105 | |
| 106 | formatter = forEachSystem ({ pkgs, ... }: pkgs.nixfmt); |
| 107 | }; |
| 108 | } |
| 109 |