1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-22 10:19:39 +01:00

tests: rework derivation stubbing

Instead of having to manually stub packages that should not be
downloaded we instead automatically stub all packages (except a small
list of whitelisted ones). Tests can re-introduce the real package by
using the `realPkgs` module argument.
This commit is contained in:
Robert Helgesson 2025-01-31 21:24:47 +01:00
parent c5c2cbc866
commit 7a3f0b3b8d
No known key found for this signature in database
GPG key ID: 96E745BD17AA17ED
480 changed files with 3557 additions and 5511 deletions

View file

@ -9,31 +9,105 @@ let
sha256 = "0qhn7nnwdwzh910ss78ga2d00v42b0lspfd7ybl61mpfgz3lmdcj"; sha256 = "0qhn7nnwdwzh910ss78ga2d00v42b0lspfd7ybl61mpfgz3lmdcj";
}; };
# Recursively replace each derivation in the given attribute set with the same
# derivation but with the `outPath` attribute set to the string
# `"@package-name@"`. This allows the tests to refer to derivations through
# their values without establishing an actual dependency on the derivation
# output.
scrubDerivations = attrs:
let
scrubDerivation = name: value:
let
scrubbedValue = scrubDerivations value;
newDrvAttrs = {
buildScript = abort "no build allowed";
outPath = builtins.traceVerbose ("${name} - got out path")
"@${lib.getName value}@";
# Prevent getOutput from descending into outputs
outputSpecified = true;
# Allow the original package to be used in derivation inputs
__spliced = {
buildHost = value;
hostTarget = value;
};
};
in if lib.isAttrs value then
if lib.isDerivation value then
scrubbedValue // newDrvAttrs
else
scrubbedValue
else
value;
in lib.mapAttrs scrubDerivation attrs;
# Globally unscrub a few selected packages that are used by a wide selection of tests.
whitelist = let
inner = self: super: {
inherit (pkgs)
coreutils jq desktop-file-utils diffutils findutils glibcLocales gettext
gnugrep gnused shared-mime-info emptyDirectory
# Needed by pretty much all tests that have anything to do with fish.
babelfish fish;
xorg =
super.xorg.overrideScope (self: super: { inherit (pkgs.xorg) lndir; });
};
outer = self: super:
inner self super // {
buildPackages = super.buildPackages.extend inner;
};
in outer;
scrubbedPkgs =
let rawScrubbedPkgs = lib.makeExtensible (final: scrubDerivations pkgs);
in builtins.traceVerbose "eval scrubbed nixpkgs"
(rawScrubbedPkgs.extend whitelist);
modules = import ../modules/modules.nix { modules = import ../modules/modules.nix {
inherit lib pkgs; inherit lib pkgs;
check = false; check = false;
} ++ [{ } ++ [
# Bypass <nixpkgs> reference inside modules/modules.nix to make the test ({ config, ... }: {
# suite more pure. _module.args = {
_module.args.pkgsPath = pkgs.path; # Prevent the nixpkgs module from working. We want to minimize the number
# of evaluations of Nixpkgs.
pkgsPath = abort "pkgs path is unavailable in tests";
realPkgs = pkgs;
pkgs = let
overlays = config.test.stubOverlays ++ lib.optionals
(config.nixpkgs.overlays != null && config.nixpkgs.overlays != [ ])
config.nixpkgs.overlays;
stubbedPkgs = if overlays == [ ] then
scrubbedPkgs
else
builtins.traceVerbose "eval overlayed nixpkgs"
(lib.foldr (o: p: p.extend o) scrubbedPkgs overlays);
in lib.mkImageMediaOverride stubbedPkgs;
};
# Fix impurities. Without these some of the user's environment # Fix impurities. Without these some of the user's environment
# will leak into the tests through `builtins.getEnv`. # will leak into the tests through `builtins.getEnv`.
xdg.enable = true; xdg.enable = true;
home = { home = {
username = "hm-user"; username = "hm-user";
homeDirectory = "/home/hm-user"; homeDirectory = "/home/hm-user";
stateVersion = lib.mkDefault "18.09"; stateVersion = lib.mkDefault "18.09";
}; };
# Avoid including documentation since this will cause # Avoid including documentation since this will cause
# unnecessary rebuilds of the tests. # unnecessary rebuilds of the tests.
manual.manpages.enable = lib.mkDefault false; manual.manpages.enable = lib.mkDefault false;
imports = [ ./asserts.nix ./big-test.nix ./stubs.nix ]; imports = [ ./asserts.nix ./big-test.nix ./stubs.nix ];
test.enableBig = enableBig; test.enableBig = enableBig;
}]; })
];
isDarwin = pkgs.stdenv.hostPlatform.isDarwin; isDarwin = pkgs.stdenv.hostPlatform.isDarwin;
isLinux = pkgs.stdenv.hostPlatform.isLinux; isLinux = pkgs.stdenv.hostPlatform.isLinux;

View file

@ -15,24 +15,23 @@
}; };
}; };
i18n-custom-locales = { pkgs, ... }: { i18n-custom-locales = { config, pkgs, ... }: {
config = let stub = pkgs.glibcLocalesCustom; config = let
in { customGlibcLocales = pkgs.glibcLocales.override {
test.stubs.glibcLocalesCustom = { allLocales = false;
inherit (pkgs.glibcLocales) version; locales = [ "en_US.UTF-8/UTF-8" ];
outPath = null; # we need a real path for this stub
}; };
in {
i18n.glibcLocales = stub; i18n.glibcLocales = customGlibcLocales;
nmt.script = '' nmt.script = ''
hmEnvFile=home-path/etc/profile.d/hm-session-vars.sh hmEnvFile=home-path/etc/profile.d/hm-session-vars.sh
assertFileExists $hmEnvFile assertFileExists $hmEnvFile
assertFileRegex $hmEnvFile 'LOCALE_ARCHIVE_.*${stub}' assertFileRegex $hmEnvFile 'LOCALE_ARCHIVE_.*${customGlibcLocales}'
envFile=home-files/.config/environment.d/10-home-manager.conf envFile=home-files/.config/environment.d/10-home-manager.conf
assertFileExists $envFile assertFileExists $envFile
assertFileRegex $envFile 'LOCALE_ARCHIVE_.*${stub}' assertFileRegex $envFile 'LOCALE_ARCHIVE_.*${customGlibcLocales}'
''; '';
}; };
}; };

View file

@ -1,13 +1,13 @@
{ config, pkgs, ... }: { config, lib, realPkgs, ... }:
{
imports = [ ./fcitx5-stubs.nix ];
lib.mkIf config.test.enableBig {
i18n.inputMethod = { i18n.inputMethod = {
enabled = "fcitx5"; enabled = "fcitx5";
fcitx5.waylandFrontend = true; fcitx5.waylandFrontend = true;
}; };
_module.args.pkgs = lib.mkForce realPkgs;
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/systemd/user/fcitx5-daemon.service assertFileExists home-files/.config/systemd/user/fcitx5-daemon.service
assertFileNotRegex home-path/etc/profile.d/hm-session-vars.sh 'GTK_IM_MODULE' assertFileNotRegex home-path/etc/profile.d/hm-session-vars.sh 'GTK_IM_MODULE'

View file

@ -1,57 +0,0 @@
{
test.stubs = {
fcitx5 = {
version = "0";
outPath = null;
buildScript = ''
mkdir -p $out/bin $out/share/applications $out/share/dbus-1/services $out/etc/xdg/autostart
touch $out/bin/fcitx5 \
$out/bin/fcitx5-config-qt \
$out/share/applications/org.fcitx.Fcitx5.desktop \
$out/share/dbus-1/services/org.fcitx.Fcitx5.service \
$out/etc/xdg/autostart/org.fcitx.Fcitx5.desktop
# The grep usage of fcitx5-with-addons expects one of the files to match with the fcitx5.out
# https://github.com/NixOS/nixpkgs/blob/d2eb4be48705289791428c07aca8ff654c1422ba/pkgs/tools/inputmethods/fcitx5/with-addons.nix#L40-L44
echo $out >> $out/etc/xdg/autostart/org.fcitx.Fcitx5.desktop
chmod +x $out/bin/fcitx5 \
$out/bin/fcitx5-config-qt
'';
};
fcitx5-lua = { outPath = null; };
fcitx5-gtk = { outPath = null; };
gtk2 = {
buildScript = ''
mkdir -p $out/bin
echo '#/usr/bin/env bash' > $out/bin/gtk-query-immodules-2.0
chmod +x $out/bin/*
'';
};
gtk3 = {
buildScript = ''
mkdir -p $out/bin
echo '#/usr/bin/env bash' > $out/bin/gtk-query-immodules-3.0
chmod +x $out/bin/*
'';
};
};
nixpkgs.overlays = [
(final: prev: {
libsForQt5 = prev.libsForQt5.overrideScope (qt5final: qt5prev: {
fcitx5-chinese-addons = prev.mkStubPackage { outPath = null; };
fcitx5-configtool = prev.mkStubPackage { outPath = null; };
fcitx5-qt = prev.mkStubPackage { outPath = null; };
fcitx5-with-addons = qt5prev.fcitx5-with-addons.override {
inherit (final) libsForQt5 qt6Packages;
};
});
qt6Packages = prev.qt6Packages.overrideScope (qt6final: qt6prev: {
fcitx5-qt = prev.mkStubPackage { outPath = null; };
});
})
];
}

View file

@ -1,5 +1,3 @@
{ config, pkgs, ... }:
let let
kimeConfig = '' kimeConfig = ''

View file

@ -1,8 +1,8 @@
{ {
debug = { pkgs, config, lib, ... }: debug = { realPkgs, config, lib, ... }:
lib.mkIf config.test.enableBig { lib.mkIf config.test.enableBig {
home.enableDebugInfo = true; home.enableDebugInfo = true;
home.packages = with pkgs; [ curl gdb ]; home.packages = with realPkgs; [ curl gdb ];
nmt.script = '' nmt.script = ''
[ -L $TESTED/home-path/lib/debug/curl ] \ [ -L $TESTED/home-path/lib/debug/curl ] \

View file

@ -1,17 +1,11 @@
{ config, lib, pkgs, ... }:
with lib;
{ {
config = { home.packages = [
home.packages = [ # Look, no font!
# Look, no font! ];
];
fonts.fontconfig.enable = true; fonts.fontconfig.enable = true;
nmt.script = '' nmt.script = ''
assertPathNotExists home-path/lib/fontconfig/cache assertPathNotExists home-path/lib/fontconfig/cache
''; '';
};
} }

View file

@ -1,15 +1,13 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, realPkgs, ... }:
with lib; lib.mkIf config.test.enableBig {
home.packages = [ pkgs.comic-relief ];
{ fonts.fontconfig.enable = true;
config = {
home.packages = [ pkgs.comic-relief ];
fonts.fontconfig.enable = true; _module.args.pkgs = lib.mkForce realPkgs;
nmt.script = '' nmt.script = ''
assertDirectoryNotEmpty home-path/lib/fontconfig/cache assertDirectoryNotEmpty home-path/lib/fontconfig/cache
''; '';
};
} }

View file

@ -1,25 +1,17 @@
{ config, lib, pkgs, ... }:
with lib;
{ {
config = { gtk = {
gtk = { enable = true;
enable = true; theme.name = "Adwaita";
theme.name = "Adwaita"; gtk2.extraConfig = "gtk-can-change-accels = 1";
gtk2.extraConfig = "gtk-can-change-accels = 1";
};
test.stubs.dconf = { };
nmt.script = ''
assertFileExists home-files/.gtkrc-2.0
assertFileContent home-files/.gtkrc-2.0 \
${./gtk2-basic-config-expected.conf}
assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \
'GTK2_RC_FILES=.*/.gtkrc-2.0'
'';
}; };
nmt.script = ''
assertFileExists home-files/.gtkrc-2.0
assertFileContent home-files/.gtkrc-2.0 \
${./gtk2-basic-config-expected.conf}
assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \
'GTK2_RC_FILES=.*/.gtkrc-2.0'
'';
} }

View file

@ -1,18 +1,12 @@
{ config, lib, pkgs, ... }: { config, ... }:
with lib;
{ {
config = { gtk.enable = true;
gtk.enable = true; gtk.gtk2.configLocation = "${config.xdg.configHome}/gtk-2.0/gtkrc";
gtk.gtk2.configLocation = "${config.xdg.configHome}/gtk-2.0/gtkrc";
test.stubs.dconf = { }; nmt.script = ''
assertFileExists home-files/.config/gtk-2.0/gtkrc
nmt.script = '' assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \
assertFileExists home-files/.config/gtk-2.0/gtkrc 'GTK2_RC_FILES=.*/\.config/gtk-2.0/gtkrc'
assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \ '';
'GTK2_RC_FILES=.*/\.config/gtk-2.0/gtkrc'
'';
};
} }

View file

@ -1,24 +1,16 @@
{ config, lib, pkgs, ... }:
with lib;
{ {
config = { gtk = {
gtk = { enable = true;
enable = true; gtk3.extraConfig = {
gtk3.extraConfig = { gtk-cursor-blink = false;
gtk-cursor-blink = false; gtk-recent-files-limit = 20;
gtk-recent-files-limit = 20;
};
}; };
test.stubs.dconf = { };
nmt.script = ''
assertFileExists home-files/.config/gtk-3.0/settings.ini
assertFileContent home-files/.config/gtk-3.0/settings.ini \
${./gtk3-basic-settings-expected.ini}
'';
}; };
nmt.script = ''
assertFileExists home-files/.config/gtk-3.0/settings.ini
assertFileContent home-files/.config/gtk-3.0/settings.ini \
${./gtk3-basic-settings-expected.ini}
'';
} }

View file

@ -1,22 +1,22 @@
{ ... }: { lib, realPkgs, ... }:
{ {
config = { manual = {
manual = { html.enable = true;
html.enable = true; manpages.enable = true;
manpages.enable = true; json.enable = true;
json.enable = true;
};
nmt.script = ''
assertFileExists home-path/share/doc/home-manager/index.xhtml
assertFileExists home-path/share/doc/home-manager/options.json
assertFileExists home-path/share/doc/home-manager/options.xhtml
assertFileExists home-path/share/doc/home-manager/nixos-options.xhtml
assertFileExists home-path/share/doc/home-manager/nix-darwin-options.xhtml
assertFileExists home-path/share/doc/home-manager/release-notes.xhtml
assertFileExists home-path/share/man/man1/home-manager.1
assertFileExists home-path/share/man/man5/home-configuration.nix.5
'';
}; };
_module.args.pkgs = lib.mkForce realPkgs;
nmt.script = ''
assertFileExists home-path/share/doc/home-manager/index.xhtml
assertFileExists home-path/share/doc/home-manager/options.json
assertFileExists home-path/share/doc/home-manager/options.xhtml
assertFileExists home-path/share/doc/home-manager/nixos-options.xhtml
assertFileExists home-path/share/doc/home-manager/nix-darwin-options.xhtml
assertFileExists home-path/share/doc/home-manager/release-notes.xhtml
assertFileExists home-path/share/man/man1/home-manager.1
assertFileExists home-path/share/man/man5/home-configuration.nix.5
'';
} }

View file

@ -1,16 +1,8 @@
{ config, lib, pkgs, ... }:
with lib;
{ {
config = { xsession.numlock.enable = true;
xsession.numlock.enable = true;
test.stubs.numlockx = { }; nmt.script = ''
serviceFile=home-files/.config/systemd/user/numlockx.service
nmt.script = '' assertFileExists $serviceFile
serviceFile=home-files/.config/systemd/user/numlockx.service '';
assertFileExists $serviceFile
'';
};
} }

View file

@ -6,13 +6,6 @@
style.name = "adwaita"; style.name = "adwaita";
}; };
test.stubs = {
qgnomeplatform = { };
qgnomeplatform-qt6 = { };
adwaita-qt = { };
adwaita-qt6 = { };
};
nmt.script = '' nmt.script = ''
assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \ assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \
'QT_QPA_PLATFORMTHEME="gnome"' 'QT_QPA_PLATFORMTHEME="gnome"'

View file

@ -1,6 +1,6 @@
{ { config, ... }:
imports = [ ../../i18n/input-method/fcitx5-stubs.nix ];
{
qt = { qt = {
enable = true; enable = true;
platformTheme.name = "gtk"; platformTheme.name = "gtk";
@ -11,11 +11,11 @@
nixpkgs.overlays = [ nixpkgs.overlays = [
(final: prev: { (final: prev: {
libsForQt5 = prev.libsForQt5.overrideScope (qt5final: qt5prev: { libsForQt5 = prev.libsForQt5.overrideScope (qt5final: qt5prev: {
qtstyleplugins = prev.mkStubPackage { outPath = null; }; qtstyleplugins = config.lib.test.mkStubPackage { outPath = null; };
}); });
qt6Packages = prev.qt6Packages.overrideScope (qt6final: qt6prev: { qt6Packages = prev.qt6Packages.overrideScope (qt6final: qt6prev: {
qt6gtk2 = prev.mkStubPackage { outPath = null; }; qt6gtk2 = config.lib.test.mkStubPackage { outPath = null; };
}); });
}) })
]; ];

View file

@ -1,20 +1,38 @@
{ pkgs, ... }: { { pkgs, ... }:
config = {
xdg.autostart = {
enable = true;
entries = [
"${pkgs.evolution}/share/applications/org.gnome.Evolution.desktop"
"${pkgs.tdesktop}/share/applications/org.telegram.desktop.desktop"
];
};
nmt.script = '' {
assertFileExists home-files/.config/autostart/org.gnome.Evolution.desktop xdg.autostart = {
assertFileContent home-files/.config/autostart/org.gnome.Evolution.desktop \ enable = true;
${pkgs.evolution}/share/applications/org.gnome.Evolution.desktop entries = [
assertFileExists home-files/.config/autostart/org.telegram.desktop.desktop "${pkgs.test1}/share/applications/test1.desktop"
assertFileContent home-files/.config/autostart/org.telegram.desktop.desktop \ "${pkgs.test2}/share/applications/test2.desktop"
${pkgs.tdesktop}/share/applications/org.telegram.desktop.desktop ];
'';
}; };
test.stubs = {
test1 = {
outPath = null;
buildScript = ''
mkdir -p $out/share/applications
echo test1 > $out/share/applications/test1.desktop
'';
};
test2 = {
outPath = null;
buildScript = ''
mkdir -p $out/share/applications
echo test2 > $out/share/applications/test2.desktop
'';
};
};
nmt.script = ''
assertFileExists home-files/.config/autostart/test1.desktop
assertFileContent home-files/.config/autostart/test1.desktop \
${pkgs.test1}/share/applications/test1.desktop
assertFileExists home-files/.config/autostart/test2.desktop
assertFileContent home-files/.config/autostart/test2.desktop \
${pkgs.test2}/share/applications/test2.desktop
'';
} }

View file

@ -1,26 +1,28 @@
{ config, lib, pkgs, ... }: { config, lib, realPkgs, ... }:
lib.mkIf config.test.enableBig { lib.mkIf config.test.enableBig {
xdg.portal = { xdg.portal = {
enable = true; enable = true;
extraPortals = extraPortals =
[ pkgs.xdg-desktop-portal-hyprland pkgs.xdg-desktop-portal-wlr ]; [ realPkgs.xdg-desktop-portal-hyprland realPkgs.xdg-desktop-portal-wlr ];
configPackages = [ pkgs.hyprland ]; configPackages = [ realPkgs.hyprland ];
config = { sway.default = [ "wlr" "gtk" ]; }; config = { sway.default = [ "wlr" "gtk" ]; };
}; };
test.unstubs = [ (self: super: { inherit (realPkgs) xdg-desktop-portal; }) ];
nmt.script = '' nmt.script = ''
assertFileExists home-path/share/systemd/user/xdg-desktop-portal.service assertFileExists home-path/share/systemd/user/xdg-desktop-portal.service
assertFileExists home-path/share/systemd/user/xdg-desktop-portal-wlr.service assertFileExists home-path/share/systemd/user/xdg-desktop-portal-wlr.service
assertFileExists home-path/share/systemd/user/xdg-desktop-portal-hyprland.service assertFileExists home-path/share/systemd/user/xdg-desktop-portal-hyprland.service
assertFileContent home-path/share/xdg-desktop-portal/portals/hyprland.portal \ assertFileContent home-path/share/xdg-desktop-portal/portals/hyprland.portal \
${pkgs.xdg-desktop-portal-hyprland}/share/xdg-desktop-portal/portals/hyprland.portal ${realPkgs.xdg-desktop-portal-hyprland}/share/xdg-desktop-portal/portals/hyprland.portal
assertFileContent home-path/share/xdg-desktop-portal/portals/wlr.portal \ assertFileContent home-path/share/xdg-desktop-portal/portals/wlr.portal \
${pkgs.xdg-desktop-portal-wlr}/share/xdg-desktop-portal/portals/wlr.portal ${realPkgs.xdg-desktop-portal-wlr}/share/xdg-desktop-portal/portals/wlr.portal
assertFileContent home-path/share/xdg-desktop-portal/hyprland-portals.conf \ assertFileContent home-path/share/xdg-desktop-portal/hyprland-portals.conf \
${pkgs.hyprland}/share/xdg-desktop-portal/hyprland-portals.conf ${realPkgs.hyprland}/share/xdg-desktop-portal/hyprland-portals.conf
assertFileContent home-files/.config/xdg-desktop-portal/sway-portals.conf \ assertFileContent home-files/.config/xdg-desktop-portal/sway-portals.conf \
${./sway-portals-expected.conf} ${./sway-portals-expected.conf}
''; '';

View file

@ -6,8 +6,6 @@ with lib;
config = { config = {
programs.abook.enable = true; programs.abook.enable = true;
test.stubs.abook = { };
nmt.script = '' nmt.script = ''
assertPathNotExists home-files/.config/abook/abookrc assertPathNotExists home-files/.config/abook/abookrc
''; '';

View file

@ -28,8 +28,6 @@ with lib;
''; '';
}; };
test.stubs.abook = { };
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/abook/abookrc assertFileExists home-files/.config/abook/abookrc
assertFileContent home-files/.config/abook/abookrc ${./with-settings.cfg} assertFileContent home-files/.config/abook/abookrc ${./with-settings.cfg}

View file

@ -19,8 +19,6 @@ with lib;
This option is safe; if `passwordCommand` is properly set, no credentials will be written to the nix store. This option is safe; if `passwordCommand` is properly set, no credentials will be written to the nix store.
'']; ''];
test.stubs.aerc = { };
programs.aerc = { programs.aerc = {
enable = true; enable = true;
extraAccounts = { extraAccounts = {

View file

@ -12,7 +12,5 @@ with lib;
assertPathNotExists ${dir}/stylesets assertPathNotExists ${dir}/stylesets
''; '';
programs.aerc.enable = true; programs.aerc.enable = true;
test.stubs.aerc = { };
}; };
} }

View file

@ -19,8 +19,6 @@ with lib;
assertFileContent ${dir}/stylesets/asLines ${./stylesets.expected} assertFileContent ${dir}/stylesets/asLines ${./stylesets.expected}
''; '';
test.stubs.aerc = { };
programs.aerc = { programs.aerc = {
enable = true; enable = true;

View file

@ -17,8 +17,6 @@
}; };
}; };
test.stubs.aerospace = { };
nmt.script = '' nmt.script = ''
assertFileContent home-files/.config/aerospace/aerospace.toml ${ assertFileContent home-files/.config/aerospace/aerospace.toml ${
./settings-expected.toml ./settings-expected.toml

View file

@ -1,11 +1,7 @@
{ {
config = { programs.alacritty.enable = true;
programs.alacritty.enable = true;
test.stubs.alacritty = { }; nmt.script = ''
assertPathNotExists home-files/.config/alacritty
nmt.script = '' '';
assertPathNotExists home-files/.config/alacritty
'';
};
} }

View file

@ -1,31 +1,23 @@
{ config, ... }:
{ {
config = { programs.alacritty = {
programs.alacritty = { enable = true;
enable = true; settings = {
package = config.lib.test.mkStubPackage { }; window.dimensions = {
lines = 3;
settings = { columns = 200;
window.dimensions = {
lines = 3;
columns = 200;
};
keyboard.bindings = [{
key = "K";
mods = "Control";
chars = "\\u000c";
}];
}; };
keyboard.bindings = [{
key = "K";
mods = "Control";
chars = "\\u000c";
}];
}; };
test.stubs = { alacritty = { }; };
nmt.script = ''
assertFileContent \
home-files/.config/alacritty/alacritty.toml \
${./example-settings-expected.toml}
'';
}; };
nmt.script = ''
assertFileContent \
home-files/.config/alacritty/alacritty.toml \
${./example-settings-expected.toml}
'';
} }

View file

@ -1,39 +1,33 @@
{ config, lib, ... }: { lib, ... }:
{ {
config = { programs.alacritty = {
programs.alacritty = { enable = true;
enable = true; settings = {
package = config.lib.test.mkStubPackage { }; window.dimensions = {
lines = 3;
columns = 200;
};
settings = { keyboard.bindings = [{
window.dimensions = { key = "K";
lines = 3; mods = "Control";
columns = 200; chars = "\\u000c";
}; }];
keyboard.bindings = [{ font = let
key = "K"; defaultFont =
mods = "Control"; lib.mkMerge [ (lib.mkIf true "SFMono") (lib.mkIf false "Iosevka") ];
chars = "\\u000c"; in {
}]; normal.family = defaultFont;
bold.family = defaultFont;
font = let
defaultFont =
lib.mkMerge [ (lib.mkIf true "SFMono") (lib.mkIf false "Iosevka") ];
in {
normal.family = defaultFont;
bold.family = defaultFont;
};
}; };
}; };
test.stubs = { alacritty = { }; };
nmt.script = ''
assertFileContent \
home-files/.config/alacritty/alacritty.toml \
${./settings-toml-expected.toml}
'';
}; };
nmt.script = ''
assertFileContent \
home-files/.config/alacritty/alacritty.toml \
${./settings-toml-expected.toml}
'';
} }

View file

@ -1,36 +1,28 @@
{ config, ... }:
{ {
config = { programs.alacritty = {
programs.alacritty = { enable = true;
enable = true; settings = {
package = config.lib.test.mkStubPackage { }; window.dimensions = {
lines = 3;
columns = 200;
};
settings = { keyboard.bindings = [{
window.dimensions = { key = "K";
lines = 3; mods = "Control";
columns = 200; chars = "\\u000c";
}; }];
keyboard.bindings = [{ font = {
key = "K"; normal.family = "SFMono";
mods = "Control"; bold.family = "SFMono";
chars = "\\u000c";
}];
font = {
normal.family = "SFMono";
bold.family = "SFMono";
};
}; };
}; };
test.stubs = { alacritty = { }; };
nmt.script = ''
assertFileContent \
home-files/.config/alacritty/alacritty.toml \
${./settings-toml-expected.toml}
'';
}; };
nmt.script = ''
assertFileContent \
home-files/.config/alacritty/alacritty.toml \
${./settings-toml-expected.toml}
'';
} }

View file

@ -1,34 +1,26 @@
{ config, lib, pkgs, ... }:
with lib;
{ {
imports = [ ../../accounts/email-test-accounts.nix ]; imports = [ ../../accounts/email-test-accounts.nix ];
config = { accounts.email.accounts = {
accounts.email.accounts = { "hm@example.com" = {
"hm@example.com" = { notmuch.enable = true;
notmuch.enable = true; alot = {
alot = { contactCompletion = { };
contactCompletion = { }; extraConfig = ''
extraConfig = '' auto_remove_unread = True
auto_remove_unread = True ask_subject = False
ask_subject = False handle_mouse = True
handle_mouse = True '';
'';
};
imap.port = 993;
}; };
imap.port = 993;
}; };
programs.alot = { enable = true; };
test.stubs.alot = { };
nmt.script = ''
assertFileExists home-files/.config/alot/config
assertFileContent home-files/.config/alot/config ${./alot-expected.conf}
'';
}; };
programs.alot = { enable = true; };
nmt.script = ''
assertFileExists home-files/.config/alot/config
assertFileContent home-files/.config/alot/config ${./alot-expected.conf}
'';
} }

View file

@ -1,5 +1,3 @@
{ pkgs, ... }:
let relToDotDirCustom = ".zshplugins"; let relToDotDirCustom = ".zshplugins";
in { in {
programs.zsh = { programs.zsh = {
@ -12,11 +10,6 @@ in {
}; };
}; };
test.stubs = {
antidote = { };
zsh = { };
};
nmt.script = '' nmt.script = ''
assertFileContains home-files/${relToDotDirCustom}/.zshrc \ assertFileContains home-files/${relToDotDirCustom}/.zshrc \
'source @antidote@/share/antidote/antidote.zsh' 'source @antidote@/share/antidote/antidote.zsh'

View file

@ -1,40 +1,32 @@
{ config, lib, pkgs, ... }:
with lib;
{ {
config = { programs.aria2 = {
programs.aria2 = { enable = true;
enable = true;
settings = { settings = {
listen-port = 60000; listen-port = 60000;
dht-listen-port = 60000; dht-listen-port = 60000;
seed-ratio = 1.0; seed-ratio = 1.0;
max-upload-limit = "50K"; max-upload-limit = "50K";
ftp-pasv = true; ftp-pasv = true;
};
extraConfig = ''
# Extra aria2 configuration.
'';
}; };
test.stubs.aria2 = { }; extraConfig = ''
# Extra aria2 configuration.
nmt.script = ''
assertFileContent \
home-files/.config/aria2/aria2.conf \
${
pkgs.writeText "aria2-expected-config.conf" ''
dht-listen-port=60000
ftp-pasv=true
listen-port=60000
max-upload-limit=50K
seed-ratio=1.000000
# Extra aria2 configuration.
''
}
''; '';
}; };
nmt.script = ''
assertFileContent \
home-files/.config/aria2/aria2.conf \
${
builtins.toFile "aria2-expected-config.conf" ''
dht-listen-port=60000
ftp-pasv=true
listen-port=60000
max-upload-limit=50K
seed-ratio=1.000000
# Extra aria2 configuration.
''
}
'';
} }

View file

@ -1,5 +1,3 @@
{ ... }:
{ {
programs = { programs = {
atuin.enable = true; atuin.enable = true;
@ -9,11 +7,6 @@
}; };
}; };
test.stubs = {
atuin = { name = "atuin"; };
bash-preexec = { };
};
nmt.script = '' nmt.script = ''
assertFileExists home-files/.bashrc assertFileExists home-files/.bashrc
assertFileContains \ assertFileContains \

View file

@ -1,13 +1,6 @@
{ ... }:
{ {
programs.atuin.enable = true; programs.atuin.enable = true;
test.stubs = {
atuin = { name = "atuin"; };
bash-preexec = { };
};
nmt.script = '' nmt.script = ''
assertPathNotExists home-files/.config/atuin/config.toml assertPathNotExists home-files/.config/atuin/config.toml
''; '';

View file

@ -12,11 +12,6 @@
}; };
}; };
test.stubs = {
atuin = { name = "atuin"; };
bash-preexec = { };
};
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \
home-files/.config/atuin/config.toml \ home-files/.config/atuin/config.toml \

View file

@ -10,11 +10,6 @@
xdg.dataFile."fish/home-manager_generated_completions".source = xdg.dataFile."fish/home-manager_generated_completions".source =
lib.mkForce (builtins.toFile "empty" ""); lib.mkForce (builtins.toFile "empty" "");
test.stubs = {
atuin = { name = "atuin"; };
bash-preexec = { };
};
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/fish/config.fish assertFileExists home-files/.config/fish/config.fish
assertFileContains \ assertFileContains \

View file

@ -17,11 +17,6 @@
xdg.dataFile."fish/home-manager_generated_completions".source = xdg.dataFile."fish/home-manager_generated_completions".source =
lib.mkForce (builtins.toFile "empty" ""); lib.mkForce (builtins.toFile "empty" "");
test.stubs = {
atuin = { name = "atuin"; };
bash-preexec = { };
};
nmt.script = '' nmt.script = ''
assertFileNotRegex home-files/.zshrc 'atuin init zsh' assertFileNotRegex home-files/.zshrc 'atuin init zsh'
assertFileNotRegex home-files/.bashrc 'atuin init bash' assertFileNotRegex home-files/.bashrc 'atuin init bash'

View file

@ -16,11 +16,6 @@
xdg.dataFile."fish/home-manager_generated_completions".source = xdg.dataFile."fish/home-manager_generated_completions".source =
lib.mkForce (builtins.toFile "empty" ""); lib.mkForce (builtins.toFile "empty" "");
test.stubs = {
atuin = { name = "atuin"; };
bash-preexec = { };
};
nmt.script = '' nmt.script = ''
assertFileExists home-files/.bashrc assertFileExists home-files/.bashrc
assertFileContains \ assertFileContains \

View file

@ -1,16 +1,9 @@
{ ... }:
{ {
programs = { programs = {
atuin.enable = true; atuin.enable = true;
zsh.enable = true; zsh.enable = true;
}; };
test.stubs = {
atuin = { name = "atuin"; };
bash-preexec = { };
};
nmt.script = '' nmt.script = ''
assertFileExists home-files/.zshrc assertFileExists home-files/.zshrc
assertFileContains \ assertFileContains \

View file

@ -1,18 +1,12 @@
{ config, lib, pkgs, ... }:
with lib;
{ {
config = { programs.autojump.enable = true;
programs.autojump.enable = true;
test.stubs.autojump = { test.stubs.autojump = {
buildScript = "mkdir -p $out/bin; touch $out/bin/autojump"; buildScript = "mkdir -p $out/bin; touch $out/bin/autojump";
outPath = null; outPath = null;
};
nmt.script = ''
assertFileExists home-path/bin/autojump
'';
}; };
nmt.script = ''
assertFileExists home-path/bin/autojump
'';
} }

View file

@ -1,66 +1,60 @@
{ config, pkgs, ... }:
{ {
config = { programs.autorandr = {
programs.autorandr = { enable = true;
enable = true; profiles = {
profiles = { default = {
default = { fingerprint = {
fingerprint = { DP1 = "XXX";
DP1 = "XXX"; DP2 = "YYY";
DP2 = "YYY"; };
}; config = {
config = { DP1.enable = false;
DP1.enable = false; DP2 = {
DP2 = { crtc = 0;
crtc = 0; primary = true;
primary = true; position = "0x0";
position = "0x0"; mode = "1920x1080";
mode = "1920x1080"; filter = "nearest";
filter = "nearest"; transform = [
transform = [ [ 0.6 0.0 0.0 ] # a b c
[ 0.6 0.0 0.0 ] # a b c [ 0.0 0.6 0.0 ] # d e f
[ 0.0 0.6 0.0 ] # d e f [ 0.0 0.0 1.0 ] # g h i
[ 0.0 0.0 1.0 ] # g h i ];
]; extraConfig = ''
extraConfig = '' key1 value1
key1 value1 key2 value2
key2 value2 '';
'';
};
}; };
}; };
}; };
}; };
test.stubs.autorandr = { };
nmt.script = ''
config=home-files/.config/autorandr/default/config
setup=home-files/.config/autorandr/default/setup
assertFileExists $setup
assertFileRegex $setup 'DP1 XXX'
assertFileRegex $setup 'DP2 YYY'
assertFileExists $config
assertFileContent $config \
${
pkgs.writeText "basic-configuration.conf" ''
output DP1
off
output DP2
pos 0x0
crtc 0
primary
mode 1920x1080
filter nearest
transform 0.600000,0.000000,0.000000,0.000000,0.600000,0.000000,0.000000,0.000000,1.000000
key1 value1
key2 value2
''
}
'';
}; };
nmt.script = ''
config=home-files/.config/autorandr/default/config
setup=home-files/.config/autorandr/default/setup
assertFileExists $setup
assertFileRegex $setup 'DP1 XXX'
assertFileRegex $setup 'DP2 YYY'
assertFileExists $config
assertFileContent $config \
${
builtins.toFile "basic-configuration.conf" ''
output DP1
off
output DP2
pos 0x0
crtc 0
primary
mode 1920x1080
filter nearest
transform 0.600000,0.000000,0.000000,0.000000,0.600000,0.000000,0.000000,0.000000,1.000000
key1 value1
key2 value2
''
}
'';
} }

View file

@ -1,34 +1,28 @@
{ config, pkgs, ... }:
{ {
config = { programs.autorandr = {
programs.autorandr = { enable = true;
enable = true; profiles = {
profiles = { default = {
default = { fingerprint.DP1 = "XXX";
fingerprint.DP1 = "XXX"; config.DP1 = {
config.DP1 = { scale = {
scale = { x = 2;
x = 2; y = 4;
y = 4;
};
}; };
}; };
}; };
}; };
test.stubs.autorandr = { };
nmt.script = ''
config=home-files/.config/autorandr/default/config
assertFileExists $config
assertFileContent $config \
${
pkgs.writeText "scale-expected.conf" ''
output DP1
scale 2x4''
}
'';
}; };
nmt.script = ''
config=home-files/.config/autorandr/default/config
assertFileExists $config
assertFileContent $config \
${
builtins.toFile "scale-expected.conf" ''
output DP1
scale 2x4''
}
'';
} }

View file

@ -1,5 +1,3 @@
{ ... }:
{ {
programs = { programs = {
awscli = { awscli = {
@ -14,8 +12,6 @@
}; };
}; };
test.stubs.awscli2 = { };
nmt.script = '' nmt.script = ''
assertFileExists home-files/.aws/config assertFileExists home-files/.aws/config
assertFileContent home-files/.aws/config \ assertFileContent home-files/.aws/config \

View file

@ -21,7 +21,7 @@ in {
}; };
}; };
}; };
test.stubs.bacon = { };
nmt.script = '' nmt.script = ''
assertFileExists 'home-files/${configDir}/prefs.toml' assertFileExists 'home-files/${configDir}/prefs.toml'
assertFileContent 'home-files/${configDir}/prefs.toml' ${./expected.toml} assertFileContent 'home-files/${configDir}/prefs.toml' ${./expected.toml}

View file

@ -7,8 +7,6 @@ let
in { in {
programs.bacon.enable = true; programs.bacon.enable = true;
test.stubs.bacon = { };
nmt.script = '' nmt.script = ''
assertPathNotExists 'home-files/${configDir}/prefs.toml' assertPathNotExists 'home-files/${configDir}/prefs.toml'
''; '';

View file

@ -1,12 +1,6 @@
{ config, lib, pkgs, ... }:
with lib;
{ {
programs.bash.enable = true; programs.bash.enable = true;
test.stubs.bash-completion = { };
nmt.script = '' nmt.script = ''
assertFileExists home-files/.bashrc assertFileExists home-files/.bashrc

View file

@ -1,27 +1,21 @@
{ config, lib, pkgs, ... }:
with lib;
{ {
config = { programs.bash = {
programs.bash = { enable = true;
enable = true; enableCompletion = false;
enableCompletion = false;
logoutExtra = '' logoutExtra = ''
clear-console clear-console
'';
};
nmt.script = ''
assertFileExists home-files/.bash_logout
assertFileContent \
home-files/.bash_logout \
${
builtins.toFile "logout-expected" ''
clear-console
''
}
''; '';
}; };
nmt.script = ''
assertFileExists home-files/.bash_logout
assertFileContent \
home-files/.bash_logout \
${
builtins.toFile "logout-expected" ''
clear-console
''
}
'';
} }

View file

@ -1,33 +1,29 @@
{ config, lib, pkgs, ... }: { config, ... }:
with lib;
{ {
config = { programs.bash = {
programs.bash = { enable = true;
enable = true; enableCompletion = false;
enableCompletion = false;
sessionVariables = { sessionVariables = {
V1 = "v1"; V1 = "v1";
V2 = "v2-${config.programs.bash.sessionVariables.V1}"; V2 = "v2-${config.programs.bash.sessionVariables.V1}";
};
}; };
nmt.script = ''
assertFileExists home-files/.profile
assertFileContent \
home-files/.profile \
${
builtins.toFile "session-variables-expected" ''
. "/home/hm-user/.nix-profile/etc/profile.d/hm-session-vars.sh"
export V1="v1"
export V2="v2-v1"
''
}
'';
}; };
nmt.script = ''
assertFileExists home-files/.profile
assertFileContent \
home-files/.profile \
${
builtins.toFile "session-variables-expected" ''
. "/home/hm-user/.nix-profile/etc/profile.d/hm-session-vars.sh"
export V1="v1"
export V2="v2-v1"
''
}
'';
} }

View file

@ -1,58 +1,50 @@
{ config, lib, pkgs, ... }:
with lib;
{ {
config = { programs.bat = {
programs.bat = { enable = true;
enable = true;
config = { config = {
theme = "TwoDark"; theme = "TwoDark";
pager = "less -FR"; pager = "less -FR";
map-syntax = [ "*.jenkinsfile:Groovy" "*.props:Java Properties" ]; map-syntax = [ "*.jenkinsfile:Groovy" "*.props:Java Properties" ];
show-all = true; show-all = true;
# False boolean options should not appear in the config # False boolean options should not appear in the config
lessopen = false; lessopen = false;
};
themes.testtheme.src = pkgs.writeText "testtheme.tmTheme" ''
This is a test theme.
'';
syntaxes.testsyntax.src = pkgs.writeText "testsyntax.sublime-syntax" ''
This is a test syntax.
'';
}; };
test.stubs.bat = { }; themes.testtheme.src = builtins.toFile "testtheme.tmTheme" ''
This is a test theme.
'';
nmt.script = '' syntaxes.testsyntax.src = builtins.toFile "testsyntax.sublime-syntax" ''
assertFileExists home-files/.config/bat/config This is a test syntax.
assertFileContent home-files/.config/bat/config ${
pkgs.writeText "bat.expected" ''
--map-syntax='*.jenkinsfile:Groovy'
--map-syntax='*.props:Java Properties'
--pager='less -FR'
--theme=TwoDark
--show-all
''
}
assertFileExists home-files/.config/bat/themes/testtheme.tmTheme
assertFileContent home-files/.config/bat/themes/testtheme.tmTheme ${
pkgs.writeText "bat.expected" ''
This is a test theme.
''
}
assertFileExists home-files/.config/bat/syntaxes/testsyntax.sublime-syntax
assertFileContent home-files/.config/bat/syntaxes/testsyntax.sublime-syntax ${
pkgs.writeText "bat.expected" ''
This is a test syntax.
''
}
''; '';
}; };
nmt.script = ''
assertFileExists home-files/.config/bat/config
assertFileContent home-files/.config/bat/config ${
builtins.toFile "bat.expected" ''
--map-syntax='*.jenkinsfile:Groovy'
--map-syntax='*.props:Java Properties'
--pager='less -FR'
--theme=TwoDark
--show-all
''
}
assertFileExists home-files/.config/bat/themes/testtheme.tmTheme
assertFileContent home-files/.config/bat/themes/testtheme.tmTheme ${
builtins.toFile "bat.expected" ''
This is a test theme.
''
}
assertFileExists home-files/.config/bat/syntaxes/testsyntax.sublime-syntax
assertFileContent home-files/.config/bat/syntaxes/testsyntax.sublime-syntax ${
builtins.toFile "bat.expected" ''
This is a test syntax.
''
}
'';
} }

View file

@ -1,67 +1,59 @@
{ config, lib, pkgs, ... }:
with lib;
{ {
config = { programs.bat = {
programs.bat = { enable = true;
enable = true;
config = { config = {
theme = "TwoDark"; theme = "TwoDark";
pager = "less -FR"; pager = "less -FR";
map-syntax = [ "*.jenkinsfile:Groovy" "*.props:Java Properties" ]; map-syntax = [ "*.jenkinsfile:Groovy" "*.props:Java Properties" ];
};
themes.testtheme = ''
This is a test theme.
'';
syntaxes.testsyntax = ''
This is a test syntax.
'';
}; };
test.stubs.bat = { }; themes.testtheme = ''
This is a test theme.
'';
test.asserts.warnings.enable = true; syntaxes.testsyntax = ''
test.asserts.warnings.expected = [ This is a test syntax.
''
Using programs.bat.themes as a string option is deprecated and will be
removed in the future. Please change to using it as an attribute set
instead.
''
''
Using programs.bat.syntaxes as a string option is deprecated and will be
removed in the future. Please change to using it as an attribute set
instead.
''
];
nmt.script = ''
assertFileExists home-files/.config/bat/config
assertFileContent home-files/.config/bat/config ${
pkgs.writeText "bat.expected" ''
--map-syntax='*.jenkinsfile:Groovy'
--map-syntax='*.props:Java Properties'
--pager='less -FR'
--theme=TwoDark
''
}
assertFileExists home-files/.config/bat/themes/testtheme.tmTheme
assertFileContent home-files/.config/bat/themes/testtheme.tmTheme ${
pkgs.writeText "bat.expected" ''
This is a test theme.
''
}
assertFileExists home-files/.config/bat/syntaxes/testsyntax.sublime-syntax
assertFileContent home-files/.config/bat/syntaxes/testsyntax.sublime-syntax ${
pkgs.writeText "bat.expected" ''
This is a test syntax.
''
}
''; '';
}; };
test.asserts.warnings.enable = true;
test.asserts.warnings.expected = [
''
Using programs.bat.themes as a string option is deprecated and will be
removed in the future. Please change to using it as an attribute set
instead.
''
''
Using programs.bat.syntaxes as a string option is deprecated and will be
removed in the future. Please change to using it as an attribute set
instead.
''
];
nmt.script = ''
assertFileExists home-files/.config/bat/config
assertFileContent home-files/.config/bat/config ${
builtins.toFile "bat.expected" ''
--map-syntax='*.jenkinsfile:Groovy'
--map-syntax='*.props:Java Properties'
--pager='less -FR'
--theme=TwoDark
''
}
assertFileExists home-files/.config/bat/themes/testtheme.tmTheme
assertFileContent home-files/.config/bat/themes/testtheme.tmTheme ${
builtins.toFile "bat.expected" ''
This is a test theme.
''
}
assertFileExists home-files/.config/bat/syntaxes/testsyntax.sublime-syntax
assertFileContent home-files/.config/bat/syntaxes/testsyntax.sublime-syntax ${
builtins.toFile "bat.expected" ''
This is a test syntax.
''
}
'';
} }

View file

@ -1,5 +1,3 @@
{ config, ... }:
{ {
home.stateVersion = "23.05"; home.stateVersion = "23.05";
@ -14,11 +12,6 @@
mpdIntegration.enableStats = true; mpdIntegration.enableStats = true;
}; };
test.stubs = {
beets = { };
mpd = { };
};
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/beets/config.yaml assertFileExists home-files/.config/beets/config.yaml
assertFileContent \ assertFileContent \

View file

@ -1,11 +1,8 @@
{ config, ... }:
{ {
home.stateVersion = "23.05"; home.stateVersion = "23.05";
programs.beets = { programs.beets = {
enable = true; enable = true;
package = config.lib.test.mkStubPackage { outPath = "@beets@"; };
mpdIntegration.enableUpdate = true; mpdIntegration.enableUpdate = true;
}; };

View file

@ -19,8 +19,6 @@
}; };
}; };
test.stubs.bemenu = { };
nmt.script = '' nmt.script = ''
assertFileExists home-path/etc/profile.d/hm-session-vars.sh assertFileExists home-path/etc/profile.d/hm-session-vars.sh
assertFileContains home-path/etc/profile.d/hm-session-vars.sh \ assertFileContains home-path/etc/profile.d/hm-session-vars.sh \

View file

@ -1,7 +1,5 @@
{ {
programs.bemenu = { enable = true; }; programs.bemenu.enable = true;
test.stubs.bemenu = { };
nmt.script = '' nmt.script = ''
assertFileExists home-path/etc/profile.d/hm-session-vars.sh assertFileExists home-path/etc/profile.d/hm-session-vars.sh

View file

@ -1,4 +1,4 @@
{ config, pkgs, ... }: { config, realPkgs, ... }:
let let
@ -61,8 +61,6 @@ in {
}; };
}; };
test.stubs.borgmatic = { };
nmt.script = '' nmt.script = ''
config_file=$TESTED/home-files/.config/borgmatic.d/main.yaml config_file=$TESTED/home-files/.config/borgmatic.d/main.yaml
assertFileExists $config_file assertFileExists $config_file
@ -120,7 +118,7 @@ in {
builtins.elemAt backups.main.hooks.extraConfig.before_actions 0 builtins.elemAt backups.main.hooks.extraConfig.before_actions 0
}" }"
yq=${pkgs.yq-go}/bin/yq yq=${realPkgs.yq-go}/bin/yq
for filter in "''${!expectations[@]}"; do for filter in "''${!expectations[@]}"; do
expected_value="''${expectations[$filter]}" expected_value="''${expectations[$filter]}"

View file

@ -1,10 +1,4 @@
{ config, pkgs, ... }: {
let
backups = config.programs.borgmatic.backups;
in {
programs.borgmatic = { programs.borgmatic = {
enable = true; enable = true;
backups = { backups = {
@ -18,8 +12,6 @@ in {
}; };
}; };
test.stubs.borgmatic = { };
test.asserts.assertions.expected = ['' test.asserts.assertions.expected = [''
Borgmatic backup configuration "main" cannot specify both 'location.sourceDirectories' and 'location.patterns'. Borgmatic backup configuration "main" cannot specify both 'location.sourceDirectories' and 'location.patterns'.
'']; ''];

View file

@ -1,11 +1,6 @@
{ config, pkgs, ... }: { realPkgs, ... }:
let {
backups = config.programs.borgmatic.backups;
excludeFile = builtins.toFile "excludeFile.txt" "/foo/bar";
in {
programs.borgmatic = { programs.borgmatic = {
enable = true; enable = true;
backups = { backups = {
@ -19,13 +14,11 @@ in {
}; };
}; };
test.stubs.borgmatic = { };
nmt.script = '' nmt.script = ''
config_file=$TESTED/home-files/.config/borgmatic.d/main.yaml config_file=$TESTED/home-files/.config/borgmatic.d/main.yaml
assertFileExists $config_file assertFileExists $config_file
yq=${pkgs.yq-go}/bin/yq yq=${realPkgs.yq-go}/bin/yq
hmExclusionsFile=$($yq '.exclude_from[0]' $config_file) hmExclusionsFile=$($yq '.exclude_from[0]' $config_file)
expected_content='/home/hm-user/.config/borgmatic.d/main.yaml' expected_content='/home/hm-user/.config/borgmatic.d/main.yaml'

View file

@ -1,8 +1,7 @@
{ config, pkgs, ... }: { realPkgs, ... }:
let let
backups = config.programs.borgmatic.backups;
excludeFile = builtins.toFile "excludeFile.txt" "/foo/bar"; excludeFile = builtins.toFile "excludeFile.txt" "/foo/bar";
in { in {
@ -20,8 +19,6 @@ in {
}; };
}; };
test.stubs.borgmatic = { };
nmt.script = '' nmt.script = ''
config_file=$TESTED/home-files/.config/borgmatic.d/main.yaml config_file=$TESTED/home-files/.config/borgmatic.d/main.yaml
assertFileExists $config_file assertFileExists $config_file
@ -30,7 +27,7 @@ in {
expectations[exclude_from[0]]="${excludeFile}" expectations[exclude_from[0]]="${excludeFile}"
yq=${pkgs.yq-go}/bin/yq yq=${realPkgs.yq-go}/bin/yq
for filter in "''${!expectations[@]}"; do for filter in "''${!expectations[@]}"; do
expected_value="''${expectations[$filter]}" expected_value="''${expectations[$filter]}"

View file

@ -1,8 +1,7 @@
{ config, pkgs, ... }: { realPkgs, ... }:
let let
backups = config.programs.borgmatic.backups;
excludeFile = builtins.toFile "excludeFile.txt" "/foo/bar"; excludeFile = builtins.toFile "excludeFile.txt" "/foo/bar";
in { in {
@ -20,8 +19,6 @@ in {
}; };
}; };
test.stubs.borgmatic = { };
nmt.script = '' nmt.script = ''
config_file=$TESTED/home-files/.config/borgmatic.d/main.yaml config_file=$TESTED/home-files/.config/borgmatic.d/main.yaml
assertFileExists $config_file assertFileExists $config_file
@ -30,7 +27,7 @@ in {
expectations[exclude_from[0]]="${excludeFile}" expectations[exclude_from[0]]="${excludeFile}"
yq=${pkgs.yq-go}/bin/yq yq=${realPkgs.yq-go}/bin/yq
for filter in "''${!expectations[@]}"; do for filter in "''${!expectations[@]}"; do
expected_value="''${expectations[$filter]}" expected_value="''${expectations[$filter]}"

View file

@ -1,17 +1,9 @@
{ config, pkgs, ... }: {
let
backups = config.programs.borgmatic.backups;
in {
programs.borgmatic = { programs.borgmatic = {
enable = true; enable = true;
backups = { main = { location = { repositories = [ "/mnt/disk1" ]; }; }; }; backups = { main = { location = { repositories = [ "/mnt/disk1" ]; }; }; };
}; };
test.stubs.borgmatic = { };
test.asserts.assertions.expected = ['' test.asserts.assertions.expected = [''
Borgmatic backup configuration "main" must specify one of 'location.sourceDirectories' or 'location.patterns'. Borgmatic backup configuration "main" must specify one of 'location.sourceDirectories' or 'location.patterns'.
'']; ''];

View file

@ -1,8 +1,7 @@
{ config, pkgs, ... }: { config, realPkgs, ... }:
let let
boolToString = bool: if bool then "true" else "false";
backups = config.programs.borgmatic.backups; backups = config.programs.borgmatic.backups;
in { in {
@ -23,8 +22,6 @@ in {
}; };
}; };
test.stubs.borgmatic = { };
nmt.script = '' nmt.script = ''
config_file=$TESTED/home-files/.config/borgmatic.d/main.yaml config_file=$TESTED/home-files/.config/borgmatic.d/main.yaml
assertFileExists $config_file assertFileExists $config_file
@ -44,7 +41,7 @@ in {
builtins.elemAt backups.main.location.patterns 3 builtins.elemAt backups.main.location.patterns 3
}" }"
yq=${pkgs.yq-go}/bin/yq yq=${realPkgs.yq-go}/bin/yq
for filter in "''${!expectations[@]}"; do for filter in "''${!expectations[@]}"; do
expected_value="''${expectations[$filter]}" expected_value="''${expectations[$filter]}"

View file

@ -6,8 +6,6 @@ with lib;
config = { config = {
programs.boxxy.enable = true; programs.boxxy.enable = true;
test.stubs.boxxy = { };
nmt.script = '' nmt.script = ''
assertPathNotExists home-files/.config/boxxy assertPathNotExists home-files/.config/boxxy
''; '';

View file

@ -15,8 +15,6 @@ with lib;
context = [ "/home/test_user/your_project_repo" ]; context = [ "/home/test_user/your_project_repo" ];
}]; }];
test.stubs.boxxy = { };
nmt.script = '' nmt.script = ''
boxxyyaml=home-files/.config/boxxy/boxxy.yaml boxxyyaml=home-files/.config/boxxy/boxxy.yaml
assertFileExists $boxxyyaml assertFileExists $boxxyyaml

View file

@ -1,4 +1,4 @@
{ ... }: { realPkgs, ... }:
{ {
programs.broot = { programs.broot = {
@ -6,10 +6,7 @@
settings.modal = true; settings.modal = true;
}; };
tests.stubs = { nixpkgs.overlays = [ (self: super: { inherit (realPkgs) broot hjson; }) ];
broot = { };
hjson = { };
};
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/broot/conf.toml assertFileExists home-files/.config/broot/conf.toml

View file

@ -1,35 +1,32 @@
{ config, lib, pkgs, ... }: { realPkgs, ... }:
with lib;
{ {
config = { programs.browserpass = {
programs.browserpass = { enable = true;
enable = true; browsers = [ "brave" "chrome" "chromium" "firefox" "librewolf" "vivaldi" ];
browsers =
[ "brave" "chrome" "chromium" "firefox" "librewolf" "vivaldi" ];
};
nmt.script = if pkgs.stdenv.hostPlatform.isDarwin then ''
for dir in "BraveSoftware/Brave-Browser" "Google/Chrome" "Chromium" "Mozilla" "LibreWolf" "Vivaldi"; do
assertFileExists "home-files/Library/Application Support/$dir/NativeMessagingHosts/com.github.browserpass.native.json"
done
for dir in "Google/Chrome" "Chromium" "Vivaldi"; do
assertFileExists "home-files/Library/Application Support/$dir/policies/managed/com.github.browserpass.native.json"
done
'' else ''
for dir in "BraveSoftware/Brave-Browser" "google-chrome" "chromium" "vivaldi"; do
assertFileExists "home-files/.config/$dir/NativeMessagingHosts/com.github.browserpass.native.json"
done
for dir in "google-chrome" "chromium" "vivaldi"; do
assertFileExists "home-files/.config/$dir/policies/managed/com.github.browserpass.native.json"
done
for dir in ".mozilla" ".librewolf"; do
assertFileExists "home-files/$dir/native-messaging-hosts/com.github.browserpass.native.json"
done
'';
}; };
nixpkgs.overlays = [ (self: super: { inherit (realPkgs) browserpass; }) ];
nmt.script = if realPkgs.stdenv.hostPlatform.isDarwin then ''
for dir in "BraveSoftware/Brave-Browser" "Google/Chrome" "Chromium" "Mozilla" "LibreWolf" "Vivaldi"; do
assertFileExists "home-files/Library/Application Support/$dir/NativeMessagingHosts/com.github.browserpass.native.json"
done
for dir in "Google/Chrome" "Chromium" "Vivaldi"; do
assertFileExists "home-files/Library/Application Support/$dir/policies/managed/com.github.browserpass.native.json"
done
'' else ''
for dir in "BraveSoftware/Brave-Browser" "google-chrome" "chromium" "vivaldi"; do
assertFileExists "home-files/.config/$dir/NativeMessagingHosts/com.github.browserpass.native.json"
done
for dir in "google-chrome" "chromium" "vivaldi"; do
assertFileExists "home-files/.config/$dir/policies/managed/com.github.browserpass.native.json"
done
for dir in ".mozilla" ".librewolf"; do
assertFileExists "home-files/$dir/native-messaging-hosts/com.github.browserpass.native.json"
done
'';
} }

View file

@ -1,10 +1,6 @@
{ ... }:
{ {
programs.btop.enable = true; programs.btop.enable = true;
test.stubs.btop = { };
nmt.script = '' nmt.script = ''
assertPathNotExists home-files/.config/btop assertPathNotExists home-files/.config/btop
''; '';

View file

@ -1,5 +1,3 @@
{ ... }:
{ {
programs = { programs = {
carapace.enable = true; carapace.enable = true;
@ -9,6 +7,6 @@
nmt.script = '' nmt.script = ''
assertFileExists home-files/.bashrc assertFileExists home-files/.bashrc
assertFileRegex home-files/.bashrc \ assertFileRegex home-files/.bashrc \
'source <(/nix/store/.*carapace.*/bin/carapace _carapace bash)' 'source <(@carapace@/bin/carapace _carapace bash)'
''; '';
} }

View file

@ -1,11 +1,13 @@
{ ... }: { config, lib, realPkgs, ... }:
{ lib.mkIf config.test.enableBig {
programs = { programs = {
carapace.enable = true; carapace.enable = true;
fish.enable = true; fish.enable = true;
}; };
nixpkgs.overlays = [ (self: super: { inherit (realPkgs) carapace; }) ];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/fish/config.fish assertFileExists home-files/.config/fish/config.fish
assertFileRegex home-files/.config/fish/config.fish \ assertFileRegex home-files/.config/fish/config.fish \

View file

@ -1,5 +1,3 @@
{ ... }:
{ {
programs = { programs = {
carapace.enable = true; carapace.enable = true;
@ -9,6 +7,6 @@
nmt.script = '' nmt.script = ''
assertFileExists home-files/.zshrc assertFileExists home-files/.zshrc
assertFileRegex home-files/.zshrc \ assertFileRegex home-files/.zshrc \
'source <(/nix/store/.*carapace.*/bin/carapace _carapace zsh)' 'source <(@carapace@/bin/carapace _carapace zsh)'
''; '';
} }

View file

@ -1,5 +1,3 @@
{ ... }:
{ {
programs.cmus = { programs.cmus = {
enable = true; enable = true;
@ -7,8 +5,6 @@
extraConfig = "test"; extraConfig = "test";
}; };
test.stubs.cmus = { };
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \
home-files/.config/cmus/rc \ home-files/.config/cmus/rc \

View file

@ -1,5 +1,3 @@
{ ... }:
{ {
programs.comodoro = { programs.comodoro = {
enable = true; enable = true;
@ -26,8 +24,6 @@
}; };
}; };
test.stubs.comodoro = { };
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/comodoro/config.toml assertFileExists home-files/.config/comodoro/config.toml
assertFileContent home-files/.config/comodoro/config.toml ${./expected.toml} assertFileContent home-files/.config/comodoro/config.toml ${./expected.toml}

View file

@ -1,17 +1,11 @@
{ config, lib, pkgs, ... }:
with lib;
{ {
config = { programs.bash.enable = true;
programs.bash.enable = true; programs.direnv.enable = true;
programs.direnv.enable = true;
nmt.script = '' nmt.script = ''
assertFileExists home-files/.bashrc assertFileExists home-files/.bashrc
assertFileRegex \ assertFileRegex \
home-files/.bashrc \ home-files/.bashrc \
'eval "\$(/nix/store/.*direnv.*/bin/direnv hook bash)"' 'eval "\$(@direnv@/bin/direnv hook bash)"'
''; '';
};
} }

View file

@ -1,16 +1,14 @@
{ config, lib, pkgs, ... }: { realPkgs, ... }:
with lib;
{ {
config = { programs.bash.enable = true;
programs.bash.enable = true; programs.direnv.enable = true;
programs.direnv.enable = true; programs.direnv.nix-direnv.enable = true;
programs.direnv.nix-direnv.enable = true;
nmt.script = '' nixpkgs.overlays = [ (_: _: { inherit (realPkgs) nix-direnv; }) ];
assertFileExists home-files/.bashrc
assertFileExists home-files/.config/direnv/lib/hm-nix-direnv.sh nmt.script = ''
''; assertFileExists home-files/.bashrc
}; assertFileExists home-files/.config/direnv/lib/hm-nix-direnv.sh
'';
} }

View file

@ -4,8 +4,6 @@
programs.nushell.enable = true; programs.nushell.enable = true;
programs.direnv.enable = true; programs.direnv.enable = true;
test.stubs.nushell = { };
nmt.script = let nmt.script = let
configFile = if pkgs.stdenv.isDarwin && !config.xdg.enable then configFile = if pkgs.stdenv.isDarwin && !config.xdg.enable then
"home-files/Library/Application Support/nushell/config.nu" "home-files/Library/Application Support/nushell/config.nu"
@ -13,6 +11,6 @@
"home-files/.config/nushell/config.nu"; "home-files/.config/nushell/config.nu";
in '' in ''
assertFileExists "${configFile}" assertFileExists "${configFile}"
assertFileRegex "${configFile}" '/nix/store/.*direnv.*/bin/direnv export json' assertFileRegex "${configFile}" '@direnv@/bin/direnv export json'
''; '';
} }

View file

@ -1,21 +1,19 @@
{ config, lib, pkgs, ... }: { realPkgs, ... }:
with lib;
let expectedContent = "something important"; let expectedContent = "something important";
in { in {
config = { programs.bash.enable = true;
programs.bash.enable = true; programs.direnv.enable = true;
programs.direnv.enable = true; programs.direnv.nix-direnv.enable = true;
programs.direnv.nix-direnv.enable = true; programs.direnv.stdlib = expectedContent;
programs.direnv.stdlib = expectedContent;
nmt.script = '' nixpkgs.overlays = [ (_: _: { inherit (realPkgs) nix-direnv; }) ];
assertFileExists home-files/.bashrc
assertFileExists home-files/.config/direnv/lib/hm-nix-direnv.sh nmt.script = ''
assertFileRegex \ assertFileExists home-files/.bashrc
home-files/.config/direnv/direnvrc \ assertFileExists home-files/.config/direnv/lib/hm-nix-direnv.sh
'${expectedContent}' assertFileRegex \
''; home-files/.config/direnv/direnvrc \
}; '${expectedContent}'
'';
} }

View file

@ -1,20 +1,14 @@
{ config, lib, pkgs, ... }:
with lib;
let expectedContent = "something important"; let expectedContent = "something important";
in { in {
config = { programs.bash.enable = true;
programs.bash.enable = true; programs.direnv.enable = true;
programs.direnv.enable = true; programs.direnv.stdlib = expectedContent;
programs.direnv.stdlib = expectedContent;
nmt.script = '' nmt.script = ''
assertPathNotExists home-files/.config/direnv/lib/hm-nix-direnv.sh assertPathNotExists home-files/.config/direnv/lib/hm-nix-direnv.sh
assertFileExists home-files/.bashrc assertFileExists home-files/.bashrc
assertFileRegex \ assertFileRegex \
home-files/.config/direnv/direnvrc \ home-files/.config/direnv/direnvrc \
'${expectedContent}' '${expectedContent}'
''; '';
};
} }

View file

@ -29,8 +29,6 @@
}; };
}; };
test.stubs.fastfetch = { };
nmt.script = let configFile = "home-files/.config/fastfetch/config.jsonc"; nmt.script = let configFile = "home-files/.config/fastfetch/config.jsonc";
in '' in ''
assertFileExists "${configFile}" assertFileExists "${configFile}"

View file

@ -1,8 +1,6 @@
{ {
programs.fastfetch.enable = true; programs.fastfetch.enable = true;
test.stubs.fastfetch = { };
nmt.script = '' nmt.script = ''
assertPathNotExists "home-files/.config/fastfetch/config.jsonc" assertPathNotExists "home-files/.config/fastfetch/config.jsonc"
''; '';

View file

@ -1,32 +1,26 @@
{ pkgs, ... }:
{ {
config = { programs.feh.enable = true;
programs.feh.enable = true;
programs.feh.buttons = { programs.feh.buttons = {
zoom_in = null; zoom_in = null;
zoom_out = 4; zoom_out = 4;
next_img = "C-4"; next_img = "C-4";
prev_img = [ 3 "C-3" ]; prev_img = [ 3 "C-3" ];
};
programs.feh.keybindings = {
zoom_in = null;
zoom_out = "minus";
prev_img = [ "h" "Left" ];
};
test.stubs.feh = { };
nmt.script = ''
assertFileContent \
home-files/.config/feh/buttons \
${./feh-bindings-expected-buttons}
assertFileContent \
home-files/.config/feh/keys \
${./feh-bindings-expected-keys}
'';
}; };
programs.feh.keybindings = {
zoom_in = null;
zoom_out = "minus";
prev_img = [ "h" "Left" ];
};
nmt.script = ''
assertFileContent \
home-files/.config/feh/buttons \
${./feh-bindings-expected-buttons}
assertFileContent \
home-files/.config/feh/keys \
${./feh-bindings-expected-keys}
'';
} }

View file

@ -1,15 +1,9 @@
{ pkgs, ... }:
{ {
config = { programs.feh.enable = true;
programs.feh.enable = true;
test.stubs.feh = { }; nmt.script = ''
assertPathNotExists home-files/.config/feh/buttons
nmt.script = '' assertPathNotExists home-files/.config/feh/keys
assertPathNotExists home-files/.config/feh/buttons assertPathNotExists home-files/.config/feh/themes
assertPathNotExists home-files/.config/feh/keys '';
assertPathNotExists home-files/.config/feh/themes
'';
};
} }

View file

@ -1,32 +1,26 @@
{ pkgs, ... }:
{ {
config = { programs.feh.enable = true;
programs.feh.enable = true;
programs.feh.themes = { programs.feh.themes = {
feh = [ "--image-bg" "black" ]; feh = [ "--image-bg" "black" ];
webcam = [ "--multiwindow" "--reload" "20" ]; webcam = [ "--multiwindow" "--reload" "20" ];
present = [ "--full-screen" "--sort" "name" "--hide-pointer" ]; present = [ "--full-screen" "--sort" "name" "--hide-pointer" ];
booth = [ "--full-screen" "--hide-pointer" "--slideshow-delay" "20" ]; booth = [ "--full-screen" "--hide-pointer" "--slideshow-delay" "20" ];
imagemap = [ imagemap = [
"-rVq" "-rVq"
"--thumb-width" "--thumb-width"
"40" "40"
"--thumb-height" "--thumb-height"
"30" "30"
"--index-info" "--index-info"
"%n\\n%wx%h" "%n\\n%wx%h"
]; ];
example = [ "--info" "foo bar" ]; example = [ "--info" "foo bar" ];
};
test.stubs.feh = { };
nmt.script = ''
assertFileContent \
home-files/.config/feh/themes \
${./feh-themes-expected}
'';
}; };
nmt.script = ''
assertFileContent \
home-files/.config/feh/themes \
${./feh-themes-expected}
'';
} }

View file

@ -1,25 +1,21 @@
modulePath: modulePath:
{ config, lib, pkgs, ... }: { config, lib, realPkgs, ... }:
let let
cfg = lib.getAttrFromPath modulePath config; cfg = lib.getAttrFromPath modulePath config;
firefoxMockOverlay = import ./setup-firefox-mock-overlay.nix modulePath; in lib.mkIf config.test.enableBig
(lib.setAttrByPath modulePath { enable = true; } // {
home.stateVersion = "19.09";
in { _module.args.pkgs = lib.mkForce realPkgs;
imports = [ firefoxMockOverlay ];
config = lib.mkIf config.test.enableBig nmt.script = ''
(lib.setAttrByPath modulePath { enable = true; } // { package=${cfg.package}
home.stateVersion = "19.09"; finalPackage=${cfg.finalPackage}
if [[ $package != $finalPackage ]]; then
nmt.script = '' fail "Expected finalPackage ($finalPackage) to equal package ($package)"
package=${cfg.package} fi
finalPackage=${cfg.finalPackage} '';
if [[ $package != $finalPackage ]]; then })
fail "Expected finalPackage ($finalPackage) to equal package ($package)"
fi
'';
});
}

View file

@ -1,30 +1,36 @@
modulePath: modulePath:
{ config, lib, pkgs, ... }: { config, lib, realPkgs, ... }:
with lib;
let let
cfg = getAttrFromPath modulePath config; cfg = lib.getAttrFromPath modulePath config;
in { in {
nixpkgs.overlays = [ test.stubs = let unwrappedName = "${cfg.wrappedPackageName}-unwrapped";
(self: super: { in {
"${cfg.wrappedPackageName}-unwrapped" = "${unwrappedName}" = {
pkgs.runCommandLocal "${cfg.wrappedPackageName}-0" { name = unwrappedName;
meta.description = "I pretend to be ${cfg.name}"; extraAttrs = {
passthru.gtk3 = null; binaryName = cfg.wrappedPackageName;
} '' gtk3 = null;
mkdir -p "$out"/{bin,lib} meta.description = "I pretend to be ${cfg.name}";
touch "$out/bin/${cfg.wrappedPackageName}" };
chmod 755 "$out/bin/${cfg.wrappedPackageName}" outPath = null;
''; buildScript = ''
echo BUILD
mkdir -p "$out"/{bin,lib}
touch "$out/bin/${cfg.wrappedPackageName}"
chmod 755 "$out/bin/${cfg.wrappedPackageName}"
'';
};
chrome-gnome-shell = chrome-gnome-shell = {
pkgs.runCommandLocal "dummy-chrome-gnome-shell" { } '' buildScript = ''
mkdir -p $out/lib/mozilla/native-messaging-hosts mkdir -p $out/lib/mozilla/native-messaging-hosts
touch $out/lib/mozilla/native-messaging-hosts/dummy touch $out/lib/mozilla/native-messaging-hosts/dummy
''; '';
}) };
]; };
nixpkgs.overlays = [ (_: _: { inherit (realPkgs) mozlz4a; }) ];
} }

View file

@ -1,15 +1,7 @@
{ config, lib, pkgs, ... }:
with lib;
{ {
config = { programs.foot.enable = true;
programs.foot.enable = true;
test.stubs.foot = { }; nmt.script = ''
assertPathNotExists home-files/.config/foot
nmt.script = '' '';
assertPathNotExists home-files/.config/foot
'';
};
} }

View file

@ -1,29 +1,25 @@
{ config, lib, pkgs, ... }: { config, ... }:
with lib;
{ {
config = { programs.foot = {
programs.foot = { enable = true;
enable = true; package = config.lib.test.mkStubPackage { };
package = config.lib.test.mkStubPackage { };
settings = { settings = {
main = { main = {
term = "xterm-256color"; term = "xterm-256color";
font = "Fira Code:size=11"; font = "Fira Code:size=11";
dpi-aware = "yes"; dpi-aware = "yes";
};
mouse = { hide-when-typing = "yes"; };
}; };
};
nmt.script = '' mouse = { hide-when-typing = "yes"; };
assertFileContent \ };
home-files/.config/foot/foot.ini \
${./example-settings-expected.ini}
'';
}; };
nmt.script = ''
assertFileContent \
home-files/.config/foot/foot.ini \
${./example-settings-expected.ini}
'';
} }

View file

@ -1,19 +1,14 @@
{ config, lib, pkgs, ... }:
{ {
config = { programs.foot = {
programs.foot = { enable = true;
package = config.lib.test.mkStubPackage { outPath = "@foot@"; }; server.enable = true;
enable = true;
server.enable = true;
};
nmt.script = ''
assertPathNotExists home-files/.config/foot/foot.ini
assertFileContent \
home-files/.config/systemd/user/foot.service \
${./systemd-user-service-expected.service}
'';
}; };
nmt.script = ''
assertPathNotExists home-files/.config/foot/foot.ini
assertFileContent \
home-files/.config/systemd/user/foot.service \
${./systemd-user-service-expected.service}
'';
} }

View file

@ -1,5 +1,3 @@
{ config, pkgs, ... }:
{ {
programs.freetube = { programs.freetube = {
enable = true; enable = true;
@ -17,8 +15,6 @@
}; };
}; };
test.stubs.freetube = { };
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/FreeTube/hm_settings.db assertFileExists home-files/.config/FreeTube/hm_settings.db
assertFileContent home-files/.config/FreeTube/hm_settings.db \ assertFileContent home-files/.config/FreeTube/hm_settings.db \

View file

@ -1,10 +1,6 @@
{ ... }:
{ {
programs.fuzzel.enable = true; programs.fuzzel.enable = true;
test.stubs.fuzzel = { };
nmt.script = '' nmt.script = ''
assertPathNotExists home-files/.config/fuzzel assertPathNotExists home-files/.config/fuzzel
''; '';

View file

@ -12,8 +12,6 @@
}; };
}; };
test.stubs.gallery-dl = { };
nmt.script = '' nmt.script = ''
assertFileContent home-files/.config/gallery-dl/config.json \ assertFileContent home-files/.config/gallery-dl/config.json \
${builtins.toFile "gallery-dl-expected-settings.json" '' ${builtins.toFile "gallery-dl-expected-settings.json" ''

View file

@ -1,5 +1,3 @@
{ ... }:
{ {
programs.gh-dash = { programs.gh-dash = {
enable = true; enable = true;
@ -11,8 +9,6 @@
}; };
}; };
test.stubs.gh = { };
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/gh-dash/config.yml assertFileExists home-files/.config/gh-dash/config.yml
assertFileContent home-files/.config/gh-dash/config.yml ${ assertFileContent home-files/.config/gh-dash/config.yml ${

View file

@ -1,26 +1,20 @@
{ config, lib, pkgs, ... }:
{ {
config = { programs.gh = {
programs.gh = { enable = true;
enable = true; settings.aliases = { co = "pr checkout"; };
settings.aliases = { co = "pr checkout"; }; settings.editor = "vim";
settings.editor = "vim";
};
test.stubs.gh = { };
nmt.script = ''
assertFileExists home-files/.config/gh/config.yml
assertFileContent home-files/.config/gh/config.yml ${
builtins.toFile "config-file.yml" ''
aliases:
co: pr checkout
editor: vim
git_protocol: https
version: '1'
''
}
'';
}; };
nmt.script = ''
assertFileExists home-files/.config/gh/config.yml
assertFileContent home-files/.config/gh/config.yml ${
builtins.toFile "config-file.yml" ''
aliases:
co: pr checkout
editor: vim
git_protocol: https
version: '1'
''
}
'';
} }

View file

@ -1,5 +1,3 @@
{ config, lib, pkgs, ... }:
{ {
programs.gh = { programs.gh = {
enable = true; enable = true;
@ -11,8 +9,6 @@
programs.git.enable = true; programs.git.enable = true;
test.stubs.gh = { };
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/git/config assertFileExists home-files/.config/git/config
assertFileContent home-files/.config/git/config \ assertFileContent home-files/.config/git/config \

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }: { pkgs, ... }:
{ {
programs.gh = { programs.gh = {
@ -7,7 +7,6 @@
}; };
test.stubs = { test.stubs = {
gh = { };
gh-eco = { gh-eco = {
name = "gh-eco"; name = "gh-eco";
buildScript = '' buildScript = ''

View file

@ -1,36 +1,32 @@
{ config, options, lib, pkgs, ... }: { options, lib, ... }:
{ {
config = { programs.gh = {
programs.gh = { enable = true;
enable = true; aliases = { co = "pr checkout"; };
aliases = { co = "pr checkout"; }; editor = "vim";
editor = "vim";
};
test.stubs.gh = { };
test.asserts.warnings.expected = [
"The option `programs.gh.editor' defined in ${
lib.showFiles options.programs.gh.editor.files
} has been renamed to `programs.gh.settings.editor'."
"The option `programs.gh.aliases' defined in ${
lib.showFiles options.programs.gh.aliases.files
} has been renamed to `programs.gh.settings.aliases'."
];
test.asserts.warnings.enable = true;
nmt.script = ''
assertFileExists home-files/.config/gh/config.yml
assertFileContent home-files/.config/gh/config.yml ${
builtins.toFile "config-file.yml" ''
aliases:
co: pr checkout
editor: vim
git_protocol: https
version: '1'
''
}
'';
}; };
test.asserts.warnings.expected = [
"The option `programs.gh.editor' defined in ${
lib.showFiles options.programs.gh.editor.files
} has been renamed to `programs.gh.settings.editor'."
"The option `programs.gh.aliases' defined in ${
lib.showFiles options.programs.gh.aliases.files
} has been renamed to `programs.gh.settings.aliases'."
];
test.asserts.warnings.enable = true;
nmt.script = ''
assertFileExists home-files/.config/gh/config.yml
assertFileContent home-files/.config/gh/config.yml ${
builtins.toFile "config-file.yml" ''
aliases:
co: pr checkout
editor: vim
git_protocol: https
version: '1'
''
}
'';
} }

View file

@ -1,6 +1,6 @@
{ {
programs.ghostty.enable = true; programs.ghostty.enable = true;
test.stubs.ghostty = { };
nmt.script = '' nmt.script = ''
assertPathNotExists home-files/.config/ghostty/config assertPathNotExists home-files/.config/ghostty/config
''; '';

View file

@ -1,7 +1,6 @@
{ config, ... }: { {
programs.ghostty = { programs.ghostty = {
enable = true; enable = true;
package = config.lib.test.mkStubPackage { };
themes = { themes = {
catppuccin-mocha = { catppuccin-mocha = {

View file

@ -1,7 +1,3 @@
{ config, lib, pkgs, ... }:
with lib;
{ {
programs.git-cliff = { programs.git-cliff = {
enable = true; enable = true;
@ -13,8 +9,6 @@ with lib;
}; };
}; };
test.stubs.git-cliff = { };
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \
home-files/.config/git-cliff/cliff.toml \ home-files/.config/git-cliff/cliff.toml \

View file

@ -1,12 +1,10 @@
{ config, pkgs, ... }: { config, ... }:
{ {
programs.git-credential-oauth = { enable = true; }; programs.git-credential-oauth = { enable = true; };
programs.git = { enable = true; }; programs.git = { enable = true; };
test.stubs.git-credential-oauth = { };
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/git/config assertFileExists home-files/.config/git/config
assertFileContains \ assertFileContains \

View file

@ -1,4 +1,4 @@
{ config, pkgs, ... }: { config, ... }:
{ {
programs.git-credential-oauth = { programs.git-credential-oauth = {
@ -8,8 +8,6 @@
programs.git = { enable = true; }; programs.git = { enable = true; };
test.stubs.git-credential-oauth = { };
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/git/config assertFileExists home-files/.config/git/config
assertFileContains \ assertFileContains \

View file

@ -1,40 +1,36 @@
{ config, lib, pkgs, ... }: { realPkgs, ... }:
with lib;
{ {
imports = [ ../../accounts/email-test-accounts.nix ]; imports = [ ../../accounts/email-test-accounts.nix ];
config = { accounts.email.accounts.hm-account.smtp.tls.certificatesFile =
accounts.email.accounts.hm-account.smtp.tls.certificatesFile = "/etc/test/certificates.crt";
"/etc/test/certificates.crt";
programs.git = {
enable = true;
package = pkgs.gitMinimal;
userEmail = "hm@example.com";
userName = "H. M. Test";
};
home.stateVersion = "20.09"; programs.git = {
enable = true;
nmt.script = '' userEmail = "hm@example.com";
function assertGitConfig() { userName = "H. M. Test";
local value
value=$(${pkgs.gitMinimal}/bin/git config \
--file $TESTED/home-files/.config/git/config \
--get $1)
if [[ $value != $2 ]]; then
fail "Expected option '$1' to have value '$2' but it was '$value'"
fi
}
assertFileExists home-files/.config/git/config
assertFileContent home-files/.config/git/config ${
./git-with-email-expected.conf
}
assertGitConfig "sendemail.hm@example.com.from" "H. M. Test <hm@example.com>"
assertGitConfig "sendemail.hm-account.from" "H. M. Test Jr. <hm@example.org>"
'';
}; };
home.stateVersion = "20.09";
nmt.script = ''
function assertGitConfig() {
local value
value=$(${realPkgs.gitMinimal}/bin/git config \
--file $TESTED/home-files/.config/git/config \
--get $1)
if [[ $value != $2 ]]; then
fail "Expected option '$1' to have value '$2' but it was '$value'"
fi
}
assertFileExists home-files/.config/git/config
assertFileContent home-files/.config/git/config ${
./git-with-email-expected.conf
}
assertGitConfig "sendemail.hm@example.com.from" "H. M. Test <hm@example.com>"
assertGitConfig "sendemail.hm-account.from" "H. M. Test Jr. <hm@example.org>"
'';
} }

View file

@ -1,4 +1,4 @@
{ pkgs, ... }: { realPkgs, ... }:
{ {
programs.git = { programs.git = {
@ -8,7 +8,7 @@
nmt.script = '' nmt.script = ''
function getGitConfig() { function getGitConfig() {
${pkgs.gitMinimal}/bin/git config \ ${realPkgs.gitMinimal}/bin/git config \
--file $TESTED/home-files/.config/git/config \ --file $TESTED/home-files/.config/git/config \
--get $1 --get $1
} }

View file

@ -1,43 +1,36 @@
{ config, lib, pkgs, ... }: { pkgs, realPkgs, ... }:
with lib;
{ {
imports = [ ../../accounts/email-test-accounts.nix ]; imports = [ ../../accounts/email-test-accounts.nix ];
config = { accounts.email.accounts."hm@example.com".msmtp.enable = true;
accounts.email.accounts."hm@example.com".msmtp.enable = true;
programs.git = { programs.git = {
enable = true; enable = true;
package = pkgs.gitMinimal; userEmail = "hm@example.com";
userEmail = "hm@example.com"; userName = "H. M. Test";
userName = "H. M. Test";
};
home.stateVersion = "20.09";
test.stubs.msmtp = { };
nmt.script = ''
function assertGitConfig() {
local value
value=$(${pkgs.gitMinimal}/bin/git config \
--file $TESTED/home-files/.config/git/config \
--get $1)
if [[ $value != $2 ]]; then
fail "Expected option '$1' to have value '$2' but it was '$value'"
fi
}
assertFileExists home-files/.config/git/config
assertFileContent home-files/.config/git/config \
${./git-with-msmtp-expected.conf}
assertGitConfig "sendemail.hm@example.com.from" "H. M. Test <hm@example.com>"
assertGitConfig "sendemail.hm-account.from" "H. M. Test Jr. <hm@example.org>"
assertGitConfig "sendemail.hm@example.com.smtpServer" "${pkgs.msmtp}/bin/msmtp"
assertGitConfig "sendemail.hm@example.com.envelopeSender" "auto"
'';
}; };
home.stateVersion = "20.09";
nmt.script = ''
function assertGitConfig() {
local value
value=$(${realPkgs.gitMinimal}/bin/git config \
--file $TESTED/home-files/.config/git/config \
--get $1)
if [[ $value != $2 ]]; then
fail "Expected option '$1' to have value '$2' but it was '$value'"
fi
}
assertFileExists home-files/.config/git/config
assertFileContent home-files/.config/git/config \
${./git-with-msmtp-expected.conf}
assertGitConfig "sendemail.hm@example.com.from" "H. M. Test <hm@example.com>"
assertGitConfig "sendemail.hm-account.from" "H. M. Test Jr. <hm@example.org>"
assertGitConfig "sendemail.hm@example.com.smtpServer" "${pkgs.msmtp}/bin/msmtp"
assertGitConfig "sendemail.hm@example.com.envelopeSender" "auto"
'';
} }

Some files were not shown because too many files have changed in this diff Show more