aynish-nixos #1

Merged
aynish merged 11 commits from j3s/capsul-images:aynish-nixos into aynish-nixos 2022-07-18 04:27:42 +00:00
6 changed files with 73 additions and 56 deletions

View File

@ -5,7 +5,7 @@ homedir="/home/$user"
mkdir -p "$homedir/.ssh"
chmod 700 "$homedir/.ssh"
chown "$user" "$homedir/.ssh"
chown -R "$user:$user" "$homedir"
mount -t iso9660 -o ro /dev/sr0 /mnt
@ -13,38 +13,9 @@ grep '\- ssh' /mnt/user-data | cut -d ' ' -f 8- > "$homedir/.ssh/authorized_key
chmod 600 "$homedir/.ssh/authorized_keys"
chown "$user" "$homedir/.ssh/authorized_keys"
chown "$user:$user" "$homedir/.ssh/authorized_keys"
/run/current-system/profile/sbin/resize2fs /dev/vda2
cat <<EOF > /etc/configuration.nix
{ config, pkgs, ... }:
{
imports = [
./hardware-configuration.nix
];
# we always want git and vim
environment.systemPackages = with pkgs; [
git
vim
];
boot.loader.grub.enable = true;
boot.loader.grub.version = 2;
boot.loader.grub.device = "/dev/vda";
system.stateVersion = "22.05";
users.users.cyberian = {
isNormalUser = true;
};
services.openssh = {
enable = true;
};
EOF
umount /mnt
rm /root/capsul-init
sudo nixos-rebuild switch

View File

@ -1,3 +1,6 @@
# this configuration is intended to give us ssh
# access to the build machine
{ config, pkgs, ... }:
{
@ -5,10 +8,10 @@
./hardware-configuration.nix
];
# we always want git and vim
# we always want nano & vi
environment.systemPackages = with pkgs; [
git
vim
vi
nano
];
boot.loader.grub.enable = true;
@ -18,7 +21,6 @@
users.users.cyberian = {
isNormalUser = true;
password = "password";
};
users.users.root.password = "password";
@ -27,16 +29,4 @@
permitRootLogin = "yes";
passwordAuthentication = true;
};
# Feel free to remove this after first boot
# /root/capsul-init gets deleted after first run
systemd.services.capsul-init = {
serviceConfig.Type = "oneshot";
unitConfig = {
ConditionPathExists = "/root/capsul-init";
};
serviceConfig = {
ExecStart = "/root/capsul-init";
};
};
}

View File

@ -0,0 +1,43 @@
# this configuration is meant to be the final
# handed over to the user
{ config, pkgs, ... }:
{
imports = [
./hardware-configuration.nix
];
# we always want nano & vi
environment.systemPackages = with pkgs; [
nano
vi
];
boot.loader.grub.enable = true;
boot.loader.grub.version = 2;
boot.loader.grub.device = "/dev/vda";
system.stateVersion = "22.05";
users.users.cyberian = {
isNormalUser = true;
};
services.openssh = {
enable = true;
};
# Feel free to remove this after first boot
# /root/capsul-init gets deleted after first run
systemd.services.capsul-init = {
enable = true;
unitConfig = {
ConditionPathExists = "/root/capsul-init";
};
serviceConfig = {
Type = "oneshot";
ExecStart = "/root/capsul-init";
};
wantedBy = [ "multi-user.target" ];
};
}

View File

@ -30,11 +30,11 @@
"inline": ["echo 'executing trigger-reboot...' && /tmp/trigger-reboot & exit 0"],
"expect_disconnect": true
},
{
"type": "shell",
"inline": ["echo 'reconnected after rebooting'"],
"pause_before": "30s"
},
{
"type": "shell",
"inline": ["echo 'reconnected after rebooting'"],
"pause_before": "30s"
},
{
"type": "file",
"source": "capsul-init",
@ -43,9 +43,22 @@
{
"type": "shell",
"inline": [
"mv /tmp/capsul-init /root/capsul-init",
"chmod +x /root/capsul-init"
]
"mv /tmp/capsul-init /root/capsul-init",
"chmod +x /root/capsul-init"
]
},
{
"type": "file",
"source": "final-configuration.nix",
"destination": "/etc/nixos/configuration.nix"
},
{
"type": "shell",
"inline": [
"nixos-rebuild switch",
"rm -f /etc/ssh/*key*",
"printf '' > /etc/machine-id"
]
}
],
"builders": [

View File

@ -1,6 +1,5 @@
#!/bin/sh
sudo su
parted -s --align=none /dev/vda mktable gpt mkpart primary ext2 0 2MB mkpart primary ext2 2MB 100% set 1 bios_grub on
mkfs.ext4 -L root /dev/vda2
mount LABEL=root /mnt

1
nixos/OWNERS Normal file
View File

@ -0,0 +1 @@
@aynish:sealight.xyz