forked from cyberia/capsul-images
aynish-nixos #1
6 changed files with 73 additions and 56 deletions
|
@ -5,7 +5,7 @@ homedir="/home/$user"
|
||||||
|
|
||||||
mkdir -p "$homedir/.ssh"
|
mkdir -p "$homedir/.ssh"
|
||||||
chmod 700 "$homedir/.ssh"
|
chmod 700 "$homedir/.ssh"
|
||||||
chown "$user" "$homedir/.ssh"
|
chown -R "$user:$user" "$homedir"
|
||||||
|
|
||||||
mount -t iso9660 -o ro /dev/sr0 /mnt
|
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"
|
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
|
/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
|
umount /mnt
|
||||||
rm /root/capsul-init
|
rm /root/capsul-init
|
||||||
sudo nixos-rebuild switch
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
# this configuration is intended to give us ssh
|
||||||
|
# access to the build machine
|
||||||
|
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -5,10 +8,10 @@
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
# we always want git and vim
|
# we always want nano & vi
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
git
|
vi
|
||||||
vim
|
nano
|
||||||
];
|
];
|
||||||
|
|
||||||
boot.loader.grub.enable = true;
|
boot.loader.grub.enable = true;
|
||||||
|
@ -18,7 +21,6 @@
|
||||||
|
|
||||||
users.users.cyberian = {
|
users.users.cyberian = {
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
password = "password";
|
|
||||||
};
|
};
|
||||||
users.users.root.password = "password";
|
users.users.root.password = "password";
|
||||||
|
|
||||||
|
@ -27,16 +29,4 @@
|
||||||
permitRootLogin = "yes";
|
permitRootLogin = "yes";
|
||||||
passwordAuthentication = true;
|
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";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
43
nixos/22.05/final-configuration.nix
Normal file
43
nixos/22.05/final-configuration.nix
Normal 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" ];
|
||||||
|
};
|
||||||
|
}
|
|
@ -30,11 +30,11 @@
|
||||||
"inline": ["echo 'executing trigger-reboot...' && /tmp/trigger-reboot & exit 0"],
|
"inline": ["echo 'executing trigger-reboot...' && /tmp/trigger-reboot & exit 0"],
|
||||||
"expect_disconnect": true
|
"expect_disconnect": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"inline": ["echo 'reconnected after rebooting'"],
|
"inline": ["echo 'reconnected after rebooting'"],
|
||||||
"pause_before": "30s"
|
"pause_before": "30s"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"source": "capsul-init",
|
"source": "capsul-init",
|
||||||
|
@ -43,9 +43,22 @@
|
||||||
{
|
{
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"inline": [
|
"inline": [
|
||||||
"mv /tmp/capsul-init /root/capsul-init",
|
"mv /tmp/capsul-init /root/capsul-init",
|
||||||
"chmod +x /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": [
|
"builders": [
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#!/bin/sh
|
#!/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
|
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
|
mkfs.ext4 -L root /dev/vda2
|
||||||
mount LABEL=root /mnt
|
mount LABEL=root /mnt
|
||||||
|
|
1
nixos/OWNERS
Normal file
1
nixos/OWNERS
Normal file
|
@ -0,0 +1 @@
|
||||||
|
@aynish:sealight.xyz
|
Loading…
Reference in a new issue