about summary refs log tree commit diff stats
path: root/modules/system/boot
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-05-20 16:10:21 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-05-20 16:14:26 +0200
commit368cb6b0d25db2ae23be42ad51584de059997e51 (patch)
tree3282e45d3ebced63c8498a47e83a255c35de620b /modules/system/boot
parentrefactor(hm): Rename to `modules/home` (diff)
downloadnixos-config-368cb6b0d25db2ae23be42ad51584de059997e51.zip
refactor(sys): Modularize and move to `modules/system` or `pkgs`
Diffstat (limited to '')
-rwxr-xr-xmodules/system/boot/boot_pictures/gnu.png (renamed from sys/boot/boot_pictures/gnu.png)bin327518 -> 327518 bytes
-rwxr-xr-xmodules/system/boot/boot_pictures/gnulin_emb_1.png (renamed from sys/boot/boot_pictures/gnulin_emb_1.png)bin207444 -> 207444 bytes
-rwxr-xr-xmodules/system/boot/boot_pictures/gnulin_emb_2.png (renamed from sys/boot/boot_pictures/gnulin_emb_2.png)bin208347 -> 208347 bytes
-rw-r--r--modules/system/boot/default.nix129
-rw-r--r--modules/system/boot/iso_entry/archlive_iso.nix (renamed from sys/boot/archlive_iso.nix)0
-rw-r--r--modules/system/boot/iso_entry/signing_key.nix (renamed from sys/boot/signing_key.nix)0
6 files changed, 129 insertions, 0 deletions
diff --git a/sys/boot/boot_pictures/gnu.png b/modules/system/boot/boot_pictures/gnu.png
index d07dee3e..d07dee3e 100755
--- a/sys/boot/boot_pictures/gnu.png
+++ b/modules/system/boot/boot_pictures/gnu.png
Binary files differdiff --git a/sys/boot/boot_pictures/gnulin_emb_1.png b/modules/system/boot/boot_pictures/gnulin_emb_1.png
index 483f2681..483f2681 100755
--- a/sys/boot/boot_pictures/gnulin_emb_1.png
+++ b/modules/system/boot/boot_pictures/gnulin_emb_1.png
Binary files differdiff --git a/sys/boot/boot_pictures/gnulin_emb_2.png b/modules/system/boot/boot_pictures/gnulin_emb_2.png
index 48cd6ad7..48cd6ad7 100755
--- a/sys/boot/boot_pictures/gnulin_emb_2.png
+++ b/modules/system/boot/boot_pictures/gnulin_emb_2.png
Binary files differdiff --git a/modules/system/boot/default.nix b/modules/system/boot/default.nix
new file mode 100644
index 00000000..1e6fa99b
--- /dev/null
+++ b/modules/system/boot/default.nix
@@ -0,0 +1,129 @@
+{
+  config,
+  lib,
+  pkgs,
+  ...
+}: let
+  cfg = config.soispha.boot;
+in {
+  options.soispha.boot = {
+    enable = lib.mkEnableOption "Bootloader configuration";
+    # TODO: Add this option <2024-05-16>
+    # enableIsoEntry = lib.mkEnableOption "an tails iso boot entry";
+  };
+
+  config = lib.mkIf cfg.enable (
+    # let
+    # cfg = config.boot.loader.systemd-boot;
+    # inherit (config.boot.loader) efi;
+    #
+    # esa = n: lib.strings.escapeShellArg n;
+    #
+    # bootMountPoint =
+    #   if cfg.xbootldrMountPoint != null
+    #   then cfg.xbootldrMountPoint
+    #   else efi.efiSysMountPoint;
+    #
+    # nixosDir = "/EFI/nixos";
+    #
+    # # FIXME: This system has two big problems:
+    # # 1. It does not updated files, which still have the same name
+    # # 2. It forgets about files, which were 'deleted' in this configuration (these just
+    # #    stay on disk forever) <2024-05-11>
+    # copyExtraFiles = ''
+    #   echo "[systemd-boot] copying files to ${bootMountPoint}"
+    #   empty_file=$(mktemp)
+    #
+    #   ${lib.concatStrings (lib.mapAttrsToList (n: v:
+    #     /*
+    #     bash
+    #     */
+    #     ''
+    #       if ! [ -e ${esa "${bootMountPoint}/${n}"} ]; then
+    #         install -Dp "${v}" ${esa "${bootMountPoint}/${n}"}
+    #         install -D "$empty_file" ${esa "${bootMountPoint}/${nixosDir}/.extra-files/${n}"}
+    #       fi
+    #     '')
+    #   cfg.extraFiles)}
+    #
+    #   ${lib.concatStrings (lib.mapAttrsToList (n: v:
+    #     /*
+    #     bash
+    #     */
+    #     ''
+    #       # if ! [ -e ${esa "${bootMountPoint}/loader/entries/${n}"} ]; then
+    #         install -Dp "${pkgs.writeText n v}" ${esa "${bootMountPoint}/loader/entries/${n}"}
+    #         install -D "$empty_file" ${esa "${bootMountPoint}/${nixosDir}/.extra-files/loader/entries/${n}"}
+    #       # fi
+    #     '')
+    #   cfg.extraEntries)}
+    # '';
+    # in
+    {
+      # FIXME: Reactviate this whole iso thing when a disko redeploy is done.
+      # (and switch to tails instead of arch) <2024-05-12>
+      #
+      # system.activationScripts = {
+      #   copyExtraFilesForBoot = copyExtraFiles;
+      # };
+
+      boot = {
+        initrd = {
+          kernelModules = ["nvme" "btrfs"];
+        };
+
+        kernelPackages = pkgs.linuxPackages_latest;
+
+        lanzaboote = {
+          enable = true;
+          pkiBundle = "/etc/secureboot";
+
+          settings = {
+            # Disable editing the kernel command line (which could allow someone to become root)
+            editor = false;
+          };
+        };
+
+        loader = {
+          systemd-boot = {
+            # Lanzaboote currently replaces the systemd-boot module.
+            # This setting is usually set to true in configuration.nix
+            # generated at installation time. So we force it to false
+            # for now.
+            enable = false;
+
+            # extraEntries = {
+            #   "live.conf" = ''
+            #     title Archlinux Live ISO
+            #     linux /live/vmlinuz-linux
+            #     initrd /live/initramfs-linux.img
+            #     options img_dev=${config.soispha.disks.disk} img_loop=/archlinux.iso copytoram
+            #   '';
+            # };
+            #
+            # extraFiles = let
+            #   iso = import ./archlive_iso.nix {inherit pkgs;};
+            # in {
+            #   "archlinux.iso" = "${iso}/archlinux.iso";
+            #   "live/initramfs-linux.img" = "${iso}/live/initramfs-linux.img";
+            #   "live/vmlinuz-linux" = "${iso}/live/vmlinuz-linux";
+            # };
+          };
+
+          grub = {
+            enable = false;
+            # theme = pkgs.nixos-grub2-theme;
+            splashImage = ./boot_pictures/gnu.png;
+            efiSupport = true;
+            device = "nodev"; # only for efi
+          };
+
+          efi = {
+            canTouchEfiVariables = true;
+            efiSysMountPoint = "/boot";
+          };
+        };
+      };
+    }
+  );
+}
diff --git a/sys/boot/archlive_iso.nix b/modules/system/boot/iso_entry/archlive_iso.nix
index d19a4a87..d19a4a87 100644
--- a/sys/boot/archlive_iso.nix
+++ b/modules/system/boot/iso_entry/archlive_iso.nix
diff --git a/sys/boot/signing_key.nix b/modules/system/boot/iso_entry/signing_key.nix
index 788447be..788447be 100644
--- a/sys/boot/signing_key.nix
+++ b/modules/system/boot/iso_entry/signing_key.nix