From 22d431e2712e0b90c00847f44b768f7b9c2f6469 Mon Sep 17 00:00:00 2001 From: Grey Jones Date: Fri, 28 Aug 2026 05:26:46 +0100 Subject: [PATCH] refactor to fix dependency on 'osConfig' arg --- modules/components/shells/noctalia.nix | 40 +++++++++---------- modules/components/window-managers/niri.nix | 18 ++++----- modules/features/applications/gui/floorp.nix | 12 ++++-- modules/features/applications/gui/kitty.nix | 8 +++- .../features/applications/gui/nautilus.nix | 10 ++++- modules/features/applications/gui/vscode.nix | 8 +++- modules/features/shells/zsh.nix | 13 ++++-- modules/global/helpers.nix | 14 +------ modules/global/home.nix | 8 ++-- modules/global/options.nix | 5 +++ modules/hosts/takamaki/takamaki.nix | 5 +++ 11 files changed, 86 insertions(+), 55 deletions(-) diff --git a/modules/components/shells/noctalia.nix b/modules/components/shells/noctalia.nix index 7bcb4de..5dcf8aa 100644 --- a/modules/components/shells/noctalia.nix +++ b/modules/components/shells/noctalia.nix @@ -6,26 +6,26 @@ ]; programs.noctalia.enable = true; + + home-manager.sharedModules = [ + { + home.activation = { + symlinkNoctaliaState = lib.hm.dag.entryAfter ["writeBoundary"] (config.helpers.mkSymlinkActivationScript { + target = ".local/state/noctalia/settings.toml"; + source = "dotfiles/${config.info.hostName}/noctalia/settings.toml"; + }); + + symlinkNoctaliaStatePlugins = lib.hm.dag.entryAfter ["writeBoundary"] (config.helpers.mkSymlinkActivationScript { + target = ".local/state/noctalia/plugins"; + source = "dotfiles/${config.info.hostName}/noctalia/plugins"; + isDir = true; + }); + }; + + xdg.configFile."noctalia/settings.toml".source = "${self}/dotfiles/${config.info.hostName}/noctalia/settings.toml"; + xdg.configFile."noctalia/plugins".source = "${self}/dotfiles/${config.info.hostName}/noctalia/plugins"; + } + ]; }; }; - - flake.homeModules.graphics = { lib, pkgs, osConfig, config, ... }: { - config = lib.mkIf (builtins.tryEval osConfig).success (lib.mkIf ((osConfig.components.shells == "noctalia")||(builtins.elem "noctalia" osConfig.components.shells)) { - home.activation = { - symlinkNoctaliaState = lib.hm.dag.entryAfter ["writeBoundary"] (config.helpers.mkSymlinkActivationScript { - target = ".local/state/noctalia/settings.toml"; - source = "dotfiles/${config.info.hostName}/noctalia/settings.toml"; - }); - - symlinkNoctaliaStatePlugins = lib.hm.dag.entryAfter ["writeBoundary"] (config.helpers.mkSymlinkActivationScript { - target = ".local/state/noctalia/plugins"; - source = "dotfiles/${config.info.hostName}/noctalia/plugins"; - isDir = true; - }); - }; - - xdg.configFile."noctalia/settings.toml".source = "${self}/dotfiles/${config.info.hostName}/noctalia/settings.toml"; - xdg.configFile."noctalia/plugins".source = "${self}/dotfiles/${config.info.hostName}/noctalia/plugins"; - }); - }; } \ No newline at end of file diff --git a/modules/components/window-managers/niri.nix b/modules/components/window-managers/niri.nix index 5aed825..72ce305 100644 --- a/modules/components/window-managers/niri.nix +++ b/modules/components/window-managers/niri.nix @@ -36,15 +36,15 @@ } )); }; + + home-manager.sharedModules = [ + { + home.activation.symlinkNiriConfig = lib.hm.dag.entryAfter ["writeBoundary"] (config.helpers.mkSymlinkActivationScript { + target = ".config/niri/config.kdl"; + source = "dotfiles/${config.info.hostName}/niri.kdl"; + }); + } + ]; }; }; - - flake.homeModules.graphics = { lib, osConfig, config, ... }: { - config = lib.mkIf (builtins.tryEval osConfig).success (lib.mkIf ((osConfig.components.windowManagers == "niri")||(builtins.elem "niri" osConfig.components.windowManagers)) { - home.activation.symlinkNiriConfig = lib.hm.dag.entryAfter ["writeBoundary"] (config.helpers.mkSymlinkActivationScript { - target = ".config/niri/config.kdl"; - source = "dotfiles/${config.info.hostName}/niri.kdl"; - }); - }); - }; } \ No newline at end of file diff --git a/modules/features/applications/gui/floorp.nix b/modules/features/applications/gui/floorp.nix index b7f96f3..2bf10da 100644 --- a/modules/features/applications/gui/floorp.nix +++ b/modules/features/applications/gui/floorp.nix @@ -1,13 +1,19 @@ { inputs, self, ... }: { - flake.homeModules.graphics = { pkgs, lib, config, osConfig, ... }: { + flake.nixosModules.graphics = { pkgs, lib, config, ... }: { + home-manager.sharedModules = lib.mkIf (config.features.nixos.stylix.enable) [ + ({ config, lib, ... }: { + stylix.targets.floorp.profileNames = lib.mkIf (config.features.applications.gui.floorp.enable) [ "default" ]; + }) + ]; + }; + + flake.homeModules.graphics = { pkgs, lib, config, ... }: { options.features.applications.gui.floorp.enable = lib.mkEnableOption "floorp"; config = lib.mkIf (config.features.applications.gui.floorp.enable) ( let firefox-addons = with pkgs; inputs.firefox-addons.packages.${system}; in { - stylix.targets.floorp.profileNames = [ "default" ]; - programs.floorp = { enable = true; nativeMessagingHosts = [ diff --git a/modules/features/applications/gui/kitty.nix b/modules/features/applications/gui/kitty.nix index 8fda5c1..a910a09 100644 --- a/modules/features/applications/gui/kitty.nix +++ b/modules/features/applications/gui/kitty.nix @@ -1,10 +1,16 @@ { inputs, self, ... }: { flake.nixosModules.graphics = { pkgs, config, lib, ... }: { options.features.applications.gui.kitty.enable = lib.mkEnableOption "kitty"; + + config.home-manager.sharedModules = lib.mkIf (config.features.applications.gui.kitty.enable) [ + { + features.applications.gui.kitty.enable = true; + } + ]; }; flake.homeModules.graphics = { pkgs, config, lib, ... }: { - options.features.applications.gui.kitty.enable = lib.mkOption (config.helpers.inheritOsConfigToHome "features.applications.gui.kitty.enable"); + options.features.applications.gui.kitty.enable = lib.mkEnableOption "kitty"; config = lib.mkIf (config.features.applications.gui.kitty.enable) { programs.kitty = { diff --git a/modules/features/applications/gui/nautilus.nix b/modules/features/applications/gui/nautilus.nix index 4941d89..e447af4 100644 --- a/modules/features/applications/gui/nautilus.nix +++ b/modules/features/applications/gui/nautilus.nix @@ -16,11 +16,17 @@ enable = true; terminal = "kitty"; }; + + home-manager.sharedModules = [ + { + features.applications.gui.nautilus.enable = true; + } + ]; }; }; - flake.homeModules.graphics = { pkgs, osConfig, config, lib, ... }: { - options.features.applications.gui.nautilus.enable = lib.mkOption (config.helpers.inheritOsConfigToHome "features.applications.gui.nautilus.enable"); + flake.homeModules.graphics = { pkgs, config, lib, ... }: { + options.features.applications.gui.nautilus.enable = lib.mkEnableOption "nautilus"; config = lib.mkIf (config.features.applications.gui.nautilus.enable) { gtk.gtk3.bookmarks = [ diff --git a/modules/features/applications/gui/vscode.nix b/modules/features/applications/gui/vscode.nix index 7128b09..1adccb1 100644 --- a/modules/features/applications/gui/vscode.nix +++ b/modules/features/applications/gui/vscode.nix @@ -1,10 +1,16 @@ { inputs, self, ... }: { flake.nixosModules.graphics = { config, pkgs, lib, ... }: { options.features.applications.gui.vscode.enable = lib.mkEnableOption "vscode"; + + config.home-manager.sharedModules = lib.mkIf (config.features.applications.gui.vscode.enable) [ + { + features.applications.gui.vscode.enable = true; + } + ]; }; flake.homeModules.graphics = { config, pkgs, lib, ... }: { - options.features.applications.gui.vscode.enable = lib.mkOption (config.helpers.inheritOsConfigToHome "features.applications.gui.vscode.enable"); + options.features.applications.gui.vscode.enable = lib.mkEnableOption "vscode"; config = lib.mkIf (config.features.applications.gui.vscode.enable) { home.packages = [ pkgs.vscode ]; diff --git a/modules/features/shells/zsh.nix b/modules/features/shells/zsh.nix index ea40a61..56e4eca 100644 --- a/modules/features/shells/zsh.nix +++ b/modules/features/shells/zsh.nix @@ -9,16 +9,23 @@ programs.zsh.enable = true; users.defaultUserShell = pkgs.zsh; users.users."grey".shell = pkgs.zsh; + + home-manager.sharedModules = [ + { + features.shells.zsh.enable = true; + features.shells.zsh.antidote.enable = lib.mkIf (config.features.shells.zsh.antidote.enable) true; + } + ]; }; }; - flake.homeModules.global = { pkgs, osConfig, config, lib, ... }: { + flake.homeModules.global = { pkgs, config, lib, ... }: { options.features.shells.zsh = { enable = lib.mkEnableOption "zsh"; antidote.enable = lib.mkEnableOption "antidote"; }; - config = (if (builtins.tryEval osConfig).success then (lib.mkIf (osConfig.features.shells.zsh.enable || config.features.shells.zsh.enable)) else (lib.mkIf (config.features.shells.zsh.enable))) { + config = lib.mkIf (config.features.shells.zsh.enable) { home.shell.enableZshIntegration = true; programs.kitty.shellIntegration.enableZshIntegration = true; @@ -26,7 +33,7 @@ programs.zsh = { enable = true; completionInit = ""; - antidote = (if (builtins.tryEval osConfig).success then (lib.mkIf (osConfig.features.shells.zsh.antidote.enable || config.features.shells.zsh.antidote.enable)) else (lib.mkIf (config.features.shells.zsh.antidote.enable))) { + antidote = lib.mkIf (config.features.shells.zsh.antidote.enable) { enable = true; plugins = [ "getantidote/use-omz" diff --git a/modules/global/helpers.nix b/modules/global/helpers.nix index 9b7de6a..7bcde01 100644 --- a/modules/global/helpers.nix +++ b/modules/global/helpers.nix @@ -31,7 +31,7 @@ }; }; - flake.homeModules.global = { pkgs, config, osConfig, lib, ... }: { + flake.homeModules.global = { pkgs, config, lib, ... }: { options.helpers = { mkSymlinkActivationScript = lib.mkOption { type = lib.types.functionTo lib.types.str; @@ -43,18 +43,6 @@ ''; readOnly = true; }; - - inheritOsConfigToHome = lib.mkOption { - type = lib.types.functionTo lib.types.attrs; - default = let - safeOsConfig = builtins.tryEval osConfig; - in option: { - type = if safeOsConfig.success then safeOsConfig.value.helpers.attrByStrPath (safeOsConfig.value.helpers.typeOf (safeOsConfig.value.helpers.attrByStrPath option safeOsConfig.value)) lib.types else null; - default = (lib.mkIf (safeOsConfig.success) (safeOsConfig.value.helpers.attrByStrPath option safeOsConfig.value)).content; - readOnly = true; - }; - readOnly = true; - }; }; }; } \ No newline at end of file diff --git a/modules/global/home.nix b/modules/global/home.nix index 05123e3..f8e8c52 100644 --- a/modules/global/home.nix +++ b/modules/global/home.nix @@ -1,18 +1,20 @@ { inputs, self, ... }: { - flake.homeModules.global = { config, pkgs, osConfig, ... }: { + flake.homeModules.global = { config, pkgs, ... }: { nix.gc = { automatic = true; persistent = true; dates = "Sun 05:00"; }; + nixpkgs.config.allowUnfree = true; + home = { stateVersion = config.info.stateVersion; packages = with pkgs; [ speedtest-go ] ++ config.features.applications.extraPackages - ++ (if !(builtins.tryEval osConfig).success then [ + ++ (if config.info.isStandalone then [ pkgs.home-manager ] else []); @@ -24,7 +26,7 @@ xdg = { enable = true; - localBinInPath = !(builtins.tryEval osConfig).success; + localBinInPath = true; }; programs = { diff --git a/modules/global/options.nix b/modules/global/options.nix index 01db747..fb721a5 100644 --- a/modules/global/options.nix +++ b/modules/global/options.nix @@ -49,6 +49,11 @@ type = lib.types.str; default = ""; }; + + isStandalone = lib.mkOption { + type = lib.types.bool; + default = false; + }; }; features.applications.extraPackages = lib.mkOption { diff --git a/modules/hosts/takamaki/takamaki.nix b/modules/hosts/takamaki/takamaki.nix index f11ef19..eb0e434 100644 --- a/modules/hosts/takamaki/takamaki.nix +++ b/modules/hosts/takamaki/takamaki.nix @@ -13,6 +13,7 @@ rootPath = "/home/grey/flake"; hostName = "takamaki"; stateVersion = "26.11"; + isStandalone = true; }; features = { @@ -26,6 +27,10 @@ fastfetch.enable = true; }; + gui = { + vscode.enable = true; + }; + extraPackages = with pkgs; [ (writeShellScriptBin "switch-os" '' sudo efibootmgr --bootnext 0000