Skip to content

Instantly share code, notes, and snippets.

@elseym
Last active April 10, 2021 19:16
Show Gist options
  • Save elseym/23c3448328cc1efec97738b1e24a29c1 to your computer and use it in GitHub Desktop.
Save elseym/23c3448328cc1efec97738b1e24a29c1 to your computer and use it in GitHub Desktop.
nixos.party
{
imports = [ <nixpkgs/nixos/modules/profiles/qemu-guest.nix> ];
boot.loader.grub.devices = [ "$nixosparty_disk" ];
fileSystems."/".label = "root";
swapDevices = [ { label = "swap"; } ];
networking.hostName = "$nixosparty_name";
services.openssh.enable = true;
users.users."root" = {
password = "$nixosparty_password";
openssh.authorizedKeys.keys = [ $nixosparty_authorized_keys ];
};
}
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p bash coreutils envsubst gptfdisk e2fsprogs utillinux systemd
set -x
: ${nixosparty_disk:=/dev/sda}
: ${nixosparty_name:=nixos}
: ${nixosparty_password:=hunter2}
: ${nixosparty_authorized_keys:=""}
: () { [[ "$nixosparty_dryrun" ]] && echo ${@} || ${@}; }
: wipefs -a $nixosparty_disk{?,}
: udevadm settle
: sgdisk $nixosparty_disk -Z -o -n0::+2M -c0:grub -t0:ef02 -n1::+2G -c1:swap -t1:8200 -n2:: -c2:root -t2:8300
: udevadm settle
: mkfs.ext4 -q -F -L root /dev/disk/by-partlabel/root
: mkswap -f -L swap /dev/disk/by-partlabel/swap
: udevadm settle
: mkdir -p /mnt
: mount -L root /mnt
: swapon -L swap
: udevadm settle
: mkdir -p /mnt/etc/nixos
: envsubst <configuration.nix.tpl >/mnt/etc/nixos/configuration.nix
: nixos-install --no-root-passwd
: reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment