1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 03:29:45 +01:00

tests: various minor cleanups

This commit is contained in:
Robert Helgesson 2023-05-13 00:08:12 +02:00
parent 19c509a6fa
commit eec2272999
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
41 changed files with 680 additions and 747 deletions

View file

@ -1,9 +1,6 @@
{ config, lib, ... }: { ... }:
with lib;
{ {
config = {
home.file."executable" = { home.file."executable" = {
text = ""; text = "";
executable = true; executable = true;
@ -13,5 +10,4 @@ with lib;
assertFileExists home-files/executable assertFileExists home-files/executable
assertFileIsExecutable home-files/executable; assertFileIsExecutable home-files/executable;
''; '';
};
} }

View file

@ -1,9 +1,6 @@
{ config, lib, ... }: { ... }:
with lib;
{ {
config = {
home.file.".hidden".source = ./.hidden; home.file.".hidden".source = ./.hidden;
nmt.script = '' nmt.script = ''
@ -15,5 +12,4 @@ with lib;
} }
} }
''; '';
};
} }

View file

@ -1,13 +1,10 @@
{ config, lib, ... }: { config, ... }:
with lib;
let let
filePath = ./. + "/source with spaces!"; filePath = ./. + "/source with spaces!";
in { in {
config = {
home.file."oos".source = config.lib.file.mkOutOfStoreSymlink filePath; home.file."oos".source = config.lib.file.mkOutOfStoreSymlink filePath;
nmt.script = '' nmt.script = ''
@ -25,5 +22,4 @@ in {
fail "Symlink home-files/oos should point to $expected via the Nix store, but it actually points to $actual." fail "Symlink home-files/oos should point to $expected via the Nix store, but it actually points to $actual."
fi fi
''; '';
};
} }

View file

@ -1,9 +1,6 @@
{ config, lib, ... }: { ... }:
with lib;
{ {
config = {
home.file."source with spaces!".source = ./. + "/source with spaces!"; home.file."source with spaces!".source = ./. + "/source with spaces!";
nmt.script = '' nmt.script = ''
@ -16,5 +13,4 @@ with lib;
} }
} }
''; '';
};
} }

View file

@ -1,7 +1,6 @@
{ ... }: { ... }:
{ {
config = {
home.file = { home.file = {
conflict1 = { conflict1 = {
text = ""; text = "";
@ -22,5 +21,4 @@
conflict1 = { source = ./foo.nix; target = "baz"; }; conflict1 = { source = ./foo.nix; target = "baz"; };
conflict2 = { source = ./bar.nix; target = "baz"; }; conflict2 = { source = ./bar.nix; target = "baz"; };
}'']; }''];
};
} }

View file

@ -1,15 +1,11 @@
{ config, lib, pkgs, ... }: { ... }:
with lib;
{ {
config = {
home.file."$HOME/$FOO/bar baz".text = "blah"; home.file."$HOME/$FOO/bar baz".text = "blah";
nmt.script = '' nmt.script = ''
assertFileExists 'home-files/$HOME/$FOO/bar baz'; assertFileExists 'home-files/$HOME/$FOO/bar baz';
assertFileContent 'home-files/$HOME/$FOO/bar baz' \ assertFileContent 'home-files/$HOME/$FOO/bar baz' \
${pkgs.writeText "expected" "blah"} ${builtins.toFile "expected" "blah"}
''; '';
};
} }

View file

@ -1,9 +1,6 @@
{ config, lib, ... }: { ... }:
with lib;
{ {
config = {
home.file."using-text".text = '' home.file."using-text".text = ''
This is the This is the
expected text. expected text.
@ -14,5 +11,4 @@ with lib;
assertFileIsNotExecutable home-files/using-text assertFileIsNotExecutable home-files/using-text
assertFileContent home-files/using-text ${./text-expected.txt} assertFileContent home-files/using-text ${./text-expected.txt}
''; '';
};
} }

View file

@ -1,10 +1,11 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
let let
boolToString = bool: if bool then "true" else "false"; boolToString = bool: if bool then "true" else "false";
backups = config.programs.borgmatic.backups; backups = config.programs.borgmatic.backups;
in { in {
config = {
programs.borgmatic = { programs.borgmatic = {
enable = true; enable = true;
backups = { backups = {
@ -112,5 +113,4 @@ in {
fail "Expected one_file_system to be true but it was $one_file_system" fail "Expected one_file_system to be true but it was $one_file_system"
fi fi
''; '';
};
} }

View file

@ -1,10 +1,11 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
let let
backups = config.programs.borgmatic.backups; backups = config.programs.borgmatic.backups;
excludeFile = pkgs.writeText "excludeFile.txt" "/foo/bar"; excludeFile = builtins.toFile "excludeFile.txt" "/foo/bar";
in { in {
config = {
programs.borgmatic = { programs.borgmatic = {
enable = true; enable = true;
backups = { backups = {
@ -36,5 +37,4 @@ in {
exit 1 exit 1
fi fi
''; '';
};
} }

View file

@ -1,10 +1,11 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
let let
backups = config.programs.borgmatic.backups; backups = config.programs.borgmatic.backups;
excludeFile = pkgs.writeText "excludeFile.txt" "/foo/bar"; excludeFile = builtins.toFile "excludeFile.txt" "/foo/bar";
in { in {
config = {
programs.borgmatic = { programs.borgmatic = {
enable = true; enable = true;
backups = { backups = {
@ -50,5 +51,4 @@ in {
exit 1 exit 1
fi fi
''; '';
};
} }

View file

@ -1,10 +1,11 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
let let
backups = config.programs.borgmatic.backups; backups = config.programs.borgmatic.backups;
excludeFile = pkgs.writeText "excludeFile.txt" "/foo/bar"; excludeFile = builtins.toFile "excludeFile.txt" "/foo/bar";
in { in {
config = {
programs.borgmatic = { programs.borgmatic = {
enable = true; enable = true;
backups = { backups = {
@ -41,5 +42,4 @@ in {
done done
''; '';
};
} }

View file

@ -1,7 +1,6 @@
{ config, pkgs, ... }: { ... }:
{ {
config = {
services.barrier.client = { services.barrier.client = {
enable = true; enable = true;
server = "testServer"; server = "testServer";
@ -15,5 +14,4 @@
assertFileExists $clientServiceFile assertFileExists $clientServiceFile
assertFileRegex $clientServiceFile 'ExecStart=.*/bin/barrierc -f testServer' assertFileRegex $clientServiceFile 'ExecStart=.*/bin/barrierc -f testServer'
''; '';
};
} }

View file

@ -1,5 +1,6 @@
{ config, pkgs, ... }: { { ... }:
config = {
{
services.devilspie2 = { services.devilspie2 = {
enable = true; enable = true;
@ -33,5 +34,4 @@
assertFileRegex $serviceFile 'ExecStart=.*/bin/devilspie2' assertFileRegex $serviceFile 'ExecStart=.*/bin/devilspie2'
''; '';
};
} }

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }: { pkgs, ... }:
{ {
nixpkgs.overlays = [ nixpkgs.overlays = [

View file

@ -1,16 +1,13 @@
{ config, lib, pkgs, ... }: { lib, pkgs, ... }:
with lib;
{ {
config = {
nixpkgs.overlays = [ nixpkgs.overlays = [
(self: super: rec { (self: super: rec {
emacs = pkgs.writeShellScriptBin "dummy-emacs-27.2" "" // { emacs = pkgs.writeShellScriptBin "dummy-emacs-27.2" "" // {
outPath = "@emacs@"; outPath = "@emacs@";
}; };
emacsPackagesFor = _: emacsPackagesFor = _:
makeScope super.newScope (_: { emacsWithPackages = _: emacs; }); lib.makeScope super.newScope (_: { emacsWithPackages = _: emacs; });
}) })
]; ];
@ -24,15 +21,17 @@ with lib;
assertFileExists home-files/.config/systemd/user/emacs.service assertFileExists home-files/.config/systemd/user/emacs.service
assertFileExists home-path/share/applications/emacsclient.desktop assertFileExists home-path/share/applications/emacsclient.desktop
assertFileContent home-files/.config/systemd/user/emacs.service \ assertFileContent \
home-files/.config/systemd/user/emacs.service \
${ ${
pkgs.substituteAll { pkgs.substituteAll {
inherit (pkgs) runtimeShell; inherit (pkgs) runtimeShell;
src = ./emacs-service-emacs.service; src = ./emacs-service-emacs.service;
} }
} }
assertFileContent home-path/share/applications/emacsclient.desktop \
assertFileContent \
home-path/share/applications/emacsclient.desktop \
${./emacs-27-emacsclient.desktop} ${./emacs-27-emacsclient.desktop}
''; '';
};
} }

View file

@ -1,16 +1,13 @@
{ config, lib, pkgs, ... }: { lib, pkgs, ... }:
with lib;
{ {
config = {
nixpkgs.overlays = [ nixpkgs.overlays = [
(self: super: rec { (self: super: rec {
emacs = pkgs.writeShellScriptBin "dummy-emacs-28.2" "" // { emacs = pkgs.writeShellScriptBin "dummy-emacs-28.2" "" // {
outPath = "@emacs@"; outPath = "@emacs@";
}; };
emacsPackagesFor = _: emacsPackagesFor = _:
makeScope super.newScope (_: { emacsWithPackages = _: emacs; }); lib.makeScope super.newScope (_: { emacsWithPackages = _: emacs; });
}) })
]; ];
@ -25,16 +22,17 @@ with lib;
assertFileExists home-files/.config/systemd/user/emacs.service assertFileExists home-files/.config/systemd/user/emacs.service
assertFileExists home-path/share/applications/emacsclient.desktop assertFileExists home-path/share/applications/emacsclient.desktop
assertFileContent home-files/.config/systemd/user/emacs.service \ assertFileContent \
home-files/.config/systemd/user/emacs.service \
${ ${
pkgs.substituteAll { pkgs.substituteAll {
inherit (pkgs) runtimeShell; inherit (pkgs) runtimeShell;
src = src = ./emacs-service-emacs-after-graphical-session-target.service;
./emacs-service-emacs-after-graphical-session-target.service;
} }
} }
assertFileContent home-path/share/applications/emacsclient.desktop \
assertFileContent \
home-path/share/applications/emacsclient.desktop \
${./emacs-28-emacsclient.desktop} ${./emacs-28-emacsclient.desktop}
''; '';
};
} }

View file

@ -1,6 +1,4 @@
{ config, lib, pkgs, ... }: { lib, pkgs, ... }:
with lib;
{ {
config = { config = {
@ -10,7 +8,7 @@ with lib;
outPath = "@emacs@"; outPath = "@emacs@";
}; };
emacsPackagesFor = _: emacsPackagesFor = _:
makeScope super.newScope (_: { emacsWithPackages = _: emacs; }); lib.makeScope super.newScope (_: { emacsWithPackages = _: emacs; });
}) })
]; ];
@ -24,14 +22,17 @@ with lib;
assertFileExists home-files/.config/systemd/user/emacs.service assertFileExists home-files/.config/systemd/user/emacs.service
assertFileExists home-path/share/applications/emacsclient.desktop assertFileExists home-path/share/applications/emacsclient.desktop
assertFileContent home-files/.config/systemd/user/emacs.service \ assertFileContent \
home-files/.config/systemd/user/emacs.service \
${ ${
pkgs.substituteAll { pkgs.substituteAll {
inherit (pkgs) runtimeShell; inherit (pkgs) runtimeShell;
src = ./emacs-service-emacs.service; src = ./emacs-service-emacs.service;
} }
} }
assertFileContent home-path/share/applications/emacsclient.desktop \
assertFileContent \
home-path/share/applications/emacsclient.desktop \
${./emacs-28-emacsclient.desktop} ${./emacs-28-emacsclient.desktop}
''; '';
}; };

View file

@ -1,10 +1,6 @@
{ config, lib, pkgs, ... }: { lib, pkgs, ... }:
with lib; {
let
in {
config = { config = {
nixpkgs.overlays = [ nixpkgs.overlays = [
(self: super: rec { (self: super: rec {
@ -12,7 +8,7 @@ in {
outPath = "@emacs@"; outPath = "@emacs@";
}; };
emacsPackagesFor = _: emacsPackagesFor = _:
makeScope super.newScope (_: { emacsWithPackages = _: emacs; }); lib.makeScope super.newScope (_: { emacsWithPackages = _: emacs; });
}) })
]; ];
@ -27,16 +23,21 @@ in {
assertFileExists home-files/.config/systemd/user/emacs.service assertFileExists home-files/.config/systemd/user/emacs.service
assertFileExists home-path/share/applications/emacsclient.desktop assertFileExists home-path/share/applications/emacsclient.desktop
assertFileContent home-files/.config/systemd/user/emacs.socket \ assertFileContent \
home-files/.config/systemd/user/emacs.socket \
${./emacs-socket-emacs.socket} ${./emacs-socket-emacs.socket}
assertFileContent home-files/.config/systemd/user/emacs.service \
assertFileContent \
home-files/.config/systemd/user/emacs.service \
${ ${
pkgs.substituteAll { pkgs.substituteAll {
inherit (pkgs) runtimeShell coreutils; inherit (pkgs) runtimeShell coreutils;
src = ./emacs-socket-emacs.service; src = ./emacs-socket-emacs.service;
} }
} }
assertFileContent home-path/share/applications/emacsclient.desktop \
assertFileContent \
home-path/share/applications/emacsclient.desktop \
${./emacs-27-emacsclient.desktop} ${./emacs-27-emacsclient.desktop}
''; '';
}; };

View file

@ -1,10 +1,6 @@
{ config, lib, pkgs, ... }: { lib, pkgs, ... }:
with lib; {
let
in {
config = { config = {
nixpkgs.overlays = [ nixpkgs.overlays = [
(self: super: rec { (self: super: rec {
@ -12,7 +8,7 @@ in {
outPath = "@emacs@"; outPath = "@emacs@";
}; };
emacsPackagesFor = _: emacsPackagesFor = _:
makeScope super.newScope (_: { emacsWithPackages = _: emacs; }); lib.makeScope super.newScope (_: { emacsWithPackages = _: emacs; });
}) })
]; ];
@ -27,16 +23,21 @@ in {
assertFileExists home-files/.config/systemd/user/emacs.service assertFileExists home-files/.config/systemd/user/emacs.service
assertFileExists home-path/share/applications/emacsclient.desktop assertFileExists home-path/share/applications/emacsclient.desktop
assertFileContent home-files/.config/systemd/user/emacs.socket \ assertFileContent \
home-files/.config/systemd/user/emacs.socket \
${./emacs-socket-emacs.socket} ${./emacs-socket-emacs.socket}
assertFileContent home-files/.config/systemd/user/emacs.service \
assertFileContent \
home-files/.config/systemd/user/emacs.service \
${ ${
pkgs.substituteAll { pkgs.substituteAll {
inherit (pkgs) runtimeShell coreutils; inherit (pkgs) runtimeShell coreutils;
src = ./emacs-socket-emacs.service; src = ./emacs-socket-emacs.service;
} }
} }
assertFileContent home-path/share/applications/emacsclient.desktop \
assertFileContent \
home-path/share/applications/emacsclient.desktop \
${./emacs-28-emacsclient.desktop} ${./emacs-28-emacsclient.desktop}
''; '';
}; };

View file

@ -1,7 +1,5 @@
{ lib, pkgs, ... }: { lib, pkgs, ... }:
with lib;
{ {
services.emacs = { services.emacs = {
enable = true; enable = true;
@ -15,7 +13,7 @@ with lib;
outPath = "@emacs@"; outPath = "@emacs@";
}; };
emacsPackagesFor = _: emacsPackagesFor = _:
makeScope super.newScope (_: { emacsWithPackages = _: emacs; }); lib.makeScope super.newScope (_: { emacsWithPackages = _: emacs; });
}) })
]; ];

View file

@ -1,7 +1,6 @@
{ ... }: { ... }:
{ {
config = {
services.flameshot = { enable = true; }; services.flameshot = { enable = true; };
test.stubs.flameshot = { }; test.stubs.flameshot = { };
@ -9,5 +8,4 @@
nmt.script = '' nmt.script = ''
assertPathNotExists home-files/.config/flameshot/flameshot.ini assertPathNotExists home-files/.config/flameshot/flameshot.ini
''; '';
};
} }

View file

@ -1,7 +1,6 @@
{ ... }: { ... }:
{ {
config = {
services.flameshot = { services.flameshot = {
enable = true; enable = true;
@ -26,5 +25,4 @@
'' ''
} }
''; '';
};
} }

View file

@ -1,5 +1,6 @@
{ config, pkgs, ... }: { { ... }:
config = {
{
services.fluidsynth.enable = true; services.fluidsynth.enable = true;
services.fluidsynth.soundService = "pipewire-pulse"; services.fluidsynth.soundService = "pipewire-pulse";
services.fluidsynth.soundFont = "/path/to/soundFont"; services.fluidsynth.soundFont = "/path/to/soundFont";
@ -21,5 +22,4 @@
assertFileContains $serviceFile \ assertFileContains $serviceFile \
'BindsTo=pipewire-pulse.service' 'BindsTo=pipewire-pulse.service'
''; '';
};
} }

View file

@ -1,11 +1,8 @@
{ config, lib, pkgs, ... }: { ... }:
with lib;
{ {
imports = [ ../../accounts/email-test-accounts.nix ]; imports = [ ../../accounts/email-test-accounts.nix ];
config = {
services.lieer.enable = true; services.lieer.enable = true;
accounts.email.accounts = { accounts.email.accounts = {
@ -30,5 +27,4 @@ with lib;
assertFileContent home-files/.config/systemd/user/lieer-hm-example-com.timer \ assertFileContent home-files/.config/systemd/user/lieer-hm-example-com.timer \
${./lieer-service-expected.timer} ${./lieer-service-expected.timer}
''; '';
};
} }

View file

@ -1,13 +1,9 @@
{ lib, pkgs, ... }: { pkgs, ... }:
with lib;
{ {
config = {
xsession.windowManager.bspwm = { xsession.windowManager.bspwm = {
enable = true; enable = true;
monitors.focused = monitors.focused = [ "desktop 1" "d'esk top" ]; # pathological desktop names
[ "desktop 1" "d'esk top" ]; # pathological desktop names
alwaysResetDesktops = false; alwaysResetDesktops = false;
settings = { settings = {
border_width = 2; border_width = 2;
@ -40,8 +36,7 @@ with lib;
assertFileExists "$bspwmrc" assertFileExists "$bspwmrc"
assertFileIsExecutable "$bspwmrc" assertFileIsExecutable "$bspwmrc"
assertFileContent "$bspwmrc" ${ assertFileContent "$bspwmrc" ${
pkgs.writeShellScript "bspwmrc-expected" (readFile ./bspwmrc) pkgs.writeShellScript "bspwmrc-expected" (builtins.readFile ./bspwmrc)
} }
''; '';
};
} }

View file

@ -1,4 +1,4 @@
{ config, lib, ... }: { ... }:
{ {
imports = [ ./i3-stubs.nix ]; imports = [ ./i3-stubs.nix ];

View file

@ -1,9 +1,6 @@
{ config, lib, ... }: { ... }:
with lib;
{ {
config = {
xsession.windowManager.i3 = { xsession.windowManager.i3 = {
enable = true; enable = true;
@ -27,5 +24,4 @@ with lib;
assertFileContent home-files/.config/i3/config \ assertFileContent home-files/.config/i3/config \
${./i3-followmouse-expected.conf} ${./i3-followmouse-expected.conf}
''; '';
};
} }

View file

@ -1,4 +1,4 @@
{ config, lib, ... }: { ... }:
{ {
imports = [ ./i3-stubs.nix ]; imports = [ ./i3-stubs.nix ];

View file

@ -1,4 +1,4 @@
{ config, lib, ... }: { ... }:
{ {
imports = [ ./i3-stubs.nix ]; imports = [ ./i3-stubs.nix ];

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }: { ... }:
{ {
imports = [ ./i3-stubs.nix ]; imports = [ ./i3-stubs.nix ];
@ -11,6 +11,6 @@
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/i3/config assertFileExists home-files/.config/i3/config
assertFileContent home-files/.config/i3/config \ assertFileContent home-files/.config/i3/config \
${pkgs.writeText "expected" ""} ${builtins.toFile "expected" ""}
''; '';
} }

View file

@ -1,4 +1,4 @@
{ config, lib, ... }: { ... }:
{ {
imports = [ ./i3-stubs.nix ]; imports = [ ./i3-stubs.nix ];

View file

@ -1,4 +1,4 @@
{ config, lib, ... }: { ... }:
let let
i3 = { i3 = {

View file

@ -1,6 +1,4 @@
{ config, lib, pkgs, ... }: { config, pkgs, ... }:
with lib;
{ {
imports = [ ./sway-stubs.nix ]; imports = [ ./sway-stubs.nix ];

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }: { config, pkgs, ... }:
{ {
imports = [ ./sway-stubs.nix ]; imports = [ ./sway-stubs.nix ];

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }: { config, pkgs, ... }:
{ {
imports = [ ./sway-stubs.nix ]; imports = [ ./sway-stubs.nix ];

View file

@ -1,7 +1,6 @@
{ config, lib, pkgs, ... }: { ... }:
{ {
config = {
wayland.windowManager.sway.swaynag = { wayland.windowManager.sway.swaynag = {
enable = true; enable = true;
@ -11,5 +10,4 @@
nmt.script = '' nmt.script = ''
assertPathNotExists home-files/.config/swaynag assertPathNotExists home-files/.config/swaynag
''; '';
};
} }

View file

@ -1,10 +1,7 @@
{ config, lib, pkgs, ... }: { lib, ... }:
with lib;
{ {
config = { home.username = lib.mkForce "root";
home.username = mkForce "root";
systemd.user.services."test-service@" = { systemd.user.services."test-service@" = {
Unit = { Description = "A basic test service"; }; Unit = { Description = "A basic test service"; };
@ -19,5 +16,4 @@ with lib;
serviceFile=home-files/.config/systemd/user/test-service@.service serviceFile=home-files/.config/systemd/user/test-service@.service
assertPathNotExists $serviceFile assertPathNotExists $serviceFile
''; '';
};
} }

View file

@ -5,7 +5,6 @@ let
echo "Just a test" echo "Just a test"
''; '';
in { in {
config = {
systemd.user.services."test-service@" = { systemd.user.services."test-service@" = {
Unit = { Description = "A basic test service"; }; Unit = { Description = "A basic test service"; };
@ -33,5 +32,4 @@ in {
'' ''
} }
''; '';
};
} }

View file

@ -1,7 +1,6 @@
{ config, lib, pkgs, ... }: { pkgs, ... }:
{ {
config = {
systemd.user.sessionVariables = { systemd.user.sessionVariables = {
V_int = 1; V_int = 1;
V_str = "2"; V_str = "2";
@ -22,5 +21,4 @@
'' ''
} }
''; '';
};
} }

View file

@ -1,9 +1,6 @@
{ config, lib, pkgs, ... }: { ... }:
with lib;
{ {
config = {
systemd.user.slices.app-test = { systemd.user.slices.app-test = {
Unit = { Description = "Slice for a test app"; }; Unit = { Description = "Slice for a test app"; };
@ -27,5 +24,4 @@ with lib;
'' ''
} }
''; '';
};
} }

View file

@ -1,9 +1,6 @@
{ config, lib, pkgs, ... }: { ... }:
with lib;
{ {
config = {
systemd.user.timers.test-timer = { systemd.user.timers.test-timer = {
Unit = { Description = "A basic test timer"; }; Unit = { Description = "A basic test timer"; };
@ -21,5 +18,4 @@ with lib;
assertFileExists $unitDir/timers.target.wants/test-timer.timer assertFileExists $unitDir/timers.target.wants/test-timer.timer
''; '';
};
} }