create /mnt for nixos build #5

Closed
aynish wants to merge 10 commits from aynish/capsul-images:aynish-nixos into main
5 changed files with 31 additions and 20 deletions

View file

@ -5,7 +5,10 @@ homedir="/home/$user"
mkdir -p "$homedir/.ssh"
chmod 700 "$homedir/.ssh"
chown -R "$user:$user" "$homedir"
chown -R "$user" "$homedir"
mkdir "/mnt"
chmod -R 755 "/mnt"
mount -t iso9660 -o ro /dev/sr0 /mnt
@ -13,9 +16,15 @@ grep '\- ssh' /mnt/user-data | cut -d ' ' -f 8- > "$homedir/.ssh/authorized_key
chmod 600 "$homedir/.ssh/authorized_keys"
chown "$user:$user" "$homedir/.ssh/authorized_keys"
chown "$user" "$homedir/.ssh/authorized_keys"
/run/current-system/profile/sbin/resize2fs /dev/vda2
# set random forgotten password for cyberian and root
pass="\$(head /dev/urandom | tr -dc a-z0-9 | head -c30)"
echo "cyberian:\$pass" | chpasswd
pass="\$(head /dev/urandom | tr -dc a-z0-9 | head -c30)"
echo "root:\$pass" | chpasswd
resize2fs /dev/vda2
umount /mnt
rm /root/capsul-init

View file

@ -8,9 +8,9 @@
./hardware-configuration.nix
];
# we always want nano & vi
# we always want nano & vim
environment.systemPackages = with pkgs; [
vi
vim
nano
];

View file

@ -11,7 +11,7 @@
# we always want nano & vi
environment.systemPackages = with pkgs; [
nano
vi
vim
];
boot.loader.grub.enable = true;
@ -21,16 +21,20 @@
users.users.cyberian = {
isNormalUser = true;
extraGroups = [ "wheel" ];
};
security.sudo.wheelNeedsPassword = false; # We throw away the password but we still want root
services.openssh = {
enable = true;
passwordAuthentication = false;
};
# Feel free to remove this after first boot
# /root/capsul-init gets deleted after first run
systemd.services.capsul-init = {
enable = true;
path = [ pkgs.coreutils pkgs.e2fsprogs pkgs.shadow pkgs.mount pkgs.umount ];
unitConfig = {
ConditionPathExists = "/root/capsul-init";
};

View file

@ -35,18 +35,6 @@
"inline": ["echo 'reconnected after rebooting'"],
"pause_before": "30s"
},
{
"type": "file",
"source": "capsul-init",
"destination": "/tmp/capsul-init"
},
{
"type": "shell",
"inline": [
"mv /tmp/capsul-init /root/capsul-init",
"chmod +x /root/capsul-init"
]
},
{
"type": "file",
"source": "final-configuration.nix",
@ -59,6 +47,18 @@
"rm -f /etc/ssh/*key*",
"printf '' > /etc/machine-id"
]
},
{
"type": "file",
"source": "capsul-init",
"destination": "/tmp/capsul-init"
},
{
"type": "shell",
"inline": [
"mv /tmp/capsul-init /root/capsul-init",
"chmod +x /root/capsul-init"
]
}
],
"builders": [

View file

@ -1,2 +0,0 @@
- test that the systemd module works as intended
- `nixos-delete-generations`