From 44cbc96e0d0dd03ffc78fbba1b50d6acfc8c8574 Mon Sep 17 00:00:00 2001 From: kalipso Date: Tue, 3 Nov 2026 18:16:06 +0100 Subject: [PATCH] [scripts] init malobeo ssh commands they are not yet working, its just placeholders --- outputs.nix | 23 +++++++++++++++++------ packages/ssh_to_hosts.nix | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 packages/ssh_to_hosts.nix diff --git a/outputs.nix b/outputs.nix index 65aa9fe..2a3075b 100644 --- a/outputs.nix +++ b/outputs.nix @@ -47,12 +47,18 @@ in (utils.lib.eachSystem (builtins.filter filter_system utils.lib.defaultSystems shellHook = ''echo "Available scripts: ${builtins.concatStringsSep " " installed}"''; }; - legacyPackages = { - scripts.remote-install = pkgs.writeShellScriptBin "remote-install" (builtins.readFile ./scripts/remote-install-encrypt.sh); - scripts.boot-unlock = pkgs.writeShellScriptBin "boot-unlock" (builtins.readFile ./scripts/unlock-boot.sh); - scripts.add-host-keys = pkgs.writeShellScriptBin "add-host-keys" (builtins.readFile ./scripts/add_new_host_keys.sh); - scripts.run-vm = self.packages.${system}.run-vm; - }; + legacyPackages.scripts = { + malobeo-remote-install = pkgs.writeShellScriptBin "malobeo-remote-install" (builtins.readFile ./scripts/remote-install-encrypt.sh); + malobeo-boot-unlock = pkgs.writeShellScriptBin "malobeo-boot-unlock" (builtins.readFile ./scripts/unlock-boot.sh); + malobeo-add-host-keys = pkgs.writeShellScriptBin "malobeo-add-host-keys" (builtins.readFile ./scripts/add_new_host_keys.sh); + malobeo-run-vm = self.packages.${system}.run-vm; + } // (import ./packages/ssh_to_hosts.nix) { + malobeo = (import ./machines/hosts.nix {}).malobeo; + peers = import ./machines/modules/malobeo/peers.nix; + pkgs = pkgs; + lib = nixpkgs.lib; + }; + vmBuilder = utils.buildVM; @@ -75,6 +81,11 @@ in (utils.lib.eachSystem (builtins.filter filter_system utils.lib.defaultSystems }; run-vm = pkgs.writeShellScriptBin "run-vm" (builtins.readFile ./scripts/run-vm.sh); + } // (import ./packages/ssh_to_hosts.nix) { + malobeo = (import ./machines/hosts.nix {}).malobeo; + peers = import ./machines/modules/malobeo/peers.nix; + pkgs = pkgs; + lib = nixpkgs.lib; }; apps = { diff --git a/packages/ssh_to_hosts.nix b/packages/ssh_to_hosts.nix new file mode 100644 index 0000000..fc04b78 --- /dev/null +++ b/packages/ssh_to_hosts.nix @@ -0,0 +1,35 @@ +{ malobeo, peers, pkgs, lib, ... }: +#mapAttrs' (name: value: nameValuePair ("foo_" + name) ("bar-" + value)) +let + get_ip = hostname: malobeo.hosts.${hostname}.network.address; + generate_ssh_command = hostname: hostConfig: ( + if hostConfig.network.local == true then + if hostname == "fanny" then + "ssh admin@${malobeo.hosts."fanny".network.address}" + else + "ssh -J admin@${malobeo.hosts."fanny".network.address} admin@${get_ip hostname}" + else + "offsite" + ); +in +(lib.attrsets.mapAttrs' (hostname: hostConfig: lib.nameValuePair + ("malobeo-ssh-${hostname}") + (pkgs.writeShellScriptBin "malobeo-ssh-${hostname}" + '' + #!/bin/sh + echo "${hostname} ${generate_ssh_command hostname hostConfig}" + '')) malobeo.hosts ) +#{ +# test-pkg = pkgs.writeShellScriptBin "run-vm" (builtins.readFile ../scripts/run-vm.sh); +#} + + +# microvm +# - local: +# - yes: ssh through fanny +# - no: if in peers.nix -> ssh through vpn, else not possible +# not microvm: +# - local: +# - yes: ssh through fanny (except for fanny) +# - no: not supported + -- 2.54.0