mirror of
https://github.com/elitak/nixos-infect.git
synced 2024-12-23 00:28:28 +03:00
commit
7c2f3e8e2d
1 changed files with 9 additions and 5 deletions
14
nixos-infect
14
nixos-infect
|
@ -47,6 +47,9 @@
|
||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
|
export disk=$( (>/dev/null ls -l /dev/vda && echo vda) \
|
||||||
|
|| (>/dev/null ls -l /dev/sda && echo sda) )
|
||||||
|
|
||||||
makeConf() {
|
makeConf() {
|
||||||
# NB <<"EOF" quotes / $ ` in heredocs, <<EOF does not
|
# NB <<"EOF" quotes / $ ` in heredocs, <<EOF does not
|
||||||
mkdir -p /etc/nixos
|
mkdir -p /etc/nixos
|
||||||
|
@ -72,8 +75,8 @@ EOF
|
||||||
{ ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
imports = [ <nixpkgs/nixos/modules/profiles/qemu-guest.nix> ];
|
imports = [ <nixpkgs/nixos/modules/profiles/qemu-guest.nix> ];
|
||||||
boot.loader.grub.device = "/dev/vda";
|
boot.loader.grub.device = "/dev/$disk";
|
||||||
fileSystems."/" = { device = "/dev/vda1"; fsType = "ext4"; };
|
fileSystems."/" = { device = "/dev/${disk}1"; fsType = "ext4"; };
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
@ -150,13 +153,14 @@ makeConf
|
||||||
makeSwap # smallest (512MB) droplet needs extra memory!
|
makeSwap # smallest (512MB) droplet needs extra memory!
|
||||||
|
|
||||||
which dnf && dnf install -y perl-Digest-SHA # Fedora 24
|
which dnf && dnf install -y perl-Digest-SHA # Fedora 24
|
||||||
|
which bzcat || (which yum && yum install -y bzip2) # CentOS
|
||||||
|
|
||||||
# DigitalOcean doesn't seem to set USER while running user data
|
# DigitalOcean doesn't seem to set USER while running user data
|
||||||
export USER="root"
|
export USER="root"
|
||||||
export HOME="/root"
|
export HOME="/root"
|
||||||
|
|
||||||
groupadd -r nixbld -g 30000
|
groupadd -r nixbld -g 30000 || true
|
||||||
seq 1 10 | xargs -I{} useradd -c "Nix build user {}" -d /var/empty -g nixbld -G nixbld -M -N -r -s `which nologin` nixbld{}
|
seq 1 10 | xargs -I{} useradd -c "Nix build user {}" -d /var/empty -g nixbld -G nixbld -M -N -r -s `which nologin` nixbld{} || true
|
||||||
|
|
||||||
curl https://nixos.org/nix/install | sh
|
curl https://nixos.org/nix/install | sh
|
||||||
|
|
||||||
|
@ -190,7 +194,7 @@ etc/resolv.conf
|
||||||
root/.nix-defexpr/channels
|
root/.nix-defexpr/channels
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
mv -v /boot /boot.bak &&
|
rm -rf /boot.bak && mv -v /boot /boot.bak &&
|
||||||
/nix/var/nix/profiles/system/bin/switch-to-configuration boot
|
/nix/var/nix/profiles/system/bin/switch-to-configuration boot
|
||||||
|
|
||||||
reboot
|
reboot
|
||||||
|
|
Loading…
Reference in a new issue