generated from Luis/nextjs-python-web-template
In this directory we generate all the files that we need to load nixpkgs. This seems more robust than all those environment variables that may or not may be set.
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from .errors import ClanError
|
|
|
|
|
|
def get_clan_flake_toplevel() -> Path:
|
|
"""Returns the path to the toplevel of the clan flake"""
|
|
for project_file in [".clan-flake", ".git", ".hg", ".svn", "flake.nix"]:
|
|
initial_path = Path(os.getcwd())
|
|
path = Path(initial_path)
|
|
while path.parent != path:
|
|
if (path / project_file).exists():
|
|
return path
|
|
path = path.parent
|
|
raise ClanError("Could not find clan flake toplevel directory")
|
|
|
|
|
|
def user_config_dir() -> Path:
|
|
if sys.platform == "win32":
|
|
return Path(os.getenv("APPDATA", os.path.expanduser("~\\AppData\\Roaming\\")))
|
|
elif sys.platform == "darwin":
|
|
return Path(os.path.expanduser("~/Library/Application Support/"))
|
|
else:
|
|
return Path(os.getenv("XDG_CONFIG_HOME", os.path.expanduser("~/.config")))
|
|
|
|
|
|
def module_root() -> Path:
|
|
return Path(__file__).parent
|
|
|
|
|
|
def flake_registry() -> Path:
|
|
return module_root() / "nixpkgs" / "flake-registry.json"
|
|
|
|
|
|
def nixpkgs() -> Path:
|
|
return (module_root() / "nixpkgs" / "path").resolve()
|
|
|
|
|
|
def unfree_nixpkgs() -> Path:
|
|
return module_root() / "nixpkgs" / "unfree"
|