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" = {
text = "";
executable = true;
@ -13,5 +10,4 @@ with lib;
assertFileExists home-files/executable
assertFileIsExecutable home-files/executable;
'';
};
}

View file

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

View file

@ -1,13 +1,10 @@
{ config, lib, ... }:
with lib;
{ config, ... }:
let
filePath = ./. + "/source with spaces!";
in {
config = {
home.file."oos".source = config.lib.file.mkOutOfStoreSymlink filePath;
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."
fi
'';
};
}

View file

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

View file

@ -1,7 +1,6 @@
{ ... }:
{
config = {
home.file = {
conflict1 = {
text = "";
@ -22,5 +21,4 @@
conflict1 = { source = ./foo.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";
nmt.script = ''
assertFileExists '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 = ''
This is the
expected text.
@ -14,5 +11,4 @@ with lib;
assertFileIsNotExecutable home-files/using-text
assertFileContent home-files/using-text ${./text-expected.txt}
'';
};
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,16 +1,13 @@
{ config, lib, pkgs, ... }:
with lib;
{ lib, pkgs, ... }:
{
config = {
nixpkgs.overlays = [
(self: super: rec {
emacs = pkgs.writeShellScriptBin "dummy-emacs-27.2" "" // {
outPath = "@emacs@";
};
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-path/share/applications/emacsclient.desktop
assertFileContent home-files/.config/systemd/user/emacs.service \
assertFileContent \
home-files/.config/systemd/user/emacs.service \
${
pkgs.substituteAll {
inherit (pkgs) runtimeShell;
src = ./emacs-service-emacs.service;
}
}
assertFileContent home-path/share/applications/emacsclient.desktop \
assertFileContent \
home-path/share/applications/emacsclient.desktop \
${./emacs-27-emacsclient.desktop}
'';
};
}

View file

@ -1,16 +1,13 @@
{ config, lib, pkgs, ... }:
with lib;
{ lib, pkgs, ... }:
{
config = {
nixpkgs.overlays = [
(self: super: rec {
emacs = pkgs.writeShellScriptBin "dummy-emacs-28.2" "" // {
outPath = "@emacs@";
};
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-path/share/applications/emacsclient.desktop
assertFileContent home-files/.config/systemd/user/emacs.service \
assertFileContent \
home-files/.config/systemd/user/emacs.service \
${
pkgs.substituteAll {
inherit (pkgs) runtimeShell;
src =
./emacs-service-emacs-after-graphical-session-target.service;
src = ./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}
'';
};
}

View file

@ -1,6 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{ lib, pkgs, ... }:
{
config = {
@ -10,7 +8,7 @@ with lib;
outPath = "@emacs@";
};
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-path/share/applications/emacsclient.desktop
assertFileContent home-files/.config/systemd/user/emacs.service \
assertFileContent \
home-files/.config/systemd/user/emacs.service \
${
pkgs.substituteAll {
inherit (pkgs) runtimeShell;
src = ./emacs-service-emacs.service;
}
}
assertFileContent home-path/share/applications/emacsclient.desktop \
assertFileContent \
home-path/share/applications/emacsclient.desktop \
${./emacs-28-emacsclient.desktop}
'';
};

View file

@ -1,10 +1,6 @@
{ config, lib, pkgs, ... }:
{ lib, pkgs, ... }:
with lib;
let
in {
{
config = {
nixpkgs.overlays = [
(self: super: rec {
@ -12,7 +8,7 @@ in {
outPath = "@emacs@";
};
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-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}
assertFileContent home-files/.config/systemd/user/emacs.service \
assertFileContent \
home-files/.config/systemd/user/emacs.service \
${
pkgs.substituteAll {
inherit (pkgs) runtimeShell coreutils;
src = ./emacs-socket-emacs.service;
}
}
assertFileContent home-path/share/applications/emacsclient.desktop \
assertFileContent \
home-path/share/applications/emacsclient.desktop \
${./emacs-27-emacsclient.desktop}
'';
};

View file

@ -1,10 +1,6 @@
{ config, lib, pkgs, ... }:
{ lib, pkgs, ... }:
with lib;
let
in {
{
config = {
nixpkgs.overlays = [
(self: super: rec {
@ -12,7 +8,7 @@ in {
outPath = "@emacs@";
};
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-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}
assertFileContent home-files/.config/systemd/user/emacs.service \
assertFileContent \
home-files/.config/systemd/user/emacs.service \
${
pkgs.substituteAll {
inherit (pkgs) runtimeShell coreutils;
src = ./emacs-socket-emacs.service;
}
}
assertFileContent home-path/share/applications/emacsclient.desktop \
assertFileContent \
home-path/share/applications/emacsclient.desktop \
${./emacs-28-emacsclient.desktop}
'';
};

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,13 +1,9 @@
{ lib, pkgs, ... }:
with lib;
{ pkgs, ... }:
{
config = {
xsession.windowManager.bspwm = {
enable = true;
monitors.focused =
[ "desktop 1" "d'esk top" ]; # pathological desktop names
monitors.focused = [ "desktop 1" "d'esk top" ]; # pathological desktop names
alwaysResetDesktops = false;
settings = {
border_width = 2;
@ -40,8 +36,7 @@ with lib;
assertFileExists "$bspwmrc"
assertFileIsExecutable "$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 ];

View file

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

View file

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

View file

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

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ ... }:
{
imports = [ ./i3-stubs.nix ];
@ -11,6 +11,6 @@
nmt.script = ''
assertFileExists 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 ];

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -5,7 +5,6 @@ let
echo "Just a test"
'';
in {
config = {
systemd.user.services."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 = {
V_int = 1;
V_str = "2";
@ -22,5 +21,4 @@
''
}
'';
};
}

View file

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