From 8a05332caca00e65082f6e9ac79225f7b0a766f9 Mon Sep 17 00:00:00 2001 From: Victor Borja Date: Mon, 16 Mar 2026 19:31:01 -0600 Subject: [PATCH] fix(ctx): Fix #292, using hm from host with no-bidir enabled. --- modules/context/user.nix | 1 + nix/lib/home-env.nix | 1 - .../modules/features/conditional-config.nix | 1 + ...ssue-292-hm-used-when-no-bidir-enabled.nix | 27 ++++++ .../ci/modules/features/perUser-perHost.nix | 1 + .../user-host-bidirectional-config.nix | 90 ++++++++++++++++--- 6 files changed, 106 insertions(+), 15 deletions(-) create mode 100644 templates/ci/modules/features/deadbugs/issue-292-hm-used-when-no-bidir-enabled.nix diff --git a/modules/context/user.nix b/modules/context/user.nix index 82094db2a..2b052bbca 100644 --- a/modules/context/user.nix +++ b/modules/context/user.nix @@ -76,6 +76,7 @@ let from-user = { host, user }: fixedTo { inherit host user; } den.aspects.${user.aspect}; from-host = { host, user }: atLeast den.aspects.${host.aspect} { inherit host user; }; + in { den.ctx = ctx; diff --git a/nix/lib/home-env.nix b/nix/lib/home-env.nix index 0e8ff4d66..67a84d255 100644 --- a/nix/lib/home-env.nix +++ b/nix/lib/home-env.nix @@ -72,7 +72,6 @@ let includes = [ (den.ctx."${ctxName}-user" { inherit host user; }) (den.ctx.user { inherit host user; }) - (den.lib.parametric.fixedTo { inherit host user; } den.aspects.${host.aspect}) ]; }; diff --git a/templates/ci/modules/features/conditional-config.nix b/templates/ci/modules/features/conditional-config.nix index 5f83ff5a4..6b042ffbb 100644 --- a/templates/ci/modules/features/conditional-config.nix +++ b/templates/ci/modules/features/conditional-config.nix @@ -69,6 +69,7 @@ pingu = { }; }; den.default.homeManager.home.stateVersion = "25.11"; + den.ctx.user.includes = [ den._.bidirectional ]; den.aspects.igloo.includes = [ git-for-linux-only ]; expr = [ diff --git a/templates/ci/modules/features/deadbugs/issue-292-hm-used-when-no-bidir-enabled.nix b/templates/ci/modules/features/deadbugs/issue-292-hm-used-when-no-bidir-enabled.nix new file mode 100644 index 000000000..6f627cea5 --- /dev/null +++ b/templates/ci/modules/features/deadbugs/issue-292-hm-used-when-no-bidir-enabled.nix @@ -0,0 +1,27 @@ +{ denTest, ... }: +{ + flake.tests.deadbugs-issue-292 = { + + test-should-not-read-from-host-without-bidirectionality = denTest ( + { + den, + lib, + igloo, # igloo = nixosConfigurations.igloo.config + tuxHm, # tuxHm = igloo.home-manager.users.tux + ... + }: + { + den.hosts.x86_64-linux.igloo.users.tux = { }; + + den.aspects.igloo.includes = [ den.aspects.bash ]; + den.aspects.tux.includes = [ den.aspects.bash ]; + + den.aspects.bash.homeManager.programs.bash.historyIgnore = [ "foo" ]; + + expr = tuxHm.programs.bash.historyIgnore; + expected = [ "foo" ]; + } + ); + + }; +} diff --git a/templates/ci/modules/features/perUser-perHost.nix b/templates/ci/modules/features/perUser-perHost.nix index 6e88482ba..26678d4dd 100644 --- a/templates/ci/modules/features/perUser-perHost.nix +++ b/templates/ci/modules/features/perUser-perHost.nix @@ -85,6 +85,7 @@ }; den.aspects.igloo.includes = [ + (den.lib.perHost { nixos.funny = [ "atHost perHost static" ]; }) (den.lib.perHost ( { host }: diff --git a/templates/ci/modules/features/user-host-bidirectional-config.nix b/templates/ci/modules/features/user-host-bidirectional-config.nix index 79124b0a5..b13f4bf45 100644 --- a/templates/ci/modules/features/user-host-bidirectional-config.nix +++ b/templates/ci/modules/features/user-host-bidirectional-config.nix @@ -2,7 +2,7 @@ { flake.tests.user-host-bidirectional-config = { - test-host-owned-configures-all-users = denTest ( + test-host-owned-unidirectional = denTest ( { den, tuxHm, @@ -10,13 +10,12 @@ ... }: { - den.default.homeManager.home.stateVersion = "25.11"; - den.hosts.x86_64-linux.igloo.users = { tux = { }; pingu = { }; }; + # no bidirectionality enabled, this is ignored den.aspects.igloo.homeManager.programs.direnv.enable = true; expr = [ @@ -24,13 +23,13 @@ pinguHm.programs.direnv.enable ]; expected = [ - true - true + false + false ]; } ); - test-host-static-configures-all-users = denTest ( + test-host-owned-bidirectional = denTest ( { den, tuxHm, @@ -38,17 +37,48 @@ ... }: { - den.default.homeManager.home.stateVersion = "25.11"; + den.hosts.x86_64-linux.igloo.users = { + tux = { }; + pingu = { }; + }; + + den.ctx.user.includes = [ den._.bidirectional ]; + den.aspects.igloo.homeManager.programs.direnv.enable = true; + + expr = [ + tuxHm.programs.direnv.enable + pinguHm.programs.direnv.enable + ]; + expected = [ + false + false + ]; + } + ); + test-host-bidirectional-static-includes-configures-all-users = denTest ( + { + den, + tuxHm, + pinguHm, + ... + }: + { den.hosts.x86_64-linux.igloo.users = { tux = { }; pingu = { }; }; + den.ctx.user.includes = [ den._.bidirectional ]; + den.aspects.igloo.includes = [ { - homeManager.programs.direnv.enable = true; + homeManager.programs.direnv.enable = throw "unreachable, static includes wont be used by bidirectionality"; } + # This is the way, walk in it: + (den.lib.perUser { + homeManager.programs.direnv.enable = true; + }) ]; expr = [ @@ -62,7 +92,41 @@ } ); - test-host-parametric-configures-all-users = denTest ( + test-host-parametric-unidirectional = denTest ( + { + den, + tuxHm, + pinguHm, + ... + }: + { + + den.hosts.x86_64-linux.igloo.users = { + tux = { }; + pingu = { }; + }; + + den.aspects.igloo.includes = [ + ( + { host, user }: + { + homeManager.programs.direnv.enable = true; + } + ) + ]; + + expr = [ + tuxHm.programs.direnv.enable + pinguHm.programs.direnv.enable + ]; + expected = [ + false + false + ]; + } + ); + + test-host-parametric-bidirectional = denTest ( { den, tuxHm, @@ -70,13 +134,14 @@ ... }: { - den.default.homeManager.home.stateVersion = "25.11"; den.hosts.x86_64-linux.igloo.users = { tux = { }; pingu = { }; }; + den.ctx.user.includes = [ den._.bidirectional ]; + den.aspects.igloo.includes = [ ( { host, user }: @@ -105,7 +170,6 @@ ... }: { - den.default.homeManager.home.stateVersion = "25.11"; den.hosts.x86_64-linux.igloo.users.tux = { }; den.hosts.x86_64-linux.iceberg.users.tux = { }; @@ -123,7 +187,7 @@ } ); - test-user-static-configures-all-hosts = denTest ( + test-user-static-unidirectional-configures-all-hosts = denTest ( { den, igloo, @@ -131,7 +195,6 @@ ... }: { - den.default.homeManager.home.stateVersion = "25.11"; den.hosts.x86_64-linux.igloo.users.tux = { }; den.hosts.x86_64-linux.iceberg.users.tux = { }; @@ -161,7 +224,6 @@ ... }: { - den.default.homeManager.home.stateVersion = "25.11"; den.hosts.x86_64-linux.igloo.users.tux = { }; den.hosts.x86_64-linux.iceberg.users.tux = { };