Skip to content

Commit 061f5d9

Browse files
adalessaAJenbo
authored andcommitted
red the version of the stubs from lock
1 parent dc87f97 commit 061f5d9

1 file changed

Lines changed: 33 additions & 12 deletions

File tree

flake.nix

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,57 @@
66
flake-utils.url = "github:numtide/flake-utils";
77
};
88

9-
outputs = { self, nixpkgs, flake-utils }:
10-
flake-utils.lib.eachDefaultSystem (system:
9+
outputs =
10+
{
11+
self,
12+
nixpkgs,
13+
flake-utils,
14+
}:
15+
flake-utils.lib.eachDefaultSystem (
16+
system:
1117
let
1218
pkgs = import nixpkgs {
1319
inherit system;
1420
};
1521

1622
manifest = (pkgs.lib.importTOML ./Cargo.toml).package;
23+
stubsLock = pkgs.lib.importTOML ./stubs.lock;
24+
repoParts = pkgs.lib.splitString "/" stubsLock.repo;
25+
26+
owner = builtins.elemAt repoParts 0;
27+
repo = builtins.elemAt repoParts 1;
28+
29+
stubsTarball = pkgs.fetchurl {
30+
url = "https://github.com/${owner}/${repo}/archive/${stubsLock.commit}.tar.gz";
31+
32+
# convert hex → SRI
33+
hash = builtins.convertHash {
34+
hash = stubsLock.sha256;
35+
hashAlgo = "sha256";
36+
toHashFormat = "sri";
37+
};
38+
};
39+
40+
stubsSrc = pkgs.runCommand "phpstorm-stubs" { } ''
41+
mkdir -p $out
42+
tar -xzf ${stubsTarball} --strip-components=1 -C $out
43+
'';
1744
in
1845
{
1946
packages.default = self.packages.${system}.phpantom-lsp;
20-
packages.phpantom-lsp = pkgs.rustPlatform.buildRustPackage rec {
47+
packages.phpantom-lsp = pkgs.rustPlatform.buildRustPackage {
2148
pname = manifest.name;
2249
cargoLock.lockFile = ./Cargo.lock;
2350
version = manifest.version;
2451

2552
# Use current directory as the source
2653
src = pkgs.lib.cleanSource ./.;
2754

28-
stubsSrc = pkgs.fetchFromGitHub {
29-
owner = "JetBrains";
30-
repo = "phpstorm-stubs";
31-
rev = "3327932472f512d2eb9e122b19702b335083fd9d";
32-
hash = "sha256-WN5DAvaw4FfHBl2AqSo1OcEthUm3lOpikdB78qy3cyY=";
33-
};
34-
3555
postPatch = ''
3656
mkdir -p stubs/jetbrains
3757
cp -a ${stubsSrc} stubs/jetbrains/phpstorm-stubs
3858
chmod u+wx stubs/jetbrains/phpstorm-stubs
39-
echo "${stubsSrc.rev}" > stubs/jetbrains/phpstorm-stubs/.commit
59+
echo "${stubsLock.commit}" > stubs/jetbrains/phpstorm-stubs/.commit
4060
'';
4161

4262
checkFlags = [
@@ -49,5 +69,6 @@
4969
ln -s $out/bin/phpantom-lsp $out/bin/phpantom_lsp
5070
'';
5171
};
52-
});
72+
}
73+
);
5374
}

0 commit comments

Comments
 (0)