Compare commits

..

1 Commits

Author SHA1 Message Date
a-kenji
59e614987b clan: add examples and description to most help
Add examples and description to most toplevel help outputs.
2024-05-27 14:29:54 +02:00
27 changed files with 84 additions and 301 deletions

View File

@@ -1,4 +1,4 @@
# Contributing to Clan # Contributing to cLAN
## Live-reloading documentation ## Live-reloading documentation

View File

@@ -1,6 +1,6 @@
# Clan Core Repository # Clan Core Repository
Welcome to the Clan Core Repository, the heart of the [clan.lol](https://clan.lol/) project! This monorepo is the foundation of Clan, a revolutionary open-source project aimed at restoring fun, freedom, and functionality to computing. Here, you'll find all the essential packages, NixOS modules, CLI tools, and tests needed to contribute to and work with the Clan project. Clan leverages the Nix system to ensure reliability, security, and seamless management of digital environments, putting the power back into the hands of users. Welcome to the Clan Core Repository, the heart of the [clan.lol](https://clan.lol/) project! This monorepo is the foundation of Clan, a revolutionary open-source project aimed at restoring fun, freedom, and functionality to computing. Here, you'll find all the essential packages, NixOS modules, CLI tools, and tests needed to contribute to and work with the cLAN project. Clan leverages the Nix system to ensure reliability, security, and seamless management of digital environments, putting the power back into the hands of users.
## Why Clan? ## Why Clan?

View File

@@ -1,4 +1,4 @@
{ ... }: { inputs, ... }:
{ {
perSystem = perSystem =
{ {
@@ -9,6 +9,7 @@
}: }:
let let
writers = pkgs.callPackage ./pkgs/builders/script-writers.nix { }; writers = pkgs.callPackage ./pkgs/builders/script-writers.nix { };
inherit (pkgs.callPackage inputs.git-hooks { }) lib;
ansiEscapes = { ansiEscapes = {
reset = ''\033[0m''; reset = ''\033[0m'';
@@ -21,6 +22,11 @@
select-shell = writers.writePython3Bin "select-shell" { select-shell = writers.writePython3Bin "select-shell" {
flakeIgnore = [ "E501" ]; flakeIgnore = [ "E501" ];
} ./pkgs/scripts/select-shell.py; } ./pkgs/scripts/select-shell.py;
# run treefmt before each commit
install-pre-commit-hook =
with lib.git-hooks;
pre-commit (wrap.abort-on-change config.treefmt.build.wrapper);
in in
{ {
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
@@ -35,6 +41,8 @@
config.treefmt.build.wrapper config.treefmt.build.wrapper
]; ];
shellHook = '' shellHook = ''
${install-pre-commit-hook}
echo -e "${ansiEscapes.green}switch to another dev-shell using: select-shell${ansiEscapes.reset}" echo -e "${ansiEscapes.green}switch to another dev-shell using: select-shell${ansiEscapes.reset}"
''; '';
}; };

View File

@@ -20,11 +20,11 @@ There are several reasons for choosing to self-host. These can include:
Alice wants to self-host a mumble server for her family. Alice wants to self-host a mumble server for her family.
- She visits to the Clan website, and follows the instructions on how to install Clan-OS on her server. - She visits to the cLAN website, and follows the instructions on how to install cLAN-OS on her server.
- Alice logs into a terminal on her server via SSH (alternatively uses Clan GUI app) - Alice logs into a terminal on her server via SSH (alternatively uses cLAN GUI app)
- Using the Clan CLI or GUI tool, alice creates a new private network for her family (VPN) - Using the cLAN CLI or GUI tool, alice creates a new private network for her family (VPN)
- Alice now browses a list of curated Clan modules and finds a module for mumble. - Alice now browses a list of curated cLAN modules and finds a module for mumble.
- She adds this module to her network using the Clan tool. - She adds this module to her network using the cLAN tool.
- After that, she uses the clan tool to invite her family members to her network - After that, she uses the clan tool to invite her family members to her network
- Other family members join the private network via the invitation. - Other family members join the private network via the invitation.
- By accepting the invitation, other members automatically install all required software to interact with the network on their machine. - By accepting the invitation, other members automatically install all required software to interact with the network on their machine.
@@ -33,7 +33,7 @@ Alice wants to self-host a mumble server for her family.
Alice wants to add a photos app to her private network Alice wants to add a photos app to her private network
- She uses the clan CLI or GUI tool to manage her existing private Clan family network - She uses the clan CLI or GUI tool to manage her existing private cLAN family network
- She discovers a module for photoprism, and adds it to her server using the tool - She discovers a module for photoprism, and adds it to her server using the tool
- Other members who are already part of her network, will receive a notification that an update is required to their environment - Other members who are already part of her network, will receive a notification that an update is required to their environment
- After accepting, all new software and services to interact with the new photoprism service will be installed automatically. - After accepting, all new software and services to interact with the new photoprism service will be installed automatically.

View File

@@ -1,4 +1,4 @@
# Joining a Clan network # Joining a cLAN network
## General Description ## General Description
@@ -8,13 +8,13 @@ Joining a self-hosted infrastructure involves connecting to a network, server, o
### Story 1: Joining a private network ### Story 1: Joining a private network
Alice' son Bob has never heard of Clan, but receives an invitation URL from Alice who already set up private Clan network for her family. Alice' son Bob has never heard of cLAN, but receives an invitation URL from Alice who already set up private cLAN network for her family.
Bob opens the invitation link and lands on the Clan website. He quickly learns about what Clan is and can see that the invitation is for a private network of his family that hosts a number of services, like a private voice chat and a photo sharing platform. Bob opens the invitation link and lands on the cLAN website. He quickly learns about what cLAN is and can see that the invitation is for a private network of his family that hosts a number of services, like a private voice chat and a photo sharing platform.
Bob decides to join the network and follows the instructions to install the Clan tool on his computer. Bob decides to join the network and follows the instructions to install the cLAN tool on his computer.
Feeding the invitation link to the Clan tool, bob registers his machine with the network. Feeding the invitation link to the cLAN tool, bob registers his machine with the network.
All programs required to interact with the network will be installed and configured automatically and securely. All programs required to interact with the network will be installed and configured automatically and securely.
@@ -22,7 +22,7 @@ Optionally, bob can customize the configuration of these programs through a simp
### Story 2: Receiving breaking changes ### Story 2: Receiving breaking changes
The Clan family network which Bob is part of received an update. The cLAN family network which Bob is part of received an update.
The existing photo sharing service has been removed and replaced with another alternative service. The new photo sharing service requires a different client app to view and upload photos. The existing photo sharing service has been removed and replaced with another alternative service. The new photo sharing service requires a different client app to view and upload photos.
@@ -30,7 +30,7 @@ Bob accepts the update. Now his environment will be updated. The old client soft
Because Bob has customized the previous photo viewing app, he is notified that this customization is no longer valid, as the software has been removed (deprecation message).l Because Bob has customized the previous photo viewing app, he is notified that this customization is no longer valid, as the software has been removed (deprecation message).l
Optionally, Bob can now customize the new photo viewing software through his Clan configuration app or via a config file. Optionally, Bob can now customize the new photo viewing software through his cLAN configuration app or via a config file.
## Challenges ## Challenges

View File

@@ -1,10 +1,10 @@
# Clan module maintaining # cLAN module maintaining
## General Description ## General Description
Clan modules are pieces of software that can be used by admins to build a private or public infrastructure. cLAN modules are pieces of software that can be used by admins to build a private or public infrastructure.
Clan modules should have the following properties: cLAN modules should have the following properties:
1. Documented: It should be clear what the module does and how to use it. 1. Documented: It should be clear what the module does and how to use it.
1. Self contained: A module should be usable as is. If it requires any other software or settings, those should be delivered with the module itself. 1. Self contained: A module should be usable as is. If it requires any other software or settings, those should be delivered with the module itself.

View File

@@ -4,15 +4,10 @@ Clan enables encryption of secrets (such as passwords & keys) ensuring security
Clan utilizes the [sops](https://github.com/getsops/sops) format and integrates with [sops-nix](https://github.com/Mic92/sops-nix) on NixOS machines. Clan utilizes the [sops](https://github.com/getsops/sops) format and integrates with [sops-nix](https://github.com/Mic92/sops-nix) on NixOS machines.
This guide will walk you through:
- **Creating a Keypair for Your User**: Learn how to generate a keypair for $USER to securely control all secrets. ### Create Your Master Keypair
- **Creating Your First Secret**: Step-by-step instructions on creating your initial secret.
- **Assigning Machine Access to the Secret**: Understand how to grant a machine access to the newly created secret.
## Create Your Admin Keypair To get started, you'll need to create **Your master keypair**.
To get started, you'll need to create **Your admin keypair**.
!!! info !!! info
Don't worry — if you've already made one before, this step won't change or overwrite it. Don't worry — if you've already made one before, this step won't change or overwrite it.
@@ -32,7 +27,7 @@ Also add your age public key to the repository with 'clan secrets users add YOUR
!!! warning !!! warning
Make sure to keep a safe backup of the private key you've just created. Make sure to keep a safe backup of the private key you've just created.
If it's lost, you won't be able to get to your secrets anymore because they all need the admin key to be unlocked. If it's lost, you won't be able to get to your secrets anymore because they all need the master key to be unlocked.
!!! note !!! note
It's safe to add any secrets created by the clan CLI and placed in your repository to version control systems like `git`. It's safe to add any secrets created by the clan CLI and placed in your repository to version control systems like `git`.
@@ -40,7 +35,7 @@ Also add your age public key to the repository with 'clan secrets users add YOUR
### Add Your Public Key ### Add Your Public Key
```bash ```bash
clan secrets users add $USER <your_public_key> clan secrets users add <your_username> <your_public_key>
``` ```
It's best to choose the same username as on your Setup/Admin Machine that you use to control the deployment with. It's best to choose the same username as on your Setup/Admin Machine that you use to control the deployment with.
@@ -106,19 +101,16 @@ In your nixos configuration you can get a path to secrets like this `config.sops
### Assigning Access ### Assigning Access
When using `clan secrets set <secret>` without arguments, secrets are encrypted for the key of the user named like your current $USER. By default, secrets are encrypted for your key. To specify which users and machines can access a secret:
To add machines/users to an existing secret use:
```bash
clan secrets machines add-secret <machine_name> <secret_name>
```
Alternatively specify users and machines while creating a secret:
```bash ```bash
clan secrets set --machine <machine1> --machine <machine2> --user <user1> --user <user2> <secret_name> clan secrets set --machine <machine1> --machine <machine2> --user <user1> --user <user2> <secret_name>
``` ```
You can also just add machines/users to existing secrets:
```bash
clan secrets machines add-secret <machine_name> <secret_name>
```
## Advanced ## Advanced
@@ -191,9 +183,11 @@ Since our clan secret module will auto-import secrets that are encrypted for a p
you can now remove `sops.secrets.<secrets> = { };` unless you need to specify more options for the secret like owner/group of the secret file. you can now remove `sops.secrets.<secrets> = { };` unless you need to specify more options for the secret like owner/group of the secret file.
## Indepth Explanation ## Indepth Explanation
The secrets system conceptually knows two different entities: The secrets system conceptually knows two different entities:
- **Machine**: consumes secrets - **Machine**: consumes secrets

View File

@@ -1,25 +0,0 @@
#!/usr/bin/env bash
# nix eval \
# --json \
# --impure \
# --expr \
# "(let pkgs = import <nixpkgs> { }; in (pkgs.lib.evalModules { modules = (import <nixpkgs/nixos/modules/module-list.nix>) ++ [ ({...}: { nixpkgs.hostPlatform = builtins.currentSystem;} ) ] ; })).options"
# nix eval \
# --json \
# --impure \
# --expr \
# "(let pkgs = import <nixpkgs> { }; in (pkgs.lib.evalModules { modules = (import <nixpkgs/nixos/modules/module-list.nix>) ++ [(import <nixpkgs/nixos/modules/misc/assertions.nix>)] ++ [ (builtins.getFlake https://git.clan.lol/clan/clan-core/archive/main.tar.gz).clanModules (builtins.getFlake https://git.clan.lol/clan/clan-core/archive/main.tar.gz).nixosModules.clanCore ({...}: { nixpkgs.hostPlatform = builtins.currentSystem;} ) ] ; })).options"
# nix eval \
# --json \
# --impure \
# --expr \
# "(let pkgs = import <nixpkgs> { }; allNixosModules = (import <nixpkgs/nixos/modules/module-list.nix>) ++ [(import <nixpkgs/nixos/modules/misc/assertions.nix>) { nixpkgs.hostPlatform = \"x86_64-linux\"; }]; in (pkgs.lib.evalModules { modules = allNixosModules ++ [ (builtins.getFlake https://git.clan.lol/clan/clan-core/archive/main.tar.gz).clanModules (builtins.getFlake https://git.clan.lol/clan/clan-core/archive/main.tar.gz).nixosModules.clanCore ({...}: { nixpkgs.hostPlatform = builtins.currentSystem;} ) ] ; })).options"
#
#
nix eval \
--json \
--impure \
--file \
./options.nix

17
flake.lock generated
View File

@@ -40,6 +40,22 @@
"type": "github" "type": "github"
} }
}, },
"git-hooks": {
"flake": false,
"locked": {
"lastModified": 1716413087,
"narHash": "sha256-nSTIB7JeJGBGsvtqlyfhUByh/isyK1nfOq2YMxUOFJQ=",
"owner": "fricklerhandwerk",
"repo": "git-hooks",
"rev": "99a78fcf7dc03ba7b1d5c00af109c1e28ced3490",
"type": "github"
},
"original": {
"owner": "fricklerhandwerk",
"repo": "git-hooks",
"type": "github"
}
},
"nixlib": { "nixlib": {
"locked": { "locked": {
"lastModified": 1712450863, "lastModified": 1712450863,
@@ -133,6 +149,7 @@
"inputs": { "inputs": {
"disko": "disko", "disko": "disko",
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"git-hooks": "git-hooks",
"nixos-generators": "nixos-generators", "nixos-generators": "nixos-generators",
"nixos-images": "nixos-images", "nixos-images": "nixos-images",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",

View File

@@ -21,6 +21,8 @@
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs"; flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
treefmt-nix.url = "github:numtide/treefmt-nix"; treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs"; treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
git-hooks.url = "github:fricklerhandwerk/git-hooks";
git-hooks.flake = false;
}; };
outputs = outputs =

View File

@@ -1,17 +0,0 @@
let
flake = builtins.getFlake "https://git.clan.lol/clan/clan-core/archive/main.tar.gz";
nixpkgs = flake.inputs.nixpkgs;
pkgs = flake.inputs.nixpkgs.legacyPackages.${builtins.currentSystem};
clanCore = flake.outputs.nixosModules.clanCore;
clanModules = flake.outputs.clanModules;
allNixosModules = (import "${nixpkgs}/nixos/modules/module-list.nix") ++ [
"${nixpkgs}/nixos/modules/misc/assertions.nix"
{ nixpkgs.hostPlatform = "x86_64-linux"; }
];
clanCoreNixosModules = [
clanCore
{ clanCore.clanDir = ./.; }
] ++ allNixosModules ++ (builtins.attrValues clanModules);
clanCoreNixos = pkgs.nixos { imports = clanCoreNixosModules; };
in
clanCoreNixos.options

View File

@@ -54,7 +54,7 @@ class AppendOptionAction(argparse.Action):
def create_parser(prog: str | None = None) -> argparse.ArgumentParser: def create_parser(prog: str | None = None) -> argparse.ArgumentParser:
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
prog=prog, prog=prog,
description="The clan cli tool.", description="cLAN tool",
epilog=( epilog=(
""" """
Online reference for the clan cli tool: https://docs.clan.lol/reference/cli/ Online reference for the clan cli tool: https://docs.clan.lol/reference/cli/
@@ -126,7 +126,6 @@ For more detailed information, visit: https://docs.clan.lol/getting-started/back
parser_flake = subparsers.add_parser( parser_flake = subparsers.add_parser(
"flakes", "flakes",
help="create a clan flake inside the current directory", help="create a clan flake inside the current directory",
description="create a clan flake inside the current directory",
epilog=( epilog=(
""" """
Examples: Examples:
@@ -144,7 +143,6 @@ For more detailed information, visit: https://docs.clan.lol/getting-started
parser_config = subparsers.add_parser( parser_config = subparsers.add_parser(
"config", "config",
help="set nixos configuration", help="set nixos configuration",
description="set nixos configuration",
epilog=( epilog=(
""" """
""" """
@@ -153,32 +151,12 @@ For more detailed information, visit: https://docs.clan.lol/getting-started
) )
config.register_parser(parser_config) config.register_parser(parser_config)
parser_ssh = subparsers.add_parser( parser_ssh = subparsers.add_parser("ssh", help="ssh to a remote machine")
"ssh",
help="ssh to a remote machine",
description="ssh to a remote machine",
epilog=(
"""
This subcommand allows seamless ssh access to the nixos-image builders.
Examples:
$ clan ssh [ssh_args ...] --json [JSON]
Will ssh in to the machine based on the deployment information contained in
the json string. [JSON] can either be a json formatted string itself, or point
towards a file containing the deployment information
For more detailed information, visit: https://docs.clan.lol/getting-started/deploy
"""
),
formatter_class=argparse.RawTextHelpFormatter,
)
ssh_cli.register_parser(parser_ssh) ssh_cli.register_parser(parser_ssh)
parser_secrets = subparsers.add_parser( parser_secrets = subparsers.add_parser(
"secrets", "secrets",
help="manage secrets", help="manage secrets",
description="manage secrets",
epilog=( epilog=(
""" """
This subcommand provides an interface to secret facts. This subcommand provides an interface to secret facts.
@@ -202,7 +180,6 @@ For more detailed information, visit: https://docs.clan.lol/getting-started/secr
parser_facts = subparsers.add_parser( parser_facts = subparsers.add_parser(
"facts", "facts",
help="manage facts", help="manage facts",
description="manage facts",
epilog=( epilog=(
""" """
@@ -239,7 +216,6 @@ For more detailed information, visit: https://docs.clan.lol/getting-started/secr
parser_machine = subparsers.add_parser( parser_machine = subparsers.add_parser(
"machines", "machines",
help="manage machines and their configuration", help="manage machines and their configuration",
description="manage machines and their configuration",
epilog=( epilog=(
""" """
This subcommand provides an interface to machines managed by clan. This subcommand provides an interface to machines managed by clan.
@@ -263,22 +239,14 @@ For more detailed information, visit: https://docs.clan.lol/getting-started/depl
) )
machines.register_parser(parser_machine) machines.register_parser(parser_machine)
parser_vms = subparsers.add_parser( parser_vms = subparsers.add_parser("vms", help="manage virtual machines")
"vms", help="manage virtual machines", description="manage virtual machines"
)
vms.register_parser(parser_vms) vms.register_parser(parser_vms)
parser_history = subparsers.add_parser( parser_history = subparsers.add_parser("history", help="manage history")
"history",
help="manage history",
description="manage history",
)
history.register_parser(parser_history) history.register_parser(parser_history)
parser_flash = subparsers.add_parser( parser_flash = subparsers.add_parser(
"flash", "flash", help="flash machines to usb sticks or into isos"
help="flash machines to usb sticks or into isos",
description="flash machines to usb sticks or into isos",
) )
flash.register_parser(parser_flash) flash.register_parser(parser_flash)

View File

@@ -140,23 +140,3 @@ def run(
raise ClanCmdError(cmd_out) raise ClanCmdError(cmd_out)
return cmd_out return cmd_out
def run_no_stdout(
cmd: list[str],
*,
env: dict[str, str] | None = None,
cwd: Path = Path.cwd(),
log: Log = Log.STDERR,
check: bool = True,
error_msg: str | None = None,
) -> CmdOut:
"""
Like run, but automatically suppresses stdout, if not in DEBUG log level.
If in DEBUG log level the stdout of commands will be shown.
"""
if logging.getLogger(__name__.split(".")[0]).isEnabledFor(logging.DEBUG):
return run(cmd, env=env, log=log, check=check, error_msg=error_msg)
else:
log = Log.NONE
return run(cmd, env=env, log=log, check=check, error_msg=error_msg)

View File

@@ -53,7 +53,7 @@ def inspect_flake(flake_url: str | Path, machine_name: str) -> FlakeConfig:
gcroot_icon: Path = machine_gcroot(flake_url=str(flake_url)) / vm.machine_name gcroot_icon: Path = machine_gcroot(flake_url=str(flake_url)) / vm.machine_name
nix_add_to_gcroots(vm.machine_icon, gcroot_icon) nix_add_to_gcroots(vm.machine_icon, gcroot_icon)
# Get the Clan name # Get the cLAN name
cmd = nix_eval( cmd = nix_eval(
[ [
f'{flake_url}#clanInternals.machines."{system}"."{machine_name}".config.clanCore.clanName' f'{flake_url}#clanInternals.machines."{system}"."{machine_name}".config.clanCore.clanName'
@@ -70,7 +70,7 @@ def inspect_flake(flake_url: str | Path, machine_name: str) -> FlakeConfig:
) )
res = run_cmd(cmd) res = run_cmd(cmd)
# If the icon is null, no icon is set for this Clan # If the icon is null, no icon is set for this cLAN
if res == "null": if res == "null":
icon_path = None icon_path = None
else: else:
@@ -113,7 +113,7 @@ def inspect_command(args: argparse.Namespace) -> None:
res = inspect_flake( res = inspect_flake(
flake_url=inspect_options.flake, machine_name=inspect_options.machine flake_url=inspect_options.flake, machine_name=inspect_options.machine
) )
print("Clan name:", res.clan_name) print("cLAN name:", res.clan_name)
print("Icon:", res.icon) print("Icon:", res.icon)
print("Description:", res.description) print("Description:", res.description)
print("Last updated:", res.last_updated) print("Last updated:", res.last_updated)

View File

@@ -17,26 +17,7 @@ def register_parser(parser: argparse.ArgumentParser) -> None:
required=True, required=True,
) )
update_parser = subparser.add_parser( update_parser = subparser.add_parser("update", help="Update a machine")
"update",
help="Update a machine",
epilog=(
"""
This subcommand provides an interface to update machines managed by clan.
Examples:
$ clan machines update [MACHINES]
Will update the specified machine [MACHINE], if [MACHINE] is omitted, the command
will attempt to update every configured machine.
To exclude machines being updated `clan.deployment.requireExplicitUpdate = true;`
can be set in the machine config.
For more detailed information, visit: https://docs.clan.lol/getting-started/deploy
"""
),
formatter_class=argparse.RawTextHelpFormatter,
)
register_update_parser(update_parser) register_update_parser(update_parser)
create_parser = subparser.add_parser("create", help="Create a machine") create_parser = subparser.add_parser("create", help="Create a machine")
@@ -45,21 +26,7 @@ For more detailed information, visit: https://docs.clan.lol/getting-started/depl
delete_parser = subparser.add_parser("delete", help="Delete a machine") delete_parser = subparser.add_parser("delete", help="Delete a machine")
register_delete_parser(delete_parser) register_delete_parser(delete_parser)
list_parser = subparser.add_parser( list_parser = subparser.add_parser("list", help="List machines")
"list",
help="List machines",
epilog=(
"""
This subcommand lists all machines managed by this clan.
Examples:
$ clan machines list
Lists all the machines and their descriptions.
"""
),
formatter_class=argparse.RawTextHelpFormatter,
)
register_list_parser(list_parser) register_list_parser(list_parser)
install_parser = subparser.add_parser( install_parser = subparser.add_parser(
@@ -70,23 +37,5 @@ Examples:
The target must be a Linux based system reachable via SSH. The target must be a Linux based system reachable via SSH.
Installing a machine means overwriting the target's disk. Installing a machine means overwriting the target's disk.
""", """,
epilog=(
"""
This subcommand provides an interface to install machines managed by clan.
Examples:
$ clan machines install [MACHINE] [TARGET_HOST]
Will install the specified machine [MACHINE], to the specified [TARGET_HOST].
$ clan machines install [MACHINE] --json [JSON]
Will install the specified machine [MACHINE] to the host exposed by
the deployment information of the [JSON] deployment string.
For information on how to set up the installer see: https://docs.clan.lol/getting-started/installer/
For more detailed information, visit: https://docs.clan.lol/getting-started/deploy
"""
),
formatter_class=argparse.RawTextHelpFormatter,
) )
register_install_parser(install_parser) register_install_parser(install_parser)

View File

@@ -6,7 +6,7 @@ from pathlib import Path
from clan_cli.api import API from clan_cli.api import API
from ..cmd import run_no_stdout from ..cmd import Log, run
from ..nix import nix_config, nix_eval from ..nix import nix_config, nix_eval
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@@ -34,7 +34,10 @@ def list_machines(flake_url: str | Path, debug: bool) -> dict[str, MachineInfo]:
] ]
) )
proc = run_no_stdout(cmd) if not debug:
proc = run(cmd, log=Log.NONE)
else:
proc = run(cmd)
res = proc.stdout.strip() res = proc.stdout.strip()
machines_dict = json.loads(res) machines_dict = json.loads(res)

View File

@@ -10,7 +10,7 @@ from clan_cli.clan_uri import ClanURI, MachineData
from clan_cli.dirs import vm_state_dir from clan_cli.dirs import vm_state_dir
from clan_cli.qemu.qmp import QEMUMonitorProtocol from clan_cli.qemu.qmp import QEMUMonitorProtocol
from ..cmd import run_no_stdout from ..cmd import run
from ..errors import ClanError from ..errors import ClanError
from ..nix import nix_build, nix_config, nix_eval, nix_metadata from ..nix import nix_build, nix_config, nix_eval, nix_metadata
from ..ssh import Host, parse_deployment_address from ..ssh import Host, parse_deployment_address
@@ -197,7 +197,7 @@ class Machine:
config_json.flush() config_json.flush()
file_info = json.loads( file_info = json.loads(
run_no_stdout( run(
nix_eval( nix_eval(
[ [
"--impure", "--impure",
@@ -247,10 +247,10 @@ class Machine:
] ]
if method == "eval": if method == "eval":
output = run_no_stdout(nix_eval(args)).stdout.strip() output = run(nix_eval(args)).stdout.strip()
return output return output
elif method == "build": elif method == "build":
outpath = run_no_stdout(nix_build(args)).stdout.strip() outpath = run(nix_build(args)).stdout.strip()
return Path(outpath) return Path(outpath)
else: else:
raise ValueError(f"Unknown method {method}") raise ValueError(f"Unknown method {method}")

View File

@@ -106,7 +106,7 @@ def nix_shell(packages: list[str], cmd: list[str]) -> list[str]:
if os.environ.get("IN_NIX_SANDBOX"): if os.environ.get("IN_NIX_SANDBOX"):
return cmd return cmd
return [ return [
*nix_command(["shell", "--inputs-from", f"{nixpkgs_flake()!s}"]), *nix_command(["shell", "--offline", "--inputs-from", f"{nixpkgs_flake()!s}"]),
*packages, *packages,
"-c", "-c",
*cmd, *cmd,

View File

@@ -83,7 +83,7 @@ let
cp -r ${./.} $out cp -r ${./.} $out
chmod -R +w $out chmod -R +w $out
rm $out/clan_cli/config/jsonschema rm $out/clan_cli/config/jsonschema
ln -sf ${nixpkgs'} $out/clan_cli/nixpkgs ln -s ${nixpkgs'} $out/clan_cli/nixpkgs
cp -r ${../../lib/jsonschema} $out/clan_cli/config/jsonschema cp -r ${../../lib/jsonschema} $out/clan_cli/config/jsonschema
''; '';
@@ -101,7 +101,7 @@ let
outputs = _inputs: { }; outputs = _inputs: { };
} }
EOF EOF
ln -sf ${nixpkgs} $out/path ln -s ${nixpkgs} $out/path
nix flake update $out \ nix flake update $out \
--store ./. \ --store ./. \
--extra-experimental-features 'nix-command flakes' --extra-experimental-features 'nix-command flakes'

View File

@@ -26,7 +26,7 @@ log = logging.getLogger(__name__)
class MainWindow(Adw.ApplicationWindow): class MainWindow(Adw.ApplicationWindow):
def __init__(self, config: ClanConfig) -> None: def __init__(self, config: ClanConfig) -> None:
super().__init__() super().__init__()
self.set_title("Clan Manager") self.set_title("cLAN Manager")
self.set_default_size(980, 850) self.set_default_size(980, 850)
overlay = ToastOverlay.use().overlay overlay = ToastOverlay.use().overlay

View File

@@ -27,7 +27,7 @@ let
name = "org.clan.vm-manager"; name = "org.clan.vm-manager";
exec = "clan-vm-manager %u"; exec = "clan-vm-manager %u";
icon = ./clan_vm_manager/assets/clan_white.png; icon = ./clan_vm_manager/assets/clan_white.png;
desktopName = "Clan Manager"; desktopName = "cLAN Manager";
startupWMClass = "clan"; startupWMClass = "clan";
mimeTypes = [ "x-scheme-handler/clan" ]; mimeTypes = [ "x-scheme-handler/clan" ];
}; };

View File

@@ -1,40 +0,0 @@
{
lib,
coreutils,
nil,
nixd,
nixpkgs-fmt,
direnv,
vscode-extensions,
vscode-with-extensions,
vscodium,
writeShellApplication,
}:
let
codium = vscode-with-extensions.override {
vscode = vscodium;
vscodeExtensions = [
vscode-extensions.jnoortheen.nix-ide
vscode-extensions.mkhl.direnv
];
};
in
writeShellApplication {
name = "clan-edit-codium";
runtimeInputs = [
coreutils
nil
nixd
nixpkgs-fmt
direnv
];
text = ''
set -eux
DATA_DIR="''${XDG_CACHE_HOME:-$HOME/.cache}/clan-edit-codium"
SETTINGS="$DATA_DIR"/User/settings.json
${coreutils}/bin/mkdir -p "$DATA_DIR/User"
cat ${./settings.json} > "$SETTINGS"
exec ${lib.getExe codium} --user-data-dir "$DATA_DIR" "$@"
'';
}

View File

@@ -1,4 +0,0 @@
{ pkgs }:
{
clan-edit-codium = pkgs.callPackage ./clan-edit-codium.nix;
}

View File

@@ -1,23 +0,0 @@
{
"security.workspace.trust.enabled": false,
"nix.enableLanguageServer": true,
"nix.serverPath": "nixd",
"nix.formatterPath": "nixpkgs-fmt",
"nix.serverSettings": {
"nixd": {
"formatting": {
"command": "nixpkgs-fmt"
},
"options": {
"nixos": {
"expr": "(let pkgs = import <nixpkgs> { }; in (pkgs.lib.evalModules { modules
= (import <nixpkgs/nixos/modules/module-list.nix>) ++ [ ({...}: {
nixpkgs.hostPlatform = builtins.currentSystem;} ) ] ; })).options"
},
"home-manager": {
"expr": "(builtins.getFlake \"github:nix-community/home-manager\").homeConfigurations.<name>.options"
}
}
}
}
}

View File

@@ -25,7 +25,6 @@
moonlight-sunshine-accept = pkgs.callPackage ./moonlight-sunshine-accept { }; moonlight-sunshine-accept = pkgs.callPackage ./moonlight-sunshine-accept { };
merge-after-ci = pkgs.callPackage ./merge-after-ci { inherit (config.packages) tea-create-pr; }; merge-after-ci = pkgs.callPackage ./merge-after-ci { inherit (config.packages) tea-create-pr; };
pending-reviews = pkgs.callPackage ./pending-reviews { }; pending-reviews = pkgs.callPackage ./pending-reviews { };
editor = pkgs.callPackage ./editor/clan-edit-codium.nix { };
} }
// lib.optionalAttrs pkgs.stdenv.isLinux { // lib.optionalAttrs pkgs.stdenv.isLinux {
wayland-proxy-virtwl = pkgs.callPackage ./wayland-proxy-virtwl { }; wayland-proxy-virtwl = pkgs.callPackage ./wayland-proxy-virtwl { };

View File

@@ -1,28 +0,0 @@
#!/usr/bin/env bash
# To install:
# ln -sf ../../scripts/pre-commit .git/hooks/pre-commit
set -o errexit
set -o nounset
set -o pipefail
readarray staged < <(git diff --name-only --cached)
[[ ${#staged[@]} = 0 ]] && exit
unstash() {
local ret=$?
set +e
git stash pop -q
exit "$ret"
}
git stash push --quiet --keep-index --message "pre-commit"
trap unstash EXIT
nix fmt
{
changed=$(git diff --name-only --exit-code);
status=$?;
} || true
if [[ $status -ne 0 ]]; then
exec 1>&2
echo Files changed by pre-commit hook:
echo "$changed"
exit $status
fi

View File

@@ -85,9 +85,9 @@
}; };
in in
{ {
# all machines managed by Clan # all machines managed by cLAN
inherit (clan) nixosConfigurations clanInternals; inherit (clan) nixosConfigurations clanInternals;
# add the Clan cli tool to the dev shell # add the cLAN cli tool to the dev shell
devShells.${system}.default = pkgs.mkShell { devShells.${system}.default = pkgs.mkShell {
packages = [ clan-core.packages.${system}.clan-cli ]; packages = [ clan-core.packages.${system}.clan-cli ];
}; };