Skip to content

Commit

Permalink
Merge pull request #553 from nix-community/systemd-cycle
Browse files Browse the repository at this point in the history
Fix cyclic dependency in systemd units. Add test to check for that
  • Loading branch information
K900 authored Sep 27, 2024
2 parents 13e2ab9 + 664828c commit 4aef94d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
clippy
mdbook
nixpkgs-fmt
powershell
rustc
rustfmt
shfmt
Expand Down
8 changes: 5 additions & 3 deletions modules/wsl-distro.nix
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,17 @@ in
where = "/tmp/.X11-unix/X0";
type = "none";
options = "bind";
wantedBy = [ "local-fs.target" ];
after = [ "nixos-wsl-migration-x11mount.service" ];
wants = after;
wantedBy = [ "local-fs.target" ];
}];
# Remove symbolic link for WSLg X11 socket, which was created by NixOS-WSL until 2024-02-24
systemd.services.nixos-wsl-migration-x11mount = {
description = "Remove /tmp/.X11-unix symlink if present";
before = [ "tmp-.X11\x2dunix-X0.mount" ];
unitConfig.ConditionPathIsSymbolicLink = "/tmp/.X11-unix";
unitConfig = {
ConditionPathIsSymbolicLink = "/tmp/.X11-unix";
DefaultDependencies = "no";
};
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
Expand Down
9 changes: 8 additions & 1 deletion tests/systemd-services.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@ Describe "Systemd Services" {
}

It "should boot" {
$distro.Launch("true")
$output = $distro.Launch("systemctl is-system-running") | Remove-Escapes
$LASTEXITCODE | Should -Be 0
$output | Should -BeExactly "running"
}

It "should not have any failed unit" {
$output = $distro.Launch("sudo systemctl list-units --failed") | Remove-Escapes
$LASTEXITCODE | Should -Be 0
$output | Where-Object { $_.trim() -ne "" } | Select-Object -Last 1 | Should -BeExactly "0 loaded units listed."
}

It "should not have any systemd-analyze verify warnings" {
$output = $distro.Launch("sudo systemd-analyze verify multi-user.target --no-pager 2>&1") | Remove-Escapes
$LASTEXITCODE | Should -Be 0
$output | Should -BeExactly ""
}

AfterAll {
Expand Down

0 comments on commit 4aef94d

Please sign in to comment.