diff --git a/.gitignore b/.gitignore index 3911f220..9c4f9551 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,8 @@ pnpm-debug.log* .pnpm-debug.log* # Common build outputs +result +result-* dist/ **/dist/ build/ diff --git a/README.md b/README.md index 56b09734..365670f0 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,12 @@ curl -fsSL --proto '=https' --tlsv1.2 https://install.codanna.sh | sh brew install codanna ``` +### Or via Nix + +```bash +nix run github:bartolli/codanna +``` + ### Windows (PowerShell) ```powershell irm https://raw.githubusercontent.com/bartolli/codanna/main/scripts/install.ps1 | iex diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..fe873248 --- /dev/null +++ b/flake.lock @@ -0,0 +1,143 @@ +{ + "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "naersk", + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1752475459, + "narHash": "sha256-z6QEu4ZFuHiqdOPbYss4/Q8B0BFhacR8ts6jO/F/aOU=", + "owner": "nix-community", + "repo": "fenix", + "rev": "bf0d6f70f4c9a9cf8845f992105652173f4b617f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "naersk": { + "inputs": { + "fenix": "fenix", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1769799857, + "narHash": "sha256-88IFXZ7Sa1vxbz5pty0Io5qEaMQMMUPMonLa3Ls/ss4=", + "owner": "nix-community", + "repo": "naersk", + "rev": "9d4ed44d8b8cecdceb1d6fd76e74123d90ae6339", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "naersk", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1773628058, + "narHash": "sha256-hpXH0z3K9xv0fHaje136KY872VT2T5uwxtezlAskQgY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f8573b9c935cfaa162dd62cc9e75ae2db86f85df", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "naersk": "naersk", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1752428706, + "narHash": "sha256-EJcdxw3aXfP8Ex1Nm3s0awyH9egQvB2Gu+QEnJn2Sfg=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "591e3b7624be97e4443ea7b5542c191311aa141d", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1774062094, + "narHash": "sha256-ba3c+hS7KzEiwtZRGHagIAYdcmdY3rCSWVCyn64rx7s=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "c807e83cc2e32adc35f51138b3bdef722c0812ab", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..1a12cbe6 --- /dev/null +++ b/flake.nix @@ -0,0 +1,69 @@ +{ + description = "Code Intelligence for Large Language Models"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + naersk = { + url = "github:nix-community/naersk"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = + { + self, + nixpkgs, + rust-overlay, + naersk, + flake-utils, + ... + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ rust-overlay.overlays.default ]; + }; + rust = pkgs.rust-bin.stable.latest.default; + naersk' = pkgs.callPackage naersk { + cargo = rust; + rustc = rust; + }; + in + { + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ + rust + rust-analyzer + openssl + onnxruntime + pkg-config + ]; + ORT_SKIP_DOWNLOAD = "1"; + }; + packages.default = naersk'.buildPackage { + pname = "codanna"; + src = ./.; + buildInputs = [ + pkgs.openssl + pkgs.onnxruntime + ]; + nativeBuildInputs = [ pkgs.pkg-config ]; + cargoBuildOptions = + x: + x + ++ [ + "-p" + "codanna" + ]; + ORT_SKIP_DOWNLOAD = "1"; + }; + } + ); +}