forked from nix-community/home-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7349b01
commit 8264bfe
Showing
8 changed files
with
156 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
tests/integration/standalone/mu/config-account-without-mu.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ lib, ... }: { | ||
imports = [ ./config-two-accounts.nix ]; | ||
|
||
accounts.email.accounts.example2.mu.enable = lib.mkForce false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
home.username = "alice"; | ||
home.homeDirectory = "/home/alice"; | ||
home.stateVersion = "24.11"; | ||
|
||
programs.mu.enable = true; | ||
|
||
programs.home-manager.enable = true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
imports = [ ./config-no-accounts.nix ]; | ||
|
||
accounts.email.accounts.example = { | ||
primary = true; | ||
address = "[email protected]"; | ||
mu.enable = true; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
imports = [ ./config-one-account.nix ]; | ||
|
||
accounts.email.accounts.example.aliases = [ "[email protected]" ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
imports = [ ./config-one-account.nix ]; | ||
|
||
accounts.email.accounts.example2 = { | ||
address = "[email protected]"; | ||
mu.enable = true; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
{ pkgs, ... }: { | ||
name = "mu-store-init"; | ||
|
||
nodes.machine = { ... }: { | ||
imports = [ "${pkgs.path}/nixos/modules/installer/cd-dvd/channel.nix" ]; | ||
virtualisation.memorySize = 2048; | ||
users.users.alice = { | ||
isNormalUser = true; | ||
description = "Alice Foobar"; | ||
password = "foobar"; | ||
uid = 1000; | ||
}; | ||
}; | ||
|
||
testScript = '' | ||
start_all() | ||
machine.wait_for_unit("network.target") | ||
machine.wait_for_unit("multi-user.target") | ||
home_manager = "${../../../..}" | ||
home_config = "/home/alice/.config/home-manager" | ||
def login_as_alice(): | ||
machine.wait_until_tty_matches("1", "login: ") | ||
machine.send_chars("alice\n") | ||
machine.wait_until_tty_matches("1", "Password: ") | ||
machine.send_chars("foobar\n") | ||
machine.wait_until_tty_matches("1", "alice\\@machine") | ||
def logout_alice(): | ||
machine.send_chars("exit\n") | ||
def alice_cmd(cmd): | ||
return f"su -l alice --shell /bin/sh -c $'export XDG_RUNTIME_DIR=/run/user/$UID ; {cmd}'" | ||
def succeed_as_alice(cmd): | ||
return machine.succeed(alice_cmd(cmd)) | ||
def fail_as_alice(cmd): | ||
return machine.fail(alice_cmd(cmd)) | ||
def switch_to(config): | ||
succeed_as_alice(f"cp {home_config}/{config}.nix {home_config}/home.nix") | ||
return succeed_as_alice("home-manager switch") | ||
# succeed_as_alice(". /home/alice/.nix-profile/etc/profile.d/hm-session-vars.sh") | ||
# Create a persistent login so that Alice has a systemd session. | ||
login_as_alice() | ||
# Set up a home-manager channel. | ||
succeed_as_alice(" ; ".join([ | ||
"mkdir -p /home/alice/.nix-defexpr/channels", | ||
f"ln -s {home_manager} /home/alice/.nix-defexpr/channels/home-manager" | ||
])) | ||
succeed_as_alice("nix-shell \"<home-manager>\" -A install") | ||
succeed_as_alice(f"cp -t {home_config} ${./.}/config-*") | ||
with subtest("Switch to empty profile"): | ||
switch_to("config-no-accounts") | ||
actual = succeed_as_alice("mu info store") | ||
expected = "/home/alice/Maildir" | ||
assert expected in actual, \ | ||
f"expected mu info store to contain {expected}, but got {actual}" | ||
unexpected = "personal-address" | ||
assert not unexpected in actual, \ | ||
f"expected mu info store not to contain {unexpected}, but got {actual}" | ||
with subtest("Switch to profile with an account"): | ||
switch_to("config-one-account") | ||
actual = succeed_as_alice("mu info store") | ||
expected = "[email protected]" | ||
assert expected in actual, \ | ||
f"expected mu info store to contain {expected}, but got {actual}" | ||
with subtest("Switch to profile with two accounts"): | ||
switch_to("config-two-accounts") | ||
actual = succeed_as_alice("mu info store") | ||
expected = "[email protected]" | ||
assert expected in actual, \ | ||
f"expected mu info store to contain {expected}, but got {actual}" | ||
expected = "[email protected]" | ||
assert expected in actual, \ | ||
f"expected mu info store to contain {expected}, but got {actual}" | ||
with subtest("Switch back to profile with one account"): | ||
switch_to("config-one-account") | ||
actual = succeed_as_alice("mu info store") | ||
expected = "[email protected]" | ||
assert expected in actual, \ | ||
f"expected mu info store to contain {expected}, but got {actual}" | ||
unexpected = "[email protected]" | ||
assert not unexpected in actual, \ | ||
f"expected mu info store not to contain {unexpected}, but got {actual}" | ||
with subtest("Switch to profile with an alias"): | ||
switch_to("config-one-alias") | ||
actual = succeed_as_alice("mu info store") | ||
expected = "[email protected]" | ||
assert expected in actual, \ | ||
f"expected mu info store to contain {expected}, but got {actual}" | ||
expected = "[email protected]" | ||
assert expected in actual, \ | ||
f"expected mu info store to contain {expected}, but got {actual}" | ||
with subtest("Switch to a profile with mu disabled for one account"): | ||
switch_to("config-account-without-mu") | ||
actual = succeed_as_alice("mu info store") | ||
expected = "[email protected]" | ||
assert expected in actual, \ | ||
f"expected mu info store to contain {expected}, but got {actual}" | ||
unexpected = "[email protected]" | ||
assert not unexpected in actual, \ | ||
f"expected mu info store not to contain {unexpected}, but got {actual}" | ||
''; | ||
} |