diff --git a/build-vm.sh b/build-vm.sh deleted file mode 100755 index 4cb07b0..0000000 --- a/build-vm.sh +++ /dev/null @@ -1,21 +0,0 @@ -#/usr/bin/env sh - -# Build a NixOS VM for testing -# -# For x86_64 hosts: use curacao config -# For aarch64 hosts: use pindakaas config - -if ! command -v nom-build -then - exec nix-shell -p nix-output-monitor --run $0 -fi - -if [ "$(uname -m)" == "x86_64" ] -then - config=./curacao.nix -elif [ "$(uname -m)" == "aarch64" ] -then - config=./pindakaas.nix -fi -nom-build '' -A vm \ - -I nixos-config=${config} diff --git a/curacao.nix b/curacao.nix deleted file mode 100644 index 1344c11..0000000 --- a/curacao.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ ... }: -{ - imports = [ - "${builtins.fetchTarball "https://github.com/NixOS/nixos-hardware/archive/468a7a108108908c7a35d6549f1e1f0236a9448a.tar.gz"}/dell/g3/3779" - ./os/loader.nix - ]; - - boot.loader.efi.canTouchEfiVariables = true; - - networking.hostName = "curacao"; - frogeye.extra = true; - frogeye.desktop.xorg = true; - frogeye.dev.docker = true; -} diff --git a/curacao/hardware.nix b/curacao/hardware.nix new file mode 100644 index 0000000..b7e23b5 --- /dev/null +++ b/curacao/hardware.nix @@ -0,0 +1,8 @@ +{ lib, ... }: +{ + imports = [ + "${builtins.fetchTarball "https://github.com/NixOS/nixos-hardware/archive/468a7a108108908c7a35d6549f1e1f0236a9448a.tar.gz"}/dell/g3/3779" + ]; + + boot.loader.efi.canTouchEfiVariables = lib.mkDefault true; +} diff --git a/curacao/options.nix b/curacao/options.nix new file mode 100644 index 0000000..0fcf285 --- /dev/null +++ b/curacao/options.nix @@ -0,0 +1,10 @@ +{ ... }: +{ + frogeye = { + desktop.xorg = true; + dev = { + docker = true; + }; + extra = true; + }; +} diff --git a/curacao/os.nix b/curacao/os.nix new file mode 100644 index 0000000..fd60a8c --- /dev/null +++ b/curacao/os.nix @@ -0,0 +1,11 @@ +{ ... }: +{ + imports = [ + ../os + ./options.nix + ./hardware.nix + ./disko.nix + ]; + + networking.hostName = "curacao"; +} diff --git a/curacao_test.nix b/curacao_test.nix deleted file mode 100644 index 485bb16..0000000 --- a/curacao_test.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ ... }: -{ - imports = [ - ./hm/loader.nix - ]; - - home.username = "gnix"; - home.homeDirectory = "/home/gnix"; - - frogeye.extra = true; - frogeye.desktop.xorg = true; - frogeye.desktop.nixGLIntel = true; - frogeye.dev.ansible = true; - frogeye.dev.c = true; - frogeye.dev.docker = true; - frogeye.dev.fpga = true; - frogeye.dev.python = true; -} diff --git a/curacao_test/hm.nix b/curacao_test/hm.nix new file mode 100644 index 0000000..b6f615d --- /dev/null +++ b/curacao_test/hm.nix @@ -0,0 +1,12 @@ +{ ... }: +{ + imports = [ + ../hm + ../curacao/options.nix + ]; + + home.username = "gnix"; + home.homeDirectory = "/home/gnix"; + + frogeye.desktop.nixGLIntel = true; +} diff --git a/hm/loader.nix b/hm/default.nix similarity index 100% rename from hm/loader.nix rename to hm/default.nix diff --git a/build-pindakaas-disk.sh b/install_os.sh similarity index 67% rename from build-pindakaas-disk.sh rename to install_os.sh index 4c0a658..cf9a66c 100755 --- a/build-pindakaas-disk.sh +++ b/install_os.sh @@ -3,10 +3,14 @@ #! nix-shell -p bash nixos-install-tools set -euo pipefail +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) # Parse arguments function help { - echo "Usage: $0 -e" + echo "Usage: $0 profile [-e]" + echo + echo "Arguments:" + echo " file: OS/disk profile to use" echo echo "Options:" echo " -h: Display this help message." @@ -32,11 +36,31 @@ do done shift "$(($OPTIND -1))" -if [ "$#" -gt 0 ] +if [ "$#" -ne 1 ] then help exit 2 fi +profile="$1" + +profile_dir="${SCRIPT_DIR}/${profile}" +if [ ! -d "$profile_dir" ] +then + echo "Profile not found." +fi + +disko_config="${profile_dir}/disko.nix" +if [ ! -f "$disko_config" ] +then + echo "Disk configuration not found." +fi + +nixos_config="${profile_dir}/os.nix" +if [ ! -f "$nixos_config" ] +then + echo "NixOS configuration not found." +fi + set -x @@ -45,7 +69,7 @@ set -x sudo ./add_channels.sh # Format or mount disk -sudo nix --extra-experimental-features nix-command --extra-experimental-features flakes run github:nix-community/disko -- --mode $disko_mode ./pindakaas_disko.nix +sudo nix --extra-experimental-features nix-command --extra-experimental-features flakes run github:nix-community/disko -- --mode "$disko_mode" "$disko_config" # Generate hardware-config.nix sudo nixos-generate-config --no-filesystems --root /mnt @@ -53,11 +77,11 @@ sudo nixos-generate-config --no-filesystems --root /mnt # Plug system configuration into this git repo sudo mkdir -p /mnt/etc/nixos -echo "{ ... }: { imports = [ ./hardware-configuration.nix /home/geoffrey/.config/dotfiles/pindakaas.nix ]; }" | sudo tee /mnt/etc/nixos/configuration.nix > /dev/null +echo "{ ... }: { imports = [ ./hardware-configuration.nix ${nixos_config} ]; }" | sudo tee /mnt/etc/nixos/configuration.nix > /dev/null # Everything there should be covered by (and conflicts with) the repo anyways. # Install NixOS! Or create a new generation. -sudo nixos-install +sudo nixos-install --no-root-password # Install dotfiles. Actually not needed by nixos-install since it doesn't rewrite global paths to /mnt. # Without it no nixos-rebuild from the system itself once installed though. @@ -66,6 +90,5 @@ sudo nixos-install # sudo cp -a ../dotfiles /mnt/home/geoffrey/.config/ # sudo chown geoffrey:geoffrey /mnt/home/geoffrey -R -# Signal we're done! -# Although it might ask for passwords beforehand, so not sure it's really useful +# Signal the installation is done! echo  diff --git a/os/loader.nix b/os/default.nix similarity index 100% rename from os/loader.nix rename to os/default.nix diff --git a/os/geoffrey.nix b/os/geoffrey.nix index 1597880..d828426 100644 --- a/os/geoffrey.nix +++ b/os/geoffrey.nix @@ -22,7 +22,7 @@ home-manager = { users.geoffrey = { pkgs, ... }: { imports = [ - ../hm/loader.nix + ../hm ]; frogeye = config.frogeye; }; diff --git a/pindakaas.nix b/pindakaas/hardware.nix similarity index 73% rename from pindakaas.nix rename to pindakaas/hardware.nix index d52901c..0dc278b 100644 --- a/pindakaas.nix +++ b/pindakaas/hardware.nix @@ -3,9 +3,8 @@ imports = [ # First commit before 23.05 release date: "${builtins.fetchTarball "https://github.com/NixOS/nixos-hardware/archive/468a7a108108908c7a35d6549f1e1f0236a9448a.tar.gz"}/pine64/pinebook-pro" - ./os/loader.nix - ./pindakaas_disko.nix ]; + boot = { # nixos-hardware use latest kernel by default. It has been set a while ago, we maybe don't need it anymore? kernelPackages = pkgs.linuxPackages; @@ -25,14 +24,4 @@ }; }; - - networking.hostName = "pindakaas"; - - # DEBUG Barebones is faster - frogeye.dev.ansible = false; - frogeye.dev.python = false; - - # frogeye.extra = false; # FIXME Not working yet - # frogeye.desktop.xorg = true; - # frogeye.dev.docker = true; } diff --git a/pindakaas/options.nix b/pindakaas/options.nix new file mode 100644 index 0000000..f14ad67 --- /dev/null +++ b/pindakaas/options.nix @@ -0,0 +1,6 @@ +{ ... }: +{ + frogeye.extra = false; # FIXME Not working yet + frogeye.desktop.xorg = true; + frogeye.dev.docker = true; +} diff --git a/pindakaas/os.nix b/pindakaas/os.nix new file mode 100644 index 0000000..e0e1f93 --- /dev/null +++ b/pindakaas/os.nix @@ -0,0 +1,11 @@ +{ ... }: +{ + imports = [ + ../os + ./hardware.nix + ./disko.nix + ./options.nix + ]; + + networking.hostName = "pindakaas"; +} diff --git a/pindakaas_disko.nix b/pindakaas_sd/disko.nix similarity index 72% rename from pindakaas_disko.nix rename to pindakaas_sd/disko.nix index bd93cc7..2074c00 100644 --- a/pindakaas_disko.nix +++ b/pindakaas_sd/disko.nix @@ -22,11 +22,34 @@ }; root = { size = "100%"; + # content = { + # type = "filesystem"; + # format = "ext4"; + # mountpoint = "/"; + # }; content = { - type = "filesystem"; - format = "ext4"; - mountpoint = "/"; - }; + type = "btrfs"; + extraArgs = [ "-f" ]; + subvolumes = { + "/nixos" = { + mountpoint = "/"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/home" = { + mountpoint = "/home"; + mountOptions = [ "compress=zstd" "relatime" ]; + }; + "/nix" = { + mountpoint = "/nix"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + # Maybe later + # "/swap" = { + # mountpoint = "/.swapvol"; + # swap.swapfile.size = "20M"; + # }; + }; + }; }; # FIXME Hang on Linux boot, for some reason # luks = { diff --git a/pindakaas_sd/options.nix b/pindakaas_sd/options.nix new file mode 100644 index 0000000..d825514 --- /dev/null +++ b/pindakaas_sd/options.nix @@ -0,0 +1,6 @@ +{ ... }: +{ + # Barebones is faster to test partition schemes + frogeye.dev.ansible = false; + frogeye.dev.python = false; +} diff --git a/pindakaas_sd/os.nix b/pindakaas_sd/os.nix new file mode 100644 index 0000000..87c9333 --- /dev/null +++ b/pindakaas_sd/os.nix @@ -0,0 +1,11 @@ +{ pkgs, config, ... }: +{ + imports = [ + ../os + ../pindakaas/hardware.nix + ./disko.nix + ./options.nix + ]; + + networking.hostName = "pindakaas_sd"; +} diff --git a/.gitignore b/vm/.gitignore similarity index 100% rename from .gitignore rename to vm/.gitignore diff --git a/vm/build.sh b/vm/build.sh new file mode 100755 index 0000000..97e698d --- /dev/null +++ b/vm/build.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env nix-shell +#! nix-shell -i bash +#! nix-shell -p bash nix-output-monitor + +# Build a NixOS VM for testing + +set -euo pipefail +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +nom-build '' -A vm \ + -I nixos-config=./os.nix diff --git a/vm/options.nix b/vm/options.nix new file mode 100644 index 0000000..f342e90 --- /dev/null +++ b/vm/options.nix @@ -0,0 +1,14 @@ +{ ... }: +{ + frogeye = { + desktop.xorg = true; + dev = { + ansible = true; + c = true; + docker = true; + fpga = true; + python = true; + }; + # extra = true; # FIXME Should support aarch64 + }; +} diff --git a/vm/os.nix b/vm/os.nix new file mode 100644 index 0000000..e74e854 --- /dev/null +++ b/vm/os.nix @@ -0,0 +1,10 @@ +{ ... }: +{ + imports = [ + ../os + ./options.nix + ]; + + # Create a different disk image depending on the architecture + networking.hostName = "${builtins.currentSystem}"; +}