diff --git a/base/self-update/default.nix b/base/self-update/default.nix index 759411c9..7c1d1afb 100644 --- a/base/self-update/default.nix +++ b/base/self-update/default.nix @@ -33,6 +33,8 @@ in }; environment.etc."rauc/system.conf" = { + # TODO: disk labels/paths and statusfile path should be supplied/defined + # by skeleton/installer text = '' [system] compatible=dividat-play-computer diff --git a/default.nix b/default.nix index 8004ce2a..b1e1a039 100644 --- a/default.nix +++ b/default.nix @@ -80,24 +80,14 @@ let # USB live system live = callPackage ./live { application = application; }; - # Installation script - install-playos = callPackage ./installer/install-playos { - grubCfg = ./bootloader/grub.cfg; - }; - - # Rescue system - rescueSystem = callPackage ./bootloader/rescue { - application = application; - }; - - # Installer ISO image + # Installer script and ISO (PlayOS skeleton) installer = callPackage ./installer {}; # Script to deploy updates deploy-update = callPackage ./deployment/deploy-update { application = application; live = if buildLive then live else ""; - installer = if buildInstaller then installer else ""; + installer = if buildInstaller then installer.isoImage else ""; }; # RAUC bundle @@ -108,7 +98,11 @@ let testingToplevel = callPackage ./testing/system { application = application; }; # Disk image containing pre-installed system - disk = if diskBuildEnabled then callPackage ./testing/disk {} else null; + disk = + if diskBuildEnabled then + callPackage ./testing/disk { inherit (installer) install-playos rescueSystem; } + else + null; # Script for spinning up VMs run-in-vm = callPackage ./testing/run-in-vm {}; @@ -139,7 +133,7 @@ let }; releaseDisk = pkgs.callPackage ./testing/disk/release.nix { - inherit (releaseValidationComponents) install-playos; + install-playos = releaseValidationComponents.installer.install-playos; }; in @@ -149,7 +143,7 @@ with pkgs; stdenv.mkDerivation { buildInputs = [ rauc (python3.withPackages(ps: with ps; [pyparted])) - components.install-playos + components.installer.install-playos ]; buildCommand = '' @@ -176,7 +170,7 @@ with pkgs; stdenv.mkDerivation { '' # Installer ISO image + lib.optionalString buildInstaller '' - ln -s ${components.installer}/iso/${components.safeProductName}-installer-${components.version}.iso $out/${components.safeProductName}-installer-${components.version}.iso + ln -s ${components.installer.isoImage}/iso/${components.safeProductName}-installer-${components.version}.iso $out/${components.safeProductName}-installer-${components.version}.iso '' # RAUC bundle + lib.optionalString buildBundle '' diff --git a/bootloader/grub.cfg b/installer/bootloader/grub.cfg similarity index 100% rename from bootloader/grub.cfg rename to installer/bootloader/grub.cfg diff --git a/bootloader/rescue/default.nix b/installer/bootloader/rescue/default.nix similarity index 95% rename from bootloader/rescue/default.nix rename to installer/bootloader/rescue/default.nix index 4ecd113a..601c91e0 100644 --- a/bootloader/rescue/default.nix +++ b/installer/bootloader/rescue/default.nix @@ -1,13 +1,12 @@ { stdenv, lib -, application +, systemMetadata , squashfsTools, closureInfo, makeInitrd, linkFarm -, importFromNixos +, nixos , writeScript, dialog , vim, grub2_efi, rauc , squashfsCompressionOpts}: with lib; let - nixos = importFromNixos ""; squashfsCompressionParams = if (squashfsCompressionOpts == null) @@ -23,7 +22,7 @@ let do ${dialog}/bin/dialog --clear --title "" \ - --backtitle "${application.fullProductName} - Rescue System" \ + --backtitle "${systemMetadata.fullProductName} - Rescue System" \ --nocancel \ --menu "Please Select an action" 0 0 0 \ "wipe-user-data" "Delete all user data." \ @@ -94,7 +93,7 @@ in ''; }; networking = { - hostName = "${application.safeProductName}-rescue"; + hostName = "${systemMetadata.safeProductName}-rescue"; # enable wpa_supplicant wireless = { enable = true; diff --git a/installer/configuration.nix b/installer/configuration.nix index 9c7b8ea1..29f025af 100644 --- a/installer/configuration.nix +++ b/installer/configuration.nix @@ -1,10 +1,28 @@ -{ config, pkgs, lib, install-playos, version, safeProductName, fullProductName, greeting, squashfsCompressionOpts, ... }: +{ install-playos, squashfsCompressionOpts, systemMetadata, ... }: + +{ modulesPath, lib, ... }: with lib; +with systemMetadata; +let + # TODO: WIP ^_^ + greeting = label: '' + ░░░░ + ░▒▒▒▒▒▒▒ ░ ▒ + ▒▒▒▒▒ ░░▒▒░░░▒▒▒▒▒ ▒▒ + ▒▒ ░░░░░░░ ▒▒▒▒▒ + ▒▒▒ ▲ ▲ ▒▒ + ▒░░ ░ + ░░░ ░ + ░░░▒▒ ▒▒░░░ ▒▒▒ ░░ ${label} + ▒▒▒▒▒▒▒▒ ░░░▒▒▒░░░ + ''; + +in { imports = [ - (pkgs.importFromNixos "modules/installer/cd-dvd/iso-image.nix") + "${modulesPath}/installer/cd-dvd/iso-image.nix" ]; # Custom label when identifying OS diff --git a/installer/default.nix b/installer/default.nix index 5da8101f..22740010 100644 --- a/installer/default.nix +++ b/installer/default.nix @@ -1,18 +1,48 @@ -# Build NixOS system -{ config, lib, pkgs -, version, safeProductName, fullProductName, greeting, install-playos -, squashfsCompressionOpts +# TODO: rename this to "skeleton" that exposes several components: +# - [ ] skeleton configuration params (partition labels, hard-coded paths like /boot/status.ini) +# - [x] the installer script (for e2e and release validation tests) +# - [x] the rescueSystem (for e2e and release validation tests) +# - [x] the installer ISO +{ squashfsCompressionOpts +, systemImage +# TODO: combine this into a single systemMetadata attrset that is defined in the top-level default.nix +, safeProductName, fullProductName, kioskUrl, updateUrl, version }: let - nixos = pkgs.importFromNixos ""; + pkgs = import ./pkgs; + + systemMetadata = { + inherit safeProductName fullProductName kioskUrl updateUrl version; + }; + + # Rescue system + rescueSystem = pkgs.callPackage ./bootloader/rescue { + inherit (pkgs) nixos; + inherit squashfsCompressionOpts; + inherit systemMetadata; + }; + + + # Installation script + install-playos = pkgs.callPackage ./install-playos { + grubCfg = ./bootloader/grub.cfg; + inherit rescueSystem; + inherit systemImage systemMetadata; + }; configuration = (import ./configuration.nix) { - inherit config pkgs lib install-playos version safeProductName fullProductName greeting squashfsCompressionOpts; + inherit install-playos squashfsCompressionOpts; + inherit systemMetadata; }; -in -(nixos { - inherit configuration; - system = "x86_64-linux"; -}).config.system.build.isoImage + isoImage = (pkgs.nixos { + configuration = { + imports = [ configuration ]; + }; + system = "x86_64-linux"; + }).config.system.build.isoImage; +in +{ + inherit install-playos isoImage rescueSystem; +} diff --git a/installer/install-playos/default.nix b/installer/install-playos/default.nix index 0a994338..8bddd18f 100644 --- a/installer/install-playos/default.nix +++ b/installer/install-playos/default.nix @@ -1,32 +1,23 @@ -{ stdenv -, substituteAll -, makeWrapper -, grub2_efi -, e2fsprogs -, dosfstools -, utillinux -, python3 -, pv -, closureInfo +{ pkgs , systemImage , rescueSystem , grubCfg -, version -, updateUrl -, kioskUrl +, systemMetadata }: +with pkgs; let systemClosureInfo = closureInfo { rootPaths = [ systemImage ]; }; python = python3.withPackages(ps: with ps; [pyparted]); in stdenv.mkDerivation { - name = "install-playos-${version}"; + name = "install-playos-${systemMetadata.version}"; src = substituteAll { src = ./install-playos.py; - inherit grubCfg systemImage rescueSystem systemClosureInfo version updateUrl kioskUrl; + inherit grubCfg systemImage rescueSystem systemClosureInfo; + inherit (systemMetadata) version kioskUrl updateUrl; inherit python; }; diff --git a/installer/pkgs/default.nix b/installer/pkgs/default.nix new file mode 100644 index 00000000..6aa30bb9 --- /dev/null +++ b/installer/pkgs/default.nix @@ -0,0 +1,17 @@ +let + nixpkgs = builtins.fetchTarball { + # nixos-24.05 2024-10-07 + url = "https://github.com/nixos/nixpkgs/archive/ecbc1ca8ffd6aea8372ad16be9ebbb39889e55b6.tar.gz"; + sha256 = "0yfaybsa30zx4bm900hgn3hz92javlf4d47ahdaxj9fai00ddc1x"; + }; + + overlay = + self: super: { + rauc = (import ./rauc) super; + + nixos = import "${nixpkgs}/nixos"; + }; +in +import nixpkgs { + overlays = [ overlay ]; +} diff --git a/pkgs/rauc/0001-Adapt-notion-of-GRUB-primary-slot-to-allow-for-2-uns.patch b/installer/pkgs/rauc/0001-Adapt-notion-of-GRUB-primary-slot-to-allow-for-2-uns.patch similarity index 100% rename from pkgs/rauc/0001-Adapt-notion-of-GRUB-primary-slot-to-allow-for-2-uns.patch rename to installer/pkgs/rauc/0001-Adapt-notion-of-GRUB-primary-slot-to-allow-for-2-uns.patch diff --git a/pkgs/rauc/default.nix b/installer/pkgs/rauc/default.nix similarity index 100% rename from pkgs/rauc/default.nix rename to installer/pkgs/rauc/default.nix diff --git a/pkgs/default.nix b/pkgs/default.nix index 9f0ef639..be2af8b5 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -13,7 +13,8 @@ let importFromNixos = path: import (nixpkgs + "/nixos/" + path); - rauc = (import ./rauc) super; + # use RAUC from installer/skeleton + rauc = (import ../installer/pkgs).rauc; ocamlPackages = super.ocamlPackages.overrideScope (self: super: { semver = self.callPackage ./ocaml-modules/semver {}; diff --git a/system-image/default.nix b/system-image/default.nix index ca8d1302..27dab61a 100644 --- a/system-image/default.nix +++ b/system-image/default.nix @@ -16,6 +16,7 @@ let nixos = pkgs.importFromNixos ""; in ] ++ extraModules; # Storage + # TODO: should be defined by installer/skeleton config module fileSystems = { "/boot" = { device = "/dev/disk/by-label/ESP"; @@ -28,6 +29,7 @@ let nixos = pkgs.importFromNixos ""; in device = "/dev/root"; options = [ "ro" ]; }; + # TODO: should be defined by installer/skeleton config module persistentDataPartition.device = "/dev/disk/by-label/data"; };