From 0999683e2305f44f18784388bd2d7e453248ca17 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Mon, 14 Dec 2020 23:52:01 -0500 Subject: [PATCH] modules: Add shared-rootfs Used to undo some of the close-knit integration work NixOS does, so we can cheat an make a more generic rootfs. --- modules/module-list.nix | 1 + modules/shared-rootfs.nix | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 modules/shared-rootfs.nix diff --git a/modules/module-list.nix b/modules/module-list.nix index 344034a6..ac663c65 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -35,6 +35,7 @@ ./nixpkgs.nix ./quirks ./rootfs.nix + ./shared-rootfs.nix ./system-target.nix ./system-types.nix ] diff --git a/modules/shared-rootfs.nix b/modules/shared-rootfs.nix new file mode 100644 index 00000000..85d2cdf8 --- /dev/null +++ b/modules/shared-rootfs.nix @@ -0,0 +1,35 @@ +{ config, lib, ... }: + +let + inherit (config.mobile.rootfs.shared) enabled; + inherit (lib) mkIf mkOption types; +in +{ + options = { + mobile.rootfs.shared.enabled = mkOption { + internal = true; + type = types.bool; + default = false; + description = '' + Enable when building a generic rootfs that does not include a kernel image. + + This makes sturdier rootfs that work on different devices. + ''; + }; + }; + + config = mkIf enabled { + # Ensure we don't bring a kernel or initrd into the system. + system.boot.loader.kernelFile = "dummy"; + system.boot.loader.initrdFile = "dummy"; + + # And totally obliterate device-specific files from stage-2. + system.extraSystemBuilderCmds = '' + echo ":: Removing non-generic system items..." + ( + cd $out + rm -vf dtbs initrd kernel kernel-modules kernel-params + ) + ''; + }; +}