commit 7175ef57293bdedd5f0a4ccbd4136f5c4ac645e7
parent d1643b91e905912e84ed522d1013136450cda021
Author: Vincent Demeester <vincent@sbr.pm>
Date: Wed, 29 Apr 2020 01:08:07 +0200
Add few scripts and fix README.org
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Diffstat:
6 files changed, 89 insertions(+), 3 deletions(-)
diff --git a/.gitignore b/.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
diff --git a/README.org b/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
diff --git a/configuration.nix b/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}";
+}
diff --git a/hack/create-vm.sh b/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
diff --git a/home.nix b/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
diff --git a/install.sh b/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"