Check if nix profile's  manifest.json file exists
@@ -100,10 +100,15 @@ def check_package_version(p: AvailablePackage, current_url: str) -> str:
def reload_packages() -> None:
global packages, installed_packages
- packages = {}
- installed_packages = []
- with open(f'{os.getenv("HOME")}/.nix-profile/manifest.json') as manifest_file:
+
+ if os.path.exists(f'{os.getenv("HOME")}/.nix-profile/manifest.json'):
+ manifest_file = open(f'{os.getenv("HOME")}/.nix-profile/manifest.json')
manifest = json.loads(manifest_file.read())['elements']
+ manifest_file.close()
+ else:
+ manifest = []
+
+ packages = {}
available_packages_lookup = {p.package: (key, p) for key, p in available_packages.items()}
for idx, m in enumerate(manifest):
@@ -121,15 +126,13 @@ def reload_packages() -> None:
available_package.repo, available_package.package, status, version, immutable, idx
)
else:
- packages[name] = ConcretePackage(
- available_package.repo, available_package.package, LOCAL, index=idx
- )
+ packages[name] = ConcretePackage(available_package.repo, available_package.package, LOCAL, index=idx)
installed_packages = list(packages.keys())
- for p in available_packages:
- if p not in installed_packages:
- package = available_packages[p]
- packages[p] = ConcretePackage(package.repo, package.package, AVAILABLE, '')
+ for pkg_name in available_packages:
+ if pkg_name not in installed_packages:
+ available_package = available_packages[pkg_name]
+ packages[pkg_name] = ConcretePackage(available_package.repo, available_package.package, AVAILABLE, '')
class PackageVersion:
