diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index e064d5aa..af3efeaf 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -40,3 +40,10 @@ Also make sure to read the guidelines found at - If this PR adds a new module - [ ] Added myself as module maintainer. See [example](https://github.com/nix-community/home-manager/blob/068ff76a10e95820f886ac46957edcff4e44621d/modules/programs/lesspipe.nix#L6). + +#### Maintainer CC + + diff --git a/flake.lock b/flake.lock index b411a332..74b2c113 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1688049487, - "narHash": "sha256-100g4iaKC9MalDjUW9iN6Jl/OocTDtXdeAj7pEGIRh4=", + "lastModified": 1688679045, + "narHash": "sha256-t3xGEfYIwhaLTPU8FLtN/pLPytNeDwbLI6a7XFFBlGo=", "owner": "nixos", "repo": "nixpkgs", - "rev": "4bc72cae107788bf3f24f30db2e2f685c9298dc9", + "rev": "3c7487575d9445185249a159046cc02ff364bff8", "type": "github" }, "original": { diff --git a/home-manager/home-manager b/home-manager/home-manager index 85c6da87..7b7b6fe2 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -156,7 +156,7 @@ function setFlakeAttribute() { fi if [[ -v configFlake ]]; then - FLAKE_ARG="$(dirname "$(readlink -f "$configFlake")")" + FLAKE_ARG="path:$(dirname "$(readlink -f "$configFlake")")" fi fi diff --git a/home-manager/po/id.po b/home-manager/po/id.po index 5a363753..ef56f19a 100644 --- a/home-manager/po/id.po +++ b/home-manager/po/id.po @@ -8,8 +8,8 @@ msgstr "" "Project-Id-Version: Home Manager\n" "Report-Msgid-Bugs-To: https://github.com/nix-community/home-manager/issues\n" "POT-Creation-Date: 2023-05-27 09:08+0200\n" -"PO-Revision-Date: 2023-06-22 09:51+0000\n" -"Last-Translator: Abdul V Vahry \n" +"PO-Revision-Date: 2023-07-01 13:50+0000\n" +"Last-Translator: Reza Almanda \n" "Language-Team: Indonesian \n" "Language: id\n" @@ -17,7 +17,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.18.1\n" +"X-Generator: Weblate 5.0-dev\n" #: home-manager/home-manager:71 msgid "No configuration file found at %s" @@ -27,12 +27,11 @@ msgstr "Tidak ada file konfigurasi yang ditemukan di %s" #. 'home.nix' or 'flake.nix'. #: home-manager/home-manager:88 home-manager/home-manager:92 #: home-manager/home-manager:154 -#, fuzzy msgid "" "Keeping your Home Manager %s in %s is deprecated,\n" "please move it to %s" msgstr "" -"Mempertahankan Pengelola Rumah Anda %s di %s tidak digunakan lagi,\n" +"Mempertahankan Pengelola Beranda Anda %s di %s tidak digunakan lagi,\n" "tolong pindahkan ke %s" #: home-manager/home-manager:99 @@ -45,9 +44,8 @@ msgstr "Tidak dapat menemukan direktori profil yang sesuai, mencoba %s dan %s" #. translators: Here "flake" is a noun that refers to the Nix Flakes feature. #: home-manager/home-manager:191 -#, fuzzy msgid "Can't inspect options of a flake configuration" -msgstr "Tidak dapat memeriksa opsi konfigurasi serpih" +msgstr "Tidak dapat memeriksa opsi konfigurasi flake" #: home-manager/home-manager:253 home-manager/home-manager:276 #: home-manager/home-manager:973 @@ -56,7 +54,7 @@ msgstr "%s: opsi tidak diketahui '%s'" #: home-manager/home-manager:258 home-manager/home-manager:974 msgid "Run '%s --help' for usage help" -msgstr "" +msgstr "Jalankan '%s --help' untuk bantuan penggunaan" #: home-manager/home-manager:284 home-manager/home-manager:383 msgid "The file %s already exists, leaving it unchanged..." diff --git a/modules/accounts/calendar.nix b/modules/accounts/calendar.nix index d53d3afa..e96f2f2d 100644 --- a/modules/accounts/calendar.nix +++ b/modules/accounts/calendar.nix @@ -12,7 +12,7 @@ let path = mkOption { type = types.str; default = "${cfg.basePath}/${name}"; - defaultText = "‹accounts.contact.basePath›/‹name›"; + defaultText = "‹accounts.calendar.basePath›/‹name›"; description = "The path of the storage."; }; diff --git a/modules/config/i18n.nix b/modules/config/i18n.nix index e9b01b4e..d5619afb 100644 --- a/modules/config/i18n.nix +++ b/modules/config/i18n.nix @@ -15,15 +15,16 @@ # below for changes: # https://github.com/NixOS/nixpkgs/blob/nixpkgs-unstable/pkgs/development/libraries/glibc/nix-locale-archive.patch -{ lib, pkgs, ... }: +{ lib, pkgs, config, ... }: with lib; let + inherit (config.i18n) glibcLocales; - inherit (pkgs.glibcLocales) version; + inherit (glibcLocales) version; - archivePath = "${pkgs.glibcLocales}/lib/locale/locale-archive"; + archivePath = "${glibcLocales}/lib/locale/locale-archive"; # lookup the version of glibcLocales and set the appropriate environment vars localeVars = if versionAtLeast version "2.27" then { @@ -36,6 +37,31 @@ let in { meta.maintainers = with maintainers; [ midchildan ]; + options = { + i18n.glibcLocales = mkOption { + type = types.path; + description = '' + Customized glibcLocales package providing + the LOCALE_ARCHIVE_* environment variable. + + This option only applies to the Linux platform. + + When Home Manager is configured with NixOS, the default value + will be set to i18n.glibcLocales from the + system configuration. + ''; + example = literalExpression '' + pkgs.glibcLocales.override { + allLocales = false; + locales = [ "en_US.UTF-8/UTF-8" ]; + } + ''; + # NB. See nixos/default.nix for NixOS default. + default = pkgs.glibcLocales; + defaultText = literalExpression "pkgs.glibcLocales"; + }; + }; + config = mkIf pkgs.stdenv.hostPlatform.isLinux { # For shell sessions. home.sessionVariables = localeVars; diff --git a/modules/misc/news.nix b/modules/misc/news.nix index f6584383..6d8a4003 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1143,6 +1143,28 @@ in A new module is available: 'services.ssh-agent' ''; } + + { + time = "2023-07-08T08:27:41+00:00"; + message = '' + A new modules is available: 'programs.darcs' + ''; + } + + { + time = "2023-07-08T09:21:06+00:00"; + message = '' + A new module is available: 'programs.pyenv'. + ''; + } + + { + time = "2023-07-08T09:44:56+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.swayosd' + ''; + } ]; }; } diff --git a/modules/misc/xfconf.nix b/modules/misc/xfconf.nix index ab21a66b..f9858c5f 100644 --- a/modules/misc/xfconf.nix +++ b/modules/misc/xfconf.nix @@ -76,7 +76,7 @@ in { settings = mkOption { type = with types; # xfIntVariant must come AFTER str; otherwise strings are treated as submodule imports... - let value = oneOf [ bool int float str xfIntVariant ]; + let value = nullOr (oneOf [ bool int float str xfIntVariant ]); in attrsOf (attrsOf (either value (listOf value))) // { description = "xfconf settings"; }; @@ -108,8 +108,11 @@ in { mkCommand = channel: property: value: '' $DRY_RUN_CMD ${pkgs.xfce.xfconf}/bin/xfconf-query \ ${ - escapeShellArgs - ([ "-n" "-c" channel "-p" "/${property}" ] ++ withType value) + escapeShellArgs ([ "-c" channel "-p" "/${property}" ] + ++ (if value == null then + [ "-r" ] + else + [ "-n" ] ++ withType value)) } ''; diff --git a/modules/modules.nix b/modules/modules.nix index f6a15c02..a77b75e6 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -70,6 +70,7 @@ let ./programs/chromium.nix ./programs/command-not-found/command-not-found.nix ./programs/comodoro.nix + ./programs/darcs.nix ./programs/dircolors.nix ./programs/direnv.nix ./programs/discocss.nix @@ -168,6 +169,7 @@ let ./programs/pls.nix ./programs/powerline-go.nix ./programs/pubs.nix + ./programs/pyenv.nix ./programs/pylint.nix ./programs/qutebrowser.nix ./programs/rbw.nix @@ -310,6 +312,7 @@ let ./services/stalonetray.nix ./services/status-notifier-watcher.nix ./services/swayidle.nix + ./services/swayosd.nix ./services/sxhkd.nix ./services/syncthing.nix ./services/systembus-notify.nix diff --git a/modules/po/id.po b/modules/po/id.po index 6ebbcd0a..37335ae2 100644 --- a/modules/po/id.po +++ b/modules/po/id.po @@ -8,17 +8,20 @@ msgstr "" "Project-Id-Version: Home Manager Modules\n" "Report-Msgid-Bugs-To: https://github.com/nix-community/home-manager/issues\n" "POT-Creation-Date: 2023-05-27 09:08+0200\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: Automatically generated\n" -"Language-Team: none\n" +"PO-Revision-Date: 2023-07-01 13:50+0000\n" +"Last-Translator: Reza Almanda \n" +"Language-Team: Indonesian \n" "Language: id\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Weblate 5.0-dev\n" #: modules/files.nix:234 msgid "Creating home file links in %s" -msgstr "" +msgstr "Membuat tautan file beranda dalam %s" #: modules/files.nix:247 msgid "Cleaning up orphan links from %s" @@ -26,11 +29,11 @@ msgstr "" #: modules/files.nix:263 msgid "Creating profile generation %s" -msgstr "" +msgstr "Membuat profil %s" #: modules/files.nix:280 msgid "No change so reusing latest profile generation %s" -msgstr "" +msgstr "Tidak ada perubahan, jadi gunakan kembali pembuatan profil terbaru %s%s" #: modules/home-environment.nix:627 msgid "" @@ -50,11 +53,11 @@ msgstr "" #: modules/home-environment.nix:660 msgid "Activating %s" -msgstr "" +msgstr "Mengaktifkan %s" #: modules/lib-bash/activation-init.sh:22 msgid "Migrating profile from %s to %s" -msgstr "" +msgstr "Memigrasi profil dari %s ke %s" #: modules/lib-bash/activation-init.sh:53 msgid "Could not find suitable profile directory, tried %s and %s" diff --git a/modules/programs/antidote.nix b/modules/programs/antidote.nix index 2c4a14d1..f1fa044c 100644 --- a/modules/programs/antidote.nix +++ b/modules/programs/antidote.nix @@ -8,11 +8,13 @@ let (optionalString (config.programs.zsh.dotDir != null) (config.programs.zsh.dotDir + "/")) + file; - zPluginStr = with lib; - (pluginNames: - optionalString (pluginNames != [ ]) "${concatStrings (map (name: '' - ${name} - '') pluginNames)}"); + zPluginStr = (pluginNames: + optionalString (pluginNames != [ ]) "${concatStrings (map (name: '' + ${name} + '') pluginNames)}"); + + parseHashId = path: + elemAt (builtins.match "/nix/store/([a-zA-Z0-9]+)-.*" path) 0; in { meta.maintainers = [ maintainers.hitsmaxft ]; @@ -33,20 +35,24 @@ in { config = mkIf cfg.enable { home.packages = [ cfg.package ]; - - home.file."${relToDotDir ".zsh_plugins.txt"}".text = zPluginStr cfg.plugins; - - ### move zsh_plugins.txt - programs.zsh.initExtraBeforeCompInit = '' + programs.zsh.initExtraBeforeCompInit = let + configFiles = pkgs.runCommand "hm_antidote-files" { } '' + echo "${zPluginStr cfg.plugins}" > $out + ''; + hashId = parseHashId "${configFiles}"; + in '' ## home-manager/antidote begin : source ${cfg.package}/share/antidote/antidote.zsh ${optionalString cfg.useFriendlyNames "zstyle ':antidote:bundle' use-friendly-names 'yes'"} - bundlefile=$HOME/${relToDotDir ".zsh_plugins.txt"} + + bundlefile=${configFiles} zstyle ':antidote:bundle' file $bundlefile - staticfile=$HOME/${relToDotDir ".zsh_plugins.zsh"} + staticfile=/tmp/tmp_hm_zsh_plugins.zsh-${hashId} zstyle ':antidote:static' file $staticfile + antidote load $bundlefile $staticfile + ## home-manager/antidote end ''; }; diff --git a/modules/programs/darcs.nix b/modules/programs/darcs.nix new file mode 100644 index 00000000..a2a45cba --- /dev/null +++ b/modules/programs/darcs.nix @@ -0,0 +1,52 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.darcs; + +in { + meta.maintainers = with maintainers; [ chris-martin ]; + + options = { + programs.darcs = { + enable = mkEnableOption "darcs"; + + package = mkPackageOption pkgs "darcs" { }; + + author = mkOption { + type = types.listOf types.str; + default = [ ]; + example = [ "Fred Bloggs " ]; + description = '' + If this list has a single entry, it will be used as the author + when you record a patch. If there are multiple entries, Darcs + will prompt you to choose one of them. + ''; + }; + + boring = mkOption { + type = types.listOf types.str; + default = [ ]; + example = [ "^.idea$" ".iml$" "^.stack-work$" ]; + description = "File patterns to ignore"; + }; + }; + }; + + config = mkIf cfg.enable (mkMerge [ + { home.packages = [ cfg.package ]; } + + (mkIf (cfg.author != [ ]) { + home.file.".darcs/author".text = + concatMapStrings (x: x + "\n") cfg.author; + }) + + (mkIf (cfg.boring != [ ]) { + home.file.".darcs/boring".text = + concatMapStrings (x: x + "\n") cfg.boring; + }) + + ]); +} diff --git a/modules/programs/himalaya.nix b/modules/programs/himalaya.nix index 1a57ec89..673bd7de 100644 --- a/modules/programs/himalaya.nix +++ b/modules/programs/himalaya.nix @@ -8,14 +8,18 @@ let # attrs util that removes entries containing a null value compactAttrs = lib.filterAttrs (_: val: !isNull val); + # Needed for notmuch config, because the DB is here, and not in each account's dir + maildirBasePath = config.accounts.email.maildirBasePath; + # make a himalaya config from a home-manager email account config mkAccountConfig = _: account: let - imapEnabled = !isNull account.imap; - maildirEnabled = !imapEnabled && !isNull account.maildir - && !account.notmuch.enable; - notmuchEnabled = !imapEnabled && !isNull account.maildir - && account.notmuch.enable; + # Use notmuch if it's enabled, otherwise fallback to IMAP then maildir + # Maildir is always set, so there's no easy way to detect if it's being used + notmuchEnabled = account.notmuch.enable; + imapEnabled = !isNull account.imap && !notmuchEnabled; + maildirEnabled = !isNull account.maildir && !imapEnabled + && !notmuchEnabled; globalConfig = { email = account.address; @@ -55,7 +59,7 @@ let notmuchConfig = lib.optionalAttrs notmuchEnabled (compactAttrs { backend = "notmuch"; - notmuch-db-path = account.maildir.absPath; + notmuch-db-path = maildirBasePath; }); smtpConfig = lib.optionalAttrs (!isNull account.smtp) (compactAttrs { diff --git a/modules/programs/khal.nix b/modules/programs/khal.nix index 555a3b80..209716a1 100644 --- a/modules/programs/khal.nix +++ b/modules/programs/khal.nix @@ -25,7 +25,6 @@ let genCalendarStr = name: value: concatStringsSep "\n" ([ "[[${name}]]" - "highlight_event_days = True" "path = ${ value.local.path + "/" + (optionalString (value.khal.type == "discover") value.khal.glob) @@ -158,6 +157,7 @@ in { # locale = definedAttrs (cfg.locale // { _module = null; }); default = optionalAttrs (!isNull primaryAccount) { + highlight_event_days = true; default_calendar = if isNull primaryAccount.primaryCollection then primaryAccount.name else diff --git a/modules/programs/nushell.nix b/modules/programs/nushell.nix index a977bd4a..b72cbb69 100644 --- a/modules/programs/nushell.nix +++ b/modules/programs/nushell.nix @@ -96,6 +96,23 @@ in { ''; }; + loginFile = mkOption { + type = types.nullOr (linesOrSource "login.nu"); + default = null; + example = '' + # Prints "Hello, World" upon logging into tty1 + if (tty) == "/dev/tty1" { + echo "Hello, World" + } + ''; + description = '' + The login file to be used for nushell upon logging in. + + + See for more information. + ''; + }; + extraConfig = mkOption { type = types.lines; default = ""; @@ -112,6 +129,14 @@ in { ''; }; + extraLogin = mkOption { + type = types.lines; + default = ""; + description = '' + Additional configuration to add to the nushell login file. + ''; + }; + shellAliases = mkOption { type = types.attrsOf types.str; default = { }; @@ -161,6 +186,12 @@ in { envVarsStr ]; }) + (mkIf (cfg.loginFile != null || cfg.extraLogin != "") { + "${configDir}/login.nu".text = mkMerge [ + (mkIf (cfg.loginFile != null) cfg.loginFile.text) + cfg.extraLogin + ]; + }) ]; }; } diff --git a/modules/programs/pyenv.nix b/modules/programs/pyenv.nix new file mode 100644 index 00000000..a83713bb --- /dev/null +++ b/modules/programs/pyenv.nix @@ -0,0 +1,79 @@ +{ config, pkgs, lib, ... }: + +let + + cfg = config.programs.pyenv; + + tomlFormat = pkgs.formats.toml { }; + +in { + meta.maintainers = with lib.maintainers; [ tmarkus ]; + + options.programs.pyenv = { + enable = lib.mkEnableOption "pyenv"; + + package = lib.mkOption { + type = lib.types.package; + default = pkgs.pyenv; + defaultText = lib.literalExpression "pkgs.pyenv"; + description = "The package to use for pyenv."; + }; + + enableBashIntegration = lib.mkOption { + type = lib.types.bool; + default = true; + description = '' + Whether to enable pyenv's Bash integration. + ''; + }; + + enableZshIntegration = lib.mkOption { + type = lib.types.bool; + default = true; + description = '' + Whether to enable pyenv's Zsh integration. + ''; + }; + + enableFishIntegration = lib.mkOption { + type = lib.types.bool; + default = true; + description = '' + Whether to enable pyenv's Fish integration. + ''; + }; + + rootDirectory = lib.mkOption { + type = lib.types.path; + apply = toString; + default = "${config.xdg.dataHome}/pyenv"; + defaultText = "\${config.xdg.dataHome}/pyenv"; + description = '' + The pyenv root directory (PYENV_ROOT). + + Note: Deviating from upstream which uses `$HOME/.pyenv`, + the default path is set according to the XDG base directory specification. + ''; + }; + }; + + config = lib.mkIf cfg.enable { + # Always add the configured `pyenv` package. + home.packages = [ cfg.package ]; + + programs.bash.initExtra = lib.mkIf cfg.enableBashIntegration '' + export PYENV_ROOT="${cfg.rootDirectory}" + eval "$(${lib.getExe cfg.package} init - bash)" + ''; + + programs.zsh.initExtra = lib.mkIf cfg.enableZshIntegration '' + export PYENV_ROOT="${cfg.rootDirectory}" + eval "$(${lib.getExe cfg.package} init - zsh)" + ''; + + programs.fish.interactiveShellInit = lib.mkIf cfg.enableFishIntegration '' + set -Ux PYENV_ROOT "${cfg.rootDirectory}" + ${lib.getExe cfg.package} init - fish | source + ''; + }; +} diff --git a/modules/services/imapnotify.nix b/modules/services/imapnotify.nix index 0197ec54..bc595ca9 100644 --- a/modules/services/imapnotify.nix +++ b/modules/services/imapnotify.nix @@ -8,6 +8,8 @@ let safeName = lib.replaceStrings [ "@" ":" "\\" "[" "]" ] [ "-" "-" "-" "" "" ]; + configName = account: "imapnotify-${safeName account.name}-config.json"; + imapnotifyAccounts = filter (a: a.imapnotify.enable) (attrValues config.accounts.email.accounts); @@ -19,9 +21,9 @@ let Unit = { Description = "imapnotify for ${name}"; }; Service = { - ExecStart = "${pkgs.goimapnotify}/bin/goimapnotify -conf ${ - genAccountConfig account - }"; + # Use the nix store path for config to ensure service restarts when it changes + ExecStart = + "${getExe cfg.package} -conf '${genAccountConfig account}'"; Restart = "always"; RestartSec = 30; Type = "simple"; @@ -34,8 +36,30 @@ let }; }; + genAccountAgent = account: + let name = safeName account.name; + in { + name = "imapnotify-${name}"; + value = { + enable = true; + config = { + # Use the nix store path for config to ensure service restarts when it changes + ProgramArguments = + [ "${getExe cfg.package}" "-conf" "${genAccountConfig account}" ]; + KeepAlive = true; + ThrottleInterval = 30; + ExitTimeOut = 0; + ProcessType = "Background"; + RunAtLoad = true; + } // optionalAttrs account.notmuch.enable { + EnvironmentVariables.NOTMUCH_CONFIG = + "${config.xdg.configHome}/notmuch/default/config"; + }; + }; + }; + genAccountConfig = account: - pkgs.writeText "imapnotify-${safeName account.name}-config.json" (let + pkgs.writeText (configName account) (let port = if account.imap.port != null then account.imap.port else if account.imap.tls.enable then @@ -62,7 +86,17 @@ in { meta.maintainers = [ maintainers.nickhu ]; options = { - services.imapnotify = { enable = mkEnableOption "imapnotify"; }; + services.imapnotify = { + enable = mkEnableOption "imapnotify"; + + package = mkOption { + type = types.package; + default = pkgs.goimapnotify; + defaultText = literalExpression "pkgs.goimapnotify"; + example = literalExpression "pkgs.imapnotify"; + description = "The imapnotify package to use"; + }; + }; accounts.email.accounts = mkOption { type = with types; attrsOf (submodule (import ./imapnotify-accounts.nix)); @@ -79,8 +113,6 @@ in { + concatMapStringsSep ", " (a: a.name) badAccounts; }; in [ - (lib.hm.assertions.assertPlatform "services.imapnotify" pkgs - lib.platforms.linux) (checkAccounts (a: a.maildir == null) "maildir configuration") (checkAccounts (a: a.imap == null) "IMAP configuration") (checkAccounts (a: a.passwordCommand == null) "password command") @@ -88,5 +120,12 @@ in { ]; systemd.user.services = listToAttrs (map genAccountUnit imapnotifyAccounts); + + launchd.agents = listToAttrs (map genAccountAgent imapnotifyAccounts); + + xdg.configFile = listToAttrs (map (account: { + name = "imapnotify/${configName account}"; + value.source = genAccountConfig account; + }) imapnotifyAccounts); }; } diff --git a/modules/services/swayosd.nix b/modules/services/swayosd.nix new file mode 100644 index 00000000..067c104c --- /dev/null +++ b/modules/services/swayosd.nix @@ -0,0 +1,58 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.swayosd; + +in { + meta.maintainers = [ hm.maintainers.pltanton ]; + + options.services.swayosd = { + enable = mkEnableOption '' + swayosd, a GTK based on screen display for keyboard shortcuts like + caps-lock and volume''; + + package = mkPackageOption pkgs "swayosd" { }; + + maxVolume = mkOption { + type = types.nullOr types.ints.unsigned; + default = null; + example = 120; + description = '' + Sets the maximum volume. + ''; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + (hm.assertions.assertPlatform "services.swayosd" pkgs platforms.linux) + ]; + + home.packages = [ cfg.package ]; + + systemd.user = { + services.swayosd = { + Unit = { + Description = "Volume/backlight OSD indicator"; + PartOf = [ "graphical-session.target" ]; + After = [ "graphical-session.target" ]; + ConditionEnvironment = "WAYLAND_DISPLAY"; + Documentation = "man:swayosd(1)"; + }; + + Service = { + Type = "simple"; + ExecStart = "${cfg.package}/bin/swayosd" + + (optionalString (cfg.maxVolume != null) + " --max-volume ${toString cfg.maxVolume}"); + Restart = "always"; + }; + + Install = { WantedBy = [ "graphical-session.target" ]; }; + }; + }; + }; +} diff --git a/modules/services/unison.nix b/modules/services/unison.nix index d7f8a628..e32f7052 100644 --- a/modules/services/unison.nix +++ b/modules/services/unison.nix @@ -22,7 +22,7 @@ let }; commandOptions = mkOption rec { - type = with types; attrsOf str; + type = with types; attrsOf (either str (listOf str)); apply = mergeAttrs default; default = { repeat = "watch"; @@ -36,6 +36,8 @@ let Additional command line options as a dictionary to pass to the unison program. + Use a list of strings to declare the same option multiple times. + See unison @@ -60,7 +62,9 @@ let }; }; - serialiseArg = key: val: escapeShellArg "-${key}=${escape [ "=" ] val}"; + serialiseArg = key: val: + concatStringsSep " " + (forEach (toList val) (x: escapeShellArg "-${key}=${escape [ "=" ] x}")); serialiseArgs = args: concatStringsSep " " (mapAttrsToList serialiseArg args); diff --git a/modules/services/vdirsyncer.nix b/modules/services/vdirsyncer.nix index 75ad0bba..ab9230d0 100644 --- a/modules/services/vdirsyncer.nix +++ b/modules/services/vdirsyncer.nix @@ -67,9 +67,11 @@ in { Service = { Type = "oneshot"; # TODO `vdirsyncer discover` - ExecStart = "${cfg.package}/bin/vdirsyncer ${ - concatStringsSep " " vdirsyncerOptions - } sync"; + ExecStart = let optStr = concatStringsSep " " vdirsyncerOptions; + in [ + "${cfg.package}/bin/vdirsyncer ${optStr} metasync" + "${cfg.package}/bin/vdirsyncer ${optStr} sync" + ]; }; }; diff --git a/modules/services/window-managers/i3-sway/lib/options.nix b/modules/services/window-managers/i3-sway/lib/options.nix index 0cbea642..6c9f38da 100644 --- a/modules/services/window-managers/i3-sway/lib/options.nix +++ b/modules/services/window-managers/i3-sway/lib/options.nix @@ -770,7 +770,7 @@ in { [ { command = "systemctl --user restart polybar"; always = true; notification = false; } { command = "dropbox start"; notification = false; } - { command = "firefox"; workspace = "1: web"; } + { command = "firefox"; } ]; '' else diff --git a/nixos/default.nix b/nixos/default.nix index f8a5d642..736a787d 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -23,6 +23,9 @@ in { # fontconfig by default. fonts.fontconfig.enable = lib.mkDefault (cfg.useUserPackages && config.fonts.fontconfig.enable); + + # Inherit glibcLocales setting from NixOS. + i18n.glibcLocales = lib.mkDefault config.i18n.glibcLocales; }]; }; } diff --git a/tests/default.nix b/tests/default.nix index c04de313..89026403 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -68,6 +68,7 @@ import nmt { ./modules/programs/browserpass ./modules/programs/btop ./modules/programs/comodoro + ./modules/programs/darcs ./modules/programs/dircolors ./modules/programs/direnv ./modules/programs/emacs @@ -88,6 +89,7 @@ import nmt { ./modules/programs/k9s ./modules/programs/kakoune ./modules/programs/kitty + ./modules/programs/khal ./modules/programs/ledger ./modules/programs/less ./modules/programs/lf @@ -115,6 +117,7 @@ import nmt { ./modules/programs/pls ./modules/programs/powerline-go ./modules/programs/pubs + ./modules/programs/pyenv ./modules/programs/qutebrowser ./modules/programs/readline ./modules/programs/ripgrep @@ -143,6 +146,7 @@ import nmt { ./modules/xresources ] ++ lib.optionals isDarwin [ ./modules/launchd + ./modules/services/imapnotify-darwin ./modules/targets-darwin ] ++ lib.optionals isLinux [ ./modules/config/i18n @@ -201,6 +205,7 @@ import nmt { ./modules/services/gpg-agent ./modules/services/gromit-mpx ./modules/services/home-manager-auto-upgrade + ./modules/services/imapnotify ./modules/services/kanshi ./modules/services/lieer ./modules/services/mopidy @@ -218,6 +223,7 @@ import nmt { ./modules/services/redshift-gammastep ./modules/services/screen-locker ./modules/services/swayidle + ./modules/services/swayosd ./modules/services/sxhkd ./modules/services/syncthing/linux ./modules/services/trayer diff --git a/tests/modules/config/i18n/default.nix b/tests/modules/config/i18n/default.nix index 10b35b6f..667b3b1d 100644 --- a/tests/modules/config/i18n/default.nix +++ b/tests/modules/config/i18n/default.nix @@ -14,4 +14,26 @@ ''; }; }; + + i18n-custom-locales = { pkgs, ... }: { + config = let stub = pkgs.glibcLocalesCustom; + in { + test.stubs.glibcLocalesCustom = { + inherit (pkgs.glibcLocales) version; + outPath = null; # we need a real path for this stub + }; + + i18n.glibcLocales = stub; + + nmt.script = '' + hmEnvFile=home-path/etc/profile.d/hm-session-vars.sh + assertFileExists $hmEnvFile + assertFileRegex $hmEnvFile 'LOCALE_ARCHIVE_.*${stub}' + + envFile=home-files/.config/environment.d/10-home-manager.conf + assertFileExists $envFile + assertFileRegex $envFile 'LOCALE_ARCHIVE_.*${stub}' + ''; + }; + }; } diff --git a/tests/modules/home-environment/session-variables.nix b/tests/modules/home-environment/session-variables.nix index 08c988d2..e1c8bedf 100644 --- a/tests/modules/home-environment/session-variables.nix +++ b/tests/modules/home-environment/session-variables.nix @@ -9,7 +9,7 @@ let if [ -n "$__HM_SESS_VARS_SOURCED" ]; then return; fi export __HM_SESS_VARS_SOURCED=1 - export LOCALE_ARCHIVE_2_27="${pkgs.glibcLocales}/lib/locale/locale-archive" + export LOCALE_ARCHIVE_2_27="${config.i18n.glibcLocales}/lib/locale/locale-archive" export V1="v1" export V2="v2-v1" export XDG_CACHE_HOME="/home/hm-user/.cache" diff --git a/tests/modules/misc/xdg/system-dirs.nix b/tests/modules/misc/xdg/system-dirs.nix index fa34ae0b..432724bf 100644 --- a/tests/modules/misc/xdg/system-dirs.nix +++ b/tests/modules/misc/xdg/system-dirs.nix @@ -10,7 +10,7 @@ assertFileExists $envFile assertFileContent $envFile ${ pkgs.writeText "expected" '' - LOCALE_ARCHIVE_2_27=${pkgs.glibcLocales}/lib/locale/locale-archive + LOCALE_ARCHIVE_2_27=${config.i18n.glibcLocales}/lib/locale/locale-archive XDG_CACHE_HOME=/home/hm-user/.cache XDG_CONFIG_DIRS=/etc/xdg:/foo/bar''${XDG_CONFIG_DIRS:+:$XDG_CONFIG_DIRS} XDG_CONFIG_HOME=/home/hm-user/.config diff --git a/tests/modules/programs/antidote/antidote.nix b/tests/modules/programs/antidote/antidote.nix index 04ba6dd5..3d8fff6a 100644 --- a/tests/modules/programs/antidote/antidote.nix +++ b/tests/modules/programs/antidote/antidote.nix @@ -24,7 +24,5 @@ in { 'antidote load' assertFileContains home-files/${relToDotDirCustom}/.zshrc \ "zstyle ':antidote:bundle' use-friendly-names 'yes'" - assertFileContains home-files/${relToDotDirCustom}/.zsh_plugins.txt \ - 'zsh-users/zsh-autosuggestions' ''; } diff --git a/tests/modules/programs/beets/mpdstats-external.nix b/tests/modules/programs/beets/mpdstats-external.nix index f7e6d5b1..32a9c073 100644 --- a/tests/modules/programs/beets/mpdstats-external.nix +++ b/tests/modules/programs/beets/mpdstats-external.nix @@ -1,29 +1,27 @@ -{ config, lib, pkgs, ... }: +{ config, ... }: { - config = { - home.stateVersion = "23.05"; + home.stateVersion = "23.05"; - programs.beets = { - enable = true; - package = config.lib.test.mkStubPackage { outPath = "@beets@"; }; - mpdIntegration = { - enableStats = true; - host = "10.0.0.42"; - port = 6601; - }; + programs.beets = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@beets@"; }; + mpdIntegration = { + enableStats = true; + host = "10.0.0.42"; + port = 6601; }; - - nmt.script = '' - assertFileExists home-files/.config/beets/config.yaml - assertFileContent \ - home-files/.config/beets/config.yaml \ - ${./mpdstats-external-expected.yaml} - - assertFileExists home-files/.config/systemd/user/beets-mpdstats.service - assertFileContent \ - home-files/.config/systemd/user/beets-mpdstats.service \ - ${./mpdstats-external-expected.service} - ''; }; + + nmt.script = '' + assertFileExists home-files/.config/beets/config.yaml + assertFileContent \ + home-files/.config/beets/config.yaml \ + ${./mpdstats-external-expected.yaml} + + assertFileExists home-files/.config/systemd/user/beets-mpdstats.service + assertFileContent \ + home-files/.config/systemd/user/beets-mpdstats.service \ + ${./mpdstats-external-expected.service} + ''; } diff --git a/tests/modules/programs/beets/mpdstats.nix b/tests/modules/programs/beets/mpdstats.nix index b4fba4a4..781eaa84 100644 --- a/tests/modules/programs/beets/mpdstats.nix +++ b/tests/modules/programs/beets/mpdstats.nix @@ -1,31 +1,29 @@ -{ config, lib, pkgs, ... }: +{ config, ... }: { - config = { - home.stateVersion = "23.05"; + home.stateVersion = "23.05"; - services.mpd = { - enable = true; - musicDirectory = "/my/music/dir"; - network.port = 4242; - }; - - programs.beets = { - enable = true; - package = config.lib.test.mkStubPackage { outPath = "@beets@"; }; - mpdIntegration.enableStats = true; - }; - - nmt.script = '' - assertFileExists home-files/.config/beets/config.yaml - assertFileContent \ - home-files/.config/beets/config.yaml \ - ${./mpdstats-expected.yaml} - - assertFileExists home-files/.config/systemd/user/beets-mpdstats.service - assertFileContent \ - home-files/.config/systemd/user/beets-mpdstats.service \ - ${./mpdstats-expected.service} - ''; + services.mpd = { + enable = true; + musicDirectory = "/my/music/dir"; + network.port = 4242; }; + + programs.beets = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@beets@"; }; + mpdIntegration.enableStats = true; + }; + + nmt.script = '' + assertFileExists home-files/.config/beets/config.yaml + assertFileContent \ + home-files/.config/beets/config.yaml \ + ${./mpdstats-expected.yaml} + + assertFileExists home-files/.config/systemd/user/beets-mpdstats.service + assertFileContent \ + home-files/.config/systemd/user/beets-mpdstats.service \ + ${./mpdstats-expected.service} + ''; } diff --git a/tests/modules/programs/beets/mpdupdate.nix b/tests/modules/programs/beets/mpdupdate.nix index 3516ae20..b73da81e 100644 --- a/tests/modules/programs/beets/mpdupdate.nix +++ b/tests/modules/programs/beets/mpdupdate.nix @@ -1,20 +1,18 @@ -{ config, lib, pkgs, ... }: +{ config, ... }: { - config = { - home.stateVersion = "23.05"; + home.stateVersion = "23.05"; - programs.beets = { - enable = true; - package = config.lib.test.mkStubPackage { outPath = "@beets@"; }; - mpdIntegration.enableUpdate = true; - }; - - nmt.script = '' - assertFileExists home-files/.config/beets/config.yaml - assertFileContent \ - home-files/.config/beets/config.yaml \ - ${./mpdupdate-expected.yaml} - ''; + programs.beets = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@beets@"; }; + mpdIntegration.enableUpdate = true; }; + + nmt.script = '' + assertFileExists home-files/.config/beets/config.yaml + assertFileContent \ + home-files/.config/beets/config.yaml \ + ${./mpdupdate-expected.yaml} + ''; } diff --git a/tests/modules/programs/darcs/author-expected.txt b/tests/modules/programs/darcs/author-expected.txt new file mode 100644 index 00000000..94be1127 --- /dev/null +++ b/tests/modules/programs/darcs/author-expected.txt @@ -0,0 +1,2 @@ +Real Person +Real Person diff --git a/tests/modules/programs/darcs/author.nix b/tests/modules/programs/darcs/author.nix new file mode 100644 index 00000000..26cfb469 --- /dev/null +++ b/tests/modules/programs/darcs/author.nix @@ -0,0 +1,17 @@ +{ pkgs, ... }: + +{ + config = { + programs.darcs = { + enable = true; + author = [ + "Real Person " + "Real Person " + ]; + }; + + nmt.script = '' + assertFileContent home-files/.darcs/author ${./author-expected.txt} + ''; + }; +} diff --git a/tests/modules/programs/darcs/boring-expected.txt b/tests/modules/programs/darcs/boring-expected.txt new file mode 100644 index 00000000..4a41138c --- /dev/null +++ b/tests/modules/programs/darcs/boring-expected.txt @@ -0,0 +1,3 @@ +^.idea$ +.iml$ +^.stack-work$ diff --git a/tests/modules/programs/darcs/boring.nix b/tests/modules/programs/darcs/boring.nix new file mode 100644 index 00000000..ae02f18c --- /dev/null +++ b/tests/modules/programs/darcs/boring.nix @@ -0,0 +1,14 @@ +{ pkgs, ... }: + +{ + config = { + programs.darcs = { + enable = true; + boring = [ "^.idea$" ".iml$" "^.stack-work$" ]; + }; + + nmt.script = '' + assertFileContent home-files/.darcs/boring ${./boring-expected.txt} + ''; + }; +} diff --git a/tests/modules/programs/darcs/default.nix b/tests/modules/programs/darcs/default.nix new file mode 100644 index 00000000..78984123 --- /dev/null +++ b/tests/modules/programs/darcs/default.nix @@ -0,0 +1,4 @@ +{ + darcs-author = ./author.nix; + darcs-boring = ./boring.nix; +} diff --git a/tests/modules/programs/himalaya/notmuch-sendmail-expected.toml b/tests/modules/programs/himalaya/notmuch-sendmail-expected.toml index 1eaa511b..fcc00c7c 100644 --- a/tests/modules/programs/himalaya/notmuch-sendmail-expected.toml +++ b/tests/modules/programs/himalaya/notmuch-sendmail-expected.toml @@ -5,7 +5,7 @@ backend = "notmuch" default = true display-name = "H. M. Test" email = "hm@example.com" -notmuch-db-path = "/home/hm-user/Maildir/hm@example.com" +notmuch-db-path = "/home/hm-user/Maildir" sender = "sendmail" sendmail-cmd = "msmtp" diff --git a/tests/modules/programs/khal/config.nix b/tests/modules/programs/khal/config.nix new file mode 100644 index 00000000..1633d132 --- /dev/null +++ b/tests/modules/programs/khal/config.nix @@ -0,0 +1,32 @@ +{ ... }: + +{ + programs.khal.enable = true; + accounts.calendar = { + basePath = "$XDG_CONFIG_HOME/cal"; + accounts = { + test = { + primary = true; + primaryCollection = "test"; + khal = { + enable = true; + readOnly = true; + type = "calendar"; + }; + local.type = "filesystem"; + local.fileExt = ".ics"; + name = "test"; + remote = { + type = "http"; + url = "https://example.com/events.ical"; + }; + }; + }; + }; + + test.stubs = { khal = { }; }; + + nmt.script = '' + assertFileExists home-files/.config/khal/config + ''; +} diff --git a/tests/modules/programs/khal/default.nix b/tests/modules/programs/khal/default.nix new file mode 100644 index 00000000..999dc4c5 --- /dev/null +++ b/tests/modules/programs/khal/default.nix @@ -0,0 +1 @@ +{ khal-config = ./config.nix; } diff --git a/tests/modules/programs/nnn/nnn.nix b/tests/modules/programs/nnn/nnn.nix index 7a01fd85..948317ae 100644 --- a/tests/modules/programs/nnn/nnn.nix +++ b/tests/modules/programs/nnn/nnn.nix @@ -1,55 +1,53 @@ -{ config, lib, pkgs, ... }: +{ pkgs, ... }: { - config = { - programs.nnn = { - enable = true; - bookmarks = { - d = "~/Documents"; - D = "~/Downloads"; - p = "~/Pictures"; - v = "~/Videos"; - }; - package = pkgs.nnnDummy; - extraPackages = with pkgs; [ foo bar ]; - plugins = { - src = ./plugins; - mappings = { - c = "fzcd"; - f = "finder"; - v = "imgview"; - }; - }; + programs.nnn = { + enable = true; + bookmarks = { + d = "~/Documents"; + D = "~/Downloads"; + p = "~/Pictures"; + v = "~/Videos"; }; - - test.stubs = { - nnnDummy.buildScript = '' - runHook preInstall - - mkdir -p "$out/bin" - touch "$out/bin/nnn" - chmod +x "$out/bin/nnn" - - runHook postInstall - ''; - foo = { name = "foo"; }; - bar = { name = "bar"; }; - }; - - nmt = { - description = - "Check if the binary is correctly wrapped and if the symlinks are made"; - script = '' - assertDirectoryExists home-files/.config/nnn/plugins - - for bookmark in 'export NNN_BMS' '~/Downloads' '~/Documents' '~/Pictures' '~/Videos'; do - assertFileRegex home-path/bin/nnn "$bookmark" - done - - for plugin in 'export NNN_PLUG' 'fzcd' 'finder' 'imgview'; do - assertFileRegex home-path/bin/nnn "$plugin" - done - ''; + package = pkgs.nnnDummy; + extraPackages = with pkgs; [ foo bar ]; + plugins = { + src = ./plugins; + mappings = { + c = "fzcd"; + f = "finder"; + v = "imgview"; + }; }; }; + + test.stubs = { + nnnDummy.buildScript = '' + runHook preInstall + + mkdir -p "$out/bin" + touch "$out/bin/nnn" + chmod +x "$out/bin/nnn" + + runHook postInstall + ''; + foo = { name = "foo"; }; + bar = { name = "bar"; }; + }; + + nmt = { + description = + "Check if the binary is correctly wrapped and if the symlinks are made"; + script = '' + assertDirectoryExists home-files/.config/nnn/plugins + + for bookmark in 'export NNN_BMS' '~/Downloads' '~/Documents' '~/Pictures' '~/Videos'; do + assertFileRegex home-path/bin/nnn "$bookmark" + done + + for plugin in 'export NNN_PLUG' 'fzcd' 'finder' 'imgview'; do + assertFileRegex home-path/bin/nnn "$plugin" + done + ''; + }; } diff --git a/tests/modules/programs/nushell/example-settings.nix b/tests/modules/programs/nushell/example-settings.nix index d8cb01a7..7259db6d 100644 --- a/tests/modules/programs/nushell/example-settings.nix +++ b/tests/modules/programs/nushell/example-settings.nix @@ -16,6 +16,13 @@ let-env FOO = 'BAR' ''; + loginFile.text = '' + # Prints "Hello, World" upon logging into tty1 + if (tty) == "/dev/tty1" { + echo "Hello, World" + } + ''; + shellAliases = { "lsname" = "(ls | get name)"; "ll" = "ls -a"; @@ -38,5 +45,8 @@ assertFileContent \ "${configDir}/env.nu" \ ${./env-expected.nu} + assertFileContent \ + "${configDir}/login.nu" \ + ${./login-expected.nu} ''; } diff --git a/tests/modules/programs/nushell/login-expected.nu b/tests/modules/programs/nushell/login-expected.nu new file mode 100644 index 00000000..9c21789d --- /dev/null +++ b/tests/modules/programs/nushell/login-expected.nu @@ -0,0 +1,5 @@ +# Prints "Hello, World" upon logging into tty1 +if (tty) == "/dev/tty1" { + echo "Hello, World" +} + diff --git a/tests/modules/programs/pyenv/bash.nix b/tests/modules/programs/pyenv/bash.nix new file mode 100644 index 00000000..ac6a8f0c --- /dev/null +++ b/tests/modules/programs/pyenv/bash.nix @@ -0,0 +1,17 @@ +{ ... }: + +{ + programs = { + bash.enable = true; + pyenv.enable = true; + }; + + test.stubs.pyenv = { name = "pyenv"; }; + + nmt.script = '' + assertFileExists home-files/.bashrc + assertFileContains \ + home-files/.bashrc \ + 'eval "$(@pyenv@/bin/pyenv init - bash)"' + ''; +} diff --git a/tests/modules/programs/pyenv/default.nix b/tests/modules/programs/pyenv/default.nix new file mode 100644 index 00000000..c2e65058 --- /dev/null +++ b/tests/modules/programs/pyenv/default.nix @@ -0,0 +1,5 @@ +{ + pyenv-bash = ./bash.nix; + pyenv-zsh = ./zsh.nix; + pyenv-fish = ./fish.nix; +} diff --git a/tests/modules/programs/pyenv/fish.nix b/tests/modules/programs/pyenv/fish.nix new file mode 100644 index 00000000..41b4911b --- /dev/null +++ b/tests/modules/programs/pyenv/fish.nix @@ -0,0 +1,17 @@ +{ ... }: + +{ + programs = { + fish.enable = true; + pyenv.enable = true; + }; + + test.stubs.pyenv = { name = "pyenv"; }; + + nmt.script = '' + assertFileExists home-files/.config/fish/config.fish + assertFileContains \ + home-files/.config/fish/config.fish \ + '@pyenv@/bin/pyenv init - fish | source' + ''; +} diff --git a/tests/modules/programs/pyenv/zsh.nix b/tests/modules/programs/pyenv/zsh.nix new file mode 100644 index 00000000..da029fc2 --- /dev/null +++ b/tests/modules/programs/pyenv/zsh.nix @@ -0,0 +1,17 @@ +{ ... }: + +{ + programs = { + zsh.enable = true; + pyenv.enable = true; + }; + + test.stubs.pyenv = { name = "pyenv"; }; + + nmt.script = '' + assertFileExists home-files/.zshrc + assertFileContains \ + home-files/.zshrc \ + 'eval "$(@pyenv@/bin/pyenv init - zsh)"' + ''; +} diff --git a/tests/modules/programs/qutebrowser/keybindings.nix b/tests/modules/programs/qutebrowser/keybindings.nix index 258c57ad..00e730ef 100644 --- a/tests/modules/programs/qutebrowser/keybindings.nix +++ b/tests/modules/programs/qutebrowser/keybindings.nix @@ -1,47 +1,43 @@ -{ config, lib, pkgs, ... }: - -with lib; +{ lib, pkgs, ... }: { - config = { - programs.qutebrowser = { - enable = true; + programs.qutebrowser = { + enable = true; - enableDefaultBindings = false; + enableDefaultBindings = false; - keyBindings = { - normal = { - "" = "spawn mpv {url}"; - ",l" = ''config-cycle spellcheck.languages ["en-GB"] ["en-US"]''; - "" = mkMerge [ - "config-cycle tabs.show never always" - "config-cycle statusbar.show in-mode always" - "config-cycle scrolling.bar never always" - ]; - }; - prompt = { "" = "prompt-yes"; }; + keyBindings = { + normal = { + "" = "spawn mpv {url}"; + ",l" = ''config-cycle spellcheck.languages ["en-GB"] ["en-US"]''; + "" = lib.mkMerge [ + "config-cycle tabs.show never always" + "config-cycle statusbar.show in-mode always" + "config-cycle scrolling.bar never always" + ]; }; + prompt = { "" = "prompt-yes"; }; }; - - test.stubs.qutebrowser = { }; - - nmt.script = let - qutebrowserConfig = if pkgs.stdenv.hostPlatform.isDarwin then - ".qutebrowser/config.py" - else - ".config/qutebrowser/config.py"; - in '' - assertFileContent \ - home-files/${qutebrowserConfig} \ - ${ - pkgs.writeText "qutebrowser-expected-config.py" '' - config.load_autoconfig(False) - c.bindings.default = {} - config.bind(",l", "config-cycle spellcheck.languages [\"en-GB\"] [\"en-US\"]", mode="normal") - config.bind("", "spawn mpv {url}", mode="normal") - config.bind("", "config-cycle tabs.show never always ;; config-cycle statusbar.show in-mode always ;; config-cycle scrolling.bar never always", mode="normal") - config.bind("", "prompt-yes", mode="prompt")'' - } - ''; }; + + test.stubs.qutebrowser = { }; + + nmt.script = let + qutebrowserConfig = if pkgs.stdenv.hostPlatform.isDarwin then + ".qutebrowser/config.py" + else + ".config/qutebrowser/config.py"; + in '' + assertFileContent \ + home-files/${qutebrowserConfig} \ + ${ + pkgs.writeText "qutebrowser-expected-config.py" '' + config.load_autoconfig(False) + c.bindings.default = {} + config.bind(",l", "config-cycle spellcheck.languages [\"en-GB\"] [\"en-US\"]", mode="normal") + config.bind("", "spawn mpv {url}", mode="normal") + config.bind("", "config-cycle tabs.show never always ;; config-cycle statusbar.show in-mode always ;; config-cycle scrolling.bar never always", mode="normal") + config.bind("", "prompt-yes", mode="prompt")'' + } + ''; } diff --git a/tests/modules/programs/qutebrowser/quickmarks.nix b/tests/modules/programs/qutebrowser/quickmarks.nix index 1491a1e6..9437fc61 100644 --- a/tests/modules/programs/qutebrowser/quickmarks.nix +++ b/tests/modules/programs/qutebrowser/quickmarks.nix @@ -1,33 +1,29 @@ -{ config, lib, pkgs, ... }: - -with lib; +{ pkgs, ... }: { - config = { - programs.qutebrowser = { - enable = true; + programs.qutebrowser = { + enable = true; - quickmarks = { - nixpkgs = "https://github.com/NixOS/nixpkgs"; - home-manager = "https://github.com/nix-community/home-manager"; - }; + quickmarks = { + nixpkgs = "https://github.com/NixOS/nixpkgs"; + home-manager = "https://github.com/nix-community/home-manager"; }; - - test.stubs.qutebrowser = { }; - - nmt.script = let - quickmarksFile = if pkgs.stdenv.hostPlatform.isDarwin then - ".qutebrowser/quickmarks" - else - ".config/qutebrowser/quickmarks"; - in '' - assertFileContent \ - home-files/${quickmarksFile} \ - ${ - pkgs.writeText "qutebrowser-expected-quickmarks" '' - home-manager https://github.com/nix-community/home-manager - nixpkgs https://github.com/NixOS/nixpkgs'' - } - ''; }; + + test.stubs.qutebrowser = { }; + + nmt.script = let + quickmarksFile = if pkgs.stdenv.hostPlatform.isDarwin then + ".qutebrowser/quickmarks" + else + ".config/qutebrowser/quickmarks"; + in '' + assertFileContent \ + home-files/${quickmarksFile} \ + ${ + pkgs.writeText "qutebrowser-expected-quickmarks" '' + home-manager https://github.com/nix-community/home-manager + nixpkgs https://github.com/NixOS/nixpkgs'' + } + ''; } diff --git a/tests/modules/programs/qutebrowser/settings.nix b/tests/modules/programs/qutebrowser/settings.nix index dca6ae6f..e2cf3915 100644 --- a/tests/modules/programs/qutebrowser/settings.nix +++ b/tests/modules/programs/qutebrowser/settings.nix @@ -1,50 +1,46 @@ -{ config, lib, pkgs, ... }: - -with lib; +{ pkgs, ... }: { - config = { - programs.qutebrowser = { - enable = true; + programs.qutebrowser = { + enable = true; - settings = { - colors = { - hints = { - bg = "#000000"; - fg = "#ffffff"; - }; - tabs.bar.bg = "#000000"; + settings = { + colors = { + hints = { + bg = "#000000"; + fg = "#ffffff"; }; - spellcheck.languages = [ "en-US" "sv-SE" ]; - tabs.tabs_are_windows = true; + tabs.bar.bg = "#000000"; }; - - extraConfig = '' - # Extra qutebrowser configuration. - ''; + spellcheck.languages = [ "en-US" "sv-SE" ]; + tabs.tabs_are_windows = true; }; - test.stubs.qutebrowser = { }; - - nmt.script = let - qutebrowserConfig = if pkgs.stdenv.hostPlatform.isDarwin then - ".qutebrowser/config.py" - else - ".config/qutebrowser/config.py"; - in '' - assertFileContent \ - home-files/${qutebrowserConfig} \ - ${ - pkgs.writeText "qutebrowser-expected-config.py" '' - config.load_autoconfig(False) - c.colors.hints.bg = "#000000" - c.colors.hints.fg = "#ffffff" - c.colors.tabs.bar.bg = "#000000" - c.spellcheck.languages = ["en-US", "sv-SE"] - c.tabs.tabs_are_windows = True - # Extra qutebrowser configuration. - '' - } + extraConfig = '' + # Extra qutebrowser configuration. ''; }; + + test.stubs.qutebrowser = { }; + + nmt.script = let + qutebrowserConfig = if pkgs.stdenv.hostPlatform.isDarwin then + ".qutebrowser/config.py" + else + ".config/qutebrowser/config.py"; + in '' + assertFileContent \ + home-files/${qutebrowserConfig} \ + ${ + pkgs.writeText "qutebrowser-expected-config.py" '' + config.load_autoconfig(False) + c.colors.hints.bg = "#000000" + c.colors.hints.fg = "#ffffff" + c.colors.tabs.bar.bg = "#000000" + c.spellcheck.languages = ["en-US", "sv-SE"] + c.tabs.tabs_are_windows = True + # Extra qutebrowser configuration. + '' + } + ''; } diff --git a/tests/modules/programs/terminator/config-file.nix b/tests/modules/programs/terminator/config-file.nix index 50b9c42e..9e4e5d6e 100644 --- a/tests/modules/programs/terminator/config-file.nix +++ b/tests/modules/programs/terminator/config-file.nix @@ -1,24 +1,24 @@ -{ config, lib, pkgs, ... }: { - config = { - programs.terminator = { - enable = true; - config = { - global_config.borderless = true; - profiles.default.background_color = "#002b36"; - }; +{ pkgs, ... }: + +{ + programs.terminator = { + enable = true; + config = { + global_config.borderless = true; + profiles.default.background_color = "#002b36"; }; - - test.stubs.terminator = { }; - - nmt.script = '' - assertFileContent home-files/.config/terminator/config ${ - pkgs.writeText "expected" '' - [global_config] - borderless = True - [profiles] - [[default]] - background_color = "#002b36"'' - } - ''; }; + + test.stubs.terminator = { }; + + nmt.script = '' + assertFileContent home-files/.config/terminator/config ${ + pkgs.writeText "expected" '' + [global_config] + borderless = True + [profiles] + [[default]] + background_color = "#002b36"'' + } + ''; } diff --git a/tests/modules/programs/topgrade/settings.nix b/tests/modules/programs/topgrade/settings.nix index a8f5c6d1..e80e98b8 100644 --- a/tests/modules/programs/topgrade/settings.nix +++ b/tests/modules/programs/topgrade/settings.nix @@ -1,36 +1,32 @@ -{ config, lib, pkgs, ... }: - -with lib; +{ lib, ... }: { - config = { - programs.topgrade = { - enable = true; + programs.topgrade = { + enable = true; - settings = mkMerge [ - { - disable = [ "sdkman" "flutter" "node" "nix" "home_manager" ]; + settings = lib.mkMerge [ + { + disable = [ "sdkman" "flutter" "node" "nix" "home_manager" ]; - remote_topgrades = [ "backup" "ci" ]; + remote_topgrades = [ "backup" "ci" ]; - remote_topgrade_path = "bin/topgrade"; - } + remote_topgrade_path = "bin/topgrade"; + } - { - set_title = false; - cleanup = true; + { + set_title = false; + cleanup = true; - commands = { "Purge unused APT packages" = "sudo apt autoremove"; }; - } - ]; - }; - - test.stubs.topgrade = { }; - - nmt.script = '' - assertFileContent \ - home-files/.config/topgrade.toml \ - ${./settings-expected.toml} - ''; + commands = { "Purge unused APT packages" = "sudo apt autoremove"; }; + } + ]; }; + + test.stubs.topgrade = { }; + + nmt.script = '' + assertFileContent \ + home-files/.config/topgrade.toml \ + ${./settings-expected.toml} + ''; } diff --git a/tests/modules/programs/vscode/keybindings.nix b/tests/modules/programs/vscode/keybindings.nix index ed457a9b..64212e29 100644 --- a/tests/modules/programs/vscode/keybindings.nix +++ b/tests/modules/programs/vscode/keybindings.nix @@ -1,7 +1,5 @@ # Test that keybindings.json is created correctly. -{ config, lib, pkgs, ... }: - -with lib; +{ pkgs, ... }: let bindings = [ @@ -65,18 +63,16 @@ let ''; in { - config = { - programs.vscode = { - enable = true; - keybindings = bindings; - package = pkgs.writeScriptBin "vscode" "" // { pname = "vscode"; }; - }; - - nmt.script = '' - assertFileExists "home-files/${keybindingsPath}" - assertFileContent "home-files/${keybindingsPath}" "${expectedKeybindings}" - - assertPathNotExists "home-files/${settingsPath}" - ''; + programs.vscode = { + enable = true; + keybindings = bindings; + package = pkgs.writeScriptBin "vscode" "" // { pname = "vscode"; }; }; + + nmt.script = '' + assertFileExists "home-files/${keybindingsPath}" + assertFileContent "home-files/${keybindingsPath}" "${expectedKeybindings}" + + assertPathNotExists "home-files/${settingsPath}" + ''; } diff --git a/tests/modules/programs/vscode/tasks.nix b/tests/modules/programs/vscode/tasks.nix index f0d28380..ea85b3d6 100644 --- a/tests/modules/programs/vscode/tasks.nix +++ b/tests/modules/programs/vscode/tasks.nix @@ -1,4 +1,4 @@ -{ pkgs, config, ... }: +{ pkgs, ... }: let diff --git a/tests/modules/programs/zplug/modules.nix b/tests/modules/programs/zplug/modules.nix index 90b70f0b..1256e33c 100644 --- a/tests/modules/programs/zplug/modules.nix +++ b/tests/modules/programs/zplug/modules.nix @@ -1,52 +1,48 @@ -{ config, lib, pkgs, ... }: - -with lib; +{ config, pkgs, ... }: { - config = { - programs.zsh = { + programs.zsh = { + enable = true; + zplug = { enable = true; - zplug = { - enable = true; - zplugHome = pkgs.emptyDirectory; - plugins = [ - { - name = "plugins/git"; - tags = [ "from:oh-my-zsh" ]; - } - { - name = "lib/clipboard"; - tags = [ "from:oh-my-zsh" ''if:"[[ $OSTYPE == *darwin* ]]"'' ]; - } - ]; - }; + zplugHome = pkgs.emptyDirectory; + plugins = [ + { + name = "plugins/git"; + tags = [ "from:oh-my-zsh" ]; + } + { + name = "lib/clipboard"; + tags = [ "from:oh-my-zsh" ''if:"[[ $OSTYPE == *darwin* ]]"'' ]; + } + ]; }; - - test.stubs = { - zplug = { }; - zsh = { }; - }; - - nmt.script = '' - assertFileContains home-files/.zshrc \ - 'source @zplug@/share/zplug/init.zsh' - - assertFileContains home-files/.zshrc \ - 'zplug "plugins/git", from:oh-my-zsh' - - assertFileContains home-files/.zshrc \ - 'zplug "lib/clipboard", from:oh-my-zsh, if:"[[ $OSTYPE == *darwin* ]]"' - - assertFileContains home-files/.zshrc \ - 'if ! zplug check; then - zplug install - fi' - - assertFileRegex home-files/.zshrc \ - '^zplug load$' - - assertFileContains home-files/.zshrc \ - 'export ZPLUG_HOME=${config.programs.zsh.zplug.zplugHome}' - ''; }; + + test.stubs = { + zplug = { }; + zsh = { }; + }; + + nmt.script = '' + assertFileContains home-files/.zshrc \ + 'source @zplug@/share/zplug/init.zsh' + + assertFileContains home-files/.zshrc \ + 'zplug "plugins/git", from:oh-my-zsh' + + assertFileContains home-files/.zshrc \ + 'zplug "lib/clipboard", from:oh-my-zsh, if:"[[ $OSTYPE == *darwin* ]]"' + + assertFileContains home-files/.zshrc \ + 'if ! zplug check; then + zplug install + fi' + + assertFileRegex home-files/.zshrc \ + '^zplug load$' + + assertFileContains home-files/.zshrc \ + 'export ZPLUG_HOME=${config.programs.zsh.zplug.zplugHome}' + ''; } diff --git a/tests/modules/services/imapnotify-darwin/default.nix b/tests/modules/services/imapnotify-darwin/default.nix new file mode 100644 index 00000000..a722604d --- /dev/null +++ b/tests/modules/services/imapnotify-darwin/default.nix @@ -0,0 +1 @@ +{ imapnotify-launchd = ./launchd.nix; } diff --git a/tests/modules/services/imapnotify-darwin/launchd.nix b/tests/modules/services/imapnotify-darwin/launchd.nix new file mode 100644 index 00000000..5502ebbf --- /dev/null +++ b/tests/modules/services/imapnotify-darwin/launchd.nix @@ -0,0 +1,41 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + imports = [ ../../accounts/email-test-accounts.nix ]; + + accounts.email.accounts = { + "hm@example.com" = { + notmuch.enable = true; + imap.port = 993; + + imapnotify = { + enable = true; + boxes = [ "Inbox" ]; + onNotify = '' + ${pkgs.notmuch}/bin/notmuch new + ''; + }; + }; + }; + + services.imapnotify = { + enable = true; + package = (config.lib.test.mkStubPackage { + name = "goimapnotify"; + outPath = "@goimapnotify@"; + }); + }; + + test.stubs.notmuch = { }; + + nmt.script = let + serviceFileName = "org.nix-community.home.imapnotify-hm-example.com.plist"; + in '' + serviceFile="LaunchAgents/${serviceFileName}" + serviceFileNormalized="$(normalizeStorePaths "$serviceFile")" + assertFileExists $serviceFile + assertFileContent $serviceFileNormalized ${./launchd.plist} + ''; +} diff --git a/tests/modules/services/imapnotify-darwin/launchd.plist b/tests/modules/services/imapnotify-darwin/launchd.plist new file mode 100644 index 00000000..75009bb6 --- /dev/null +++ b/tests/modules/services/imapnotify-darwin/launchd.plist @@ -0,0 +1,29 @@ + + + + + EnvironmentVariables + + NOTMUCH_CONFIG + /home/hm-user/.config/notmuch/default/config + + ExitTimeOut + 0 + KeepAlive + + Label + org.nix-community.home.imapnotify-hm-example.com + ProcessType + Background + ProgramArguments + + @goimapnotify@/bin/goimapnotify + -conf + /nix/store/00000000000000000000000000000000-imapnotify-hm-example.com-config.json + + RunAtLoad + + ThrottleInterval + 30 + + \ No newline at end of file diff --git a/tests/modules/services/imapnotify/default.nix b/tests/modules/services/imapnotify/default.nix new file mode 100644 index 00000000..f3a725dd --- /dev/null +++ b/tests/modules/services/imapnotify/default.nix @@ -0,0 +1 @@ +{ imapnotify = ./imapnotify.nix; } diff --git a/tests/modules/services/imapnotify/imapnotify.nix b/tests/modules/services/imapnotify/imapnotify.nix new file mode 100644 index 00000000..c607c042 --- /dev/null +++ b/tests/modules/services/imapnotify/imapnotify.nix @@ -0,0 +1,39 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + imports = [ ../../accounts/email-test-accounts.nix ]; + + accounts.email.accounts = { + "hm@example.com" = { + notmuch.enable = true; + imap.port = 993; + + imapnotify = { + enable = true; + boxes = [ "Inbox" ]; + onNotify = '' + ${pkgs.notmuch}/bin/notmuch new + ''; + }; + }; + }; + + services.imapnotify = { + enable = true; + package = (config.lib.test.mkStubPackage { + name = "goimapnotify"; + outPath = "@goimapnotify@"; + }); + }; + + test.stubs.notmuch = { }; + + nmt.script = '' + serviceFile="home-files/.config/systemd/user/imapnotify-hm-example.com.service" + serviceFileNormalized="$(normalizeStorePaths "$serviceFile")" + assertFileExists $serviceFile + assertFileContent $serviceFileNormalized ${./imapnotify.service} + ''; +} diff --git a/tests/modules/services/imapnotify/imapnotify.service b/tests/modules/services/imapnotify/imapnotify.service new file mode 100644 index 00000000..3e3bd9ff --- /dev/null +++ b/tests/modules/services/imapnotify/imapnotify.service @@ -0,0 +1,12 @@ +[Install] +WantedBy=default.target + +[Service] +Environment=NOTMUCH_CONFIG=/home/hm-user/.config/notmuch/default/config +ExecStart=@goimapnotify@/bin/goimapnotify -conf '/nix/store/00000000000000000000000000000000-imapnotify-hm-example.com-config.json' +Restart=always +RestartSec=30 +Type=simple + +[Unit] +Description=imapnotify for hm-example.com diff --git a/tests/modules/services/swayosd/default.nix b/tests/modules/services/swayosd/default.nix new file mode 100644 index 00000000..c327610a --- /dev/null +++ b/tests/modules/services/swayosd/default.nix @@ -0,0 +1 @@ +{ swayosd = ./swayosd.nix; } diff --git a/tests/modules/services/swayosd/swayosd.nix b/tests/modules/services/swayosd/swayosd.nix new file mode 100644 index 00000000..b371d86a --- /dev/null +++ b/tests/modules/services/swayosd/swayosd.nix @@ -0,0 +1,35 @@ +{ config, ... }: + +{ + services.swayosd = { + enable = true; + package = config.lib.test.mkStubPackage { + name = "swayosd"; + outPath = "@swayosd@"; + }; + maxVolume = 10; + }; + + nmt.script = '' + assertFileContent \ + home-files/.config/systemd/user/swayosd.service \ + ${ + builtins.toFile "swayosd.service" '' + [Install] + WantedBy=graphical-session.target + + [Service] + ExecStart=@swayosd@/bin/swayosd --max-volume 10 + Restart=always + Type=simple + + [Unit] + After=graphical-session.target + ConditionEnvironment=WAYLAND_DISPLAY + Description=Volume/backlight OSD indicator + Documentation=man:swayosd(1) + PartOf=graphical-session.target + '' + } + ''; +} diff --git a/tests/modules/systemd/session-variables.nix b/tests/modules/systemd/session-variables.nix index d234767f..e427bbee 100644 --- a/tests/modules/systemd/session-variables.nix +++ b/tests/modules/systemd/session-variables.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ config, pkgs, ... }: { systemd.user.sessionVariables = { @@ -11,7 +11,7 @@ assertFileExists $envFile assertFileContent $envFile ${ pkgs.writeText "expected" '' - LOCALE_ARCHIVE_2_27=${pkgs.glibcLocales}/lib/locale/locale-archive + LOCALE_ARCHIVE_2_27=${config.i18n.glibcLocales}/lib/locale/locale-archive V_int=1 V_str=2 XDG_CACHE_HOME=/home/hm-user/.cache