Skip to content

Instantly share code, notes, and snippets.

@sigma
Last active November 25, 2024 10:12
Show Gist options
  • Save sigma/f2544979dbb7f93a2b6f6cd7729d2751 to your computer and use it in GitHub Desktop.
Save sigma/f2544979dbb7f93a2b6f6cd7729d2751 to your computer and use it in GitHub Desktop.
#!/bin/sh
parted /dev/sda -- mklabel gpt
parted /dev/sda -- mkpart root ext4 512MB -8GB
parted /dev/sda -- mkpart swap linux-swap -8GB 100%
parted /dev/sda -- mkpart ESP fat32 1MB 512MB
parted /dev/sda -- set 3 esp on
mkfs.ext4 -L nixos /dev/sda1
mkswap -L swap /dev/sda2
mkfs.fat -F 32 -n boot /dev/sda3
mount /dev/disk/by-label/nixos /mnt
mkdir -p /mnt/boot
mount -o umask=077 /dev/disk/by-label/boot /mnt/boot
swapon /dev/disk/by-label/swap
nixos-generate-config --root /mnt
# Fixup devices: uuid -> label
sed -i '/fileSystems."\/"/{n;s:by-uuid/.*":by-label/nixos":}' /mnt/etc/nixos/hardware-configuration.nix
sed -i '/fileSystems."\/boot"/{n;s:by-uuid/.*":by-label/boot":}' /mnt/etc/nixos/hardware-configuration.nix
sed -i '/swapDevices/{n;s:by-uuid/.*":by-label/swap":}' /mnt/etc/nixos/hardware-configuration.nix
# Add config module
cat >> /mnt/etc/nixos/yann-config.nix <<EOL
{pkgs, ...}: {
networking.hostName = "devbox";
networking.networkmanager.enable = true;
time.timeZone = "Europe/Paris";
users.users.yann = {
isNormalUser = true;
extraGroups = [ "wheel" ];
packages = with pkgs; [
gitMinimal
];
};
environment.systemPackages = with pkgs; [
vim
zile
wget
];
services.openssh.enable = true;
virtualisation.vmware.guest = {
enable = true;
headless = true;
};
}
EOL
sed -i '/hardware-configuration.nix/i ./yann-config.nix' /mnt/etc/nixos/configuration.nix
nixos-install --root /mnt
nixos-enter --root /mnt -c 'passwd yann'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment