cli: fix nixpkgs unfree import

This commit is contained in:
Jörg Thalheim
2023-09-06 17:29:49 +02:00
parent 35c5f248d1
commit 3bdd3af248
7 changed files with 34 additions and 24 deletions

View File

@@ -6,7 +6,7 @@ from typing import Optional
from fastapi import HTTPException
from clan_cli.dirs import get_clan_flake_toplevel, nixpkgs
from clan_cli.dirs import get_clan_flake_toplevel, nixpkgs_source
from clan_cli.machines.folders import machine_folder, machine_settings_file
from clan_cli.nix import nix_eval
@@ -54,7 +54,7 @@ def schema_for_machine(machine_name: str, flake: Optional[Path] = None) -> dict:
f"""
let
flake = builtins.getFlake (toString {flake});
lib = import {nixpkgs()}/lib;
lib = import {nixpkgs_source()}/lib;
options = flake.nixosConfigurations.{machine_name}.options;
clanOptions = options.clan;
jsonschemaLib = import {Path(__file__).parent / "jsonschema"} {{ inherit lib; }};

View File

@@ -1,4 +1,3 @@
import json
import os
import sys
from pathlib import Path
@@ -31,15 +30,12 @@ def module_root() -> Path:
return Path(__file__).parent
def deps_flake() -> Path:
return (module_root() / "deps_flake").resolve()
def nixpkgs_flake() -> Path:
return (module_root() / "nixpkgs").resolve()
def nixpkgs() -> Path:
# load the flake.lock json file from the deps_flake and return nodes.nixpkgs.path
with open(deps_flake() / "flake.lock") as f:
flake_lock = json.load(f)
return Path(flake_lock["nodes"]["nixpkgs"]["locked"]["path"])
def nixpkgs_source() -> Path:
return (module_root() / "nixpkgs" / "path").resolve()
def unfree_nixpkgs() -> Path:

View File

@@ -1,7 +1,7 @@
import os
import tempfile
from .dirs import deps_flake, nixpkgs, unfree_nixpkgs
from .dirs import nixpkgs_flake, nixpkgs_source, unfree_nixpkgs
def nix_eval(flags: list[str]) -> list[str]:
@@ -15,7 +15,7 @@ def nix_eval(flags: list[str]) -> list[str]:
"nix-command flakes",
"--override-input",
"nixpkgs",
str(nixpkgs()),
str(nixpkgs_source()),
# --store is required to prevent this error:
# error: cannot unlink '/nix/store/6xg259477c90a229xwmb53pdfkn6ig3g-default-builder.sh': Operation not permitted
"--store",
@@ -43,7 +43,7 @@ def nix_shell(packages: list[str], cmd: list[str]) -> list[str]:
"--extra-experimental-features",
"nix-command flakes",
"--inputs-from",
f"{str(deps_flake())}",
f"{str(nixpkgs_flake())}",
]
+ wrapped_packages
+ ["-c"]