From e9c6c54ee16f83b4a0b2ef16c5f83fb08518b268 Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Wed, 25 Dec 2024 23:11:43 -0800 Subject: [PATCH] feat: bundle external nixosModules with liminalOS module --- flake.nix | 54 +++++++++++++++++++------- hm/default.nix | 4 -- hm/modules/common/shellenv/default.nix | 2 - hm/modules/linux/spicetify/default.nix | 10 +---- modules/default.nix | 1 + modules/linux/core/default.nix | 4 +- modules/linux/flatpak/default.nix | 4 -- modules/linux/stylix/default.nix | 4 -- modules/linux/wsl/default.nix | 4 -- reference/hosts/demeter/default.nix | 4 +- reference/users/youwen/default.nix | 3 +- 11 files changed, 49 insertions(+), 45 deletions(-) diff --git a/flake.nix b/flake.nix index 977e6c4..88c8cb4 100755 --- a/flake.nix +++ b/flake.nix @@ -106,6 +106,7 @@ nixpkgs, nix-darwin, flake-parts, + self, ... }: let @@ -120,9 +121,13 @@ ]; flake = { nixosConfigurations = { - demeter = buildLiminalOS { - inherit inputs nixpkgs; - systemModule = ./reference/hosts/demeter; + demeter = nixpkgs.lib.nixosSystem { + specialArgs = { + inherit inputs self; + }; + modules = [ + ./reference/hosts/demeter + ]; }; callisto = buildLiminalOS { inherit nixpkgs inputs; @@ -145,6 +150,39 @@ ./hosts/phobos ]; }; + + nixosModules = rec { + default = liminalOS; + liminalOS = { + imports = [ + inputs.nix-flatpak.nixosModules.nix-flatpak + inputs.home-manager.nixosModules.home-manager + inputs.nixos-wsl.nixosModules.default + inputs.stylix.nixosModules.stylix + ./modules/default.nix + ( + { pkgs, ... }: + { + home-manager.extraSpecialArgs = { + spicepkgs = inputs.spicetify.legacyPackages.${pkgs.system}; + inherit inputs self; + }; + } + ) + ]; + }; + }; + + homeManagerModules = rec { + default = liminalOS; + liminalOS = { + imports = [ + inputs.nix-index-database.hmModules.nix-index + inputs.spicetify.homeManagerModules.default + ./hm/modules/default.nix + ]; + }; + }; }; perSystem = { @@ -170,16 +208,6 @@ inputs.viminal.packages.${system}.default ]; }; - - nixosModules = { - default = config.nixosModules.liminalOS; - liminalOS = ./modules/default.nix; - }; - - homeManagerModules = { - default = config.homeManagerModules.liminalOS; - liminalOS = ./hm/modules/default.nix; - }; }; }; } diff --git a/hm/default.nix b/hm/default.nix index 2c3bf2f..c8fac7c 100644 --- a/hm/default.nix +++ b/hm/default.nix @@ -8,10 +8,6 @@ let cfg = config.liminalOS; in { - imports = [ - inputs.home-manager.nixosModules.home-manager - ]; - options.liminalOS.integrateHomeManager = lib.mkOption { type = lib.types.bool; default = cfg.enable; diff --git a/hm/modules/common/shellenv/default.nix b/hm/modules/common/shellenv/default.nix index a6d1d43..c53e52a 100644 --- a/hm/modules/common/shellenv/default.nix +++ b/hm/modules/common/shellenv/default.nix @@ -1,7 +1,6 @@ { config, lib, - inputs, pkgs, osConfig, ... @@ -11,7 +10,6 @@ let in { imports = [ - inputs.nix-index-database.hmModules.nix-index ./fastfetch ]; diff --git a/hm/modules/linux/spicetify/default.nix b/hm/modules/linux/spicetify/default.nix index 985397e..8b43605 100644 --- a/hm/modules/linux/spicetify/default.nix +++ b/hm/modules/linux/spicetify/default.nix @@ -1,19 +1,11 @@ { - inputs, - pkgs, + spicepkgs, config, osConfig, lib, ... }: -let - spicepkgs = inputs.spicetify.legacyPackages.${pkgs.system}; -in { - imports = [ - inputs.spicetify.homeManagerModules.default - ]; - config = lib.mkIf (config.liminalOS.programs.enable && osConfig.liminalOS.config.allowUnfree) { programs.spicetify = { enable = true; diff --git a/modules/default.nix b/modules/default.nix index 0f342f8..e2f8919 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -10,6 +10,7 @@ in { imports = [ ./linux + ../hm ]; options.liminalOS = { darwin.enable = lib.mkOption { diff --git a/modules/linux/core/default.nix b/modules/linux/core/default.nix index ed06c1b..56517dd 100644 --- a/modules/linux/core/default.nix +++ b/modules/linux/core/default.nix @@ -183,8 +183,8 @@ in programs.fish.enable = true; - services.tlp.enable = lib.mkIf (cfg.formFactor == "laptop") true; - programs.light.enable = lib.mkIf (cfg.formFactor == "laptop") true; + services.tlp.enable = lib.mkIf (config.liminalOS.formFactor == "laptop") true; + programs.light.enable = lib.mkIf (config.liminalOS.formFactor == "laptop") true; hardware.bluetooth = lib.mkIf cfg.bluetooth.enable { enable = true; diff --git a/modules/linux/flatpak/default.nix b/modules/linux/flatpak/default.nix index 6c65c41..872cda5 100644 --- a/modules/linux/flatpak/default.nix +++ b/modules/linux/flatpak/default.nix @@ -12,10 +12,6 @@ let cfg = config.liminalOS.programs.flatpak; in { - imports = [ - inputs.nix-flatpak.nixosModules.nix-flatpak - ]; - options.liminalOS.programs.flatpak = { enable = lib.mkOption { type = lib.types.bool; diff --git a/modules/linux/stylix/default.nix b/modules/linux/stylix/default.nix index 52bf4db..aa8d32a 100644 --- a/modules/linux/stylix/default.nix +++ b/modules/linux/stylix/default.nix @@ -26,10 +26,6 @@ in }; }; - imports = [ - inputs.stylix.nixosModules.stylix - ]; - config = lib.mkIf cfg.enable { stylix = { enable = true; diff --git a/modules/linux/wsl/default.nix b/modules/linux/wsl/default.nix index d2f4416..3c90fdf 100644 --- a/modules/linux/wsl/default.nix +++ b/modules/linux/wsl/default.nix @@ -8,10 +8,6 @@ let cfg = config.liminalOS.wsl; in { - imports = [ - inputs.nixos-wsl.nixosModules.default - ]; - options.liminalOS.wsl = { enable = lib.mkEnableOption "WSL"; }; diff --git a/reference/hosts/demeter/default.nix b/reference/hosts/demeter/default.nix index 279603c..f0559a6 100644 --- a/reference/hosts/demeter/default.nix +++ b/reference/hosts/demeter/default.nix @@ -1,13 +1,13 @@ { inputs, + self, ... }: { imports = [ ./configuration.nix - ../../../modules/linux - ../../../hm + self.nixosModules.liminalOS ../../../overlays { home-manager.users.youwen = { diff --git a/reference/users/youwen/default.nix b/reference/users/youwen/default.nix index a133346..f7dcbb8 100644 --- a/reference/users/youwen/default.nix +++ b/reference/users/youwen/default.nix @@ -1,6 +1,7 @@ +{ self, ... }: { imports = [ - ../../../hm/modules + self.homeManagerModules.liminalOS ]; home = {