From 97b6bce707d4195f9f9b275fd23777e26c7753bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 21 Jul 2024 15:26:37 +0200 Subject: [PATCH 1/5] remove deprecated adwaita-icon-theme --- pkgs/clan-vm-manager/default.nix | 38 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/pkgs/clan-vm-manager/default.nix b/pkgs/clan-vm-manager/default.nix index 2bf0a5012..6f9acc541 100644 --- a/pkgs/clan-vm-manager/default.nix +++ b/pkgs/clan-vm-manager/default.nix @@ -1,25 +1,25 @@ { - python3, - runCommand, - setuptools, - copyDesktopItems, - pygobject3, - wrapGAppsHook, - gtk4, - gnome, - pygobject-stubs, - gobject-introspection, + adwaita-icon-theme, clan-cli, - makeDesktopItem, + copyDesktopItems, + fontconfig, + gobject-introspection, + gtk4, libadwaita, - webkitgtk_6_0, + makeDesktopItem, + pygobject-stubs, + pygobject3, pytest, # Testing framework pytest-cov, # Generate coverage reports pytest-subprocess, # fake the real subprocess behavior to make your tests more independent. - pytest-xdist, # Run tests in parallel on multiple cores pytest-timeout, # Add timeouts to your tests + pytest-xdist, # Run tests in parallel on multiple cores + python3, + runCommand, + setuptools, + webkitgtk_6_0, webview-ui, - fontconfig, + wrapGAppsHook, }: let source = ./.; @@ -39,7 +39,7 @@ let gtk4 libadwaita webkitgtk_6_0 - gnome.adwaita-icon-theme + adwaita-icon-theme ]; # Deps including python packages from the local project @@ -112,8 +112,8 @@ python3.pkgs.buildPythonApplication rec { mkdir -p .home/.local/share/fonts export HOME=.home - fc-cache --verbose - # > fc-cache succeded + fc-cache --verbose + # > fc-cache succeded echo "Loaded the following fonts ..." fc-list @@ -160,8 +160,8 @@ python3.pkgs.buildPythonApplication rec { mkdir -p .home/.local/share/fonts export HOME=.home - fc-cache --verbose - # > fc-cache succeded + fc-cache --verbose + # > fc-cache succeded echo "Loaded the following fonts ..." fc-list From 59c5942d862d59a2045f1c872a421e5e6a3ac0ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 21 Jul 2024 15:27:31 +0200 Subject: [PATCH 2/5] drop binary cache from flake This generates warnings for users of the CLI and confuses them. In our CI systems we can just provide our binary cache. --- flake.nix | 5 ----- 1 file changed, 5 deletions(-) diff --git a/flake.nix b/flake.nix index 3b09a906f..545eac1a8 100644 --- a/flake.nix +++ b/flake.nix @@ -1,11 +1,6 @@ { description = "clan.lol base operating system"; - nixConfig.extra-substituters = [ "https://cache.clan.lol" ]; - nixConfig.extra-trusted-public-keys = [ - "cache.clan.lol-1:3KztgSAB5R1M+Dz7vzkBGzXdodizbgLXGXKXlcQLA28=" - ]; - inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small"; disko.url = "github:nix-community/disko"; From 5033421c522604bdd1d65f60a2ac896facd4f297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 21 Jul 2024 15:29:49 +0200 Subject: [PATCH 3/5] only set git author / email when no one is set globally --- pkgs/clan-cli/clan_cli/clan/create.py | 63 +++++++++++++++------------ 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/clan/create.py b/pkgs/clan-cli/clan_cli/clan/create.py index e282b5b69..a0c5814dd 100644 --- a/pkgs/clan-cli/clan_cli/clan/create.py +++ b/pkgs/clan-cli/clan_cli/clan/create.py @@ -18,9 +18,11 @@ minimal_template_url: str = "git+https://git.clan.lol/clan/clan-core#templates.m @dataclass class CreateClanResponse: - git_init: CmdOut + flake_init: CmdOut + git_init: CmdOut | None git_add: CmdOut - git_config: CmdOut + git_config_username: CmdOut | None + git_config_email: CmdOut | None flake_update: CmdOut @@ -34,6 +36,10 @@ class CreateOptions: template_url: str = minimal_template_url +def git_command(directory: Path, *args: str) -> list[str]: + return nix_shell(["nixpkgs#git"], ["git", "-C", str(directory), *args]) + + @API.register def create_clan(options: CreateOptions) -> CreateClanResponse: directory = Path(options.directory) @@ -52,7 +58,6 @@ def create_clan(options: CreateOptions) -> CreateClanResponse: description="Directory already exists and is not empty.", ) - cmd_responses = {} command = nix_command( [ "flake", @@ -61,27 +66,27 @@ def create_clan(options: CreateOptions) -> CreateClanResponse: template_url, ] ) - out = run(command, cwd=directory) + flake_init = run(command, cwd=directory) - ## Begin: setup git - command = nix_shell(["nixpkgs#git"], ["git", "init"]) - out = run(command, cwd=directory) - cmd_responses["git init"] = out + git_init = None + if not directory.joinpath(".git").exists(): + git_init = run(git_command(directory, "init")) + git_add = run(git_command(directory, "add", ".")) - command = nix_shell(["nixpkgs#git"], ["git", "add", "."]) - out = run(command, cwd=directory) - cmd_responses["git add"] = out + # check if username is set + has_username = run(git_command(directory, "config", "user.name"), check=False) + git_config_username = None + if has_username.returncode != 0: + git_config_username = run( + git_command(directory, "config", "user.name", "clan-tool") + ) - command = nix_shell(["nixpkgs#git"], ["git", "config", "user.name", "clan-tool"]) - out = run(command, cwd=directory) - cmd_responses["git config"] = out - - command = nix_shell( - ["nixpkgs#git"], ["git", "config", "user.email", "clan@example.com"] - ) - out = run(command, cwd=directory) - cmd_responses["git config"] = out - ## End: setup git + has_username = run(git_command(directory, "config", "user.email"), check=False) + git_config_email = None + if has_username.returncode != 0: + git_config_email = run( + git_command(directory, "config", "user.email", "clan@example.com") + ) # Write inventory.json file inventory = load_inventory(directory) @@ -90,15 +95,17 @@ def create_clan(options: CreateOptions) -> CreateClanResponse: # Persist creates a commit message for each change save_inventory(inventory, directory, "Init inventory") - command = ["nix", "flake", "update"] - out = run(command, cwd=directory) - cmd_responses["flake update"] = out + flake_update = run( + nix_shell(["nixpkgs#nix"], ["nix", "flake", "update"]), cwd=directory + ) response = CreateClanResponse( - git_init=cmd_responses["git init"], - git_add=cmd_responses["git add"], - git_config=cmd_responses["git config"], - flake_update=cmd_responses["flake update"], + flake_init=flake_init, + git_init=git_init, + git_add=git_add, + git_config_username=git_config_username, + git_config_email=git_config_email, + flake_update=flake_update, ) return response From 7ea26b1716655d655d26eb9b5c390341960c3744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 21 Jul 2024 15:53:22 +0200 Subject: [PATCH 4/5] flake/create: fix "directory does not exist" error --- pkgs/clan-cli/clan_cli/clan/create.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/clan-cli/clan_cli/clan/create.py b/pkgs/clan-cli/clan_cli/clan/create.py index a0c5814dd..75921131d 100644 --- a/pkgs/clan-cli/clan_cli/clan/create.py +++ b/pkgs/clan-cli/clan_cli/clan/create.py @@ -42,7 +42,7 @@ def git_command(directory: Path, *args: str) -> list[str]: @API.register def create_clan(options: CreateOptions) -> CreateClanResponse: - directory = Path(options.directory) + directory = Path(options.directory).resolve() template_url = options.template_url if not directory.exists(): directory.mkdir() From faf0528be2f5ff207aba2e6dd8c01b739f715398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 21 Jul 2024 16:39:01 +0200 Subject: [PATCH 5/5] improve lsblk instructions --- templates/flake-parts/flake.nix | 8 ++++++-- templates/new-clan/flake.nix | 10 +++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/templates/flake-parts/flake.nix b/templates/flake-parts/flake.nix index b093b1766..2e7685140 100644 --- a/templates/flake-parts/flake.nix +++ b/templates/flake-parts/flake.nix @@ -49,7 +49,9 @@ # This only works however if you have avahi running on your admin machine else use IP clan.core.networking.targetHost = pkgs.lib.mkDefault "root@jon"; - # ssh root@flash-installer.local lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT + # You can get your disk id by running the following command on the installer: + # Replace with the IP of the installer printed on the screen or by running the `ip addr` command. + # ssh root@ lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT disko.devices.disk.main = { device = "/dev/disk/by-id/__CHANGE_ME__"; }; @@ -80,7 +82,9 @@ # This only works however if you have avahi running on your admin machine else use IP clan.core.networking.targetHost = pkgs.lib.mkDefault "root@sara"; - # ssh root@flash-installer.local lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT + # You can get your disk id by running the following command on the installer: + # Replace with the IP of the installer printed on the screen or by running the `ip addr` command. + # ssh root@ lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT disko.devices.disk.main = { device = "/dev/disk/by-id/__CHANGE_ME__"; }; diff --git a/templates/new-clan/flake.nix b/templates/new-clan/flake.nix index 155166100..da1d598d9 100644 --- a/templates/new-clan/flake.nix +++ b/templates/new-clan/flake.nix @@ -11,7 +11,7 @@ # Usage see: https://docs.clan.lol clan = clan-core.lib.buildClan { directory = self; - meta.name = "__CHANGE_ME__"; # Ensure this is internet wide unique. + meta.name = "__CHANGE_ME__"; # Ensure this is unique among all clans you want to use. # Distributed services, uncomment to enable. # inventory = { @@ -45,7 +45,9 @@ # This only works however if you have avahi running on your admin machine else use IP clan.core.networking.targetHost = pkgs.lib.mkDefault "root@jon"; - # ssh root@flash-installer.local lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT + # You can get your disk id by running the following command on the installer: + # Replace with the IP of the installer printed on the screen or by running the `ip addr` command. + # ssh root@ lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT disko.devices.disk.main.device = "/dev/disk/by-id/__CHANGE_ME__"; # IMPORTANT! Add your SSH key here @@ -74,7 +76,9 @@ # This only works however if you have avahi running on your admin machine else use IP clan.core.networking.targetHost = pkgs.lib.mkDefault "root@sara"; - # ssh root@flash-installer.local lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT + # You can get your disk id by running the following command on the installer: + # Replace with the IP of the installer printed on the screen or by running the `ip addr` command. + # ssh root@ lsblk --output NAME,ID-LINK,FSTYPE,SIZE,MOUNTPOINT disko.devices.disk.main.device = "/dev/disk/by-id/__CHANGE_ME__"; # IMPORTANT! Add your SSH key here