Commit 7175ef57293b

Vincent Demeester <vincent@sbr.pm>
2020-04-29 01:08:07
Add few scripts and fix README.org
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent d1643b9
hack/create-vm.sh
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+out=$(git rev-parse --show-toplevel)/qemu
+
+mkdir -p $out
+diskImage=$out/nixos-test.qcow2
+qemu-img create -f qcow2 $diskImage 20G
+qemu-system-x86_64 \
+    -enable-kvm \
+    -m 2048 \
+    -nic user,model=virtio \
+    -drive file=$diskImage,media=disk,if=virtio \
+    -cdrom ~/desktop/isos/nixos-minimal-20.03.1445.95b9c99f6d0-x86_64-linux.iso \
+    -sdl
.gitignore
@@ -5,4 +5,5 @@ hostname
 assets/machines.nix
 docs/sitemap.org
 tools/emacs/emacs.pdmp
-tools/emacs/recentf
\ No newline at end of file
+tools/emacs/recentf
+qemu
configuration.nix
@@ -0,0 +1,18 @@
+# This configuration file simply determines the hostname and then import both
+# the default configuration (common for all machine) and specific machine
+# configuration.
+let
+  hostName = "${builtins.readFile ./hostname}";
+in
+rec {
+  imports = [
+    # Generated hardware configuration
+    ./hardware-configuration.nix
+    # Default profile with default configuration
+    ./modules/module-list.nix
+    # Machine specific configuration files
+    (./machine + "/${hostName}.nix")
+  ];
+
+  networking.hostName = "${hostName}";
+}
home.nix
@@ -1,3 +1,6 @@
+# This configuration file simply determines the hostname and then import both
+# the default configuration (common for all machine) and specific machine
+# configuration.
 let
   hostName = "${builtins.readFile ./hostname}";
 in
install.sh
@@ -0,0 +1,50 @@
+#!/usr/bin/env bash
+# This scripts tries to automate the NixOS installation
+# as much as possible.
+# curl https://gitlab.com/vdemeester/home/-/raw/master/install.sh | sh
+
+set -euo pipefail
+
+read -p "Hostname: " name
+read -p "Disk:" disk
+read -p "Swap size (8GiB)": swap
+swap=${swap:-8GiB}
+
+echo "Partiton disk"
+set -x
+
+parted ${disk} -- mklabel gpt
+parted ${disk} -- mkpart primary 512MiB -${swap}
+parted ${disk} -- mkpart primary linux-swap -${swap} 100%
+parted ${disk} -- mkpart ESP fat32 1MiB 512MiB
+parted ${disk} -- set 3 boot on
+
+set +x
+echo "Format partiion"
+set -x
+
+mkfs.ext4 -L nixos ${disk}1
+mkswap -L swap ${disk}2
+mkfs.fat -F 32 -n boot ${disk}3
+
+set +x
+echo "Mount filesystems"
+set -x
+
+mount /dev/disk/by-label/nixos /mnt
+mkdir -p /mnt/boot
+mount /dev/disk/by-label/boot /mnt/boot
+swapon ${disk}2
+
+set +x
+echo "Setup configuration"
+set -x
+
+mkdir -p /mnt/etc
+git clone https://gitlab.com/vdemeester/home.git /mnt/etc/nixos
+echo -n ${name} > /mnt/etc/nixos/hostname
+
+set +x
+echo "Run the following:"
+echo "- nixos-generate-config --root /mnt"
+echo "- (once ready) nixos-install"
README.org
@@ -34,7 +34,7 @@
 you can use ~curl~ for this.
 
 #+begin_src bash
-curl https://raw.githubusercontent.com/vdemeester/home/master/bootstrap.sh | sh
+curl https://gitlab.com/vdemeester/home/-/raw/master/bootstrap.sh | sh
 #+end_src
 
 Otherwise, clone this repository somewhere, read the =bootstrap.sh= file and execute it if