diff --git a/tests/modules/files/executable.nix b/tests/modules/files/executable.nix index b286c2b4..9ab8f359 100644 --- a/tests/modules/files/executable.nix +++ b/tests/modules/files/executable.nix @@ -1,17 +1,13 @@ -{ config, lib, ... }: - -with lib; +{ ... }: { - config = { - home.file."executable" = { - text = ""; - executable = true; - }; - - nmt.script = '' - assertFileExists home-files/executable - assertFileIsExecutable home-files/executable; - ''; + home.file."executable" = { + text = ""; + executable = true; }; + + nmt.script = '' + assertFileExists home-files/executable + assertFileIsExecutable home-files/executable; + ''; } diff --git a/tests/modules/files/hidden-source.nix b/tests/modules/files/hidden-source.nix index 8169fedc..380a2cb2 100644 --- a/tests/modules/files/hidden-source.nix +++ b/tests/modules/files/hidden-source.nix @@ -1,19 +1,15 @@ -{ config, lib, ... }: - -with lib; +{ ... }: { - config = { - home.file.".hidden".source = ./.hidden; + home.file.".hidden".source = ./.hidden; - nmt.script = '' - assertFileExists home-files/.hidden; - assertFileContent home-files/.hidden ${ - builtins.path { - path = ./.hidden; - name = "expected"; - } + nmt.script = '' + assertFileExists home-files/.hidden; + assertFileContent home-files/.hidden ${ + builtins.path { + path = ./.hidden; + name = "expected"; } - ''; - }; + } + ''; } diff --git a/tests/modules/files/out-of-store-symlink.nix b/tests/modules/files/out-of-store-symlink.nix index af274aae..15a70fa7 100644 --- a/tests/modules/files/out-of-store-symlink.nix +++ b/tests/modules/files/out-of-store-symlink.nix @@ -1,29 +1,25 @@ -{ config, lib, ... }: - -with lib; +{ config, ... }: let filePath = ./. + "/source with spaces!"; in { - config = { - home.file."oos".source = config.lib.file.mkOutOfStoreSymlink filePath; + home.file."oos".source = config.lib.file.mkOutOfStoreSymlink filePath; - nmt.script = '' - assertLinkExists "home-files/oos" + nmt.script = '' + assertLinkExists "home-files/oos" - storePath="$(readlink $TESTED/home-files/oos)" + storePath="$(readlink $TESTED/home-files/oos)" - if [[ ! -L $storePath ]]; then - fail "Expected $storePath to be a symbolic link, but it was not." - fi + if [[ ! -L $storePath ]]; then + fail "Expected $storePath to be a symbolic link, but it was not." + fi - actual="$(readlink "$storePath")" - expected="${toString filePath}" - if [[ $actual != $expected ]]; then - fail "Symlink home-files/oos should point to $expected via the Nix store, but it actually points to $actual." - fi - ''; - }; + actual="$(readlink "$storePath")" + expected="${toString filePath}" + if [[ $actual != $expected ]]; then + fail "Symlink home-files/oos should point to $expected via the Nix store, but it actually points to $actual." + fi + ''; } diff --git a/tests/modules/files/source-with-spaces.nix b/tests/modules/files/source-with-spaces.nix index 1d593c64..cd78664e 100644 --- a/tests/modules/files/source-with-spaces.nix +++ b/tests/modules/files/source-with-spaces.nix @@ -1,20 +1,16 @@ -{ config, lib, ... }: - -with lib; +{ ... }: { - config = { - home.file."source with spaces!".source = ./. + "/source with spaces!"; + home.file."source with spaces!".source = ./. + "/source with spaces!"; - nmt.script = '' - assertFileExists 'home-files/source with spaces!'; - assertFileContent 'home-files/source with spaces!' \ - ${ - builtins.path { - path = ./. + "/source with spaces!"; - name = "source-with-spaces-expected"; - } + nmt.script = '' + assertFileExists 'home-files/source with spaces!'; + assertFileContent 'home-files/source with spaces!' \ + ${ + builtins.path { + path = ./. + "/source with spaces!"; + name = "source-with-spaces-expected"; } - ''; - }; + } + ''; } diff --git a/tests/modules/files/target-conflict.nix b/tests/modules/files/target-conflict.nix index dbcee80a..9677cf9d 100644 --- a/tests/modules/files/target-conflict.nix +++ b/tests/modules/files/target-conflict.nix @@ -1,26 +1,24 @@ { ... }: { - config = { - home.file = { - conflict1 = { - text = ""; - target = "baz"; - }; - conflict2 = { - source = ./target-conflict.nix; - target = "baz"; - }; + home.file = { + conflict1 = { + text = ""; + target = "baz"; + }; + conflict2 = { + source = ./target-conflict.nix; + target = "baz"; }; - - test.asserts.assertions.expected = ['' - Conflicting managed target files: baz - - This may happen, for example, if you have a configuration similar to - - home.file = { - conflict1 = { source = ./foo.nix; target = "baz"; }; - conflict2 = { source = ./bar.nix; target = "baz"; }; - }'']; }; + + test.asserts.assertions.expected = ['' + Conflicting managed target files: baz + + This may happen, for example, if you have a configuration similar to + + home.file = { + conflict1 = { source = ./foo.nix; target = "baz"; }; + conflict2 = { source = ./bar.nix; target = "baz"; }; + }'']; } diff --git a/tests/modules/files/target-with-shellvar.nix b/tests/modules/files/target-with-shellvar.nix index c54946eb..59fc02fd 100644 --- a/tests/modules/files/target-with-shellvar.nix +++ b/tests/modules/files/target-with-shellvar.nix @@ -1,15 +1,11 @@ -{ config, lib, pkgs, ... }: - -with lib; +{ ... }: { - config = { - home.file."$HOME/$FOO/bar baz".text = "blah"; + home.file."$HOME/$FOO/bar baz".text = "blah"; - nmt.script = '' - assertFileExists 'home-files/$HOME/$FOO/bar baz'; - assertFileContent 'home-files/$HOME/$FOO/bar baz' \ - ${pkgs.writeText "expected" "blah"} - ''; - }; + nmt.script = '' + assertFileExists 'home-files/$HOME/$FOO/bar baz'; + assertFileContent 'home-files/$HOME/$FOO/bar baz' \ + ${builtins.toFile "expected" "blah"} + ''; } diff --git a/tests/modules/files/text.nix b/tests/modules/files/text.nix index 6fc9a26f..c09c56c4 100644 --- a/tests/modules/files/text.nix +++ b/tests/modules/files/text.nix @@ -1,18 +1,14 @@ -{ config, lib, ... }: - -with lib; +{ ... }: { - config = { - home.file."using-text".text = '' - This is the - expected text. - ''; + home.file."using-text".text = '' + This is the + expected text. + ''; - nmt.script = '' - assertFileExists home-files/using-text - assertFileIsNotExecutable home-files/using-text - assertFileContent home-files/using-text ${./text-expected.txt} - ''; - }; + nmt.script = '' + assertFileExists home-files/using-text + assertFileIsNotExecutable home-files/using-text + assertFileContent home-files/using-text ${./text-expected.txt} + ''; } diff --git a/tests/modules/programs/borgmatic/basic-configuration.nix b/tests/modules/programs/borgmatic/basic-configuration.nix index b9988d47..f27b84b8 100644 --- a/tests/modules/programs/borgmatic/basic-configuration.nix +++ b/tests/modules/programs/borgmatic/basic-configuration.nix @@ -1,116 +1,116 @@ { config, pkgs, ... }: let + boolToString = bool: if bool then "true" else "false"; backups = config.programs.borgmatic.backups; + in { - config = { - programs.borgmatic = { - enable = true; - backups = { - main = { - location = { - sourceDirectories = [ "/my-stuff-to-backup" ]; - repositories = [ "/mnt/disk1" "/mnt/disk2" ]; - extraConfig = { - one_file_system = true; - exclude_patterns = [ "*.swp" ]; - }; + programs.borgmatic = { + enable = true; + backups = { + main = { + location = { + sourceDirectories = [ "/my-stuff-to-backup" ]; + repositories = [ "/mnt/disk1" "/mnt/disk2" ]; + extraConfig = { + one_file_system = true; + exclude_patterns = [ "*.swp" ]; }; + }; - storage = { - encryptionPasscommand = "fetch-the-password.sh"; - extraConfig = { checkpoint_interval = 200; }; - }; + storage = { + encryptionPasscommand = "fetch-the-password.sh"; + extraConfig = { checkpoint_interval = 200; }; + }; - retention = { - keepWithin = "14d"; - keepSecondly = 12; - extraConfig = { prefix = "hostname"; }; - }; + retention = { + keepWithin = "14d"; + keepSecondly = 12; + extraConfig = { prefix = "hostname"; }; + }; - consistency = { - checks = [ - { - name = "repository"; - frequency = "2 weeks"; - } - { - name = "archives"; - frequency = "4 weeks"; - } - ]; + consistency = { + checks = [ + { + name = "repository"; + frequency = "2 weeks"; + } + { + name = "archives"; + frequency = "4 weeks"; + } + ]; - extraConfig = { prefix = "hostname"; }; - }; + extraConfig = { prefix = "hostname"; }; }; }; }; - - test.stubs.borgmatic = { }; - - nmt.script = '' - config_file=$TESTED/home-files/.config/borgmatic.d/main.yaml - assertFileExists $config_file - - declare -A expectations - - expectations[location.source_directories[0]]="${ - builtins.elemAt backups.main.location.sourceDirectories 0 - }" - expectations[location.repositories[0]]="${ - builtins.elemAt backups.main.location.repositories 0 - }" - expectations[location.repositories[1]]="${ - builtins.elemAt backups.main.location.repositories 1 - }" - expectations[location.one_file_system]="${ - boolToString backups.main.location.extraConfig.one_file_system - }" - expectations[location.exclude_patterns[0]]="${ - builtins.elemAt backups.main.location.extraConfig.exclude_patterns 0 - }" - - expectations[storage.encryption_passcommand]="${backups.main.storage.encryptionPasscommand}" - expectations[storage.checkpoint_interval]="${ - toString backups.main.storage.extraConfig.checkpoint_interval - }" - - expectations[retention.keep_within]="${backups.main.retention.keepWithin}" - expectations[retention.keep_secondly]="${ - toString backups.main.retention.keepSecondly - }" - expectations[retention.prefix]="${backups.main.retention.extraConfig.prefix}" - - expectations[consistency.checks[0].name]="${ - (builtins.elemAt backups.main.consistency.checks 0).name - }" - expectations[consistency.checks[0].frequency]="${ - (builtins.elemAt backups.main.consistency.checks 0).frequency - }" - expectations[consistency.checks[1].name]="${ - (builtins.elemAt backups.main.consistency.checks 1).name - }" - expectations[consistency.checks[1].frequency]="${ - (builtins.elemAt backups.main.consistency.checks 1).frequency - }" - expectations[consistency.prefix]="${backups.main.consistency.extraConfig.prefix}" - - yq=${pkgs.yq-go}/bin/yq - - for filter in "''${!expectations[@]}"; do - expected_value="''${expectations[$filter]}" - actual_value="$($yq ".$filter" $config_file)" - - if [[ "$actual_value" != "$expected_value" ]]; then - fail "Expected '$filter' to be '$expected_value' but was '$actual_value'" - fi - done - - one_file_system=$($yq ".location.one_file_system" $config_file) - if [[ $one_file_system != "true" ]]; then - fail "Expected one_file_system to be true but it was $one_file_system" - fi - ''; }; + + test.stubs.borgmatic = { }; + + nmt.script = '' + config_file=$TESTED/home-files/.config/borgmatic.d/main.yaml + assertFileExists $config_file + + declare -A expectations + + expectations[location.source_directories[0]]="${ + builtins.elemAt backups.main.location.sourceDirectories 0 + }" + expectations[location.repositories[0]]="${ + builtins.elemAt backups.main.location.repositories 0 + }" + expectations[location.repositories[1]]="${ + builtins.elemAt backups.main.location.repositories 1 + }" + expectations[location.one_file_system]="${ + boolToString backups.main.location.extraConfig.one_file_system + }" + expectations[location.exclude_patterns[0]]="${ + builtins.elemAt backups.main.location.extraConfig.exclude_patterns 0 + }" + + expectations[storage.encryption_passcommand]="${backups.main.storage.encryptionPasscommand}" + expectations[storage.checkpoint_interval]="${ + toString backups.main.storage.extraConfig.checkpoint_interval + }" + + expectations[retention.keep_within]="${backups.main.retention.keepWithin}" + expectations[retention.keep_secondly]="${ + toString backups.main.retention.keepSecondly + }" + expectations[retention.prefix]="${backups.main.retention.extraConfig.prefix}" + + expectations[consistency.checks[0].name]="${ + (builtins.elemAt backups.main.consistency.checks 0).name + }" + expectations[consistency.checks[0].frequency]="${ + (builtins.elemAt backups.main.consistency.checks 0).frequency + }" + expectations[consistency.checks[1].name]="${ + (builtins.elemAt backups.main.consistency.checks 1).name + }" + expectations[consistency.checks[1].frequency]="${ + (builtins.elemAt backups.main.consistency.checks 1).frequency + }" + expectations[consistency.prefix]="${backups.main.consistency.extraConfig.prefix}" + + yq=${pkgs.yq-go}/bin/yq + + for filter in "''${!expectations[@]}"; do + expected_value="''${expectations[$filter]}" + actual_value="$($yq ".$filter" $config_file)" + + if [[ "$actual_value" != "$expected_value" ]]; then + fail "Expected '$filter' to be '$expected_value' but was '$actual_value'" + fi + done + + one_file_system=$($yq ".location.one_file_system" $config_file) + if [[ $one_file_system != "true" ]]; then + fail "Expected one_file_system to be true but it was $one_file_system" + fi + ''; } diff --git a/tests/modules/programs/borgmatic/exclude-hm-symlinks-nothing-else.nix b/tests/modules/programs/borgmatic/exclude-hm-symlinks-nothing-else.nix index 3556cf5a..1d238b91 100644 --- a/tests/modules/programs/borgmatic/exclude-hm-symlinks-nothing-else.nix +++ b/tests/modules/programs/borgmatic/exclude-hm-symlinks-nothing-else.nix @@ -1,40 +1,40 @@ { config, pkgs, ... }: let + backups = config.programs.borgmatic.backups; - excludeFile = pkgs.writeText "excludeFile.txt" "/foo/bar"; + excludeFile = builtins.toFile "excludeFile.txt" "/foo/bar"; + in { - config = { - programs.borgmatic = { - enable = true; - backups = { - main = { - location = { - sourceDirectories = [ "/my-stuff-to-backup" ]; - repositories = [ "/mnt/disk1" ]; - excludeHomeManagerSymlinks = true; - }; + programs.borgmatic = { + enable = true; + backups = { + main = { + location = { + sourceDirectories = [ "/my-stuff-to-backup" ]; + repositories = [ "/mnt/disk1" ]; + excludeHomeManagerSymlinks = true; }; }; }; - - test.stubs.borgmatic = { }; - - nmt.script = '' - config_file=$TESTED/home-files/.config/borgmatic.d/main.yaml - assertFileExists $config_file - - yq=${pkgs.yq-go}/bin/yq - - hmExclusionsFile=$($yq '.location.exclude_from[0]' $config_file) - expected_content='/home/hm-user/.config/borgmatic.d/main.yaml' - - grep --quiet "$expected_content" "$hmExclusionsFile" - - if [[ $? -ne 0 ]]; then - echo "Expected to find $expected_content in file $hmExclusionsFile but didn't" >&2 - exit 1 - fi - ''; }; + + test.stubs.borgmatic = { }; + + nmt.script = '' + config_file=$TESTED/home-files/.config/borgmatic.d/main.yaml + assertFileExists $config_file + + yq=${pkgs.yq-go}/bin/yq + + hmExclusionsFile=$($yq '.location.exclude_from[0]' $config_file) + expected_content='/home/hm-user/.config/borgmatic.d/main.yaml' + + grep --quiet "$expected_content" "$hmExclusionsFile" + + if [[ $? -ne 0 ]]; then + echo "Expected to find $expected_content in file $hmExclusionsFile but didn't" >&2 + exit 1 + fi + ''; } diff --git a/tests/modules/programs/borgmatic/exclude-hm-symlinks.nix b/tests/modules/programs/borgmatic/exclude-hm-symlinks.nix index ba46e3ff..8635b28d 100644 --- a/tests/modules/programs/borgmatic/exclude-hm-symlinks.nix +++ b/tests/modules/programs/borgmatic/exclude-hm-symlinks.nix @@ -1,54 +1,54 @@ { config, pkgs, ... }: let + backups = config.programs.borgmatic.backups; - excludeFile = pkgs.writeText "excludeFile.txt" "/foo/bar"; + excludeFile = builtins.toFile "excludeFile.txt" "/foo/bar"; + in { - config = { - programs.borgmatic = { - enable = true; - backups = { - main = { - location = { - sourceDirectories = [ "/my-stuff-to-backup" ]; - repositories = [ "/mnt/disk1" ]; - excludeHomeManagerSymlinks = true; - extraConfig = { exclude_from = [ (toString excludeFile) ]; }; - }; + programs.borgmatic = { + enable = true; + backups = { + main = { + location = { + sourceDirectories = [ "/my-stuff-to-backup" ]; + repositories = [ "/mnt/disk1" ]; + excludeHomeManagerSymlinks = true; + extraConfig = { exclude_from = [ (toString excludeFile) ]; }; }; }; }; - - test.stubs.borgmatic = { }; - - nmt.script = '' - config_file=$TESTED/home-files/.config/borgmatic.d/main.yaml - assertFileExists $config_file - - declare -A expectations - - expectations[location.exclude_from[0]]="${excludeFile}" - - yq=${pkgs.yq-go}/bin/yq - - for filter in "''${!expectations[@]}"; do - expected_value="''${expectations[$filter]}" - actual_value="$($yq ".$filter" $config_file)" - - if [[ "$actual_value" != "$expected_value" ]]; then - fail "Expected '$filter' to be '$expected_value' but was '$actual_value'" - fi - done - - hmExclusionsFile=$($yq '.location.exclude_from[1]' $config_file) - expected_content='/home/hm-user/.config/borgmatic.d/main.yaml' - - grep --quiet "$expected_content" "$hmExclusionsFile" - - if [[ $? -ne 0 ]]; then - echo "Expected to find $expected_content in file $hmExclusionsFile but didn't" >&2 - exit 1 - fi - ''; }; + + test.stubs.borgmatic = { }; + + nmt.script = '' + config_file=$TESTED/home-files/.config/borgmatic.d/main.yaml + assertFileExists $config_file + + declare -A expectations + + expectations[location.exclude_from[0]]="${excludeFile}" + + yq=${pkgs.yq-go}/bin/yq + + for filter in "''${!expectations[@]}"; do + expected_value="''${expectations[$filter]}" + actual_value="$($yq ".$filter" $config_file)" + + if [[ "$actual_value" != "$expected_value" ]]; then + fail "Expected '$filter' to be '$expected_value' but was '$actual_value'" + fi + done + + hmExclusionsFile=$($yq '.location.exclude_from[1]' $config_file) + expected_content='/home/hm-user/.config/borgmatic.d/main.yaml' + + grep --quiet "$expected_content" "$hmExclusionsFile" + + if [[ $? -ne 0 ]]; then + echo "Expected to find $expected_content in file $hmExclusionsFile but didn't" >&2 + exit 1 + fi + ''; } diff --git a/tests/modules/programs/borgmatic/include-hm-symlinks.nix b/tests/modules/programs/borgmatic/include-hm-symlinks.nix index 1d6163bf..f4f5bfcd 100644 --- a/tests/modules/programs/borgmatic/include-hm-symlinks.nix +++ b/tests/modules/programs/borgmatic/include-hm-symlinks.nix @@ -1,45 +1,45 @@ { config, pkgs, ... }: let + backups = config.programs.borgmatic.backups; - excludeFile = pkgs.writeText "excludeFile.txt" "/foo/bar"; + excludeFile = builtins.toFile "excludeFile.txt" "/foo/bar"; + in { - config = { - programs.borgmatic = { - enable = true; - backups = { - main = { - location = { - sourceDirectories = [ "/my-stuff-to-backup" ]; - repositories = [ "/mnt/disk1" ]; - excludeHomeManagerSymlinks = false; - extraConfig = { exclude_from = [ (toString excludeFile) ]; }; - }; + programs.borgmatic = { + enable = true; + backups = { + main = { + location = { + sourceDirectories = [ "/my-stuff-to-backup" ]; + repositories = [ "/mnt/disk1" ]; + excludeHomeManagerSymlinks = false; + extraConfig = { exclude_from = [ (toString excludeFile) ]; }; }; }; }; - - test.stubs.borgmatic = { }; - - nmt.script = '' - config_file=$TESTED/home-files/.config/borgmatic.d/main.yaml - assertFileExists $config_file - - declare -A expectations - - expectations[location.exclude_from[0]]="${excludeFile}" - - yq=${pkgs.yq-go}/bin/yq - - for filter in "''${!expectations[@]}"; do - expected_value="''${expectations[$filter]}" - actual_value="$($yq ".$filter" $config_file)" - - if [[ "$actual_value" != "$expected_value" ]]; then - fail "Expected '$filter' to be '$expected_value' but was '$actual_value'" - fi - done - - ''; }; + + test.stubs.borgmatic = { }; + + nmt.script = '' + config_file=$TESTED/home-files/.config/borgmatic.d/main.yaml + assertFileExists $config_file + + declare -A expectations + + expectations[location.exclude_from[0]]="${excludeFile}" + + yq=${pkgs.yq-go}/bin/yq + + for filter in "''${!expectations[@]}"; do + expected_value="''${expectations[$filter]}" + actual_value="$($yq ".$filter" $config_file)" + + if [[ "$actual_value" != "$expected_value" ]]; then + fail "Expected '$filter' to be '$expected_value' but was '$actual_value'" + fi + done + + ''; } diff --git a/tests/modules/services/barrier/basic-configuration.nix b/tests/modules/services/barrier/basic-configuration.nix index d0834285..e7e39318 100644 --- a/tests/modules/services/barrier/basic-configuration.nix +++ b/tests/modules/services/barrier/basic-configuration.nix @@ -1,19 +1,17 @@ -{ config, pkgs, ... }: +{ ... }: { - config = { - services.barrier.client = { - enable = true; - server = "testServer"; - }; - - test.stubs.barrier = { }; - - nmt.script = '' - clientServiceFile=home-files/.config/systemd/user/barrierc.service - - assertFileExists $clientServiceFile - assertFileRegex $clientServiceFile 'ExecStart=.*/bin/barrierc -f testServer' - ''; + services.barrier.client = { + enable = true; + server = "testServer"; }; + + test.stubs.barrier = { }; + + nmt.script = '' + clientServiceFile=home-files/.config/systemd/user/barrierc.service + + assertFileExists $clientServiceFile + assertFileRegex $clientServiceFile 'ExecStart=.*/bin/barrierc -f testServer' + ''; } diff --git a/tests/modules/services/devilspie2/configuration.nix b/tests/modules/services/devilspie2/configuration.nix index 2072d4d8..14bdc6f0 100644 --- a/tests/modules/services/devilspie2/configuration.nix +++ b/tests/modules/services/devilspie2/configuration.nix @@ -1,37 +1,37 @@ -{ config, pkgs, ... }: { - config = { - services.devilspie2 = { - enable = true; +{ ... }: - config = '' - if (get_window_class() == "Gnome-terminal") then - make_always_on_top(); - end +{ + services.devilspie2 = { + enable = true; - if string.match(get_window_name(), "LibreOffice Writer") then - maximize(); - end + config = '' + if (get_window_class() == "Gnome-terminal") then + make_always_on_top(); + end - if (get_window_class()=="Org.gnome.Nautilus") then - set_window_geometry(1600,300,900,700); - end - ''; - }; + if string.match(get_window_name(), "LibreOffice Writer") then + maximize(); + end - test.stubs.devilspie2 = { }; - - nmt.script = '' - configlua=home-files/.config/devilspie2/config.lua - - assertFileExists $configlua - - assertFileContent $configlua ${./config.lua} - - serviceFile=home-files/.config/systemd/user/devilspie2.service - - assertFileExists $serviceFile - - assertFileRegex $serviceFile 'ExecStart=.*/bin/devilspie2' + if (get_window_class()=="Org.gnome.Nautilus") then + set_window_geometry(1600,300,900,700); + end ''; }; + + test.stubs.devilspie2 = { }; + + nmt.script = '' + configlua=home-files/.config/devilspie2/config.lua + + assertFileExists $configlua + + assertFileContent $configlua ${./config.lua} + + serviceFile=home-files/.config/systemd/user/devilspie2.service + + assertFileExists $serviceFile + + assertFileRegex $serviceFile 'ExecStart=.*/bin/devilspie2' + ''; } diff --git a/tests/modules/services/emacs/emacs-default-editor.nix b/tests/modules/services/emacs/emacs-default-editor.nix index 77897a5b..de91846c 100644 --- a/tests/modules/services/emacs/emacs-default-editor.nix +++ b/tests/modules/services/emacs/emacs-default-editor.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ pkgs, ... }: { nixpkgs.overlays = [ diff --git a/tests/modules/services/emacs/emacs-service-27.nix b/tests/modules/services/emacs/emacs-service-27.nix index 6bc99ced..76c33a5e 100644 --- a/tests/modules/services/emacs/emacs-service-27.nix +++ b/tests/modules/services/emacs/emacs-service-27.nix @@ -1,38 +1,37 @@ -{ config, lib, pkgs, ... }: - -with lib; +{ lib, pkgs, ... }: { - config = { - nixpkgs.overlays = [ - (self: super: rec { - emacs = pkgs.writeShellScriptBin "dummy-emacs-27.2" "" // { - outPath = "@emacs@"; - }; - emacsPackagesFor = _: - makeScope super.newScope (_: { emacsWithPackages = _: emacs; }); - }) - ]; + nixpkgs.overlays = [ + (self: super: rec { + emacs = pkgs.writeShellScriptBin "dummy-emacs-27.2" "" // { + outPath = "@emacs@"; + }; + emacsPackagesFor = _: + lib.makeScope super.newScope (_: { emacsWithPackages = _: emacs; }); + }) + ]; - programs.emacs.enable = true; - services.emacs.enable = true; - services.emacs.client.enable = true; - services.emacs.extraOptions = [ "-f" "exwm-enable" ]; + programs.emacs.enable = true; + services.emacs.enable = true; + services.emacs.client.enable = true; + services.emacs.extraOptions = [ "-f" "exwm-enable" ]; - nmt.script = '' - assertPathNotExists home-files/.config/systemd/user/emacs.socket - assertFileExists home-files/.config/systemd/user/emacs.service - assertFileExists home-path/share/applications/emacsclient.desktop + nmt.script = '' + assertPathNotExists home-files/.config/systemd/user/emacs.socket + assertFileExists home-files/.config/systemd/user/emacs.service + assertFileExists home-path/share/applications/emacsclient.desktop - assertFileContent home-files/.config/systemd/user/emacs.service \ - ${ - pkgs.substituteAll { - inherit (pkgs) runtimeShell; - src = ./emacs-service-emacs.service; - } - } - assertFileContent home-path/share/applications/emacsclient.desktop \ - ${./emacs-27-emacsclient.desktop} - ''; - }; + assertFileContent \ + home-files/.config/systemd/user/emacs.service \ + ${ + pkgs.substituteAll { + inherit (pkgs) runtimeShell; + src = ./emacs-service-emacs.service; + } + } + + assertFileContent \ + home-path/share/applications/emacsclient.desktop \ + ${./emacs-27-emacsclient.desktop} + ''; } diff --git a/tests/modules/services/emacs/emacs-service-28-after-graphical-session-target.nix b/tests/modules/services/emacs/emacs-service-28-after-graphical-session-target.nix index 237e9d14..edd232e4 100644 --- a/tests/modules/services/emacs/emacs-service-28-after-graphical-session-target.nix +++ b/tests/modules/services/emacs/emacs-service-28-after-graphical-session-target.nix @@ -1,40 +1,38 @@ -{ config, lib, pkgs, ... }: - -with lib; +{ lib, pkgs, ... }: { - config = { - nixpkgs.overlays = [ - (self: super: rec { - emacs = pkgs.writeShellScriptBin "dummy-emacs-28.2" "" // { - outPath = "@emacs@"; - }; - emacsPackagesFor = _: - makeScope super.newScope (_: { emacsWithPackages = _: emacs; }); - }) - ]; + nixpkgs.overlays = [ + (self: super: rec { + emacs = pkgs.writeShellScriptBin "dummy-emacs-28.2" "" // { + outPath = "@emacs@"; + }; + emacsPackagesFor = _: + lib.makeScope super.newScope (_: { emacsWithPackages = _: emacs; }); + }) + ]; - programs.emacs.enable = true; - services.emacs.enable = true; - services.emacs.client.enable = true; - services.emacs.extraOptions = [ "-f" "exwm-enable" ]; - services.emacs.startWithUserSession = "graphical"; + programs.emacs.enable = true; + services.emacs.enable = true; + services.emacs.client.enable = true; + services.emacs.extraOptions = [ "-f" "exwm-enable" ]; + services.emacs.startWithUserSession = "graphical"; - nmt.script = '' - assertPathNotExists home-files/.config/systemd/user/emacs.socket - assertFileExists home-files/.config/systemd/user/emacs.service - assertFileExists home-path/share/applications/emacsclient.desktop + nmt.script = '' + assertPathNotExists home-files/.config/systemd/user/emacs.socket + assertFileExists home-files/.config/systemd/user/emacs.service + assertFileExists home-path/share/applications/emacsclient.desktop - assertFileContent home-files/.config/systemd/user/emacs.service \ - ${ - pkgs.substituteAll { - inherit (pkgs) runtimeShell; - src = - ./emacs-service-emacs-after-graphical-session-target.service; - } - } - assertFileContent home-path/share/applications/emacsclient.desktop \ - ${./emacs-28-emacsclient.desktop} - ''; - }; + assertFileContent \ + home-files/.config/systemd/user/emacs.service \ + ${ + pkgs.substituteAll { + inherit (pkgs) runtimeShell; + src = ./emacs-service-emacs-after-graphical-session-target.service; + } + } + + assertFileContent \ + home-path/share/applications/emacsclient.desktop \ + ${./emacs-28-emacsclient.desktop} + ''; } diff --git a/tests/modules/services/emacs/emacs-service-28.nix b/tests/modules/services/emacs/emacs-service-28.nix index febfe828..a5d9c87c 100644 --- a/tests/modules/services/emacs/emacs-service-28.nix +++ b/tests/modules/services/emacs/emacs-service-28.nix @@ -1,6 +1,4 @@ -{ config, lib, pkgs, ... }: - -with lib; +{ lib, pkgs, ... }: { config = { @@ -10,7 +8,7 @@ with lib; outPath = "@emacs@"; }; emacsPackagesFor = _: - makeScope super.newScope (_: { emacsWithPackages = _: emacs; }); + lib.makeScope super.newScope (_: { emacsWithPackages = _: emacs; }); }) ]; @@ -24,15 +22,18 @@ with lib; assertFileExists home-files/.config/systemd/user/emacs.service assertFileExists home-path/share/applications/emacsclient.desktop - assertFileContent home-files/.config/systemd/user/emacs.service \ - ${ - pkgs.substituteAll { - inherit (pkgs) runtimeShell; - src = ./emacs-service-emacs.service; - } - } - assertFileContent home-path/share/applications/emacsclient.desktop \ - ${./emacs-28-emacsclient.desktop} + assertFileContent \ + home-files/.config/systemd/user/emacs.service \ + ${ + pkgs.substituteAll { + inherit (pkgs) runtimeShell; + src = ./emacs-service-emacs.service; + } + } + + assertFileContent \ + home-path/share/applications/emacsclient.desktop \ + ${./emacs-28-emacsclient.desktop} ''; }; } diff --git a/tests/modules/services/emacs/emacs-socket-27.nix b/tests/modules/services/emacs/emacs-socket-27.nix index b3b71e02..c7282bdb 100644 --- a/tests/modules/services/emacs/emacs-socket-27.nix +++ b/tests/modules/services/emacs/emacs-socket-27.nix @@ -1,10 +1,6 @@ -{ config, lib, pkgs, ... }: +{ lib, pkgs, ... }: -with lib; - -let - -in { +{ config = { nixpkgs.overlays = [ (self: super: rec { @@ -12,7 +8,7 @@ in { outPath = "@emacs@"; }; emacsPackagesFor = _: - makeScope super.newScope (_: { emacsWithPackages = _: emacs; }); + lib.makeScope super.newScope (_: { emacsWithPackages = _: emacs; }); }) ]; @@ -27,17 +23,22 @@ in { assertFileExists home-files/.config/systemd/user/emacs.service assertFileExists home-path/share/applications/emacsclient.desktop - assertFileContent home-files/.config/systemd/user/emacs.socket \ - ${./emacs-socket-emacs.socket} - assertFileContent home-files/.config/systemd/user/emacs.service \ - ${ - pkgs.substituteAll { - inherit (pkgs) runtimeShell coreutils; - src = ./emacs-socket-emacs.service; - } - } - assertFileContent home-path/share/applications/emacsclient.desktop \ - ${./emacs-27-emacsclient.desktop} + assertFileContent \ + home-files/.config/systemd/user/emacs.socket \ + ${./emacs-socket-emacs.socket} + + assertFileContent \ + home-files/.config/systemd/user/emacs.service \ + ${ + pkgs.substituteAll { + inherit (pkgs) runtimeShell coreutils; + src = ./emacs-socket-emacs.service; + } + } + + assertFileContent \ + home-path/share/applications/emacsclient.desktop \ + ${./emacs-27-emacsclient.desktop} ''; }; } diff --git a/tests/modules/services/emacs/emacs-socket-28.nix b/tests/modules/services/emacs/emacs-socket-28.nix index 91106665..c822f535 100644 --- a/tests/modules/services/emacs/emacs-socket-28.nix +++ b/tests/modules/services/emacs/emacs-socket-28.nix @@ -1,10 +1,6 @@ -{ config, lib, pkgs, ... }: +{ lib, pkgs, ... }: -with lib; - -let - -in { +{ config = { nixpkgs.overlays = [ (self: super: rec { @@ -12,7 +8,7 @@ in { outPath = "@emacs@"; }; emacsPackagesFor = _: - makeScope super.newScope (_: { emacsWithPackages = _: emacs; }); + lib.makeScope super.newScope (_: { emacsWithPackages = _: emacs; }); }) ]; @@ -27,17 +23,22 @@ in { assertFileExists home-files/.config/systemd/user/emacs.service assertFileExists home-path/share/applications/emacsclient.desktop - assertFileContent home-files/.config/systemd/user/emacs.socket \ - ${./emacs-socket-emacs.socket} - assertFileContent home-files/.config/systemd/user/emacs.service \ - ${ - pkgs.substituteAll { - inherit (pkgs) runtimeShell coreutils; - src = ./emacs-socket-emacs.service; - } - } - assertFileContent home-path/share/applications/emacsclient.desktop \ - ${./emacs-28-emacsclient.desktop} + assertFileContent \ + home-files/.config/systemd/user/emacs.socket \ + ${./emacs-socket-emacs.socket} + + assertFileContent \ + home-files/.config/systemd/user/emacs.service \ + ${ + pkgs.substituteAll { + inherit (pkgs) runtimeShell coreutils; + src = ./emacs-socket-emacs.service; + } + } + + assertFileContent \ + home-path/share/applications/emacsclient.desktop \ + ${./emacs-28-emacsclient.desktop} ''; }; } diff --git a/tests/modules/services/emacs/emacs-socket-and-startWithUserSession.nix b/tests/modules/services/emacs/emacs-socket-and-startWithUserSession.nix index 5f47089e..1f6d5673 100644 --- a/tests/modules/services/emacs/emacs-socket-and-startWithUserSession.nix +++ b/tests/modules/services/emacs/emacs-socket-and-startWithUserSession.nix @@ -1,7 +1,5 @@ { lib, pkgs, ... }: -with lib; - { services.emacs = { enable = true; @@ -15,7 +13,7 @@ with lib; outPath = "@emacs@"; }; emacsPackagesFor = _: - makeScope super.newScope (_: { emacsWithPackages = _: emacs; }); + lib.makeScope super.newScope (_: { emacsWithPackages = _: emacs; }); }) ]; diff --git a/tests/modules/services/flameshot/empty-settings.nix b/tests/modules/services/flameshot/empty-settings.nix index a5205660..2c700c49 100644 --- a/tests/modules/services/flameshot/empty-settings.nix +++ b/tests/modules/services/flameshot/empty-settings.nix @@ -1,13 +1,11 @@ { ... }: { - config = { - services.flameshot = { enable = true; }; + services.flameshot = { enable = true; }; - test.stubs.flameshot = { }; + test.stubs.flameshot = { }; - nmt.script = '' - assertPathNotExists home-files/.config/flameshot/flameshot.ini - ''; - }; + nmt.script = '' + assertPathNotExists home-files/.config/flameshot/flameshot.ini + ''; } diff --git a/tests/modules/services/flameshot/example-settings.nix b/tests/modules/services/flameshot/example-settings.nix index 213e86b3..d61b93e9 100644 --- a/tests/modules/services/flameshot/example-settings.nix +++ b/tests/modules/services/flameshot/example-settings.nix @@ -1,30 +1,28 @@ { ... }: { - config = { - services.flameshot = { - enable = true; + services.flameshot = { + enable = true; - settings = { - General = { - disabledTrayIcon = true; - showStartupLaunchMessage = false; - }; + settings = { + General = { + disabledTrayIcon = true; + showStartupLaunchMessage = false; }; }; - - test.stubs.flameshot = { }; - - nmt.script = '' - assertFileContent \ - home-files/.config/flameshot/flameshot.ini \ - ${ - builtins.toFile "expected.ini" '' - [General] - disabledTrayIcon=true - showStartupLaunchMessage=false - '' - } - ''; }; + + test.stubs.flameshot = { }; + + nmt.script = '' + assertFileContent \ + home-files/.config/flameshot/flameshot.ini \ + ${ + builtins.toFile "expected.ini" '' + [General] + disabledTrayIcon=true + showStartupLaunchMessage=false + '' + } + ''; } diff --git a/tests/modules/services/fluidsynth/service.nix b/tests/modules/services/fluidsynth/service.nix index 7fbfa79c..ce0427b8 100644 --- a/tests/modules/services/fluidsynth/service.nix +++ b/tests/modules/services/fluidsynth/service.nix @@ -1,25 +1,25 @@ -{ config, pkgs, ... }: { - config = { - services.fluidsynth.enable = true; - services.fluidsynth.soundService = "pipewire-pulse"; - services.fluidsynth.soundFont = "/path/to/soundFont"; - services.fluidsynth.extraOptions = [ "--sample-rate 96000" ]; +{ ... }: - test.stubs.fluidsynth = { }; +{ + services.fluidsynth.enable = true; + services.fluidsynth.soundService = "pipewire-pulse"; + services.fluidsynth.soundFont = "/path/to/soundFont"; + services.fluidsynth.extraOptions = [ "--sample-rate 96000" ]; - nmt.script = '' - serviceFile=home-files/.config/systemd/user/fluidsynth.service + test.stubs.fluidsynth = { }; - assertFileExists $serviceFile + nmt.script = '' + serviceFile=home-files/.config/systemd/user/fluidsynth.service - assertFileContains $serviceFile \ - 'ExecStart=@fluidsynth@/bin/fluidsynth -a pulseaudio -si --sample-rate 96000 /path/to/soundFont' + assertFileExists $serviceFile - assertFileContains $serviceFile \ - 'After=pipewire-pulse.service' + assertFileContains $serviceFile \ + 'ExecStart=@fluidsynth@/bin/fluidsynth -a pulseaudio -si --sample-rate 96000 /path/to/soundFont' - assertFileContains $serviceFile \ - 'BindsTo=pipewire-pulse.service' - ''; - }; + assertFileContains $serviceFile \ + 'After=pipewire-pulse.service' + + assertFileContains $serviceFile \ + 'BindsTo=pipewire-pulse.service' + ''; } diff --git a/tests/modules/services/lieer/lieer-service.nix b/tests/modules/services/lieer/lieer-service.nix index f11f1f6e..796afc07 100644 --- a/tests/modules/services/lieer/lieer-service.nix +++ b/tests/modules/services/lieer/lieer-service.nix @@ -1,34 +1,30 @@ -{ config, lib, pkgs, ... }: - -with lib; +{ ... }: { imports = [ ../../accounts/email-test-accounts.nix ]; - config = { - services.lieer.enable = true; + services.lieer.enable = true; - accounts.email.accounts = { - "hm@example.com" = { - flavor = "gmail.com"; - lieer = { - enable = true; - sync.enable = true; - }; - notmuch.enable = true; + accounts.email.accounts = { + "hm@example.com" = { + flavor = "gmail.com"; + lieer = { + enable = true; + sync.enable = true; }; + notmuch.enable = true; }; - - test.stubs.lieer = { }; - - nmt.script = '' - assertFileExists home-files/.config/systemd/user/lieer-hm-example-com.service - assertFileExists home-files/.config/systemd/user/lieer-hm-example-com.timer - - assertFileContent home-files/.config/systemd/user/lieer-hm-example-com.service \ - ${./lieer-service-expected.service} - assertFileContent home-files/.config/systemd/user/lieer-hm-example-com.timer \ - ${./lieer-service-expected.timer} - ''; }; + + test.stubs.lieer = { }; + + nmt.script = '' + assertFileExists home-files/.config/systemd/user/lieer-hm-example-com.service + assertFileExists home-files/.config/systemd/user/lieer-hm-example-com.timer + + assertFileContent home-files/.config/systemd/user/lieer-hm-example-com.service \ + ${./lieer-service-expected.service} + assertFileContent home-files/.config/systemd/user/lieer-hm-example-com.timer \ + ${./lieer-service-expected.timer} + ''; } diff --git a/tests/modules/services/window-managers/bspwm/configuration.nix b/tests/modules/services/window-managers/bspwm/configuration.nix index 49c82f6f..cd2bfa2e 100644 --- a/tests/modules/services/window-managers/bspwm/configuration.nix +++ b/tests/modules/services/window-managers/bspwm/configuration.nix @@ -1,47 +1,42 @@ -{ lib, pkgs, ... }: - -with lib; +{ pkgs, ... }: { - config = { - xsession.windowManager.bspwm = { - enable = true; - monitors.focused = - [ "desktop 1" "d'esk top" ]; # pathological desktop names - alwaysResetDesktops = false; - settings = { - border_width = 2; - split_ratio = 0.52; - gapless_monocle = true; - external_rules_command = "/path/to/external rules command"; - ignore_ewmh_fullscreen = [ "enter" "exit" ]; - }; - rules."*" = { - sticky = true; - center = false; - desktop = "d'esk top#next"; - splitDir = "north"; - border = null; - unknownRule = 42; - }; - extraConfigEarly = '' - extra config early - ''; - extraConfig = '' - extra config - ''; - startupPrograms = [ "foo" "bar || qux" ]; + xsession.windowManager.bspwm = { + enable = true; + monitors.focused = [ "desktop 1" "d'esk top" ]; # pathological desktop names + alwaysResetDesktops = false; + settings = { + border_width = 2; + split_ratio = 0.52; + gapless_monocle = true; + external_rules_command = "/path/to/external rules command"; + ignore_ewmh_fullscreen = [ "enter" "exit" ]; }; - - test.stubs.bspwm = { }; - - nmt.script = '' - bspwmrc=home-files/.config/bspwm/bspwmrc - assertFileExists "$bspwmrc" - assertFileIsExecutable "$bspwmrc" - assertFileContent "$bspwmrc" ${ - pkgs.writeShellScript "bspwmrc-expected" (readFile ./bspwmrc) - } + rules."*" = { + sticky = true; + center = false; + desktop = "d'esk top#next"; + splitDir = "north"; + border = null; + unknownRule = 42; + }; + extraConfigEarly = '' + extra config early ''; + extraConfig = '' + extra config + ''; + startupPrograms = [ "foo" "bar || qux" ]; }; + + test.stubs.bspwm = { }; + + nmt.script = '' + bspwmrc=home-files/.config/bspwm/bspwmrc + assertFileExists "$bspwmrc" + assertFileIsExecutable "$bspwmrc" + assertFileContent "$bspwmrc" ${ + pkgs.writeShellScript "bspwmrc-expected" (builtins.readFile ./bspwmrc) + } + ''; } 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 66b4ca87..abb4112a 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,4 +1,4 @@ -{ config, lib, ... }: +{ ... }: { imports = [ ./i3-stubs.nix ]; diff --git a/tests/modules/services/window-managers/i3/i3-followmouse.nix b/tests/modules/services/window-managers/i3/i3-followmouse.nix index 43e15cda..db84abd1 100644 --- a/tests/modules/services/window-managers/i3/i3-followmouse.nix +++ b/tests/modules/services/window-managers/i3/i3-followmouse.nix @@ -1,31 +1,27 @@ -{ config, lib, ... }: - -with lib; +{ ... }: { - config = { - xsession.windowManager.i3 = { - enable = true; + xsession.windowManager.i3 = { + enable = true; - config.focus.followMouse = false; - }; - - nixpkgs.overlays = [ - (self: super: { - dmenu = super.dmenu // { outPath = "@dmenu@"; }; - - i3 = super.writeScriptBin "i3" "" // { outPath = "@i3@"; }; - - i3-gaps = super.writeScriptBin "i3" "" // { outPath = "@i3-gaps@"; }; - - i3status = super.i3status // { outPath = "@i3status@"; }; - }) - ]; - - nmt.script = '' - assertFileExists home-files/.config/i3/config - assertFileContent home-files/.config/i3/config \ - ${./i3-followmouse-expected.conf} - ''; + config.focus.followMouse = false; }; + + nixpkgs.overlays = [ + (self: super: { + dmenu = super.dmenu // { outPath = "@dmenu@"; }; + + i3 = super.writeScriptBin "i3" "" // { outPath = "@i3@"; }; + + i3-gaps = super.writeScriptBin "i3" "" // { outPath = "@i3-gaps@"; }; + + i3status = super.i3status // { outPath = "@i3status@"; }; + }) + ]; + + nmt.script = '' + assertFileExists home-files/.config/i3/config + assertFileContent home-files/.config/i3/config \ + ${./i3-followmouse-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 7e4532e5..0216681f 100644 --- a/tests/modules/services/window-managers/i3/i3-fonts-deprecated.nix +++ b/tests/modules/services/window-managers/i3/i3-fonts-deprecated.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ ... }: { imports = [ ./i3-stubs.nix ]; diff --git a/tests/modules/services/window-managers/i3/i3-fonts.nix b/tests/modules/services/window-managers/i3/i3-fonts.nix index 3618451f..decd9fcc 100644 --- a/tests/modules/services/window-managers/i3/i3-fonts.nix +++ b/tests/modules/services/window-managers/i3/i3-fonts.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ ... }: { imports = [ ./i3-stubs.nix ]; 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 f321ad49..8433b0c7 100644 --- a/tests/modules/services/window-managers/i3/i3-null-config.nix +++ b/tests/modules/services/window-managers/i3/i3-null-config.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ ... }: { imports = [ ./i3-stubs.nix ]; @@ -11,6 +11,6 @@ nmt.script = '' assertFileExists home-files/.config/i3/config assertFileContent home-files/.config/i3/config \ - ${pkgs.writeText "expected" ""} + ${builtins.toFile "expected" ""} ''; } 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 521b5f5d..733d619f 100644 --- a/tests/modules/services/window-managers/i3/i3-workspace-default.nix +++ b/tests/modules/services/window-managers/i3/i3-workspace-default.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ ... }: { imports = [ ./i3-stubs.nix ]; 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 df4a2c78..8dcae4f8 100644 --- a/tests/modules/services/window-managers/i3/i3-workspace-output.nix +++ b/tests/modules/services/window-managers/i3/i3-workspace-output.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ ... }: let i3 = { 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 52aa3cc4..03f64fc2 100644 --- a/tests/modules/services/window-managers/sway/sway-followmouse-legacy.nix +++ b/tests/modules/services/window-managers/sway/sway-followmouse-legacy.nix @@ -1,6 +1,4 @@ -{ config, lib, pkgs, ... }: - -with lib; +{ config, pkgs, ... }: { imports = [ ./sway-stubs.nix ]; diff --git a/tests/modules/services/window-managers/sway/sway-followmouse.nix b/tests/modules/services/window-managers/sway/sway-followmouse.nix index 788ad218..b8a2bc16 100644 --- a/tests/modules/services/window-managers/sway/sway-followmouse.nix +++ b/tests/modules/services/window-managers/sway/sway-followmouse.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, pkgs, ... }: { imports = [ ./sway-stubs.nix ]; diff --git a/tests/modules/services/window-managers/sway/sway-modules.nix b/tests/modules/services/window-managers/sway/sway-modules.nix index 567f7b5c..b8aa58c5 100644 --- a/tests/modules/services/window-managers/sway/sway-modules.nix +++ b/tests/modules/services/window-managers/sway/sway-modules.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, pkgs, ... }: { imports = [ ./sway-stubs.nix ]; diff --git a/tests/modules/services/window-managers/sway/swaynag-empty-settings.nix b/tests/modules/services/window-managers/sway/swaynag-empty-settings.nix index 0180852a..56782547 100644 --- a/tests/modules/services/window-managers/sway/swaynag-empty-settings.nix +++ b/tests/modules/services/window-managers/sway/swaynag-empty-settings.nix @@ -1,15 +1,13 @@ -{ config, lib, pkgs, ... }: +{ ... }: { - config = { - wayland.windowManager.sway.swaynag = { - enable = true; + wayland.windowManager.sway.swaynag = { + enable = true; - settings = { }; - }; - - nmt.script = '' - assertPathNotExists home-files/.config/swaynag - ''; + settings = { }; }; + + nmt.script = '' + assertPathNotExists home-files/.config/swaynag + ''; } diff --git a/tests/modules/systemd/services-disabled-for-root.nix b/tests/modules/systemd/services-disabled-for-root.nix index f54ebd08..38d4f955 100644 --- a/tests/modules/systemd/services-disabled-for-root.nix +++ b/tests/modules/systemd/services-disabled-for-root.nix @@ -1,23 +1,19 @@ -{ config, lib, pkgs, ... }: - -with lib; +{ lib, ... }: { - config = { - home.username = mkForce "root"; + home.username = lib.mkForce "root"; - systemd.user.services."test-service@" = { - Unit = { Description = "A basic test service"; }; + systemd.user.services."test-service@" = { + Unit = { Description = "A basic test service"; }; - Service = { - Environment = [ "VAR1=1" "VAR2=2" ]; - ExecStart = ''/some/exec/start/command --with-arguments "%i"''; - }; + Service = { + Environment = [ "VAR1=1" "VAR2=2" ]; + ExecStart = ''/some/exec/start/command --with-arguments "%i"''; }; - - nmt.script = '' - serviceFile=home-files/.config/systemd/user/test-service@.service - assertPathNotExists $serviceFile - ''; }; + + nmt.script = '' + serviceFile=home-files/.config/systemd/user/test-service@.service + assertPathNotExists $serviceFile + ''; } diff --git a/tests/modules/systemd/services.nix b/tests/modules/systemd/services.nix index ce030f7c..439a03f2 100644 --- a/tests/modules/systemd/services.nix +++ b/tests/modules/systemd/services.nix @@ -5,33 +5,31 @@ let echo "Just a test" ''; in { - config = { - systemd.user.services."test-service@" = { - Unit = { Description = "A basic test service"; }; + systemd.user.services."test-service@" = { + Unit = { Description = "A basic test service"; }; - Service = { - Environment = [ "VAR1=1" "VAR2=2" ]; - ExecStartPre = drvScript; - ExecStart = ''/some/exec/start/command --with-arguments "%i"''; - }; + Service = { + Environment = [ "VAR1=1" "VAR2=2" ]; + ExecStartPre = drvScript; + ExecStart = ''/some/exec/start/command --with-arguments "%i"''; }; - - nmt.script = '' - serviceFile=home-files/.config/systemd/user/test-service@.service - assertFileExists $serviceFile - assertFileContent $serviceFile \ - ${ - pkgs.writeText "services-expected.conf" '' - [Service] - Environment=VAR1=1 - Environment=VAR2=2 - ExecStart=/some/exec/start/command --with-arguments "%i" - ExecStartPre=${drvScript} - - [Unit] - Description=A basic test service - '' - } - ''; }; + + nmt.script = '' + serviceFile=home-files/.config/systemd/user/test-service@.service + assertFileExists $serviceFile + assertFileContent $serviceFile \ + ${ + pkgs.writeText "services-expected.conf" '' + [Service] + Environment=VAR1=1 + Environment=VAR2=2 + ExecStart=/some/exec/start/command --with-arguments "%i" + ExecStartPre=${drvScript} + + [Unit] + Description=A basic test service + '' + } + ''; } diff --git a/tests/modules/systemd/session-variables.nix b/tests/modules/systemd/session-variables.nix index cbc348c4..d234767f 100644 --- a/tests/modules/systemd/session-variables.nix +++ b/tests/modules/systemd/session-variables.nix @@ -1,26 +1,24 @@ -{ config, lib, pkgs, ... }: +{ pkgs, ... }: { - config = { - systemd.user.sessionVariables = { - V_int = 1; - V_str = "2"; - }; - - nmt.script = '' - envFile=home-files/.config/environment.d/10-home-manager.conf - assertFileExists $envFile - assertFileContent $envFile ${ - pkgs.writeText "expected" '' - LOCALE_ARCHIVE_2_27=${pkgs.glibcLocales}/lib/locale/locale-archive - V_int=1 - V_str=2 - XDG_CACHE_HOME=/home/hm-user/.cache - XDG_CONFIG_HOME=/home/hm-user/.config - XDG_DATA_HOME=/home/hm-user/.local/share - XDG_STATE_HOME=/home/hm-user/.local/state - '' - } - ''; + systemd.user.sessionVariables = { + V_int = 1; + V_str = "2"; }; + + nmt.script = '' + envFile=home-files/.config/environment.d/10-home-manager.conf + assertFileExists $envFile + assertFileContent $envFile ${ + pkgs.writeText "expected" '' + LOCALE_ARCHIVE_2_27=${pkgs.glibcLocales}/lib/locale/locale-archive + V_int=1 + V_str=2 + XDG_CACHE_HOME=/home/hm-user/.cache + XDG_CONFIG_HOME=/home/hm-user/.config + XDG_DATA_HOME=/home/hm-user/.local/share + XDG_STATE_HOME=/home/hm-user/.local/state + '' + } + ''; } diff --git a/tests/modules/systemd/slices.nix b/tests/modules/systemd/slices.nix index 0bb90504..68f6c70a 100644 --- a/tests/modules/systemd/slices.nix +++ b/tests/modules/systemd/slices.nix @@ -1,31 +1,27 @@ -{ config, lib, pkgs, ... }: - -with lib; +{ ... }: { - config = { - systemd.user.slices.app-test = { - Unit = { Description = "Slice for a test app"; }; + systemd.user.slices.app-test = { + Unit = { Description = "Slice for a test app"; }; - Slice = { - MemoryHigh = "30%"; - MemoryMax = "40%"; - }; + Slice = { + MemoryHigh = "30%"; + MemoryMax = "40%"; }; - - nmt.script = '' - sliceFile=home-files/.config/systemd/user/app-test.slice - assertFileExists $sliceFile - assertFileContent $sliceFile ${ - builtins.toFile "app-test-expected.conf" '' - [Slice] - MemoryHigh=30% - MemoryMax=40% - - [Unit] - Description=Slice for a test app - '' - } - ''; }; + + nmt.script = '' + sliceFile=home-files/.config/systemd/user/app-test.slice + assertFileExists $sliceFile + assertFileContent $sliceFile ${ + builtins.toFile "app-test-expected.conf" '' + [Slice] + MemoryHigh=30% + MemoryMax=40% + + [Unit] + Description=Slice for a test app + '' + } + ''; } diff --git a/tests/modules/systemd/timers.nix b/tests/modules/systemd/timers.nix index 1c0e2722..b9d167e3 100644 --- a/tests/modules/systemd/timers.nix +++ b/tests/modules/systemd/timers.nix @@ -1,25 +1,21 @@ -{ config, lib, pkgs, ... }: - -with lib; +{ ... }: { - config = { - systemd.user.timers.test-timer = { - Unit = { Description = "A basic test timer"; }; + systemd.user.timers.test-timer = { + Unit = { Description = "A basic test timer"; }; - Timer = { OnUnitActiveSec = "1h 30m"; }; + Timer = { OnUnitActiveSec = "1h 30m"; }; - Install = { WantedBy = [ "timers.target" ]; }; - }; - - nmt.script = '' - unitDir=home-files/.config/systemd/user - timerFile=$unitDir/test-timer.timer - - assertFileExists $timerFile - assertFileContent $timerFile ${./timers-expected.conf} - - assertFileExists $unitDir/timers.target.wants/test-timer.timer - ''; + Install = { WantedBy = [ "timers.target" ]; }; }; + + nmt.script = '' + unitDir=home-files/.config/systemd/user + timerFile=$unitDir/test-timer.timer + + assertFileExists $timerFile + assertFileContent $timerFile ${./timers-expected.conf} + + assertFileExists $unitDir/timers.target.wants/test-timer.timer + ''; }