nix: deduplicate home-manager merging
All checks were successful
Test / Create distribution (push) Successful in 44s
Test / Sandbox (push) Successful in 55s
Test / Sandbox (race detector) (push) Successful in 53s
Test / Fortify (race detector) (push) Successful in 50s
Test / Fpkg (push) Successful in 54s
Test / Fortify (push) Successful in 2m8s
Test / Flake checks (push) Successful in 1m7s
All checks were successful
Test / Create distribution (push) Successful in 44s
Test / Sandbox (push) Successful in 55s
Test / Sandbox (race detector) (push) Successful in 53s
Test / Fortify (race detector) (push) Successful in 50s
Test / Fpkg (push) Successful in 54s
Test / Fortify (push) Successful in 2m8s
Test / Flake checks (push) Successful in 1m7s
This becomes a problem when extraHomeConfig defines nixos module options. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
9a7c81a44e
commit
bf5772bd8a
62
nixos.nix
62
nixos.nix
@ -9,6 +9,7 @@ packages:
|
|||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
lists
|
lists
|
||||||
|
attrsets
|
||||||
mkMerge
|
mkMerge
|
||||||
mkIf
|
mkIf
|
||||||
mapAttrs
|
mapAttrs
|
||||||
@ -231,25 +232,48 @@ in
|
|||||||
{
|
{
|
||||||
useUserPackages = false; # prevent users.users entries from being added
|
useUserPackages = false; # prevent users.users entries from being added
|
||||||
|
|
||||||
users = mkMerge (
|
users =
|
||||||
foldlAttrs (
|
mkMerge
|
||||||
acc: _: fid:
|
(foldlAttrs
|
||||||
acc
|
(
|
||||||
++ foldlAttrs (
|
acc: _: fid:
|
||||||
acc': _: app:
|
foldlAttrs
|
||||||
acc'
|
(
|
||||||
++ [
|
acc: _: app:
|
||||||
{
|
(
|
||||||
${getsubname fid app.identity} = mkMerge [
|
let
|
||||||
cfg.extraHomeConfig
|
key = getsubname fid app.identity;
|
||||||
app.extraConfig
|
in
|
||||||
{ home.packages = app.packages; }
|
{
|
||||||
];
|
usernames = acc.usernames // {
|
||||||
}
|
${key} = true;
|
||||||
]
|
};
|
||||||
) [ { ${getsubname fid 0} = cfg.extraHomeConfig; } ] cfg.apps
|
merge = acc.merge ++ [
|
||||||
) [ privPackages ] cfg.users
|
{
|
||||||
);
|
${key} = mkMerge (
|
||||||
|
[
|
||||||
|
app.extraConfig
|
||||||
|
{ home.packages = app.packages; }
|
||||||
|
]
|
||||||
|
++ lib.optional (!attrsets.hasAttrByPath [ key ] acc.usernames) cfg.extraHomeConfig
|
||||||
|
);
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
inherit (acc) usernames;
|
||||||
|
merge = acc.merge ++ [ { ${getsubname fid 0} = cfg.extraHomeConfig; } ];
|
||||||
|
}
|
||||||
|
cfg.apps
|
||||||
|
)
|
||||||
|
{
|
||||||
|
usernames = { };
|
||||||
|
merge = [ privPackages ];
|
||||||
|
}
|
||||||
|
cfg.users
|
||||||
|
).merge;
|
||||||
};
|
};
|
||||||
|
|
||||||
users =
|
users =
|
||||||
|
@ -95,14 +95,23 @@
|
|||||||
stateDir = "/var/lib/fortify";
|
stateDir = "/var/lib/fortify";
|
||||||
users.alice = 0;
|
users.alice = 0;
|
||||||
|
|
||||||
extraHomeConfig = {
|
extraHomeConfig =
|
||||||
home.stateVersion = "23.05";
|
{ config, ... }:
|
||||||
};
|
{
|
||||||
|
# To test merge deduplication:
|
||||||
|
options._fortify.stateVersion = lib.mkOption { type = lib.types.str; };
|
||||||
|
|
||||||
|
config = {
|
||||||
|
home = { inherit (config._fortify) stateVersion; };
|
||||||
|
_fortify.stateVersion = "23.05";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
apps = {
|
apps = {
|
||||||
"cat.gensokyo.extern.foot.noEnablements" = {
|
"cat.gensokyo.extern.foot.noEnablements" = {
|
||||||
name = "ne-foot";
|
name = "ne-foot";
|
||||||
identity = 1;
|
identity = 1;
|
||||||
|
shareUid = true;
|
||||||
verbose = true;
|
verbose = true;
|
||||||
share = pkgs.foot;
|
share = pkgs.foot;
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
@ -130,7 +139,8 @@
|
|||||||
|
|
||||||
"cat.gensokyo.extern.Alacritty.x11" = {
|
"cat.gensokyo.extern.Alacritty.x11" = {
|
||||||
name = "x11-alacritty";
|
name = "x11-alacritty";
|
||||||
identity = 3;
|
identity = 1;
|
||||||
|
shareUid = true;
|
||||||
verbose = true;
|
verbose = true;
|
||||||
share = pkgs.alacritty;
|
share = pkgs.alacritty;
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
|
@ -206,9 +206,9 @@ machine.wait_until_fails("pgrep foot", timeout=5)
|
|||||||
|
|
||||||
# Test XWayland (foot does not support X):
|
# Test XWayland (foot does not support X):
|
||||||
swaymsg("exec x11-alacritty")
|
swaymsg("exec x11-alacritty")
|
||||||
wait_for_window(f"u0_a{aid(2)}@machine")
|
wait_for_window(f"u0_a{aid(0)}@machine")
|
||||||
machine.send_chars("clear; glinfo && touch /tmp/x11-ok\n")
|
machine.send_chars("clear; glinfo && touch /tmp/x11-ok\n")
|
||||||
machine.wait_for_file(tmpdir_path(2, "x11-ok"), timeout=15)
|
machine.wait_for_file(tmpdir_path(0, "x11-ok"), timeout=15)
|
||||||
collect_state_ui("alacritty_x11")
|
collect_state_ui("alacritty_x11")
|
||||||
check_state("x11-alacritty", 2)
|
check_state("x11-alacritty", 2)
|
||||||
machine.send_chars("exit\n")
|
machine.send_chars("exit\n")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user