From 3470751c3ea78d45f5dfcbc9e5fe752b9e0ea187 Mon Sep 17 00:00:00 2001 From: Emma Thorpe Date: Tue, 16 Jun 2026 13:29:15 +0100 Subject: [PATCH] refactor(modules): declare swayDesktop feature flag in a base module lyrathorpe/user.nix reads features.swayDesktop.enable on every host, but the option was declared inside lyrathorpe/swaywm.nix -- so a host that does not import swaywm.nix (a headless server) would fail evaluation. Move the option declaration to a new always-imported system/modules/features.nix and wire it into baseModules; swaywm.nix keeps only its implementation (config) block. Headless hosts can now omit swaywm.nix and the flag defaults to false. --- flake.nix | 1 + lyrathorpe/swaywm.nix | 6 +++--- system/modules/features.nix | 12 ++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 system/modules/features.nix diff --git a/flake.nix b/flake.nix index 63167b0..ce10500 100644 --- a/flake.nix +++ b/flake.nix @@ -114,6 +114,7 @@ baseModules = [ ./lyrathorpe/user.nix ./system/modules/common-nixos.nix + ./system/modules/features.nix commonModule home-manager.nixosModules.home-manager { diff --git a/lyrathorpe/swaywm.nix b/lyrathorpe/swaywm.nix index 9c5551b..22d27c5 100644 --- a/lyrathorpe/swaywm.nix +++ b/lyrathorpe/swaywm.nix @@ -11,9 +11,9 @@ let ctp = import ./catppuccin-mocha.nix; in { - options = { - features.swayDesktop.enable = lib.mkEnableOption "Enable Sway Desktop"; - }; + # The features.swayDesktop.enable option is declared in + # system/modules/features.nix (so headless hosts can read/set it without + # importing this module). This module only provides its implementation. config = lib.mkIf cfg.enable { programs.sway = { enable = true; diff --git a/system/modules/features.nix b/system/modules/features.nix new file mode 100644 index 0000000..486c4b8 --- /dev/null +++ b/system/modules/features.nix @@ -0,0 +1,12 @@ +# Feature-flag option declarations shared by every NixOS host (imported via +# baseModules in flake.nix). Declaring the flags here -- rather than inside the +# module that implements them -- means a host can read or set a flag without +# importing the (often large) implementation module. In particular, +# features.swayDesktop.enable is read by lyrathorpe/user.nix on every host, but a +# headless host (e.g. the Pi) must be able to leave it at its default without +# pulling in lyrathorpe/swaywm.nix. The implementation lives in swaywm.nix, +# gated on this flag. +{ lib, ... }: +{ + options.features.swayDesktop.enable = lib.mkEnableOption "the Sway desktop"; +}