tests: add option test.stubs

This option provides a more convenient way to overlay dummy packages.
It also adds a function `config.lib.test.mkStubPackage` that can,
e.g., be used for `package` options.
This commit is contained in:
Robert Helgesson 2021-09-26 11:08:45 +02:00
parent b0651cc217
commit cb09a968e9
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
159 changed files with 753 additions and 981 deletions

View file

@ -26,10 +26,13 @@ let
# unnecessary rebuilds of the tests. # unnecessary rebuilds of the tests.
manual.manpages.enable = false; manual.manpages.enable = false;
imports = [ ./asserts.nix ]; imports = [ ./asserts.nix ./stubs.nix ];
} }
]; ];
isDarwin = pkgs.stdenv.hostPlatform.isDarwin;
isLinux = pkgs.stdenv.hostPlatform.isLinux;
in in
import nmt { import nmt {
@ -89,12 +92,11 @@ import nmt {
./modules/programs/zplug ./modules/programs/zplug
./modules/programs/zsh ./modules/programs/zsh
./modules/xresources ./modules/xresources
] ++ lib.optionals pkgs.stdenv.hostPlatform.isDarwin [ ] ++ lib.optionals isDarwin [
./modules/targets-darwin ./modules/targets-darwin
] ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [ ] ++ lib.optionals isLinux [
./modules/config/i18n ./modules/config/i18n
./modules/i18n/input-method ./modules/i18n/input-method
./modules/misc/debug
./modules/misc/gtk ./modules/misc/gtk
./modules/misc/numlock ./modules/misc/numlock
./modules/misc/pam ./modules/misc/pam
@ -103,7 +105,6 @@ import nmt {
./modules/misc/xsession ./modules/misc/xsession
./modules/programs/abook ./modules/programs/abook
./modules/programs/autorandr ./modules/programs/autorandr
./modules/programs/firefox
./modules/programs/foot ./modules/programs/foot
./modules/programs/getmail ./modules/programs/getmail
./modules/programs/gnome-terminal ./modules/programs/gnome-terminal
@ -142,5 +143,8 @@ import nmt {
./modules/targets-linux ./modules/targets-linux
] ++ lib.optionals enableBig [ ] ++ lib.optionals enableBig [
./modules/programs/emacs ./modules/programs/emacs
] ++ lib.optionals (enableBig && isLinux) [
./modules/misc/debug
./modules/programs/firefox
]); ]);
} }

View file

@ -1,15 +1,14 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
config = { imports = [ ./fcitx5-stubs.nix ];
nixpkgs.overlays = [ (import ./fcitx5-overlay.nix) ];
i18n.inputMethod = {
enabled = "fcitx5";
fcitx5.addons = with pkgs; [ fcitx5-chinese-addons ];
};
nmt.script = '' i18n.inputMethod = {
assertFileExists home-files/.config/systemd/user/fcitx5-daemon.service enabled = "fcitx5";
''; fcitx5.addons = with pkgs; [ fcitx5-chinese-addons ];
}; };
nmt.script = ''
assertFileExists home-files/.config/systemd/user/fcitx5-daemon.service
'';
} }

View file

@ -1,22 +0,0 @@
final: prev:
let
dummy = prev.runCommandLocal "dummy-package" { } "mkdir $out";
in {
fcitx5 = prev.runCommandLocal "fcitx5" { version = "0"; } ''
mkdir -p $out/bin $out/share/applications $out/etc/xdg/autostart
touch $out/bin/fcitx5 \
$out/share/applications/org.fcitx.Fcitx5.desktop \
$out/etc/xdg/autostart/org.fcitx.Fcitx5.desktop
chmod +x $out/bin/fcitx5
'';
fcitx5-configtool = dummy;
fcitx5-lua = dummy;
fcitx5-qt = dummy;
fcitx5-gtk = dummy;
fcitx5-with-addons =
prev.fcitx5-with-addons.override { inherit (final) fcitx5-qt; };
fcitx5-chinese-addons = dummy;
}

View file

@ -0,0 +1,27 @@
{
test.stubs = {
fcitx5 = {
version = "0";
outPath = null;
buildScript = ''
mkdir -p $out/bin $out/share/applications $out/etc/xdg/autostart
touch $out/bin/fcitx5 \
$out/share/applications/org.fcitx.Fcitx5.desktop \
$out/etc/xdg/autostart/org.fcitx.Fcitx5.desktop
chmod +x $out/bin/fcitx5
'';
};
fcitx5-configtool = { outPath = null; };
fcitx5-lua = { outPath = null; };
fcitx5-qt = { outPath = null; };
fcitx5-gtk = { outPath = null; };
fcitx5-chinese-addons = { outPath = null; };
};
nixpkgs.overlays = [
(self: super: {
fcitx5-with-addons =
super.fcitx5-with-addons.override { inherit (self) fcitx5-qt; };
})
];
}

View file

@ -9,6 +9,8 @@ with lib;
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
assertFileContent home-files/.gtkrc-2.0 ${ assertFileContent home-files/.gtkrc-2.0 ${

View file

@ -7,6 +7,8 @@ with lib;
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 \

View file

@ -6,9 +6,7 @@ with lib;
config = { config = {
xsession.numlock.enable = true; xsession.numlock.enable = true;
nixpkgs.overlays = [ test.stubs.numlockx = { };
(self: super: { numlockx = pkgs.writeScriptBin "dummy-numlockx" ""; })
];
nmt.script = '' nmt.script = ''
serviceFile=home-files/.config/systemd/user/numlockx.service serviceFile=home-files/.config/systemd/user/numlockx.service

View file

@ -7,15 +7,11 @@
platformTheme = "gnome"; platformTheme = "gnome";
style = { style = {
name = "adwaita"; name = "adwaita";
package = pkgs.dummyTheme; package = config.lib.test.mkStubPackage { };
}; };
}; };
nixpkgs.overlays = [ test.stubs.qgnomeplatform = { };
(self: super: {
dummyTheme = pkgs.runCommandLocal "theme" { } "mkdir $out";
})
];
nmt.script = '' nmt.script = ''
assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \ assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \

View file

@ -6,8 +6,7 @@ with lib;
config = { config = {
programs.abook.enable = true; programs.abook.enable = true;
nixpkgs.overlays = test.stubs.abook = { };
[ (self: super: { abook = pkgs.writeScriptBin "dummy-abook" ""; }) ];
nmt.script = '' nmt.script = ''
assertPathNotExists home-files/.config/abook/abookrc assertPathNotExists home-files/.config/abook/abookrc

View file

@ -28,8 +28,7 @@ with lib;
''; '';
}; };
nixpkgs.overlays = test.stubs.abook = { };
[ (self: super: { abook = pkgs.writeScriptBin "dummy-abook" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/abook/abookrc assertFileExists home-files/.config/abook/abookrc

View file

@ -6,9 +6,7 @@ with lib;
config = { config = {
programs.alacritty.enable = true; programs.alacritty.enable = true;
nixpkgs.overlays = [ test.stubs.alacritty = { };
(self: super: { alacritty = pkgs.writeScriptBin "dummy-alacritty" ""; })
];
nmt.script = '' nmt.script = ''
assertPathNotExists home-files/.config/alacritty assertPathNotExists home-files/.config/alacritty

View file

@ -6,7 +6,7 @@ with lib;
config = { config = {
programs.alacritty = { programs.alacritty = {
enable = true; enable = true;
package = pkgs.writeScriptBin "dummy-alacritty" ""; package = config.lib.test.mkStubPackage { };
settings = { settings = {
window.dimensions = { window.dimensions = {

View file

@ -6,7 +6,7 @@ with lib;
config = { config = {
programs.alacritty = { programs.alacritty = {
enable = true; enable = true;
package = pkgs.writeScriptBin "dummy-alacritty" ""; package = config.lib.test.mkStubPackage { };
settings = { settings = {
window.dimensions = { window.dimensions = {

View file

@ -23,8 +23,7 @@ with lib;
programs.alot = { enable = true; }; programs.alot = { enable = true; };
nixpkgs.overlays = test.stubs.alot = { };
[ (self: super: { alot = pkgs.writeScriptBin "dummy-alot" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/alot/config assertFileExists home-files/.config/alot/config

View file

@ -20,8 +20,7 @@ with lib;
''; '';
}; };
nixpkgs.overlays = test.stubs.aria2 = { };
[ (self: super: { aria2 = pkgs.writeScriptBin "dummy-aria2" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \

View file

@ -6,6 +6,10 @@ with lib;
config = { config = {
programs.autojump.enable = true; programs.autojump.enable = true;
test.stubs.autojump = {
buildScript = "mkdir -p $out/bin; touch $out/bin/autojump";
};
nmt.script = '' nmt.script = ''
assertFileExists home-path/bin/autojump assertFileExists home-path/bin/autojump
''; '';

View file

@ -28,6 +28,8 @@
}; };
}; };
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

View file

@ -17,6 +17,8 @@
}; };
}; };
test.stubs.autorandr = { };
nmt.script = '' nmt.script = ''
config=home-files/.config/autorandr/default/config config=home-files/.config/autorandr/default/config

View file

@ -18,8 +18,7 @@ with lib;
''; '';
}; };
nixpkgs.overlays = test.stubs.bat = { };
[ (self: super: { bat = pkgs.writeScriptBin "dummy" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/bat/config assertFileExists home-files/.config/bat/config

View file

@ -6,7 +6,7 @@ with lib;
config = { config = {
programs.bottom = { programs.bottom = {
enable = true; enable = true;
package = pkgs.writeScriptBin "dummy" ""; package = config.lib.test.mkStubPackage { };
}; };
nmt.script = '' nmt.script = ''

View file

@ -6,7 +6,7 @@ with lib;
config = { config = {
programs.bottom = { programs.bottom = {
enable = true; enable = true;
package = pkgs.writeShellScriptBin "dummy" ""; package = config.lib.test.mkStubPackage { };
settings = { settings = {
flags = { flags = {

View file

@ -9,8 +9,7 @@ with lib;
modal = true; modal = true;
}; };
nixpkgs.overlays = test.stubs.broot = { };
[ (self: super: { broot = pkgs.writeScriptBin "dummy" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/broot/conf.toml assertFileExists home-files/.config/broot/conf.toml

View file

@ -17,8 +17,7 @@
prev_img = [ "h" "Left" ]; prev_img = [ "h" "Left" ];
}; };
nixpkgs.overlays = test.stubs.feh = { };
[ (self: super: { feh = pkgs.writeScriptBin "dummy-feh" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \

View file

@ -4,8 +4,7 @@
config = { config = {
programs.feh.enable = true; programs.feh.enable = true;
nixpkgs.overlays = test.stubs.feh = { };
[ (self: super: { feh = pkgs.writeScriptBin "dummy-feh" ""; }) ];
nmt.script = '' nmt.script = ''
assertPathNotExists home-files/.config/feh/buttons assertPathNotExists home-files/.config/feh/buttons

View file

@ -34,8 +34,7 @@ in {
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" "");
nixpkgs.overlays = test.stubs.fish = { };
[ (self: super: { fish = pkgs.writeScriptBin "dummy" ""; }) ];
nmt = { nmt = {
description = description =

View file

@ -14,8 +14,7 @@ with lib;
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" "");
nixpkgs.overlays = test.stubs.fish = { };
[ (self: super: { fish = pkgs.writeScriptBin "dummy" ""; }) ];
nmt = { nmt = {
description = description =

View file

@ -50,8 +50,7 @@ in {
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" "");
nixpkgs.overlays = test.stubs.fish = { };
[ (self: super: { fish = pkgs.writeScriptBin "dummy" ""; }) ];
nmt = { nmt = {
description = description =

View file

@ -6,8 +6,7 @@ with lib;
config = { config = {
programs.foot.enable = true; programs.foot.enable = true;
nixpkgs.overlays = test.stubs.foot = { };
[ (self: super: { foot = pkgs.writeScriptBin "dummy-foot" ""; }) ];
nmt.script = '' nmt.script = ''
assertPathNotExists home-files/.config/foot assertPathNotExists home-files/.config/foot

View file

@ -6,7 +6,7 @@ with lib;
config = { config = {
programs.foot = { programs.foot = {
enable = true; enable = true;
package = pkgs.writeShellScriptBin "dummy-foot" ""; package = config.lib.test.mkStubPackage { };
settings = { settings = {
main = { main = {

View file

@ -1,11 +1,9 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
let {
package = pkgs.writeShellScriptBin "dummy-foot" "" // { outPath = "@foot@"; };
in {
config = { config = {
programs.foot = { programs.foot = {
inherit package; package = config.lib.test.mkStubPackage { outPath = "@foot@"; };
enable = true; enable = true;
server.enable = true; server.enable = true;
}; };

View file

@ -8,8 +8,7 @@
editor = "vim"; editor = "vim";
}; };
nixpkgs.overlays = test.stubs.gh = { };
[ (self: super: { gh = pkgs.writeScriptBin "dummy-gh" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/gh/config.yml assertFileExists home-files/.config/gh/config.yml

View file

@ -79,14 +79,10 @@ in {
} }
]; ];
nixpkgs.overlays = [ test.stubs = {
(self: super: { git-lfs = { };
git-lfs = pkgs.writeScriptBin "dummy-git-lfs" ""; delta = { };
delta = pkgs.writeScriptBin "dummy-delta" "" // { };
outPath = "@delta@";
};
})
];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/git/config assertFileExists home-files/.config/git/config

View file

@ -4,13 +4,6 @@ with lib;
{ {
config = { config = {
nixpkgs.overlays = [
(self: super: {
gnome.gnome-terminal =
pkgs.writeScriptBin "dummy-gnome3-gnome-terminal" "";
})
];
programs.gnome-terminal = { programs.gnome-terminal = {
enable = true; enable = true;
profile = { profile = {
@ -55,6 +48,14 @@ with lib;
showMenubar = false; showMenubar = false;
}; };
nixpkgs.overlays = [
(self: super: {
gnome.gnome-terminal = config.lib.test.mkStubPackage { };
})
];
test.stubs.dconf = { };
nmt.script = '' nmt.script = ''
dconfIni=$(grep -oPm 1 '/nix/store/[a-z0-9]*?-hm-dconf.ini' $TESTED/activate) dconfIni=$(grep -oPm 1 '/nix/store/[a-z0-9]*?-hm-dconf.ini' $TESTED/activate)
assertFileContent $dconfIni ${./gnome-terminal-1.conf} assertFileContent $dconfIni ${./gnome-terminal-1.conf}

View file

@ -5,34 +5,31 @@ 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" = { himalaya = {
himalaya = { enable = true;
enable = true;
settings = { default-page-size = 50; }; settings = { default-page-size = 50; };
};
imap.port = 995;
smtp.port = 465;
}; };
imap.port = 995;
smtp.port = 465;
}; };
programs.himalaya = {
enable = true;
settings = { downloads-dir = "/data/download"; };
};
nixpkgs.overlays =
[ (self: super: { himalaya = pkgs.writeScriptBin "dummy-alot" ""; }) ];
nmt.script = ''
assertFileExists home-files/.config/himalaya/config.toml
assertFileContent home-files/.config/himalaya/config.toml ${
./himalaya-expected.toml
}
'';
}; };
programs.himalaya = {
enable = true;
settings = { downloads-dir = "/data/download"; };
};
test.stubs.himalaya = { };
nmt.script = ''
assertFileExists home-files/.config/himalaya/config.toml
assertFileContent home-files/.config/himalaya/config.toml ${
./himalaya-expected.toml
}
'';
} }

View file

@ -6,8 +6,7 @@ with lib;
config = { config = {
programs.htop.enable = true; programs.htop.enable = true;
nixpkgs.overlays = test.stubs.htop = { };
[ (self: super: { htop = pkgs.writeScriptBin "dummy" ""; }) ];
nmt.script = '' nmt.script = ''
assertPathNotExists home-files/.config/htop assertPathNotExists home-files/.config/htop

View file

@ -36,8 +36,7 @@ with lib;
(text "Systemd") (text "Systemd")
]); ]);
nixpkgs.overlays = test.stubs.htop = { };
[ (self: super: { htop = pkgs.writeScriptBin "dummy" ""; }) ];
nmt.script = '' nmt.script = ''
htoprc=home-files/.config/htop/htoprc htoprc=home-files/.config/htop/htoprc

View file

@ -7,8 +7,7 @@ with lib;
programs.htop.enable = true; programs.htop.enable = true;
programs.htop.settings = { color_scheme = 6; }; programs.htop.settings = { color_scheme = 6; };
nixpkgs.overlays = test.stubs.htop = { };
[ (self: super: { htop = pkgs.writeScriptBin "dummy" ""; }) ];
# Test that the 'fields' key is written in addition to the customized # Test that the 'fields' key is written in addition to the customized
# settings or htop won't read the options. # settings or htop won't read the options.

View file

@ -92,11 +92,7 @@ with lib;
}; };
}; };
nixpkgs.overlays = [ test.stubs.i3status-rust = { };
(self: super: {
i3status-rust = pkgs.writeScriptBin "dummy-i3status-rust" "";
})
];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/i3status-rust/config-custom.toml assertFileExists home-files/.config/i3status-rust/config-custom.toml

View file

@ -6,11 +6,7 @@ with lib;
config = { config = {
programs.i3status-rust = { enable = true; }; programs.i3status-rust = { enable = true; };
nixpkgs.overlays = [ test.stubs.i3status-rust = { };
(self: super: {
i3status-rust = pkgs.writeScriptBin "dummy-i3status-rust" "";
})
];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/i3status-rust/config-default.toml assertFileExists home-files/.config/i3status-rust/config-default.toml

View file

@ -102,11 +102,7 @@ with lib;
}; };
}; };
nixpkgs.overlays = [ test.stubs.i3status-rust = { };
(self: super: {
i3status-rust = pkgs.writeScriptBin "dummy-i3status-rust" "";
})
];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/i3status-rust/config-extra-settings.toml assertFileExists home-files/.config/i3status-rust/config-extra-settings.toml

View file

@ -52,11 +52,7 @@ with lib;
}; };
nixpkgs.overlays = [ test.stubs.i3status-rust = { };
(self: super: {
i3status-rust = pkgs.writeScriptBin "dummy-i3status-rust" "";
})
];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/i3status-rust/config-top.toml assertFileExists home-files/.config/i3status-rust/config-top.toml

View file

@ -32,9 +32,7 @@ with lib;
}; };
}; };
nixpkgs.overlays = [ test.stubs.i3status = { };
(self: super: { i3status = pkgs.writeScriptBin "dummy-i3status" ""; })
];
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \

View file

@ -9,9 +9,7 @@ with lib;
enableDefault = true; enableDefault = true;
}; };
nixpkgs.overlays = [ test.stubs.i3status = { };
(self: super: { i3status = pkgs.writeScriptBin "dummy-i3status" ""; })
];
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \

View file

@ -19,13 +19,12 @@ with lib;
}; };
}; };
test.stubs.irsii = { };
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \
home-files/.irssi/config \ home-files/.irssi/config \
${./example-settings-expected.config} ${./example-settings-expected.config}
''; '';
nixpkgs.overlays =
[ (self: super: { irsii = pkgs.writeScriptBin "dummy-irsii" ""; }) ];
}; };
} }

View file

@ -30,8 +30,7 @@ with lib;
environment = { LS_COLORS = "1"; }; environment = { LS_COLORS = "1"; };
}; };
nixpkgs.overlays = test.stubs.kitty = { };
[ (self: super: { kitty = pkgs.writeScriptBin "dummy-kitty" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/kitty/kitty.conf assertFileExists home-files/.config/kitty/kitty.conf

View file

@ -75,8 +75,7 @@ in {
}; };
}; };
nixpkgs.overlays = test.stubs.lf = { };
[ (self: super: { lf = pkgs.writeScriptBin "dummy-lf" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/lf/lfrc assertFileExists home-files/.config/lf/lfrc

View file

@ -7,8 +7,7 @@ in {
config = { config = {
programs.lf = { enable = true; }; programs.lf = { enable = true; };
nixpkgs.overlays = test.stubs.lf = { };
[ (self: super: { lf = pkgs.writeScriptBin "dummy-lf" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/lf/lfrc assertFileExists home-files/.config/lf/lfrc

View file

@ -32,8 +32,7 @@ in {
previewer = { source = pvScript; }; previewer = { source = pvScript; };
}; };
nixpkgs.overlays = test.stubs.lf = { };
[ (self: super: { lf = pkgs.writeScriptBin "dummy-lf" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/lf/lfrc assertFileExists home-files/.config/lf/lfrc

View file

@ -7,7 +7,7 @@ with lib;
config = { config = {
programs.lieer.enable = true; programs.lieer.enable = true;
programs.lieer.package = pkgs.writeScriptBin "dummy-gmailieer" ""; programs.lieer.package = config.lib.test.mkStubPackage { };
accounts.email.accounts."hm@example.com" = { accounts.email.accounts."hm@example.com" = {
flavor = "gmail.com"; flavor = "gmail.com";

View file

@ -4,7 +4,7 @@
config = { config = {
programs.mangohud = { programs.mangohud = {
enable = true; enable = true;
package = pkgs.writeScriptBin "dummy-mangohud" ""; package = config.lib.test.mkStubPackage { };
settings = { settings = {
output_folder = /home/user/Documents/mangohud; output_folder = /home/user/Documents/mangohud;
fps_limit = [ 30 60 ]; fps_limit = [ 30 60 ];

View file

@ -29,9 +29,7 @@
defaultProfiles = [ "gpu-hq" ]; defaultProfiles = [ "gpu-hq" ];
}; };
nixpkgs.overlays = [ test.stubs.mpvDummy = { };
(self: super: { mpvDummy = pkgs.runCommandLocal "mpv" { } "mkdir $out"; })
];
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \

View file

@ -22,7 +22,7 @@
touch $out/bin/{,u}mpv $out/Applications/mpv.app/Contents/MacOS/mpv touch $out/bin/{,u}mpv $out/Applications/mpv.app/Contents/MacOS/mpv
chmod 755 $out/bin/{,u}mpv $out/Applications/mpv.app/Contents/MacOS/mpv chmod 755 $out/bin/{,u}mpv $out/Applications/mpv.app/Contents/MacOS/mpv
''; '';
mpvDummy = pkgs.runCommandLocal "mpv" { } "mkdir $out"; mpvDummy = config.lib.test.mkStubPackage { };
mpvScript = mpvScript =
pkgs.runCommandLocal "mpvScript" { scriptName = "something"; } pkgs.runCommandLocal "mpvScript" { scriptName = "something"; }
"mkdir $out"; "mkdir $out";

View file

@ -7,12 +7,10 @@
services.mpd.enable = true; services.mpd.enable = true;
services.mpd.musicDirectory = "/home/user/music"; services.mpd.musicDirectory = "/home/user/music";
nixpkgs.overlays = [ test.stubs = {
(self: super: { ncmpcpp = { };
ncmpcpp = pkgs.writeScriptBin "dummy-ncmpcpp" ""; mpd = { };
mpd = pkgs.writeScriptBin "dummy-mpd" ""; };
})
];
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \

View file

@ -4,8 +4,7 @@
config = { config = {
programs.ncmpcpp.enable = true; programs.ncmpcpp.enable = true;
nixpkgs.overlays = test.stubs.ncmpcpp = { };
[ (self: super: { ncmpcpp = pkgs.writeScriptBin "dummy-ncmpcpp" ""; }) ];
nmt.script = '' nmt.script = ''
assertPathNotExists home-files/.config/ncmpcpp/config assertPathNotExists home-files/.config/ncmpcpp/config

View file

@ -44,8 +44,7 @@
]; ];
}; };
nixpkgs.overlays = test.stubs.ncmpcpp = { };
[ (self: super: { ncmpcpp = pkgs.writeScriptBin "dummy-ncmpcpp" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \

View file

@ -19,8 +19,7 @@ in {
automaticPreferences.".default" = autopref; automaticPreferences.".default" = autopref;
}; };
nixpkgs.overlays = test.stubs.ne = { };
[ (self: super: { ne = pkgs.writeScriptBin "dummy-ne" ""; }) ];
nmt = { nmt = {
description = description =

View file

@ -53,8 +53,7 @@ in {
inherit automaticPreferences; inherit automaticPreferences;
}; };
nixpkgs.overlays = test.stubs.ne = { };
[ (self: super: { ne = pkgs.writeScriptBin "dummy-ne" ""; }) ];
nmt = { nmt = {
description = "Check that configuration files are correctly written"; description = "Check that configuration files are correctly written";

View file

@ -17,8 +17,7 @@ with lib;
programs.neomutt.enable = true; programs.neomutt.enable = true;
programs.neomutt.changeFolderWhenSourcingAccount = false; programs.neomutt.changeFolderWhenSourcingAccount = false;
nixpkgs.overlays = test.stubs.neomutt = { };
[ (self: super: { neomutt = pkgs.writeScriptBin "dummy-neomutt" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/neomutt/hm@example.com assertFileExists home-files/.config/neomutt/hm@example.com

View file

@ -13,8 +13,7 @@ with lib;
programs.neomutt.enable = true; programs.neomutt.enable = true;
nixpkgs.overlays = test.stubs.neomutt = { };
[ (self: super: { neomutt = pkgs.writeScriptBin "dummy-neomutt" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/neomutt/neomuttrc assertFileExists home-files/.config/neomutt/neomuttrc

View file

@ -50,8 +50,7 @@ with lib;
]; ];
}; };
nixpkgs.overlays = test.stubs.neomutt = { };
[ (self: super: { neomutt = pkgs.writeScriptBin "dummy-neomutt" ""; }) ];
test.asserts.warnings.expected = [ test.asserts.warnings.expected = [
"Specifying 'programs.neomutt.(binds|macros).map' as a string is deprecated, use a list of strings instead. See https://github.com/nix-community/home-manager/pull/1885." "Specifying 'programs.neomutt.(binds|macros).map' as a string is deprecated, use a list of strings instead. See https://github.com/nix-community/home-manager/pull/1885."

View file

@ -50,8 +50,7 @@ with lib;
]; ];
}; };
nixpkgs.overlays = test.stubs.neomutt = { };
[ (self: super: { neomutt = pkgs.writeScriptBin "dummy-neomutt" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/neomutt/neomuttrc assertFileExists home-files/.config/neomutt/neomuttrc

View file

@ -16,8 +16,7 @@ with lib; {
programs.neomutt.enable = true; programs.neomutt.enable = true;
nixpkgs.overlays = test.stubs.neomutt = { };
[ (self: super: { neomutt = pkgs.writeScriptBin "dummy-neomutt" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/neomutt/neomuttrc assertFileExists home-files/.config/neomutt/neomuttrc

View file

@ -21,8 +21,7 @@ with lib;
programs.neomutt.enable = true; programs.neomutt.enable = true;
nixpkgs.overlays = test.stubs.neomutt = { };
[ (self: super: { neomutt = pkgs.writeScriptBin "dummy-neomutt" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/neomutt/neomuttrc assertFileExists home-files/.config/neomutt/neomuttrc

View file

@ -33,8 +33,7 @@ with lib;
vimKeys = false; vimKeys = false;
}; };
nixpkgs.overlays = test.stubs.neomutt = { };
[ (self: super: { neomutt = pkgs.writeScriptBin "dummy-neomutt" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/neomutt/neomuttrc assertFileExists home-files/.config/neomutt/neomuttrc

View file

@ -24,8 +24,7 @@ with lib;
vimKeys = false; vimKeys = false;
}; };
nixpkgs.overlays = test.stubs.neomutt = { };
[ (self: super: { neomutt = pkgs.writeScriptBin "dummy-neomutt" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/neomutt/neomuttrc assertFileExists home-files/.config/neomutt/neomuttrc

View file

@ -22,9 +22,7 @@ with lib;
queries = { "foo" = ''rssurl =~ "example.com"''; }; queries = { "foo" = ''rssurl =~ "example.com"''; };
}; };
nixpkgs.overlays = [ test.stubs.newsboat = { };
(self: super: { newsboat = pkgs.writeScriptBin "dummy-newsboat" ""; })
];
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \

View file

@ -22,9 +22,7 @@ with lib;
queries = { "foo" = ''rssurl =~ "example.com"''; }; queries = { "foo" = ''rssurl =~ "example.com"''; };
}; };
nixpkgs.overlays = [ test.stubs.newsboat = { };
(self: super: { newsboat = pkgs.writeScriptBin "dummy-newsboat" ""; })
];
# The format didn't change since 20.03, just the location. # The format didn't change since 20.03, just the location.
nmt.script = '' nmt.script = ''

View file

@ -20,9 +20,7 @@ with lib;
queries = { "foo" = ''rssurl =~ "example.com"''; }; queries = { "foo" = ''rssurl =~ "example.com"''; };
}; };
nixpkgs.overlays = [ test.stubs.newsboat = { };
(self: super: { newsboat = pkgs.writeScriptBin "dummy-newsboat" ""; })
];
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \

View file

@ -12,14 +12,10 @@
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" "");
nixpkgs.overlays = [ test.stubs = {
(self: super: zsh = { };
let dummy = pkgs.writeScriptBin "dummy" ""; fish = { };
in { };
zsh = dummy;
fish = dummy;
})
];
programs.nix-index.enable = true; programs.nix-index.enable = true;

View file

@ -16,14 +16,10 @@ in {
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" "");
nixpkgs.overlays = [ test.stubs = {
(self: super: zsh = { };
let dummy = pkgs.writeScriptBin "dummy" ""; fish = { };
in { };
zsh = dummy;
fish = dummy;
})
];
programs.nix-index.enable = true; programs.nix-index.enable = true;

View file

@ -22,8 +22,7 @@ with lib;
]; ];
}; };
nixpkgs.overlays = test.stubs.nushell = { };
[ (self: super: { nushell = pkgs.writeScriptBin "dummy-nushell" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \

View file

@ -18,8 +18,7 @@ with lib;
}; };
}; };
nixpkgs.overlays = test.stubs.powerline-go = { };
[ (self: super: { powerline-go = pkgs.writeScriptBin "dummy-pkg" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.bashrc assertFileExists home-files/.bashrc

View file

@ -22,14 +22,10 @@ with lib;
xdg.dataFile."fish/home-manager_generated_completions".source = xdg.dataFile."fish/home-manager_generated_completions".source =
mkForce (builtins.toFile "empty" ""); mkForce (builtins.toFile "empty" "");
nixpkgs.overlays = [ test.stubs = {
(self: super: powerline-go = { };
let dummy = pkgs.writeScriptBin "dummy" ""; fish = { };
in { };
powerline-go = dummy;
fish = dummy;
})
];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.config/fish/config.fish assertFileExists home-files/.config/fish/config.fish

View file

@ -18,12 +18,10 @@ with lib;
}; };
}; };
nixpkgs.overlays = [ test.stubs = {
(self: super: { powerline-go = { };
powerline-go = pkgs.writeScriptBin "dummy-pkg" ""; zsh = { };
zsh = pkgs.writeScriptBin "dummy-pkg" ""; };
})
];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.zshrc assertFileExists home-files/.zshrc

View file

@ -18,11 +18,7 @@ with lib;
}; };
}; };
nixpkgs.overlays = [ test.stubs.qutebrowser = { };
(self: super: {
qutebrowser = pkgs.writeScriptBin "dummy-qutebrowser" "";
})
];
nmt.script = let nmt.script = let
qutebrowserConfig = if pkgs.stdenv.hostPlatform.isDarwin then qutebrowserConfig = if pkgs.stdenv.hostPlatform.isDarwin then

View file

@ -13,11 +13,7 @@ with lib;
}; };
}; };
nixpkgs.overlays = [ test.stubs.qutebrowser = { };
(self: super: {
qutebrowser = pkgs.writeScriptBin "dummy-qutebrowser" "";
})
];
nmt.script = let nmt.script = let
quickmarksFile = if pkgs.stdenv.hostPlatform.isDarwin then quickmarksFile = if pkgs.stdenv.hostPlatform.isDarwin then

View file

@ -24,11 +24,7 @@ with lib;
''; '';
}; };
nixpkgs.overlays = [ test.stubs.qutebrowser = { };
(self: super: {
qutebrowser = pkgs.writeScriptBin "dummy-qutebrowser" "";
})
];
nmt.script = let nmt.script = let
qutebrowserConfig = if pkgs.stdenv.hostPlatform.isDarwin then qutebrowserConfig = if pkgs.stdenv.hostPlatform.isDarwin then

View file

@ -1,4 +1,5 @@
{ pkgs, ... }: { pkgs, ... }:
let let
inherit (pkgs.stdenv.hostPlatform) isDarwin; inherit (pkgs.stdenv.hostPlatform) isDarwin;
@ -7,13 +8,11 @@ let
else else
".config/rbw/config.json"; ".config/rbw/config.json";
in { in {
config = { imports = [ ./rbw-stubs.nix ];
programs.rbw.enable = true;
nixpkgs.overlays = [ (import ./overlay.nix) ]; programs.rbw.enable = true;
nmt.script = '' nmt.script = ''
assertPathNotExists home-files/${path} assertPathNotExists home-files/${path}
''; '';
};
} }

View file

@ -1,12 +0,0 @@
self: super: {
rbw = self.writeScriptBin "dummy-rbw" "";
pinentry = {
gnome3 = self.writeScriptBin "pinentry-gnome3" "" // {
outPath = "@pinentry-gnome3@";
};
gtk2 = self.writeScriptBin "pinentry-gtk2" "" // {
outPath = "@pinentry-gtk2@";
};
flavors = [ "gnome3" "gtk2" ];
};
}

View file

@ -0,0 +1,16 @@
{ config, ... }:
{
test.stubs.rbw = { };
nixpkgs.overlays = [
(self: super: {
pinentry = {
gnome3 =
config.lib.test.mkStubPackage { outPath = "@pinentry-gnome3@"; };
gtk2 = config.lib.test.mkStubPackage { outPath = "@pinentry-gtk2@"; };
flavors = [ "gnome3" "gtk2" ];
};
})
];
}

View file

@ -1,4 +1,5 @@
{ pkgs, ... }: { pkgs, ... }:
let let
inherit (pkgs.stdenv.hostPlatform) isDarwin; inherit (pkgs.stdenv.hostPlatform) isDarwin;
@ -17,23 +18,21 @@ let
} }
''; '';
in { in {
config = { imports = [ ./rbw-stubs.nix ];
programs.rbw = {
enable = true; programs.rbw = {
settings = { enable = true;
email = "name@example.com"; settings = {
base_url = "bitwarden.example.com"; email = "name@example.com";
identity_url = "identity.example.com"; base_url = "bitwarden.example.com";
lock_timeout = 300; identity_url = "identity.example.com";
pinentry = "gnome3"; lock_timeout = 300;
}; pinentry = "gnome3";
}; };
nixpkgs.overlays = [ (import ./overlay.nix) ];
nmt.script = ''
assertFileExists home-files/${path}
assertFileContent home-files/${path} '${expected}'
'';
}; };
nmt.script = ''
assertFileExists home-files/${path}
assertFileContent home-files/${path} '${expected}'
'';
} }

View file

@ -1,4 +1,5 @@
{ pkgs, ... }: { pkgs, ... }:
let let
inherit (pkgs.stdenv.hostPlatform) isDarwin; inherit (pkgs.stdenv.hostPlatform) isDarwin;
@ -17,17 +18,15 @@ let
} }
''; '';
in { in {
config = { imports = [ ./rbw-stubs.nix ];
programs.rbw = {
enable = true;
settings = { email = "name@example.com"; };
};
nixpkgs.overlays = [ (import ./overlay.nix) ]; programs.rbw = {
enable = true;
nmt.script = '' settings = { email = "name@example.com"; };
assertFileExists home-files/${path}
assertFileContent home-files/${path} '${expected}'
'';
}; };
nmt.script = ''
assertFileExists home-files/${path}
assertFileContent home-files/${path} '${expected}'
'';
} }

View file

@ -16,14 +16,10 @@ with lib;
}; };
}; };
nixpkgs.overlays = [ test.stubs = {
(self: super: rofi = { };
let dummy = pkgs.writeScriptBin "dummy" ""; rofi-pass = { };
in { };
rofi = dummy;
rofi-pass = dummy;
})
];
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \

View file

@ -13,14 +13,10 @@ with lib;
}; };
}; };
nixpkgs.overlays = [ test.stubs = {
(self: super: rofi = { };
let dummy = pkgs.writeScriptBin "dummy" ""; rofi-pass = { };
in { };
rofi = dummy;
rofi-pass = dummy;
})
];
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \

View file

@ -17,8 +17,7 @@ with lib;
}; };
}; };
nixpkgs.overlays = test.stubs.rofi = { };
[ (self: super: { rofi = pkgs.writeScriptBin "dummy-rofi" ""; }) ];
test.asserts.assertions.expected = ['' test.asserts.assertions.expected = [''
Cannot use the rofi options 'theme' and 'colors' simultaneously. Cannot use the rofi options 'theme' and 'colors' simultaneously.

View file

@ -29,8 +29,7 @@ with lib;
}; };
}; };
nixpkgs.overlays = test.stubs.rofi = { };
[ (self: super: { rofi = pkgs.writeScriptBin "dummy-rofi" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \

View file

@ -48,8 +48,7 @@ with lib;
}; };
}; };
nixpkgs.overlays = test.stubs.rofi = { };
[ (self: super: { rofi = pkgs.writeScriptBin "dummy-rofi" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \

View file

@ -10,8 +10,7 @@
zsh.enable = true; zsh.enable = true;
}; };
nixpkgs.overlays = test.stubs.zsh = { };
[ (self: super: { zsh = pkgs.writeScriptBin "dummy" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileNotRegex home-files/.zshrc '${pkgs.scmpuff} init -s' assertFileNotRegex home-files/.zshrc '${pkgs.scmpuff} init -s'

View file

@ -8,8 +8,7 @@
zsh.enable = true; zsh.enable = true;
}; };
nixpkgs.overlays = test.stubs.zsh = { };
[ (self: super: { zsh = pkgs.writeScriptBin "dummy" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileNotRegex home-files/.zshrc '${pkgs.scmpuff} init -s' assertFileNotRegex home-files/.zshrc '${pkgs.scmpuff} init -s'

View file

@ -5,8 +5,7 @@
zsh.enable = true; zsh.enable = true;
}; };
nixpkgs.overlays = test.stubs.zsh = { };
[ (self: super: { zsh = pkgs.writeScriptBin "dummy" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileExists home-files/.zshrc assertFileExists home-files/.zshrc

View file

@ -39,8 +39,7 @@ with lib;
}; };
}; };
nixpkgs.overlays = test.stubs.sm64ex = { };
[ (self: super: { sm64ex = pkgs.writeScriptBin "dummy-sm64ex" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \

View file

@ -44,9 +44,7 @@ with lib;
]; ];
}; };
nixpkgs.overlays = [ test.stubs.starship = { };
(self: super: { starship = pkgs.writeScriptBin "dummy-starship" ""; })
];
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \

View file

@ -8,8 +8,7 @@
}; };
}; };
nixpkgs.overlays = test.stubs.terminator = { };
[ (self: super: { terminator = pkgs.writeScriptBin "dummy" ""; }) ];
nmt.script = '' nmt.script = ''
assertFileContent home-files/.config/terminator/config ${ assertFileContent home-files/.config/terminator/config ${

View file

@ -25,9 +25,7 @@ with lib;
]; ];
}; };
nixpkgs.overlays = [ test.stubs.topgrade = { };
(self: super: { topgrade = pkgs.writeScriptBin "dummy-topgrade" ""; })
];
nmt.script = '' nmt.script = ''
assertFileContent \ assertFileContent \

View file

@ -2,12 +2,10 @@
with lib; with lib;
let {
package = pkgs.writeScriptBin "dummy-waybar" "" // { outPath = "@waybar@"; };
in {
config = { config = {
programs.waybar = { programs.waybar = {
inherit package; package = config.lib.test.mkStubPackage { outPath = "@waybar@"; };
enable = true; enable = true;
settings = [{ settings = [{
layer = "top"; layer = "top";
@ -41,9 +39,7 @@ in {
format = "hello from {}"; format = "hello from {}";
exec = let exec = let
dummyScript = dummyScript =
pkgs.writeShellScriptBin "dummy" "echo within waybar" // { config.lib.test.mkStubPackage { outPath = "@dummy@"; };
outPath = "@dummy@";
};
in "${dummyScript}/bin/dummy"; in "${dummyScript}/bin/dummy";
}; };
}; };

View file

@ -2,12 +2,10 @@
with lib; with lib;
let {
package = pkgs.writeScriptBin "dummy-waybar" "" // { outPath = "@waybar@"; };
in {
config = { config = {
programs.waybar = { programs.waybar = {
inherit package; package = config.lib.test.mkStubPackage { outPath = "@waybar@"; };
enable = true; enable = true;
style = '' style = ''
* { * {

View file

@ -2,12 +2,10 @@
with lib; with lib;
let {
package = pkgs.writeScriptBin "dummy-waybar" "" // { outPath = "@waybar@"; };
in {
config = { config = {
programs.waybar = { programs.waybar = {
inherit package; package = config.lib.test.mkStubPackage { outPath = "@waybar@"; };
enable = true; enable = true;
systemd.enable = true; systemd.enable = true;
}; };

View file

@ -2,12 +2,10 @@
with lib; with lib;
let {
package = pkgs.writeScriptBin "dummy-waybar" "" // { outPath = "@waybar@"; };
in {
config = { config = {
programs.waybar = { programs.waybar = {
inherit package; package = config.lib.test.mkStubPackage { outPath = "@waybar@"; };
enable = true; enable = true;
settings = [{ settings = [{
modules-left = [ "custom/my-module" ]; modules-left = [ "custom/my-module" ];

View file

@ -6,7 +6,7 @@ with lib;
config = { config = {
programs.xmobar = { programs.xmobar = {
enable = true; enable = true;
package = pkgs.writeScriptBin "dummy" ""; package = config.lib.test.mkStubPackage { };
extraConfig = '' extraConfig = ''
Config Config
{ font = "Fira Code" { font = "Fira Code"

View file

@ -21,16 +21,14 @@ with lib;
}; };
}; };
nixpkgs.overlays = [ test.stubs = {
(self: super: { zplug = { };
zsh = pkgs.writeScriptBin "dummy-zsh" ""; zsh = { };
zplug = pkgs.writeScriptBin "dummy-zplug" ""; };
})
];
nmt.script = '' nmt.script = ''
assertFileRegex home-files/.zshrc \ assertFileContains home-files/.zshrc \
'^source ${builtins.storeDir}/.*zplug.*/init\.zsh$' 'source @zplug@/init.zsh'
assertFileContains home-files/.zshrc \ assertFileContains home-files/.zshrc \
'zplug "plugins/git", from:oh-my-zsh' 'zplug "plugins/git", from:oh-my-zsh'

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