2023-07-21 09:23:10 +00:00
|
|
|
{ lib
|
2023-07-21 09:14:54 +00:00
|
|
|
, pkgs
|
2023-07-28 14:37:10 +00:00
|
|
|
, modulesPath
|
2023-07-21 09:14:54 +00:00
|
|
|
, ...
|
2023-07-12 17:50:23 +00:00
|
|
|
}: {
|
2023-07-07 13:55:13 +00:00
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d /var/shared 0777 root root - -"
|
|
|
|
];
|
2023-07-28 14:37:10 +00:00
|
|
|
imports = [
|
|
|
|
(modulesPath + "/profiles/installation-device.nix")
|
|
|
|
(modulesPath + "/profiles/all-hardware.nix")
|
|
|
|
(modulesPath + "/profiles/base.nix")
|
|
|
|
];
|
2023-07-07 13:55:13 +00:00
|
|
|
services.openssh.settings.PermitRootLogin = "yes";
|
|
|
|
system.activationScripts.root-password = ''
|
2023-07-24 09:31:52 +00:00
|
|
|
mkdir -p /var/shared
|
2023-07-07 13:55:13 +00:00
|
|
|
${pkgs.pwgen}/bin/pwgen -s 16 1 > /var/shared/root-password
|
|
|
|
echo "root:$(cat /var/shared/root-password)" | chpasswd
|
|
|
|
'';
|
2023-07-24 10:09:11 +00:00
|
|
|
hidden-ssh-announce = {
|
2023-07-07 13:55:13 +00:00
|
|
|
enable = true;
|
|
|
|
script = pkgs.writers.writeDash "write-hostname" ''
|
2023-07-28 16:17:10 +00:00
|
|
|
set -efu
|
2023-07-24 09:31:52 +00:00
|
|
|
mkdir -p /var/shared
|
2023-07-07 13:55:13 +00:00
|
|
|
echo "$1" > /var/shared/onion-hostname
|
2023-07-24 10:09:11 +00:00
|
|
|
${pkgs.jq}/bin/jq -nc \
|
|
|
|
--arg password "$(cat /var/shared/root-password)" \
|
|
|
|
--arg address "$(cat /var/shared/onion-hostname)" '{
|
|
|
|
password: $password, address: $address
|
|
|
|
}' > /var/shared/login.info
|
|
|
|
cat /var/shared/login.info |
|
2023-07-28 16:12:48 +00:00
|
|
|
${pkgs.qrencode}/bin/qrencode -t utf8 -o /var/shared/qrcode.utf8
|
2023-07-24 10:09:11 +00:00
|
|
|
cat /var/shared/login.info |
|
2023-07-28 16:12:48 +00:00
|
|
|
${pkgs.qrencode}/bin/qrencode -t png -o /var/shared/qrcode.png
|
2023-07-07 13:55:13 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
services.getty.autologinUser = lib.mkForce "root";
|
|
|
|
programs.bash.interactiveShellInit = ''
|
|
|
|
if [ "$(tty)" = "/dev/tty1" ]; then
|
2023-07-28 16:17:21 +00:00
|
|
|
echo 'waiting for tor to generate the hidden service'
|
|
|
|
until test -e /var/shared/qrcode.utf8; do echo .; sleep 1; done
|
2023-07-24 10:09:11 +00:00
|
|
|
cat /var/shared/qrcode.utf8
|
2023-07-07 13:55:13 +00:00
|
|
|
fi
|
|
|
|
'';
|
2023-07-28 14:37:10 +00:00
|
|
|
boot.loader.grub.efiInstallAsRemovable = true;
|
|
|
|
boot.loader.grub.efiSupport = true;
|
|
|
|
disko.devices = {
|
|
|
|
disk = {
|
|
|
|
stick = {
|
|
|
|
type = "disk";
|
|
|
|
device = "/vda";
|
|
|
|
imageSize = "3G";
|
|
|
|
content = {
|
|
|
|
type = "gpt";
|
|
|
|
partitions = {
|
|
|
|
boot = {
|
|
|
|
size = "1M";
|
|
|
|
type = "EF02"; # for grub MBR
|
|
|
|
};
|
|
|
|
ESP = {
|
|
|
|
size = "100M";
|
|
|
|
type = "EF00";
|
|
|
|
content = {
|
|
|
|
type = "filesystem";
|
|
|
|
format = "vfat";
|
|
|
|
mountpoint = "/boot";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
root = {
|
|
|
|
size = "100%";
|
|
|
|
content = {
|
|
|
|
type = "filesystem";
|
|
|
|
format = "ext4";
|
|
|
|
mountpoint = "/";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-07-07 14:05:20 +00:00
|
|
|
};
|
2023-07-07 13:55:13 +00:00
|
|
|
}
|