wip: home-manager support
This commit is contained in:
parent
4d6fdba390
commit
9e4d359699
3 changed files with 48 additions and 8 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
{ core-inputs, user-inputs, snowfall-lib }:
|
{ core-inputs, user-inputs, snowfall-lib }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (core-inputs.nixpkgs.lib) assertMsg foldl head tail concatMap optionalAttrs mkIf filterAttrs mapAttrs' mkMerge mapAttrsToList optionals mkDefault;
|
inherit (core-inputs.nixpkgs.lib) assertMsg foldl head tail concatMap optionalAttrs mkIf filterAttrs mapAttrs' mkMerge mapAttrsToList optionals mkDefault mkAliasDefinitions;
|
||||||
|
|
||||||
user-homes-root = snowfall-lib.fs.get-snowfall-file "homes";
|
user-homes-root = snowfall-lib.fs.get-snowfall-file "homes";
|
||||||
user-modules-root = snowfall-lib.fs.get-snowfall-file "modules";
|
user-modules-root = snowfall-lib.fs.get-snowfall-file "modules";
|
||||||
|
|
@ -57,7 +57,10 @@ in
|
||||||
|
|
||||||
output = "homeConfigurations";
|
output = "homeConfigurations";
|
||||||
|
|
||||||
modules = [ path ] ++ modules;
|
modules = [
|
||||||
|
path
|
||||||
|
../../modules/home/user/default.nix
|
||||||
|
] ++ modules;
|
||||||
|
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit name;
|
inherit name;
|
||||||
|
|
@ -80,6 +83,9 @@ in
|
||||||
(module-args: import ./nix-registry-module.nix (module-args // {
|
(module-args: import ./nix-registry-module.nix (module-args // {
|
||||||
inherit user-inputs core-inputs;
|
inherit user-inputs core-inputs;
|
||||||
}))
|
}))
|
||||||
|
({
|
||||||
|
snowfallorg.user.name = mkDefault user-metadata.user;
|
||||||
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
extraSpecialArgs = specialArgs // args.specialArgs;
|
extraSpecialArgs = specialArgs // args.specialArgs;
|
||||||
|
|
@ -180,7 +186,7 @@ in
|
||||||
|
|
||||||
# @NOTE(jakehamilton): We *must* specify named attributes here in order
|
# @NOTE(jakehamilton): We *must* specify named attributes here in order
|
||||||
# for home-manager to provide them.
|
# for home-manager to provide them.
|
||||||
wrapped-user-module = home-args@{ pkgs, lib, ... }:
|
wrapped-user-module = home-args@{ pkgs, lib, osConfig ? {}, ... }:
|
||||||
let
|
let
|
||||||
user-module-result = import user-module home-args;
|
user-module-result = import user-module home-args;
|
||||||
user-imports =
|
user-imports =
|
||||||
|
|
@ -193,6 +199,7 @@ in
|
||||||
user-module-result.config
|
user-module-result.config
|
||||||
else
|
else
|
||||||
builtins.removeAttrs user-module-result [ "imports" "options" "_file" ];
|
builtins.removeAttrs user-module-result [ "imports" "options" "_file" ];
|
||||||
|
user = created-user.specialArgs.user;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
_file = builtins.toString user-module;
|
_file = builtins.toString user-module;
|
||||||
|
|
@ -201,8 +208,9 @@ in
|
||||||
config = mkMerge [
|
config = mkMerge [
|
||||||
user-config
|
user-config
|
||||||
({
|
({
|
||||||
snowfallorg.user.name = mkDefault created-user.specialArgs.user;
|
snowfallorg.user.name = mkDefault user;
|
||||||
})
|
})
|
||||||
|
(osConfig.snowfallorg.home.resolvedHomes.${user} or {})
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
|
@ -212,9 +220,7 @@ in
|
||||||
config = mkIf host-matches {
|
config = mkIf host-matches {
|
||||||
home-manager = {
|
home-manager = {
|
||||||
users.${user-name} = wrapped-user-module;
|
users.${user-name} = wrapped-user-module;
|
||||||
sharedModules = other-modules ++ [
|
sharedModules = other-modules;
|
||||||
../../modules/home/user/default.nix
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -100,10 +100,13 @@ in
|
||||||
darwin-system-builder = args:
|
darwin-system-builder = args:
|
||||||
assert assertMsg (user-inputs ? darwin) "In order to create virtual systems, you must include `darwin` as a flake input.";
|
assert assertMsg (user-inputs ? darwin) "In order to create virtual systems, you must include `darwin` as a flake input.";
|
||||||
user-inputs.darwin.lib.darwinSystem
|
user-inputs.darwin.lib.darwinSystem
|
||||||
((builtins.removeAttrs args [ "system" ]) // {
|
((builtins.removeAttrs args [ "system" "modules" ]) // {
|
||||||
specialArgs = args.specialArgs // {
|
specialArgs = args.specialArgs // {
|
||||||
format = "darwin";
|
format = "darwin";
|
||||||
};
|
};
|
||||||
|
modules = args.modules ++ [
|
||||||
|
../../modules/darwin/home/default.nix
|
||||||
|
];
|
||||||
});
|
});
|
||||||
linux-system-builder = args:
|
linux-system-builder = args:
|
||||||
core-inputs.nixpkgs.lib.nixosSystem
|
core-inputs.nixpkgs.lib.nixosSystem
|
||||||
|
|
|
||||||
31
modules/darwin/home/default.nix
Normal file
31
modules/darwin/home/default.nix
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
{ lib, options, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (lib) types mkOption mkIf mkMerge mkAliasDefinitions;
|
||||||
|
|
||||||
|
cfg = options.snowfallorg;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.snowfallorg = {
|
||||||
|
home = mkOption {
|
||||||
|
description = "Configuration for home-manager.";
|
||||||
|
type = types.attrsOf (types.submodule ({ name, ... }: {
|
||||||
|
options.config = {
|
||||||
|
type = types.attrs;
|
||||||
|
default = { };
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
resolvedHomes = mkOption {
|
||||||
|
type = types.attrs;
|
||||||
|
default = { };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkMerge (builtins.map
|
||||||
|
(name: {
|
||||||
|
snowfallorg.resolvedHomes.${name} = mkAliasDefinitions options.snowfallorg.home.${name}.config;
|
||||||
|
})
|
||||||
|
(builtins.attrNames cfg.home));
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue