From cb09a968e9b4ab12a8f203f454a1fba372a9fd71 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 26 Sep 2021 11:08:45 +0200 Subject: [PATCH] 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. --- tests/default.nix | 14 ++-- .../input-method/fcitx5-configuration.nix | 17 ++-- .../i18n/input-method/fcitx5-overlay.nix | 22 ----- .../i18n/input-method/fcitx5-stubs.nix | 27 +++++++ tests/modules/misc/gtk/gtk2-basic-config.nix | 2 + .../misc/gtk/gtk2-config-file-location.nix | 2 + tests/modules/misc/numlock/numlock.nix | 4 +- .../misc/qt/qt-platform-theme-gnome.nix | 8 +- tests/modules/programs/abook/no-settings.nix | 3 +- .../modules/programs/abook/with-settings.nix | 3 +- .../programs/alacritty/empty-settings.nix | 4 +- .../programs/alacritty/example-settings.nix | 2 +- .../programs/alacritty/settings-merging.nix | 2 +- tests/modules/programs/alot/alot.nix | 3 +- tests/modules/programs/aria2/settings.nix | 3 +- .../programs/autojump/default-settings.nix | 4 + .../autorandr/basic-configuration.nix | 2 + tests/modules/programs/autorandr/scale.nix | 2 + tests/modules/programs/bat/bat.nix | 3 +- .../programs/bottom/empty-settings.nix | 2 +- .../programs/bottom/example-settings.nix | 2 +- tests/modules/programs/broot/broot.nix | 3 +- tests/modules/programs/feh/feh-bindings.nix | 3 +- .../programs/feh/feh-empty-settings.nix | 3 +- tests/modules/programs/fish/functions.nix | 3 +- tests/modules/programs/fish/no-functions.nix | 3 +- tests/modules/programs/fish/plugins.nix | 3 +- .../modules/programs/foot/empty-settings.nix | 3 +- .../programs/foot/example-settings.nix | 2 +- .../programs/foot/systemd-user-service.nix | 6 +- tests/modules/programs/gh/config-file.nix | 3 +- tests/modules/programs/git/git.nix | 12 +-- .../gnome-terminal/gnome-terminal-1.nix | 15 ++-- tests/modules/programs/himalaya/himalaya.nix | 47 +++++------ .../modules/programs/htop/empty-settings.nix | 3 +- .../programs/htop/example-settings.nix | 3 +- .../programs/htop/settings-without-fields.nix | 3 +- .../programs/i3status-rust/with-custom.nix | 6 +- .../programs/i3status-rust/with-default.nix | 6 +- .../i3status-rust/with-extra-settings.nix | 6 +- .../i3status-rust/with-multiple-bars.nix | 6 +- .../modules/programs/i3status/with-custom.nix | 4 +- .../programs/i3status/with-default.nix | 4 +- .../programs/irsii/example-settings.nix | 5 +- .../programs/kitty/example-settings.nix | 3 +- tests/modules/programs/lf/all-options.nix | 3 +- tests/modules/programs/lf/minimal-options.nix | 3 +- tests/modules/programs/lf/no-pv-keybind.nix | 3 +- tests/modules/programs/lieer/lieer.nix | 2 +- .../programs/mangohud/basic-configuration.nix | 2 +- .../programs/mpv/mpv-example-settings.nix | 4 +- .../programs/mpv/mpv-invalid-settings.nix | 2 +- .../ncmpcpp-linux/ncmpcpp-use-mpd-config.nix | 10 +-- .../ncmpcpp/ncmpcpp-empty-settings.nix | 3 +- .../ncmpcpp/ncmpcpp-example-settings.nix | 3 +- tests/modules/programs/ne/defprefs.nix | 3 +- tests/modules/programs/ne/passthroughs.nix | 3 +- .../neomutt/neomutt-no-folder-change.nix | 3 +- .../programs/neomutt/neomutt-not-primary.nix | 3 +- .../neomutt-with-binds-with-warning.nix | 3 +- .../programs/neomutt/neomutt-with-binds.nix | 3 +- .../programs/neomutt/neomutt-with-gpg.nix | 3 +- .../programs/neomutt/neomutt-with-msmtp.nix | 3 +- .../neomutt/neomutt-with-named-mailboxes.nix | 3 +- tests/modules/programs/neomutt/neomutt.nix | 3 +- .../newsboat/newsboat-basics-2003.nix | 4 +- .../newsboat/newsboat-basics-2105.nix | 4 +- .../programs/newsboat/newsboat-basics.nix | 4 +- .../nix-index/assert-on-command-not-found.nix | 12 +-- .../programs/nix-index/integrations.nix | 12 +-- tests/modules/programs/nushell/settings.nix | 3 +- tests/modules/programs/powerline-go/bash.nix | 3 +- tests/modules/programs/powerline-go/fish.nix | 12 +-- tests/modules/programs/powerline-go/zsh.nix | 10 +-- .../programs/qutebrowser/keybindings.nix | 6 +- .../programs/qutebrowser/quickmarks.nix | 6 +- .../modules/programs/qutebrowser/settings.nix | 6 +- tests/modules/programs/rbw/empty-settings.nix | 13 ++- tests/modules/programs/rbw/overlay.nix | 12 --- tests/modules/programs/rbw/rbw-stubs.nix | 16 ++++ tests/modules/programs/rbw/settings.nix | 33 ++++---- .../modules/programs/rbw/simple-settings.nix | 21 +++-- .../programs/rofi-pass/rofi-pass-config.nix | 12 +-- .../programs/rofi-pass/rofi-pass-root.nix | 12 +-- .../rofi/assert-on-both-theme-and-colors.nix | 3 +- tests/modules/programs/rofi/custom-theme.nix | 3 +- tests/modules/programs/rofi/valid-config.nix | 3 +- tests/modules/programs/scmpuff/no-shell.nix | 3 +- tests/modules/programs/scmpuff/no-zsh.nix | 3 +- tests/modules/programs/scmpuff/zsh.nix | 3 +- tests/modules/programs/sm64ex/settings.nix | 3 +- tests/modules/programs/starship/settings.nix | 4 +- .../programs/terminator/config-file.nix | 3 +- tests/modules/programs/topgrade/settings.nix | 4 +- .../programs/waybar/settings-complex.nix | 10 +-- tests/modules/programs/waybar/styling.nix | 6 +- .../systemd-with-graphical-session-target.nix | 6 +- .../programs/waybar/warnings-tests.nix | 6 +- .../programs/xmobar/basic-configuration.nix | 2 +- tests/modules/programs/zplug/modules.nix | 14 ++-- .../programs/zsh/history-ignore-pattern.nix | 3 +- .../programs/zsh/history-path-new-custom.nix | 3 +- .../programs/zsh/history-path-new-default.nix | 3 +- .../programs/zsh/history-path-old-custom.nix | 3 +- .../programs/zsh/history-path-old-default.nix | 3 +- tests/modules/programs/zsh/prezto.nix | 29 +++---- .../programs/zsh/session-variables.nix | 3 +- .../services/barrier/basic-configuration.nix | 3 +- .../services/devilspie2/configuration.nix | 4 +- .../services/dropbox/basic-configuration.nix | 8 +- tests/modules/services/fluidsynth/service.nix | 8 +- .../services/fnott/example-settings.nix | 2 +- .../services/fnott/global-properties.nix | 2 +- .../services/fnott/systemd-user-service.nix | 2 +- tests/modules/services/git-sync/basic.nix | 2 +- .../services/gpg-agent/default-homedir.nix | 3 +- .../services/gpg-agent/override-homedir.nix | 3 +- .../services/kanshi/basic-configuration.nix | 2 +- .../lieer/lieer-service-expected.service | 2 +- .../modules/services/lieer/lieer-service.nix | 8 +- .../pantalaimon/basic-configuration.nix | 4 +- tests/modules/services/pbgopy/service.nix | 8 +- .../services/polybar/basic-configuration.nix | 2 +- .../gammastep-basic-configuration.nix | 8 +- .../redshift-basic-configuration.nix | 8 +- .../modules/services/sxhkd/configuration.nix | 48 ++++++----- tests/modules/services/sxhkd/service.nix | 46 +++++------ .../tray-as-bool-triggers-warning.nix | 6 +- .../services/trayer/basic-configuration.nix | 4 +- .../i3/i3-bar-focused-colors.nix | 32 ++++---- .../i3/i3-fonts-deprecated.nix | 40 +++++----- .../services/window-managers/i3/i3-fonts.nix | 42 +++++----- .../window-managers/i3/i3-keybindings.nix | 36 ++++----- .../window-managers/i3/i3-null-config.nix | 24 +++--- .../window-managers/i3/i3-overlay.nix | 12 --- .../services/window-managers/i3/i3-stubs.nix | 19 +++++ .../i3/i3-workspace-default.nix | 24 +++--- .../i3/i3-workspace-output.nix | 80 +++++++++---------- .../sway/sway-bar-focused-colors.conf | 2 +- .../sway/sway-bar-focused-colors.nix | 44 +++++----- .../sway/sway-bindkeys-to-code.conf | 2 +- .../sway/sway-bindkeys-to-code.nix | 36 ++++----- .../window-managers/sway/sway-default.conf | 2 +- .../window-managers/sway/sway-default.nix | 34 +++----- .../sway/sway-followmouse-legacy.nix | 36 ++++----- .../window-managers/sway/sway-followmouse.nix | 38 ++++----- .../window-managers/sway/sway-modules.conf | 2 +- .../window-managers/sway/sway-modules.nix | 42 ++++------ .../window-managers/sway/sway-null-config.nix | 28 +++---- .../sway/sway-null-package.nix | 50 +++++------- .../window-managers/sway/sway-overlay.nix | 17 ---- .../window-managers/sway/sway-post-2003.nix | 36 ++++----- .../window-managers/sway/sway-stubs.nix | 13 +++ .../sway/sway-workspace-default-expected.conf | 2 +- .../sway/sway-workspace-default.nix | 36 ++++----- .../sway/sway-workspace-output-expected.conf | 2 +- .../sway/sway-workspace-output.nix | 80 +++++++++---------- .../services/wlsunset/wlsunset-service.nix | 4 +- tests/stubs.nix | 61 ++++++++++++++ 159 files changed, 753 insertions(+), 981 deletions(-) delete mode 100644 tests/modules/i18n/input-method/fcitx5-overlay.nix create mode 100644 tests/modules/i18n/input-method/fcitx5-stubs.nix delete mode 100644 tests/modules/programs/rbw/overlay.nix create mode 100644 tests/modules/programs/rbw/rbw-stubs.nix delete mode 100644 tests/modules/services/window-managers/i3/i3-overlay.nix create mode 100644 tests/modules/services/window-managers/i3/i3-stubs.nix delete mode 100644 tests/modules/services/window-managers/sway/sway-overlay.nix create mode 100644 tests/modules/services/window-managers/sway/sway-stubs.nix create mode 100644 tests/stubs.nix diff --git a/tests/default.nix b/tests/default.nix index a773fd50b..a6daa4c04 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -26,10 +26,13 @@ let # unnecessary rebuilds of the tests. manual.manpages.enable = false; - imports = [ ./asserts.nix ]; + imports = [ ./asserts.nix ./stubs.nix ]; } ]; + isDarwin = pkgs.stdenv.hostPlatform.isDarwin; + isLinux = pkgs.stdenv.hostPlatform.isLinux; + in import nmt { @@ -89,12 +92,11 @@ import nmt { ./modules/programs/zplug ./modules/programs/zsh ./modules/xresources - ] ++ lib.optionals pkgs.stdenv.hostPlatform.isDarwin [ + ] ++ lib.optionals isDarwin [ ./modules/targets-darwin - ] ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [ + ] ++ lib.optionals isLinux [ ./modules/config/i18n ./modules/i18n/input-method - ./modules/misc/debug ./modules/misc/gtk ./modules/misc/numlock ./modules/misc/pam @@ -103,7 +105,6 @@ import nmt { ./modules/misc/xsession ./modules/programs/abook ./modules/programs/autorandr - ./modules/programs/firefox ./modules/programs/foot ./modules/programs/getmail ./modules/programs/gnome-terminal @@ -142,5 +143,8 @@ import nmt { ./modules/targets-linux ] ++ lib.optionals enableBig [ ./modules/programs/emacs + ] ++ lib.optionals (enableBig && isLinux) [ + ./modules/misc/debug + ./modules/programs/firefox ]); } diff --git a/tests/modules/i18n/input-method/fcitx5-configuration.nix b/tests/modules/i18n/input-method/fcitx5-configuration.nix index b29a94aa5..59738fb01 100644 --- a/tests/modules/i18n/input-method/fcitx5-configuration.nix +++ b/tests/modules/i18n/input-method/fcitx5-configuration.nix @@ -1,15 +1,14 @@ { config, pkgs, ... }: { - config = { - nixpkgs.overlays = [ (import ./fcitx5-overlay.nix) ]; - i18n.inputMethod = { - enabled = "fcitx5"; - fcitx5.addons = with pkgs; [ fcitx5-chinese-addons ]; - }; + imports = [ ./fcitx5-stubs.nix ]; - nmt.script = '' - assertFileExists home-files/.config/systemd/user/fcitx5-daemon.service - ''; + i18n.inputMethod = { + enabled = "fcitx5"; + fcitx5.addons = with pkgs; [ fcitx5-chinese-addons ]; }; + + nmt.script = '' + assertFileExists home-files/.config/systemd/user/fcitx5-daemon.service + ''; } diff --git a/tests/modules/i18n/input-method/fcitx5-overlay.nix b/tests/modules/i18n/input-method/fcitx5-overlay.nix deleted file mode 100644 index 4007552cb..000000000 --- a/tests/modules/i18n/input-method/fcitx5-overlay.nix +++ /dev/null @@ -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; -} diff --git a/tests/modules/i18n/input-method/fcitx5-stubs.nix b/tests/modules/i18n/input-method/fcitx5-stubs.nix new file mode 100644 index 000000000..cdf707de6 --- /dev/null +++ b/tests/modules/i18n/input-method/fcitx5-stubs.nix @@ -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; }; + }) + ]; +} diff --git a/tests/modules/misc/gtk/gtk2-basic-config.nix b/tests/modules/misc/gtk/gtk2-basic-config.nix index 4ac7299a2..a49cc44e7 100644 --- a/tests/modules/misc/gtk/gtk2-basic-config.nix +++ b/tests/modules/misc/gtk/gtk2-basic-config.nix @@ -9,6 +9,8 @@ with lib; gtk2.extraConfig = "gtk-can-change-accels = 1"; }; + test.stubs.dconf = { }; + nmt.script = '' assertFileExists home-files/.gtkrc-2.0 assertFileContent home-files/.gtkrc-2.0 ${ diff --git a/tests/modules/misc/gtk/gtk2-config-file-location.nix b/tests/modules/misc/gtk/gtk2-config-file-location.nix index 41de2877f..a08998384 100644 --- a/tests/modules/misc/gtk/gtk2-config-file-location.nix +++ b/tests/modules/misc/gtk/gtk2-config-file-location.nix @@ -7,6 +7,8 @@ with lib; gtk.enable = true; gtk.gtk2.configLocation = "${config.xdg.configHome}/gtk-2.0/gtkrc"; + test.stubs.dconf = { }; + nmt.script = '' assertFileExists home-files/.config/gtk-2.0/gtkrc assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \ diff --git a/tests/modules/misc/numlock/numlock.nix b/tests/modules/misc/numlock/numlock.nix index aa468c212..5616de1c5 100644 --- a/tests/modules/misc/numlock/numlock.nix +++ b/tests/modules/misc/numlock/numlock.nix @@ -6,9 +6,7 @@ with lib; config = { xsession.numlock.enable = true; - nixpkgs.overlays = [ - (self: super: { numlockx = pkgs.writeScriptBin "dummy-numlockx" ""; }) - ]; + test.stubs.numlockx = { }; nmt.script = '' serviceFile=home-files/.config/systemd/user/numlockx.service diff --git a/tests/modules/misc/qt/qt-platform-theme-gnome.nix b/tests/modules/misc/qt/qt-platform-theme-gnome.nix index e9aa1a250..80baeae6f 100644 --- a/tests/modules/misc/qt/qt-platform-theme-gnome.nix +++ b/tests/modules/misc/qt/qt-platform-theme-gnome.nix @@ -7,15 +7,11 @@ platformTheme = "gnome"; style = { name = "adwaita"; - package = pkgs.dummyTheme; + package = config.lib.test.mkStubPackage { }; }; }; - nixpkgs.overlays = [ - (self: super: { - dummyTheme = pkgs.runCommandLocal "theme" { } "mkdir $out"; - }) - ]; + test.stubs.qgnomeplatform = { }; nmt.script = '' assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \ diff --git a/tests/modules/programs/abook/no-settings.nix b/tests/modules/programs/abook/no-settings.nix index ad04acd23..f8b096fb1 100644 --- a/tests/modules/programs/abook/no-settings.nix +++ b/tests/modules/programs/abook/no-settings.nix @@ -6,8 +6,7 @@ with lib; config = { programs.abook.enable = true; - nixpkgs.overlays = - [ (self: super: { abook = pkgs.writeScriptBin "dummy-abook" ""; }) ]; + test.stubs.abook = { }; nmt.script = '' assertPathNotExists home-files/.config/abook/abookrc diff --git a/tests/modules/programs/abook/with-settings.nix b/tests/modules/programs/abook/with-settings.nix index 3cb02a266..e89ad7dad 100644 --- a/tests/modules/programs/abook/with-settings.nix +++ b/tests/modules/programs/abook/with-settings.nix @@ -28,8 +28,7 @@ with lib; ''; }; - nixpkgs.overlays = - [ (self: super: { abook = pkgs.writeScriptBin "dummy-abook" ""; }) ]; + test.stubs.abook = { }; nmt.script = '' assertFileExists home-files/.config/abook/abookrc diff --git a/tests/modules/programs/alacritty/empty-settings.nix b/tests/modules/programs/alacritty/empty-settings.nix index 65470473c..ecc6df35a 100644 --- a/tests/modules/programs/alacritty/empty-settings.nix +++ b/tests/modules/programs/alacritty/empty-settings.nix @@ -6,9 +6,7 @@ with lib; config = { programs.alacritty.enable = true; - nixpkgs.overlays = [ - (self: super: { alacritty = pkgs.writeScriptBin "dummy-alacritty" ""; }) - ]; + test.stubs.alacritty = { }; nmt.script = '' assertPathNotExists home-files/.config/alacritty diff --git a/tests/modules/programs/alacritty/example-settings.nix b/tests/modules/programs/alacritty/example-settings.nix index c3671aa0c..61b8b4b4e 100644 --- a/tests/modules/programs/alacritty/example-settings.nix +++ b/tests/modules/programs/alacritty/example-settings.nix @@ -6,7 +6,7 @@ with lib; config = { programs.alacritty = { enable = true; - package = pkgs.writeScriptBin "dummy-alacritty" ""; + package = config.lib.test.mkStubPackage { }; settings = { window.dimensions = { diff --git a/tests/modules/programs/alacritty/settings-merging.nix b/tests/modules/programs/alacritty/settings-merging.nix index 1b8559d69..c7962fb52 100644 --- a/tests/modules/programs/alacritty/settings-merging.nix +++ b/tests/modules/programs/alacritty/settings-merging.nix @@ -6,7 +6,7 @@ with lib; config = { programs.alacritty = { enable = true; - package = pkgs.writeScriptBin "dummy-alacritty" ""; + package = config.lib.test.mkStubPackage { }; settings = { window.dimensions = { diff --git a/tests/modules/programs/alot/alot.nix b/tests/modules/programs/alot/alot.nix index 3f74ef21c..6316fbd76 100644 --- a/tests/modules/programs/alot/alot.nix +++ b/tests/modules/programs/alot/alot.nix @@ -23,8 +23,7 @@ with lib; programs.alot = { enable = true; }; - nixpkgs.overlays = - [ (self: super: { alot = pkgs.writeScriptBin "dummy-alot" ""; }) ]; + test.stubs.alot = { }; nmt.script = '' assertFileExists home-files/.config/alot/config diff --git a/tests/modules/programs/aria2/settings.nix b/tests/modules/programs/aria2/settings.nix index 0b5a52d90..346de9679 100644 --- a/tests/modules/programs/aria2/settings.nix +++ b/tests/modules/programs/aria2/settings.nix @@ -20,8 +20,7 @@ with lib; ''; }; - nixpkgs.overlays = - [ (self: super: { aria2 = pkgs.writeScriptBin "dummy-aria2" ""; }) ]; + test.stubs.aria2 = { }; nmt.script = '' assertFileContent \ diff --git a/tests/modules/programs/autojump/default-settings.nix b/tests/modules/programs/autojump/default-settings.nix index 2f6670272..2cca7de88 100644 --- a/tests/modules/programs/autojump/default-settings.nix +++ b/tests/modules/programs/autojump/default-settings.nix @@ -6,6 +6,10 @@ with lib; config = { programs.autojump.enable = true; + test.stubs.autojump = { + buildScript = "mkdir -p $out/bin; touch $out/bin/autojump"; + }; + nmt.script = '' assertFileExists home-path/bin/autojump ''; diff --git a/tests/modules/programs/autorandr/basic-configuration.nix b/tests/modules/programs/autorandr/basic-configuration.nix index fad18f754..c28edaa2a 100644 --- a/tests/modules/programs/autorandr/basic-configuration.nix +++ b/tests/modules/programs/autorandr/basic-configuration.nix @@ -28,6 +28,8 @@ }; }; + test.stubs.autorandr = { }; + nmt.script = '' config=home-files/.config/autorandr/default/config setup=home-files/.config/autorandr/default/setup diff --git a/tests/modules/programs/autorandr/scale.nix b/tests/modules/programs/autorandr/scale.nix index 9092e61dc..095778a43 100644 --- a/tests/modules/programs/autorandr/scale.nix +++ b/tests/modules/programs/autorandr/scale.nix @@ -17,6 +17,8 @@ }; }; + test.stubs.autorandr = { }; + nmt.script = '' config=home-files/.config/autorandr/default/config diff --git a/tests/modules/programs/bat/bat.nix b/tests/modules/programs/bat/bat.nix index 2860d1e6e..e98612922 100644 --- a/tests/modules/programs/bat/bat.nix +++ b/tests/modules/programs/bat/bat.nix @@ -18,8 +18,7 @@ with lib; ''; }; - nixpkgs.overlays = - [ (self: super: { bat = pkgs.writeScriptBin "dummy" ""; }) ]; + test.stubs.bat = { }; nmt.script = '' assertFileExists home-files/.config/bat/config diff --git a/tests/modules/programs/bottom/empty-settings.nix b/tests/modules/programs/bottom/empty-settings.nix index bedcf2126..71799c831 100644 --- a/tests/modules/programs/bottom/empty-settings.nix +++ b/tests/modules/programs/bottom/empty-settings.nix @@ -6,7 +6,7 @@ with lib; config = { programs.bottom = { enable = true; - package = pkgs.writeScriptBin "dummy" ""; + package = config.lib.test.mkStubPackage { }; }; nmt.script = '' diff --git a/tests/modules/programs/bottom/example-settings.nix b/tests/modules/programs/bottom/example-settings.nix index 3635bd199..30d8e21bf 100644 --- a/tests/modules/programs/bottom/example-settings.nix +++ b/tests/modules/programs/bottom/example-settings.nix @@ -6,7 +6,7 @@ with lib; config = { programs.bottom = { enable = true; - package = pkgs.writeShellScriptBin "dummy" ""; + package = config.lib.test.mkStubPackage { }; settings = { flags = { diff --git a/tests/modules/programs/broot/broot.nix b/tests/modules/programs/broot/broot.nix index 88b13974b..a2dddca38 100644 --- a/tests/modules/programs/broot/broot.nix +++ b/tests/modules/programs/broot/broot.nix @@ -9,8 +9,7 @@ with lib; modal = true; }; - nixpkgs.overlays = - [ (self: super: { broot = pkgs.writeScriptBin "dummy" ""; }) ]; + test.stubs.broot = { }; nmt.script = '' assertFileExists home-files/.config/broot/conf.toml diff --git a/tests/modules/programs/feh/feh-bindings.nix b/tests/modules/programs/feh/feh-bindings.nix index f6b9e5b6e..787b02d7c 100644 --- a/tests/modules/programs/feh/feh-bindings.nix +++ b/tests/modules/programs/feh/feh-bindings.nix @@ -17,8 +17,7 @@ prev_img = [ "h" "Left" ]; }; - nixpkgs.overlays = - [ (self: super: { feh = pkgs.writeScriptBin "dummy-feh" ""; }) ]; + test.stubs.feh = { }; nmt.script = '' assertFileContent \ diff --git a/tests/modules/programs/feh/feh-empty-settings.nix b/tests/modules/programs/feh/feh-empty-settings.nix index ad0d15153..62feb8230 100644 --- a/tests/modules/programs/feh/feh-empty-settings.nix +++ b/tests/modules/programs/feh/feh-empty-settings.nix @@ -4,8 +4,7 @@ config = { programs.feh.enable = true; - nixpkgs.overlays = - [ (self: super: { feh = pkgs.writeScriptBin "dummy-feh" ""; }) ]; + test.stubs.feh = { }; nmt.script = '' assertPathNotExists home-files/.config/feh/buttons diff --git a/tests/modules/programs/fish/functions.nix b/tests/modules/programs/fish/functions.nix index 9bca418e7..67f8ba0d5 100644 --- a/tests/modules/programs/fish/functions.nix +++ b/tests/modules/programs/fish/functions.nix @@ -34,8 +34,7 @@ in { xdg.dataFile."fish/home-manager_generated_completions".source = lib.mkForce (builtins.toFile "empty" ""); - nixpkgs.overlays = - [ (self: super: { fish = pkgs.writeScriptBin "dummy" ""; }) ]; + test.stubs.fish = { }; nmt = { description = diff --git a/tests/modules/programs/fish/no-functions.nix b/tests/modules/programs/fish/no-functions.nix index 7cd2966e7..0ab38a09e 100644 --- a/tests/modules/programs/fish/no-functions.nix +++ b/tests/modules/programs/fish/no-functions.nix @@ -14,8 +14,7 @@ with lib; xdg.dataFile."fish/home-manager_generated_completions".source = lib.mkForce (builtins.toFile "empty" ""); - nixpkgs.overlays = - [ (self: super: { fish = pkgs.writeScriptBin "dummy" ""; }) ]; + test.stubs.fish = { }; nmt = { description = diff --git a/tests/modules/programs/fish/plugins.nix b/tests/modules/programs/fish/plugins.nix index 61e1603f0..6b02dd46f 100644 --- a/tests/modules/programs/fish/plugins.nix +++ b/tests/modules/programs/fish/plugins.nix @@ -50,8 +50,7 @@ in { xdg.dataFile."fish/home-manager_generated_completions".source = lib.mkForce (builtins.toFile "empty" ""); - nixpkgs.overlays = - [ (self: super: { fish = pkgs.writeScriptBin "dummy" ""; }) ]; + test.stubs.fish = { }; nmt = { description = diff --git a/tests/modules/programs/foot/empty-settings.nix b/tests/modules/programs/foot/empty-settings.nix index 3935fd9dc..26b82e7fb 100644 --- a/tests/modules/programs/foot/empty-settings.nix +++ b/tests/modules/programs/foot/empty-settings.nix @@ -6,8 +6,7 @@ with lib; config = { programs.foot.enable = true; - nixpkgs.overlays = - [ (self: super: { foot = pkgs.writeScriptBin "dummy-foot" ""; }) ]; + test.stubs.foot = { }; nmt.script = '' assertPathNotExists home-files/.config/foot diff --git a/tests/modules/programs/foot/example-settings.nix b/tests/modules/programs/foot/example-settings.nix index c23063823..8390305ea 100644 --- a/tests/modules/programs/foot/example-settings.nix +++ b/tests/modules/programs/foot/example-settings.nix @@ -6,7 +6,7 @@ with lib; config = { programs.foot = { enable = true; - package = pkgs.writeShellScriptBin "dummy-foot" ""; + package = config.lib.test.mkStubPackage { }; settings = { main = { diff --git a/tests/modules/programs/foot/systemd-user-service.nix b/tests/modules/programs/foot/systemd-user-service.nix index 1eff14f9f..5ebd90675 100644 --- a/tests/modules/programs/foot/systemd-user-service.nix +++ b/tests/modules/programs/foot/systemd-user-service.nix @@ -1,11 +1,9 @@ { config, lib, pkgs, ... }: -let - package = pkgs.writeShellScriptBin "dummy-foot" "" // { outPath = "@foot@"; }; -in { +{ config = { programs.foot = { - inherit package; + package = config.lib.test.mkStubPackage { outPath = "@foot@"; }; enable = true; server.enable = true; }; diff --git a/tests/modules/programs/gh/config-file.nix b/tests/modules/programs/gh/config-file.nix index 71fd74d32..432437f93 100644 --- a/tests/modules/programs/gh/config-file.nix +++ b/tests/modules/programs/gh/config-file.nix @@ -8,8 +8,7 @@ editor = "vim"; }; - nixpkgs.overlays = - [ (self: super: { gh = pkgs.writeScriptBin "dummy-gh" ""; }) ]; + test.stubs.gh = { }; nmt.script = '' assertFileExists home-files/.config/gh/config.yml diff --git a/tests/modules/programs/git/git.nix b/tests/modules/programs/git/git.nix index 5417f7ea0..6c7320604 100644 --- a/tests/modules/programs/git/git.nix +++ b/tests/modules/programs/git/git.nix @@ -79,14 +79,10 @@ in { } ]; - nixpkgs.overlays = [ - (self: super: { - git-lfs = pkgs.writeScriptBin "dummy-git-lfs" ""; - delta = pkgs.writeScriptBin "dummy-delta" "" // { - outPath = "@delta@"; - }; - }) - ]; + test.stubs = { + git-lfs = { }; + delta = { }; + }; nmt.script = '' assertFileExists home-files/.config/git/config diff --git a/tests/modules/programs/gnome-terminal/gnome-terminal-1.nix b/tests/modules/programs/gnome-terminal/gnome-terminal-1.nix index 44d95cb3b..bb58983fe 100644 --- a/tests/modules/programs/gnome-terminal/gnome-terminal-1.nix +++ b/tests/modules/programs/gnome-terminal/gnome-terminal-1.nix @@ -4,13 +4,6 @@ with lib; { config = { - nixpkgs.overlays = [ - (self: super: { - gnome.gnome-terminal = - pkgs.writeScriptBin "dummy-gnome3-gnome-terminal" ""; - }) - ]; - programs.gnome-terminal = { enable = true; profile = { @@ -55,6 +48,14 @@ with lib; showMenubar = false; }; + nixpkgs.overlays = [ + (self: super: { + gnome.gnome-terminal = config.lib.test.mkStubPackage { }; + }) + ]; + + test.stubs.dconf = { }; + nmt.script = '' dconfIni=$(grep -oPm 1 '/nix/store/[a-z0-9]*?-hm-dconf.ini' $TESTED/activate) assertFileContent $dconfIni ${./gnome-terminal-1.conf} diff --git a/tests/modules/programs/himalaya/himalaya.nix b/tests/modules/programs/himalaya/himalaya.nix index ce5385d14..827a09bef 100644 --- a/tests/modules/programs/himalaya/himalaya.nix +++ b/tests/modules/programs/himalaya/himalaya.nix @@ -5,34 +5,31 @@ with lib; { imports = [ ../../accounts/email-test-accounts.nix ]; - config = { - accounts.email.accounts = { - "hm@example.com" = { - himalaya = { - enable = true; + accounts.email.accounts = { + "hm@example.com" = { + himalaya = { + enable = true; - settings = { default-page-size = 50; }; - }; - - imap.port = 995; - smtp.port = 465; + settings = { default-page-size = 50; }; }; + + 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 + } + ''; } diff --git a/tests/modules/programs/htop/empty-settings.nix b/tests/modules/programs/htop/empty-settings.nix index ae4e437fd..b8e43600f 100644 --- a/tests/modules/programs/htop/empty-settings.nix +++ b/tests/modules/programs/htop/empty-settings.nix @@ -6,8 +6,7 @@ with lib; config = { programs.htop.enable = true; - nixpkgs.overlays = - [ (self: super: { htop = pkgs.writeScriptBin "dummy" ""; }) ]; + test.stubs.htop = { }; nmt.script = '' assertPathNotExists home-files/.config/htop diff --git a/tests/modules/programs/htop/example-settings.nix b/tests/modules/programs/htop/example-settings.nix index 412b8c7d8..71685434a 100644 --- a/tests/modules/programs/htop/example-settings.nix +++ b/tests/modules/programs/htop/example-settings.nix @@ -36,8 +36,7 @@ with lib; (text "Systemd") ]); - nixpkgs.overlays = - [ (self: super: { htop = pkgs.writeScriptBin "dummy" ""; }) ]; + test.stubs.htop = { }; nmt.script = '' htoprc=home-files/.config/htop/htoprc diff --git a/tests/modules/programs/htop/settings-without-fields.nix b/tests/modules/programs/htop/settings-without-fields.nix index 7a6ebe8dc..2f4b3e864 100644 --- a/tests/modules/programs/htop/settings-without-fields.nix +++ b/tests/modules/programs/htop/settings-without-fields.nix @@ -7,8 +7,7 @@ with lib; programs.htop.enable = true; programs.htop.settings = { color_scheme = 6; }; - nixpkgs.overlays = - [ (self: super: { htop = pkgs.writeScriptBin "dummy" ""; }) ]; + test.stubs.htop = { }; # Test that the 'fields' key is written in addition to the customized # settings or htop won't read the options. diff --git a/tests/modules/programs/i3status-rust/with-custom.nix b/tests/modules/programs/i3status-rust/with-custom.nix index 4ced6add5..b53963ddb 100644 --- a/tests/modules/programs/i3status-rust/with-custom.nix +++ b/tests/modules/programs/i3status-rust/with-custom.nix @@ -92,11 +92,7 @@ with lib; }; }; - nixpkgs.overlays = [ - (self: super: { - i3status-rust = pkgs.writeScriptBin "dummy-i3status-rust" ""; - }) - ]; + test.stubs.i3status-rust = { }; nmt.script = '' assertFileExists home-files/.config/i3status-rust/config-custom.toml diff --git a/tests/modules/programs/i3status-rust/with-default.nix b/tests/modules/programs/i3status-rust/with-default.nix index b62c248c8..4a0d4a4c4 100644 --- a/tests/modules/programs/i3status-rust/with-default.nix +++ b/tests/modules/programs/i3status-rust/with-default.nix @@ -6,11 +6,7 @@ with lib; config = { programs.i3status-rust = { enable = true; }; - nixpkgs.overlays = [ - (self: super: { - i3status-rust = pkgs.writeScriptBin "dummy-i3status-rust" ""; - }) - ]; + test.stubs.i3status-rust = { }; nmt.script = '' assertFileExists home-files/.config/i3status-rust/config-default.toml diff --git a/tests/modules/programs/i3status-rust/with-extra-settings.nix b/tests/modules/programs/i3status-rust/with-extra-settings.nix index 16f3428a0..4a0442732 100644 --- a/tests/modules/programs/i3status-rust/with-extra-settings.nix +++ b/tests/modules/programs/i3status-rust/with-extra-settings.nix @@ -102,11 +102,7 @@ with lib; }; }; - nixpkgs.overlays = [ - (self: super: { - i3status-rust = pkgs.writeScriptBin "dummy-i3status-rust" ""; - }) - ]; + test.stubs.i3status-rust = { }; nmt.script = '' assertFileExists home-files/.config/i3status-rust/config-extra-settings.toml diff --git a/tests/modules/programs/i3status-rust/with-multiple-bars.nix b/tests/modules/programs/i3status-rust/with-multiple-bars.nix index 9cbbe2854..eab7f42d4 100644 --- a/tests/modules/programs/i3status-rust/with-multiple-bars.nix +++ b/tests/modules/programs/i3status-rust/with-multiple-bars.nix @@ -52,11 +52,7 @@ with lib; }; - nixpkgs.overlays = [ - (self: super: { - i3status-rust = pkgs.writeScriptBin "dummy-i3status-rust" ""; - }) - ]; + test.stubs.i3status-rust = { }; nmt.script = '' assertFileExists home-files/.config/i3status-rust/config-top.toml diff --git a/tests/modules/programs/i3status/with-custom.nix b/tests/modules/programs/i3status/with-custom.nix index 4aa01773e..830bc6c98 100644 --- a/tests/modules/programs/i3status/with-custom.nix +++ b/tests/modules/programs/i3status/with-custom.nix @@ -32,9 +32,7 @@ with lib; }; }; - nixpkgs.overlays = [ - (self: super: { i3status = pkgs.writeScriptBin "dummy-i3status" ""; }) - ]; + test.stubs.i3status = { }; nmt.script = '' assertFileContent \ diff --git a/tests/modules/programs/i3status/with-default.nix b/tests/modules/programs/i3status/with-default.nix index 0b7e4ee2f..d56ecc205 100644 --- a/tests/modules/programs/i3status/with-default.nix +++ b/tests/modules/programs/i3status/with-default.nix @@ -9,9 +9,7 @@ with lib; enableDefault = true; }; - nixpkgs.overlays = [ - (self: super: { i3status = pkgs.writeScriptBin "dummy-i3status" ""; }) - ]; + test.stubs.i3status = { }; nmt.script = '' assertFileContent \ diff --git a/tests/modules/programs/irsii/example-settings.nix b/tests/modules/programs/irsii/example-settings.nix index d7b9ff1e6..0eced1688 100644 --- a/tests/modules/programs/irsii/example-settings.nix +++ b/tests/modules/programs/irsii/example-settings.nix @@ -19,13 +19,12 @@ with lib; }; }; + test.stubs.irsii = { }; + nmt.script = '' assertFileContent \ home-files/.irssi/config \ ${./example-settings-expected.config} ''; - - nixpkgs.overlays = - [ (self: super: { irsii = pkgs.writeScriptBin "dummy-irsii" ""; }) ]; }; } diff --git a/tests/modules/programs/kitty/example-settings.nix b/tests/modules/programs/kitty/example-settings.nix index 1f3b82b98..8d609a5ab 100644 --- a/tests/modules/programs/kitty/example-settings.nix +++ b/tests/modules/programs/kitty/example-settings.nix @@ -30,8 +30,7 @@ with lib; environment = { LS_COLORS = "1"; }; }; - nixpkgs.overlays = - [ (self: super: { kitty = pkgs.writeScriptBin "dummy-kitty" ""; }) ]; + test.stubs.kitty = { }; nmt.script = '' assertFileExists home-files/.config/kitty/kitty.conf diff --git a/tests/modules/programs/lf/all-options.nix b/tests/modules/programs/lf/all-options.nix index a25467a26..35d7901d6 100644 --- a/tests/modules/programs/lf/all-options.nix +++ b/tests/modules/programs/lf/all-options.nix @@ -75,8 +75,7 @@ in { }; }; - nixpkgs.overlays = - [ (self: super: { lf = pkgs.writeScriptBin "dummy-lf" ""; }) ]; + test.stubs.lf = { }; nmt.script = '' assertFileExists home-files/.config/lf/lfrc diff --git a/tests/modules/programs/lf/minimal-options.nix b/tests/modules/programs/lf/minimal-options.nix index b3c26ba9b..078c776e7 100644 --- a/tests/modules/programs/lf/minimal-options.nix +++ b/tests/modules/programs/lf/minimal-options.nix @@ -7,8 +7,7 @@ in { config = { programs.lf = { enable = true; }; - nixpkgs.overlays = - [ (self: super: { lf = pkgs.writeScriptBin "dummy-lf" ""; }) ]; + test.stubs.lf = { }; nmt.script = '' assertFileExists home-files/.config/lf/lfrc diff --git a/tests/modules/programs/lf/no-pv-keybind.nix b/tests/modules/programs/lf/no-pv-keybind.nix index 524a41a36..c948cf0b5 100644 --- a/tests/modules/programs/lf/no-pv-keybind.nix +++ b/tests/modules/programs/lf/no-pv-keybind.nix @@ -32,8 +32,7 @@ in { previewer = { source = pvScript; }; }; - nixpkgs.overlays = - [ (self: super: { lf = pkgs.writeScriptBin "dummy-lf" ""; }) ]; + test.stubs.lf = { }; nmt.script = '' assertFileExists home-files/.config/lf/lfrc diff --git a/tests/modules/programs/lieer/lieer.nix b/tests/modules/programs/lieer/lieer.nix index c19521d11..5e7847464 100644 --- a/tests/modules/programs/lieer/lieer.nix +++ b/tests/modules/programs/lieer/lieer.nix @@ -7,7 +7,7 @@ with lib; config = { programs.lieer.enable = true; - programs.lieer.package = pkgs.writeScriptBin "dummy-gmailieer" ""; + programs.lieer.package = config.lib.test.mkStubPackage { }; accounts.email.accounts."hm@example.com" = { flavor = "gmail.com"; diff --git a/tests/modules/programs/mangohud/basic-configuration.nix b/tests/modules/programs/mangohud/basic-configuration.nix index 7ff4a8901..6af57d281 100644 --- a/tests/modules/programs/mangohud/basic-configuration.nix +++ b/tests/modules/programs/mangohud/basic-configuration.nix @@ -4,7 +4,7 @@ config = { programs.mangohud = { enable = true; - package = pkgs.writeScriptBin "dummy-mangohud" ""; + package = config.lib.test.mkStubPackage { }; settings = { output_folder = /home/user/Documents/mangohud; fps_limit = [ 30 60 ]; diff --git a/tests/modules/programs/mpv/mpv-example-settings.nix b/tests/modules/programs/mpv/mpv-example-settings.nix index 5701d9eab..9bb53e57d 100644 --- a/tests/modules/programs/mpv/mpv-example-settings.nix +++ b/tests/modules/programs/mpv/mpv-example-settings.nix @@ -29,9 +29,7 @@ defaultProfiles = [ "gpu-hq" ]; }; - nixpkgs.overlays = [ - (self: super: { mpvDummy = pkgs.runCommandLocal "mpv" { } "mkdir $out"; }) - ]; + test.stubs.mpvDummy = { }; nmt.script = '' assertFileContent \ diff --git a/tests/modules/programs/mpv/mpv-invalid-settings.nix b/tests/modules/programs/mpv/mpv-invalid-settings.nix index f7fd390a9..1c4a80c11 100644 --- a/tests/modules/programs/mpv/mpv-invalid-settings.nix +++ b/tests/modules/programs/mpv/mpv-invalid-settings.nix @@ -22,7 +22,7 @@ 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 ''; - mpvDummy = pkgs.runCommandLocal "mpv" { } "mkdir $out"; + mpvDummy = config.lib.test.mkStubPackage { }; mpvScript = pkgs.runCommandLocal "mpvScript" { scriptName = "something"; } "mkdir $out"; diff --git a/tests/modules/programs/ncmpcpp-linux/ncmpcpp-use-mpd-config.nix b/tests/modules/programs/ncmpcpp-linux/ncmpcpp-use-mpd-config.nix index 5262f0314..f977bddec 100644 --- a/tests/modules/programs/ncmpcpp-linux/ncmpcpp-use-mpd-config.nix +++ b/tests/modules/programs/ncmpcpp-linux/ncmpcpp-use-mpd-config.nix @@ -7,12 +7,10 @@ services.mpd.enable = true; services.mpd.musicDirectory = "/home/user/music"; - nixpkgs.overlays = [ - (self: super: { - ncmpcpp = pkgs.writeScriptBin "dummy-ncmpcpp" ""; - mpd = pkgs.writeScriptBin "dummy-mpd" ""; - }) - ]; + test.stubs = { + ncmpcpp = { }; + mpd = { }; + }; nmt.script = '' assertFileContent \ diff --git a/tests/modules/programs/ncmpcpp/ncmpcpp-empty-settings.nix b/tests/modules/programs/ncmpcpp/ncmpcpp-empty-settings.nix index e5134002d..554366509 100644 --- a/tests/modules/programs/ncmpcpp/ncmpcpp-empty-settings.nix +++ b/tests/modules/programs/ncmpcpp/ncmpcpp-empty-settings.nix @@ -4,8 +4,7 @@ config = { programs.ncmpcpp.enable = true; - nixpkgs.overlays = - [ (self: super: { ncmpcpp = pkgs.writeScriptBin "dummy-ncmpcpp" ""; }) ]; + test.stubs.ncmpcpp = { }; nmt.script = '' assertPathNotExists home-files/.config/ncmpcpp/config diff --git a/tests/modules/programs/ncmpcpp/ncmpcpp-example-settings.nix b/tests/modules/programs/ncmpcpp/ncmpcpp-example-settings.nix index 02a1f09c9..a85ea552c 100644 --- a/tests/modules/programs/ncmpcpp/ncmpcpp-example-settings.nix +++ b/tests/modules/programs/ncmpcpp/ncmpcpp-example-settings.nix @@ -44,8 +44,7 @@ ]; }; - nixpkgs.overlays = - [ (self: super: { ncmpcpp = pkgs.writeScriptBin "dummy-ncmpcpp" ""; }) ]; + test.stubs.ncmpcpp = { }; nmt.script = '' assertFileContent \ diff --git a/tests/modules/programs/ne/defprefs.nix b/tests/modules/programs/ne/defprefs.nix index dce98b286..64d78d276 100644 --- a/tests/modules/programs/ne/defprefs.nix +++ b/tests/modules/programs/ne/defprefs.nix @@ -19,8 +19,7 @@ in { automaticPreferences.".default" = autopref; }; - nixpkgs.overlays = - [ (self: super: { ne = pkgs.writeScriptBin "dummy-ne" ""; }) ]; + test.stubs.ne = { }; nmt = { description = diff --git a/tests/modules/programs/ne/passthroughs.nix b/tests/modules/programs/ne/passthroughs.nix index 4c129e944..f753826f3 100644 --- a/tests/modules/programs/ne/passthroughs.nix +++ b/tests/modules/programs/ne/passthroughs.nix @@ -53,8 +53,7 @@ in { inherit automaticPreferences; }; - nixpkgs.overlays = - [ (self: super: { ne = pkgs.writeScriptBin "dummy-ne" ""; }) ]; + test.stubs.ne = { }; nmt = { description = "Check that configuration files are correctly written"; diff --git a/tests/modules/programs/neomutt/neomutt-no-folder-change.nix b/tests/modules/programs/neomutt/neomutt-no-folder-change.nix index db7246604..0e874c228 100644 --- a/tests/modules/programs/neomutt/neomutt-no-folder-change.nix +++ b/tests/modules/programs/neomutt/neomutt-no-folder-change.nix @@ -17,8 +17,7 @@ with lib; programs.neomutt.enable = true; programs.neomutt.changeFolderWhenSourcingAccount = false; - nixpkgs.overlays = - [ (self: super: { neomutt = pkgs.writeScriptBin "dummy-neomutt" ""; }) ]; + test.stubs.neomutt = { }; nmt.script = '' assertFileExists home-files/.config/neomutt/hm@example.com diff --git a/tests/modules/programs/neomutt/neomutt-not-primary.nix b/tests/modules/programs/neomutt/neomutt-not-primary.nix index 10e9791de..ccf5444a9 100644 --- a/tests/modules/programs/neomutt/neomutt-not-primary.nix +++ b/tests/modules/programs/neomutt/neomutt-not-primary.nix @@ -13,8 +13,7 @@ with lib; programs.neomutt.enable = true; - nixpkgs.overlays = - [ (self: super: { neomutt = pkgs.writeScriptBin "dummy-neomutt" ""; }) ]; + test.stubs.neomutt = { }; nmt.script = '' assertFileExists home-files/.config/neomutt/neomuttrc diff --git a/tests/modules/programs/neomutt/neomutt-with-binds-with-warning.nix b/tests/modules/programs/neomutt/neomutt-with-binds-with-warning.nix index 529d28475..54012e9dd 100644 --- a/tests/modules/programs/neomutt/neomutt-with-binds-with-warning.nix +++ b/tests/modules/programs/neomutt/neomutt-with-binds-with-warning.nix @@ -50,8 +50,7 @@ with lib; ]; }; - nixpkgs.overlays = - [ (self: super: { neomutt = pkgs.writeScriptBin "dummy-neomutt" ""; }) ]; + test.stubs.neomutt = { }; 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." diff --git a/tests/modules/programs/neomutt/neomutt-with-binds.nix b/tests/modules/programs/neomutt/neomutt-with-binds.nix index bd40cd893..64ebf80f8 100644 --- a/tests/modules/programs/neomutt/neomutt-with-binds.nix +++ b/tests/modules/programs/neomutt/neomutt-with-binds.nix @@ -50,8 +50,7 @@ with lib; ]; }; - nixpkgs.overlays = - [ (self: super: { neomutt = pkgs.writeScriptBin "dummy-neomutt" ""; }) ]; + test.stubs.neomutt = { }; nmt.script = '' assertFileExists home-files/.config/neomutt/neomuttrc diff --git a/tests/modules/programs/neomutt/neomutt-with-gpg.nix b/tests/modules/programs/neomutt/neomutt-with-gpg.nix index 164e4b58c..2eed53583 100644 --- a/tests/modules/programs/neomutt/neomutt-with-gpg.nix +++ b/tests/modules/programs/neomutt/neomutt-with-gpg.nix @@ -16,8 +16,7 @@ with lib; { programs.neomutt.enable = true; - nixpkgs.overlays = - [ (self: super: { neomutt = pkgs.writeScriptBin "dummy-neomutt" ""; }) ]; + test.stubs.neomutt = { }; nmt.script = '' assertFileExists home-files/.config/neomutt/neomuttrc diff --git a/tests/modules/programs/neomutt/neomutt-with-msmtp.nix b/tests/modules/programs/neomutt/neomutt-with-msmtp.nix index 1d5db5f90..48b2197d0 100644 --- a/tests/modules/programs/neomutt/neomutt-with-msmtp.nix +++ b/tests/modules/programs/neomutt/neomutt-with-msmtp.nix @@ -21,8 +21,7 @@ with lib; programs.neomutt.enable = true; - nixpkgs.overlays = - [ (self: super: { neomutt = pkgs.writeScriptBin "dummy-neomutt" ""; }) ]; + test.stubs.neomutt = { }; nmt.script = '' assertFileExists home-files/.config/neomutt/neomuttrc diff --git a/tests/modules/programs/neomutt/neomutt-with-named-mailboxes.nix b/tests/modules/programs/neomutt/neomutt-with-named-mailboxes.nix index 9478a9110..fd4fedf01 100644 --- a/tests/modules/programs/neomutt/neomutt-with-named-mailboxes.nix +++ b/tests/modules/programs/neomutt/neomutt-with-named-mailboxes.nix @@ -33,8 +33,7 @@ with lib; vimKeys = false; }; - nixpkgs.overlays = - [ (self: super: { neomutt = pkgs.writeScriptBin "dummy-neomutt" ""; }) ]; + test.stubs.neomutt = { }; nmt.script = '' assertFileExists home-files/.config/neomutt/neomuttrc diff --git a/tests/modules/programs/neomutt/neomutt.nix b/tests/modules/programs/neomutt/neomutt.nix index d4419d93e..08c8f5bf3 100644 --- a/tests/modules/programs/neomutt/neomutt.nix +++ b/tests/modules/programs/neomutt/neomutt.nix @@ -24,8 +24,7 @@ with lib; vimKeys = false; }; - nixpkgs.overlays = - [ (self: super: { neomutt = pkgs.writeScriptBin "dummy-neomutt" ""; }) ]; + test.stubs.neomutt = { }; nmt.script = '' assertFileExists home-files/.config/neomutt/neomuttrc diff --git a/tests/modules/programs/newsboat/newsboat-basics-2003.nix b/tests/modules/programs/newsboat/newsboat-basics-2003.nix index 587a31bb2..26d5f4b32 100644 --- a/tests/modules/programs/newsboat/newsboat-basics-2003.nix +++ b/tests/modules/programs/newsboat/newsboat-basics-2003.nix @@ -22,9 +22,7 @@ with lib; queries = { "foo" = ''rssurl =~ "example.com"''; }; }; - nixpkgs.overlays = [ - (self: super: { newsboat = pkgs.writeScriptBin "dummy-newsboat" ""; }) - ]; + test.stubs.newsboat = { }; nmt.script = '' assertFileContent \ diff --git a/tests/modules/programs/newsboat/newsboat-basics-2105.nix b/tests/modules/programs/newsboat/newsboat-basics-2105.nix index e7a17c5d7..ec0f33728 100644 --- a/tests/modules/programs/newsboat/newsboat-basics-2105.nix +++ b/tests/modules/programs/newsboat/newsboat-basics-2105.nix @@ -22,9 +22,7 @@ with lib; queries = { "foo" = ''rssurl =~ "example.com"''; }; }; - nixpkgs.overlays = [ - (self: super: { newsboat = pkgs.writeScriptBin "dummy-newsboat" ""; }) - ]; + test.stubs.newsboat = { }; # The format didn't change since 20.03, just the location. nmt.script = '' diff --git a/tests/modules/programs/newsboat/newsboat-basics.nix b/tests/modules/programs/newsboat/newsboat-basics.nix index e6eb41517..fe7f85070 100644 --- a/tests/modules/programs/newsboat/newsboat-basics.nix +++ b/tests/modules/programs/newsboat/newsboat-basics.nix @@ -20,9 +20,7 @@ with lib; queries = { "foo" = ''rssurl =~ "example.com"''; }; }; - nixpkgs.overlays = [ - (self: super: { newsboat = pkgs.writeScriptBin "dummy-newsboat" ""; }) - ]; + test.stubs.newsboat = { }; nmt.script = '' assertFileContent \ diff --git a/tests/modules/programs/nix-index/assert-on-command-not-found.nix b/tests/modules/programs/nix-index/assert-on-command-not-found.nix index b3b869cb8..0fa6ee799 100644 --- a/tests/modules/programs/nix-index/assert-on-command-not-found.nix +++ b/tests/modules/programs/nix-index/assert-on-command-not-found.nix @@ -12,14 +12,10 @@ xdg.dataFile."fish/home-manager_generated_completions".source = lib.mkForce (builtins.toFile "empty" ""); - nixpkgs.overlays = [ - (self: super: - let dummy = pkgs.writeScriptBin "dummy" ""; - in { - zsh = dummy; - fish = dummy; - }) - ]; + test.stubs = { + zsh = { }; + fish = { }; + }; programs.nix-index.enable = true; diff --git a/tests/modules/programs/nix-index/integrations.nix b/tests/modules/programs/nix-index/integrations.nix index 33a5de2dc..1ae46df55 100644 --- a/tests/modules/programs/nix-index/integrations.nix +++ b/tests/modules/programs/nix-index/integrations.nix @@ -16,14 +16,10 @@ in { xdg.dataFile."fish/home-manager_generated_completions".source = lib.mkForce (builtins.toFile "empty" ""); - nixpkgs.overlays = [ - (self: super: - let dummy = pkgs.writeScriptBin "dummy" ""; - in { - zsh = dummy; - fish = dummy; - }) - ]; + test.stubs = { + zsh = { }; + fish = { }; + }; programs.nix-index.enable = true; diff --git a/tests/modules/programs/nushell/settings.nix b/tests/modules/programs/nushell/settings.nix index 09c192b3b..7eef0909c 100644 --- a/tests/modules/programs/nushell/settings.nix +++ b/tests/modules/programs/nushell/settings.nix @@ -22,8 +22,7 @@ with lib; ]; }; - nixpkgs.overlays = - [ (self: super: { nushell = pkgs.writeScriptBin "dummy-nushell" ""; }) ]; + test.stubs.nushell = { }; nmt.script = '' assertFileContent \ diff --git a/tests/modules/programs/powerline-go/bash.nix b/tests/modules/programs/powerline-go/bash.nix index 945bde731..34017d884 100644 --- a/tests/modules/programs/powerline-go/bash.nix +++ b/tests/modules/programs/powerline-go/bash.nix @@ -18,8 +18,7 @@ with lib; }; }; - nixpkgs.overlays = - [ (self: super: { powerline-go = pkgs.writeScriptBin "dummy-pkg" ""; }) ]; + test.stubs.powerline-go = { }; nmt.script = '' assertFileExists home-files/.bashrc diff --git a/tests/modules/programs/powerline-go/fish.nix b/tests/modules/programs/powerline-go/fish.nix index 7009c8c29..b7891bbfb 100644 --- a/tests/modules/programs/powerline-go/fish.nix +++ b/tests/modules/programs/powerline-go/fish.nix @@ -22,14 +22,10 @@ with lib; xdg.dataFile."fish/home-manager_generated_completions".source = mkForce (builtins.toFile "empty" ""); - nixpkgs.overlays = [ - (self: super: - let dummy = pkgs.writeScriptBin "dummy" ""; - in { - powerline-go = dummy; - fish = dummy; - }) - ]; + test.stubs = { + powerline-go = { }; + fish = { }; + }; nmt.script = '' assertFileExists home-files/.config/fish/config.fish diff --git a/tests/modules/programs/powerline-go/zsh.nix b/tests/modules/programs/powerline-go/zsh.nix index 0ed88215d..161499c9a 100644 --- a/tests/modules/programs/powerline-go/zsh.nix +++ b/tests/modules/programs/powerline-go/zsh.nix @@ -18,12 +18,10 @@ with lib; }; }; - nixpkgs.overlays = [ - (self: super: { - powerline-go = pkgs.writeScriptBin "dummy-pkg" ""; - zsh = pkgs.writeScriptBin "dummy-pkg" ""; - }) - ]; + test.stubs = { + powerline-go = { }; + zsh = { }; + }; nmt.script = '' assertFileExists home-files/.zshrc diff --git a/tests/modules/programs/qutebrowser/keybindings.nix b/tests/modules/programs/qutebrowser/keybindings.nix index 1236c058d..a719d9f76 100644 --- a/tests/modules/programs/qutebrowser/keybindings.nix +++ b/tests/modules/programs/qutebrowser/keybindings.nix @@ -18,11 +18,7 @@ with lib; }; }; - nixpkgs.overlays = [ - (self: super: { - qutebrowser = pkgs.writeScriptBin "dummy-qutebrowser" ""; - }) - ]; + test.stubs.qutebrowser = { }; nmt.script = let qutebrowserConfig = if pkgs.stdenv.hostPlatform.isDarwin then diff --git a/tests/modules/programs/qutebrowser/quickmarks.nix b/tests/modules/programs/qutebrowser/quickmarks.nix index 30d1856c8..1491a1e67 100644 --- a/tests/modules/programs/qutebrowser/quickmarks.nix +++ b/tests/modules/programs/qutebrowser/quickmarks.nix @@ -13,11 +13,7 @@ with lib; }; }; - nixpkgs.overlays = [ - (self: super: { - qutebrowser = pkgs.writeScriptBin "dummy-qutebrowser" ""; - }) - ]; + test.stubs.qutebrowser = { }; nmt.script = let quickmarksFile = if pkgs.stdenv.hostPlatform.isDarwin then diff --git a/tests/modules/programs/qutebrowser/settings.nix b/tests/modules/programs/qutebrowser/settings.nix index e9bedcaa3..dca6ae6f5 100644 --- a/tests/modules/programs/qutebrowser/settings.nix +++ b/tests/modules/programs/qutebrowser/settings.nix @@ -24,11 +24,7 @@ with lib; ''; }; - nixpkgs.overlays = [ - (self: super: { - qutebrowser = pkgs.writeScriptBin "dummy-qutebrowser" ""; - }) - ]; + test.stubs.qutebrowser = { }; nmt.script = let qutebrowserConfig = if pkgs.stdenv.hostPlatform.isDarwin then diff --git a/tests/modules/programs/rbw/empty-settings.nix b/tests/modules/programs/rbw/empty-settings.nix index 3e4c821d8..aa25c876c 100644 --- a/tests/modules/programs/rbw/empty-settings.nix +++ b/tests/modules/programs/rbw/empty-settings.nix @@ -1,4 +1,5 @@ { pkgs, ... }: + let inherit (pkgs.stdenv.hostPlatform) isDarwin; @@ -7,13 +8,11 @@ let else ".config/rbw/config.json"; in { - config = { - programs.rbw.enable = true; + imports = [ ./rbw-stubs.nix ]; - nixpkgs.overlays = [ (import ./overlay.nix) ]; + programs.rbw.enable = true; - nmt.script = '' - assertPathNotExists home-files/${path} - ''; - }; + nmt.script = '' + assertPathNotExists home-files/${path} + ''; } diff --git a/tests/modules/programs/rbw/overlay.nix b/tests/modules/programs/rbw/overlay.nix deleted file mode 100644 index f10b1955f..000000000 --- a/tests/modules/programs/rbw/overlay.nix +++ /dev/null @@ -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" ]; - }; -} diff --git a/tests/modules/programs/rbw/rbw-stubs.nix b/tests/modules/programs/rbw/rbw-stubs.nix new file mode 100644 index 000000000..c48d88be6 --- /dev/null +++ b/tests/modules/programs/rbw/rbw-stubs.nix @@ -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" ]; + }; + }) + ]; +} diff --git a/tests/modules/programs/rbw/settings.nix b/tests/modules/programs/rbw/settings.nix index de08ec830..8cf9572bb 100644 --- a/tests/modules/programs/rbw/settings.nix +++ b/tests/modules/programs/rbw/settings.nix @@ -1,4 +1,5 @@ { pkgs, ... }: + let inherit (pkgs.stdenv.hostPlatform) isDarwin; @@ -17,23 +18,21 @@ let } ''; in { - config = { - programs.rbw = { - enable = true; - settings = { - email = "name@example.com"; - base_url = "bitwarden.example.com"; - identity_url = "identity.example.com"; - lock_timeout = 300; - pinentry = "gnome3"; - }; + imports = [ ./rbw-stubs.nix ]; + + programs.rbw = { + enable = true; + settings = { + email = "name@example.com"; + base_url = "bitwarden.example.com"; + identity_url = "identity.example.com"; + 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}' + ''; } diff --git a/tests/modules/programs/rbw/simple-settings.nix b/tests/modules/programs/rbw/simple-settings.nix index 4e05b69fe..becf9fad1 100644 --- a/tests/modules/programs/rbw/simple-settings.nix +++ b/tests/modules/programs/rbw/simple-settings.nix @@ -1,4 +1,5 @@ { pkgs, ... }: + let inherit (pkgs.stdenv.hostPlatform) isDarwin; @@ -17,17 +18,15 @@ let } ''; in { - config = { - programs.rbw = { - enable = true; - settings = { email = "name@example.com"; }; - }; + imports = [ ./rbw-stubs.nix ]; - nixpkgs.overlays = [ (import ./overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/${path} - assertFileContent home-files/${path} '${expected}' - ''; + programs.rbw = { + enable = true; + settings = { email = "name@example.com"; }; }; + + nmt.script = '' + assertFileExists home-files/${path} + assertFileContent home-files/${path} '${expected}' + ''; } diff --git a/tests/modules/programs/rofi-pass/rofi-pass-config.nix b/tests/modules/programs/rofi-pass/rofi-pass-config.nix index a1161dbdc..2028e840e 100644 --- a/tests/modules/programs/rofi-pass/rofi-pass-config.nix +++ b/tests/modules/programs/rofi-pass/rofi-pass-config.nix @@ -16,14 +16,10 @@ with lib; }; }; - nixpkgs.overlays = [ - (self: super: - let dummy = pkgs.writeScriptBin "dummy" ""; - in { - rofi = dummy; - rofi-pass = dummy; - }) - ]; + test.stubs = { + rofi = { }; + rofi-pass = { }; + }; nmt.script = '' assertFileContent \ diff --git a/tests/modules/programs/rofi-pass/rofi-pass-root.nix b/tests/modules/programs/rofi-pass/rofi-pass-root.nix index 02bd06c12..300e89db9 100644 --- a/tests/modules/programs/rofi-pass/rofi-pass-root.nix +++ b/tests/modules/programs/rofi-pass/rofi-pass-root.nix @@ -13,14 +13,10 @@ with lib; }; }; - nixpkgs.overlays = [ - (self: super: - let dummy = pkgs.writeScriptBin "dummy" ""; - in { - rofi = dummy; - rofi-pass = dummy; - }) - ]; + test.stubs = { + rofi = { }; + rofi-pass = { }; + }; nmt.script = '' assertFileContent \ diff --git a/tests/modules/programs/rofi/assert-on-both-theme-and-colors.nix b/tests/modules/programs/rofi/assert-on-both-theme-and-colors.nix index 087ca472a..a62faf734 100644 --- a/tests/modules/programs/rofi/assert-on-both-theme-and-colors.nix +++ b/tests/modules/programs/rofi/assert-on-both-theme-and-colors.nix @@ -17,8 +17,7 @@ with lib; }; }; - nixpkgs.overlays = - [ (self: super: { rofi = pkgs.writeScriptBin "dummy-rofi" ""; }) ]; + test.stubs.rofi = { }; test.asserts.assertions.expected = ['' Cannot use the rofi options 'theme' and 'colors' simultaneously. diff --git a/tests/modules/programs/rofi/custom-theme.nix b/tests/modules/programs/rofi/custom-theme.nix index 2d318a4e4..99c9a9896 100644 --- a/tests/modules/programs/rofi/custom-theme.nix +++ b/tests/modules/programs/rofi/custom-theme.nix @@ -29,8 +29,7 @@ with lib; }; }; - nixpkgs.overlays = - [ (self: super: { rofi = pkgs.writeScriptBin "dummy-rofi" ""; }) ]; + test.stubs.rofi = { }; nmt.script = '' assertFileContent \ diff --git a/tests/modules/programs/rofi/valid-config.nix b/tests/modules/programs/rofi/valid-config.nix index efcb1acdc..84c741521 100644 --- a/tests/modules/programs/rofi/valid-config.nix +++ b/tests/modules/programs/rofi/valid-config.nix @@ -48,8 +48,7 @@ with lib; }; }; - nixpkgs.overlays = - [ (self: super: { rofi = pkgs.writeScriptBin "dummy-rofi" ""; }) ]; + test.stubs.rofi = { }; nmt.script = '' assertFileContent \ diff --git a/tests/modules/programs/scmpuff/no-shell.nix b/tests/modules/programs/scmpuff/no-shell.nix index 96314e7a0..ddc40773e 100644 --- a/tests/modules/programs/scmpuff/no-shell.nix +++ b/tests/modules/programs/scmpuff/no-shell.nix @@ -10,8 +10,7 @@ zsh.enable = true; }; - nixpkgs.overlays = - [ (self: super: { zsh = pkgs.writeScriptBin "dummy" ""; }) ]; + test.stubs.zsh = { }; nmt.script = '' assertFileNotRegex home-files/.zshrc '${pkgs.scmpuff} init -s' diff --git a/tests/modules/programs/scmpuff/no-zsh.nix b/tests/modules/programs/scmpuff/no-zsh.nix index 90e0034bb..5854fdd6f 100644 --- a/tests/modules/programs/scmpuff/no-zsh.nix +++ b/tests/modules/programs/scmpuff/no-zsh.nix @@ -8,8 +8,7 @@ zsh.enable = true; }; - nixpkgs.overlays = - [ (self: super: { zsh = pkgs.writeScriptBin "dummy" ""; }) ]; + test.stubs.zsh = { }; nmt.script = '' assertFileNotRegex home-files/.zshrc '${pkgs.scmpuff} init -s' diff --git a/tests/modules/programs/scmpuff/zsh.nix b/tests/modules/programs/scmpuff/zsh.nix index b27f6ca8c..d132945f6 100644 --- a/tests/modules/programs/scmpuff/zsh.nix +++ b/tests/modules/programs/scmpuff/zsh.nix @@ -5,8 +5,7 @@ zsh.enable = true; }; - nixpkgs.overlays = - [ (self: super: { zsh = pkgs.writeScriptBin "dummy" ""; }) ]; + test.stubs.zsh = { }; nmt.script = '' assertFileExists home-files/.zshrc diff --git a/tests/modules/programs/sm64ex/settings.nix b/tests/modules/programs/sm64ex/settings.nix index 9ccf3953f..04499f158 100644 --- a/tests/modules/programs/sm64ex/settings.nix +++ b/tests/modules/programs/sm64ex/settings.nix @@ -39,8 +39,7 @@ with lib; }; }; - nixpkgs.overlays = - [ (self: super: { sm64ex = pkgs.writeScriptBin "dummy-sm64ex" ""; }) ]; + test.stubs.sm64ex = { }; nmt.script = '' assertFileContent \ diff --git a/tests/modules/programs/starship/settings.nix b/tests/modules/programs/starship/settings.nix index 4c506c9e8..c3517cae7 100644 --- a/tests/modules/programs/starship/settings.nix +++ b/tests/modules/programs/starship/settings.nix @@ -44,9 +44,7 @@ with lib; ]; }; - nixpkgs.overlays = [ - (self: super: { starship = pkgs.writeScriptBin "dummy-starship" ""; }) - ]; + test.stubs.starship = { }; nmt.script = '' assertFileContent \ diff --git a/tests/modules/programs/terminator/config-file.nix b/tests/modules/programs/terminator/config-file.nix index 1ae06fdc9..50b9c42e7 100644 --- a/tests/modules/programs/terminator/config-file.nix +++ b/tests/modules/programs/terminator/config-file.nix @@ -8,8 +8,7 @@ }; }; - nixpkgs.overlays = - [ (self: super: { terminator = pkgs.writeScriptBin "dummy" ""; }) ]; + test.stubs.terminator = { }; nmt.script = '' assertFileContent home-files/.config/terminator/config ${ diff --git a/tests/modules/programs/topgrade/settings.nix b/tests/modules/programs/topgrade/settings.nix index a7436b5ef..a8f5c6d10 100644 --- a/tests/modules/programs/topgrade/settings.nix +++ b/tests/modules/programs/topgrade/settings.nix @@ -25,9 +25,7 @@ with lib; ]; }; - nixpkgs.overlays = [ - (self: super: { topgrade = pkgs.writeScriptBin "dummy-topgrade" ""; }) - ]; + test.stubs.topgrade = { }; nmt.script = '' assertFileContent \ diff --git a/tests/modules/programs/waybar/settings-complex.nix b/tests/modules/programs/waybar/settings-complex.nix index 1756ae120..1297f5579 100644 --- a/tests/modules/programs/waybar/settings-complex.nix +++ b/tests/modules/programs/waybar/settings-complex.nix @@ -2,12 +2,10 @@ with lib; -let - package = pkgs.writeScriptBin "dummy-waybar" "" // { outPath = "@waybar@"; }; -in { +{ config = { programs.waybar = { - inherit package; + package = config.lib.test.mkStubPackage { outPath = "@waybar@"; }; enable = true; settings = [{ layer = "top"; @@ -41,9 +39,7 @@ in { format = "hello from {}"; exec = let dummyScript = - pkgs.writeShellScriptBin "dummy" "echo within waybar" // { - outPath = "@dummy@"; - }; + config.lib.test.mkStubPackage { outPath = "@dummy@"; }; in "${dummyScript}/bin/dummy"; }; }; diff --git a/tests/modules/programs/waybar/styling.nix b/tests/modules/programs/waybar/styling.nix index bd73f2aaf..6e34847ed 100644 --- a/tests/modules/programs/waybar/styling.nix +++ b/tests/modules/programs/waybar/styling.nix @@ -2,12 +2,10 @@ with lib; -let - package = pkgs.writeScriptBin "dummy-waybar" "" // { outPath = "@waybar@"; }; -in { +{ config = { programs.waybar = { - inherit package; + package = config.lib.test.mkStubPackage { outPath = "@waybar@"; }; enable = true; style = '' * { diff --git a/tests/modules/programs/waybar/systemd-with-graphical-session-target.nix b/tests/modules/programs/waybar/systemd-with-graphical-session-target.nix index e751d804d..eff5af9cc 100644 --- a/tests/modules/programs/waybar/systemd-with-graphical-session-target.nix +++ b/tests/modules/programs/waybar/systemd-with-graphical-session-target.nix @@ -2,12 +2,10 @@ with lib; -let - package = pkgs.writeScriptBin "dummy-waybar" "" // { outPath = "@waybar@"; }; -in { +{ config = { programs.waybar = { - inherit package; + package = config.lib.test.mkStubPackage { outPath = "@waybar@"; }; enable = true; systemd.enable = true; }; diff --git a/tests/modules/programs/waybar/warnings-tests.nix b/tests/modules/programs/waybar/warnings-tests.nix index f7912dba7..e844cc61d 100644 --- a/tests/modules/programs/waybar/warnings-tests.nix +++ b/tests/modules/programs/waybar/warnings-tests.nix @@ -2,12 +2,10 @@ with lib; -let - package = pkgs.writeScriptBin "dummy-waybar" "" // { outPath = "@waybar@"; }; -in { +{ config = { programs.waybar = { - inherit package; + package = config.lib.test.mkStubPackage { outPath = "@waybar@"; }; enable = true; settings = [{ modules-left = [ "custom/my-module" ]; diff --git a/tests/modules/programs/xmobar/basic-configuration.nix b/tests/modules/programs/xmobar/basic-configuration.nix index 99ed57de1..bbd9420ea 100644 --- a/tests/modules/programs/xmobar/basic-configuration.nix +++ b/tests/modules/programs/xmobar/basic-configuration.nix @@ -6,7 +6,7 @@ with lib; config = { programs.xmobar = { enable = true; - package = pkgs.writeScriptBin "dummy" ""; + package = config.lib.test.mkStubPackage { }; extraConfig = '' Config { font = "Fira Code" diff --git a/tests/modules/programs/zplug/modules.nix b/tests/modules/programs/zplug/modules.nix index 704c5c5e2..373b6b889 100644 --- a/tests/modules/programs/zplug/modules.nix +++ b/tests/modules/programs/zplug/modules.nix @@ -21,16 +21,14 @@ with lib; }; }; - nixpkgs.overlays = [ - (self: super: { - zsh = pkgs.writeScriptBin "dummy-zsh" ""; - zplug = pkgs.writeScriptBin "dummy-zplug" ""; - }) - ]; + test.stubs = { + zplug = { }; + zsh = { }; + }; nmt.script = '' - assertFileRegex home-files/.zshrc \ - '^source ${builtins.storeDir}/.*zplug.*/init\.zsh$' + assertFileContains home-files/.zshrc \ + 'source @zplug@/init.zsh' assertFileContains home-files/.zshrc \ 'zplug "plugins/git", from:oh-my-zsh' diff --git a/tests/modules/programs/zsh/history-ignore-pattern.nix b/tests/modules/programs/zsh/history-ignore-pattern.nix index ba423efe2..68be58fe8 100644 --- a/tests/modules/programs/zsh/history-ignore-pattern.nix +++ b/tests/modules/programs/zsh/history-ignore-pattern.nix @@ -11,8 +11,7 @@ with lib; config = { programs.zsh.enable = true; - nixpkgs.overlays = - [ (self: super: { zsh = pkgs.writeScriptBin "dummy-zsh" ""; }) ]; + test.stubs.zsh = { }; nmt.script = '' assertFileContains home-files/.zshrc "HISTORY_IGNORE='(echo *|rm *)'" diff --git a/tests/modules/programs/zsh/history-path-new-custom.nix b/tests/modules/programs/zsh/history-path-new-custom.nix index 0c052d694..1a691f1ca 100644 --- a/tests/modules/programs/zsh/history-path-new-custom.nix +++ b/tests/modules/programs/zsh/history-path-new-custom.nix @@ -10,8 +10,7 @@ with lib; history.path = "$HOME/some/directory/zsh_history"; }; - nixpkgs.overlays = - [ (self: super: { zsh = pkgs.writeScriptBin "dummy-zsh" ""; }) ]; + test.stubs.zsh = { }; nmt.script = '' assertFileRegex home-files/.zshrc '^HISTFILE="$HOME/some/directory/zsh_history"$' diff --git a/tests/modules/programs/zsh/history-path-new-default.nix b/tests/modules/programs/zsh/history-path-new-default.nix index 6d1f58a29..06fe88d06 100644 --- a/tests/modules/programs/zsh/history-path-new-default.nix +++ b/tests/modules/programs/zsh/history-path-new-default.nix @@ -7,8 +7,7 @@ with lib; home.stateVersion = "20.03"; programs.zsh.enable = true; - nixpkgs.overlays = - [ (self: super: { zsh = pkgs.writeScriptBin "dummy-zsh" ""; }) ]; + test.stubs.zsh = { }; nmt.script = '' assertFileRegex home-files/.zshrc '^HISTFILE="$HOME/.zsh_history"$' diff --git a/tests/modules/programs/zsh/history-path-old-custom.nix b/tests/modules/programs/zsh/history-path-old-custom.nix index f5b178b5e..42a85d004 100644 --- a/tests/modules/programs/zsh/history-path-old-custom.nix +++ b/tests/modules/programs/zsh/history-path-old-custom.nix @@ -10,8 +10,7 @@ with lib; history.path = "some/directory/zsh_history"; }; - nixpkgs.overlays = - [ (self: super: { zsh = pkgs.writeScriptBin "dummy-zsh" ""; }) ]; + test.stubs.zsh = { }; nmt.script = '' assertFileRegex home-files/.zshrc '^HISTFILE="$HOME/some/directory/zsh_history"$' diff --git a/tests/modules/programs/zsh/history-path-old-default.nix b/tests/modules/programs/zsh/history-path-old-default.nix index d880d9664..490a2715d 100644 --- a/tests/modules/programs/zsh/history-path-old-default.nix +++ b/tests/modules/programs/zsh/history-path-old-default.nix @@ -7,8 +7,7 @@ with lib; home.stateVersion = "19.03"; programs.zsh.enable = true; - nixpkgs.overlays = - [ (self: super: { zsh = pkgs.writeScriptBin "dummy-zsh" ""; }) ]; + test.stubs.zsh = { }; nmt.script = '' assertFileRegex home-files/.zshrc '^HISTFILE="$HOME/.zsh_history"$' diff --git a/tests/modules/programs/zsh/prezto.nix b/tests/modules/programs/zsh/prezto.nix index 5bc95510d..922112ef9 100644 --- a/tests/modules/programs/zsh/prezto.nix +++ b/tests/modules/programs/zsh/prezto.nix @@ -3,23 +3,20 @@ with lib; { - config = { - programs.zsh.prezto.enable = true; + programs.zsh.prezto.enable = true; - nixpkgs.overlays = [ - (self: super: { - zsh-prezto = super.runCommandLocal "dummy-zsh-prezto" { } '' - mkdir -p $out/share/zsh-prezto/runcoms - echo '# zprofile' > $out/share/zsh-prezto/runcoms/zprofile - echo '# zlogin' > $out/share/zsh-prezto/runcoms/zlogin - echo '# zlogout' > $out/share/zsh-prezto/runcoms/zlogout - echo '# zshenv' > $out/share/zsh-prezto/runcoms/zshenv - ''; - }) - ]; - - nmt.script = '' - assertFileExists home-files/.zpreztorc + test.stubs.zsh-prezto = { + outPath = null; + buildScript = '' + mkdir -p $out/share/zsh-prezto/runcoms + echo '# zprofile' > $out/share/zsh-prezto/runcoms/zprofile + echo '# zlogin' > $out/share/zsh-prezto/runcoms/zlogin + echo '# zlogout' > $out/share/zsh-prezto/runcoms/zlogout + echo '# zshenv' > $out/share/zsh-prezto/runcoms/zshenv ''; }; + + nmt.script = '' + assertFileExists home-files/.zpreztorc + ''; } diff --git a/tests/modules/programs/zsh/session-variables.nix b/tests/modules/programs/zsh/session-variables.nix index 5c322be13..638b41c9f 100644 --- a/tests/modules/programs/zsh/session-variables.nix +++ b/tests/modules/programs/zsh/session-variables.nix @@ -13,8 +13,7 @@ with lib; }; }; - nixpkgs.overlays = - [ (self: super: { zsh = pkgs.writeScriptBin "dummy-zsh" ""; }) ]; + test.stubs.zsh = { }; nmt.script = '' assertFileExists home-files/.zshrc diff --git a/tests/modules/services/barrier/basic-configuration.nix b/tests/modules/services/barrier/basic-configuration.nix index 83a9365e4..03b1beae7 100644 --- a/tests/modules/services/barrier/basic-configuration.nix +++ b/tests/modules/services/barrier/basic-configuration.nix @@ -7,8 +7,7 @@ server = "testServer"; }; - nixpkgs.overlays = - [ (self: super: { barrier = pkgs.writeScriptBin "dummy-barrier" ""; }) ]; + test.stubs.barrier = { }; nmt.script = '' clientServiceFile=home-files/.config/systemd/user/barrierc.service diff --git a/tests/modules/services/devilspie2/configuration.nix b/tests/modules/services/devilspie2/configuration.nix index eb576b9fa..2072d4d84 100644 --- a/tests/modules/services/devilspie2/configuration.nix +++ b/tests/modules/services/devilspie2/configuration.nix @@ -18,9 +18,7 @@ ''; }; - nixpkgs.overlays = [ - (self: super: { devilspie2 = pkgs.writeScriptBin "dummy-devilspie2" ""; }) - ]; + test.stubs.devilspie2 = { }; nmt.script = '' configlua=home-files/.config/devilspie2/config.lua diff --git a/tests/modules/services/dropbox/basic-configuration.nix b/tests/modules/services/dropbox/basic-configuration.nix index 96a17cd73..9b8a6d651 100644 --- a/tests/modules/services/dropbox/basic-configuration.nix +++ b/tests/modules/services/dropbox/basic-configuration.nix @@ -7,13 +7,7 @@ path = "${config.home.homeDirectory}/dropbox"; }; - nixpkgs.overlays = [ - (self: super: { - dropbox-cli = pkgs.writeScriptBin "dummy-dropbox-cli" "" // { - outPath = "@dropbox-cli@"; - }; - }) - ]; + test.stubs.dropbox-cli = { }; nmt.script = '' serviceFile=home-files/.config/systemd/user/dropbox.service diff --git a/tests/modules/services/fluidsynth/service.nix b/tests/modules/services/fluidsynth/service.nix index 9115eb0de..7fbfa79ce 100644 --- a/tests/modules/services/fluidsynth/service.nix +++ b/tests/modules/services/fluidsynth/service.nix @@ -5,13 +5,7 @@ services.fluidsynth.soundFont = "/path/to/soundFont"; services.fluidsynth.extraOptions = [ "--sample-rate 96000" ]; - nixpkgs.overlays = [ - (self: super: { - fluidsynth = pkgs.writeScriptBin "dummy-fluidsynth" "" // { - outPath = "@fluidsynth@"; - }; - }) - ]; + test.stubs.fluidsynth = { }; nmt.script = '' serviceFile=home-files/.config/systemd/user/fluidsynth.service diff --git a/tests/modules/services/fnott/example-settings.nix b/tests/modules/services/fnott/example-settings.nix index 3685637d7..16b591ff7 100644 --- a/tests/modules/services/fnott/example-settings.nix +++ b/tests/modules/services/fnott/example-settings.nix @@ -4,7 +4,7 @@ config = { services.fnott = { enable = true; - package = pkgs.writeScriptBin "dummy-fnott" ""; + package = config.lib.test.mkStubPackage { }; settings = { main = { notification-margin = 5; }; diff --git a/tests/modules/services/fnott/global-properties.nix b/tests/modules/services/fnott/global-properties.nix index 5a9d7e038..3be88d787 100644 --- a/tests/modules/services/fnott/global-properties.nix +++ b/tests/modules/services/fnott/global-properties.nix @@ -5,7 +5,7 @@ config = { services.fnott = { enable = true; - package = pkgs.writeScriptBin "dummy-fnott" ""; + package = config.lib.test.mkStubPackage { }; settings = { main = { diff --git a/tests/modules/services/fnott/systemd-user-service.nix b/tests/modules/services/fnott/systemd-user-service.nix index 05859277b..7efa06435 100644 --- a/tests/modules/services/fnott/systemd-user-service.nix +++ b/tests/modules/services/fnott/systemd-user-service.nix @@ -4,7 +4,7 @@ config = { services.fnott = { enable = true; - package = pkgs.writeScriptBin "dummy-foot" "" // { outPath = "@fnott@"; }; + package = config.lib.test.mkStubPackage { outPath = "@fnott@"; }; }; nmt.script = '' diff --git a/tests/modules/services/git-sync/basic.nix b/tests/modules/services/git-sync/basic.nix index 2e9ec9ad7..0e9c7ad65 100644 --- a/tests/modules/services/git-sync/basic.nix +++ b/tests/modules/services/git-sync/basic.nix @@ -4,7 +4,7 @@ config = { services.git-sync = { enable = true; - package = pkgs.writeScriptBin "dummy" "" // { outPath = "@git-sync@"; }; + package = config.lib.test.mkStubPackage { outPath = "@git-sync@"; }; repositories.test = { path = "/a/path"; uri = "git+ssh://user@example.com:/~user/path/to/repo.git"; diff --git a/tests/modules/services/gpg-agent/default-homedir.nix b/tests/modules/services/gpg-agent/default-homedir.nix index f7ebf5739..1b4333e12 100644 --- a/tests/modules/services/gpg-agent/default-homedir.nix +++ b/tests/modules/services/gpg-agent/default-homedir.nix @@ -7,8 +7,7 @@ with lib; services.gpg-agent.enable = true; programs.gpg.enable = true; - nixpkgs.overlays = - [ (self: super: { gnupg = pkgs.writeScriptBin "dummy-gnupg" ""; }) ]; + test.stubs.gnupg = { }; nmt.script = '' in="${config.systemd.user.sockets.gpg-agent.Socket.ListenStream}" diff --git a/tests/modules/services/gpg-agent/override-homedir.nix b/tests/modules/services/gpg-agent/override-homedir.nix index 6705a0014..6c231a3b2 100644 --- a/tests/modules/services/gpg-agent/override-homedir.nix +++ b/tests/modules/services/gpg-agent/override-homedir.nix @@ -10,8 +10,7 @@ with lib; homedir = "${config.home.homeDirectory}/foo/bar"; }; - nixpkgs.overlays = - [ (self: super: { gnupg = pkgs.writeScriptBin "dummy-gnupg" ""; }) ]; + test.stubs.gnupg = { }; nmt.script = '' in="${config.systemd.user.sockets.gpg-agent.Socket.ListenStream}" diff --git a/tests/modules/services/kanshi/basic-configuration.nix b/tests/modules/services/kanshi/basic-configuration.nix index 15fbbb9ce..b8cd5d214 100644 --- a/tests/modules/services/kanshi/basic-configuration.nix +++ b/tests/modules/services/kanshi/basic-configuration.nix @@ -2,7 +2,7 @@ config = { services.kanshi = { enable = true; - package = pkgs.writeScriptBin "dummy-kanshi" ""; + package = config.lib.test.mkStubPackage { }; profiles = { nomad = { outputs = [{ diff --git a/tests/modules/services/lieer/lieer-service-expected.service b/tests/modules/services/lieer/lieer-service-expected.service index 8437b9895..1d282eb98 100644 --- a/tests/modules/services/lieer/lieer-service-expected.service +++ b/tests/modules/services/lieer/lieer-service-expected.service @@ -1,6 +1,6 @@ [Service] Environment=NOTMUCH_CONFIG=/home/hm-user/.config/notmuch/notmuchrc -ExecStart=@lieer@/bin/gmi sync +ExecStart=@gmailieer@/bin/gmi sync Type=oneshot WorkingDirectory=/home/hm-user/Mail/hm@example.com diff --git a/tests/modules/services/lieer/lieer-service.nix b/tests/modules/services/lieer/lieer-service.nix index af3074b0f..f624ae826 100644 --- a/tests/modules/services/lieer/lieer-service.nix +++ b/tests/modules/services/lieer/lieer-service.nix @@ -19,13 +19,7 @@ with lib; }; }; - nixpkgs.overlays = [ - (self: super: { - gmailieer = pkgs.writeScriptBin "dummy-gmailieer" "" // { - outPath = "@lieer@"; - }; - }) - ]; + test.stubs.gmailieer = { }; nmt.script = '' assertFileExists home-files/.config/systemd/user/lieer-hm-example-com.service diff --git a/tests/modules/services/pantalaimon/basic-configuration.nix b/tests/modules/services/pantalaimon/basic-configuration.nix index f04101c05..ac36c0b87 100644 --- a/tests/modules/services/pantalaimon/basic-configuration.nix +++ b/tests/modules/services/pantalaimon/basic-configuration.nix @@ -4,9 +4,7 @@ config = { services.pantalaimon = { enable = true; - package = pkgs.writeScriptBin "dummy-pantalaimon" "" // { - outPath = "@pantalaimon@"; - }; + package = config.lib.test.mkStubPackage { outPath = "@pantalaimon@"; }; settings = { Default = { LogLevel = "Debug"; diff --git a/tests/modules/services/pbgopy/service.nix b/tests/modules/services/pbgopy/service.nix index fb03c355c..465024537 100644 --- a/tests/modules/services/pbgopy/service.nix +++ b/tests/modules/services/pbgopy/service.nix @@ -2,13 +2,7 @@ config = { services.pbgopy.enable = true; - nixpkgs.overlays = [ - (self: super: { - pbgopy = pkgs.writeScriptBin "dummy-pbgopy" "" // { - outPath = "@pbgopy@"; - }; - }) - ]; + test.stubs.pbgopy = { }; nmt.script = '' serviceFile=home-files/.config/systemd/user/pbgopy.service diff --git a/tests/modules/services/polybar/basic-configuration.nix b/tests/modules/services/polybar/basic-configuration.nix index fd23256c3..b6374acd8 100644 --- a/tests/modules/services/polybar/basic-configuration.nix +++ b/tests/modules/services/polybar/basic-configuration.nix @@ -4,7 +4,7 @@ config = { services.polybar = { enable = true; - package = pkgs.writeScriptBin "dummy-polybar" ""; + package = config.lib.test.mkStubPackage { }; script = "polybar bar &"; config = { "bar/top" = { diff --git a/tests/modules/services/redshift-gammastep/gammastep-basic-configuration.nix b/tests/modules/services/redshift-gammastep/gammastep-basic-configuration.nix index 9ccf38528..6f0454bf3 100644 --- a/tests/modules/services/redshift-gammastep/gammastep-basic-configuration.nix +++ b/tests/modules/services/redshift-gammastep/gammastep-basic-configuration.nix @@ -16,13 +16,7 @@ }; }; - nixpkgs.overlays = [ - (self: super: { - gammastep = pkgs.writeScriptBin "dummy-gammastep" "" // { - outPath = "@gammastep@"; - }; - }) - ]; + test.stubs.gammastep = { }; nmt.script = '' assertFileContent \ diff --git a/tests/modules/services/redshift-gammastep/redshift-basic-configuration.nix b/tests/modules/services/redshift-gammastep/redshift-basic-configuration.nix index 5e2fe40e0..691d01e25 100644 --- a/tests/modules/services/redshift-gammastep/redshift-basic-configuration.nix +++ b/tests/modules/services/redshift-gammastep/redshift-basic-configuration.nix @@ -16,13 +16,7 @@ }; }; - nixpkgs.overlays = [ - (self: super: { - redshift = pkgs.writeScriptBin "dummy-redshift" "" // { - outPath = "@redshift@"; - }; - }) - ]; + test.stubs.redshift = { }; nmt.script = '' assertFileContent \ diff --git a/tests/modules/services/sxhkd/configuration.nix b/tests/modules/services/sxhkd/configuration.nix index e9d85477b..9e9965051 100644 --- a/tests/modules/services/sxhkd/configuration.nix +++ b/tests/modules/services/sxhkd/configuration.nix @@ -1,34 +1,32 @@ -{ config, pkgs, ... }: { - config = { - services.sxhkd = { - enable = true; +{ config, pkgs, ... }: - package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out" // { - outPath = "@sxhkd@"; - }; +{ + services.sxhkd = { + enable = true; - keybindings = { - "super + a" = "run command a"; - "super + b" = null; - "super + Shift + b" = "run command b"; - }; + package = config.lib.test.mkStubPackage { outPath = "@sxhkd@"; }; - extraConfig = '' - super + c - call command c - - # comment - super + d - call command d - ''; + keybindings = { + "super + a" = "run command a"; + "super + b" = null; + "super + Shift + b" = "run command b"; }; - nmt.script = '' - sxhkdrc=home-files/.config/sxhkd/sxhkdrc + extraConfig = '' + super + c + call command c - assertFileExists $sxhkdrc - - assertFileContent $sxhkdrc ${./sxhkdrc} + # comment + super + d + call command d ''; }; + + nmt.script = '' + sxhkdrc=home-files/.config/sxhkd/sxhkdrc + + assertFileExists $sxhkdrc + + assertFileContent $sxhkdrc ${./sxhkdrc} + ''; } diff --git a/tests/modules/services/sxhkd/service.nix b/tests/modules/services/sxhkd/service.nix index 44bed4252..84f3086a8 100644 --- a/tests/modules/services/sxhkd/service.nix +++ b/tests/modules/services/sxhkd/service.nix @@ -1,30 +1,26 @@ { config, pkgs, ... }: { - config = { - xsession = { - enable = true; - windowManager.command = ""; - }; - - services.sxhkd = { - enable = true; - package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out" // { - outPath = "@sxhkd@"; - }; - extraOptions = [ "-m 1" ]; - }; - - nmt.script = '' - xsessionFile=home-files/.xsession - - assertFileExists $xsessionFile - - assertFileContains $xsessionFile \ - 'systemctl --user stop sxhkd.scope 2> /dev/null || true' - - assertFileContains $xsessionFile \ - 'systemd-cat -t sxhkd systemd-run --user --scope -u sxhkd @sxhkd@/bin/sxhkd -m 1 &' - ''; + xsession = { + enable = true; + windowManager.command = ""; }; + + services.sxhkd = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@sxhkd@"; }; + extraOptions = [ "-m 1" ]; + }; + + nmt.script = '' + xsessionFile=home-files/.xsession + + assertFileExists $xsessionFile + + assertFileContains $xsessionFile \ + 'systemctl --user stop sxhkd.scope 2> /dev/null || true' + + assertFileContains $xsessionFile \ + 'systemd-cat -t sxhkd systemd-run --user --scope -u sxhkd @sxhkd@/bin/sxhkd -m 1 &' + ''; } diff --git a/tests/modules/services/syncthing/tray-as-bool-triggers-warning.nix b/tests/modules/services/syncthing/tray-as-bool-triggers-warning.nix index 9f9dc2ba9..ca018c2d8 100644 --- a/tests/modules/services/syncthing/tray-as-bool-triggers-warning.nix +++ b/tests/modules/services/syncthing/tray-as-bool-triggers-warning.nix @@ -6,14 +6,12 @@ with lib; config = { services.syncthing.tray = true; - nixpkgs.overlays = [ - (self: super: { syncthingtray-minimal = pkgs.writeScriptBin "dummy" ""; }) - ]; - test.asserts.warnings.expected = [ "Specifying 'services.syncthing.tray' as a boolean is deprecated, set 'services.syncthing.tray.enable' instead. See https://github.com/nix-community/home-manager/pull/1257." ]; + test.stubs.syncthingtray-minimal = { }; + nmt.script = '' assertFileExists home-files/.config/systemd/user/syncthingtray.service ''; diff --git a/tests/modules/services/trayer/basic-configuration.nix b/tests/modules/services/trayer/basic-configuration.nix index 23632331e..3020e6310 100644 --- a/tests/modules/services/trayer/basic-configuration.nix +++ b/tests/modules/services/trayer/basic-configuration.nix @@ -4,9 +4,7 @@ config = { services.trayer = { enable = true; - package = pkgs.writeScriptBin "dummy-trayer" "" // { - outPath = "@trayer@"; - }; + package = config.lib.test.mkStubPackage { outPath = "@trayer@"; }; settings = { edge = "top"; padding = 6; diff --git a/tests/modules/services/window-managers/i3/i3-bar-focused-colors.nix b/tests/modules/services/window-managers/i3/i3-bar-focused-colors.nix index aaa6809f5..66b4ca87a 100644 --- a/tests/modules/services/window-managers/i3/i3-bar-focused-colors.nix +++ b/tests/modules/services/window-managers/i3/i3-bar-focused-colors.nix @@ -1,25 +1,21 @@ { config, lib, ... }: -with lib; - { - config = { - xsession.windowManager.i3 = { - enable = true; + imports = [ ./i3-stubs.nix ]; - config.bars = [{ - colors.focusedBackground = "#ffffff"; - colors.focusedStatusline = "#000000"; - colors.focusedSeparator = "#999999"; - }]; - }; + xsession.windowManager.i3 = { + enable = true; - nixpkgs.overlays = [ (import ./i3-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/i3/config - assertFileContent home-files/.config/i3/config \ - ${./i3-bar-focused-colors-expected.conf} - ''; + config.bars = [{ + colors.focusedBackground = "#ffffff"; + colors.focusedStatusline = "#000000"; + colors.focusedSeparator = "#999999"; + }]; }; + + nmt.script = '' + assertFileExists home-files/.config/i3/config + assertFileContent home-files/.config/i3/config \ + ${./i3-bar-focused-colors-expected.conf} + ''; } diff --git a/tests/modules/services/window-managers/i3/i3-fonts-deprecated.nix b/tests/modules/services/window-managers/i3/i3-fonts-deprecated.nix index c5142ed45..7e4532e57 100644 --- a/tests/modules/services/window-managers/i3/i3-fonts-deprecated.nix +++ b/tests/modules/services/window-managers/i3/i3-fonts-deprecated.nix @@ -1,29 +1,25 @@ { config, lib, ... }: -with lib; - { - config = { - xsession.windowManager.i3 = { - enable = true; + imports = [ ./i3-stubs.nix ]; - config = { - bars = [{ fonts = [ "FontAwesome" "Iosevka 11.500000" ]; }]; - fonts = [ "DejaVuSansMono" "Terminus Bold Semi-Condensed 13.500000" ]; - }; + xsession.windowManager.i3 = { + enable = true; + + config = { + bars = [{ fonts = [ "FontAwesome" "Iosevka 11.500000" ]; }]; + fonts = [ "DejaVuSansMono" "Terminus Bold Semi-Condensed 13.500000" ]; }; - - nixpkgs.overlays = [ (import ./i3-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/i3/config - assertFileContent home-files/.config/i3/config \ - ${./i3-fonts-expected.conf} - ''; - - test.asserts.warnings.expected = [ - "Specifying i3.config.fonts as a list is deprecated. Use the attrset version instead." - "Specifying i3.config.bars[].fonts as a list is deprecated. Use the attrset version instead." - ]; }; + + nmt.script = '' + assertFileExists home-files/.config/i3/config + assertFileContent home-files/.config/i3/config \ + ${./i3-fonts-expected.conf} + ''; + + test.asserts.warnings.expected = [ + "Specifying i3.config.fonts as a list is deprecated. Use the attrset version instead." + "Specifying i3.config.bars[].fonts as a list is deprecated. Use the attrset version instead." + ]; } diff --git a/tests/modules/services/window-managers/i3/i3-fonts.nix b/tests/modules/services/window-managers/i3/i3-fonts.nix index 20ea5cabe..3618451f8 100644 --- a/tests/modules/services/window-managers/i3/i3-fonts.nix +++ b/tests/modules/services/window-managers/i3/i3-fonts.nix @@ -1,33 +1,29 @@ { config, lib, ... }: -with lib; - { - config = { - xsession.windowManager.i3 = { - enable = true; + imports = [ ./i3-stubs.nix ]; - config = { - bars = [{ - fonts = { - names = [ "FontAwesome" "Iosevka" ]; - size = 11.5; - }; - }]; + xsession.windowManager.i3 = { + enable = true; + + config = { + bars = [{ fonts = { - names = [ "DejaVuSansMono" "Terminus" ]; - style = "Bold Semi-Condensed"; - size = 13.5; + names = [ "FontAwesome" "Iosevka" ]; + size = 11.5; }; + }]; + fonts = { + names = [ "DejaVuSansMono" "Terminus" ]; + style = "Bold Semi-Condensed"; + size = 13.5; }; }; - - nixpkgs.overlays = [ (import ./i3-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/i3/config - assertFileContent home-files/.config/i3/config \ - ${./i3-fonts-expected.conf} - ''; }; + + nmt.script = '' + assertFileExists home-files/.config/i3/config + assertFileContent home-files/.config/i3/config \ + ${./i3-fonts-expected.conf} + ''; } diff --git a/tests/modules/services/window-managers/i3/i3-keybindings.nix b/tests/modules/services/window-managers/i3/i3-keybindings.nix index bc3cae6e0..2137c53ed 100644 --- a/tests/modules/services/window-managers/i3/i3-keybindings.nix +++ b/tests/modules/services/window-managers/i3/i3-keybindings.nix @@ -1,27 +1,23 @@ { config, lib, ... }: -with lib; - { - config = { - xsession.windowManager.i3 = { - enable = true; + imports = [ ./i3-stubs.nix ]; - config.keybindings = - let modifier = config.xsession.windowManager.i3.config.modifier; - in lib.mkOptionDefault { - "${modifier}+Left" = "overridden-command"; - "${modifier}+Right" = null; - "${modifier}+Invented" = "invented-key-command"; - }; - }; + xsession.windowManager.i3 = { + enable = true; - nixpkgs.overlays = [ (import ./i3-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/i3/config - assertFileContent home-files/.config/i3/config \ - ${./i3-keybindings-expected.conf} - ''; + config.keybindings = + let modifier = config.xsession.windowManager.i3.config.modifier; + in lib.mkOptionDefault { + "${modifier}+Left" = "overridden-command"; + "${modifier}+Right" = null; + "${modifier}+Invented" = "invented-key-command"; + }; }; + + nmt.script = '' + assertFileExists home-files/.config/i3/config + assertFileContent home-files/.config/i3/config \ + ${./i3-keybindings-expected.conf} + ''; } diff --git a/tests/modules/services/window-managers/i3/i3-null-config.nix b/tests/modules/services/window-managers/i3/i3-null-config.nix index a9b378824..1c221319b 100644 --- a/tests/modules/services/window-managers/i3/i3-null-config.nix +++ b/tests/modules/services/window-managers/i3/i3-null-config.nix @@ -1,20 +1,16 @@ { config, lib, pkgs, ... }: -with lib; - { - config = { - xsession.windowManager.i3 = { - enable = true; - config = null; - }; + imports = [ ./i3-stubs.nix ]; - nixpkgs.overlays = [ (import ./i3-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/i3/config - assertFileContent home-files/.config/i3/config \ - ${pkgs.writeText "expected" "\n"} - ''; + xsession.windowManager.i3 = { + enable = true; + config = null; }; + + nmt.script = '' + assertFileExists home-files/.config/i3/config + assertFileContent home-files/.config/i3/config \ + ${pkgs.writeText "expected" "\n"} + ''; } diff --git a/tests/modules/services/window-managers/i3/i3-overlay.nix b/tests/modules/services/window-managers/i3/i3-overlay.nix deleted file mode 100644 index fead262f4..000000000 --- a/tests/modules/services/window-managers/i3/i3-overlay.nix +++ /dev/null @@ -1,12 +0,0 @@ -self: super: -# Avoid unnecessary downloads in CI jobs and/or make out paths -# constant, i.e., not containing hashes, version numbers etc. -{ - dmenu = super.dmenu // { outPath = "@dmenu@"; }; - - i3 = super.writeScriptBin "i3" "" // { outPath = "@i3@"; }; - - i3-gaps = super.writeScriptBin "i3" "" // { outPath = "@i3-gaps@"; }; - - i3status = super.i3status // { outPath = "@i3status@"; }; -} diff --git a/tests/modules/services/window-managers/i3/i3-stubs.nix b/tests/modules/services/window-managers/i3/i3-stubs.nix new file mode 100644 index 000000000..cfb892ace --- /dev/null +++ b/tests/modules/services/window-managers/i3/i3-stubs.nix @@ -0,0 +1,19 @@ +{ + # Avoid unnecessary downloads in CI jobs and/or make out paths constant, i.e., + # not containing hashes, version numbers etc. + test.stubs = { + dmenu = { }; + + i3 = { + buildScript = '' + mkdir -p $out/bin + echo '#!/bin/sh' > $out/bin/i3 + chmod 755 $out/bin/i3 + ''; + }; + + i3-gaps = { }; + + i3status = { }; + }; +} diff --git a/tests/modules/services/window-managers/i3/i3-workspace-default.nix b/tests/modules/services/window-managers/i3/i3-workspace-default.nix index 0a825b1e8..521b5f5d7 100644 --- a/tests/modules/services/window-managers/i3/i3-workspace-default.nix +++ b/tests/modules/services/window-managers/i3/i3-workspace-default.nix @@ -1,21 +1,17 @@ { config, lib, ... }: -with lib; - { - config = { - xsession.windowManager.i3 = { - enable = true; + imports = [ ./i3-stubs.nix ]; - config.defaultWorkspace = "workspace number 1"; - }; + xsession.windowManager.i3 = { + enable = true; - nixpkgs.overlays = [ (import ./i3-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/i3/config - assertFileContent home-files/.config/i3/config \ - ${./i3-workspace-default-expected.conf} - ''; + config.defaultWorkspace = "workspace number 1"; }; + + nmt.script = '' + assertFileExists home-files/.config/i3/config + assertFileContent home-files/.config/i3/config \ + ${./i3-workspace-default-expected.conf} + ''; } diff --git a/tests/modules/services/window-managers/i3/i3-workspace-output.nix b/tests/modules/services/window-managers/i3/i3-workspace-output.nix index b2ff90e02..df4a2c789 100644 --- a/tests/modules/services/window-managers/i3/i3-workspace-output.nix +++ b/tests/modules/services/window-managers/i3/i3-workspace-output.nix @@ -1,46 +1,42 @@ { config, lib, ... }: -with lib; - -{ - config = let - i3 = { - ws1 = "1"; - ws2 = "ABC"; - ws3 = "3: Test"; - ws4 = ''!"§$%&/(){}[]=?\*#<>-_.:,;²³''; - }; - - in { - xsession.windowManager.i3 = { - enable = true; - - config.workspaceOutputAssign = [ - { - workspace = "${i3.ws1}"; - output = "eDP"; - } - { - workspace = "${i3.ws2}"; - output = "DP"; - } - { - workspace = "${i3.ws3}"; - output = "HDMI"; - } - { - workspace = "${i3.ws4}"; - output = "DVI"; - } - ]; - }; - - nixpkgs.overlays = [ (import ./i3-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/i3/config - assertFileContent home-files/.config/i3/config \ - ${./i3-workspace-output-expected.conf} - ''; +let + i3 = { + ws1 = "1"; + ws2 = "ABC"; + ws3 = "3: Test"; + ws4 = ''!"§$%&/(){}[]=?\*#<>-_.:,;²³''; }; + +in { + imports = [ ./i3-stubs.nix ]; + + xsession.windowManager.i3 = { + enable = true; + + config.workspaceOutputAssign = [ + { + workspace = "${i3.ws1}"; + output = "eDP"; + } + { + workspace = "${i3.ws2}"; + output = "DP"; + } + { + workspace = "${i3.ws3}"; + output = "HDMI"; + } + { + workspace = "${i3.ws4}"; + output = "DVI"; + } + ]; + }; + + nmt.script = '' + assertFileExists home-files/.config/i3/config + assertFileContent home-files/.config/i3/config \ + ${./i3-workspace-output-expected.conf} + ''; } diff --git a/tests/modules/services/window-managers/sway/sway-bar-focused-colors.conf b/tests/modules/services/window-managers/sway/sway-bar-focused-colors.conf index dc8319d6b..558e579ae 100644 --- a/tests/modules/services/window-managers/sway/sway-bar-focused-colors.conf +++ b/tests/modules/services/window-managers/sway/sway-bar-focused-colors.conf @@ -90,7 +90,7 @@ bar { hidden_state hide position bottom status_command @i3status@/bin/i3status - swaybar_command @sway/bin/swaybar + swaybar_command @sway@/bin/swaybar workspace_buttons yes strip_workspace_numbers no tray_output primary diff --git a/tests/modules/services/window-managers/sway/sway-bar-focused-colors.nix b/tests/modules/services/window-managers/sway/sway-bar-focused-colors.nix index 8b3df36ef..9746d0503 100644 --- a/tests/modules/services/window-managers/sway/sway-bar-focused-colors.nix +++ b/tests/modules/services/window-managers/sway/sway-bar-focused-colors.nix @@ -1,32 +1,24 @@ { config, lib, pkgs, ... }: -with lib; +{ + imports = [ ./sway-stubs.nix ]; -let + wayland.windowManager.sway = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@sway@"; }; + # overriding findutils causes issues + config.menu = "${pkgs.dmenu}/bin/dmenu_run"; - dummy-package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out"; - -in { - config = { - wayland.windowManager.sway = { - enable = true; - package = dummy-package // { outPath = "@sway"; }; - # overriding findutils causes issues - config.menu = "${pkgs.dmenu}/bin/dmenu_run"; - - config.bars = [{ - colors.focusedBackground = "#ffffff"; - colors.focusedStatusline = "#000000"; - colors.focusedSeparator = "#999999"; - }]; - }; - - nixpkgs.overlays = [ (import ./sway-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/sway/config - assertFileContent home-files/.config/sway/config \ - ${./sway-bar-focused-colors.conf} - ''; + config.bars = [{ + colors.focusedBackground = "#ffffff"; + colors.focusedStatusline = "#000000"; + colors.focusedSeparator = "#999999"; + }]; }; + + nmt.script = '' + assertFileExists home-files/.config/sway/config + assertFileContent home-files/.config/sway/config \ + ${./sway-bar-focused-colors.conf} + ''; } diff --git a/tests/modules/services/window-managers/sway/sway-bindkeys-to-code.conf b/tests/modules/services/window-managers/sway/sway-bindkeys-to-code.conf index 609b0b025..7879ceab1 100644 --- a/tests/modules/services/window-managers/sway/sway-bindkeys-to-code.conf +++ b/tests/modules/services/window-managers/sway/sway-bindkeys-to-code.conf @@ -90,7 +90,7 @@ bar { hidden_state hide position bottom status_command @i3status@/bin/i3status - swaybar_command @sway/bin/swaybar + swaybar_command @sway@/bin/swaybar workspace_buttons yes strip_workspace_numbers no tray_output primary diff --git a/tests/modules/services/window-managers/sway/sway-bindkeys-to-code.nix b/tests/modules/services/window-managers/sway/sway-bindkeys-to-code.nix index bdcc4dc1b..5e62748cb 100644 --- a/tests/modules/services/window-managers/sway/sway-bindkeys-to-code.nix +++ b/tests/modules/services/window-managers/sway/sway-bindkeys-to-code.nix @@ -1,27 +1,19 @@ { config, lib, pkgs, ... }: -with lib; +{ + imports = [ ./sway-stubs.nix ]; -let - - dummy-package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out"; - -in { - config = { - wayland.windowManager.sway = { - enable = true; - package = dummy-package // { outPath = "@sway"; }; - # overriding findutils causes issues - config.menu = "${pkgs.dmenu}/bin/dmenu_run"; - config.bindkeysToCode = true; - }; - - nixpkgs.overlays = [ (import ./sway-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/sway/config - assertFileContent home-files/.config/sway/config \ - ${./sway-bindkeys-to-code.conf} - ''; + wayland.windowManager.sway = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@sway@"; }; + # overriding findutils causes issues + config.menu = "${pkgs.dmenu}/bin/dmenu_run"; + config.bindkeysToCode = true; }; + + nmt.script = '' + assertFileExists home-files/.config/sway/config + assertFileContent home-files/.config/sway/config \ + ${./sway-bindkeys-to-code.conf} + ''; } diff --git a/tests/modules/services/window-managers/sway/sway-default.conf b/tests/modules/services/window-managers/sway/sway-default.conf index cbcd2d832..1cd75fd52 100644 --- a/tests/modules/services/window-managers/sway/sway-default.conf +++ b/tests/modules/services/window-managers/sway/sway-default.conf @@ -90,7 +90,7 @@ bar { hidden_state hide position bottom status_command @i3status@/bin/i3status - swaybar_command @sway/bin/swaybar + swaybar_command @sway@/bin/swaybar workspace_buttons yes strip_workspace_numbers no tray_output primary diff --git a/tests/modules/services/window-managers/sway/sway-default.nix b/tests/modules/services/window-managers/sway/sway-default.nix index 141f6303e..7bd437317 100644 --- a/tests/modules/services/window-managers/sway/sway-default.nix +++ b/tests/modules/services/window-managers/sway/sway-default.nix @@ -1,26 +1,18 @@ { config, lib, pkgs, ... }: -with lib; +{ + imports = [ ./sway-stubs.nix ]; -let - - dummy-package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out"; - -in { - config = { - wayland.windowManager.sway = { - enable = true; - package = dummy-package // { outPath = "@sway"; }; - # overriding findutils causes issues - config.menu = "${pkgs.dmenu}/bin/dmenu_run"; - }; - - nixpkgs.overlays = [ (import ./sway-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/sway/config - assertFileContent home-files/.config/sway/config \ - ${./sway-default.conf} - ''; + wayland.windowManager.sway = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@sway@"; }; + # overriding findutils causes issues + config.menu = "${pkgs.dmenu}/bin/dmenu_run"; }; + + nmt.script = '' + assertFileExists home-files/.config/sway/config + assertFileContent home-files/.config/sway/config \ + ${./sway-default.conf} + ''; } diff --git a/tests/modules/services/window-managers/sway/sway-followmouse-legacy.nix b/tests/modules/services/window-managers/sway/sway-followmouse-legacy.nix index b83c8d1ba..ce69d9f7f 100644 --- a/tests/modules/services/window-managers/sway/sway-followmouse-legacy.nix +++ b/tests/modules/services/window-managers/sway/sway-followmouse-legacy.nix @@ -2,29 +2,23 @@ with lib; -let +{ + imports = [ ./sway-stubs.nix ]; - dummy-package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out"; + wayland.windowManager.sway = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@sway@"; }; -in { - config = { - wayland.windowManager.sway = { - enable = true; - package = dummy-package // { outPath = "@sway"; }; - - config = { - focus.followMouse = false; - menu = "${pkgs.dmenu}/bin/dmenu_run"; - bars = [ ]; - }; + config = { + focus.followMouse = false; + menu = "${pkgs.dmenu}/bin/dmenu_run"; + bars = [ ]; }; - - nixpkgs.overlays = [ (import ./sway-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/sway/config - assertFileContent home-files/.config/sway/config \ - ${./sway-followmouse-legacy-expected.conf} - ''; }; + + nmt.script = '' + assertFileExists home-files/.config/sway/config + assertFileContent home-files/.config/sway/config \ + ${./sway-followmouse-legacy-expected.conf} + ''; } diff --git a/tests/modules/services/window-managers/sway/sway-followmouse.nix b/tests/modules/services/window-managers/sway/sway-followmouse.nix index 9d18b6913..7065dd1ca 100644 --- a/tests/modules/services/window-managers/sway/sway-followmouse.nix +++ b/tests/modules/services/window-managers/sway/sway-followmouse.nix @@ -1,30 +1,22 @@ { config, lib, pkgs, ... }: -with lib; +{ + imports = [ ./sway-stubs.nix ]; -let + wayland.windowManager.sway = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@sway@"; }; - dummy-package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out"; - -in { - config = { - wayland.windowManager.sway = { - enable = true; - package = dummy-package // { outPath = "@sway"; }; - - config = { - focus.followMouse = "always"; - menu = "${pkgs.dmenu}/bin/dmenu_run"; - bars = [ ]; - }; + config = { + focus.followMouse = "always"; + menu = "${pkgs.dmenu}/bin/dmenu_run"; + bars = [ ]; }; - - nixpkgs.overlays = [ (import ./sway-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/sway/config - assertFileContent home-files/.config/sway/config \ - ${./sway-followmouse-expected.conf} - ''; }; + + nmt.script = '' + assertFileExists home-files/.config/sway/config + assertFileContent home-files/.config/sway/config \ + ${./sway-followmouse-expected.conf} + ''; } diff --git a/tests/modules/services/window-managers/sway/sway-modules.conf b/tests/modules/services/window-managers/sway/sway-modules.conf index ee6333054..1cec60e8b 100644 --- a/tests/modules/services/window-managers/sway/sway-modules.conf +++ b/tests/modules/services/window-managers/sway/sway-modules.conf @@ -102,7 +102,7 @@ bar { hidden_state hide position bottom status_command @i3status@/bin/i3status - swaybar_command @sway/bin/swaybar + swaybar_command @sway@/bin/swaybar workspace_buttons yes strip_workspace_numbers no tray_output primary diff --git a/tests/modules/services/window-managers/sway/sway-modules.nix b/tests/modules/services/window-managers/sway/sway-modules.nix index fbe927f35..96366ab0a 100644 --- a/tests/modules/services/window-managers/sway/sway-modules.nix +++ b/tests/modules/services/window-managers/sway/sway-modules.nix @@ -1,32 +1,24 @@ { config, lib, pkgs, ... }: -with lib; +{ + imports = [ ./sway-stubs.nix ]; -let + wayland.windowManager.sway = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@sway@"; }; + # overriding findutils causes issues + config = { + menu = "${pkgs.dmenu}/bin/dmenu_run"; - dummy-package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out"; - -in { - config = { - wayland.windowManager.sway = { - enable = true; - package = dummy-package // { outPath = "@sway"; }; - # overriding findutils causes issues - config = { - menu = "${pkgs.dmenu}/bin/dmenu_run"; - - input = { "*" = { xkb_variant = "dvorak"; }; }; - output = { "HDMI-A-2" = { bg = "~/path/to/background.png fill"; }; }; - seat = { "*" = { hide_cursor = "when-typing enable"; }; }; - }; + input = { "*" = { xkb_variant = "dvorak"; }; }; + output = { "HDMI-A-2" = { bg = "~/path/to/background.png fill"; }; }; + seat = { "*" = { hide_cursor = "when-typing enable"; }; }; }; - - nixpkgs.overlays = [ (import ./sway-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/sway/config - assertFileContent home-files/.config/sway/config \ - ${./sway-modules.conf} - ''; }; + + nmt.script = '' + assertFileExists home-files/.config/sway/config + assertFileContent home-files/.config/sway/config \ + ${./sway-modules.conf} + ''; } diff --git a/tests/modules/services/window-managers/sway/sway-null-config.nix b/tests/modules/services/window-managers/sway/sway-null-config.nix index fc01660cb..4033903d3 100644 --- a/tests/modules/services/window-managers/sway/sway-null-config.nix +++ b/tests/modules/services/window-managers/sway/sway-null-config.nix @@ -1,22 +1,18 @@ { config, lib, pkgs, ... }: -with lib; - { - config = { - wayland.windowManager.sway = { - enable = true; - config = null; - systemdIntegration = false; - package = pkgs.sway; - }; + imports = [ ./sway-stubs.nix ]; - nixpkgs.overlays = [ (import ./sway-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/sway/config - assertFileContent home-files/.config/sway/config \ - ${pkgs.writeText "expected" "\n"} - ''; + wayland.windowManager.sway = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@sway@"; }; + config = null; + systemdIntegration = false; }; + + nmt.script = '' + assertFileExists home-files/.config/sway/config + assertFileContent home-files/.config/sway/config \ + ${pkgs.writeText "expected" "\n"} + ''; } diff --git a/tests/modules/services/window-managers/sway/sway-null-package.nix b/tests/modules/services/window-managers/sway/sway-null-package.nix index 3993d6389..fe2a45196 100644 --- a/tests/modules/services/window-managers/sway/sway-null-package.nix +++ b/tests/modules/services/window-managers/sway/sway-null-package.nix @@ -1,35 +1,27 @@ { config, lib, pkgs, ... }: -with lib; +{ + imports = [ ./sway-stubs.nix ]; -let + # Enables the default bar configuration + home.stateVersion = "20.09"; - dummy-package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out"; - -in { - config = { - # Enables the default bar configuration - home.stateVersion = "20.09"; - - wayland.windowManager.sway = { - enable = true; - package = null; - config.menu = "${pkgs.dmenu}/bin/dmenu_run"; - }; - - nixpkgs.overlays = [ (import ./sway-overlay.nix) ]; - - assertions = [{ - assertion = - !elem config.wayland.windowManager.sway.config.bars [ [ { } ] [ ] ]; - message = - "The default Sway bars configuration should be set for this test (sway-null-package) to work."; - }]; - - nmt.script = '' - assertFileExists home-files/.config/sway/config - assertFileContent home-files/.config/sway/config \ - ${./sway-null-package.conf} - ''; + wayland.windowManager.sway = { + enable = true; + package = null; + config.menu = "${pkgs.dmenu}/bin/dmenu_run"; }; + + assertions = [{ + assertion = + !lib.elem config.wayland.windowManager.sway.config.bars [ [ { } ] [ ] ]; + message = + "The default Sway bars configuration should be set for this test (sway-null-package) to work."; + }]; + + nmt.script = '' + assertFileExists home-files/.config/sway/config + assertFileContent home-files/.config/sway/config \ + ${./sway-null-package.conf} + ''; } diff --git a/tests/modules/services/window-managers/sway/sway-overlay.nix b/tests/modules/services/window-managers/sway/sway-overlay.nix deleted file mode 100644 index 4edfb2055..000000000 --- a/tests/modules/services/window-managers/sway/sway-overlay.nix +++ /dev/null @@ -1,17 +0,0 @@ -self: super: -# Avoid unnecessary downloads in CI jobs. -let dummy-package = super.runCommandLocal "dummy-package" { } "mkdir $out"; -in { - dmenu = dummy-package // { outPath = "@dmenu@"; }; - rxvt-unicode-unwrapped = dummy-package // { - outPath = "@rxvt-unicode-unwrapped@"; - }; - i3status = dummy-package // { outPath = "@i3status@"; }; - sway = dummy-package // { outPath = "@sway@"; }; - sway-unwrapped = dummy-package // { - outPath = "@sway-unwrapped@"; - version = "1"; - }; - swaybg = dummy-package // { outPath = "@swaybg@"; }; - xwayland = dummy-package // { outPath = "@xwayland@"; }; -} diff --git a/tests/modules/services/window-managers/sway/sway-post-2003.nix b/tests/modules/services/window-managers/sway/sway-post-2003.nix index ddcf2b234..7596250ec 100644 --- a/tests/modules/services/window-managers/sway/sway-post-2003.nix +++ b/tests/modules/services/window-managers/sway/sway-post-2003.nix @@ -1,28 +1,20 @@ { config, lib, pkgs, ... }: -with lib; +{ + imports = [ ./sway-stubs.nix ]; -let + home.stateVersion = "20.09"; - dummy-package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out"; - -in { - config = { - home.stateVersion = "20.09"; - - wayland.windowManager.sway = { - enable = true; - package = dummy-package // { outPath = "@sway"; }; - # overriding findutils causes issues - config.menu = "${pkgs.dmenu}/bin/dmenu_run"; - }; - - nixpkgs.overlays = [ (import ./sway-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/sway/config - assertFileContent home-files/.config/sway/config \ - ${./sway-default.conf} - ''; + wayland.windowManager.sway = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@sway@"; }; + # overriding findutils causes issues + config.menu = "${pkgs.dmenu}/bin/dmenu_run"; }; + + nmt.script = '' + assertFileExists home-files/.config/sway/config + assertFileContent home-files/.config/sway/config \ + ${./sway-default.conf} + ''; } diff --git a/tests/modules/services/window-managers/sway/sway-stubs.nix b/tests/modules/services/window-managers/sway/sway-stubs.nix new file mode 100644 index 000000000..55a74e1c4 --- /dev/null +++ b/tests/modules/services/window-managers/sway/sway-stubs.nix @@ -0,0 +1,13 @@ +{ + # Avoid unnecessary downloads in CI jobs and/or make out paths constant, i.e., + # not containing hashes, version numbers etc. + test.stubs = { + dmenu = { }; + rxvt-unicode-unwrapped = { }; + i3status = { }; + sway = { }; + sway-unwrapped = { version = "1"; }; + swaybg = { }; + xwayland = { }; + }; +} diff --git a/tests/modules/services/window-managers/sway/sway-workspace-default-expected.conf b/tests/modules/services/window-managers/sway/sway-workspace-default-expected.conf index 9441bf5cf..7aa1e1e47 100644 --- a/tests/modules/services/window-managers/sway/sway-workspace-default-expected.conf +++ b/tests/modules/services/window-managers/sway/sway-workspace-default-expected.conf @@ -89,7 +89,7 @@ bar { hidden_state hide position bottom status_command @i3status@/bin/i3status - swaybar_command @sway/bin/swaybar + swaybar_command @sway@/bin/swaybar workspace_buttons yes strip_workspace_numbers no tray_output primary diff --git a/tests/modules/services/window-managers/sway/sway-workspace-default.nix b/tests/modules/services/window-managers/sway/sway-workspace-default.nix index 52f4f3ec1..d94110980 100644 --- a/tests/modules/services/window-managers/sway/sway-workspace-default.nix +++ b/tests/modules/services/window-managers/sway/sway-workspace-default.nix @@ -1,27 +1,19 @@ { config, lib, pkgs, ... }: -with lib; +{ + imports = [ ./sway-stubs.nix ]; -let - - dummy-package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out"; - -in { - config = { - wayland.windowManager.sway = { - enable = true; - package = dummy-package // { outPath = "@sway"; }; - # overriding findutils causes issues - config.menu = "${pkgs.dmenu}/bin/dmenu_run"; - config.defaultWorkspace = "workspace number 9"; - }; - - nixpkgs.overlays = [ (import ./sway-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/sway/config - assertFileContent home-files/.config/sway/config \ - ${./sway-workspace-default-expected.conf} - ''; + wayland.windowManager.sway = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@sway@"; }; + # overriding findutils causes issues + config.menu = "${pkgs.dmenu}/bin/dmenu_run"; + config.defaultWorkspace = "workspace number 9"; }; + + nmt.script = '' + assertFileExists home-files/.config/sway/config + assertFileContent home-files/.config/sway/config \ + ${./sway-workspace-default-expected.conf} + ''; } diff --git a/tests/modules/services/window-managers/sway/sway-workspace-output-expected.conf b/tests/modules/services/window-managers/sway/sway-workspace-output-expected.conf index 6ef9f6d13..e4a4f6cfd 100644 --- a/tests/modules/services/window-managers/sway/sway-workspace-output-expected.conf +++ b/tests/modules/services/window-managers/sway/sway-workspace-output-expected.conf @@ -90,7 +90,7 @@ bar { hidden_state hide position bottom status_command @i3status@/bin/i3status - swaybar_command @sway/bin/swaybar + swaybar_command @sway@/bin/swaybar workspace_buttons yes strip_workspace_numbers no tray_output primary diff --git a/tests/modules/services/window-managers/sway/sway-workspace-output.nix b/tests/modules/services/window-managers/sway/sway-workspace-output.nix index 5791a3da4..ce51c1f51 100644 --- a/tests/modules/services/window-managers/sway/sway-workspace-output.nix +++ b/tests/modules/services/window-managers/sway/sway-workspace-output.nix @@ -1,53 +1,45 @@ { config, lib, pkgs, ... }: -with lib; - let - - dummy-package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out"; + i3 = { + ws1 = "1"; + ws2 = "ABC"; + ws3 = "3: Test"; + ws4 = ''!"§$%&/(){}[]=?\*#<>-_.:,;²³''; + }; in { - config = let - i3 = { - ws1 = "1"; - ws2 = "ABC"; - ws3 = "3: Test"; - ws4 = ''!"§$%&/(){}[]=?\*#<>-_.:,;²³''; - }; + imports = [ ./sway-stubs.nix ]; - in { - wayland.windowManager.sway = { - enable = true; - package = dummy-package // { outPath = "@sway"; }; - # overriding findutils causes issues - config.menu = "${pkgs.dmenu}/bin/dmenu_run"; + wayland.windowManager.sway = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@sway@"; }; + # overriding findutils causes issues + config.menu = "${pkgs.dmenu}/bin/dmenu_run"; - config.workspaceOutputAssign = [ - { - workspace = "${i3.ws1}"; - output = "eDP"; - } - { - workspace = "${i3.ws2}"; - output = "DP"; - } - { - workspace = "${i3.ws3}"; - output = "HDMI"; - } - { - workspace = "${i3.ws4}"; - output = "DVI"; - } - ]; - }; - - nixpkgs.overlays = [ (import ./sway-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/sway/config - assertFileContent home-files/.config/sway/config \ - ${./sway-workspace-output-expected.conf} - ''; + config.workspaceOutputAssign = [ + { + workspace = "${i3.ws1}"; + output = "eDP"; + } + { + workspace = "${i3.ws2}"; + output = "DP"; + } + { + workspace = "${i3.ws3}"; + output = "HDMI"; + } + { + workspace = "${i3.ws4}"; + output = "DVI"; + } + ]; }; + + nmt.script = '' + assertFileExists home-files/.config/sway/config + assertFileContent home-files/.config/sway/config \ + ${./sway-workspace-output-expected.conf} + ''; } diff --git a/tests/modules/services/wlsunset/wlsunset-service.nix b/tests/modules/services/wlsunset/wlsunset-service.nix index de32a8270..e3f816505 100644 --- a/tests/modules/services/wlsunset/wlsunset-service.nix +++ b/tests/modules/services/wlsunset/wlsunset-service.nix @@ -4,9 +4,7 @@ config = { services.wlsunset = { enable = true; - package = pkgs.writeScriptBin "dummy-wlsunset" "" // { - outPath = "@wlsunset@"; - }; + package = config.lib.test.mkStubPackage { outPath = "@wlsunset@"; }; latitude = "12.3"; longitude = "128.8"; temperature.day = 6000; diff --git a/tests/stubs.nix b/tests/stubs.nix new file mode 100644 index 000000000..01f460654 --- /dev/null +++ b/tests/stubs.nix @@ -0,0 +1,61 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + stubType = types.submodule ({ name, ... }: { + options = { + name = mkOption { + type = types.str; + default = "dummy"; + description = "The stub package name."; + }; + + outPath = mkOption { + type = types.nullOr types.str; + default = "@${name}@"; + defaultText = "@\${name}@"; + }; + + version = mkOption { + type = types.nullOr types.str; + default = null; + }; + + buildScript = mkOption { + type = types.str; + default = defaultBuildScript; + }; + }; + }); + + defaultBuildScript = "mkdir $out"; + + dummyPackage = pkgs.runCommandLocal "dummy" { } defaultBuildScript; + + mkStubPackage = { name ? "dummy", outPath ? null, version ? null + , buildScript ? defaultBuildScript }: + let + pkg = if name == "dummy" && buildScript == defaultBuildScript then + dummyPackage + else + pkgs.runCommandLocal name { } buildScript; + in pkg // optionalAttrs (outPath != null) { inherit outPath; } + // optionalAttrs (version != null) { inherit version; }; + +in { + options.test.stubs = mkOption { + type = types.attrsOf stubType; + default = { }; + description = + "Package attributes that should be replaced by a stub package."; + }; + + config = { + lib.test.mkStubPackage = mkStubPackage; + + nixpkgs.overlays = mkIf (config.test.stubs != { }) + [ (self: super: mapAttrs (n: mkStubPackage) config.test.stubs) ]; + }; +}