blob: 8b6eed00bda79f22ba6fce40eaf5a53a77289511 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!/bin/bash
set -e
lxc launch images:debian/buster "$1"
USER=user
EXE="lxc exec $1 -- bash -c"
$EXE "useradd -m $USER"
$EXE "groupadd nixbld"
$EXE "usermod -a -G nixbld $USER"
$EXE "mkdir -m 0755 /nix && chown $USER /nix"
$EXE "apt -y install curl stterm xz-utils sudo"
lxc config set "$1" security.nesting true
lxc restart "$1"
sleep 1
UEXE="lxc exec $1 -- sudo --login --user $USER bash -ilc"
$UEXE "curl -L https://nixos.org/nix/install | sh"
$UEXE "mkdir -p /home/$USER/.config/nixpkgs/"
lxc file push config/config.nix "$1/home/$USER/.config/nixpkgs/"
$UEXE "nix-env -iA nixpkgs.myPackages"
lxc file push config/nixos-config "$1/home/$USER/"
$UEXE "nix-build '<nixpkgs/nixos>' -A vm -I."
$EXE "ln -s /home/user/result/system/etc/systemd/system/* /etc/systemd/system/"
$EXE "ln -s /home/user/result/system/etc/ssh/* /etc/ssh/"
|