diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..3f06416f --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "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" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1777268161, + "narHash": "sha256-bxrdOn8SCOv8tN4JbTF/TXq7kjo9ag4M+C8yzzIRYbE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1c3fe55ad329cbcb28471bb30f05c9827f724c76", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "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..431dddb7 --- /dev/null +++ b/flake.nix @@ -0,0 +1,53 @@ +{ + description = "Flake for phphantom-lsp (local development)"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + }; + + manifest = (pkgs.lib.importTOML ./Cargo.toml).package; + in + { + packages.default = self.packages.${system}.phpantom-lsp; + packages.phpantom-lsp = pkgs.rustPlatform.buildRustPackage rec { + pname = manifest.name; + cargoLock.lockFile = ./Cargo.lock; + version = manifest.version; + + # Use current directory as the source + src = pkgs.lib.cleanSource ./.; + + stubsSrc = pkgs.fetchFromGitHub { + owner = "JetBrains"; + repo = "phpstorm-stubs"; + rev = "3327932472f512d2eb9e122b19702b335083fd9d"; + hash = "sha256-WN5DAvaw4FfHBl2AqSo1OcEthUm3lOpikdB78qy3cyY="; + }; + + postPatch = '' + mkdir -p stubs/jetbrains + cp -a ${stubsSrc} stubs/jetbrains/phpstorm-stubs + chmod u+wx stubs/jetbrains/phpstorm-stubs + echo "${stubsSrc.rev}" > stubs/jetbrains/phpstorm-stubs/.commit + ''; + + checkFlags = [ + "--test" + "completion_inheritance" + ]; + + postInstall = '' + mv $out/bin/phpantom_lsp $out/bin/phpantom-lsp + ln -s $out/bin/phpantom-lsp $out/bin/phpantom_lsp + ''; + }; + }); +}