From 6310fc12fb8a57ded0abc7ae433f1fdd2e7fe5ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sat, 7 Dec 2024 08:17:50 +0100 Subject: [PATCH 1/5] waypipe: only supported on Linux --- pkgs/clan-cli/clan_cli/vms/waypipe.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/clan-cli/clan_cli/vms/waypipe.py b/pkgs/clan-cli/clan_cli/vms/waypipe.py index 749e0dea9..c7b5216dc 100644 --- a/pkgs/clan-cli/clan_cli/vms/waypipe.py +++ b/pkgs/clan-cli/clan_cli/vms/waypipe.py @@ -1,4 +1,5 @@ import contextlib +import platform import socket import subprocess import time @@ -11,6 +12,9 @@ VMADDR_CID_HYPERVISOR = 2 def test_vsock_port(port: int) -> bool: + if platform.system() != "Linux": + msg = "vsock is only supported on Linux" + raise NotImplementedError(msg) try: s = socket.socket(socket.AF_VSOCK, socket.SOCK_STREAM) s.connect((VMADDR_CID_HYPERVISOR, port)) From bdd7eb2d89e4d339acbe3994a03c83ed6d13ffda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 10 Dec 2024 13:45:46 +0100 Subject: [PATCH 2/5] prettier: also format json --- formatter.nix | 7 +++++++ pkgs/editor/settings.json | 4 +--- pkgs/webview-ui/app/tsconfig.json | 2 +- sops/machines/test-backup/key.json | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/formatter.nix b/formatter.nix index 03d4bb333..6288b82fa 100644 --- a/formatter.nix +++ b/formatter.nix @@ -13,6 +13,8 @@ treefmt.programs.deadnix.enable = true; treefmt.settings.global.excludes = [ "*.png" + "*.svg" + "package-lock.json" "*.jpeg" "*.gitignore" ".vscode/*" @@ -24,6 +26,10 @@ "*.age" "*.list" "*.desktop" + # ignore symlink + "docs/site/manual/contribute.md" + "*_test_cert" + "*_test_key" ]; treefmt.programs.prettier = { enable = true; @@ -32,6 +38,7 @@ "*.css" "*.html" "*.js" + "*.json" "*.json5" "*.jsx" "*.mdx" diff --git a/pkgs/editor/settings.json b/pkgs/editor/settings.json index 0dbc48065..cbbfa69e0 100644 --- a/pkgs/editor/settings.json +++ b/pkgs/editor/settings.json @@ -10,9 +10,7 @@ }, "options": { "nixos": { - "expr": "(let pkgs = import { }; in (pkgs.lib.evalModules { modules - = (import ) ++ [ ({...}: { - nixpkgs.hostPlatform = builtins.currentSystem;} ) ] ; })).options" + "expr": "(let pkgs = import { }; in (pkgs.lib.evalModules { modules = (import ) ++ [ ({...}: { nixpkgs.hostPlatform = builtins.currentSystem;} ) ] ; })).options" }, "home-manager": { "expr": "(builtins.getFlake \"github:nix-community/home-manager\").homeConfigurations..options" diff --git a/pkgs/webview-ui/app/tsconfig.json b/pkgs/webview-ui/app/tsconfig.json index 46c1e53b2..98e05a906 100644 --- a/pkgs/webview-ui/app/tsconfig.json +++ b/pkgs/webview-ui/app/tsconfig.json @@ -8,7 +8,7 @@ "esModuleInterop": true, "jsx": "preserve", "jsxImportSource": "solid-js", - "types": [ "vite-plugin-solid-svg/types-component-solid", "vite/client" ], + "types": ["vite-plugin-solid-svg/types-component-solid", "vite/client"], "noEmit": true, "resolveJsonModule": true, "allowJs": true, diff --git a/sops/machines/test-backup/key.json b/sops/machines/test-backup/key.json index a58accffa..a4560aa94 100755 --- a/sops/machines/test-backup/key.json +++ b/sops/machines/test-backup/key.json @@ -1,4 +1,4 @@ { "publickey": "age1ez6xlcxl5k2uekcjvsu5wjca29f0j3lml0kq8fnvnkugvnj4pyjsyzuc93", "type": "age" -} \ No newline at end of file +} From dfd1aa9d15650bb3e9fa9bd48fee7526352920c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 11 Dec 2024 15:13:01 +0100 Subject: [PATCH 3/5] documentation to mkdocs locally --- docs/README.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docs/README.md diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 000000000..96e420169 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,5 @@ +# Serve documentation locally + +``` +$ nix develop .#docs -c mkdocs serve +``` From 64f537c22d2f134c649f57ecef6408f54576d778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 11 Dec 2024 15:13:14 +0100 Subject: [PATCH 4/5] add formatters for the rest --- formatter.nix | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/formatter.nix b/formatter.nix index 6288b82fa..c88a555fd 100644 --- a/formatter.nix +++ b/formatter.nix @@ -11,6 +11,7 @@ treefmt.programs.nixfmt.enable = true; treefmt.programs.nixfmt.package = pkgs.nixfmt-rfc-style; treefmt.programs.deadnix.enable = true; + treefmt.programs.clang-format.enable = true; treefmt.settings.global.excludes = [ "*.png" "*.svg" @@ -30,6 +31,40 @@ "docs/site/manual/contribute.md" "*_test_cert" "*_test_key" + "*/gnupg-home/*" + "*/sops/secrets/*" + "vars/*" + # prettier messes up our mkdocs flavoured markdown + "*.md" + + "checks/lib/ssh/privkey" + "checks/lib/ssh/pubkey" + "checks/matrix-synapse/synapse-registration_shared_secret" + "checks/mumble/machines/peer1/facts/mumble-cert" + "checks/mumble/machines/peer2/facts/mumble-cert" + "checks/secrets/clan-secrets" + "checks/secrets/sops/groups/group/machines/machine" + "checks/syncthing/introducer/introducer_device_id" + "checks/syncthing/introducer/introducer_test_api" + "docs/site/static/asciinema-player/asciinema-player.css" + "docs/site/static/asciinema-player/asciinema-player.min.js" + "nixosModules/clanCore/vars/secret/sops/eval-tests/populated/vars/my_machine/my_generator/my_secret" + "pkgs/clan-cli/tests/data/gnupg.conf" + "pkgs/clan-cli/tests/data/password-store/.gpg-id" + "pkgs/clan-cli/tests/data/ssh_host_ed25519_key" + "pkgs/clan-cli/tests/data/sshd_config" + "pkgs/clan-vm-manager/.vscode/lhebendanz.weaudit" + "pkgs/clan-vm-manager/bin/clan-vm-manager" + "pkgs/distro-packages/vagrant_insecure_key" + "sops/secrets/test-backup-age.key/secret" + ]; + treefmt.settings.formatter.ruff-format.includes = [ + "*/bin/clan" + "*/bin/clan-app" + "*/bin/clan-config" + ]; + treefmt.settings.formatter.shellcheck.includes = [ + "scripts/pre-commit" ]; treefmt.programs.prettier = { enable = true; From 7c76b52a8df45f1d4f3c053fa083649e0bb79fca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 11 Dec 2024 15:13:24 +0100 Subject: [PATCH 5/5] run clang-format --- pkgs/clan-cli/tests/getpwnam-preload.c | 8 +++---- pkgs/minifakeroot/main.c | 32 +++++++++++++------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/pkgs/clan-cli/tests/getpwnam-preload.c b/pkgs/clan-cli/tests/getpwnam-preload.c index 93f1f9e12..828007ed1 100644 --- a/pkgs/clan-cli/tests/getpwnam-preload.c +++ b/pkgs/clan-cli/tests/getpwnam-preload.c @@ -1,10 +1,10 @@ #define _GNU_SOURCE +#include +#include +#include +#include #include #include -#include -#include -#include -#include typedef struct passwd *(*getpwnam_type)(const char *name); diff --git a/pkgs/minifakeroot/main.c b/pkgs/minifakeroot/main.c index e2b34defc..2a1440651 100644 --- a/pkgs/minifakeroot/main.c +++ b/pkgs/minifakeroot/main.c @@ -6,27 +6,27 @@ typedef uint32_t uid_t; #ifdef __APPLE__ - struct dyld_interpose { - const void * replacement; - const void * replacee; - }; - #define WRAPPER(ret, name) static ret _fakeroot_wrapper_##name - #define WRAPPER_DEF(name) \ - __attribute__((used)) static struct dyld_interpose _fakeroot_interpose_##name \ - __attribute__((section("__DATA,__interpose"))) = { &_fakeroot_wrapper_##name, &name }; +struct dyld_interpose { + const void *replacement; + const void *replacee; +}; +#define WRAPPER(ret, name) static ret _fakeroot_wrapper_##name +#define WRAPPER_DEF(name) \ + __attribute__(( \ + used)) static struct dyld_interpose _fakeroot_interpose_##name \ + __attribute__((section("__DATA,__interpose"))) = { \ + &_fakeroot_wrapper_##name, &name}; #else - #define WRAPPER(ret, name) ret name - #define WRAPPER_DEF(name) +#define WRAPPER(ret, name) ret name +#define WRAPPER_DEF(name) #endif -WRAPPER(uid_t, geteuid)(const char * path, int flags, ...) -{ - return 0; // Fake root +WRAPPER(uid_t, geteuid)(const char *path, int flags, ...) { + return 0; // Fake root } WRAPPER_DEF(geteuid) -WRAPPER(uid_t, getuid)(const char * path, int flags, ...) -{ - return 0; // Fake root +WRAPPER(uid_t, getuid)(const char *path, int flags, ...) { + return 0; // Fake root } WRAPPER_DEF(getuid)