From 8424b025f69c1f41be8be301dd171d24d51ac7e2 Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Wed, 25 Dec 2024 22:33:04 -0800 Subject: [PATCH] refactor: do not depend on inputs for modules --- flake.nix | 46 ++++++++++++++------ hm/default.nix | 7 +-- hm/modules/common/shellenv/default.nix | 4 +- hm/modules/linux/platform-tweaks/default.nix | 3 -- hm/modules/linux/programs/default.nix | 6 +-- hm/modules/linux/spicetify/default.nix | 6 +-- modules/linux/flatpak/default.nix | 4 +- modules/linux/misc/default.nix | 3 ++ modules/linux/stylix/default.nix | 39 ++++++++++++++--- modules/linux/wsl/default.nix | 4 +- reference/hosts/demeter/configuration.nix | 4 ++ 11 files changed, 87 insertions(+), 39 deletions(-) diff --git a/flake.nix b/flake.nix index 977e6c4..91290b4 100755 --- a/flake.nix +++ b/flake.nix @@ -118,11 +118,17 @@ # "aarch64-darwin" # aarch64-darwin is currently disabled due to lack of maintenance ]; - flake = { + flake = rec { nixosConfigurations = { - demeter = buildLiminalOS { - inherit inputs nixpkgs; - systemModule = ./reference/hosts/demeter; + demeter = nixpkgs.lib.nixosSystem { + specialArgs = { + liminalSystemModules = nixosModules; + liminalHomeManagerModules = homeManagerModules; + inherit inputs; + }; + modules = [ + ./reference/hosts/demeter + ]; }; callisto = buildLiminalOS { inherit nixpkgs inputs; @@ -145,12 +151,33 @@ ./hosts/phobos ]; }; + + nixosModules = rec { + inherit (inputs) + home-manager + nixos-wsl + stylix + nix-flatpak + ; + default = liminalOS; + liminalOS = ./modules/default.nix; + }; + + homeManagerModules = rec { + inherit (inputs) + spicetify + stylix + nix-index-database + zen-browser + ; + default = liminalOS; + liminalOS = ./hm/modules/default.nix; + }; }; perSystem = { pkgs, system, - config, ... }: { @@ -171,15 +198,6 @@ ]; }; - 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..ef23ee1 100644 --- a/hm/default.nix +++ b/hm/default.nix @@ -1,5 +1,6 @@ { - inputs, + liminalHomeManagerModules, + liminalSystemModules, config, lib, ... @@ -9,7 +10,7 @@ let in { imports = [ - inputs.home-manager.nixosModules.home-manager + liminalSystemModules.home-manager.nixosModules.home-manager ]; options.liminalOS.integrateHomeManager = lib.mkOption { @@ -24,6 +25,6 @@ in useGlobalPkgs = true; useUserPackages = true; backupFileExtension = "backup"; - extraSpecialArgs = { inherit inputs; }; + extraSpecialArgs = { inherit liminalHomeManagerModules; }; }; } diff --git a/hm/modules/common/shellenv/default.nix b/hm/modules/common/shellenv/default.nix index a6d1d43..258e3c7 100644 --- a/hm/modules/common/shellenv/default.nix +++ b/hm/modules/common/shellenv/default.nix @@ -1,7 +1,7 @@ { config, lib, - inputs, + liminalHomeManagerModules, pkgs, osConfig, ... @@ -11,7 +11,7 @@ let in { imports = [ - inputs.nix-index-database.hmModules.nix-index + liminalHomeManagerModules.nix-index-database.hmModules.nix-index ./fastfetch ]; diff --git a/hm/modules/linux/platform-tweaks/default.nix b/hm/modules/linux/platform-tweaks/default.nix index 4a389e4..93f4723 100644 --- a/hm/modules/linux/platform-tweaks/default.nix +++ b/hm/modules/linux/platform-tweaks/default.nix @@ -1,5 +1,4 @@ { - inputs, lib, config, osConfig, @@ -25,8 +24,6 @@ in }; config = { - services.tlp.enable = lib.mkIf (cfg.formFactor == "laptop") true; - programs.light.enable = lib.mkIf (cfg.formFactor == "laptop") true; assertions = [ { assertion = cfg.formFactor != null; diff --git a/hm/modules/linux/programs/default.nix b/hm/modules/linux/programs/default.nix index 961a43f..94ccbd3 100644 --- a/hm/modules/linux/programs/default.nix +++ b/hm/modules/linux/programs/default.nix @@ -1,6 +1,6 @@ { pkgs, - inputs, + liminalHomeManagerModules, config, lib, ... @@ -85,11 +85,11 @@ in }; home.packages = lib.mkIf cfg.zen.enable [ - inputs.zen-browser.packages.${pkgs.system}.default + liminalHomeManagerModules.zen-browser.packages.${pkgs.system}.default ]; home.sessionVariables.DEFAULT_BROWSER = lib.mkIf cfg.zen.enable "${ - inputs.zen-browser.packages.${pkgs.system}.default + liminalHomeManagerModules.zen-browser.packages.${pkgs.system}.default }/bin/zen"; }; } diff --git a/hm/modules/linux/spicetify/default.nix b/hm/modules/linux/spicetify/default.nix index 985397e..693e4f4 100644 --- a/hm/modules/linux/spicetify/default.nix +++ b/hm/modules/linux/spicetify/default.nix @@ -1,5 +1,5 @@ { - inputs, + liminalHomeManagerModules, pkgs, config, osConfig, @@ -7,11 +7,11 @@ ... }: let - spicepkgs = inputs.spicetify.legacyPackages.${pkgs.system}; + spicepkgs = liminalHomeManagerModules.spicetify.legacyPackages.${pkgs.system}; in { imports = [ - inputs.spicetify.homeManagerModules.default + liminalHomeManagerModules.spicetify.homeManagerModules.default ]; config = lib.mkIf (config.liminalOS.programs.enable && osConfig.liminalOS.config.allowUnfree) { diff --git a/modules/linux/flatpak/default.nix b/modules/linux/flatpak/default.nix index 6c65c41..f84a150 100644 --- a/modules/linux/flatpak/default.nix +++ b/modules/linux/flatpak/default.nix @@ -3,7 +3,7 @@ # persist between generations. This is not ideal, but at least it is a better # situation than imperative installation { - inputs, + liminalSystemModules, config, lib, ... @@ -13,7 +13,7 @@ let in { imports = [ - inputs.nix-flatpak.nixosModules.nix-flatpak + liminalSystemModules.nix-flatpak.nixosModules.nix-flatpak ]; options.liminalOS.programs.flatpak = { diff --git a/modules/linux/misc/default.nix b/modules/linux/misc/default.nix index b23d6ce..b9af25f 100644 --- a/modules/linux/misc/default.nix +++ b/modules/linux/misc/default.nix @@ -103,6 +103,9 @@ in ) ); + services.tlp.enable = lib.mkIf (cfg.formFactor == "laptop") true; + programs.light.enable = lib.mkIf (cfg.formFactor == "laptop") true; + environment.variables.EDITOR = lib.mkIf ( cfg.defaultEditor != null ) cfg.defaultEditor.meta.mainProgram; diff --git a/modules/linux/stylix/default.nix b/modules/linux/stylix/default.nix index 52bf4db..532e745 100644 --- a/modules/linux/stylix/default.nix +++ b/modules/linux/stylix/default.nix @@ -1,5 +1,5 @@ { - inputs, + liminalSystemModules, pkgs, config, lib, @@ -24,20 +24,45 @@ in Whether to enable plymouth and sane defaults. ''; }; + wallpaper = lib.mkOption { + type = lib.types.path; + default = "../../../hm/modules/common/shellenv/fastfetch/nixos-logo.png"; + description = '' + Path to wallpaper to set as background and generate system colorscehme from. + ''; + }; + polarity = lib.mkOption { + type = lib.types.nullOr ( + lib.types.enum [ + "light" + "dark" + ] + ); + default = null; + description = '' + Whether to force colorscheme to be generated as light or dark theme. Set to null to automatically determine. + ''; + }; + base16Scheme = lib.mkOption { + type = lib.types.nullOr lib.types.path; + default = null; + description = '' + Base 16 colorscheme from base16-schemes to override wallpaper generated colorscheme with. Set to null to use wallpaper generated scheme. + Example: ''${pkgs.base16-schemes}/share/themes/rose-pine.yaml + ''; + }; }; imports = [ - inputs.stylix.nixosModules.stylix + liminalSystemModules.stylix.nixosModules.stylix ]; config = lib.mkIf cfg.enable { stylix = { enable = true; - image = "${inputs.wallpapers}/aesthetic/afterglow_city_skyline_at_night.png"; - # image = "${inputs.wallpapers}/aesthetic/red_deadly_sun.jpg"; - # image = "${inputs.wallpapers}/aesthetic/afterglow_sand_dunes.jpg"; - base16Scheme = "${pkgs.base16-schemes}/share/themes/rose-pine.yaml"; - polarity = "dark"; + image = lib.mkIf (cfg.wallpaper != null) cfg.wallpaper; + base16Scheme = lib.mkIf (cfg.base16Scheme != null) cfg.base16Scheme; + polarity = lib.mkIf (cfg.polarity != null) cfg.polarity; fonts = { serif = { diff --git a/modules/linux/wsl/default.nix b/modules/linux/wsl/default.nix index d2f4416..b0e9d19 100644 --- a/modules/linux/wsl/default.nix +++ b/modules/linux/wsl/default.nix @@ -1,5 +1,5 @@ { - inputs, + liminalSystemModules, config, lib, ... @@ -9,7 +9,7 @@ let in { imports = [ - inputs.nixos-wsl.nixosModules.default + liminalSystemModules.nixos-wsl.nixosModules.default ]; options.liminalOS.wsl = { diff --git a/reference/hosts/demeter/configuration.nix b/reference/hosts/demeter/configuration.nix index aa63bad..8080587 100755 --- a/reference/hosts/demeter/configuration.nix +++ b/reference/hosts/demeter/configuration.nix @@ -19,6 +19,10 @@ config.allowUnfree = true; defaultEditor = inputs.viminal.packages.${pkgs.system}.default; formFactor = "desktop"; + theming = { + wallpaper = "${inputs.wallpapers}/aesthetic/afterglow_city_skyline_at_night.png"; + base16Scheme = "${pkgs.base16-schemes}/share/themes/rose-pine.yaml"; + }; system = { audio.prod.enable = true; networking = {