File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change 77import os
88import subprocess
99import sys
10+ from pathlib import Path
1011
1112
1213ROBOTNIX_GIT_MIRRORS = os .environ .get ('ROBOTNIX_GIT_MIRRORS' , '' )
@@ -31,19 +32,24 @@ def save(filename: str, data: Any) -> None:
3132
3233def get_store_path (path ):
3334 """Get actual path to a Nix store path; supports handling local remotes"""
34- prefix = os .getenv ("NIX_REMOTE" , "/" )
35- if not prefix .startswith ("/" ):
35+ prefix = os .getenv ("NIX_REMOTE" )
36+
37+ if not prefix :
38+ return path
39+
40+ prefix = Path (prefix )
41+
42+ if not prefix .is_absolute ():
3643 raise Exception (f"Must be run on a local Nix store. Current Nix store: { prefix } " )
3744
38- # Needs to be relative or otherwise join will ignore all the paths before it (WTF?)
39- normalised_path = os .path .normpath (path ).removeprefix ('/' )
40- if normalised_path == "." :
41- normalised_path = ""
42- return os .path .join (prefix , normalised_path )
45+ path = Path (path ).resolve ()
46+ remote_path = prefix .resolve ().joinpath (path .relative_to (f"{ path .drive } { path .root } " ))
47+
48+ return str (remote_path )
4349
4450class GitCheckoutInfoDict (TypedDict ):
4551 """Container for output from nix-prefetch-git"""
46- url : str
52+ url : str
4753 rev : str
4854 date : str
4955 path : str
You can’t perform that action at this time.
0 commit comments