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,13 +9,86 @@ 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`.
@ -33,7 +106,8 @@ let
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,9 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{ {
config = {
home.packages = [ home.packages = [
# Look, no font! # Look, no font!
]; ];
@ -13,5 +8,4 @@ with lib;
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 {
{
config = {
home.packages = [ pkgs.comic-relief ]; home.packages = [ pkgs.comic-relief ];
fonts.fontconfig.enable = true; 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,17 +1,10 @@
{ 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 = '' nmt.script = ''
assertFileExists home-files/.gtkrc-2.0 assertFileExists home-files/.gtkrc-2.0
@ -21,5 +14,4 @@ with lib;
assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \ assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \
'GTK2_RC_FILES=.*/.gtkrc-2.0' '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 = '' nmt.script = ''
assertFileExists home-files/.config/gtk-2.0/gtkrc assertFileExists home-files/.config/gtk-2.0/gtkrc
assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \ assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \
'GTK2_RC_FILES=.*/\.config/gtk-2.0/gtkrc' 'GTK2_RC_FILES=.*/\.config/gtk-2.0/gtkrc'
''; '';
};
} }

View file

@ -1,9 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{ {
config = {
gtk = { gtk = {
enable = true; enable = true;
gtk3.extraConfig = { gtk3.extraConfig = {
@ -12,13 +7,10 @@ with lib;
}; };
}; };
test.stubs.dconf = { };
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/gtk-3.0/settings.ini assertFileExists home-files/.config/gtk-3.0/settings.ini
assertFileContent home-files/.config/gtk-3.0/settings.ini \ assertFileContent home-files/.config/gtk-3.0/settings.ini \
${./gtk3-basic-settings-expected.ini} ${./gtk3-basic-settings-expected.ini}
''; '';
};
} }

View file

@ -1,13 +1,14 @@
{ ... }: { lib, realPkgs, ... }:
{ {
config = {
manual = { manual = {
html.enable = true; html.enable = true;
manpages.enable = true; manpages.enable = true;
json.enable = true; json.enable = true;
}; };
_module.args.pkgs = lib.mkForce realPkgs;
nmt.script = '' nmt.script = ''
assertFileExists home-path/share/doc/home-manager/index.xhtml 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.json
@ -18,5 +19,4 @@
assertFileExists home-path/share/man/man1/home-manager.1 assertFileExists home-path/share/man/man1/home-manager.1
assertFileExists home-path/share/man/man5/home-configuration.nix.5 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 = '' nmt.script = ''
serviceFile=home-files/.config/systemd/user/numlockx.service serviceFile=home-files/.config/systemd/user/numlockx.service
assertFileExists $serviceFile 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 = { xdg.autostart = {
enable = true; enable = true;
entries = [ entries = [
"${pkgs.evolution}/share/applications/org.gnome.Evolution.desktop" "${pkgs.test1}/share/applications/test1.desktop"
"${pkgs.tdesktop}/share/applications/org.telegram.desktop.desktop" "${pkgs.test2}/share/applications/test2.desktop"
]; ];
}; };
nmt.script = '' test.stubs = {
assertFileExists home-files/.config/autostart/org.gnome.Evolution.desktop test1 = {
assertFileContent home-files/.config/autostart/org.gnome.Evolution.desktop \ outPath = null;
${pkgs.evolution}/share/applications/org.gnome.Evolution.desktop buildScript = ''
assertFileExists home-files/.config/autostart/org.telegram.desktop.desktop mkdir -p $out/share/applications
assertFileContent home-files/.config/autostart/org.telegram.desktop.desktop \ echo test1 > $out/share/applications/test1.desktop
${pkgs.tdesktop}/share/applications/org.telegram.desktop.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 = '' nmt.script = ''
assertPathNotExists home-files/.config/alacritty assertPathNotExists home-files/.config/alacritty
''; '';
};
} }

View file

@ -1,11 +1,6 @@
{ config, ... }:
{ {
config = {
programs.alacritty = { programs.alacritty = {
enable = true; enable = true;
package = config.lib.test.mkStubPackage { };
settings = { settings = {
window.dimensions = { window.dimensions = {
lines = 3; lines = 3;
@ -20,12 +15,9 @@
}; };
}; };
test.stubs = { alacritty = { }; };
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \
home-files/.config/alacritty/alacritty.toml \ home-files/.config/alacritty/alacritty.toml \
${./example-settings-expected.toml} ${./example-settings-expected.toml}
''; '';
};
} }

View file

@ -1,11 +1,8 @@
{ config, lib, ... }: { lib, ... }:
{ {
config = {
programs.alacritty = { programs.alacritty = {
enable = true; enable = true;
package = config.lib.test.mkStubPackage { };
settings = { settings = {
window.dimensions = { window.dimensions = {
lines = 3; lines = 3;
@ -28,12 +25,9 @@
}; };
}; };
test.stubs = { alacritty = { }; };
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \
home-files/.config/alacritty/alacritty.toml \ home-files/.config/alacritty/alacritty.toml \
${./settings-toml-expected.toml} ${./settings-toml-expected.toml}
''; '';
};
} }

View file

@ -1,11 +1,6 @@
{ config, ... }:
{ {
config = {
programs.alacritty = { programs.alacritty = {
enable = true; enable = true;
package = config.lib.test.mkStubPackage { };
settings = { settings = {
window.dimensions = { window.dimensions = {
lines = 3; lines = 3;
@ -25,12 +20,9 @@
}; };
}; };
test.stubs = { alacritty = { }; };
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \
home-files/.config/alacritty/alacritty.toml \ home-files/.config/alacritty/alacritty.toml \
${./settings-toml-expected.toml} ${./settings-toml-expected.toml}
''; '';
};
} }

View file

@ -1,11 +1,6 @@
{ 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;
@ -23,12 +18,9 @@ with lib;
programs.alot = { enable = true; }; programs.alot = { enable = true; };
test.stubs.alot = { };
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/alot/config assertFileExists home-files/.config/alot/config
assertFileContent home-files/.config/alot/config ${./alot-expected.conf} 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,9 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{ {
config = {
programs.aria2 = { programs.aria2 = {
enable = true; enable = true;
@ -20,13 +15,11 @@ with lib;
''; '';
}; };
test.stubs.aria2 = { };
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \
home-files/.config/aria2/aria2.conf \ home-files/.config/aria2/aria2.conf \
${ ${
pkgs.writeText "aria2-expected-config.conf" '' builtins.toFile "aria2-expected-config.conf" ''
dht-listen-port=60000 dht-listen-port=60000
ftp-pasv=true ftp-pasv=true
listen-port=60000 listen-port=60000
@ -36,5 +29,4 @@ with lib;
'' ''
} }
''; '';
};
} }

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,9 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{ {
config = {
programs.autojump.enable = true; programs.autojump.enable = true;
test.stubs.autojump = { test.stubs.autojump = {
@ -14,5 +9,4 @@ with lib;
nmt.script = '' nmt.script = ''
assertFileExists home-path/bin/autojump assertFileExists home-path/bin/autojump
''; '';
};
} }

View file

@ -1,7 +1,4 @@
{ config, pkgs, ... }:
{ {
config = {
programs.autorandr = { programs.autorandr = {
enable = true; enable = true;
profiles = { profiles = {
@ -33,8 +30,6 @@
}; };
}; };
test.stubs.autorandr = { };
nmt.script = '' nmt.script = ''
config=home-files/.config/autorandr/default/config config=home-files/.config/autorandr/default/config
setup=home-files/.config/autorandr/default/setup setup=home-files/.config/autorandr/default/setup
@ -46,7 +41,7 @@
assertFileExists $config assertFileExists $config
assertFileContent $config \ assertFileContent $config \
${ ${
pkgs.writeText "basic-configuration.conf" '' builtins.toFile "basic-configuration.conf" ''
output DP1 output DP1
off off
@ -62,5 +57,4 @@
'' ''
} }
''; '';
};
} }

View file

@ -1,7 +1,4 @@
{ config, pkgs, ... }:
{ {
config = {
programs.autorandr = { programs.autorandr = {
enable = true; enable = true;
profiles = { profiles = {
@ -17,18 +14,15 @@
}; };
}; };
test.stubs.autorandr = { };
nmt.script = '' nmt.script = ''
config=home-files/.config/autorandr/default/config config=home-files/.config/autorandr/default/config
assertFileExists $config assertFileExists $config
assertFileContent $config \ assertFileContent $config \
${ ${
pkgs.writeText "scale-expected.conf" '' builtins.toFile "scale-expected.conf" ''
output DP1 output DP1
scale 2x4'' 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,9 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{ {
config = {
programs.bash = { programs.bash = {
enable = true; enable = true;
enableCompletion = false; enableCompletion = false;
@ -23,5 +18,4 @@ with lib;
'' ''
} }
''; '';
};
} }

View file

@ -1,9 +1,6 @@
{ config, lib, pkgs, ... }: { config, ... }:
with lib;
{ {
config = {
programs.bash = { programs.bash = {
enable = true; enable = true;
enableCompletion = false; enableCompletion = false;
@ -29,5 +26,4 @@ with lib;
'' ''
} }
''; '';
};
} }

View file

@ -1,9 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{ {
config = {
programs.bat = { programs.bat = {
enable = true; enable = true;
@ -17,21 +12,19 @@ with lib;
lessopen = false; lessopen = false;
}; };
themes.testtheme.src = pkgs.writeText "testtheme.tmTheme" '' themes.testtheme.src = builtins.toFile "testtheme.tmTheme" ''
This is a test theme. This is a test theme.
''; '';
syntaxes.testsyntax.src = pkgs.writeText "testsyntax.sublime-syntax" '' syntaxes.testsyntax.src = builtins.toFile "testsyntax.sublime-syntax" ''
This is a test syntax. This is a test syntax.
''; '';
}; };
test.stubs.bat = { };
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/bat/config assertFileExists home-files/.config/bat/config
assertFileContent home-files/.config/bat/config ${ assertFileContent home-files/.config/bat/config ${
pkgs.writeText "bat.expected" '' builtins.toFile "bat.expected" ''
--map-syntax='*.jenkinsfile:Groovy' --map-syntax='*.jenkinsfile:Groovy'
--map-syntax='*.props:Java Properties' --map-syntax='*.props:Java Properties'
--pager='less -FR' --pager='less -FR'
@ -42,17 +35,16 @@ with lib;
assertFileExists home-files/.config/bat/themes/testtheme.tmTheme assertFileExists home-files/.config/bat/themes/testtheme.tmTheme
assertFileContent home-files/.config/bat/themes/testtheme.tmTheme ${ assertFileContent home-files/.config/bat/themes/testtheme.tmTheme ${
pkgs.writeText "bat.expected" '' builtins.toFile "bat.expected" ''
This is a test theme. This is a test theme.
'' ''
} }
assertFileExists home-files/.config/bat/syntaxes/testsyntax.sublime-syntax assertFileExists home-files/.config/bat/syntaxes/testsyntax.sublime-syntax
assertFileContent home-files/.config/bat/syntaxes/testsyntax.sublime-syntax ${ assertFileContent home-files/.config/bat/syntaxes/testsyntax.sublime-syntax ${
pkgs.writeText "bat.expected" '' builtins.toFile "bat.expected" ''
This is a test syntax. This is a test syntax.
'' ''
} }
''; '';
};
} }

View file

@ -1,9 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{ {
config = {
programs.bat = { programs.bat = {
enable = true; enable = true;
@ -22,8 +17,6 @@ with lib;
''; '';
}; };
test.stubs.bat = { };
test.asserts.warnings.enable = true; test.asserts.warnings.enable = true;
test.asserts.warnings.expected = [ test.asserts.warnings.expected = [
'' ''
@ -41,7 +34,7 @@ with lib;
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/bat/config assertFileExists home-files/.config/bat/config
assertFileContent home-files/.config/bat/config ${ assertFileContent home-files/.config/bat/config ${
pkgs.writeText "bat.expected" '' builtins.toFile "bat.expected" ''
--map-syntax='*.jenkinsfile:Groovy' --map-syntax='*.jenkinsfile:Groovy'
--map-syntax='*.props:Java Properties' --map-syntax='*.props:Java Properties'
--pager='less -FR' --pager='less -FR'
@ -51,17 +44,16 @@ with lib;
assertFileExists home-files/.config/bat/themes/testtheme.tmTheme assertFileExists home-files/.config/bat/themes/testtheme.tmTheme
assertFileContent home-files/.config/bat/themes/testtheme.tmTheme ${ assertFileContent home-files/.config/bat/themes/testtheme.tmTheme ${
pkgs.writeText "bat.expected" '' builtins.toFile "bat.expected" ''
This is a test theme. This is a test theme.
'' ''
} }
assertFileExists home-files/.config/bat/syntaxes/testsyntax.sublime-syntax assertFileExists home-files/.config/bat/syntaxes/testsyntax.sublime-syntax
assertFileContent home-files/.config/bat/syntaxes/testsyntax.sublime-syntax ${ assertFileContent home-files/.config/bat/syntaxes/testsyntax.sublime-syntax ${
pkgs.writeText "bat.expected" '' builtins.toFile "bat.expected" ''
This is a test syntax. 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,16 +1,14 @@
{ config, lib, pkgs, ... }: { realPkgs, ... }:
with lib;
{ {
config = {
programs.browserpass = { programs.browserpass = {
enable = true; enable = true;
browsers = browsers = [ "brave" "chrome" "chromium" "firefox" "librewolf" "vivaldi" ];
[ "brave" "chrome" "chromium" "firefox" "librewolf" "vivaldi" ];
}; };
nmt.script = if pkgs.stdenv.hostPlatform.isDarwin then '' 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 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" assertFileExists "home-files/Library/Application Support/$dir/NativeMessagingHosts/com.github.browserpass.native.json"
done done
@ -31,5 +29,4 @@ with lib;
assertFileExists "home-files/$dir/native-messaging-hosts/com.github.browserpass.native.json" assertFileExists "home-files/$dir/native-messaging-hosts/com.github.browserpass.native.json"
done 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,9 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
{ {
config = {
programs.bash.enable = true; programs.bash.enable = true;
programs.direnv.enable = true; programs.direnv.enable = true;
@ -11,7 +6,6 @@ with lib;
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;
nixpkgs.overlays = [ (_: _: { inherit (realPkgs) nix-direnv; }) ];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.bashrc assertFileExists home-files/.bashrc
assertFileExists home-files/.config/direnv/lib/hm-nix-direnv.sh 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,15 +1,14 @@
{ 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;
nixpkgs.overlays = [ (_: _: { inherit (realPkgs) nix-direnv; }) ];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.bashrc assertFileExists home-files/.bashrc
assertFileExists home-files/.config/direnv/lib/hm-nix-direnv.sh assertFileExists home-files/.config/direnv/lib/hm-nix-direnv.sh
@ -17,5 +16,4 @@ in {
home-files/.config/direnv/direnvrc \ home-files/.config/direnv/direnvrc \
'${expectedContent}' '${expectedContent}'
''; '';
};
} }

View file

@ -1,10 +1,5 @@
{ 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;
@ -16,5 +11,4 @@ in {
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,7 +1,4 @@
{ pkgs, ... }:
{ {
config = {
programs.feh.enable = true; programs.feh.enable = true;
programs.feh.buttons = { programs.feh.buttons = {
@ -17,8 +14,6 @@
prev_img = [ "h" "Left" ]; prev_img = [ "h" "Left" ];
}; };
test.stubs.feh = { };
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \
home-files/.config/feh/buttons \ home-files/.config/feh/buttons \
@ -28,5 +23,4 @@
home-files/.config/feh/keys \ home-files/.config/feh/keys \
${./feh-bindings-expected-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 = '' nmt.script = ''
assertPathNotExists home-files/.config/feh/buttons assertPathNotExists home-files/.config/feh/buttons
assertPathNotExists home-files/.config/feh/keys assertPathNotExists home-files/.config/feh/keys
assertPathNotExists home-files/.config/feh/themes assertPathNotExists home-files/.config/feh/themes
''; '';
};
} }

View file

@ -1,7 +1,4 @@
{ pkgs, ... }:
{ {
config = {
programs.feh.enable = true; programs.feh.enable = true;
programs.feh.themes = { programs.feh.themes = {
@ -21,12 +18,9 @@
example = [ "--info" "foo bar" ]; example = [ "--info" "foo bar" ];
}; };
test.stubs.feh = { };
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \
home-files/.config/feh/themes \ home-files/.config/feh/themes \
${./feh-themes-expected} ${./feh-themes-expected}
''; '';
};
} }

View file

@ -1,19 +1,16 @@
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; } // {
in {
imports = [ firefoxMockOverlay ];
config = lib.mkIf config.test.enableBig
(lib.setAttrByPath modulePath { enable = true; } // {
home.stateVersion = "19.09"; home.stateVersion = "19.09";
_module.args.pkgs = lib.mkForce realPkgs;
nmt.script = '' nmt.script = ''
package=${cfg.package} package=${cfg.package}
finalPackage=${cfg.finalPackage} finalPackage=${cfg.finalPackage}
@ -21,5 +18,4 @@ in {
fail "Expected finalPackage ($finalPackage) to equal package ($package)" fail "Expected finalPackage ($finalPackage) to equal package ($package)"
fi 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;
extraAttrs = {
binaryName = cfg.wrappedPackageName;
gtk3 = null;
meta.description = "I pretend to be ${cfg.name}"; meta.description = "I pretend to be ${cfg.name}";
passthru.gtk3 = null; };
} '' outPath = null;
buildScript = ''
echo BUILD
mkdir -p "$out"/{bin,lib} mkdir -p "$out"/{bin,lib}
touch "$out/bin/${cfg.wrappedPackageName}" touch "$out/bin/${cfg.wrappedPackageName}"
chmod 755 "$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 = '' nmt.script = ''
assertPathNotExists home-files/.config/foot assertPathNotExists home-files/.config/foot
''; '';
};
} }

View file

@ -1,9 +1,6 @@
{ 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 { };
@ -25,5 +22,4 @@ with lib;
home-files/.config/foot/foot.ini \ home-files/.config/foot/foot.ini \
${./example-settings-expected.ini} ${./example-settings-expected.ini}
''; '';
};
} }

View file

@ -1,9 +1,5 @@
{ config, lib, pkgs, ... }:
{ {
config = {
programs.foot = { programs.foot = {
package = config.lib.test.mkStubPackage { outPath = "@foot@"; };
enable = true; enable = true;
server.enable = true; server.enable = true;
}; };
@ -15,5 +11,4 @@
home-files/.config/systemd/user/foot.service \ home-files/.config/systemd/user/foot.service \
${./systemd-user-service-expected.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,15 +1,10 @@
{ 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 = '' nmt.script = ''
assertFileExists home-files/.config/gh/config.yml assertFileExists home-files/.config/gh/config.yml
assertFileContent home-files/.config/gh/config.yml ${ assertFileContent home-files/.config/gh/config.yml ${
@ -22,5 +17,4 @@
'' ''
} }
''; '';
};
} }

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,15 +1,12 @@
{ 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 = [ test.asserts.warnings.expected = [
"The option `programs.gh.editor' defined in ${ "The option `programs.gh.editor' defined in ${
lib.showFiles options.programs.gh.editor.files lib.showFiles options.programs.gh.editor.files
@ -32,5 +29,4 @@
'' ''
} }
''; '';
};
} }

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,16 +1,13 @@
{ 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 = { 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";
}; };
@ -20,7 +17,7 @@ with lib;
nmt.script = '' nmt.script = ''
function assertGitConfig() { function assertGitConfig() {
local value local value
value=$(${pkgs.gitMinimal}/bin/git config \ value=$(${realPkgs.gitMinimal}/bin/git config \
--file $TESTED/home-files/.config/git/config \ --file $TESTED/home-files/.config/git/config \
--get $1) --get $1)
if [[ $value != $2 ]]; then if [[ $value != $2 ]]; then
@ -36,5 +33,4 @@ with lib;
assertGitConfig "sendemail.hm@example.com.from" "H. M. Test <hm@example.com>" 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-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,28 +1,22 @@
{ 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"; home.stateVersion = "20.09";
test.stubs.msmtp = { };
nmt.script = '' nmt.script = ''
function assertGitConfig() { function assertGitConfig() {
local value local value
value=$(${pkgs.gitMinimal}/bin/git config \ value=$(${realPkgs.gitMinimal}/bin/git config \
--file $TESTED/home-files/.config/git/config \ --file $TESTED/home-files/.config/git/config \
--get $1) --get $1)
if [[ $value != $2 ]]; then if [[ $value != $2 ]]; then
@ -39,5 +33,4 @@ with lib;
assertGitConfig "sendemail.hm@example.com.smtpServer" "${pkgs.msmtp}/bin/msmtp" assertGitConfig "sendemail.hm@example.com.smtpServer" "${pkgs.msmtp}/bin/msmtp"
assertGitConfig "sendemail.hm@example.com.envelopeSender" "auto" assertGitConfig "sendemail.hm@example.com.envelopeSender" "auto"
''; '';
};
} }

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