From 11476c3b905e88a6fbf9430465d7b0d03e1c5799 Mon Sep 17 00:00:00 2001 From: Jake Hamilton Date: Fri, 23 Feb 2024 09:51:32 -0800 Subject: [PATCH] fix: pass home specialArgs to home in nixos module --- modules/home/user/default.nix | 2 +- modules/nixos/user/default.nix | 2 +- snowfall-lib/home/default.nix | 16 +++++++++++----- snowfall-lib/system/virtual-systems.nix | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/modules/home/user/default.nix b/modules/home/user/default.nix index 9ea443b..4f04b62 100644 --- a/modules/home/user/default.nix +++ b/modules/home/user/default.nix @@ -9,7 +9,7 @@ inputs @ { cfg = config.snowfallorg; - # @NOTE(jakehamilton): The module system chokes if it finds `osConfig` named in the module arguments + # NOTE: The module system chokes if it finds `osConfig` named in the module arguments # when being used in standalone home-manager. To remedy this, we have to refer to the arguments set directly. os-user-home = inputs.osConfig.users.users.${cfg.name}.home or null; diff --git a/modules/nixos/user/default.nix b/modules/nixos/user/default.nix index d1d195b..9e11060 100644 --- a/modules/nixos/user/default.nix +++ b/modules/nixos/user/default.nix @@ -62,7 +62,7 @@ in { config = mkOption { # HM-compatible options taken from: # https://github.com/nix-community/home-manager/blob/0ee5ab611dc1fbb5180bd7d88d2aeb7841a4d179/nixos/common.nix#L14 - # @NOTE(jakehamilton): This has been adapted to support documentation generation without + # NOTE: This has been adapted to support documentation generation without # having home-manager options fully declared. type = types.submoduleWith { specialArgs = diff --git a/snowfall-lib/home/default.nix b/snowfall-lib/home/default.nix index f928063..8d0a386 100644 --- a/snowfall-lib/home/default.nix +++ b/snowfall-lib/home/default.nix @@ -32,13 +32,13 @@ in { home = rec { # Modules in home-manager expect `hm` to be available directly on `lib` itself. home-lib = - # @NOTE(jakehamilton): This prevents an error during evaluation if the input does + # NOTE: This prevents an error during evaluation if the input does # not exist. if user-inputs ? home-manager then snowfall-lib.internal.system-lib.extend (final: prev: - # @NOTE(jakehamilton): This order is important, this library's extend and other utilities must write + # NOTE: This order is important, this library's extend and other utilities must write # _over_ the original `system-lib`. snowfall-lib.internal.system-lib // prev @@ -90,7 +90,7 @@ in { }: let user-metadata = split-user-and-host name; - # @NOTE(jakehamilton): home-manager has trouble with `pkgs` recursion if it isn't passed in here. + # NOTE: home-manager has trouble with `pkgs` recursion if it isn't passed in here. pkgs = user-inputs.self.pkgs.${system}.${channelName} // {lib = home-lib;}; lib = home-lib; in @@ -115,7 +115,7 @@ in { inputs = snowfall-lib.flake.without-src user-inputs; - # @NOTE(jakehamilton): home-manager has trouble with `pkgs` recursion if it isn't passed in here. + # NOTE: home-manager has trouble with `pkgs` recursion if it isn't passed in here. inherit pkgs lib; }; @@ -294,7 +294,7 @@ in { }: let host-matches = created-user.specialArgs.host == host; - # @NOTE(jakehamilton): To conform to the config structure of home-manager, we have to + # NOTE: To conform to the config structure of home-manager, we have to # remap the options coming from `snowfallorg.user..home.config` since `mkAliasDefinitions` # does not let us target options within a submodule. wrap-user-options = user-option: @@ -333,6 +333,12 @@ in { enable = true; name = mkDefault user-name; }; + + # NOTE: specialArgs are not propagated by Home-Manager without this. + # However, not all specialArgs values can be set when using `_module.args`. + _module.args = + builtins.removeAttrs (users.users.${name}.specialArgs or {}) + ["options" "config" "lib" "pkgs" "specialArgs"]; }; home-manager = { diff --git a/snowfall-lib/system/virtual-systems.nix b/snowfall-lib/system/virtual-systems.nix index b7dac48..af0f548 100644 --- a/snowfall-lib/system/virtual-systems.nix +++ b/snowfall-lib/system/virtual-systems.nix @@ -1,4 +1,4 @@ -# @NOTE(jakehamilton): The order of these entries matters. We search them +# NOTE: The order of these entries matters. We search them # from start to finish and only match based on whether they appear in a # system target. This means that entries like "vm" would match all cases # of "vm-bootloader", "vm-no-gui", and "vmware". To avoid this mismatch,