diff --git a/tests/default.nix b/tests/default.nix index a773fd50..a6daa4c0 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 b29a94aa..59738fb0 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 4007552c..00000000 --- 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 00000000..cdf707de --- /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 4ac7299a..a49cc44e 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 41de2877..a0899838 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 aa468c21..5616de1c 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 e9aa1a25..80baeae6 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 ad04acd2..f8b096fb 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 3cb02a26..e89ad7da 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 65470473..ecc6df35 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 c3671aa0..61b8b4b4 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 1b8559d6..c7962fb5 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 3f74ef21..6316fbd7 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 0b5a52d9..346de967 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 2f667027..2cca7de8 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 fad18f75..c28edaa2 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 9092e61d..095778a4 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 2860d1e6..e9861292 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 bedcf212..71799c83 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 3635bd19..30d8e21b 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 88b13974..a2dddca3 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 f6b9e5b6..787b02d7 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 ad0d1515..62feb823 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 9bca418e..67f8ba0d 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 7cd2966e..0ab38a09 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 61e1603f..6b02dd46 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 3935fd9d..26b82e7f 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 c2306382..8390305e 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 1eff14f9..5ebd9067 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 71fd74d3..432437f9 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 5417f7ea..6c732060 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 44d95cb3..bb58983f 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 ce5385d1..827a09be 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 ae4e437f..b8e43600 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 412b8c7d..71685434 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 7a6ebe8d..2f4b3e86 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 4ced6add..b53963dd 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 b62c248c..4a0d4a4c 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 16f3428a..4a044273 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 9cbbe285..eab7f42d 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 4aa01773..830bc6c9 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 0b7e4ee2..d56ecc20 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 d7b9ff1e..0eced168 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 1f3b82b9..8d609a5a 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 a25467a2..35d7901d 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 b3c26ba9..078c776e 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 524a41a3..c948cf0b 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 c19521d1..5e784746 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 7ff4a890..6af57d28 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 5701d9ea..9bb53e57 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 f7fd390a..1c4a80c1 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 5262f031..f977bdde 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 e5134002..55436650 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 02a1f09c..a85ea552 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 dce98b28..64d78d27 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 4c129e94..f753826f 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 db724660..0e874c22 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 10e9791d..ccf5444a 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 529d2847..54012e9d 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 bd40cd89..64ebf80f 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 164e4b58..2eed5358 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 1d5db5f9..48b2197d 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 9478a911..fd4fedf0 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 d4419d93..08c8f5bf 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 587a31bb..26d5f4b3 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 e7a17c5d..ec0f3372 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 e6eb4151..fe7f8507 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 b3b869cb..0fa6ee79 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 33a5de2d..1ae46df5 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 09c192b3..7eef0909 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 945bde73..34017d88 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 7009c8c2..b7891bbf 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 0ed88215..161499c9 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 1236c058..a719d9f7 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 30d1856c..1491a1e6 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 e9bedcaa..dca6ae6f 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 3e4c821d..aa25c876 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 f10b1955..00000000 --- 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 00000000..c48d88be --- /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 de08ec83..8cf9572b 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 4e05b69f..becf9fad 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 a1161dbd..2028e840 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 02bd06c1..300e89db 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 087ca472..a62faf73 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 2d318a4e..99c9a989 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 efcb1acd..84c74152 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 96314e7a..ddc40773 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 90e0034b..5854fdd6 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 b27f6ca8..d132945f 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 9ccf3953..04499f15 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 4c506c9e..c3517cae 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 1ae06fdc..50b9c42e 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 a7436b5e..a8f5c6d1 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 1756ae12..1297f557 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 bd73f2aa..6e34847e 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 e751d804..eff5af9c 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 f7912dba..e844cc61 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 99ed57de..bbd9420e 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 704c5c5e..373b6b88 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 ba423efe..68be58fe 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 0c052d69..1a691f1c 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 6d1f58a2..06fe88d0 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 f5b178b5..42a85d00 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 d880d966..490a2715 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 5bc95510..922112ef 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 5c322be1..638b41c9 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 83a9365e..03b1beae 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 eb576b9f..2072d4d8 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 96a17cd7..9b8a6d65 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 9115eb0d..7fbfa79c 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 3685637d..16b591ff 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 5a9d7e03..3be88d78 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 05859277..7efa0643 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 2e9ec9ad..0e9c7ad6 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 f7ebf573..1b4333e1 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 6705a001..6c231a3b 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 15fbbb9c..b8cd5d21 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 8437b989..1d282eb9 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 af3074b0..f624ae82 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 f04101c0..ac36c0b8 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 fb03c355..46502453 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 fd23256c..b6374acd 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 9ccf3852..6f0454bf 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 5e2fe40e..691d01e2 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 e9d85477..9e996505 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 44bed425..84f3086a 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 9f9dc2ba..ca018c2d 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 23632331..3020e631 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 aaa6809f..66b4ca87 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 c5142ed4..7e4532e5 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 20ea5cab..3618451f 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 bc3cae6e..2137c53e 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 a9b37882..1c221319 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 fead262f..00000000 --- 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 00000000..cfb892ac --- /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 0a825b1e..521b5f5d 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 b2ff90e0..df4a2c78 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 dc8319d6..558e579a 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 8b3df36e..9746d050 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 609b0b02..7879ceab 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 bdcc4dc1..5e62748c 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 cbcd2d83..1cd75fd5 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 141f6303..7bd43731 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 b83c8d1b..ce69d9f7 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 9d18b691..7065dd1c 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 ee633305..1cec60e8 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 fbe927f3..96366ab0 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 fc01660c..4033903d 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 3993d638..fe2a4519 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 4edfb205..00000000 --- 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 ddcf2b23..7596250e 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 00000000..55a74e1c --- /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 9441bf5c..7aa1e1e4 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 52f4f3ec..d9411098 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 6ef9f6d1..e4a4f6cf 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 5791a3da..ce51c1f5 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 de32a827..e3f81650 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 00000000..01f46065 --- /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) ]; + }; +}