clan config: fix settings file location
This commit is contained in:
@@ -9,6 +9,7 @@ from typing import Any, Optional, Type
|
|||||||
|
|
||||||
from clan_cli.dirs import get_clan_flake_toplevel
|
from clan_cli.dirs import get_clan_flake_toplevel
|
||||||
from clan_cli.errors import ClanError
|
from clan_cli.errors import ClanError
|
||||||
|
from clan_cli.machines.folders import machine_settings_file
|
||||||
from clan_cli.nix import nix_eval
|
from clan_cli.nix import nix_eval
|
||||||
|
|
||||||
script_dir = Path(__file__).parent
|
script_dir = Path(__file__).parent
|
||||||
@@ -166,7 +167,6 @@ def get_or_set_option(args: argparse.Namespace) -> None:
|
|||||||
print(read_machine_option_value(args.machine, args.option))
|
print(read_machine_option_value(args.machine, args.option))
|
||||||
else:
|
else:
|
||||||
# load options
|
# load options
|
||||||
print(args.options_file)
|
|
||||||
if args.options_file is None:
|
if args.options_file is None:
|
||||||
options = options_for_machine(machine_name=args.machine)
|
options = options_for_machine(machine_name=args.machine)
|
||||||
else:
|
else:
|
||||||
@@ -174,8 +174,8 @@ def get_or_set_option(args: argparse.Namespace) -> None:
|
|||||||
options = json.load(f)
|
options = json.load(f)
|
||||||
# compute settings json file location
|
# compute settings json file location
|
||||||
if args.settings_file is None:
|
if args.settings_file is None:
|
||||||
flake = get_clan_flake_toplevel()
|
get_clan_flake_toplevel()
|
||||||
settings_file = flake / "machines" / f"{args.machine}.json"
|
settings_file = machine_settings_file(args.machine)
|
||||||
else:
|
else:
|
||||||
settings_file = args.settings_file
|
settings_file = args.settings_file
|
||||||
# set the option with the given value
|
# set the option with the given value
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ from clan_cli.nix import nix_eval
|
|||||||
|
|
||||||
|
|
||||||
def config_for_machine(machine_name: str) -> dict:
|
def config_for_machine(machine_name: str) -> dict:
|
||||||
# read the config from a json file located at {flake}/machines/{machine_name}.json
|
# read the config from a json file located at {flake}/machines/{machine_name}/settings.json
|
||||||
if not machine_folder(machine_name).exists():
|
if not machine_folder(machine_name).exists():
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=404,
|
status_code=404,
|
||||||
@@ -26,7 +26,7 @@ def config_for_machine(machine_name: str) -> dict:
|
|||||||
|
|
||||||
|
|
||||||
def set_config_for_machine(machine_name: str, config: dict) -> None:
|
def set_config_for_machine(machine_name: str, config: dict) -> None:
|
||||||
# write the config to a json file located at {flake}/machines/{machine_name}.json
|
# write the config to a json file located at {flake}/machines/{machine_name}/settings.json
|
||||||
if not machine_folder(machine_name).exists():
|
if not machine_folder(machine_name).exists():
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=404,
|
status_code=404,
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
nixosConfigurations.machine1 = inputs.nixpkgs.lib.nixosSystem {
|
nixosConfigurations.machine1 = inputs.nixpkgs.lib.nixosSystem {
|
||||||
modules = [
|
modules = [
|
||||||
./nixosModules/machine1.nix
|
./nixosModules/machine1.nix
|
||||||
(if builtins.pathExists ./machines/machine1.json
|
(if builtins.pathExists ./machines/machine1/settings.json
|
||||||
then builtins.fromJSON (builtins.readFile ./machines/machine1.json)
|
then builtins.fromJSON (builtins.readFile ./machines/machine1/settings.json)
|
||||||
else { })
|
else { })
|
||||||
{
|
{
|
||||||
nixpkgs.hostPlatform = "x86_64-linux";
|
nixpkgs.hostPlatform = "x86_64-linux";
|
||||||
|
|||||||
Reference in New Issue
Block a user