fix: pass home specialArgs to home in nixos module

This commit is contained in:
Jake Hamilton 2024-02-23 09:51:32 -08:00
parent 9b718da230
commit 11476c3b90
No known key found for this signature in database
GPG key ID: 9762169A1B35EA68
4 changed files with 14 additions and 8 deletions

View file

@ -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;

View file

@ -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 =

View file

@ -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.<name>.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 = {

View file

@ -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,