nix #11

Manually merged
geoffrey merged 113 commits from nix into main 2023-12-09 21:43:01 +01:00
21 changed files with 169 additions and 77 deletions
Showing only changes of commit 6444f8f517 - Show all commits

View file

@ -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 '<nixpkgs/nixos>' -A vm \
-I nixos-config=${config}

View file

@ -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;
}

8
curacao/hardware.nix Normal file
View file

@ -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;
}

10
curacao/options.nix Normal file
View file

@ -0,0 +1,10 @@
{ ... }:
{
frogeye = {
desktop.xorg = true;
dev = {
docker = true;
};
extra = true;
};
}

11
curacao/os.nix Normal file
View file

@ -0,0 +1,11 @@
{ ... }:
{
imports = [
../os
./options.nix
./hardware.nix
./disko.nix
];
networking.hostName = "curacao";
}

View file

@ -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;
}

12
curacao_test/hm.nix Normal file
View file

@ -0,0 +1,12 @@
{ ... }:
{
imports = [
../hm
../curacao/options.nix
];
home.username = "gnix";
home.homeDirectory = "/home/gnix";
frogeye.desktop.nixGLIntel = true;
}

View file

@ -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 

View file

@ -22,7 +22,7 @@
home-manager = {
users.geoffrey = { pkgs, ... }: {
imports = [
../hm/loader.nix
../hm
];
frogeye = config.frogeye;
};

View file

@ -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;
}

6
pindakaas/options.nix Normal file
View file

@ -0,0 +1,6 @@
{ ... }:
{
frogeye.extra = false; # FIXME Not working yet
frogeye.desktop.xorg = true;
frogeye.dev.docker = true;
}

11
pindakaas/os.nix Normal file
View file

@ -0,0 +1,11 @@
{ ... }:
{
imports = [
../os
./hardware.nix
./disko.nix
./options.nix
];
networking.hostName = "pindakaas";
}

View file

@ -22,10 +22,33 @@
};
root = {
size = "100%";
# content = {
# type = "filesystem";
# format = "ext4";
# mountpoint = "/";
# };
content = {
type = "filesystem";
format = "ext4";
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

6
pindakaas_sd/options.nix Normal file
View file

@ -0,0 +1,6 @@
{ ... }:
{
# Barebones is faster to test partition schemes
frogeye.dev.ansible = false;
frogeye.dev.python = false;
}

11
pindakaas_sd/os.nix Normal file
View file

@ -0,0 +1,11 @@
{ pkgs, config, ... }:
{
imports = [
../os
../pindakaas/hardware.nix
./disko.nix
./options.nix
];
networking.hostName = "pindakaas_sd";
}

View file

11
vm/build.sh Executable file
View file

@ -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 '<nixpkgs/nixos>' -A vm \
-I nixos-config=./os.nix

14
vm/options.nix Normal file
View file

@ -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
};
}

10
vm/os.nix Normal file
View file

@ -0,0 +1,10 @@
{ ... }:
{
imports = [
../os
./options.nix
];
# Create a different disk image depending on the architecture
networking.hostName = "${builtins.currentSystem}";
}