From cfcd52ff70e24bb44997f9890c8829de7c19e116 Mon Sep 17 00:00:00 2001 From: Default email Date: Fri, 5 Nov 2021 00:42:44 +0800 Subject: [PATCH] Project import generated by Copybara. GitOrigin-RevId: 70c5b268e10025c70823767f4fb49e240b40151d --- third_party/home-manager/.github/CODEOWNERS | 50 +- .../home-manager/.github/ISSUE_TEMPLATE.md | 31 - .../.github/ISSUE_TEMPLATE/feature-request.md | 15 + .../.github/ISSUE_TEMPLATE/issue.yaml | 46 ++ .../.github/PULL_REQUEST_TEMPLATE.md | 4 +- .../home-manager/.github/dependabot.yml | 2 +- .../.github/workflows/github_pages.yml | 2 +- .../home-manager/.github/workflows/test.yml | 5 +- third_party/home-manager/CONTRIBUTING.adoc | 258 -------- third_party/home-manager/FAQ.adoc | 173 ------ third_party/home-manager/Makefile | 20 + third_party/home-manager/README.md | 40 +- third_party/home-manager/default.nix | 2 +- .../doc/release-notes/rl-2111.adoc | 21 - .../{doc => docs}/contributing.adoc | 0 .../home-manager/{doc => docs}/default.nix | 4 +- .../home-manager/{doc => docs}/faq.adoc | 12 +- .../{doc => docs}/installation.adoc | 11 +- .../{doc => docs}/man-configuration.xml | 0 .../{doc => docs}/man-home-manager.xml | 33 + .../home-manager/{doc => docs}/man-pages.xml | 0 .../home-manager/{doc => docs}/manual.xml | 2 +- .../release-notes/release-notes.adoc | 0 .../{doc => docs}/release-notes/rl-1809.adoc | 0 .../{doc => docs}/release-notes/rl-1903.adoc | 0 .../{doc => docs}/release-notes/rl-1909.adoc | 0 .../{doc => docs}/release-notes/rl-2003.adoc | 0 .../{doc => docs}/release-notes/rl-2009.adoc | 0 .../{doc => docs}/release-notes/rl-2105.adoc | 0 .../docs/release-notes/rl-2111.adoc | 47 ++ .../{doc => docs}/writing-modules.adoc | 0 third_party/home-manager/flake.nix | 11 +- third_party/home-manager/format | 20 +- .../home-manager/home-manager/completion.bash | 6 +- .../home-manager/home-manager/completion.fish | 65 ++ .../home-manager/home-manager/completion.zsh | 7 +- .../home-manager/home-manager/default.nix | 6 +- .../home-manager/home-manager/home-manager | 18 +- .../home-manager/home-manager.nix | 5 +- .../home-manager/home-manager/install.nix | 3 + .../home-manager/modules/accounts/email.nix | 4 +- .../home-manager/modules/config/i18n.nix | 2 +- third_party/home-manager/modules/files.nix | 31 +- .../home-manager/modules/home-environment.nix | 64 +- .../modules/i18n/input-method/default.nix | 4 + .../modules/i18n/input-method/fcitx.nix | 2 +- .../modules/i18n/input-method/fcitx5.nix | 2 +- .../modules/i18n/input-method/kime.nix | 2 +- .../modules/lib-bash/activation-init.sh | 13 +- .../home-manager/modules/lib/assertions.nix | 14 + third_party/home-manager/modules/lib/dag.nix | 5 +- .../home-manager/modules/lib/default.nix | 2 + .../home-manager/modules/lib/file-type.nix | 7 +- .../home-manager/modules/lib/gvariant.nix | 11 +- .../home-manager/modules/lib/maintainers.nix | 30 +- .../modules/lib/stdlib-extended.nix | 8 +- .../home-manager/modules/lib/strings.nix | 7 +- .../home-manager/modules/lib/types-dag.nix | 6 +- .../home-manager/modules/lib/types.nix | 20 +- third_party/home-manager/modules/manual.nix | 2 +- .../home-manager/modules/misc/dconf.nix | 2 +- .../home-manager/modules/misc/fontconfig.nix | 26 +- third_party/home-manager/modules/misc/gtk.nix | 10 +- .../home-manager/modules/misc/news.nix | 149 ++++- .../modules/misc/nixpkgs-disabled.nix | 73 +++ .../home-manager/modules/misc/nixpkgs.nix | 63 +- .../home-manager/modules/misc/numlock.nix | 4 + third_party/home-manager/modules/misc/qt.nix | 2 +- .../home-manager/modules/misc/tmpfiles.nix | 5 + .../modules/misc/xdg-desktop-entries.nix | 13 +- .../modules/misc/xdg-mime-apps.nix | 7 +- .../home-manager/modules/misc/xdg-mime.nix | 7 +- .../modules/misc/xdg-system-dirs.nix | 10 +- .../modules/misc/xdg-user-dirs.nix | 3 + third_party/home-manager/modules/misc/xdg.nix | 48 +- third_party/home-manager/modules/modules.nix | 476 +++++++-------- .../home-manager/modules/programs/abook.nix | 4 + .../modules/programs/alacritty.nix | 4 +- .../modules/programs/alot-accounts.nix | 2 +- .../home-manager/modules/programs/alot.nix | 2 +- .../home-manager/modules/programs/aria2.nix | 2 +- .../home-manager/modules/programs/astroid.nix | 6 +- .../home-manager/modules/programs/atuin.nix | 90 +++ .../modules/programs/autojump.nix | 2 +- .../modules/programs/autorandr.nix | 8 +- .../home-manager/modules/programs/bash.nix | 17 +- .../home-manager/modules/programs/bat.nix | 16 +- .../home-manager/modules/programs/beets.nix | 4 +- .../home-manager/modules/programs/bottom.nix | 66 ++ .../home-manager/modules/programs/broot.nix | 9 +- .../modules/programs/chromium.nix | 10 +- .../modules/programs/dircolors.nix | 2 +- .../home-manager/modules/programs/direnv.nix | 9 +- .../home-manager/modules/programs/eclipse.nix | 4 +- .../home-manager/modules/programs/emacs.nix | 37 +- .../home-manager/modules/programs/firefox.nix | 305 ++++++---- .../home-manager/modules/programs/fish.nix | 73 +-- .../home-manager/modules/programs/foot.nix | 7 +- .../home-manager/modules/programs/fzf.nix | 18 +- .../home-manager/modules/programs/getmail.nix | 4 + .../home-manager/modules/programs/gh.nix | 117 +++- .../home-manager/modules/programs/git.nix | 25 +- .../home-manager/modules/programs/go.nix | 4 +- .../home-manager/modules/programs/gpg.nix | 12 +- .../home-manager/modules/programs/hexchat.nix | 363 +++++++++++ .../modules/programs/himalaya.nix | 6 +- .../home-manager/modules/programs/htop.nix | 562 ++---------------- .../modules/programs/i3status-rust.nix | 28 +- .../modules/programs/i3status.nix | 6 +- .../home-manager/modules/programs/irssi.nix | 99 ++- .../home-manager/modules/programs/java.nix | 46 ++ .../home-manager/modules/programs/jq.nix | 4 +- .../home-manager/modules/programs/kakoune.nix | 2 +- .../modules/programs/keychain.nix | 2 +- .../home-manager/modules/programs/kitty.nix | 76 ++- .../home-manager/modules/programs/lazygit.nix | 4 +- .../home-manager/modules/programs/lf.nix | 4 +- .../modules/programs/lieer-accounts.nix | 69 --- .../home-manager/modules/programs/lieer.nix | 231 ++++++- .../modules/programs/mangohud.nix | 37 +- .../modules/programs/matplotlib.nix | 2 +- .../modules/programs/mbsync-accounts.nix | 6 +- .../home-manager/modules/programs/mbsync.nix | 6 +- .../home-manager/modules/programs/mcfly.nix | 9 +- .../modules/programs/mercurial.nix | 2 +- .../home-manager/modules/programs/mpv.nix | 10 +- .../home-manager/modules/programs/msmtp.nix | 5 +- .../home-manager/modules/programs/ncmpcpp.nix | 8 +- .../home-manager/modules/programs/ncspot.nix | 4 +- .../home-manager/modules/programs/ne.nix | 2 +- .../modules/programs/neomutt-accounts.nix | 35 +- .../home-manager/modules/programs/neomutt.nix | 34 +- .../home-manager/modules/programs/neovim.nix | 70 ++- .../modules/programs/nix-index.nix | 2 +- .../home-manager/modules/programs/nnn.nix | 129 ++++ .../home-manager/modules/programs/noti.nix | 2 +- .../home-manager/modules/programs/nushell.nix | 4 +- .../modules/programs/obs-studio.nix | 4 +- .../home-manager/modules/programs/octant.nix | 6 +- .../modules/programs/offlineimap.nix | 4 +- .../home-manager/modules/programs/opam.nix | 2 +- .../modules/programs/password-store.nix | 8 +- .../home-manager/modules/programs/pet.nix | 4 +- .../home-manager/modules/programs/pidgin.nix | 4 +- .../modules/programs/piston-cli.nix | 4 +- .../modules/programs/powerline-go.nix | 13 +- .../modules/programs/qutebrowser.nix | 29 +- .../home-manager/modules/programs/rbw.nix | 4 +- .../modules/programs/readline.nix | 2 +- .../home-manager/modules/programs/rofi.nix | 234 +------- .../home-manager/modules/programs/sbt.nix | 8 +- .../home-manager/modules/programs/scmpuff.nix | 2 +- .../home-manager/modules/programs/senpai.nix | 4 +- .../home-manager/modules/programs/sm64ex.nix | 128 ++++ .../home-manager/modules/programs/ssh.nix | 8 +- .../modules/programs/starship.nix | 14 +- .../modules/programs/taskwarrior.nix | 4 +- .../modules/programs/terminator.nix | 9 +- .../home-manager/modules/programs/texlive.nix | 4 +- .../home-manager/modules/programs/tmux.nix | 117 ++-- .../modules/programs/topgrade.nix | 6 +- .../home-manager/modules/programs/urxvt.nix | 4 +- .../home-manager/modules/programs/vim.nix | 13 +- .../home-manager/modules/programs/vscode.nix | 10 +- .../modules/programs/vscode/haskell.nix | 4 +- .../home-manager/modules/programs/waybar.nix | 44 +- .../home-manager/modules/programs/xmobar.nix | 4 +- .../home-manager/modules/programs/z-lua.nix | 2 + .../home-manager/modules/programs/zoxide.nix | 2 +- .../home-manager/modules/programs/zplug.nix | 10 + .../home-manager/modules/programs/zsh.nix | 14 +- .../home-manager/modules/services/barrier.nix | 16 +- .../modules/services/betterlockscreen.nix | 55 ++ .../modules/services/caffeine.nix | 5 + .../modules/services/cbatticon.nix | 5 + .../modules/services/clipmenu.nix | 5 + .../modules/services/devilspie2.nix | 47 ++ .../home-manager/modules/services/dropbox.nix | 7 +- .../home-manager/modules/services/dunst.nix | 33 +- .../modules/services/dwm-status.nix | 9 +- .../modules/services/easyeffects.nix | 62 ++ .../home-manager/modules/services/emacs.nix | 18 +- .../modules/services/etesync-dav.nix | 7 +- .../modules/services/flameshot.nix | 44 +- .../modules/services/fluidsynth.nix | 18 +- .../home-manager/modules/services/fnott.nix | 112 ++++ .../home-manager/modules/services/getmail.nix | 5 + .../modules/services/git-sync.nix | 100 ++++ .../modules/services/gnome-keyring.nix | 5 + .../modules/services/gpg-agent.nix | 28 +- .../home-manager/modules/services/grobi.nix | 7 +- .../home-manager/modules/services/hound.nix | 7 +- .../modules/services/imapnotify-accounts.nix | 7 + .../modules/services/imapnotify.nix | 12 +- .../home-manager/modules/services/kanshi.nix | 27 +- .../home-manager/modules/services/kbfs.nix | 5 + .../home-manager/modules/services/keybase.nix | 5 + .../home-manager/modules/services/keynav.nix | 5 + .../modules/services/lieer-accounts.nix | 25 - .../home-manager/modules/services/lieer.nix | 15 +- .../home-manager/modules/services/lorri.nix | 7 +- .../home-manager/modules/services/mako.nix | 67 ++- .../home-manager/modules/services/mbsync.nix | 9 +- .../home-manager/modules/services/mpd.nix | 4 + .../home-manager/modules/services/mpdris2.nix | 15 +- .../modules/services/mpris-proxy.nix | 5 + .../modules/services/muchsync.nix | 18 +- .../services/network-manager-applet.nix | 5 + .../modules/services/nextcloud-client.nix | 7 +- .../modules/services/notify-osd.nix | 48 ++ .../modules/services/pantalaimon.nix | 11 +- .../modules/services/parcellite.nix | 9 +- .../modules/services/pass-secret-service.nix | 15 +- .../modules/services/password-store-sync.nix | 15 +- .../home-manager/modules/services/pbgopy.nix | 5 + .../home-manager/modules/services/picom.nix | 9 +- .../modules/services/plan9port.nix | 5 +- .../modules/services/playerctld.nix | 7 +- .../home-manager/modules/services/polybar.nix | 13 +- .../modules/services/poweralertd.nix | 5 + .../modules/services/pulseeffects.nix | 21 +- .../redshift-gammastep/lib/options.nix | 37 +- .../modules/services/rsibreak.nix | 5 + .../modules/services/screen-locker.nix | 156 +++-- .../modules/services/spotifyd.nix | 11 +- .../modules/services/stalonetray.nix | 4 +- .../services/status-notifier-watcher.nix | 9 +- .../home-manager/modules/services/sxhkd.nix | 64 +- .../modules/services/syncthing.nix | 17 +- .../modules/services/taffybar.nix | 4 +- .../modules/services/taskwarrior-sync.nix | 5 + .../home-manager/modules/services/trayer.nix | 183 ++++++ .../modules/services/unclutter.nix | 7 +- .../home-manager/modules/services/unison.nix | 9 +- .../home-manager/modules/services/volnoti.nix | 43 ++ .../services/window-managers/awesome.nix | 10 +- .../window-managers/bspwm/default.nix | 5 + .../window-managers/bspwm/options.nix | 6 +- .../services/window-managers/i3-sway/i3.nix | 18 +- .../window-managers/i3-sway/lib/functions.nix | 17 +- .../window-managers/i3-sway/lib/options.nix | 37 +- .../services/window-managers/i3-sway/sway.nix | 18 +- .../services/window-managers/xmonad.nix | 35 +- .../modules/services/wlsunset.nix | 5 + .../home-manager/modules/services/xcape.nix | 20 +- .../modules/services/xembed-sni-proxy.nix | 7 +- .../modules/services/xidlehook.nix | 13 +- .../modules/services/xscreensaver.nix | 5 + .../modules/services/xsettingsd.nix | 93 +++ .../modules/services/xsuspender.nix | 5 + third_party/home-manager/modules/systemd.nix | 249 ++++---- .../modules/targets/darwin/default.nix | 5 + .../modules/targets/darwin/fonts.nix | 24 +- .../modules/targets/darwin/keybindings.nix | 5 + .../modules/targets/darwin/search.nix | 5 + .../modules/targets/generic-linux.nix | 22 + third_party/home-manager/modules/xcursor.nix | 6 +- .../home-manager/modules/xresources.nix | 8 +- third_party/home-manager/modules/xsession.nix | 14 +- .../home-manager/nix-darwin/default.nix | 10 +- third_party/home-manager/nixos/default.nix | 52 +- third_party/home-manager/tests/asserts.nix | 60 +- third_party/home-manager/tests/default.nix | 34 +- .../tests/lib/types/dag-merge.nix | 3 +- .../tests/lib/types/dag-submodule.nix | 3 +- .../tests/lib/types/gvariant-merge.nix | 50 +- .../tests/lib/types/list-or-dag-merge.nix | 3 +- .../home-environment/session-variables.nix | 2 + .../input-method/fcitx5-configuration.nix | 17 +- .../i18n/input-method/fcitx5-overlay.nix | 22 - .../i18n/input-method/fcitx5-stubs.nix | 27 + .../misc/gtk/gtk-basic-config-expected.conf | 1 - .../modules/misc/gtk/gtk2-basic-config.nix | 2 + .../misc/gtk/gtk2-config-file-location.nix | 2 + .../tests/modules/misc/numlock/numlock.nix | 4 +- .../misc/qt/qt-platform-theme-gnome.nix | 8 +- .../tests/modules/misc/xdg/default.nix | 2 +- .../modules/misc/xdg/file-attr-names.nix | 26 - .../tests/modules/misc/xdg/file-gen.nix | 36 ++ .../xsession/basic-setxkbmap-expected.service | 2 +- .../keyboard-without-layout-expected.service | 2 +- .../modules/programs/abook/no-settings.nix | 3 +- .../modules/programs/abook/with-settings.nix | 3 +- .../programs/alacritty/empty-settings.nix | 4 +- .../programs/alacritty/example-settings.nix | 2 +- .../programs/alacritty/settings-merging.nix | 2 +- .../tests/modules/programs/alot/alot.nix | 3 +- .../tests/modules/programs/aria2/settings.nix | 3 +- .../tests/modules/programs/atuin/bash.nix | 20 + .../tests/modules/programs/atuin/default.nix | 7 + .../modules/programs/atuin/empty-settings.nix | 14 + .../atuin/example-settings-expected.toml | 4 + .../programs/atuin/example-settings.nix | 32 + .../tests/modules/programs/atuin/no-shell.nix | 23 + .../tests/modules/programs/atuin/zsh.nix | 20 + .../programs/autojump/default-settings.nix | 4 + .../autorandr/basic-configuration.nix | 2 + .../modules/programs/autorandr/scale.nix | 2 + .../tests/modules/programs/bat/bat.nix | 42 ++ .../tests/modules/programs/bat/default.nix | 1 + .../tests/modules/programs/bottom/default.nix | 4 + .../programs/bottom/empty-settings.nix | 16 + .../programs/bottom/example-settings.nix | 41 ++ .../tests/modules/programs/broot/broot.nix | 42 ++ .../tests/modules/programs/broot/default.nix | 1 + .../tests/modules/programs/emacs/default.nix | 1 + .../modules/programs/emacs/extra-config.nix | 26 + .../modules/programs/feh/feh-bindings.nix | 3 +- .../programs/feh/feh-empty-settings.nix | 3 +- .../firefox/deprecated-native-messenger.nix | 1 + ...rofile-settings-expected-bookmarks-user.js | 8 + .../profile-settings-expected-bookmarks.html | 12 + .../programs/firefox/profile-settings.nix | 29 + .../programs/firefox/state-version-19_09.nix | 1 + .../tests/modules/programs/fish/functions.nix | 6 + .../modules/programs/fish/no-functions.nix | 8 +- .../tests/modules/programs/fish/plugins.nix | 6 + .../modules/programs/foot/empty-settings.nix | 3 +- .../programs/foot/example-settings.nix | 2 +- .../programs/foot/systemd-user-service.nix | 6 +- .../tests/modules/programs/gh/config-file.nix | 13 +- .../programs/gh/credential-helper.git.conf | 2 + .../modules/programs/gh/credential-helper.nix | 21 + .../tests/modules/programs/gh/default.nix | 6 +- .../tests/modules/programs/gh/warnings.nix | 35 ++ .../modules/programs/git/git-with-msmtp.nix | 9 +- .../tests/modules/programs/git/git.nix | 12 +- .../gnome-terminal/gnome-terminal-1.nix | 15 +- .../basic-configuration-expected-main-config | 10 + ...c-configuration-expected-serverlist-config | 24 + .../programs/hexchat/basic-configuration.nix | 61 ++ .../modules/programs/hexchat/default.nix | 1 + .../modules/programs/himalaya/himalaya.nix | 47 +- .../tests/modules/programs/htop/default.nix | 4 +- ...efault-settings.nix => empty-settings.nix} | 4 +- .../modules/programs/htop/example-htoprc.txt | 11 + .../programs/htop/example-settings.nix | 6 +- .../modules/programs/htop/header_layout.nix | 37 ++ .../programs/htop/settings-without-fields.nix | 27 + .../programs/i3status-rust/with-custom.nix | 6 +- .../programs/i3status-rust/with-default.nix | 6 +- .../i3status-rust/with-extra-settings.nix | 6 +- .../i3status-rust/with-multiple-bars.nix | 6 +- .../modules/programs/i3status/with-custom.nix | 4 +- .../programs/i3status/with-default.nix | 4 +- .../tests/modules/programs/irsii/default.nix | 1 - .../tests/modules/programs/irssi/default.nix | 1 + .../example-settings-expected.config | 0 .../{irsii => irssi}/example-settings.nix | 5 +- .../example-macos-launch-services-cmdline | 1 + .../kitty/example-settings-expected.conf | 3 + .../programs/kitty/example-settings.nix | 16 +- .../tests/modules/programs/lf/all-options.nix | 3 +- .../modules/programs/lf/minimal-options.nix | 3 +- .../modules/programs/lf/no-pv-keybind.nix | 3 +- .../programs/lieer/lieer-expected.json | 19 +- .../tests/modules/programs/lieer/lieer.nix | 10 +- .../programs/mangohud/basic-configuration.nix | 2 +- .../mbsync/mbsync-master-slave-change.nix | 2 + .../tests/modules/programs/mbsync/mbsync.nix | 2 + .../programs/mpv/mpv-example-settings.nix | 4 +- .../programs/mpv/mpv-invalid-settings.nix | 2 +- .../ncmpcpp-linux/ncmpcpp-use-mpd-config.nix | 10 +- .../ncmpcpp/ncmpcpp-empty-settings.nix | 3 +- .../ncmpcpp/ncmpcpp-example-settings.nix | 3 +- .../tests/modules/programs/ne/defprefs.nix | 3 +- .../modules/programs/ne/passthroughs.nix | 3 +- .../modules/programs/neomutt/default.nix | 1 + .../programs/neomutt/neomutt-expected.conf | 1 + .../neomutt/neomutt-no-folder-change.nix | 3 +- .../neomutt/neomutt-not-primary-expected.conf | 1 + .../programs/neomutt/neomutt-not-primary.nix | 3 +- .../neomutt/neomutt-with-binds-expected.conf | 1 + .../neomutt-with-binds-with-warning.nix | 3 +- .../programs/neomutt/neomutt-with-binds.nix | 3 +- .../programs/neomutt/neomutt-with-gpg.nix | 3 +- .../programs/neomutt/neomutt-with-msmtp.nix | 3 +- ...neomutt-with-named-mailboxes-expected.conf | 35 ++ .../neomutt/neomutt-with-named-mailboxes.nix | 49 ++ .../modules/programs/neomutt/neomutt.nix | 3 +- .../programs/neovim/coc-config.expected | 3 + .../modules/programs/neovim/coc-config.nix | 27 + .../tests/modules/programs/neovim/default.nix | 1 + .../newsboat/newsboat-basics-2003.nix | 4 +- .../newsboat/newsboat-basics-2105.nix | 4 +- .../programs/newsboat/newsboat-basics.nix | 4 +- .../nix-index/assert-on-command-not-found.nix | 14 +- .../programs/nix-index/integrations.nix | 13 +- .../tests/modules/programs/nnn/default.nix | 1 + .../tests/modules/programs/nnn/nnn.nix | 57 ++ .../tests/modules/programs/nnn/plugins/.keep | 0 .../modules/programs/nushell/settings.nix | 3 +- .../modules/programs/powerline-go/bash.nix | 3 +- .../modules/programs/powerline-go/default.nix | 1 + .../modules/programs/powerline-go/fish.nix | 37 ++ .../modules/programs/powerline-go/zsh.nix | 10 +- .../programs/qutebrowser/keybindings.nix | 6 +- .../programs/qutebrowser/quickmarks.nix | 6 +- .../modules/programs/qutebrowser/settings.nix | 6 +- .../modules/programs/rbw/empty-settings.nix | 13 +- .../tests/modules/programs/rbw/overlay.nix | 12 - .../tests/modules/programs/rbw/rbw-stubs.nix | 16 + .../tests/modules/programs/rbw/settings.nix | 33 +- .../modules/programs/rbw/simple-settings.nix | 21 +- .../programs/rofi-pass/rofi-pass-config.nix | 7 +- .../programs/rofi-pass/rofi-pass-root.nix | 7 +- .../rofi/assert-on-both-theme-and-colors.nix | 27 - .../rofi/config-with-deprecated-options.nix | 17 + .../modules/programs/rofi/custom-theme.nix | 3 +- .../tests/modules/programs/rofi/default.nix | 2 +- .../programs/rofi/valid-config-expected.rasi | 9 - .../modules/programs/rofi/valid-config.nix | 30 +- .../modules/programs/sbt/credentials.nix | 4 +- .../modules/programs/scmpuff/no-shell.nix | 2 + .../tests/modules/programs/scmpuff/no-zsh.nix | 2 + .../tests/modules/programs/scmpuff/zsh.nix | 2 + .../tests/modules/programs/sm64ex/default.nix | 1 + .../modules/programs/sm64ex/settings.nix | 80 +++ .../modules/programs/starship/settings.nix | 4 +- .../programs/terminator/config-file.nix | 3 +- .../modules/programs/topgrade/settings.nix | 4 +- .../programs/waybar/settings-complex.nix | 10 +- .../tests/modules/programs/waybar/styling.nix | 6 +- .../systemd-with-graphical-session-target.nix | 6 +- .../programs/waybar/warnings-tests.nix | 6 +- .../programs/xmobar/basic-configuration.nix | 1 + .../tests/modules/programs/zplug/modules.nix | 18 +- .../programs/zsh/history-ignore-pattern.nix | 3 +- .../programs/zsh/history-path-new-custom.nix | 3 +- .../programs/zsh/history-path-new-default.nix | 3 +- .../programs/zsh/history-path-old-custom.nix | 3 +- .../programs/zsh/history-path-old-default.nix | 3 +- .../tests/modules/programs/zsh/prezto.nix | 29 +- .../programs/zsh/session-variables.nix | 6 +- .../services/barrier/basic-configuration.nix | 3 +- .../modules/services/devilspie2/config.lua | 11 + .../services/devilspie2/configuration.nix | 37 ++ .../modules/services/devilspie2/default.nix | 1 + .../services/dropbox/basic-configuration.nix | 8 +- .../services/emacs/emacs-service-27.nix | 1 + .../services/emacs/emacs-service-28.nix | 1 + .../emacs/emacs-service-emacs.service | 2 +- .../services/emacs/emacs-socket-27.nix | 1 + .../services/emacs/emacs-socket-28.nix | 1 + .../services/emacs/emacs-socket-emacs.service | 2 +- .../modules/services/flameshot/default.nix | 4 + .../services/flameshot/empty-settings.nix | 13 + .../services/flameshot/example-settings.nix | 30 + .../modules/services/fluidsynth/service.nix | 15 +- .../tests/modules/services/fnott/default.nix | 4 + .../fnott/example-settings-expected.ini | 7 + .../services/fnott/example-settings.nix | 26 + .../systemd-user-service-expected.service | 10 + .../services/fnott/systemd-user-service.nix | 16 + .../tests/modules/services/git-sync/basic.nix | 37 ++ .../modules/services/git-sync/default.nix | 1 + .../services/gpg-agent/default-homedir.nix | 3 +- .../services/gpg-agent/override-homedir.nix | 3 +- .../services/kanshi/basic-configuration.conf | 6 + .../services/kanshi/basic-configuration.nix | 11 +- .../lieer/lieer-service-expected.service | 2 +- .../modules/services/lieer/lieer-service.nix | 8 +- .../pantalaimon/basic-configuration.nix | 4 +- .../tests/modules/services/pbgopy/service.nix | 8 +- .../services/polybar/basic-configuration.nix | 2 +- .../gammastep-basic-configuration.nix | 8 +- .../redshift-basic-configuration.nix | 8 +- .../screen-locker/basic-configuration.nix | 30 + .../services/screen-locker/default.nix | 5 + .../services/screen-locker/moved-options.nix | 36 ++ .../services/screen-locker/no-xautolock.nix | 24 + .../modules/services/sxhkd/configuration.nix | 48 +- .../tests/modules/services/sxhkd/service.nix | 44 +- .../tray-as-bool-triggers-warning.nix | 6 +- .../services/trayer/basic-configuration.nix | 27 + .../tests/modules/services/trayer/default.nix | 1 + .../window-managers/bspwm/configuration.nix | 2 + .../i3/i3-bar-focused-colors.nix | 32 +- .../i3/i3-fonts-deprecated.nix | 40 +- .../services/window-managers/i3/i3-fonts.nix | 42 +- .../window-managers/i3/i3-keybindings.nix | 36 +- .../window-managers/i3/i3-null-config.nix | 24 +- .../window-managers/i3/i3-overlay.nix | 12 - .../services/window-managers/i3/i3-stubs.nix | 19 + .../i3/i3-workspace-default.nix | 24 +- .../i3/i3-workspace-output.nix | 80 ++- .../services/window-managers/sway/default.nix | 5 +- .../sway/sway-bar-focused-colors.conf | 2 +- .../sway/sway-bar-focused-colors.nix | 44 +- .../sway/sway-bindkeys-to-code.conf | 114 ++++ .../sway/sway-bindkeys-to-code.nix | 19 + .../window-managers/sway/sway-default.conf | 2 +- .../window-managers/sway/sway-default.nix | 34 +- .../sway/sway-followmouse-legacy.nix | 36 +- .../window-managers/sway/sway-followmouse.nix | 38 +- .../window-managers/sway/sway-modules.conf | 2 +- .../window-managers/sway/sway-modules.nix | 42 +- .../window-managers/sway/sway-null-config.nix | 28 +- .../sway/sway-null-package.nix | 50 +- .../window-managers/sway/sway-overlay.nix | 17 - .../window-managers/sway/sway-post-2003.nix | 36 +- .../window-managers/sway/sway-stubs.nix | 13 + .../sway/sway-workspace-default-expected.conf | 2 +- .../sway/sway-workspace-default.nix | 36 +- .../sway/sway-workspace-output-expected.conf | 2 +- .../sway/sway-workspace-output.nix | 80 ++- .../services/wlsunset/wlsunset-service.nix | 4 +- .../xsettingsd/basic-configuration.conf | 4 + .../xsettingsd/basic-configuration.nix | 26 + .../modules/services/xsettingsd/default.nix | 1 + .../tests/modules/systemd/services.nix | 22 +- .../modules/systemd/session-variables.nix | 12 +- third_party/home-manager/tests/stubs.nix | 61 ++ 513 files changed, 7280 insertions(+), 3929 deletions(-) delete mode 100644 third_party/home-manager/.github/ISSUE_TEMPLATE.md create mode 100644 third_party/home-manager/.github/ISSUE_TEMPLATE/feature-request.md create mode 100644 third_party/home-manager/.github/ISSUE_TEMPLATE/issue.yaml delete mode 100644 third_party/home-manager/CONTRIBUTING.adoc delete mode 100644 third_party/home-manager/FAQ.adoc create mode 100644 third_party/home-manager/Makefile delete mode 100644 third_party/home-manager/doc/release-notes/rl-2111.adoc rename third_party/home-manager/{doc => docs}/contributing.adoc (100%) rename third_party/home-manager/{doc => docs}/default.nix (96%) rename third_party/home-manager/{doc => docs}/faq.adoc (90%) rename third_party/home-manager/{doc => docs}/installation.adoc (96%) rename third_party/home-manager/{doc => docs}/man-configuration.xml (100%) rename third_party/home-manager/{doc => docs}/man-home-manager.xml (95%) rename third_party/home-manager/{doc => docs}/man-pages.xml (100%) rename third_party/home-manager/{doc => docs}/manual.xml (95%) rename third_party/home-manager/{doc => docs}/release-notes/release-notes.adoc (100%) rename third_party/home-manager/{doc => docs}/release-notes/rl-1809.adoc (100%) rename third_party/home-manager/{doc => docs}/release-notes/rl-1903.adoc (100%) rename third_party/home-manager/{doc => docs}/release-notes/rl-1909.adoc (100%) rename third_party/home-manager/{doc => docs}/release-notes/rl-2003.adoc (100%) rename third_party/home-manager/{doc => docs}/release-notes/rl-2009.adoc (100%) rename third_party/home-manager/{doc => docs}/release-notes/rl-2105.adoc (100%) create mode 100644 third_party/home-manager/docs/release-notes/rl-2111.adoc rename third_party/home-manager/{doc => docs}/writing-modules.adoc (100%) create mode 100644 third_party/home-manager/home-manager/completion.fish create mode 100644 third_party/home-manager/modules/lib/assertions.nix create mode 100644 third_party/home-manager/modules/misc/nixpkgs-disabled.nix create mode 100644 third_party/home-manager/modules/programs/atuin.nix create mode 100644 third_party/home-manager/modules/programs/bottom.nix create mode 100644 third_party/home-manager/modules/programs/hexchat.nix create mode 100644 third_party/home-manager/modules/programs/java.nix delete mode 100644 third_party/home-manager/modules/programs/lieer-accounts.nix create mode 100644 third_party/home-manager/modules/programs/nnn.nix create mode 100644 third_party/home-manager/modules/programs/sm64ex.nix create mode 100644 third_party/home-manager/modules/services/betterlockscreen.nix create mode 100644 third_party/home-manager/modules/services/devilspie2.nix create mode 100644 third_party/home-manager/modules/services/easyeffects.nix create mode 100644 third_party/home-manager/modules/services/fnott.nix create mode 100644 third_party/home-manager/modules/services/git-sync.nix delete mode 100644 third_party/home-manager/modules/services/lieer-accounts.nix create mode 100644 third_party/home-manager/modules/services/notify-osd.nix create mode 100644 third_party/home-manager/modules/services/trayer.nix create mode 100644 third_party/home-manager/modules/services/volnoti.nix create mode 100644 third_party/home-manager/modules/services/xsettingsd.nix delete mode 100644 third_party/home-manager/tests/modules/i18n/input-method/fcitx5-overlay.nix create mode 100644 third_party/home-manager/tests/modules/i18n/input-method/fcitx5-stubs.nix delete mode 100644 third_party/home-manager/tests/modules/misc/xdg/file-attr-names.nix create mode 100644 third_party/home-manager/tests/modules/misc/xdg/file-gen.nix create mode 100644 third_party/home-manager/tests/modules/programs/atuin/bash.nix create mode 100644 third_party/home-manager/tests/modules/programs/atuin/default.nix create mode 100644 third_party/home-manager/tests/modules/programs/atuin/empty-settings.nix create mode 100644 third_party/home-manager/tests/modules/programs/atuin/example-settings-expected.toml create mode 100644 third_party/home-manager/tests/modules/programs/atuin/example-settings.nix create mode 100644 third_party/home-manager/tests/modules/programs/atuin/no-shell.nix create mode 100644 third_party/home-manager/tests/modules/programs/atuin/zsh.nix create mode 100644 third_party/home-manager/tests/modules/programs/bat/bat.nix create mode 100644 third_party/home-manager/tests/modules/programs/bat/default.nix create mode 100644 third_party/home-manager/tests/modules/programs/bottom/default.nix create mode 100644 third_party/home-manager/tests/modules/programs/bottom/empty-settings.nix create mode 100644 third_party/home-manager/tests/modules/programs/bottom/example-settings.nix create mode 100644 third_party/home-manager/tests/modules/programs/broot/broot.nix create mode 100644 third_party/home-manager/tests/modules/programs/broot/default.nix create mode 100644 third_party/home-manager/tests/modules/programs/emacs/default.nix create mode 100644 third_party/home-manager/tests/modules/programs/emacs/extra-config.nix create mode 100644 third_party/home-manager/tests/modules/programs/firefox/profile-settings-expected-bookmarks-user.js create mode 100644 third_party/home-manager/tests/modules/programs/firefox/profile-settings-expected-bookmarks.html create mode 100644 third_party/home-manager/tests/modules/programs/gh/credential-helper.git.conf create mode 100644 third_party/home-manager/tests/modules/programs/gh/credential-helper.nix create mode 100644 third_party/home-manager/tests/modules/programs/gh/warnings.nix create mode 100644 third_party/home-manager/tests/modules/programs/hexchat/basic-configuration-expected-main-config create mode 100644 third_party/home-manager/tests/modules/programs/hexchat/basic-configuration-expected-serverlist-config create mode 100644 third_party/home-manager/tests/modules/programs/hexchat/basic-configuration.nix create mode 100644 third_party/home-manager/tests/modules/programs/hexchat/default.nix rename third_party/home-manager/tests/modules/programs/htop/{default-settings.nix => empty-settings.nix} (61%) create mode 100644 third_party/home-manager/tests/modules/programs/htop/example-htoprc.txt create mode 100644 third_party/home-manager/tests/modules/programs/htop/header_layout.nix create mode 100644 third_party/home-manager/tests/modules/programs/htop/settings-without-fields.nix delete mode 100644 third_party/home-manager/tests/modules/programs/irsii/default.nix create mode 100644 third_party/home-manager/tests/modules/programs/irssi/default.nix rename third_party/home-manager/tests/modules/programs/{irsii => irssi}/example-settings-expected.config (100%) rename third_party/home-manager/tests/modules/programs/{irsii => irssi}/example-settings.nix (85%) create mode 100644 third_party/home-manager/tests/modules/programs/kitty/example-macos-launch-services-cmdline create mode 100644 third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-named-mailboxes-expected.conf create mode 100644 third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-named-mailboxes.nix create mode 100644 third_party/home-manager/tests/modules/programs/neovim/coc-config.expected create mode 100644 third_party/home-manager/tests/modules/programs/neovim/coc-config.nix create mode 100644 third_party/home-manager/tests/modules/programs/nnn/default.nix create mode 100644 third_party/home-manager/tests/modules/programs/nnn/nnn.nix create mode 100644 third_party/home-manager/tests/modules/programs/nnn/plugins/.keep create mode 100644 third_party/home-manager/tests/modules/programs/powerline-go/fish.nix delete mode 100644 third_party/home-manager/tests/modules/programs/rbw/overlay.nix create mode 100644 third_party/home-manager/tests/modules/programs/rbw/rbw-stubs.nix delete mode 100644 third_party/home-manager/tests/modules/programs/rofi/assert-on-both-theme-and-colors.nix create mode 100644 third_party/home-manager/tests/modules/programs/rofi/config-with-deprecated-options.nix create mode 100644 third_party/home-manager/tests/modules/programs/sm64ex/default.nix create mode 100644 third_party/home-manager/tests/modules/programs/sm64ex/settings.nix create mode 100644 third_party/home-manager/tests/modules/services/devilspie2/config.lua create mode 100644 third_party/home-manager/tests/modules/services/devilspie2/configuration.nix create mode 100644 third_party/home-manager/tests/modules/services/devilspie2/default.nix create mode 100644 third_party/home-manager/tests/modules/services/flameshot/default.nix create mode 100644 third_party/home-manager/tests/modules/services/flameshot/empty-settings.nix create mode 100644 third_party/home-manager/tests/modules/services/flameshot/example-settings.nix create mode 100644 third_party/home-manager/tests/modules/services/fnott/default.nix create mode 100644 third_party/home-manager/tests/modules/services/fnott/example-settings-expected.ini create mode 100644 third_party/home-manager/tests/modules/services/fnott/example-settings.nix create mode 100644 third_party/home-manager/tests/modules/services/fnott/systemd-user-service-expected.service create mode 100644 third_party/home-manager/tests/modules/services/fnott/systemd-user-service.nix create mode 100644 third_party/home-manager/tests/modules/services/git-sync/basic.nix create mode 100644 third_party/home-manager/tests/modules/services/git-sync/default.nix create mode 100644 third_party/home-manager/tests/modules/services/screen-locker/basic-configuration.nix create mode 100644 third_party/home-manager/tests/modules/services/screen-locker/default.nix create mode 100644 third_party/home-manager/tests/modules/services/screen-locker/moved-options.nix create mode 100644 third_party/home-manager/tests/modules/services/screen-locker/no-xautolock.nix create mode 100644 third_party/home-manager/tests/modules/services/trayer/basic-configuration.nix create mode 100644 third_party/home-manager/tests/modules/services/trayer/default.nix delete mode 100644 third_party/home-manager/tests/modules/services/window-managers/i3/i3-overlay.nix create mode 100644 third_party/home-manager/tests/modules/services/window-managers/i3/i3-stubs.nix create mode 100644 third_party/home-manager/tests/modules/services/window-managers/sway/sway-bindkeys-to-code.conf create mode 100644 third_party/home-manager/tests/modules/services/window-managers/sway/sway-bindkeys-to-code.nix delete mode 100644 third_party/home-manager/tests/modules/services/window-managers/sway/sway-overlay.nix create mode 100644 third_party/home-manager/tests/modules/services/window-managers/sway/sway-stubs.nix create mode 100644 third_party/home-manager/tests/modules/services/xsettingsd/basic-configuration.conf create mode 100644 third_party/home-manager/tests/modules/services/xsettingsd/basic-configuration.nix create mode 100644 third_party/home-manager/tests/modules/services/xsettingsd/default.nix create mode 100644 third_party/home-manager/tests/stubs.nix diff --git a/third_party/home-manager/.github/CODEOWNERS b/third_party/home-manager/.github/CODEOWNERS index f7deb577fb..a12d9d950a 100644 --- a/third_party/home-manager/.github/CODEOWNERS +++ b/third_party/home-manager/.github/CODEOWNERS @@ -4,7 +4,7 @@ /modules/home-environment.nix @rycee -/modules/i18n/input-method @Kranzes +/modules/i18n/input-method @Kranzes /tests/modules/i18n/input-method @Kranzes /modules/misc/dconf.nix @gnidorah @rycee @@ -19,6 +19,8 @@ /modules/misc/news.nix @rycee +/modules/misc/nixpkgs-disabled.nix @thiagokokada + /modules/misc/numlock.nix @evanjs /tests/modules/misc/numlock @evanjs @@ -50,6 +52,9 @@ /modules/programs/autojump.nix @evanjs /tests/modules/programs/autojump @evanjs +/modules/programs/atuin.nix @hawkw +/tests/modules/programs/atuin @hawkw + /modules/programs/autorandr.nix @uvNikita /modules/programs/bash.nix @rycee @@ -58,6 +63,9 @@ /modules/programs/beets.nix @rycee +/modules/programs/bottom.nix @polykernel +/tests/modules/programs/bottom @polykernel + /modules/programs/broot.nix @aheaume /modules/programs/dircolors.nix @JustinLovinger @@ -75,8 +83,8 @@ /modules/programs/foot.nix @plabadens /tests/modules/programs/foot @plabadens -/modules/programs/gh.nix @Gerschtli -/tests/modules/programs/gh @Gerschtli +/modules/programs/gh.nix @Gerschtli @berbiche +/tests/modules/programs/gh @Gerschtli @berbiche /modules/programs/git.nix @rycee @@ -84,17 +92,23 @@ /modules/programs/go.nix @rvolosatovs +/modules/programs/hexchat.nix @superherointj @thiagokokada +/tests/modules/programs/hexchat @thiagokokada + /modules/programs/himalaya.nix @ambroisie /tests/modules/programs/himalaya @ambroisie /modules/programs/home-manager.nix @rycee /modules/programs/htop.nix @bjpbakker +/tests/modules/htop @bjpbakker /modules/programs/i3status.nix @JustinLovinger /modules/programs/i3status-rust.nix @workflow +/modules/programs/java.nix @ShamrockLee + /modules/programs/keychain.nix @marsam /modules/programs/lazygit.nix @kalhauge @@ -138,6 +152,9 @@ /modules/programs/nix-index.nix @ambroisie /tests/modules/programs/nix-index @ambroisie +/modules/programs/nnn.nix @thiagokokada +/tests/modules/programs/nnn @thiagokokada + /modules/programs/noti.nix @marsam /modules/programs/nushell.nix @Philipp-M @@ -180,6 +197,9 @@ /modules/programs/senpai.nix @malte-v +/modules/programs/sm64ex.nix @ivarwithoutbones +/tests/modules/programs/sm64ex @ivarwithoutbones + /modules/programs/ssh.nix @rycee /modules/programs/starship.nix @marsam @@ -208,17 +228,24 @@ /modules/services/barrier.nix @Kritnich /tests/modules/services/barrier @Kritnich +/modules/services/betterlockscreen.nix @SebTM + /modules/services/caffeine.nix @uvNikita /modules/services/cbatticon.nix @pmiddend /modules/services/clipmenu.nix @DamienCassou +/modules/services/devilspie2.nix @dawidsowa +/tests/modules/services/devilspie2 @dawidsowa + /modules/services/dropbox.nix @eyJhb /tests/modules/services/dropbox @eyJhb /modules/services/dunst.nix @rycee +/modules/services/easyeffects.nix @fufexan + /modules/services/emacs.nix @tadfisher /modules/services/etesync-dav.nix @Valodim @@ -227,6 +254,11 @@ /modules/services/fluidsynth.nix @Valodim +/modules/services/fnott.nix @polykernel +/tests/modules/services/fnott @polykernel + +/modules/services/git-sync.nix @IvanMalison + /modules/services/gnome-keyring.nix @rycee /modules/services/gpg-agent.nix @rycee @@ -260,6 +292,8 @@ /modules/services/network-manager-applet.nix @rycee +/modules/services/notify-osd.nix @imalison + /modules/services/pantalaimon.nix @jojosch /tests/modules/services/pantalaimon @jojosch @@ -288,6 +322,9 @@ /modules/services/redshift-gammastep @rycee @petabyteboy @thiagokokada /tests/modules/redshift-gammastep @thiagokokada +/modules/services/screen-locker.nix @jrobsonchase +/tests/modules/services/screen-locker @jrobsonchase + /modules/services/status-notifier-watcher.nix @pltanton /modules/services/syncthing.nix @rycee @@ -298,6 +335,9 @@ /modules/services/taskwarrior-sync.nix @minijackson @pacien +/modules/services/trayer.nix @AndreasMager +/tests/modules/services/trayer @AndreasMager + /modules/services/udiskie.nix @rycee /modules/services/unison.nix @pacien @@ -333,3 +373,7 @@ /modules/xresources.nix @rycee /modules/xsession.nix @rycee + +/modules/services/volnoti.nix @IvanMalison + +Makefile @thiagokokada diff --git a/third_party/home-manager/.github/ISSUE_TEMPLATE.md b/third_party/home-manager/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 06be7202df..0000000000 --- a/third_party/home-manager/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,31 +0,0 @@ - - -### Issue description - - - -### Meta - -#### Maintainer CC - - - -#### Technical details - - diff --git a/third_party/home-manager/.github/ISSUE_TEMPLATE/feature-request.md b/third_party/home-manager/.github/ISSUE_TEMPLATE/feature-request.md new file mode 100644 index 0000000000..c984617828 --- /dev/null +++ b/third_party/home-manager/.github/ISSUE_TEMPLATE/feature-request.md @@ -0,0 +1,15 @@ +--- +name: Feature request +about: Ask for a new feature to be added (module, program, etc.) +title: '' +labels: feature request +assignees: rycee, berbiche, sumnerevans + +--- + + + +### Description + diff --git a/third_party/home-manager/.github/ISSUE_TEMPLATE/issue.yaml b/third_party/home-manager/.github/ISSUE_TEMPLATE/issue.yaml new file mode 100644 index 0000000000..e7a0dc3c03 --- /dev/null +++ b/third_party/home-manager/.github/ISSUE_TEMPLATE/issue.yaml @@ -0,0 +1,46 @@ +name: Bug Report +description: File a bug/issue +title: 'bug: ' +labels: [bug, triage] + +# We cannot use nix-community/home-manager +# See https://github.com/dear-github/dear-github/issues/170 +assignees: [rycee, berbiche, sumnerevans] + +body: +- type: checkboxes + attributes: + label: Is there an existing issue for this? + description: | + Please search to see if an issue already exists for the bug you encountered. + options: + - label: I have searched the existing issues + required: true +- type: textarea + attributes: + label: Issue description + description: | + Please describe the issue. + + For support and help please use the IRC channel #home-manager at irc.oftc.net or + Matrix room instead. + validations: + required: false +- type: textarea + attributes: + label: Maintainer CC + description: | + Please @ people who are in the `meta.maintainers` list of the offending module. + If in doubt, check `git blame` for whoever last touched something. + validations: + required: false +- type: textarea + id: system + attributes: + label: System information + description: | + Please run `nix-shell -p nix-info --run "nix-info -m"` and paste the result. + render: markdown + validations: + required: true + diff --git a/third_party/home-manager/.github/PULL_REQUEST_TEMPLATE.md b/third_party/home-manager/.github/PULL_REQUEST_TEMPLATE.md index 6c68d75b24..fd0a266be9 100644 --- a/third_party/home-manager/.github/PULL_REQUEST_TEMPLATE.md +++ b/third_party/home-manager/.github/PULL_REQUEST_TEMPLATE.md @@ -15,7 +15,7 @@ pull-request. Also make sure to read the guidelines found at - https://github.com/nix-community/home-manager/blob/master/doc/contributing.adoc#sec-guidelines + https://github.com/nix-community/home-manager/blob/master/docs/contributing.adoc#sec-guidelines --> @@ -35,7 +35,7 @@ Also make sure to read the guidelines found at {long description} ``` - See [CONTRIBUTING](https://github.com/nix-community/home-manager/blob/master/doc/contributing.adoc#sec-commit-style) for more information and [recent commit messages](https://github.com/nix-community/home-manager/commits/master) for examples. + See [CONTRIBUTING](https://github.com/nix-community/home-manager/blob/master/docs/contributing.adoc#sec-commit-style) for more information and [recent commit messages](https://github.com/nix-community/home-manager/commits/master) for examples. - If this PR adds a new module diff --git a/third_party/home-manager/.github/dependabot.yml b/third_party/home-manager/.github/dependabot.yml index 45eab8b749..db1616ac18 100644 --- a/third_party/home-manager/.github/dependabot.yml +++ b/third_party/home-manager/.github/dependabot.yml @@ -10,7 +10,7 @@ updates: - package-ecosystem: "github-actions" directory: "/" - target-branch: "release-20.09" + target-branch: "release-21.05" schedule: interval: "weekly" commit-message: diff --git a/third_party/home-manager/.github/workflows/github_pages.yml b/third_party/home-manager/.github/workflows/github_pages.yml index a3109a9fc7..24eaafa27a 100644 --- a/third_party/home-manager/.github/workflows/github_pages.yml +++ b/third_party/home-manager/.github/workflows/github_pages.yml @@ -11,7 +11,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - - uses: cachix/install-nix-action@v13 + - uses: cachix/install-nix-action@v14 with: nix_path: nixpkgs=channel:nixos-unstable - uses: cachix/cachix-action@v10 diff --git a/third_party/home-manager/.github/workflows/test.yml b/third_party/home-manager/.github/workflows/test.yml index 8936bb1a1f..4608d481a7 100644 --- a/third_party/home-manager/.github/workflows/test.yml +++ b/third_party/home-manager/.github/workflows/test.yml @@ -6,12 +6,13 @@ on: jobs: tests: strategy: + fail-fast: false matrix: os: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - - uses: cachix/install-nix-action@v13 + - uses: cachix/install-nix-action@v14.1 with: nix_path: nixpkgs=channel:nixos-unstable - uses: cachix/cachix-action@v10 @@ -20,4 +21,4 @@ jobs: signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' - run: ./format -c - run: nix-shell . -A install - - run: nix-shell --pure tests -A run.all + - run: nix-shell --arg enableBig false --pure tests -A run.all diff --git a/third_party/home-manager/CONTRIBUTING.adoc b/third_party/home-manager/CONTRIBUTING.adoc deleted file mode 100644 index cffa621392..0000000000 --- a/third_party/home-manager/CONTRIBUTING.adoc +++ /dev/null @@ -1,258 +0,0 @@ -[[ch-contributing]] -== Contributing - -:open-issues: https://github.com/nix-community/home-manager/issues -:new-issue: https://github.com/nix-community/home-manager/issues/new -:fork-a-repo: https://help.github.com/articles/fork-a-repo/ -:create-a-pull-request: https://help.github.com/articles/creating-a-pull-request/ -:seven-rules: https://chris.beams.io/posts/git-commit/#seven-rules -:news-nix: https://github.com/nix-community/home-manager/blob/master/modules/misc/news.nix -:nixfmt: https://github.com/serokell/nixfmt/ -:example-commit-message: https://github.com/nix-community/home-manager/commit/69f8e47e9e74c8d3d060ca22e18246b7f7d988ef - -Contributions to Home Manager are very welcome. To make the process as smooth as possible for both you and the Home Manager maintainers we provide some guidelines that we ask you to follow. See <> for information on how to set up a suitable development environment and <> for the actual guidelines. - -This text is mainly directed at those who would like to make code contributions to Home Manager. If you just want to report a bug then first look among the already {open-issues}[open issues], if you find one matching yours then feel free to comment on it to add any additional information you may have. If no matching issue exists then go to the {new-issue}[new issue] page and write a description of your problem. Include as much information as you can, ideally also include relevant excerpts from your Home Manager configuration. - -[[sec-contrib-getting-started]] -=== Getting started - -If you have not previously forked Home Manager then you need to do that first. Have a look at GitHub's {fork-a-repo}[Fork a repo] for instructions on how to do this. - -Once you have a fork of Home Manager you should create a branch starting at the most recent `master` branch. Give your branch a reasonably descriptive name. Commit your changes to this branch and when you are happy with the result and it fulfills <> then push the branch to GitHub and {create-a-pull-request}[create a pull request]. - -Assuming your clone is at `$HOME/devel/home-manager` then you can make the `home-manager` command use it by either - -1. overriding the default path by using the `-I` command line option: -+ -[source,console] -$ home-manager -I home-manager=$HOME/devel/home-manager -+ -or - -2. changing the default path by ensuring your configuration includes -+ -[source,nix] ----- -programs.home-manager.enable = true; -programs.home-manager.path = "$HOME/devel/home-manager"; ----- -+ -and running `home-manager switch` to activate the change. Afterwards, `home-manager build` and `home-manager switch` will use your cloned repository. - -The first option is good if you only temporarily want to use your clone. - -[[sec-guidelines]] -=== Guidelines -:irc-home-manager: https://webchat.oftc.net/?channels=home-manager -:valuable-options: https://github.com/Infinisil/rfcs/blob/config-option/rfcs/0042-config-option.md#valuable-options -:rfc-42: https://github.com/Infinisil/rfcs/blob/config-option/rfcs/0042-config-option.md -:assertions: https://nixos.org/manual/nixos/stable/index.html#sec-assertions - -If your contribution satisfy the following rules then there is a good chance it will be merged without too much trouble. The rules are enforced by the Home Manager maintainers and to a lesser extent the Home Manager CI system. - -If you are uncertain how these rules affect the change you would like to make then feel free to start a discussion in the {irc-home-manager}[#home-manager] IRC channel, ideally before you start developing. - -[[sec-guidelines-back-compat]] -==== Maintain backward compatibility - -Your contribution should not cause another user's existing configuration to break unless there is a very good reason and the change should be announced to the user through an {assertions}[assertion] or similar. - -Remember that Home Manager is used in many different environments and you should consider how your change may effect others. For example, - -- Does your change work for people that do not use NixOS? Consider other GNU/Linux distributions and macOS. -- Does your change work for people whose configuration is built on one system and deployed on another system? - -[[sec-guidelines-forward-compat]] -==== Keep forward compatibility in mind - -The master branch of Home Manager tracks the unstable channel of Nixpkgs, which may update package versions at any time. It is therefore important to consider how a package update may affect your code and try to reduce the risk of breakage. - -The most effective way to reduce this risk is to follow the advice in <>. - -[[sec-guidelines-valuable-options]] -==== Add only valuable options - -When creating a new module it is tempting to include every option supported by the software. This is _strongly_ discouraged. Providing many options increases maintenance burden and risk of breakage considerably. This is why only the most {valuable-options}[important software options] should be modeled explicitly. Less important options should be expressible through an `extraConfig` escape hatch. - -A good rule of thumb for the first implementation of a module is to only add explicit options for those settings that absolutely must be set for the software to function correctly. It follows that a module for software that provides sensible default values for all settings would require no explicit options at all. - -If the software uses a structured configuration format like a JSON, YAML, INI, TOML, or even a plain list of key/value pairs then consider using a `settings` option as described in {rfc-42}[Nix RFC 42]. - -[[sec-guidelines-add-tests]] -==== Add relevant tests - -If at all possible, make sure to add new tests and expand existing tests so that your change will keep working in the future. See <> for more information about the Home Manager test suite. - -All contributed code _must_ pass the test suite. - -[[sec-guidelines-module-maintainer]] - -==== Add relevant documentation -:docbook: https://tdg.docbook.org/ -:asciidoc: https://asciidoc.org/ -:docbook-rocks: https://berbiche.github.io/docbook.rocks/ - -Many code changes require changing the documentation as well. Module options should be documented with DocBook. See {docbook-rocks}[DocBook rocks!] for a quick introduction and {docbook}[DocBook 5: The Definitive Guide] for in-depth information of DocBook. Home Manager is itself documented using a combination of DocBook and {asciidoc}[AsciiDoc]. All text is hosted in Home Manager's Git repository. - -The HTML version of the manual containing both the module option descriptions and the documentation of Home Manager can be generated and opened by typing the following in a shell within a clone of the Home Manager Git repository: - -[source,console] -$ nix-build -A docs.html -$ xdg-open ./result/share/doc/home-manager/index.html - -When you have made changes to a module, it is a good idea to check that the man page version of the module options looks good: - -[source,console] -$ nix-build -A docs.manPages -$ man ./result/share/man/man5/home-configuration.nix.5 - -==== Add yourself as a module maintainer - -Every new module _must_ include a named maintainer using the `meta.maintainers` attribute. If you are a user of a module that currently lacks a maintainer then please consider adopting it. - -If you are present in the NixOS maintainer list then you can use that entry. If you are not then you can add yourself to `modules/lib/maintainers.nix` in the Home Manager project. - -Also add yourself to `.github/CODEOWNERS` as owner of the associated module files, including the test files. You will then be automatically added as a reviewer on any new pull request that touches your files. - -Maintainers are encouraged to join the IRC channel and participate when they have opportunity. - -[[sec-guidelines-code-style]] -==== Format your code - -Make sure your code is formatted as described in <>. To maintain consistency throughout the project you are encouraged to browse through existing code and adopt its style also in new code. - -[[sec-guidelines-commit-message-style]] -==== Format your commit messages - -Similar to <> we encourage a consistent commit message format as described in <>. - -[[sec-guidelines-news-style]] -==== Format your news entries - -If your contribution includes a change that should be communicated to users of Home Manager then you can add a news entry. The entry must be formatted as described in <>. - -When new modules are added a news entry should be included but you do not need to create this entry manually. The merging maintainer will create the entry for you. This is to reduce the risk of merge conflicts. - -[[sec-guidelines-conditional-modules]] -==== Use conditional modules and news - -Home Manager includes a number of modules that are only usable on some of the supported platforms. The most common example of platform specific modules are those that define systemd user services, which only works on Linux systems. - -If you add a module that is platform specific then make sure to include a condition in the `loadModule` function call. This will make the module accessible only on systems where the condition evaluates to `true`. - -Similarly, if you are adding a news entry then it should be shown only to users that may find it relevant, see <> for a description of conditional news. - -[[sec-guidelines-licensing]] -==== Mind the license - -The Home Manager project is covered by the MIT license and we can only accept contributions that fall under this license, or are licensed in a compatible way. When you contribute self written code and documentation it is assumed that you are doing so under the MIT license. - -A potential gotcha with respect to licensing are option descriptions. Often it is convenient to copy from the upstream software documentation. When this is done it is important to verify that the license of the upstream documentation allows redistribution under the terms of the MIT license. - -[[sec-commit-style]] -=== Commits - -The commits in your pull request should be reasonably self-contained, that is, each commit should make sense in isolation. In particular, you will be asked to amend any commit that introduces syntax errors or similar problems even if they are fixed in a later commit. - -The commit messages should follow the {seven-rules}[seven rules]. We also ask you to include the affected code component or module in the first line. That is, a commit message should follow the template - ----- -{component}: {description} - -{long description} ----- - -where `{component}` refers to the code component (or module) your change affects, `{description}` is a very brief description of your change, and `{long description}` is an optional clarifying description. As a rare exception, if there is no clear component, or your change affects many components, then the `{component}` part is optional. See <> for a commit message that fulfills these requirements. - -[[ex-commit-message]] -.Compliant commit message -=============================================================================== -The commit {example-commit-message}[69f8e47e9e74c8d3d060ca22e18246b7f7d988ef] contains the commit message - ----- -starship: allow running in Emacs if vterm is used - -The vterm buffer is backed by libvterm and can handle Starship prompts -without issues. ----- - -which ticks all the boxes necessary to be accepted in Home Manager. -=============================================================================== - -Finally, when adding a new module, say `programs/foo.nix`, we use the fixed commit format `foo: add module`. You can, of course, still include a long description if you wish. - -[[sec-code-style]] -=== Code Style - -The code in Home Manager is formatted by the {nixfmt}[nixfmt] tool and the formatting is checked in the pull request tests. Run the `format` tool inside the project repository before submitting your pull request. - -Keep lines at a reasonable width, ideally 80 characters or less. This also applies to string literals. - -We prefer `lowerCamelCase` for variable and attribute names with the accepted exception of variables directly referencing packages in Nixpkgs which use a hyphenated style. For example, the Home Manager option `services.gpg-agent.enableSshSupport` references the `gpg-agent` package in Nixpkgs. - -[[sec-news]] -=== News - -Home Manager includes a system for presenting news to the user. When making a change you, therefore, have the option to also include an associated news entry. In general, a news entry should only be added for truly noteworthy news. For example, a bug fix or new option does generally not need a news entry. - -If you do have a change worthy of a news entry then please add one in {news-nix}[`news.nix`] but you should follow some basic guidelines: - -- The entry timestamp should be in ISO-8601 format having "+00:00" as time zone. For example, "2017-09-13T17:10:14+00:00". A suitable timestamp can be produced by the command -+ -[source,console] -$ date --iso-8601=second --universal - -- The entry condition should be as specific as possible. For example, if you are changing or deprecating a specific option then you could restrict the news to those users who actually use this option. - -- Wrap the news message so that it will fit in the typical terminal, that is, at most 80 characters wide. Ideally a bit less. - -- Unlike commit messages, news will be read without any connection to the Home Manager source code. It is therefore important to make the message understandable in isolation and to those who do not have knowledge of the Home Manager internals. To this end it should be written in more descriptive, prose like way. - -- If you refer to an option then write its full attribute path. That is, instead of writing -+ ----- -The option 'foo' has been deprecated, please use 'bar' instead. ----- -+ -it should read -+ ----- -The option 'services.myservice.foo' has been deprecated, please -use 'services.myservice.bar' instead. ----- - -- A new module, say `foo.nix`, should always include a news entry that has a message along the lines of -+ ----- -A new module is available: 'services.foo'. ----- -+ -If the module is platform specific, e.g., a service module using systemd, then a condition like -+ -[source,nix] -condition = hostPlatform.isLinux; -+ -should be added. If you contribute a module then you don't need to add this entry, the merger will create an entry for you. - -[[sec-tests]] -=== Tests - -Home Manager includes a basic test suite and it is highly recommended to include at least one test when adding a module. Tests are typically in the form of "golden tests" where, for example, a generated configuration file is compared to a known correct file. - -It is relatively easy to create tests by modeling the existing tests, found in the `tests` project directory. - -The full Home Manager test suite can be run by executing - -[source,console] -$ nix-shell --pure tests -A run.all - -in the project root. List all test cases through - -[source,console] -$ nix-shell --pure tests -A list - -and run an individual test, for example `alacritty-empty-settings`, through - -[source,console] -$ nix-shell --pure tests -A run.alacritty-empty-settings diff --git a/third_party/home-manager/FAQ.adoc b/third_party/home-manager/FAQ.adoc deleted file mode 100644 index 2c9c1f1683..0000000000 --- a/third_party/home-manager/FAQ.adoc +++ /dev/null @@ -1,173 +0,0 @@ -[[ch-faq]] -== Frequently Asked Questions (FAQ) - -=== Why is there a collision error when switching generation? - -Home Manager currently installs packages into the user environment, precisely as if the packages were installed through `nix-env --install`. This means that you will get a collision error if your Home Manager configuration attempts to install a package that you already have installed manually, that is, packages that shows up when you run `nix-env --query`. - -For example, imagine you have the `hello` package installed in your environment - -[source,console] ----- -$ nix-env --query -hello-2.10 ----- - -and your Home Manager configuration contains - -[source,nix] ----- -home.packages = [ pkgs.hello ]; ----- - -Then attempting to switch to this configuration will result in an error similar to - -[source,console] ----- -$ home-manager switch -these derivations will be built: - /nix/store/xg69wsnd1rp8xgs9qfsjal017nf0ldhm-home-manager-path.drv -[…] -Activating installPackages -replacing old ‘home-manager-path’ -installing ‘home-manager-path’ -building path(s) ‘/nix/store/b5c0asjz9f06l52l9812w6k39ifr49jj-user-environment’ -Wide character in die at /nix/store/64jc9gd2rkbgdb4yjx3nrgc91bpjj5ky-buildenv.pl line 79. -collision between ‘/nix/store/fmwa4axzghz11cnln5absh31nbhs9lq1-home-manager-path/bin/hello’ and ‘/nix/store/c2wyl8b9p4afivpcz8jplc9kis8rj36d-hello-2.10/bin/hello’; use ‘nix-env --set-flag priority NUMBER PKGNAME’ to change the priority of one of the conflicting packages -builder for ‘/nix/store/b37x3s7pzxbasfqhaca5dqbf3pjjw0ip-user-environment.drv’ failed with exit code 2 -error: build of ‘/nix/store/b37x3s7pzxbasfqhaca5dqbf3pjjw0ip-user-environment.drv’ failed ----- - -The solution is typically to uninstall the package from the environment using `nix-env --uninstall` and reattempt the Home Manager generation switch. - -You could also opt to unistall _all_ of the packages from your profile with `nix-env --uninstall '*'`. - -=== Why are the session variables not set? - -Home Manager is only able to set session variables automatically if it manages your Bash or Z shell configuration. If you don't want to let Home Manager manage your shell then you will have to manually source the `~/.nix-profile/etc/profile.d/hm-session-vars.sh` file in an appropriate way. In Bash and Z shell this can be done by adding - -[source,bash] ----- -. "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" ----- - -to your `.profile` and `.zshrc` files, respectively. The `hm-session-vars.sh` file should work in most Bourne-like shells. - -=== How to set up a configuration for multiple users/machines? -:post-your-homenix: https://www.reddit.com/r/NixOS/comments/9bb9h9/post_your_homemanager_homenix_file/ - -A typical way to prepare a repository of configurations for multiple logins and machines is to prepare one "top-level" file for each unique combination. - -For example, if you have two machines, called "kronos" and "rhea" on which you want to configure your user "jane" then you could create the files - -- `kronos-jane.nix`, -- `rhea-jane.nix`, and -- `common.nix` - -in your repository. On the kronos and rhea machines you can then make `~jane/.config/nixpkgs/home.nix` be a symbolic link to the corresponding file in your configuration repository. - -The `kronos-jane.nix` and `rhea-jane.nix` files follow the format - -[source,nix] ----- -{ ... }: - -{ - imports = [ ./common.nix ]; - - # Various options that are specific for this machine/user. -} ----- - -while the `common.nix` file contains configuration shared across the two logins. Of course, instead of just a single `common.nix` file you can have multiple ones, even one per program or service. - -You can get some inspiration from the {post-your-homenix}[Post your home-manager home.nix file!] Reddit thread. - -=== Why do I get an error message about `ca.desrt.dconf`? - -You are most likely trying to configure the GTK or Gnome Terminal but the DBus session is not aware of the dconf service. The full error you might get is - ----- -error: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name ca.desrt.dconf was not provided by any .service files ----- - -The solution on NixOS is to add - -[source,nix] -services.dbus.packages = with pkgs; [ gnome.dconf ]; - -to your system configuration. - -=== How do I install packages from Nixpkgs unstable? - -If you are using a stable version of Nixpkgs but would like to install some particular packages from Nixpkgs unstable – or some other channel – then you can import the unstable Nixpkgs and refer to its packages within your configuration. Something like - -[source,nix] ----- -{ pkgs, config, ... }: - -let - - pkgsUnstable = import {}; - -in - -{ - home.packages = [ - pkgsUnstable.foo - ]; - - # … -} ----- - -should work provided you have a Nix channel called `nixpkgs-unstable`. - -You can add the `nixpkgs-unstable` channel by running - -[source,console] ----- -# nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs-unstable -# nix-channel --update ----- - -Note, the package will not be affected by any package overrides, overlays, etc. - -=== How do I override the package used by a module? -:nixpkgs-overlays: https://nixos.org/nixpkgs/manual/#chap-overlays - -By default Home Manager will install the package provided by your chosen `nixpkgs` channel but occasionally you might end up needing to change this package. This can typically be done in two ways. - -1. If the module provides a `package` option, such as `programs.beets.package`, then this is the recommended way to perform the override. For example, -+ -[source,nix] -programs.beets.package = pkgs.beets.override { enableCheck = true; }; - -2. If no `package` option is available then you can typically override the relevant package using an {nixpkgs-overlays}[overlay]. -+ -For example, if you want to use the `programs.skim` module but use the `skim` package from Nixpkgs unstable, then a configuration like -+ -[source,nix] ----- -{ pkgs, config, ... }: - -let - - pkgsUnstable = import {}; - -in - -{ - programs.skim.enable = true; - - nixpkgs.overlays = [ - (self: super: { - skim = pkgsUnstable.skim; - }) - ]; - - # … -} ----- -+ -should work OK. diff --git a/third_party/home-manager/Makefile b/third_party/home-manager/Makefile new file mode 100644 index 0000000000..5172e8386f --- /dev/null +++ b/third_party/home-manager/Makefile @@ -0,0 +1,20 @@ +.PHONY: all all-tests test test-install format +NIXPKGS_REV := nixpkgs-unstable +NIX_PATH := nixpkgs=https://github.com/NixOS/nixpkgs/archive/${NIXPKGS_REV}.tar.gz + +all: all-tests test-install + +all-tests: + $(MAKE) test TEST=all + +test: +ifndef TEST + $(error Use 'make test TEST=' to run desired test) +endif + nix-shell --pure tests -I ${NIX_PATH} -A run.${TEST} + +test-install: + HOME=$(shell mktemp -d) NIX_PATH=${NIX_PATH} nix-shell . -A install + +format: + ./format diff --git a/third_party/home-manager/README.md b/third_party/home-manager/README.md index 45327ba7be..85d8db6020 100644 --- a/third_party/home-manager/README.md +++ b/third_party/home-manager/README.md @@ -70,16 +70,16 @@ Currently the easiest way to install Home Manager is as follows: 2. Add the appropriate Home Manager channel. If you are following Nixpkgs master or an unstable channel you can run - ```console - $ nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager - $ nix-channel --update + ```shell + nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager + nix-channel --update ``` and if you follow a Nixpkgs version 21.05 channel you can run - ```console - $ nix-channel --add https://github.com/nix-community/home-manager/archive/release-21.05.tar.gz home-manager - $ nix-channel --update + ```shell + nix-channel --add https://github.com/nix-community/home-manager/archive/release-21.05.tar.gz home-manager + nix-channel --update ``` On NixOS you may need to log out and back in for the channel to @@ -93,8 +93,8 @@ Currently the easiest way to install Home Manager is as follows: 3. Install Home Manager and create the first Home Manager generation: - ```console - $ nix-shell '' -A install + ```shell + nix-shell '' -A install ``` Once finished, Home Manager should be active and available in your @@ -103,13 +103,14 @@ Currently the easiest way to install Home Manager is as follows: 3. If you do not plan on having Home Manager manage your shell configuration then you must source the - ``` + ```shell $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh ``` - file in your shell configuration. Unfortunately, in this specific - case we currently only support POSIX.2-like shells such as - [Bash][] or [Z shell][]. + file in your shell configuration. This file can be sourced + directly by POSIX.2-like shells such as [Bash][] or [Z shell][]. + [Fish][] users can use utilities such as [foreign-env][] or + [babelfish][]. For example, if you use Bash then add @@ -190,14 +191,14 @@ To satisfy the above setup we should elaborate the To activate this configuration you can then run -```console -$ home-manager switch +```shell +home-manager switch ``` or if you are not feeling so lucky, -```console -$ home-manager build +```shell +home-manager build ``` which will create a `result` link to a directory containing an @@ -207,8 +208,8 @@ Documentation of available configuration options, including descriptions and usage examples, is available in the [Home Manager manual][configuration options] or offline by running -```console -$ man home-configuration.nix +```shell +man home-configuration.nix ``` Rollbacks @@ -384,3 +385,6 @@ an issue. [samueldr]: https://github.com/samueldr/ [Nix Pills]: https://nixos.org/nixos/nix-pills/ [Nix Flakes]: https://nixos.wiki/wiki/Flakes +[Fish]: https://fishshell.com +[foreign-env]: https://github.com/oh-my-fish/plugin-foreign-env +[babelfish]: https://github.com/bouk/babelfish diff --git a/third_party/home-manager/default.nix b/third_party/home-manager/default.nix index 4219d370c4..4438d827f3 100644 --- a/third_party/home-manager/default.nix +++ b/third_party/home-manager/default.nix @@ -1,7 +1,7 @@ { pkgs ? import { } }: rec { - docs = with import ./doc { inherit pkgs; }; { + docs = with import ./docs { inherit pkgs; }; { html = manual.html; manPages = manPages; json = options.json; diff --git a/third_party/home-manager/doc/release-notes/rl-2111.adoc b/third_party/home-manager/doc/release-notes/rl-2111.adoc deleted file mode 100644 index 63986f953d..0000000000 --- a/third_party/home-manager/doc/release-notes/rl-2111.adoc +++ /dev/null @@ -1,21 +0,0 @@ -[[sec-release-21.11]] -== Release 21.11 - -This is the current unstable branch and the information in this -section is therefore not final. - -[[sec-release-21.11-highlights]] -=== Highlights - -This release has the following notable changes: - -* Nothing has happened. - -[[sec-release-21.11-state-version-changes]] -=== State Version Changes - -The state version in this release includes the changes below. These -changes are only active if the `home.stateVersion` option is set to -"21.11" or later. - -* Nothing has happened. diff --git a/third_party/home-manager/doc/contributing.adoc b/third_party/home-manager/docs/contributing.adoc similarity index 100% rename from third_party/home-manager/doc/contributing.adoc rename to third_party/home-manager/docs/contributing.adoc diff --git a/third_party/home-manager/doc/default.nix b/third_party/home-manager/docs/default.nix similarity index 96% rename from third_party/home-manager/doc/default.nix rename to third_party/home-manager/docs/default.nix index 8015f1b59d..d5ff901061 100644 --- a/third_party/home-manager/doc/default.nix +++ b/third_party/home-manager/docs/default.nix @@ -9,8 +9,8 @@ let name = "nmd"; owner = "rycee"; repo = "nmd"; - rev = "2398aa79ab12aa7aba14bc3b08a6efd38ebabdc5"; - sha256 = "0yxb48afvccn8vvpkykzcr4q1rgv8jsijqncia7a5ffzshcrwrnh"; + rev = "12bc57594e12525d2e4422fa7034b2d54e9ea09a"; + sha256 = "0fpankfx2c99x4n1mhdy730yxy2b03qcw4zvjxyk4b1v60h8057n"; }; nmd = import nmdSrc { inherit lib pkgs; }; diff --git a/third_party/home-manager/doc/faq.adoc b/third_party/home-manager/docs/faq.adoc similarity index 90% rename from third_party/home-manager/doc/faq.adoc rename to third_party/home-manager/docs/faq.adoc index 2c9c1f1683..c5615fdbfc 100644 --- a/third_party/home-manager/doc/faq.adoc +++ b/third_party/home-manager/docs/faq.adoc @@ -43,15 +43,21 @@ The solution is typically to uninstall the package from the environment using `n You could also opt to unistall _all_ of the packages from your profile with `nix-env --uninstall '*'`. === Why are the session variables not set? +:foreign-env: https://github.com/oh-my-fish/plugin-foreign-env -Home Manager is only able to set session variables automatically if it manages your Bash or Z shell configuration. If you don't want to let Home Manager manage your shell then you will have to manually source the `~/.nix-profile/etc/profile.d/hm-session-vars.sh` file in an appropriate way. In Bash and Z shell this can be done by adding +Home Manager is only able to set session variables automatically if it manages your Bash, Z shell, or fish shell configuration. If you don't want to let Home Manager manage your shell then you will have to manually source the `~/.nix-profile/etc/profile.d/hm-session-vars.sh` file in an appropriate way. In Bash and Z shell this can be done by adding [source,bash] ---- . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" ---- -to your `.profile` and `.zshrc` files, respectively. The `hm-session-vars.sh` file should work in most Bourne-like shells. +to your `.profile` and `.zshrc` files, respectively. The `hm-session-vars.sh` file should work in most Bourne-like shells. For fish shell, it is possible to source it using {foreign-env}[the foreign-env plugin] + +[source,bash] +---- +fenv source "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" > /dev/null +---- === How to set up a configuration for multiple users/machines? :post-your-homenix: https://www.reddit.com/r/NixOS/comments/9bb9h9/post_your_homemanager_homenix_file/ @@ -94,7 +100,7 @@ error: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name ca.desrt. The solution on NixOS is to add [source,nix] -services.dbus.packages = with pkgs; [ gnome.dconf ]; +programs.dconf.enable = true; to your system configuration. diff --git a/third_party/home-manager/doc/installation.adoc b/third_party/home-manager/docs/installation.adoc similarity index 96% rename from third_party/home-manager/doc/installation.adoc rename to third_party/home-manager/docs/installation.adoc index 123ca7146c..82d890f193 100644 --- a/third_party/home-manager/doc/installation.adoc +++ b/third_party/home-manager/docs/installation.adoc @@ -86,9 +86,12 @@ file in your shell configuration. Alternatively source + when managing home configuration together with system configuration. + -Unfortunately, we currently only support POSIX.2-like shells such as +This file can be sourced directly by POSIX.2-like shells such as https://www.gnu.org/software/bash/[Bash] or -http://zsh.sourceforge.net/[Z shell]. +http://zsh.sourceforge.net/[Z shell]. https://fishshell.com[Fish] +users can use utilities such as +https://github.com/oh-my-fish/plugin-foreign-env[foreign-env] or +https://github.com/bouk/babelfish[babelfish]. + For example, if you use Bash then add + @@ -224,6 +227,10 @@ For example, a nix-darwin configuration may include the lines [source,nix] ---- +users.users.eve = { + name = "eve"; + home = "/Users/eve"; +} home-manager.users.eve = { pkgs, ... }: { home.packages = [ pkgs.atool pkgs.httpie ]; programs.bash.enable = true; diff --git a/third_party/home-manager/doc/man-configuration.xml b/third_party/home-manager/docs/man-configuration.xml similarity index 100% rename from third_party/home-manager/doc/man-configuration.xml rename to third_party/home-manager/docs/man-configuration.xml diff --git a/third_party/home-manager/doc/man-home-manager.xml b/third_party/home-manager/docs/man-home-manager.xml similarity index 95% rename from third_party/home-manager/doc/man-home-manager.xml rename to third_party/home-manager/docs/man-home-manager.xml index 357f4d5e8f..9f53745035 100644 --- a/third_party/home-manager/doc/man-home-manager.xml +++ b/third_party/home-manager/docs/man-home-manager.xml @@ -139,6 +139,10 @@ --debug + + --impure + + --keep-failed @@ -155,6 +159,10 @@ --(no-)substitute + + --no-out-link + + @@ -488,6 +496,18 @@ + + + + + + + Passed on to + nix-build + 1 . + + + @@ -536,6 +556,19 @@ + + + + + + + Passed on to + nix-build + 1 + when running home-manager build. + + + diff --git a/third_party/home-manager/doc/man-pages.xml b/third_party/home-manager/docs/man-pages.xml similarity index 100% rename from third_party/home-manager/doc/man-pages.xml rename to third_party/home-manager/docs/man-pages.xml diff --git a/third_party/home-manager/doc/manual.xml b/third_party/home-manager/docs/manual.xml similarity index 95% rename from third_party/home-manager/doc/manual.xml rename to third_party/home-manager/docs/manual.xml index 3f21649fc6..812a72eba5 100644 --- a/third_party/home-manager/doc/manual.xml +++ b/third_party/home-manager/docs/manual.xml @@ -9,7 +9,7 @@ Preface - This manual will eventually describes how to install, use, and extend Home + This manual will eventually describe how to install, use, and extend Home Manager. diff --git a/third_party/home-manager/doc/release-notes/release-notes.adoc b/third_party/home-manager/docs/release-notes/release-notes.adoc similarity index 100% rename from third_party/home-manager/doc/release-notes/release-notes.adoc rename to third_party/home-manager/docs/release-notes/release-notes.adoc diff --git a/third_party/home-manager/doc/release-notes/rl-1809.adoc b/third_party/home-manager/docs/release-notes/rl-1809.adoc similarity index 100% rename from third_party/home-manager/doc/release-notes/rl-1809.adoc rename to third_party/home-manager/docs/release-notes/rl-1809.adoc diff --git a/third_party/home-manager/doc/release-notes/rl-1903.adoc b/third_party/home-manager/docs/release-notes/rl-1903.adoc similarity index 100% rename from third_party/home-manager/doc/release-notes/rl-1903.adoc rename to third_party/home-manager/docs/release-notes/rl-1903.adoc diff --git a/third_party/home-manager/doc/release-notes/rl-1909.adoc b/third_party/home-manager/docs/release-notes/rl-1909.adoc similarity index 100% rename from third_party/home-manager/doc/release-notes/rl-1909.adoc rename to third_party/home-manager/docs/release-notes/rl-1909.adoc diff --git a/third_party/home-manager/doc/release-notes/rl-2003.adoc b/third_party/home-manager/docs/release-notes/rl-2003.adoc similarity index 100% rename from third_party/home-manager/doc/release-notes/rl-2003.adoc rename to third_party/home-manager/docs/release-notes/rl-2003.adoc diff --git a/third_party/home-manager/doc/release-notes/rl-2009.adoc b/third_party/home-manager/docs/release-notes/rl-2009.adoc similarity index 100% rename from third_party/home-manager/doc/release-notes/rl-2009.adoc rename to third_party/home-manager/docs/release-notes/rl-2009.adoc diff --git a/third_party/home-manager/doc/release-notes/rl-2105.adoc b/third_party/home-manager/docs/release-notes/rl-2105.adoc similarity index 100% rename from third_party/home-manager/doc/release-notes/rl-2105.adoc rename to third_party/home-manager/docs/release-notes/rl-2105.adoc diff --git a/third_party/home-manager/docs/release-notes/rl-2111.adoc b/third_party/home-manager/docs/release-notes/rl-2111.adoc new file mode 100644 index 0000000000..ecd189956b --- /dev/null +++ b/third_party/home-manager/docs/release-notes/rl-2111.adoc @@ -0,0 +1,47 @@ +[[sec-release-21.11]] +== Release 21.11 + +This is the current unstable branch and the information in this +section is therefore not final. + +[[sec-release-21.11-highlights]] +=== Highlights + +This release has the following notable changes: + +* All Home Manager modules are now loaded on all platforms. With this +change you will get a more descriptive error message if you attempt to +enable a module that is incompatible with the host platform. ++ +Previously, modules that were platform specific would only be loaded +on that particular platform. For example, a module defining a +https://systemd.io/[systemd] service would only be loaded when the +host platform was Linux. This reduced evaluation times, simplified the +generated documentation, and made it impossible to accidentally use +modules that do not support the host platform. ++ +While the above benefits are quite nice, avoiding module loads also +brings a few problems. For example, the +https://nix-community.github.io/home-manager/[public documentation] +will only show the options available for Linux hosts and the +documentation cannot make references to options within modules that +are unavailable on some hosts. Finally, users who wish to use the same +configuration file for different platforms cannot do so, even if the +platform incompatible options are unused. ++ +Ultimately, the benefits of loading all modules won and the behavior +has now changed. For associated discussion see +https://github.com/nix-community/home-manager/issues/1906[issue #1906]. + +* Rofi version 1.7.0 removed many options that were used by the module and replaced them with custom themes, which are more flexible and powerful. ++ +You can replicate your old configuration by moving those options to <>. Keep in mind that the syntax is different so you may need to do some changes. + +[[sec-release-21.11-state-version-changes]] +=== State Version Changes + +The state version in this release includes the changes below. These +changes are only active if the `home.stateVersion` option is set to +"21.11" or later. + +* The <> option now defaults to `null`, meaning that Home Manager won't do any keyboard layout management. For example, `setxkbmap` won't be run in X sessions. diff --git a/third_party/home-manager/doc/writing-modules.adoc b/third_party/home-manager/docs/writing-modules.adoc similarity index 100% rename from third_party/home-manager/doc/writing-modules.adoc rename to third_party/home-manager/docs/writing-modules.adoc diff --git a/third_party/home-manager/flake.nix b/third_party/home-manager/flake.nix index 486562b4dc..3114798e23 100644 --- a/third_party/home-manager/flake.nix +++ b/third_party/home-manager/flake.nix @@ -18,9 +18,14 @@ darwinModules.home-manager = import ./nix-darwin; darwinModule = self.darwinModules.home-manager; - packages = forAllSystems (system: { - home-manager = nixpkgsFor.${system}.callPackage ./home-manager { }; - }); + packages = forAllSystems (system: + let docs = import ./docs { pkgs = nixpkgsFor.${system}; }; + in { + home-manager = nixpkgsFor.${system}.callPackage ./home-manager { }; + docs-html = docs.manual.html; + docs-manpages = docs.manPages; + docs-json = docs.options.json; + }); defaultPackage = forAllSystems (system: self.packages.${system}.home-manager); diff --git a/third_party/home-manager/format b/third_party/home-manager/format index 5682a1f293..0fa620c1ac 100755 --- a/third_party/home-manager/format +++ b/third_party/home-manager/format @@ -1,5 +1,5 @@ #! /usr/bin/env nix-shell -#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/05f0934825c2a0750d4888c4735f9420c906b388.tar.gz -i bash -p findutils nixfmt +#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/5edf5b60c3d8f82b5fc5e73e822b6f7460584945.tar.gz -i bash -p findutils nixfmt CHECK_ARG= @@ -12,12 +12,9 @@ case $1 in ;; esac -# The first block of excludes are files where nixfmt does a poor job, -# IMHO. The second block of excludes are files touched by open pull -# requests and we want to avoid merge conflicts. +# The excludes are for files touched by open pull requests and we want +# to avoid merge conflicts. find . -name '*.nix' \ - ! -path ./modules/programs/irssi.nix \ - \ ! -path ./home-manager/home-manager.nix \ ! -path ./modules/default.nix \ ! -path ./modules/files.nix \ @@ -26,25 +23,14 @@ find . -name '*.nix' \ ! -path ./modules/lib/file-type.nix \ ! -path ./modules/manual.nix \ ! -path ./modules/misc/news.nix \ - ! -path ./modules/misc/nixpkgs.nix \ - ! -path ./modules/misc/xdg.nix \ - ! -path ./modules/modules.nix \ ! -path ./modules/programs/bash.nix \ - ! -path ./modules/programs/firefox.nix \ ! -path ./modules/programs/gpg.nix \ ! -path ./modules/programs/ssh.nix \ - ! -path ./modules/programs/tmux.nix \ ! -path ./modules/programs/zsh.nix \ ! -path ./modules/services/gpg-agent.nix \ ! -path ./modules/services/mpd.nix \ - ! -path ./modules/services/sxhkd.nix \ - ! -path ./modules/systemd.nix \ ! -path ./nix-darwin/default.nix \ ! -path ./tests/default.nix \ ! -path ./tests/modules/home-environment/session-variables.nix \ ! -path ./tests/modules/programs/gpg/override-defaults.nix \ - ! -path ./tests/modules/programs/zsh/session-variables.nix \ - ! -path ./tests/modules/services/sxhkd/service.nix \ - ! -path ./tests/modules/systemd/services.nix \ - ! -path ./tests/modules/systemd/session-variables.nix \ -exec nixfmt $CHECK_ARG {} + diff --git a/third_party/home-manager/home-manager/completion.bash b/third_party/home-manager/home-manager/completion.bash index 9a470cc2cc..cf471d1293 100644 --- a/third_party/home-manager/home-manager/completion.bash +++ b/third_party/home-manager/home-manager/completion.bash @@ -290,8 +290,10 @@ _home-manager_completions () #--------------------------# local Options - Options=( "-f" "--file" "-b" "-A" "-I" "-h" "--help" "-n" "--dry-run" "-v" "--verbose" \ - "--cores" "--debug" "--keep-failed" "--keep-going" "-j" "--max-jobs" "--no-substitute" "--show-trace" "--substitute") + Options=( "-f" "--file" "-b" "-A" "-I" "-h" "--help" "-n" "--dry-run" "-v" \ + "--verbose" "--cores" "--debug" "--impure" "--keep-failed" \ + "--keep-going" "-j" "--max-jobs" "--no-substitute" "--no-out-link" \ + "--show-trace" "--substitute" "--builders") # ^ « home-manager »'s options. diff --git a/third_party/home-manager/home-manager/completion.fish b/third_party/home-manager/home-manager/completion.fish new file mode 100644 index 0000000000..ad38d276c6 --- /dev/null +++ b/third_party/home-manager/home-manager/completion.fish @@ -0,0 +1,65 @@ +#!/bin/env fish +################################################## + +# « home-manager » command-line fish completion +# +# © 2021 "Ariel AxionL" +# +# MIT License +# + +################################################## + +### Functions +function __home_manager_generations --description "Get all generations" + for i in (home-manager generations) + set -l split (string split " " $i) + set -l gen_id $split[5] + set -l gen_datetime $split[1..2] + set -l gen_hash (string match -r '\w{32}' $i) + echo $gen_id\t$gen_datetime $gen_hash + end +end + + +### SubCommands +complete -c home-manager -n "__fish_use_subcommand" -f -a "help" -d "Print home-manager help" +complete -c home-manager -n "__fish_use_subcommand" -f -a "edit" -d "Open the home configuration in $EDITOR" +complete -c home-manager -n "__fish_use_subcommand" -f -a "option" -d "Inspect configuration option" +complete -c home-manager -n "__fish_use_subcommand" -f -a "build" -d "Build configuration into result directory" +complete -c home-manager -n "__fish_use_subcommand" -f -a "instantiate" -d "Instantiate the configuration and print the resulting derivation" +complete -c home-manager -n "__fish_use_subcommand" -f -a "switch" -d "Build and activate configuration" +complete -c home-manager -n "__fish_use_subcommand" -f -a "generations" -d "List all home environment generations" +complete -c home-manager -n "__fish_use_subcommand" -f -a "packages" -d "List all packages installed in home-manager-path" +complete -c home-manager -n "__fish_use_subcommand" -f -a "news" -d "Show news entries in a pager" +complete -c home-manager -n "__fish_use_subcommand" -f -a "uninstall" -d "Remove Home Manager" + +complete -c home-manager -n "__fish_use_subcommand" -x -a "remove-generations" -d "Remove indicated generations" +complete -c home-manager -n "__fish_seen_subcommand_from remove-generations" -f -ka '(__home_manager_generations)' + +complete -c home-manager -n "__fish_use_subcommand" -x -a "expire-generations" -d "Remove generations older than TIMESTAMP" + +### Options +complete -c home-manager -F -s f -l "file" -d "The home configuration file" +complete -c home-manager -x -s A -d "Select an expression in the configuration file" +complete -c home-manager -F -s I -d "Add a path to the Nix expression search path" +complete -c home-manager -F -l "flake" -d "Use home-manager configuration at specified flake-uri" +complete -c home-manager -F -s b -d "Move existing files to new path rather than fail" +complete -c home-manager -f -s v -l "verbose" -d "Verbose output" +complete -c home-manager -f -s n -l "dry-run" -d "Do a dry run, only prints what actions would be taken" +complete -c home-manager -f -s h -l "help" -d "Print this help" + +complete -c home-manager -x -l "arg" -d "Override inputs passed to home-manager.nix" +complete -c home-manager -x -l "argstr" -d "Like --arg but the value is a string" +complete -c home-manager -x -l "cores" -d "Threads per job (e.g. -j argument to make)" +complete -c home-manager -x -l "debug" +complete -c home-manager -x -l "impure" +complete -c home-manager -f -l "keep-failed" -d "Keep temporary directory used by failed builds" +complete -c home-manager -f -l "keep-going" -d "Keep going in case of failed builds" +complete -c home-manager -x -s j -l "max-jobs" -d "Max number of build jobs in parallel" +complete -c home-manager -x -l "option" -d "Set Nix configuration option" +complete -c home-manager -x -l "builders" -d "Remote builders" +complete -c home-manager -f -l "show-trace" -d "Print stack trace of evaluation errors" +complete -c home-manager -f -l "substitute" +complete -c home-manager -f -l "no-substitute" +complete -c home-manager -f -l "no-out-link" diff --git a/third_party/home-manager/home-manager/completion.zsh b/third_party/home-manager/home-manager/completion.zsh index 9d346851b4..d0f0e2591f 100644 --- a/third_party/home-manager/home-manager/completion.zsh +++ b/third_party/home-manager/home-manager/completion.zsh @@ -8,6 +8,7 @@ _arguments \ '-b[backup files]:EXT:()' \ '--cores[cores]:NUM:()' \ '--debug[debug]' \ + '--impure[impure]' \ '--keep-failed[keep failed]' \ '--keep-going[keep going]' \ '(-h --help)'{--help,-h}'[help]' \ @@ -16,6 +17,7 @@ _arguments \ '(-f --file)'{--file,-f}'[configuration file]:FILE:_files' \ '(-j --max-jobs)'{--max-jobs,-j}'[max jobs]:NUM:()' \ '--option[option]:NAME VALUE:()' \ + '--builders[builders]:SPEC:()' \ '--show-trace[show trace]' \ '1: :->cmds' \ '*:: :->args' && ret=0 @@ -45,13 +47,16 @@ case "$state" in _arguments \ '--cores[cores]:NUM:()' \ '--debug[debug]' \ + '--impure[impure]' \ '--keep-failed[keep failed]' \ '--keep-going[keep going]' \ '--max-jobs[max jobs]:NUM:()' \ + '--no-out-link[no out link]' \ '--no-substitute[no substitute]' \ '--option[option]:NAME VALUE:()' \ '--show-trace[show trace]' \ - '--substitute[substitute]' + '--substitute[substitute]' \ + '--builders[builders]:SPEC:()' ;; esac esac diff --git a/third_party/home-manager/home-manager/default.nix b/third_party/home-manager/home-manager/default.nix index ecdea9e7bd..1c5ab5d81f 100644 --- a/third_party/home-manager/home-manager/default.nix +++ b/third_party/home-manager/home-manager/default.nix @@ -11,8 +11,8 @@ let pathStr = if path == null then "" else path; - nixos-option = - callPackage (pkgs.path + "/nixos/modules/installer/tools/nixos-option") { }; + nixos-option = pkgs.nixos-option or (callPackage + (pkgs.path + "/nixos/modules/installer/tools/nixos-option") { }); in runCommand "home-manager" { preferLocalBuild = true; @@ -39,4 +39,6 @@ in runCommand "home-manager" { $out/share/bash-completion/completions/home-manager install -D -m755 ${./completion.zsh} \ $out/share/zsh/site-functions/_home-manager + install -D -m755 ${./completion.fish} \ + $out/share/fish/vendor_completions.d/home-manager.fish '' diff --git a/third_party/home-manager/home-manager/home-manager b/third_party/home-manager/home-manager/home-manager index de521242ee..e474141719 100644 --- a/third_party/home-manager/home-manager/home-manager +++ b/third_party/home-manager/home-manager/home-manager @@ -252,6 +252,7 @@ function doBuild() { nix build \ "${PASSTHROUGH_OPTS[@]}" \ ${DRY_RUN+--dry-run} \ + ${NO_OUT_LINK+--no-link} \ "$FLAKE_CONFIG_URI.activationPackage" \ || exitCode=1 return $exitCode @@ -263,8 +264,9 @@ function doBuild() { newsInfo=$(buildNews) local exitCode - - doBuildAttr --attr activationPackage \ + doBuildAttr \ + ${NO_OUT_LINK+--no-out-link} \ + --attr activationPackage \ && exitCode=0 || exitCode=1 presentNews "$newsInfo" @@ -514,12 +516,15 @@ function doHelp() { echo " --arg(str) NAME VALUE Override inputs passed to home-manager.nix" echo " --cores NUM" echo " --debug" + echo " --impure" echo " --keep-failed" echo " --keep-going" echo " -j, --max-jobs NUM" echo " --option NAME VALUE" echo " --show-trace" echo " --(no-)substitute" + echo " --no-out-link Do not create a symlink to the output path" + echo " --builders VALUE" echo echo "Commands" echo @@ -601,6 +606,9 @@ while [[ $# -gt 0 ]]; do PASSTHROUGH_OPTS+=("$opt" "$1" "$2") shift 2 ;; + --no-out-link) + NO_OUT_LINK=1 + ;; -h|--help) doHelp exit 0 @@ -612,12 +620,12 @@ while [[ $# -gt 0 ]]; do PASSTHROUGH_OPTS+=("$opt" "$1" "$2") shift 2 ;; - -j|--max-jobs|--cores) + -j|--max-jobs|--cores|--builders) PASSTHROUGH_OPTS+=("$opt" "$1") shift ;; --debug|--keep-failed|--keep-going|--show-trace\ - |--substitute|--no-substitute) + |--substitute|--no-substitute|--impure) PASSTHROUGH_OPTS+=("$opt") ;; -v|--verbose) @@ -695,3 +703,5 @@ case $COMMAND in exit 1 ;; esac + +# vim: ft=bash diff --git a/third_party/home-manager/home-manager/home-manager.nix b/third_party/home-manager/home-manager/home-manager.nix index 04c2d28d32..a113d1d820 100644 --- a/third_party/home-manager/home-manager/home-manager.nix +++ b/third_party/home-manager/home-manager/home-manager.nix @@ -5,9 +5,10 @@ , newsReadIdsFile ? null }: -with pkgs.lib; - let + inherit (pkgs.lib) + concatMapStringsSep fileContents filter length optionalString removeSuffix + replaceStrings splitString; env = import ../modules { configuration = diff --git a/third_party/home-manager/home-manager/install.nix b/third_party/home-manager/home-manager/install.nix index 2c1685389a..e707c57332 100644 --- a/third_party/home-manager/home-manager/install.nix +++ b/third_party/home-manager/home-manager/install.nix @@ -23,6 +23,9 @@ runCommand "home-manager-install" { if [[ -v XDG_DATA_HOME && $XDG_DATA_HOME != "$HOME/.local/share" ]]; then xdgVars="$xdgVars xdg.dataHome = \"$XDG_DATA_HOME\";$nl" fi + if [[ -v XDG_STATE_HOME && $XDG_STATE_HOME != "$HOME/.local/state" ]]; then + xdgVars="$xdgVars xdg.stateHome = \"$XDG_STATE_HOME\";$nl" + fi mkdir -p "$(dirname "$confFile")" cat > $confFile < to move automatically." + errorEcho "Please move the above files and try again or use 'home-manager switch -b backup' to back up existing files automatically." exit 1 fi ''; @@ -169,11 +175,19 @@ in relativePath="''${sourcePath#$newGenFiles/}" targetPath="$HOME/$relativePath" if [[ -e "$targetPath" && ! -L "$targetPath" && -n "$HOME_MANAGER_BACKUP_EXT" ]] ; then + # The target exists, back it up backup="$targetPath.$HOME_MANAGER_BACKUP_EXT" $DRY_RUN_CMD mv $VERBOSE_ARG "$targetPath" "$backup" || errorEcho "Moving '$targetPath' failed!" fi - $DRY_RUN_CMD mkdir -p $VERBOSE_ARG "$(dirname "$targetPath")" - $DRY_RUN_CMD ln -nsf $VERBOSE_ARG "$sourcePath" "$targetPath" + + if [[ -e "$targetPath" && ! -L "$targetPath" ]] && cmp -s "$sourcePath" "$targetPath" ; then + # The target exists but is identical – don't do anything. + $VERBOSE_ECHO "Skipping '$targetPath' as it is identical to '$sourcePath'" + else + # Place that symlink, --force + $DRY_RUN_CMD mkdir -p $VERBOSE_ARG "$(dirname "$targetPath")" + $DRY_RUN_CMD ln -nsf $VERBOSE_ARG "$sourcePath" "$targetPath" + fi done ''; @@ -284,8 +298,13 @@ in home.activation.onFilesChange = hm.dag.entryAfter ["linkGeneration"] ( concatMapStrings (v: '' - if [[ ''${changedFiles[${escapeShellArg v.target}]} -eq 1 ]]; then - ${v.onChange} + if (( ''${changedFiles[${escapeShellArg v.target}]} == 1 )); then + if [[ -v DRY_RUN || -v VERBOSE ]]; then + echo "Running onChange hook for" ${escapeShellArg v.target} + fi + if [[ ! -v DRY_RUN ]]; then + ${v.onChange} + fi fi '') (filter (v: v.onChange != "") (attrValues cfg)) ); diff --git a/third_party/home-manager/modules/home-environment.nix b/third_party/home-manager/modules/home-environment.nix index 872fcd8ff5..b3e904e5b4 100644 --- a/third_party/home-manager/modules/home-environment.nix +++ b/third_party/home-manager/modules/home-environment.nix @@ -4,6 +4,8 @@ with lib; let + inherit (config.home) stateVersion; + cfg = config.home; languageSubModule = types.submodule { @@ -115,7 +117,7 @@ let if versionAtLeast config.home.stateVersion "19.09" then null else "us"; - defaultText = literalExample "null"; + defaultText = literalExpression "null"; description = '' Keyboard layout. If null, then the system configuration will be used. @@ -149,7 +151,7 @@ let if versionAtLeast config.home.stateVersion "19.09" then null else ""; - defaultText = literalExample "null"; + defaultText = literalExpression "null"; example = "colemak"; description = '' X keyboard variant. If null, then the @@ -182,7 +184,7 @@ in options = { home.username = mkOption { type = types.str; - defaultText = literalExample '' + defaultText = literalExpression '' "$USER" for state version < 20.09, undefined for state version ≥ 20.09 ''; @@ -192,7 +194,7 @@ in home.homeDirectory = mkOption { type = types.path; - defaultText = literalExample '' + defaultText = literalExpression '' "$HOME" for state version < 20.09, undefined for state version ≥ 20.09 ''; @@ -220,7 +222,11 @@ in home.keyboard = mkOption { type = types.nullOr keyboardSubModule; - default = {}; + default = if versionAtLeast stateVersion "21.11" then null else { }; + defaultText = literalExpression '' + "{ }" for state version < 21.11, + "null" for state version ≥ 21.11 + ''; description = '' Keyboard configuration. Set to null to disable Home Manager keyboard management. @@ -268,11 +274,21 @@ in type = with types; listOf str; default = [ ]; example = [ - ".git/safe/../../bin" + "$HOME/.local/bin" "\${xdg.configHome}/emacs/bin" - "~/.local/bin" + ".git/safe/../../bin" ]; - description = "Extra directories to add to PATH."; + description = '' + Extra directories to add to PATH. + + + + These directories are added to the PATH variable in a + double-quoted context, so expressions like $HOME are + expanded by the shell. However, since expressions like ~ or + * are escaped, they will end up in the PATH + verbatim. + ''; }; home.sessionVariablesExtra = mkOption { @@ -321,7 +337,7 @@ in home.activation = mkOption { type = hm.types.dagOf types.str; default = {}; - example = literalExample '' + example = literalExpression '' { myActivationAction = lib.hm.dag.entryAfter ["writeBoundary"] ''' $DRY_RUN_CMD ln -s $VERBOSE_ARG \ @@ -373,6 +389,16 @@ in description = "The package containing the complete activation script."; }; + home.extraActivationPath = mkOption { + internal = true; + type = types.listOf types.package; + default = [ ]; + description = '' + Extra packages to add to PATH within the activation + script. + ''; + }; + home.extraBuilderCommands = mkOption { type = types.lines; default = ""; @@ -570,15 +596,17 @@ in # Programs that always should be available on the activation # script's PATH. - activationBinPaths = lib.makeBinPath [ - pkgs.bash - pkgs.coreutils - pkgs.diffutils # For `cmp` and `diff`. - pkgs.findutils - pkgs.gnugrep - pkgs.gnused - pkgs.ncurses # For `tput`. - ] + activationBinPaths = lib.makeBinPath ( + [ + pkgs.bash + pkgs.coreutils + pkgs.diffutils # For `cmp` and `diff`. + pkgs.findutils + pkgs.gnugrep + pkgs.gnused + pkgs.ncurses # For `tput`. + ] ++ config.home.extraActivationPath + ) + optionalString (!cfg.emptyActivationPath) "\${PATH:+:}$PATH"; activationScript = pkgs.writeShellScript "activation-script" '' diff --git a/third_party/home-manager/modules/i18n/input-method/default.nix b/third_party/home-manager/modules/i18n/input-method/default.nix index 0abfec179c..27b3ae86dd 100644 --- a/third_party/home-manager/modules/i18n/input-method/default.nix +++ b/third_party/home-manager/modules/i18n/input-method/default.nix @@ -95,6 +95,10 @@ in { }; config = mkIf (cfg.enabled != null) { + assertions = [ + (hm.assertions.assertPlatform "i18n.inputMethod" pkgs platforms.linux) + ]; + home.packages = [ cfg.package gtk2Cache gtk3Cache ]; }; diff --git a/third_party/home-manager/modules/i18n/input-method/fcitx.nix b/third_party/home-manager/modules/i18n/input-method/fcitx.nix index b04382a787..f7d1b41a94 100644 --- a/third_party/home-manager/modules/i18n/input-method/fcitx.nix +++ b/third_party/home-manager/modules/i18n/input-method/fcitx.nix @@ -17,7 +17,7 @@ in { engines = mkOption { type = with types; listOf fcitxEngine; default = [ ]; - example = literalExample "with pkgs.fcitx-engines; [ mozc hangul ]"; + example = literalExpression "with pkgs.fcitx-engines; [ mozc hangul ]"; description = let enginesDrv = filterAttrs (const isDerivation) pkgs.fcitx-engines; engines = concatStringsSep ", " diff --git a/third_party/home-manager/modules/i18n/input-method/fcitx5.nix b/third_party/home-manager/modules/i18n/input-method/fcitx5.nix index 29b0ed5580..9211d0b7ef 100644 --- a/third_party/home-manager/modules/i18n/input-method/fcitx5.nix +++ b/third_party/home-manager/modules/i18n/input-method/fcitx5.nix @@ -12,7 +12,7 @@ in { addons = mkOption { type = with types; listOf package; default = [ ]; - example = literalExample "with pkgs; [ fcitx5-rime ]"; + example = literalExpression "with pkgs; [ fcitx5-rime ]"; description = '' Enabled Fcitx5 addons. ''; diff --git a/third_party/home-manager/modules/i18n/input-method/kime.nix b/third_party/home-manager/modules/i18n/input-method/kime.nix index b948a99d41..4a84768e72 100644 --- a/third_party/home-manager/modules/i18n/input-method/kime.nix +++ b/third_party/home-manager/modules/i18n/input-method/kime.nix @@ -9,7 +9,7 @@ in { config = mkOption { type = yamlFormat.type; default = { }; - example = literalExample '' + example = literalExpression '' { daemon = { modules = ["Xim" "Indicator"]; diff --git a/third_party/home-manager/modules/lib-bash/activation-init.sh b/third_party/home-manager/modules/lib-bash/activation-init.sh index f95008ee75..eb2dc1ec97 100755 --- a/third_party/home-manager/modules/lib-bash/activation-init.sh +++ b/third_party/home-manager/modules/lib-bash/activation-init.sh @@ -5,9 +5,9 @@ function setupVars() { local profilesPath="$nixStateDir/profiles/per-user/$USER" local gcPath="$nixStateDir/gcroots/per-user/$USER" - genProfilePath="$profilesPath/home-manager" - newGenPath="@GENERATION_DIR@"; - newGenGcPath="$gcPath/current-home" + declare -gr genProfilePath="$profilesPath/home-manager" + declare -gr newGenPath="@GENERATION_DIR@"; + declare -gr newGenGcPath="$gcPath/current-home" local greatestGenNum greatestGenNum=$( \ @@ -16,14 +16,15 @@ function setupVars() { | sed -E 's/ *([[:digit:]]+) .*/\1/') if [[ -n $greatestGenNum ]] ; then - oldGenNum=$greatestGenNum - newGenNum=$((oldGenNum + 1)) + declare -gr oldGenNum=$greatestGenNum + declare -gr newGenNum=$((oldGenNum + 1)) else - newGenNum=1 + declare -gr newGenNum=1 fi if [[ -e $profilesPath/home-manager ]] ; then oldGenPath="$(readlink -e "$profilesPath/home-manager")" + declare -gr oldGenPath fi $VERBOSE_ECHO "Sanity checking oldGenNum and oldGenPath" diff --git a/third_party/home-manager/modules/lib/assertions.nix b/third_party/home-manager/modules/lib/assertions.nix new file mode 100644 index 0000000000..1089c27b85 --- /dev/null +++ b/third_party/home-manager/modules/lib/assertions.nix @@ -0,0 +1,14 @@ +{ lib }: + +{ + assertPlatform = module: pkgs: platforms: { + assertion = lib.elem pkgs.stdenv.hostPlatform.system platforms; + message = let + platformsStr = lib.concatStringsSep "\n" + (map (p: " - ${p}") (lib.sort (a: b: a < b) platforms)); + in '' + The module ${module} does not support your platform. It only supports + + ${platformsStr}''; + }; +} diff --git a/third_party/home-manager/modules/lib/dag.nix b/third_party/home-manager/modules/lib/dag.nix index cbe3412965..0c0e33ee76 100644 --- a/third_party/home-manager/modules/lib/dag.nix +++ b/third_party/home-manager/modules/lib/dag.nix @@ -9,9 +9,8 @@ { lib }: -with lib; - -rec { +let inherit (lib) all any filterAttrs mapAttrs mapAttrsToList toposort; +in rec { emptyDag = { }; diff --git a/third_party/home-manager/modules/lib/default.nix b/third_party/home-manager/modules/lib/default.nix index 7c2c72f709..c087c81097 100644 --- a/third_party/home-manager/modules/lib/default.nix +++ b/third_party/home-manager/modules/lib/default.nix @@ -16,6 +16,8 @@ rec { entryBefore = d.dagEntryBefore; }; + assertions = import ./assertions.nix { inherit lib; }; + gvariant = import ./gvariant.nix { inherit lib; }; maintainers = import ./maintainers.nix; strings = import ./strings.nix { inherit lib; }; diff --git a/third_party/home-manager/modules/lib/file-type.nix b/third_party/home-manager/modules/lib/file-type.nix index 71babc79aa..0b30cb1b69 100644 --- a/third_party/home-manager/modules/lib/file-type.nix +++ b/third_party/home-manager/modules/lib/file-type.nix @@ -1,7 +1,8 @@ { homeDirectory, lib, pkgs }: -with lib; - +let + inherit (lib) hasPrefix hm literalExpression mkDefault mkIf mkOption removePrefix types; +in { # Constructs a type suitable for a `home.file` like option. The # target path may be either absolute or relative, in which case it @@ -21,7 +22,7 @@ with lib; absPath = if hasPrefix "/" p then p else "${basePath}/${p}"; in removePrefix (homeDirectory + "/") absPath; - defaultText = literalExample ""; + defaultText = literalExpression ""; description = '' Path to target file relative to ${basePathDesc}. ''; diff --git a/third_party/home-manager/modules/lib/gvariant.nix b/third_party/home-manager/modules/lib/gvariant.nix index 92aa7d9837..7c4ca5b08c 100644 --- a/third_party/home-manager/modules/lib/gvariant.nix +++ b/third_party/home-manager/modules/lib/gvariant.nix @@ -5,9 +5,9 @@ { lib }: -with lib; - let + inherit (lib) + concatMapStringsSep concatStrings escape hasPrefix head replaceStrings; mkPrimitive = t: v: { _type = "gvariant"; @@ -71,6 +71,8 @@ in rec { inherit type typeOf; + isGVariant = v: v._type or "" == "gvariant"; + isArray = hasPrefix "a"; isMaybe = hasPrefix "m"; isTuple = hasPrefix "("; @@ -122,8 +124,9 @@ in rec { }; mkString = v: - mkPrimitive type.string v // { - __toString = self: "'${escape [ "'" "\\" ] self.value}'"; + let sanitize = s: replaceStrings [ "\n" ] [ "\\n" ] (escape [ "'" "\\" ] s); + in mkPrimitive type.string v // { + __toString = self: "'${sanitize self.value}'"; }; mkObjectpath = v: diff --git a/third_party/home-manager/modules/lib/maintainers.nix b/third_party/home-manager/modules/lib/maintainers.nix index d091b28a46..dba4d5e304 100644 --- a/third_party/home-manager/modules/lib/maintainers.nix +++ b/third_party/home-manager/modules/lib/maintainers.nix @@ -75,12 +75,6 @@ fingerprint = "F0E0 0311 126A CD72 4392 25E6 68BF 2EAE 6D91 CAFF"; }]; }; - thiagokokada = { - email = "thiagokokada@gmail.com"; - name = "Thiago Kenji Okada"; - github = "thiagokokada"; - githubId = 844343; - }; fendse = { email = "46252070+Fendse@users.noreply.github.com"; github = "Fendse"; @@ -115,4 +109,28 @@ githubId = 56614642; name = "Ilan Joselevich"; }; + mager = { + email = "andreas@mager.eu"; + github = "AndreasMager"; + githubId = 5646732; + name = "Andreas Mager"; + }; + bjpbakker = { + email = "bart@thesoftwarecraft.com"; + github = "bjpbakker"; + githubId = 605641; + name = "Bart Bakker"; + }; + jrobsonchase = { + email = "josh@robsonchase.com"; + github = "jrobsonchase"; + githubId = 1553581; + name = "Josh Robson Chase"; + }; + hawkw = { + name = "Eliza Weisman"; + email = "eliza@elizas.website"; + github = "hawkw"; + githubId = 2796466; + }; } diff --git a/third_party/home-manager/modules/lib/stdlib-extended.nix b/third_party/home-manager/modules/lib/stdlib-extended.nix index 93f2397cee..3c4e032aa9 100644 --- a/third_party/home-manager/modules/lib/stdlib-extended.nix +++ b/third_party/home-manager/modules/lib/stdlib-extended.nix @@ -4,4 +4,10 @@ nixpkgsLib: let mkHmLib = import ./.; -in nixpkgsLib.extend (self: super: { hm = mkHmLib { lib = super; }; }) +in nixpkgsLib.extend (self: super: { + hm = mkHmLib { lib = self; }; + + # For forward compatibility. + literalExpression = super.literalExpression or super.literalExample; + literalDocBook = super.literalDocBook or super.literalExample; +}) diff --git a/third_party/home-manager/modules/lib/strings.nix b/third_party/home-manager/modules/lib/strings.nix index fe7b2fa306..f59d815080 100644 --- a/third_party/home-manager/modules/lib/strings.nix +++ b/third_party/home-manager/modules/lib/strings.nix @@ -1,8 +1,9 @@ { lib }: -with lib; - -{ +let + inherit (lib) + genList length lowerChars replaceStrings stringToCharacters upperChars; +in { # Figures out a valid Nix store name for the given path. storeFileName = path: let diff --git a/third_party/home-manager/modules/lib/types-dag.nix b/third_party/home-manager/modules/lib/types-dag.nix index 2efb12645d..68a5826fec 100644 --- a/third_party/home-manager/modules/lib/types-dag.nix +++ b/third_party/home-manager/modules/lib/types-dag.nix @@ -1,8 +1,10 @@ { dag, lib }: -with lib; - let + inherit (lib) + concatStringsSep defaultFunctor fixedWidthNumber imap1 isAttrs isList length + listToAttrs mapAttrs mkIf mkOption mkOptionType nameValuePair stringLength + types warn; isDagEntry = e: isAttrs e && (e ? data) && (e ? after) && (e ? before); diff --git a/third_party/home-manager/modules/lib/types.nix b/third_party/home-manager/modules/lib/types.nix index a7d1dd2154..71ec587f1a 100644 --- a/third_party/home-manager/modules/lib/types.nix +++ b/third_party/home-manager/modules/lib/types.nix @@ -1,9 +1,11 @@ { lib, dag ? import ./dag.nix { inherit lib; } , gvariant ? import ./gvariant.nix { inherit lib; } }: -with lib; - let + inherit (lib) + all concatMap foldl' getFiles getValues head isFunction literalExpression + mergeAttrs mergeDefaultOption mergeOneOption mergeOptions mkOption + mkOptionType showFiles showOption types; typesDag = import ./types-dag.nix { inherit dag lib; }; @@ -37,7 +39,7 @@ in rec { package = mkOption { type = types.nullOr types.package; default = null; - example = literalExample "pkgs.dejavu_fonts"; + example = literalExpression "pkgs.dejavu_fonts"; description = '' Package providing the font. This package will be installed to your profile. If null then the font @@ -70,7 +72,11 @@ in rec { check = v: gvar.mkValue v != null; merge = loc: defs: let - vdefs = map (d: d // { value = gvar.mkValue d.value; }) defs; + vdefs = map (d: + d // { + value = + if gvar.isGVariant d.value then d.value else gvar.mkValue d.value; + }) defs; vals = map (d: d.value) vdefs; defTypes = map (x: x.type) vals; sameOrNull = x: y: if x == y then y else null; @@ -82,8 +88,10 @@ in rec { + " mismatched GVariant types given in" + " ${showFiles (getFiles defs)}.") else if gvar.isArray sharedDefType && allChecked then - (types.listOf gvariant).merge loc - (map (d: d // { value = d.value.value; }) vdefs) + gvar.mkValue ((types.listOf gvariant).merge loc + (map (d: d // { value = d.value.value; }) vdefs)) // { + type = sharedDefType; + } else if gvar.isTuple sharedDefType && allChecked then mergeOneOption loc defs else if gvar.isMaybe sharedDefType && allChecked then diff --git a/third_party/home-manager/modules/manual.nix b/third_party/home-manager/modules/manual.nix index ab01c45003..a5c020510f 100644 --- a/third_party/home-manager/modules/manual.nix +++ b/third_party/home-manager/modules/manual.nix @@ -6,7 +6,7 @@ let cfg = config.manual; - docs = import ../doc { inherit lib pkgs; }; + docs = import ../docs { inherit lib pkgs; }; in diff --git a/third_party/home-manager/modules/misc/dconf.nix b/third_party/home-manager/modules/misc/dconf.nix index e8a04de0a3..7fed1ae279 100644 --- a/third_party/home-manager/modules/misc/dconf.nix +++ b/third_party/home-manager/modules/misc/dconf.nix @@ -27,7 +27,7 @@ in { settings = mkOption { type = with types; attrsOf (attrsOf hm.types.gvariant); default = { }; - example = literalExample '' + example = literalExpression '' { "org/gnome/calculator" = { button-mode = "programming"; diff --git a/third_party/home-manager/modules/misc/fontconfig.nix b/third_party/home-manager/modules/misc/fontconfig.nix index 795ab3a74f..756f45699d 100644 --- a/third_party/home-manager/modules/misc/fontconfig.nix +++ b/third_party/home-manager/modules/misc/fontconfig.nix @@ -36,22 +36,11 @@ in { }; config = mkIf cfg.enable { - # Create two dummy files in /lib/fontconfig to make sure that - # buildEnv creates a real directory path. These files are removed - # in home.extraProfileCommands below so the packages will not - # become "runtime" dependencies. home.packages = [ - (pkgs.writeTextFile { - name = "hm-dummy1"; - destination = "/lib/fontconfig/hm-dummy1"; - text = "dummy"; - }) - - (pkgs.writeTextFile { - name = "hm-dummy2"; - destination = "/lib/fontconfig/hm-dummy2"; - text = "dummy"; - }) + # Make sure that buildEnv creates a real directory path so that we avoid + # trying to write to a read-only location. + (pkgs.runCommandLocal "dummy-fc-dir1" { } "mkdir -p $out/lib/fontconfig") + (pkgs.runCommandLocal "dummy-fc-dir2" { } "mkdir -p $out/lib/fontconfig") ]; home.extraProfileCommands = '' @@ -76,9 +65,10 @@ in { unset FONTCONFIG_FILE fi - # Remove hacky dummy files. - rm $out/lib/fontconfig/hm-dummy? - rmdir --ignore-fail-on-non-empty -p $out/lib/fontconfig + # Remove the fontconfig directory if no files were available. + if [[ -d $out/lib/fontconfig ]] ; then + rmdir --ignore-fail-on-non-empty -p $out/lib/fontconfig + fi ''; xdg.configFile = { diff --git a/third_party/home-manager/modules/misc/gtk.nix b/third_party/home-manager/modules/misc/gtk.nix index db0a8e7a36..669329b7bf 100644 --- a/third_party/home-manager/modules/misc/gtk.nix +++ b/third_party/home-manager/modules/misc/gtk.nix @@ -33,7 +33,7 @@ let package = mkOption { type = types.nullOr types.package; default = null; - example = literalExample "pkgs.gnome.gnome_themes_standard"; + example = literalExpression "pkgs.gnome.gnome_themes_standard"; description = '' Package providing the theme. This package will be installed to your profile. If null then the theme @@ -97,9 +97,9 @@ in { type = types.path; default = "${config.home.homeDirectory}/.gtkrc-2.0"; defaultText = - literalExample ''"''${config.home.homeDirectory}/.gtkrc-2.0"''; + literalExpression ''"''${config.home.homeDirectory}/.gtkrc-2.0"''; example = - literalExample ''"''${config.xdg.configHome}/gtk-2.0/gtkrc"''; + literalExpression ''"''${config.xdg.configHome}/gtk-2.0/gtkrc"''; description = '' The location to put the GTK configuration file. ''; @@ -167,7 +167,7 @@ in { ++ optionalPackage cfg.iconTheme; home.file.${cfg2.configLocation}.text = - concatStringsSep "\n" (mapAttrsToList formatGtk2Option ini) + "\n" + concatMapStrings (l: l + "\n") (mapAttrsToList formatGtk2Option ini) + cfg2.extraConfig; home.sessionVariables.GTK2_RC_FILES = cfg2.configLocation; @@ -178,7 +178,7 @@ in { xdg.configFile."gtk-3.0/gtk.css".text = cfg3.extraCss; xdg.configFile."gtk-3.0/bookmarks" = mkIf (cfg3.bookmarks != [ ]) { - text = concatStringsSep "\n" cfg3.bookmarks; + text = concatMapStrings (l: l + "\n") cfg3.bookmarks; }; dconf.settings."org/gnome/desktop/interface" = dconfIni; diff --git a/third_party/home-manager/modules/misc/news.nix b/third_party/home-manager/modules/misc/news.nix index 6e88b62466..5bdb31f821 100644 --- a/third_party/home-manager/modules/misc/news.nix +++ b/third_party/home-manager/modules/misc/news.nix @@ -536,23 +536,6 @@ in ''; } - { - time = "2018-02-09T21:14:42+00:00"; - condition = with config.programs.rofi; enable && colors != null; - message = '' - The new and preferred way to configure the rofi theme is - using rasi themes through the 'programs.rofi.theme' option. - This option can take as value either the name of a - pre-installed theme or the path to a theme file. - - A rasi theme can be generated from an Xresources config - using 'rofi -dump-theme'. - - The option 'programs.rofi.colors' is still supported but may - become deprecated and removed in the future. - ''; - } - { time = "2018-02-19T21:45:26+00:00"; message = '' @@ -2118,6 +2101,138 @@ in A new module is available: 'programs.himalaya'. ''; } + + { + time = "2021-07-11T17:45:56+00:00"; + message = '' + A new module is available: 'programs.sm64ex'. + ''; + } + + { + time = "2021-07-15T13:38:32+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.xsettingsd'. + ''; + } + + { + time = "2021-07-14T20:06:18+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.volnoti'. + ''; + } + + { + time = "2021-07-23T22:22:31+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.trayer'. + ''; + } + + { + time = "2021-07-19T01:30:46+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.notify-osd'. + ''; + } + + { + time = "2021-08-10T21:28:40+00:00"; + message = '' + A new module is available: 'programs.java'. + ''; + } + + { + time = "2021-08-11T13:55:51+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.easyeffects'. + ''; + } + + { + time = "2021-08-16T21:59:02+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.git-sync'. + ''; + } + + { + time = "2021-08-26T06:40:59+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.fnott'. + ''; + } + + { + time = "2021-08-31T18:44:26+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.betterlockscreen'. + ''; + } + + { + time = "2021-09-14T21:31:03+00:00"; + message = '' + A new module is available: 'programs.bottom'. + ''; + } + + { + time = "2021-09-23T17:04:48+00:00"; + condition = hostPlatform.isLinux && config.services.screen-locker.enable; + message = '' + 'xautolock' is now optional in 'services.screen-locker', and the + 'services.screen-locker' options have been reorganized for clarity. + See the 'xautolock' and 'xss-lock' options modules in + 'services.screen-locker'. + ''; + } + + { + time = "2021-10-05T20:55:07+00:00"; + message = '' + A new module is available: 'programs.atuin'. + ''; + } + + { + time = "2021-10-05T22:15:00+00:00"; + message = '' + A new module is available: 'programs.nnn'. + ''; + } + + { + time = "2021-10-08T22:16:50+00:00"; + condition = hostPlatform.isLinux && config.programs.rofi.enable; + message = '' + Rofi version '1.7.0' removed many options that were used by the module + and replaced them with custom themes, which are more flexible and + powerful. + + You can replicate your old configuration by moving those options to + 'programs.rofi.theme'. Keep in mind that the syntax is different so + you may need to do some changes. + ''; + } + + { + time = "2021-10-23T17:12:22+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'programs.hexchat'. + ''; + } ]; }; } diff --git a/third_party/home-manager/modules/misc/nixpkgs-disabled.nix b/third_party/home-manager/modules/misc/nixpkgs-disabled.nix new file mode 100644 index 0000000000..ab0f35df7d --- /dev/null +++ b/third_party/home-manager/modules/misc/nixpkgs-disabled.nix @@ -0,0 +1,73 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.nixpkgs; + + # Copied from nixpkgs.nix. + isConfig = x: builtins.isAttrs x || builtins.isFunction x; + + # Copied from nixpkgs.nix. + optCall = f: x: if builtins.isFunction f then f x else f; + + # Copied from nixpkgs.nix. + mergeConfig = lhs_: rhs_: + let + lhs = optCall lhs_ { inherit pkgs; }; + rhs = optCall rhs_ { inherit pkgs; }; + in lhs // rhs // optionalAttrs (lhs ? packageOverrides) { + packageOverrides = pkgs: + optCall lhs.packageOverrides pkgs + // optCall (attrByPath [ "packageOverrides" ] ({ }) rhs) pkgs; + } // optionalAttrs (lhs ? perlPackageOverrides) { + perlPackageOverrides = pkgs: + optCall lhs.perlPackageOverrides pkgs + // optCall (attrByPath [ "perlPackageOverrides" ] ({ }) rhs) pkgs; + }; + + # Copied from nixpkgs.nix. + configType = mkOptionType { + name = "nixpkgs-config"; + description = "nixpkgs config"; + check = x: + let traceXIfNot = c: if c x then true else lib.traceSeqN 1 x false; + in traceXIfNot isConfig; + merge = args: fold (def: mergeConfig def.value) { }; + }; + + # Copied from nixpkgs.nix. + overlayType = mkOptionType { + name = "nixpkgs-overlay"; + description = "nixpkgs overlay"; + check = builtins.isFunction; + merge = lib.mergeOneOption; + }; + +in { + meta.maintainers = with maintainers; [ thiagokokada ]; + + options.nixpkgs = { + config = mkOption { + default = null; + type = types.nullOr configType; + visible = false; + }; + + overlays = mkOption { + default = null; + type = types.nullOr (types.listOf overlayType); + visible = false; + }; + }; + + config = { + assertions = [{ + assertion = cfg.config == null || cfg.overlays == null; + message = '' + `nixpkgs` options are disabled when `home-manager.useGlobalPkgs` is enabled. + ''; + }]; + }; +} diff --git a/third_party/home-manager/modules/misc/nixpkgs.nix b/third_party/home-manager/modules/misc/nixpkgs.nix index 511dbec10b..e4b931fb2a 100644 --- a/third_party/home-manager/modules/misc/nixpkgs.nix +++ b/third_party/home-manager/modules/misc/nixpkgs.nix @@ -6,40 +6,31 @@ with lib; let - isConfig = x: - builtins.isAttrs x || builtins.isFunction x; + isConfig = x: builtins.isAttrs x || builtins.isFunction x; - optCall = f: x: - if builtins.isFunction f - then f x - else f; + optCall = f: x: if builtins.isFunction f then f x else f; mergeConfig = lhs_: rhs_: let lhs = optCall lhs_ { inherit pkgs; }; rhs = optCall rhs_ { inherit pkgs; }; - in - lhs // rhs // - optionalAttrs (lhs ? packageOverrides) { + in lhs // rhs // optionalAttrs (lhs ? packageOverrides) { packageOverrides = pkgs: - optCall lhs.packageOverrides pkgs // - optCall (attrByPath ["packageOverrides"] ({}) rhs) pkgs; - } // - optionalAttrs (lhs ? perlPackageOverrides) { + optCall lhs.packageOverrides pkgs + // optCall (attrByPath [ "packageOverrides" ] ({ }) rhs) pkgs; + } // optionalAttrs (lhs ? perlPackageOverrides) { perlPackageOverrides = pkgs: - optCall lhs.perlPackageOverrides pkgs // - optCall (attrByPath ["perlPackageOverrides"] ({}) rhs) pkgs; + optCall lhs.perlPackageOverrides pkgs + // optCall (attrByPath [ "perlPackageOverrides" ] ({ }) rhs) pkgs; }; configType = mkOptionType { name = "nixpkgs-config"; description = "nixpkgs config"; check = x: - let traceXIfNot = c: - if c x then true - else lib.traceSeqN 1 x false; + let traceXIfNot = c: if c x then true else lib.traceSeqN 1 x false; in traceXIfNot isConfig; - merge = args: fold (def: mergeConfig def.value) {}; + merge = args: fold (def: mergeConfig def.value) { }; }; overlayType = mkOptionType { @@ -49,13 +40,9 @@ let merge = lib.mergeOneOption; }; - _pkgs = import pkgsPath ( - filterAttrs (n: v: v != null) config.nixpkgs - ); + _pkgs = import pkgsPath (filterAttrs (n: v: v != null) config.nixpkgs); -in - -{ +in { options.nixpkgs = { config = mkOption { default = null; @@ -91,17 +78,16 @@ in overlays = mkOption { default = null; - example = literalExample - '' - [ (self: super: { - openssh = super.openssh.override { - hpnSupport = true; - withKerberos = true; - kerberos = self.libkrb5; - }; + example = literalExpression '' + [ (self: super: { + openssh = super.openssh.override { + hpnSupport = true; + withKerberos = true; + kerberos = self.libkrb5; }; - ) ] - ''; + }; + ) ] + ''; type = types.nullOr (types.listOf overlayType); description = '' List of overlays to use with the Nix Packages collection. (For @@ -144,9 +130,10 @@ in _module.args = { pkgs = mkOverride modules.defaultPriority _pkgs; pkgs_i686 = - if _pkgs.stdenv.isLinux && _pkgs.stdenv.hostPlatform.isx86 - then _pkgs.pkgsi686Linux - else { }; + if _pkgs.stdenv.isLinux && _pkgs.stdenv.hostPlatform.isx86 then + _pkgs.pkgsi686Linux + else + { }; }; }; } diff --git a/third_party/home-manager/modules/misc/numlock.nix b/third_party/home-manager/modules/misc/numlock.nix index c823f6dbdd..88032417ff 100644 --- a/third_party/home-manager/modules/misc/numlock.nix +++ b/third_party/home-manager/modules/misc/numlock.nix @@ -12,6 +12,10 @@ in { options = { xsession.numlock.enable = mkEnableOption "Num Lock"; }; config = mkIf cfg.enable { + assertions = [ + (hm.assertions.assertPlatform "xsession.numlock" pkgs platforms.linux) + ]; + systemd.user.services.numlockx = { Unit = { Description = "NumLockX"; diff --git a/third_party/home-manager/modules/misc/qt.nix b/third_party/home-manager/modules/misc/qt.nix index 1fdaf9f9b9..313e79ee4c 100644 --- a/third_party/home-manager/modules/misc/qt.nix +++ b/third_party/home-manager/modules/misc/qt.nix @@ -78,7 +78,7 @@ in { package = mkOption { type = types.nullOr types.package; default = null; - example = literalExample "pkgs.adwaita-qt"; + example = literalExpression "pkgs.adwaita-qt"; description = "Theme package to be used in Qt5 applications."; }; }; diff --git a/third_party/home-manager/modules/misc/tmpfiles.nix b/third_party/home-manager/modules/misc/tmpfiles.nix index c46fe2c553..248843029f 100644 --- a/third_party/home-manager/modules/misc/tmpfiles.nix +++ b/third_party/home-manager/modules/misc/tmpfiles.nix @@ -25,6 +25,11 @@ in { }; config = mkIf (cfg.rules != [ ]) { + assertions = [ + (hm.assertions.assertPlatform "systemd.user.tmpfiles" pkgs + platforms.linux) + ]; + xdg = { dataFile."user-tmpfiles.d/home-manager.conf" = { text = '' diff --git a/third_party/home-manager/modules/misc/xdg-desktop-entries.nix b/third_party/home-manager/modules/misc/xdg-desktop-entries.nix index 382d6c2b56..6e8393c2a6 100644 --- a/third_party/home-manager/modules/misc/xdg-desktop-entries.nix +++ b/third_party/home-manager/modules/misc/xdg-desktop-entries.nix @@ -105,7 +105,7 @@ let This may override other values. ''; default = { }; - example = literalExample '' + example = literalExpression '' { Keywords = "calc;math"; DBusActivatable = "false"; @@ -157,7 +157,7 @@ in { ''; default = { }; type = types.attrsOf (types.submodule desktopEntry); - example = literalExample '' + example = literalExpression '' { firefox = { name = "Firefox"; @@ -171,8 +171,13 @@ in { ''; }; - config.home.packages = mkIf (config.xdg.desktopEntries != { }) - (map hiPrio # we need hiPrio to override existing entries + config = mkIf (config.xdg.desktopEntries != { }) { + assertions = [ + (hm.assertions.assertPlatform "xdg.desktopEntries" pkgs platforms.linux) + ]; + + home.packages = (map hiPrio # we need hiPrio to override existing entries (attrsets.mapAttrsToList makeFile config.xdg.desktopEntries)); + }; } diff --git a/third_party/home-manager/modules/misc/xdg-mime-apps.nix b/third_party/home-manager/modules/misc/xdg-mime-apps.nix index 81d2ba0fcb..5372c6259f 100644 --- a/third_party/home-manager/modules/misc/xdg-mime-apps.nix +++ b/third_party/home-manager/modules/misc/xdg-mime-apps.nix @@ -30,7 +30,7 @@ in { associations.added = mkOption { type = types.attrsOf strListOrSingleton; default = { }; - example = literalExample '' + example = literalExpression '' { "mimetype1" = [ "foo1.desktop" "foo2.desktop" "foo3.desktop" ]; "mimetype2" = "foo4.desktop"; @@ -57,7 +57,7 @@ in { defaultApplications = mkOption { type = types.attrsOf strListOrSingleton; default = { }; - example = literalExample '' + example = literalExpression '' { "mimetype1" = [ "default1.desktop" "default2.desktop" ]; } @@ -73,6 +73,9 @@ in { }; config = mkIf cfg.enable { + assertions = + [ (hm.assertions.assertPlatform "xdg.mimeApps" pkgs platforms.linux) ]; + # Deprecated but still used by some applications. xdg.dataFile."applications/mimeapps.list".source = config.xdg.configFile."mimeapps.list".source; diff --git a/third_party/home-manager/modules/misc/xdg-mime.nix b/third_party/home-manager/modules/misc/xdg-mime.nix index 5999e1299c..fa7cdbc766 100644 --- a/third_party/home-manager/modules/misc/xdg-mime.nix +++ b/third_party/home-manager/modules/misc/xdg-mime.nix @@ -10,7 +10,9 @@ in { options = { xdg.mime.enable = mkOption { type = types.bool; - default = true; + default = pkgs.hostPlatform.isLinux; + defaultText = + literalExpression "true if host platform is Linux, false otherwise"; description = '' Whether to install programs and files to support the XDG Shared MIME-info specification and XDG MIME Applications @@ -24,6 +26,9 @@ in { }; config = mkIf config.xdg.mime.enable { + assertions = + [ (hm.assertions.assertPlatform "xdg.mime" pkgs platforms.linux) ]; + home.packages = [ # Explicitly install package to provide basic mime types. pkgs.shared-mime-info diff --git a/third_party/home-manager/modules/misc/xdg-system-dirs.nix b/third_party/home-manager/modules/misc/xdg-system-dirs.nix index f79ebc55bc..989131c5fa 100644 --- a/third_party/home-manager/modules/misc/xdg-system-dirs.nix +++ b/third_party/home-manager/modules/misc/xdg-system-dirs.nix @@ -17,7 +17,7 @@ in { config = mkOption { type = types.listOf types.str; default = [ ]; - example = literalExample ''[ "/etc/xdg" ]''; + example = literalExpression ''[ "/etc/xdg" ]''; description = '' Directory names to add to XDG_CONFIG_DIRS in the user session. @@ -27,7 +27,7 @@ in { data = mkOption { type = types.listOf types.str; default = [ ]; - example = literalExample ''[ "/usr/share" "/usr/local/share" ]''; + example = literalExpression ''[ "/usr/share" "/usr/local/share" ]''; description = '' Directory names to add to XDG_DATA_DIRS in the user session. @@ -36,6 +36,12 @@ in { }; config = mkMerge [ + (mkIf (cfg.config != [ ] || cfg.data != [ ]) { + assertions = [ + (hm.assertions.assertPlatform "xdg.systemDirs" pkgs platforms.linux) + ]; + }) + (mkIf (cfg.config != [ ]) { home.sessionVariables.XDG_CONFIG_DIRS = "${configDirs}\${XDG_CONFIG_DIRS:+:$XDG_CONFIG_DIRS}"; diff --git a/third_party/home-manager/modules/misc/xdg-user-dirs.nix b/third_party/home-manager/modules/misc/xdg-user-dirs.nix index 6694b52d76..78d350cdec 100644 --- a/third_party/home-manager/modules/misc/xdg-user-dirs.nix +++ b/third_party/home-manager/modules/misc/xdg-user-dirs.nix @@ -103,6 +103,9 @@ in { XDG_VIDEOS_DIR = cfg.videos; } // cfg.extraConfig; in mkIf cfg.enable { + assertions = + [ (hm.assertions.assertPlatform "xdg.userDirs" pkgs platforms.linux) ]; + xdg.configFile."user-dirs.dirs".text = let # For some reason, these need to be wrapped with quotes to be valid. wrapped = mapAttrs (_: value: ''"${value}"'') directories; diff --git a/third_party/home-manager/modules/misc/xdg.nix b/third_party/home-manager/modules/misc/xdg.nix index 6b2917d448..1790b87dc5 100644 --- a/third_party/home-manager/modules/misc/xdg.nix +++ b/third_party/home-manager/modules/misc/xdg.nix @@ -14,22 +14,20 @@ let defaultCacheHome = "${config.home.homeDirectory}/.cache"; defaultConfigHome = "${config.home.homeDirectory}/.config"; defaultDataHome = "${config.home.homeDirectory}/.local/share"; + defaultStateHome = "${config.home.homeDirectory}/.local/state"; - getXdgDir = name: fallback: - let - value = builtins.getEnv name; - in - if value != "" then value else fallback; + getEnvFallback = name: fallback: + let value = builtins.getEnv name; + in if value != "" then value else fallback; -in - -{ +in { options.xdg = { enable = mkEnableOption "management of XDG base directories"; cacheHome = mkOption { type = types.path; defaultText = "~/.cache"; + apply = toString; description = '' Absolute path to directory holding application caches. ''; @@ -37,7 +35,7 @@ in configFile = mkOption { type = fileType "xdg.configHome" cfg.configHome; - default = {}; + default = { }; description = '' Attribute set of files to link into the user's XDG configuration home. @@ -47,6 +45,7 @@ in configHome = mkOption { type = types.path; defaultText = "~/.config"; + apply = toString; description = '' Absolute path to directory holding application configurations. ''; @@ -54,7 +53,7 @@ in dataFile = mkOption { type = fileType "xdg.dataHome" cfg.dataHome; - default = {}; + default = { }; description = '' Attribute set of files to link into the user's XDG data home. @@ -64,10 +63,20 @@ in dataHome = mkOption { type = types.path; defaultText = "~/.local/share"; + apply = toString; description = '' Absolute path to directory holding application data. ''; }; + + stateHome = mkOption { + type = types.path; + defaultText = "~/.local/state"; + apply = toString; + description = '' + Absolute path to directory holding application states. + ''; + }; }; config = mkMerge [ @@ -75,19 +84,23 @@ in xdg.cacheHome = mkDefault defaultCacheHome; xdg.configHome = mkDefault defaultConfigHome; xdg.dataHome = mkDefault defaultDataHome; + xdg.stateHome = mkDefault defaultStateHome; home.sessionVariables = { XDG_CACHE_HOME = cfg.cacheHome; XDG_CONFIG_HOME = cfg.configHome; XDG_DATA_HOME = cfg.dataHome; + XDG_STATE_HOME = cfg.stateHome; }; }) # Legacy non-deterministic setup. (mkIf (!cfg.enable && versionOlder config.home.stateVersion "20.09") { - xdg.cacheHome = getXdgDir "XDG_CACHE_HOME" defaultCacheHome; - xdg.configHome = getXdgDir "XDG_CONFIG_HOME" defaultConfigHome; - xdg.dataHome = getXdgDir "XDG_DATA_HOME" defaultDataHome; + xdg.cacheHome = + mkDefault (getEnvFallback "XDG_CACHE_HOME" defaultCacheHome); + xdg.configHome = + mkDefault (getEnvFallback "XDG_CONFIG_HOME" defaultConfigHome); + xdg.dataHome = mkDefault (getEnvFallback "XDG_DATA_HOME" defaultDataHome); }) # "Modern" deterministic setup. @@ -95,17 +108,16 @@ in xdg.cacheHome = mkDefault defaultCacheHome; xdg.configHome = mkDefault defaultConfigHome; xdg.dataHome = mkDefault defaultDataHome; + xdg.stateHome = mkDefault stateHome; }) { home.file = mkMerge [ - (mapAttrs' - (name: file: nameValuePair "${config.xdg.configHome}/${name}" file) + (mapAttrs' (name: file: nameValuePair "${cfg.configHome}/${name}" file) cfg.configFile) - (mapAttrs' - (name: file: nameValuePair "${config.xdg.dataHome}/${name}" file) + (mapAttrs' (name: file: nameValuePair "${cfg.dataHome}/${name}" file) cfg.dataFile) - { "${config.xdg.cacheHome}/.keep".text = ""; } + { "${cfg.cacheHome}/.keep".text = ""; } ]; } ]; diff --git a/third_party/home-manager/modules/modules.nix b/third_party/home-manager/modules/modules.nix index 6d6cff5dbb..ab2761f81d 100644 --- a/third_party/home-manager/modules/modules.nix +++ b/third_party/home-manager/modules/modules.nix @@ -1,250 +1,256 @@ { pkgs - # Note, this should be "the standard library" + HM extensions. +# Note, this should be "the standard library" + HM extensions. , lib - # Whether to enable module type checking. +# Whether to enable module type checking. , check ? true -# If disabled, the pkgs attribute passed to this function is used instead. -, useNixpkgsModule ? true -}: + # If disabled, the pkgs attribute passed to this function is used instead. +, useNixpkgsModule ? true }: with lib; let - hostPlatform = pkgs.stdenv.hostPlatform; - - loadModule = file: { condition ? true }: { - inherit file condition; - }; - - allModules = [ - (loadModule ./accounts/email.nix { }) - (loadModule ./config/i18n.nix { condition = hostPlatform.isLinux; }) - (loadModule ./files.nix { }) - (loadModule ./home-environment.nix { }) - (loadModule ./i18n/input-method/default.nix { condition = hostPlatform.isLinux; }) - (loadModule ./manual.nix { }) - (loadModule ./misc/dconf.nix { }) - (loadModule ./misc/debug.nix { }) - (loadModule ./misc/fontconfig.nix { }) - (loadModule ./misc/gtk.nix { }) - (loadModule ./misc/lib.nix { }) - (loadModule ./misc/news.nix { }) - (loadModule ./misc/nixpkgs.nix { condition = useNixpkgsModule; }) - (loadModule ./misc/numlock.nix { condition = hostPlatform.isLinux; }) - (loadModule ./misc/pam.nix { }) - (loadModule ./misc/qt.nix { }) - (loadModule ./misc/submodule-support.nix { }) - (loadModule ./misc/tmpfiles.nix { condition = hostPlatform.isLinux; }) - (loadModule ./misc/version.nix { }) - (loadModule ./misc/vte.nix { }) - (loadModule ./misc/xdg-system-dirs.nix { condition = hostPlatform.isLinux; }) - (loadModule ./misc/xdg-desktop-entries.nix { condition = hostPlatform.isLinux; }) - (loadModule ./misc/xdg-mime.nix { condition = hostPlatform.isLinux; }) - (loadModule ./misc/xdg-mime-apps.nix { condition = hostPlatform.isLinux; }) - (loadModule ./misc/xdg-user-dirs.nix { condition = hostPlatform.isLinux; }) - (loadModule ./misc/xdg.nix { }) - (loadModule ./programs/abook.nix { condition = hostPlatform.isLinux; }) - (loadModule ./programs/afew.nix { }) - (loadModule ./programs/alacritty.nix { }) - (loadModule ./programs/alot.nix { }) - (loadModule ./programs/aria2.nix { }) - (loadModule ./programs/astroid.nix { }) - (loadModule ./programs/autojump.nix { }) - (loadModule ./programs/autorandr.nix { }) - (loadModule ./programs/bash.nix { }) - (loadModule ./programs/bat.nix { }) - (loadModule ./programs/beets.nix { }) - (loadModule ./programs/broot.nix { }) - (loadModule ./programs/browserpass.nix { }) - (loadModule ./programs/chromium.nix { }) - (loadModule ./programs/command-not-found/command-not-found.nix { }) - (loadModule ./programs/dircolors.nix { }) - (loadModule ./programs/direnv.nix { }) - (loadModule ./programs/eclipse.nix { }) - (loadModule ./programs/emacs.nix { }) - (loadModule ./programs/exa.nix { }) - (loadModule ./programs/feh.nix { }) - (loadModule ./programs/firefox.nix { }) - (loadModule ./programs/fish.nix { }) - (loadModule ./programs/foot.nix { condition = hostPlatform.isLinux; }) - (loadModule ./programs/fzf.nix { }) - (loadModule ./programs/getmail.nix { condition = hostPlatform.isLinux; }) - (loadModule ./programs/gh.nix { }) - (loadModule ./programs/git.nix { }) - (loadModule ./programs/gnome-terminal.nix { }) - (loadModule ./programs/go.nix { }) - (loadModule ./programs/gpg.nix { }) - (loadModule ./programs/himalaya.nix { }) - (loadModule ./programs/home-manager.nix { }) - (loadModule ./programs/htop.nix { }) - (loadModule ./programs/i3status.nix { }) - (loadModule ./programs/i3status-rust.nix { condition = hostPlatform.isLinux; }) - (loadModule ./programs/info.nix { }) - (loadModule ./programs/irssi.nix { }) - (loadModule ./programs/lieer.nix { }) - (loadModule ./programs/jq.nix { }) - (loadModule ./programs/kakoune.nix { }) - (loadModule ./programs/keychain.nix { }) - (loadModule ./programs/kitty.nix { }) - (loadModule ./programs/lazygit.nix { }) - (loadModule ./programs/lesspipe.nix { }) - (loadModule ./programs/lf.nix { }) - (loadModule ./programs/lsd.nix { }) - (loadModule ./programs/man.nix { }) - (loadModule ./programs/mangohud.nix { condition = hostPlatform.isLinux; }) - (loadModule ./programs/matplotlib.nix { }) - (loadModule ./programs/mbsync.nix { }) - (loadModule ./programs/mcfly.nix { }) - (loadModule ./programs/mercurial.nix { }) - (loadModule ./programs/mpv.nix { }) - (loadModule ./programs/msmtp.nix { }) - (loadModule ./programs/mu.nix { }) - (loadModule ./programs/ncmpcpp.nix { }) - (loadModule ./programs/ncspot.nix { }) - (loadModule ./programs/ne.nix { }) - (loadModule ./programs/neomutt.nix { }) - (loadModule ./programs/neovim.nix { }) - (loadModule ./programs/newsboat.nix { }) - (loadModule ./programs/nix-index.nix { }) - (loadModule ./programs/noti.nix { }) - (loadModule ./programs/notmuch.nix { }) - (loadModule ./programs/nushell.nix { }) - (loadModule ./programs/obs-studio.nix { }) - (loadModule ./programs/octant.nix { }) - (loadModule ./programs/offlineimap.nix { }) - (loadModule ./programs/opam.nix { }) - (loadModule ./programs/password-store.nix { }) - (loadModule ./programs/pazi.nix { }) - (loadModule ./programs/pet.nix { }) - (loadModule ./programs/pidgin.nix { }) - (loadModule ./programs/piston-cli.nix { }) - (loadModule ./programs/powerline-go.nix { }) - (loadModule ./programs/qutebrowser.nix { }) - (loadModule ./programs/rbw.nix { }) - (loadModule ./programs/readline.nix { }) - (loadModule ./programs/rofi.nix { }) - (loadModule ./programs/rofi-pass.nix { }) - (loadModule ./programs/rtorrent.nix { }) - (loadModule ./programs/scmpuff.nix { }) - (loadModule ./programs/senpai.nix { }) - (loadModule ./programs/skim.nix { }) - (loadModule ./programs/starship.nix { }) - (loadModule ./programs/sbt.nix { }) - (loadModule ./programs/ssh.nix { }) - (loadModule ./programs/taskwarrior.nix { }) - (loadModule ./programs/termite.nix { }) - (loadModule ./programs/texlive.nix { }) - (loadModule ./programs/tmux.nix { }) - (loadModule ./programs/terminator.nix { condition = hostPlatform.isLinux; }) - (loadModule ./programs/topgrade.nix { }) - (loadModule ./programs/urxvt.nix { }) - (loadModule ./programs/vim.nix { }) - (loadModule ./programs/vscode.nix { }) - (loadModule ./programs/vscode/haskell.nix { }) - (loadModule ./programs/waybar.nix { condition = hostPlatform.isLinux; }) - (loadModule ./programs/xmobar.nix { }) - (loadModule ./programs/z-lua.nix { }) - (loadModule ./programs/zathura.nix { }) - (loadModule ./programs/zoxide.nix { }) - (loadModule ./programs/zplug.nix { }) - (loadModule ./programs/zsh.nix { }) - (loadModule ./programs/zsh/prezto.nix { }) - (loadModule ./services/barrier.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/blueman-applet.nix { }) - (loadModule ./services/caffeine.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/cbatticon.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/clipmenu.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/compton.nix { }) - (loadModule ./services/dropbox.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/dunst.nix { }) - (loadModule ./services/dwm-status.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/emacs.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/etesync-dav.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/flameshot.nix { }) - (loadModule ./services/fluidsynth.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/redshift-gammastep/gammastep.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/getmail.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/gnome-keyring.nix { }) - (loadModule ./services/gpg-agent.nix { }) - (loadModule ./services/grobi.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/hound.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/imapnotify.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/kanshi.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/kbfs.nix { }) - (loadModule ./services/kdeconnect.nix { }) - (loadModule ./services/keepassx.nix { }) - (loadModule ./services/keybase.nix { }) - (loadModule ./services/keynav.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/lieer.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/lorri.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/mako.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/mbsync.nix { }) - (loadModule ./services/mpd.nix { }) - (loadModule ./services/mpdris2.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/mpris-proxy.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/muchsync.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/network-manager-applet.nix { }) - (loadModule ./services/nextcloud-client.nix { }) - (loadModule ./services/owncloud-client.nix { }) - (loadModule ./services/pantalaimon.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/parcellite.nix { }) - (loadModule ./services/pass-secret-service.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/password-store-sync.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/pasystray.nix { }) - (loadModule ./services/pbgopy.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/picom.nix { }) - (loadModule ./services/plan9port.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/playerctld.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/polybar.nix { }) - (loadModule ./services/poweralertd.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/pulseeffects.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/random-background.nix { }) - (loadModule ./services/redshift-gammastep/redshift.nix { }) - (loadModule ./services/rsibreak.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/screen-locker.nix { }) - (loadModule ./services/stalonetray.nix { }) - (loadModule ./services/status-notifier-watcher.nix { }) - (loadModule ./services/spotifyd.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/sxhkd.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/syncthing.nix { }) - (loadModule ./services/taffybar.nix { }) - (loadModule ./services/tahoe-lafs.nix { }) - (loadModule ./services/taskwarrior-sync.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/udiskie.nix { }) - (loadModule ./services/unclutter.nix { }) - (loadModule ./services/unison.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/window-managers/awesome.nix { }) - (loadModule ./services/window-managers/bspwm/default.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/window-managers/i3-sway/i3.nix { }) - (loadModule ./services/window-managers/i3-sway/sway.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/window-managers/xmonad.nix { }) - (loadModule ./services/wlsunset.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/xcape.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/xembed-sni-proxy.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/xidlehook.nix { condition = hostPlatform.isLinux; }) - (loadModule ./services/xscreensaver.nix { }) - (loadModule ./services/xsuspender.nix { condition = hostPlatform.isLinux; }) - (loadModule ./systemd.nix { }) - (loadModule ./targets/darwin { condition = hostPlatform.isDarwin; }) - (loadModule ./targets/generic-linux.nix { condition = hostPlatform.isLinux; }) - (loadModule ./xcursor.nix { }) - (loadModule ./xresources.nix { }) - (loadModule ./xsession.nix { }) - (loadModule (pkgs.path + "/nixos/modules/misc/assertions.nix") { }) - (loadModule (pkgs.path + "/nixos/modules/misc/meta.nix") { }) - ]; - - modules = map (getAttr "file") (filter (getAttr "condition") allModules); + modules = [ + ./accounts/email.nix + ./config/i18n.nix + ./files.nix + ./home-environment.nix + ./i18n/input-method/default.nix + ./manual.nix + ./misc/dconf.nix + ./misc/debug.nix + ./misc/fontconfig.nix + ./misc/gtk.nix + ./misc/lib.nix + ./misc/news.nix + ./misc/numlock.nix + ./misc/pam.nix + ./misc/qt.nix + ./misc/submodule-support.nix + ./misc/tmpfiles.nix + ./misc/version.nix + ./misc/vte.nix + ./misc/xdg-desktop-entries.nix + ./misc/xdg-mime-apps.nix + ./misc/xdg-mime.nix + ./misc/xdg-system-dirs.nix + ./misc/xdg-user-dirs.nix + ./misc/xdg.nix + ./programs/abook.nix + ./programs/afew.nix + ./programs/alacritty.nix + ./programs/alot.nix + ./programs/aria2.nix + ./programs/astroid.nix + ./programs/atuin.nix + ./programs/autojump.nix + ./programs/autorandr.nix + ./programs/bash.nix + ./programs/bat.nix + ./programs/beets.nix + ./programs/bottom.nix + ./programs/broot.nix + ./programs/browserpass.nix + ./programs/chromium.nix + ./programs/command-not-found/command-not-found.nix + ./programs/dircolors.nix + ./programs/direnv.nix + ./programs/eclipse.nix + ./programs/emacs.nix + ./programs/exa.nix + ./programs/feh.nix + ./programs/firefox.nix + ./programs/fish.nix + ./programs/foot.nix + ./programs/fzf.nix + ./programs/getmail.nix + ./programs/gh.nix + ./programs/git.nix + ./programs/gnome-terminal.nix + ./programs/go.nix + ./programs/gpg.nix + ./programs/hexchat.nix + ./programs/himalaya.nix + ./programs/home-manager.nix + ./programs/htop.nix + ./programs/i3status-rust.nix + ./programs/i3status.nix + ./programs/info.nix + ./programs/irssi.nix + ./programs/java.nix + ./programs/jq.nix + ./programs/kakoune.nix + ./programs/keychain.nix + ./programs/kitty.nix + ./programs/lazygit.nix + ./programs/lesspipe.nix + ./programs/lf.nix + ./programs/lieer.nix + ./programs/lsd.nix + ./programs/man.nix + ./programs/mangohud.nix + ./programs/matplotlib.nix + ./programs/mbsync.nix + ./programs/mcfly.nix + ./programs/mercurial.nix + ./programs/mpv.nix + ./programs/msmtp.nix + ./programs/mu.nix + ./programs/ncmpcpp.nix + ./programs/ncspot.nix + ./programs/ne.nix + ./programs/neomutt.nix + ./programs/neovim.nix + ./programs/newsboat.nix + ./programs/nix-index.nix + ./programs/nnn.nix + ./programs/noti.nix + ./programs/notmuch.nix + ./programs/nushell.nix + ./programs/obs-studio.nix + ./programs/octant.nix + ./programs/offlineimap.nix + ./programs/opam.nix + ./programs/password-store.nix + ./programs/pazi.nix + ./programs/pet.nix + ./programs/pidgin.nix + ./programs/piston-cli.nix + ./programs/powerline-go.nix + ./programs/qutebrowser.nix + ./programs/rbw.nix + ./programs/readline.nix + ./programs/rofi-pass.nix + ./programs/rofi.nix + ./programs/rtorrent.nix + ./programs/sbt.nix + ./programs/scmpuff.nix + ./programs/senpai.nix + ./programs/skim.nix + ./programs/sm64ex.nix + ./programs/ssh.nix + ./programs/starship.nix + ./programs/taskwarrior.nix + ./programs/terminator.nix + ./programs/termite.nix + ./programs/texlive.nix + ./programs/tmux.nix + ./programs/topgrade.nix + ./programs/urxvt.nix + ./programs/vim.nix + ./programs/vscode.nix + ./programs/vscode/haskell.nix + ./programs/waybar.nix + ./programs/xmobar.nix + ./programs/z-lua.nix + ./programs/zathura.nix + ./programs/zoxide.nix + ./programs/zplug.nix + ./programs/zsh.nix + ./programs/zsh/prezto.nix + ./services/barrier.nix + ./services/betterlockscreen.nix + ./services/blueman-applet.nix + ./services/caffeine.nix + ./services/cbatticon.nix + ./services/clipmenu.nix + ./services/compton.nix + ./services/devilspie2.nix + ./services/dropbox.nix + ./services/dunst.nix + ./services/dwm-status.nix + ./services/easyeffects.nix + ./services/emacs.nix + ./services/etesync-dav.nix + ./services/flameshot.nix + ./services/fluidsynth.nix + ./services/fnott.nix + ./services/getmail.nix + ./services/git-sync.nix + ./services/gnome-keyring.nix + ./services/gpg-agent.nix + ./services/grobi.nix + ./services/hound.nix + ./services/imapnotify.nix + ./services/kanshi.nix + ./services/kbfs.nix + ./services/kdeconnect.nix + ./services/keepassx.nix + ./services/keybase.nix + ./services/keynav.nix + ./services/lieer.nix + ./services/lorri.nix + ./services/mako.nix + ./services/mbsync.nix + ./services/mpd.nix + ./services/mpdris2.nix + ./services/mpris-proxy.nix + ./services/muchsync.nix + ./services/network-manager-applet.nix + ./services/nextcloud-client.nix + ./services/notify-osd.nix + ./services/owncloud-client.nix + ./services/pantalaimon.nix + ./services/parcellite.nix + ./services/pass-secret-service.nix + ./services/password-store-sync.nix + ./services/pasystray.nix + ./services/pbgopy.nix + ./services/picom.nix + ./services/plan9port.nix + ./services/playerctld.nix + ./services/polybar.nix + ./services/poweralertd.nix + ./services/pulseeffects.nix + ./services/random-background.nix + ./services/redshift-gammastep/gammastep.nix + ./services/redshift-gammastep/redshift.nix + ./services/rsibreak.nix + ./services/screen-locker.nix + ./services/spotifyd.nix + ./services/stalonetray.nix + ./services/status-notifier-watcher.nix + ./services/sxhkd.nix + ./services/syncthing.nix + ./services/taffybar.nix + ./services/tahoe-lafs.nix + ./services/taskwarrior-sync.nix + ./services/trayer.nix + ./services/udiskie.nix + ./services/unclutter.nix + ./services/unison.nix + ./services/volnoti.nix + ./services/window-managers/awesome.nix + ./services/window-managers/bspwm/default.nix + ./services/window-managers/i3-sway/i3.nix + ./services/window-managers/i3-sway/sway.nix + ./services/window-managers/xmonad.nix + ./services/wlsunset.nix + ./services/xcape.nix + ./services/xembed-sni-proxy.nix + ./services/xidlehook.nix + ./services/xscreensaver.nix + ./services/xsettingsd.nix + ./services/xsuspender.nix + ./systemd.nix + ./targets/darwin + ./targets/generic-linux.nix + ./xcursor.nix + ./xresources.nix + ./xsession.nix + (pkgs.path + "/nixos/modules/misc/assertions.nix") + (pkgs.path + "/nixos/modules/misc/meta.nix") + ] ++ optional useNixpkgsModule ./misc/nixpkgs.nix + ++ optional (!useNixpkgsModule) ./misc/nixpkgs-disabled.nix; pkgsModule = { config, ... }: { config = { _module.args.baseModules = modules; - _module.args.pkgsPath = lib.mkDefault ( - if versionAtLeast config.home.stateVersion "20.09" then + _module.args.pkgsPath = lib.mkDefault + (if versionAtLeast config.home.stateVersion "20.09" then pkgs.path else ); @@ -252,10 +258,8 @@ let _module.check = check; lib = lib.hm; } // optionalAttrs useNixpkgsModule { - nixpkgs.system = mkDefault pkgs.system; + nixpkgs.system = mkDefault pkgs.stdenv.hostPlatform.system; }; }; -in - - modules ++ [ pkgsModule ] +in modules ++ [ pkgsModule ] diff --git a/third_party/home-manager/modules/programs/abook.nix b/third_party/home-manager/modules/programs/abook.nix index 4ddc080ad5..bdbf7e87d2 100644 --- a/third_party/home-manager/modules/programs/abook.nix +++ b/third_party/home-manager/modules/programs/abook.nix @@ -27,7 +27,11 @@ in { }; config = mkIf cfg.enable { + assertions = + [ (hm.assertions.assertPlatform "programs.abook" pkgs platforms.linux) ]; + home.packages = [ pkgs.abook ]; + xdg.configFile."abook/abookrc" = mkIf (cfg.extraConfig != "") { text = '' # Generated by Home Manager. diff --git a/third_party/home-manager/modules/programs/alacritty.nix b/third_party/home-manager/modules/programs/alacritty.nix index 9c3e8e75dc..d34efb7759 100644 --- a/third_party/home-manager/modules/programs/alacritty.nix +++ b/third_party/home-manager/modules/programs/alacritty.nix @@ -13,14 +13,14 @@ in { package = mkOption { type = types.package; default = pkgs.alacritty; - defaultText = literalExample "pkgs.alacritty"; + defaultText = literalExpression "pkgs.alacritty"; description = "The Alacritty package to install."; }; settings = mkOption { type = yamlFormat.type; default = { }; - example = literalExample '' + example = literalExpression '' { window.dimensions = { lines = 3; diff --git a/third_party/home-manager/modules/programs/alot-accounts.nix b/third_party/home-manager/modules/programs/alot-accounts.nix index 89ae28f9c8..9dee3c83ad 100644 --- a/third_party/home-manager/modules/programs/alot-accounts.nix +++ b/third_party/home-manager/modules/programs/alot-accounts.nix @@ -25,7 +25,7 @@ with lib; + "}[,\\]]?'"; shellcommand_external_filtering = "False"; }; - example = literalExample '' + example = literalExpression '' { type = "shellcommand"; command = "abook --mutt-query"; diff --git a/third_party/home-manager/modules/programs/alot.nix b/third_party/home-manager/modules/programs/alot.nix index b3abf1f7da..0cc20ec6e0 100644 --- a/third_party/home-manager/modules/programs/alot.nix +++ b/third_party/home-manager/modules/programs/alot.nix @@ -200,7 +200,7 @@ in { handle_mouse = true; prefer_plaintext = true; }; - example = literalExample '' + example = literalExpression '' { auto_remove_unread = true; ask_subject = false; diff --git a/third_party/home-manager/modules/programs/aria2.nix b/third_party/home-manager/modules/programs/aria2.nix index d1317ff761..25727cead5 100644 --- a/third_party/home-manager/modules/programs/aria2.nix +++ b/third_party/home-manager/modules/programs/aria2.nix @@ -31,7 +31,7 @@ in { for options. ''; - example = literalExample '' + example = literalExpression '' { listen-port = 60000; dht-listen-port = 60000; diff --git a/third_party/home-manager/modules/programs/astroid.nix b/third_party/home-manager/modules/programs/astroid.nix index 8af18f16c1..296e8dc5e4 100644 --- a/third_party/home-manager/modules/programs/astroid.nix +++ b/third_party/home-manager/modules/programs/astroid.nix @@ -22,9 +22,9 @@ let sendmail = astroid.sendMailCommand; additional_sent_tags = ""; default = boolOpt primary; - save_drafts_to = "${maildir.absPath}/${folders.drafts}"; + save_drafts_to = "${maildir.absPath}/${folders.drafts}/cur/"; save_sent = "true"; - save_sent_to = "${maildir.absPath}/${folders.sent}"; + save_sent_to = "${maildir.absPath}/${folders.sent}/cur/"; select_query = ""; } // optionalAttrs (signature.showSignature != "none") { signature_attach = boolOpt (signature.showSignature == "attach"); @@ -93,7 +93,7 @@ in { extraConfig = mkOption { type = jsonFormat.type; default = { }; - example = literalExample '' + example = literalExpression '' { poll.interval = 0; } diff --git a/third_party/home-manager/modules/programs/atuin.nix b/third_party/home-manager/modules/programs/atuin.nix new file mode 100644 index 0000000000..dcf1232f8f --- /dev/null +++ b/third_party/home-manager/modules/programs/atuin.nix @@ -0,0 +1,90 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + + cfg = config.programs.atuin; + + tomlFormat = pkgs.formats.toml { }; + +in { + meta.maintainers = [ maintainers.hawkw ]; + + options.programs.atuin = { + enable = mkEnableOption "atuin"; + + package = mkOption { + type = types.package; + default = pkgs.atuin; + defaultText = literalExpression "pkgs.atuin"; + description = "The package to use for atuin."; + }; + + enableBashIntegration = mkOption { + type = types.bool; + default = true; + description = '' + Whether to enable Atuin's Bash integration. This will bind + ctrl-r to open the Atuin history. + ''; + }; + + enableZshIntegration = mkEnableOption "Zsh integration" // { + default = true; + description = '' + Whether to enable Atuin's Zsh integration. + + If enabled, this will bind ctrl-r and the up-arrow + key to open the Atuin history. + ''; + }; + + settings = mkOption { + type = with types; + let + prim = oneOf [ bool int str ]; + primOrPrimAttrs = either prim (attrsOf prim); + entry = either prim (listOf primOrPrimAttrs); + entryOrAttrsOf = t: either entry (attrsOf t); + entries = entryOrAttrsOf (entryOrAttrsOf entry); + in attrsOf entries // { description = "Atuin configuration"; }; + default = { }; + example = literalExpression '' + { + auto_sync = true; + sync_frequency = "5m"; + sync_address = "https://api.atuin.sh"; + search_mode = "prefix"; + } + ''; + description = '' + Configuration written to + ~/.config/atuin/config.toml. + + See for the full list + of options. + ''; + }; + }; + + config = mkIf cfg.enable { + + # Always add the configured `atuin` package. + home.packages = [ cfg.package ]; + + # If there are user-provided settings, generate the config file. + xdg.configFile."atuin/config.toml" = mkIf (cfg.settings != { }) { + source = tomlFormat.generate "atuin-config" cfg.settings; + }; + + programs.bash.initExtra = mkIf cfg.enableBashIntegration '' + source "${pkgs.bash-preexec}/share/bash/bash-preexec.sh" + eval "$(${cfg.package}/bin/atuin init bash)" + ''; + + programs.zsh.initExtra = mkIf cfg.enableZshIntegration '' + eval "$(${cfg.package}/bin/atuin init zsh)" + ''; + }; +} diff --git a/third_party/home-manager/modules/programs/autojump.nix b/third_party/home-manager/modules/programs/autojump.nix index db3bdaf593..e8bf6b4375 100644 --- a/third_party/home-manager/modules/programs/autojump.nix +++ b/third_party/home-manager/modules/programs/autojump.nix @@ -49,7 +49,7 @@ in { . ${package}/share/autojump/autojump.zsh ''; - programs.fish.promptInit = mkIf cfg.enableFishIntegration '' + programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration '' . ${package}/share/autojump/autojump.fish ''; }; diff --git a/third_party/home-manager/modules/programs/autorandr.nix b/third_party/home-manager/modules/programs/autorandr.nix index 40cad704db..69505f2552 100644 --- a/third_party/home-manager/modules/programs/autorandr.nix +++ b/third_party/home-manager/modules/programs/autorandr.nix @@ -106,7 +106,7 @@ let transform = mkOption { type = types.nullOr (matrixOf 3 3 types.float); default = null; - example = literalExample '' + example = literalExpression '' [ [ 0.6 0.0 0.0 ] [ 0.0 0.6 0.0 ] @@ -169,7 +169,7 @@ let exclusive. ''; default = null; - example = literalExample '' + example = literalExpression '' { x = 1.25; y = 1.25; @@ -280,7 +280,7 @@ in { type = globalHooksModule; description = "Global hook scripts"; default = { }; - example = literalExample '' + example = literalExpression '' { postswitch = { "notify-i3" = "''${pkgs.i3}/bin/i3-msg restart"; @@ -312,7 +312,7 @@ in { type = types.attrsOf profileModule; description = "Autorandr profiles specification."; default = { }; - example = literalExample '' + example = literalExpression '' { "work" = { fingerprint = { diff --git a/third_party/home-manager/modules/programs/bash.nix b/third_party/home-manager/modules/programs/bash.nix index 5140e1aada..c0165fe763 100644 --- a/third_party/home-manager/modules/programs/bash.nix +++ b/third_party/home-manager/modules/programs/bash.nix @@ -75,7 +75,14 @@ in # Warn if closing shell with running jobs. "checkjobs" ]; - description = "Shell options to set."; + example = [ + "extglob" + "-cdspell" + ]; + description = '' + Shell options to set. Prefix an option with + - to unset. + ''; }; sessionVariables = mkOption { @@ -90,7 +97,7 @@ in shellAliases = mkOption { default = {}; type = types.attrsOf types.str; - example = literalExample '' + example = literalExpression '' { ll = "ls -l"; ".." = "cd .."; @@ -146,8 +153,10 @@ in mapAttrsToList (k: v: "alias ${k}=${escapeShellArg v}") cfg.shellAliases ); - shoptsStr = concatStringsSep "\n" ( - map (v: "shopt -s ${v}") cfg.shellOptions + shoptsStr = let + switch = v: if hasPrefix "-" v then "-u" else "-s"; + in concatStringsSep "\n" ( + map (v: "shopt ${switch v} ${removePrefix "-" v}") cfg.shellOptions ); sessionVarsStr = config.lib.shell.exportAll cfg.sessionVariables; diff --git a/third_party/home-manager/modules/programs/bat.nix b/third_party/home-manager/modules/programs/bat.nix index e2b30ea933..30b0bbb715 100644 --- a/third_party/home-manager/modules/programs/bat.nix +++ b/third_party/home-manager/modules/programs/bat.nix @@ -6,6 +6,11 @@ let cfg = config.programs.bat; + toConfigFile = generators.toKeyValue { + mkKeyValue = k: v: "--${k}=${lib.escapeShellArg v}"; + listsAsDuplicateKeys = true; + }; + in { meta.maintainers = [ maintainers.marsam ]; @@ -13,11 +18,12 @@ in { enable = mkEnableOption "bat, a cat clone with wings"; config = mkOption { - type = types.attrsOf types.str; + type = with types; attrsOf (either str (listOf str)); default = { }; example = { theme = "TwoDark"; pager = "less -FR"; + map-syntax = [ "*.jenkinsfile:Groovy" "*.props:Java Properties" ]; }; description = '' Bat configuration. @@ -27,7 +33,7 @@ in { themes = mkOption { type = types.attrsOf types.lines; default = { }; - example = literalExample '' + example = literalExpression '' { dracula = builtins.readFile (pkgs.fetchFromGitHub { owner = "dracula"; @@ -48,10 +54,8 @@ in { home.packages = [ pkgs.bat ]; xdg.configFile = mkMerge ([{ - "bat/config" = mkIf (cfg.config != { }) { - text = concatStringsSep "\n" - (mapAttrsToList (n: v: ''--${n}="${v}"'') cfg.config); - }; + "bat/config" = + mkIf (cfg.config != { }) { text = toConfigFile cfg.config; }; }] ++ flip mapAttrsToList cfg.themes (name: body: { "bat/themes/${name}.tmTheme" = { text = body; }; })); }; diff --git a/third_party/home-manager/modules/programs/beets.nix b/third_party/home-manager/modules/programs/beets.nix index 6eb183dd1e..a0b8a346b0 100644 --- a/third_party/home-manager/modules/programs/beets.nix +++ b/third_party/home-manager/modules/programs/beets.nix @@ -31,9 +31,9 @@ in { package = mkOption { type = types.package; default = pkgs.beets; - defaultText = literalExample "pkgs.beets"; + defaultText = literalExpression "pkgs.beets"; example = - literalExample "(pkgs.beets.override { enableCheck = true; })"; + literalExpression "(pkgs.beets.override { enableCheck = true; })"; description = '' The beets package to use. Can be used to specify extensions. diff --git a/third_party/home-manager/modules/programs/bottom.nix b/third_party/home-manager/modules/programs/bottom.nix new file mode 100644 index 0000000000..459a3132c8 --- /dev/null +++ b/third_party/home-manager/modules/programs/bottom.nix @@ -0,0 +1,66 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.bottom; + + tomlFormat = pkgs.formats.toml { }; + + configDir = if pkgs.stdenv.isDarwin then + "Library/Application Support" + else + config.xdg.configHome; + +in { + options = { + programs.bottom = { + enable = mkEnableOption '' + bottom, a cross-platform graphical process/system monitor with a + customizable interface''; + + package = mkOption { + type = types.package; + default = pkgs.bottom; + defaultText = literalExpression "pkgs.bottom"; + description = "Package providing bottom."; + }; + + settings = mkOption { + type = tomlFormat.type; + default = { }; + description = '' + Configuration written to + $XDG_CONFIG_HOME/bottom/bottom.toml on Linux or + $HOME/Library/Application Support/bottom/bottom.toml on Darwin. + + See + for the default configuration. + ''; + example = literalExpression '' + { + flags = { + avg_cpu = true; + temperature_type = "c"; + }; + + colors = { + low_battery_color = "red"; + }; + } + ''; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ cfg.package ]; + + home.file."${configDir}/bottom/bottom.toml" = mkIf (cfg.settings != { }) { + source = tomlFormat.generate "bottom.toml" cfg.settings; + }; + }; + + meta.maintainers = [ maintainers.polykernel ]; +} diff --git a/third_party/home-manager/modules/programs/broot.nix b/third_party/home-manager/modules/programs/broot.nix index 72b2c6ea13..79ffb3888d 100644 --- a/third_party/home-manager/modules/programs/broot.nix +++ b/third_party/home-manager/modules/programs/broot.nix @@ -11,6 +11,7 @@ let brootConf = { verbs = cfg.verbs; skin = cfg.skin; + modal = cfg.modal; }; in { @@ -43,6 +44,8 @@ in { ''; }; + modal = mkEnableOption "modal (vim) mode"; + verbs = mkOption { type = with types; listOf (attrsOf (either bool str)); default = [ @@ -64,7 +67,7 @@ in { execution = "less {file}"; } ]; - example = literalExample '' + example = literalExpression '' [ { invocation = "p"; execution = ":parent"; } { invocation = "edit"; shortcut = "e"; execution = "$EDITOR {file}" ; } @@ -121,14 +124,14 @@ in { package = mkOption { type = types.package; default = pkgs.broot; - defaultText = literalExample "pkgs.broot"; + defaultText = literalExpression "pkgs.broot"; description = "Package providing broot"; }; skin = mkOption { type = types.attrsOf types.str; default = { }; - example = literalExample '' + example = literalExpression '' { status_normal_fg = "grayscale(18)"; status_normal_bg = "grayscale(3)"; diff --git a/third_party/home-manager/modules/programs/chromium.nix b/third_party/home-manager/modules/programs/chromium.nix index c866c09992..5a10fe760b 100644 --- a/third_party/home-manager/modules/programs/chromium.nix +++ b/third_party/home-manager/modules/programs/chromium.nix @@ -21,7 +21,7 @@ let inherit visible; type = types.package; default = defaultPkg; - defaultText = literalExample "pkgs.${browser}"; + defaultText = literalExpression "pkgs.${browser}"; description = "The ${name} package to use."; }; } // optionalAttrs (!isProprietaryChrome) { @@ -72,7 +72,7 @@ let }; in listOf (coercedTo str (v: { id = v; }) extensionType); default = [ ]; - example = literalExample '' + example = literalExpression '' [ { id = "cjpalhdlnbpafiamejdnhcphjbkeiagm"; } # ublock origin { @@ -114,10 +114,12 @@ let brave = "BraveSoftware/Brave-Browser"; }; + linuxDirs = { brave = "BraveSoftware/Brave-Browser"; }; + configDir = if pkgs.stdenv.isDarwin then - "Library/Application Support/${getAttr browser darwinDirs}" + "Library/Application Support/" + (darwinDirs."${browser}" or browser) else - "${config.xdg.configHome}/${browser}"; + "${config.xdg.configHome}/" + (linuxDirs."${browser}" or browser); extensionJson = ext: assert ext.crxPath != null -> ext.version != null; diff --git a/third_party/home-manager/modules/programs/dircolors.nix b/third_party/home-manager/modules/programs/dircolors.nix index 6ac16da50b..655d71e57c 100644 --- a/third_party/home-manager/modules/programs/dircolors.nix +++ b/third_party/home-manager/modules/programs/dircolors.nix @@ -51,7 +51,7 @@ in { See dircolors --print-database for options. ''; - example = literalExample '' + example = literalExpression '' { OTHER_WRITABLE = "30;46"; ".sh" = "01;32"; diff --git a/third_party/home-manager/modules/programs/direnv.nix b/third_party/home-manager/modules/programs/direnv.nix index 383cff3af8..9974a28fb3 100644 --- a/third_party/home-manager/modules/programs/direnv.nix +++ b/third_party/home-manager/modules/programs/direnv.nix @@ -66,8 +66,11 @@ in { enableFishIntegration = mkOption { default = true; type = types.bool; + readOnly = true; description = '' - Whether to enable Fish integration. + Whether to enable Fish integration. Note, enabling the direnv module + will always active its functionality for Fish since the direnv package + automatically gets loaded in Fish. ''; }; @@ -106,9 +109,5 @@ in { programs.zsh.initExtra = mkIf cfg.enableZshIntegration '' eval "$(${pkgs.direnv}/bin/direnv hook zsh)" ''; - - programs.fish.shellInit = mkIf cfg.enableFishIntegration '' - ${pkgs.direnv}/bin/direnv hook fish | source - ''; }; } diff --git a/third_party/home-manager/modules/programs/eclipse.nix b/third_party/home-manager/modules/programs/eclipse.nix index 21973ab937..4c9328a011 100644 --- a/third_party/home-manager/modules/programs/eclipse.nix +++ b/third_party/home-manager/modules/programs/eclipse.nix @@ -16,8 +16,8 @@ in { package = mkOption { type = types.package; default = pkgs.eclipses.eclipse-platform; - defaultText = literalExample "pkgs.eclipses.eclipse-platform"; - example = literalExample "pkgs.eclipses.eclipse-java"; + defaultText = literalExpression "pkgs.eclipses.eclipse-platform"; + example = literalExpression "pkgs.eclipses.eclipse-java"; description = '' The Eclipse package to install. ''; diff --git a/third_party/home-manager/modules/programs/emacs.nix b/third_party/home-manager/modules/programs/emacs.nix index b785f71358..4e69c55b0e 100644 --- a/third_party/home-manager/modules/programs/emacs.nix +++ b/third_party/home-manager/modules/programs/emacs.nix @@ -13,6 +13,12 @@ let emacsWithPackages = emacsPackages.emacsWithPackages; + createConfPackage = epkgs: + epkgs.trivialBuild { + pname = "default"; + src = pkgs.writeText "default.el" cfg.extraConfig; + }; + in { meta.maintainers = [ maintainers.rycee ]; @@ -23,16 +29,33 @@ in { package = mkOption { type = types.package; default = pkgs.emacs; - defaultText = literalExample "pkgs.emacs"; - example = literalExample "pkgs.emacs25-nox"; + defaultText = literalExpression "pkgs.emacs"; + example = literalExpression "pkgs.emacs25-nox"; description = "The Emacs package to use."; }; + # NOTE: The config is placed in default.el instead of ~/.emacs.d so that + # it won't conflict with Emacs configuration frameworks. Users of these + # frameworks would still benefit from this option as it would easily allow + # them to have Nix-computed paths in their configuration. + extraConfig = mkOption { + type = types.lines; + default = ""; + example = '' + (setq standard-indent 2) + ''; + description = '' + Configuration to include in the Emacs default init file. See + + for more. + ''; + }; + extraPackages = mkOption { default = self: [ ]; type = hm.types.selectorFunction; defaultText = "epkgs: []"; - example = literalExample "epkgs: [ epkgs.emms epkgs.magit ]"; + example = literalExpression "epkgs: [ epkgs.emms epkgs.magit ]"; description = '' Extra packages available to Emacs. To get a list of available packages run: @@ -44,7 +67,7 @@ in { default = self: super: { }; type = hm.types.overlayFunction; defaultText = "self: super: {}"; - example = literalExample '' + example = literalExpression '' self: super: rec { haskell-mode = self.melpaPackages.haskell-mode; # ... @@ -68,6 +91,10 @@ in { config = mkIf cfg.enable { home.packages = [ cfg.finalPackage ]; - programs.emacs.finalPackage = emacsWithPackages cfg.extraPackages; + programs.emacs = { + finalPackage = emacsWithPackages cfg.extraPackages; + extraPackages = epkgs: + optional (cfg.extraConfig != "") (createConfPackage epkgs); + }; }; } diff --git a/third_party/home-manager/modules/programs/firefox.nix b/third_party/home-manager/modules/programs/firefox.nix index d474f5b808..07de012c45 100644 --- a/third_party/home-manager/modules/programs/firefox.nix +++ b/third_party/home-manager/modules/programs/firefox.nix @@ -9,19 +9,15 @@ let cfg = config.programs.firefox; mozillaConfigPath = - if isDarwin - then "Library/Application Support/Mozilla" - else ".mozilla"; + if isDarwin then "Library/Application Support/Mozilla" else ".mozilla"; - firefoxConfigPath = - if isDarwin - then "Library/Application Support/Firefox" - else "${mozillaConfigPath}/firefox"; + firefoxConfigPath = if isDarwin then + "Library/Application Support/Firefox" + else + "${mozillaConfigPath}/firefox"; profilesPath = - if isDarwin - then "${firefoxConfigPath}/Profiles" - else firefoxConfigPath; + if isDarwin then "${firefoxConfigPath}/Profiles" else firefoxConfigPath; # The extensions path shared by all profiles; will not be supported # by future Firefox versions. @@ -32,46 +28,72 @@ let paths = cfg.extensions; }; - profiles = - flip mapAttrs' cfg.profiles (_: profile: - nameValuePair "Profile${toString profile.id}" { - Name = profile.name; - Path = - if isDarwin - then "Profiles/${profile.path}" - else profile.path; - IsRelative = 1; - Default = if profile.isDefault then 1 else 0; - } - ) // { - General = { - StartWithLastProfile = 1; - }; + profiles = flip mapAttrs' cfg.profiles (_: profile: + nameValuePair "Profile${toString profile.id}" { + Name = profile.name; + Path = if isDarwin then "Profiles/${profile.path}" else profile.path; + IsRelative = 1; + Default = if profile.isDefault then 1 else 0; + }) // { + General = { StartWithLastProfile = 1; }; }; - profilesIni = generators.toINI {} profiles; + profilesIni = generators.toINI { } profiles; - mkUserJs = prefs: extraPrefs: '' - // Generated by Home Manager. + mkUserJs = prefs: extraPrefs: bookmarks: + let + prefs' = lib.optionalAttrs ({ } != bookmarks) { + "browser.bookmarks.file" = toString (firefoxBookmarksFile bookmarks); + "browser.places.importBookmarksHTML" = true; + } // prefs; + in '' + // Generated by Home Manager. - ${concatStrings (mapAttrsToList (name: value: '' - user_pref("${name}", ${builtins.toJSON value}); - '') prefs)} + ${concatStrings (mapAttrsToList (name: value: '' + user_pref("${name}", ${builtins.toJSON value}); + '') prefs')} - ${extraPrefs} - ''; + ${extraPrefs} + ''; -in + firefoxBookmarksFile = bookmarks: + let + escapeXML = replaceStrings [ ''"'' "'" "<" ">" "&" ] [ + """ + "'" + "<" + ">" + "&" + ]; + mapper = _: entry: '' +
${escapeXML entry.name} + ''; + bookmarksEntries = lib.attrsets.mapAttrsToList mapper bookmarks; + in pkgs.writeText "firefox-bookmarks.html" '' + + + + Bookmarks +

Bookmarks Menu

+

+ ${concatStrings bookmarksEntries} +

+ ''; -{ +in { meta.maintainers = [ maintainers.rycee ]; imports = [ - (mkRemovedOptionModule ["programs" "firefox" "enableAdobeFlash"] + (mkRemovedOptionModule [ "programs" "firefox" "enableAdobeFlash" ] "Support for this option has been removed.") - (mkRemovedOptionModule ["programs" "firefox" "enableGoogleTalk"] + (mkRemovedOptionModule [ "programs" "firefox" "enableGoogleTalk" ] "Support for this option has been removed.") - (mkRemovedOptionModule ["programs" "firefox" "enableIcedTea"] + (mkRemovedOptionModule [ "programs" "firefox" "enableIcedTea" ] "Support for this option has been removed.") ]; @@ -81,12 +103,12 @@ in package = mkOption { type = types.package; - default = - if versionAtLeast config.home.stateVersion "19.09" - then pkgs.firefox - else pkgs.firefox-unwrapped; - defaultText = literalExample "pkgs.firefox"; - example = literalExample '' + default = if versionAtLeast config.home.stateVersion "19.09" then + pkgs.firefox + else + pkgs.firefox-unwrapped; + defaultText = literalExpression "pkgs.firefox"; + example = literalExpression '' pkgs.firefox.override { # See nixpkgs' firefox/wrapper.nix to check which options you can use cfg = { @@ -106,8 +128,8 @@ in extensions = mkOption { type = types.listOf types.package; - default = []; - example = literalExample '' + default = [ ]; + example = literalExpression '' with pkgs.nur.repos.rycee.firefox-addons; [ https-everywhere privacy-badger @@ -141,7 +163,7 @@ in }; profiles = mkOption { - type = types.attrsOf (types.submodule ({config, name, ...}: { + type = types.attrsOf (types.submodule ({ config, name, ... }: { options = { name = mkOption { type = types.str; @@ -159,8 +181,8 @@ in settings = mkOption { type = with types; attrsOf (either bool (either int str)); - default = {}; - example = literalExample '' + default = { }; + example = literalExpression '' { "browser.startup.homepage" = "https://nixos.org"; "browser.search.region" = "GB"; @@ -210,6 +232,45 @@ in ''; }; + bookmarks = mkOption { + type = types.attrsOf (types.submodule ({ config, name, ... }: { + options = { + name = mkOption { + type = types.str; + default = name; + description = "Bookmark name."; + }; + + keyword = mkOption { + type = types.nullOr types.str; + default = null; + description = "Bookmark search keyword."; + }; + + url = mkOption { + type = types.str; + description = "Bookmark url, use %s for search terms."; + }; + }; + })); + default = { }; + example = literalExpression '' + { + wikipedia = { + keyword = "wiki"; + url = "https://en.wikipedia.org/wiki/Special:Search?search=%s&go=Go"; + }; + "kernel.org" = { + url = "https://www.kernel.org"; + }; + } + ''; + description = '' + Preloaded bookmarks. Note, this may silently overwrite any + previously existing bookmarks! + ''; + }; + path = mkOption { type = types.str; default = name; @@ -224,7 +285,7 @@ in }; }; })); - default = {}; + default = { }; description = "Attribute set of Firefox profiles."; }; @@ -243,36 +304,27 @@ in config = mkIf cfg.enable { assertions = [ - ( - let - defaults = - catAttrs "name" (filter (a: a.isDefault) (attrValues cfg.profiles)); - in { - assertion = cfg.profiles == {} || length defaults == 1; - message = - "Must have exactly one default Firefox profile but found " - + toString (length defaults) - + optionalString (length defaults > 1) - (", namely " + concatStringsSep ", " defaults); - } - ) + (let + defaults = + catAttrs "name" (filter (a: a.isDefault) (attrValues cfg.profiles)); + in { + assertion = cfg.profiles == { } || length defaults == 1; + message = "Must have exactly one default Firefox profile but found " + + toString (length defaults) + optionalString (length defaults > 1) + (", namely " + concatStringsSep ", " defaults); + }) - ( - let - duplicates = - filterAttrs (_: v: length v != 1) - (zipAttrs - (mapAttrsToList (n: v: { "${toString v.id}" = n; }) - (cfg.profiles))); + (let + duplicates = filterAttrs (_: v: length v != 1) (zipAttrs + (mapAttrsToList (n: v: { "${toString v.id}" = n; }) (cfg.profiles))); - mkMsg = n: v: " - ID ${n} is used by ${concatStringsSep ", " v}"; - in { - assertion = duplicates == {}; - message = - "Must not have Firefox profiles with duplicate IDs but\n" - + concatStringsSep "\n" (mapAttrsToList mkMsg duplicates); - } - ) + mkMsg = n: v: " - ID ${n} is used by ${concatStringsSep ", " v}"; + in { + assertion = duplicates == { }; + message = '' + Must not have Firefox profiles with duplicate IDs but + '' + concatStringsSep "\n" (mapAttrsToList mkMsg duplicates); + }) ]; warnings = optional (cfg.enableGnomeExtensions or false) '' @@ -282,65 +334,54 @@ in its example for how to do this. ''; - home.packages = - let - # The configuration expected by the Firefox wrapper. - fcfg = { - enableGnomeExtensions = cfg.enableGnomeExtensions; + home.packages = let + # The configuration expected by the Firefox wrapper. + fcfg = { enableGnomeExtensions = cfg.enableGnomeExtensions; }; + + # A bit of hackery to force a config into the wrapper. + browserName = cfg.package.browserName or (builtins.parseDrvName + cfg.package.name).name; + + # The configuration expected by the Firefox wrapper builder. + bcfg = setAttrByPath [ browserName ] fcfg; + + package = if isDarwin then + cfg.package + else if versionAtLeast config.home.stateVersion "19.09" then + cfg.package.override (old: { cfg = old.cfg or { } // fcfg; }) + else + (pkgs.wrapFirefox.override { config = bcfg; }) cfg.package { }; + in [ package ]; + + home.file = mkMerge ([{ + "${mozillaConfigPath}/${extensionPath}" = mkIf (cfg.extensions != [ ]) { + source = "${extensionsEnvPkg}/share/mozilla/${extensionPath}"; + recursive = true; + }; + + "${firefoxConfigPath}/profiles.ini" = + mkIf (cfg.profiles != { }) { text = profilesIni; }; + }] ++ flip mapAttrsToList cfg.profiles (_: profile: { + "${profilesPath}/${profile.path}/.keep".text = ""; + + "${profilesPath}/${profile.path}/chrome/userChrome.css" = + mkIf (profile.userChrome != "") { text = profile.userChrome; }; + + "${profilesPath}/${profile.path}/chrome/userContent.css" = + mkIf (profile.userContent != "") { text = profile.userContent; }; + + "${profilesPath}/${profile.path}/user.js" = + mkIf (profile.settings != { } || profile.extraConfig != "") { + text = + mkUserJs profile.settings profile.extraConfig profile.bookmarks; }; - # A bit of hackery to force a config into the wrapper. - browserName = cfg.package.browserName - or (builtins.parseDrvName cfg.package.name).name; - - # The configuration expected by the Firefox wrapper builder. - bcfg = setAttrByPath [browserName] fcfg; - - package = - if isDarwin then - cfg.package - else if versionAtLeast config.home.stateVersion "19.09" then - cfg.package.override (old: { cfg = old.cfg or {} // fcfg; }) - else - (pkgs.wrapFirefox.override { config = bcfg; }) cfg.package { }; - in - [ package ]; - - home.file = mkMerge ( - [{ - "${mozillaConfigPath}/${extensionPath}" = mkIf (cfg.extensions != []) { - source = "${extensionsEnvPkg}/share/mozilla/${extensionPath}"; - recursive = true; - }; - - "${firefoxConfigPath}/profiles.ini" = mkIf (cfg.profiles != {}) { - text = profilesIni; - }; - }] - ++ flip mapAttrsToList cfg.profiles (_: profile: { - "${profilesPath}/${profile.path}/.keep".text = ""; - - "${profilesPath}/${profile.path}/chrome/userChrome.css" = - mkIf (profile.userChrome != "") { - text = profile.userChrome; - }; - - "${profilesPath}/${profile.path}/chrome/userContent.css" = - mkIf (profile.userContent != "") { - text = profile.userContent; - }; - - "${profilesPath}/${profile.path}/user.js" = - mkIf (profile.settings != {} || profile.extraConfig != "") { - text = mkUserJs profile.settings profile.extraConfig; - }; - - "${profilesPath}/${profile.path}/extensions" = mkIf (cfg.extensions != []) { + "${profilesPath}/${profile.path}/extensions" = + mkIf (cfg.extensions != [ ]) { source = "${extensionsEnvPkg}/share/mozilla/${extensionPath}"; recursive = true; force = true; }; - }) - ); + })); }; } diff --git a/third_party/home-manager/modules/programs/fish.nix b/third_party/home-manager/modules/programs/fish.nix index f381960f6e..0387df799a 100644 --- a/third_party/home-manager/modules/programs/fish.nix +++ b/third_party/home-manager/modules/programs/fish.nix @@ -146,6 +146,16 @@ let (mapAttrsToList (k: v: "alias ${k} ${escapeShellArg v}") cfg.shellAliases); in { + imports = [ + (mkRemovedOptionModule [ "programs" "fish" "promptInit" ] '' + Prompt is now configured through the + + programs.fish.interactiveShellInit + + option. Please change to use that instead. + '') + ]; + options = { programs.fish = { enable = mkEnableOption "fish, the friendly interactive shell"; @@ -153,7 +163,7 @@ in { package = mkOption { type = types.package; default = pkgs.fish; - defaultText = literalExample "pkgs.fish"; + defaultText = literalExpression "pkgs.fish"; description = '' The fish package to install. May be used to change the version. ''; @@ -162,10 +172,10 @@ in { shellAliases = mkOption { type = with types; attrsOf str; default = { }; - example = literalExample '' + example = literalExpression '' { - ll = "ls -l"; - ".." = "cd .."; + g = "git"; + "..." = "cd ../.."; } ''; description = '' @@ -214,20 +224,12 @@ in { initialisation. ''; }; - - promptInit = mkOption { - type = types.lines; - default = ""; - description = '' - Shell script code used to initialise fish prompt. - ''; - }; }; programs.fish.plugins = mkOption { type = types.listOf pluginModule; default = [ ]; - example = literalExample '' + example = literalExpression '' [ { name = "z"; @@ -261,7 +263,7 @@ in { programs.fish.functions = mkOption { type = with types; attrsOf (either lines functionModule); default = { }; - example = literalExample '' + example = literalExpression '' { __fish_command_not_found_handler = { body = "__fish_default_command_not_found_handler $argv[1]"; @@ -340,41 +342,24 @@ in { # ~/.config/fish/config.fish: DO NOT EDIT -- this file has been generated # automatically by home-manager. - # if we haven't sourced the general config, do it - if not set -q __fish_general_config_sourced + # Only execute this file once per shell. + set -q __fish_home_manager_config_sourced; and exit + set -g __fish_home_manager_config_sourced 1 - set --prepend fish_function_path ${ - if pkgs ? fishPlugins && pkgs.fishPlugins ? foreign-env then - "${pkgs.fishPlugins.foreign-env}/share/fish/vendor_functions.d" - else - "${pkgs.fish-foreign-env}/share/fish-foreign-env/functions" - } - fenv source ${config.home.profileDirectory}/etc/profile.d/hm-session-vars.sh > /dev/null - set -e fish_function_path[1] + set --prepend fish_function_path ${pkgs.fishPlugins.foreign-env}/share/fish/vendor_functions.d + fenv source ${config.home.profileDirectory}/etc/profile.d/hm-session-vars.sh > /dev/null + set -e fish_function_path[1] - ${cfg.shellInit} - # and leave a note so we don't source this config section again from - # this very shell (children will source the general config anew) - set -g __fish_general_config_sourced 1 + ${cfg.shellInit} - end - - # if we haven't sourced the login config, do it - status --is-login; and not set -q __fish_login_config_sourced - and begin + status --is-login; and begin # Login shell initialisation ${cfg.loginShellInit} - # and leave a note so we don't source this config section again from - # this very shell (children will source the general config anew) - set -g __fish_login_config_sourced 1 - end - # if we haven't sourced the interactive config, do it - status --is-interactive; and not set -q __fish_interactive_config_sourced - and begin + status --is-interactive; and begin # Abbreviations ${abbrsStr} @@ -382,17 +367,9 @@ in { # Aliases ${aliasesStr} - # Prompt initialisation - ${cfg.promptInit} - # Interactive shell intialisation ${cfg.interactiveShellInit} - # and leave a note so we don't source this config section again from - # this very shell (children will source the general config anew, - # allowing configuration changes in, e.g, aliases, to propagate) - set -g __fish_interactive_config_sourced 1 - end ''; } diff --git a/third_party/home-manager/modules/programs/foot.nix b/third_party/home-manager/modules/programs/foot.nix index 8df201fd9f..e6c9dc5266 100644 --- a/third_party/home-manager/modules/programs/foot.nix +++ b/third_party/home-manager/modules/programs/foot.nix @@ -16,7 +16,7 @@ in { package = mkOption { type = types.package; default = pkgs.foot; - defaultText = literalExample "pkgs.foot"; + defaultText = literalExpression "pkgs.foot"; description = "The foot package to install"; }; @@ -31,7 +31,7 @@ in { xlink:href="https://codeberg.org/dnkl/foot/src/branch/master/foot.ini"/> for a list of available options. ''; - example = literalExample '' + example = literalExpression '' { main = { term = "xterm-256color"; @@ -49,6 +49,9 @@ in { }; config = mkIf cfg.enable { + assertions = + [ (hm.assertions.assertPlatform "programs.foot" pkgs platforms.linux) ]; + home.packages = [ cfg.package ]; xdg.configFile."foot/foot.ini" = mkIf (cfg.settings != { }) { diff --git a/third_party/home-manager/modules/programs/fzf.nix b/third_party/home-manager/modules/programs/fzf.nix index 6cdd894d2a..d8eef49c1d 100644 --- a/third_party/home-manager/modules/programs/fzf.nix +++ b/third_party/home-manager/modules/programs/fzf.nix @@ -18,7 +18,7 @@ in { package = mkOption { type = types.package; default = pkgs.fzf; - defaultText = literalExample "pkgs.fzf"; + defaultText = literalExpression "pkgs.fzf"; description = "Package providing the fzf tool."; }; @@ -96,7 +96,7 @@ in { shellIntegrationOptions = mkOption { type = types.listOf types.str; default = [ ]; - example = literalExample ''[ "-d 40%" ]''; + example = literalExpression ''[ "-d 40%" ]''; description = '' If is set to true, shell integration will use these options for fzf-tmux. @@ -146,19 +146,25 @@ in { FZF_TMUX_OPTS = cfg.tmux.shellIntegrationOptions; }); - programs.bash.initExtra = mkIf cfg.enableBashIntegration '' + # Note, since fzf unconditionally binds C-r we use `mkOrder` to make the + # initialization show up a bit earlier. This is to make initialization of + # other history managers, like mcfly or atuin, take precedence. + programs.bash.initExtra = mkIf cfg.enableBashIntegration (mkOrder 200 '' if [[ :$SHELLOPTS: =~ :(vi|emacs): ]]; then . ${cfg.package}/share/fzf/completion.bash . ${cfg.package}/share/fzf/key-bindings.bash fi - ''; + ''); - programs.zsh.initExtra = mkIf cfg.enableZshIntegration '' + # Note, since fzf unconditionally binds C-r we use `mkOrder` to make the + # initialization show up a bit earlier. This is to make initialization of + # other history managers, like mcfly or atuin, take precedence. + programs.zsh.initExtra = mkIf cfg.enableZshIntegration (mkOrder 200 '' if [[ $options[zle] = on ]]; then . ${cfg.package}/share/fzf/completion.zsh . ${cfg.package}/share/fzf/key-bindings.zsh fi - ''; + ''); programs.fish.shellInit = mkIf cfg.enableFishIntegration '' source ${cfg.package}/share/fzf/key-bindings.fish && fzf_key_bindings diff --git a/third_party/home-manager/modules/programs/getmail.nix b/third_party/home-manager/modules/programs/getmail.nix index eaf297cf2a..53e39b4399 100644 --- a/third_party/home-manager/modules/programs/getmail.nix +++ b/third_party/home-manager/modules/programs/getmail.nix @@ -55,6 +55,10 @@ in { }; config = mkIf getmailEnabled { + assertions = [ + (hm.assertions.assertPlatform "programs.getmail" pkgs platforms.linux) + ]; + home.file = foldl' (a: b: a // b) { } (map (a: { "${renderConfigFilepath a}".text = renderAccountConfig a; }) accounts); diff --git a/third_party/home-manager/modules/programs/gh.nix b/third_party/home-manager/modules/programs/gh.nix index 4cda4eab34..ba457c8cbd 100644 --- a/third_party/home-manager/modules/programs/gh.nix +++ b/third_party/home-manager/modules/programs/gh.nix @@ -6,50 +6,105 @@ let cfg = config.programs.gh; + yamlFormat = pkgs.formats.yaml { }; + + settingsType = types.submodule { + freeformType = yamlFormat.type; + # These options are only here for the mkRenamedOptionModule support + options = { + aliases = mkOption { + type = with types; attrsOf str; + default = { }; + example = literalExpression '' + { + co = "pr checkout"; + pv = "pr view"; + } + ''; + description = '' + Aliases that allow you to create nicknames for gh commands. + ''; + }; + editor = mkOption { + type = types.str; + default = ""; + description = '' + The editor that gh should run when creating issues, pull requests, etc. + If blank, will refer to environment. + ''; + }; + git_protocol = mkOption { + type = types.str; + default = "https"; + example = "ssh"; + description = '' + The protocol to use when performing Git operations. + ''; + }; + }; + }; + in { - meta.maintainers = [ maintainers.gerschtli ]; + meta.maintainers = [ maintainers.gerschtli maintainers.berbiche ]; + + imports = (map (x: + mkRenamedOptionModule [ "programs" "gh" x ] [ + "programs" + "gh" + "settings" + x + ]) [ "aliases" "editor" ]) ++ [ + (mkRenamedOptionModule [ "programs" "gh" "gitProtocol" ] [ + "programs" + "gh" + "settings" + "git_protocol" + ]) + ]; options.programs.gh = { enable = mkEnableOption "GitHub CLI tool"; - aliases = mkOption { - type = with types; attrsOf str; + package = mkOption { + type = types.package; + default = pkgs.gh; + defaultText = literalExpression "pkgs.gh"; + description = "Package providing gh."; + }; + + settings = mkOption { + type = settingsType; default = { }; - example = literalExample '' + description = + "Configuration written to $XDG_CONFIG_HOME/gh/config.yml."; + example = literalExpression '' { - co = "pr checkout"; - pv = "pr view"; - } - ''; - description = '' - Aliases that allow you to create nicknames for gh commands. + git_protocol = "ssh"; + + prompt = "enabled"; + + aliases = { + co = "pr checkout"; + pv = "pr view"; + }; + }; ''; }; - editor = mkOption { - type = types.str; - default = ""; - description = '' - The editor that gh should run when creating issues, pull requests, etc. - If blank, will refer to environment. - ''; - }; - - gitProtocol = mkOption { - type = types.enum [ "https" "ssh" ]; - default = "https"; - description = '' - The protocol to use when performing Git operations. - ''; - }; + enableGitCredentialHelper = + mkEnableOption "the gh git credential helper for github.com" // { + default = true; + }; }; config = mkIf cfg.enable { - home.packages = [ pkgs.gh ]; + home.packages = [ cfg.package ]; - xdg.configFile."gh/config.yml".text = builtins.toJSON { - inherit (cfg) aliases editor; - git_protocol = cfg.gitProtocol; - }; + xdg.configFile."gh/config.yml".source = + yamlFormat.generate "gh-config.yml" cfg.settings; + + programs.git.extraConfig.credential."https://github.com".helper = + mkIf cfg.enableGitCredentialHelper + "${cfg.package}/bin/gh auth git-credential"; }; } diff --git a/third_party/home-manager/modules/programs/git.nix b/third_party/home-manager/modules/programs/git.nix index 097fbf4b42..cf6ef3bcf4 100644 --- a/third_party/home-manager/modules/programs/git.nix +++ b/third_party/home-manager/modules/programs/git.nix @@ -108,8 +108,26 @@ let contents = mkOption { type = types.attrsOf types.anything; default = { }; + example = literalExpression '' + { + user = { + email = "bob@work.example.com"; + name = "Bob Work"; + signingKey = "1A2B3C4D5E6F7G8H"; + }; + commit = { + gpgSign = true; + }; + }; + ''; description = '' Configuration to include. If empty then a path must be given. + + This follows the configuration structure as described in + + git-config + 1 + . ''; }; }; @@ -128,7 +146,7 @@ in { package = mkOption { type = types.package; default = pkgs.git; - defaultText = literalExample "pkgs.git"; + defaultText = literalExpression "pkgs.git"; description = '' Git package to install. Use pkgs.gitAndTools.gitFull to gain access to git send-email for instance. @@ -195,7 +213,7 @@ in { includes = mkOption { type = types.listOf includeModule; default = [ ]; - example = literalExample '' + example = literalExpression '' [ { path = "~/path/to/config.inc"; } { @@ -295,7 +313,8 @@ in { "ssl") else ""; - smtpSslCertPath = mkIf smtp.tls.enable smtp.tls.certificatesFile; + smtpSslCertPath = + mkIf smtp.tls.enable (toString smtp.tls.certificatesFile); smtpServer = smtp.host; smtpUser = userName; from = address; diff --git a/third_party/home-manager/modules/programs/go.nix b/third_party/home-manager/modules/programs/go.nix index 4b85ec854a..8ec361b3d2 100644 --- a/third_party/home-manager/modules/programs/go.nix +++ b/third_party/home-manager/modules/programs/go.nix @@ -16,14 +16,14 @@ in { package = mkOption { type = types.package; default = pkgs.go; - defaultText = literalExample "pkgs.go"; + defaultText = literalExpression "pkgs.go"; description = "The Go package to use."; }; packages = mkOption { type = with types; attrsOf path; default = { }; - example = literalExample '' + example = literalExpression '' { "golang.org/x/text" = builtins.fetchGit "https://go.googlesource.com/text"; "golang.org/x/time" = builtins.fetchGit "https://go.googlesource.com/time"; diff --git a/third_party/home-manager/modules/programs/gpg.nix b/third_party/home-manager/modules/programs/gpg.nix index b1717adeb2..d32a819243 100644 --- a/third_party/home-manager/modules/programs/gpg.nix +++ b/third_party/home-manager/modules/programs/gpg.nix @@ -29,14 +29,14 @@ in package = mkOption { type = types.package; default = pkgs.gnupg; - defaultText = literalExample "pkgs.gnupg"; - example = literalExample "pkgs.gnupg23"; + defaultText = literalExpression "pkgs.gnupg"; + example = literalExpression "pkgs.gnupg23"; description = "The Gnupg package to use (also used the gpg-agent service)."; }; settings = mkOption { type = types.attrsOf (types.either primitiveType (types.listOf types.str)); - example = literalExample '' + example = literalExpression '' { no-comments = false; s2k-cipher-algo = "AES128"; @@ -54,7 +54,7 @@ in scdaemonSettings = mkOption { type = types.attrsOf (types.either primitiveType (types.listOf types.str)); - example = literalExample '' + example = literalExpression '' { disable-ccid = true; } @@ -68,9 +68,9 @@ in homedir = mkOption { type = types.path; - example = literalExample "\"\${config.xdg.dataHome}/gnupg\""; + example = literalExpression "\"\${config.xdg.dataHome}/gnupg\""; default = "${config.home.homeDirectory}/.gnupg"; - defaultText = literalExample "\"\${config.home.homeDirectory}/.gnupg\""; + defaultText = literalExpression "\"\${config.home.homeDirectory}/.gnupg\""; description = "Directory to store keychains and configuration."; }; }; diff --git a/third_party/home-manager/modules/programs/hexchat.nix b/third_party/home-manager/modules/programs/hexchat.nix new file mode 100644 index 0000000000..b0836758f1 --- /dev/null +++ b/third_party/home-manager/modules/programs/hexchat.nix @@ -0,0 +1,363 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.programs.hexchat; + + channelOptions = with types; + submodule { + options = { + autoconnect = mkOption { + type = nullOr bool; + default = false; + description = "Autoconnect to network."; + }; + + connectToSelectedServerOnly = mkOption { + type = nullOr bool; + default = true; + description = "Connect to selected server only."; + }; + + bypassProxy = mkOption { + type = nullOr bool; + default = true; + description = "Bypass proxy."; + }; + + forceSSL = mkOption { + type = nullOr bool; + default = false; + description = "Use SSL for all servers."; + }; + + acceptInvalidSSLCertificates = mkOption { + type = nullOr bool; + default = false; + description = "Accept invalid SSL certificates."; + }; + + useGlobalUserInformation = mkOption { + type = nullOr bool; + default = false; + description = "Use global user information."; + }; + }; + }; + + modChannelOption = with types; + submodule { + options = { + autojoin = mkOption { + type = listOf str; + default = [ ]; + example = [ "#home-manager" "#linux" "#nix" ]; + description = "Channels list to autojoin on connecting to server."; + }; + + charset = mkOption { + type = nullOr str; + default = null; + example = "UTF-8 (Unicode)"; + description = "Character set."; + }; + + commands = mkOption { + type = listOf str; + default = [ ]; + example = literalExpression ''[ "ECHO Greetings fellow Nixer! ]''; + description = "Commands to be executed on connecting to server."; + }; + + loginMethod = mkOption { + type = nullOr (enum (attrNames loginMethodMap)); + default = null; + description = '' + The login method. The allowed options are: + + + null + Default + + + "nickServMsg" + NickServ (/MSG NickServ + password) + + + "nickServ" + NickServ (/NICKSERV + password) + + + "challengeAuth" + Challenge Auth (username + password) + + + "sasl" + SASL (username + password) + + + "serverPassword" + Server password (/PASS password) + + + "saslExternal" + SASL EXTERNAL (cert) + + + "customCommands" + + Use "commands" field for auth. For example + + commands = [ "/msg NickServ IDENTIFY my_password" ] + + + + + + ''; + }; + + nickname = mkOption { + type = nullOr str; + default = null; + description = "Primary nickname."; + }; + + nickname2 = mkOption { + type = nullOr str; + default = null; + description = "Secondary nickname."; + }; + + options = mkOption { + type = nullOr channelOptions; + default = null; + example = { + autoconnect = true; + useGlobalUserInformation = true; + }; + description = "Channel options."; + }; + + password = mkOption { + type = nullOr str; + default = null; + description = '' + Password to use. Note this password will be readable by all user's + in the Nix store. + ''; + }; + + realName = mkOption { + type = nullOr str; + default = null; + description = '' + Real name. Is used to populate the real name field that appears when + someone uses the WHOIS command on your nick. + ''; + }; + + userName = mkOption { + type = nullOr str; + default = null; + description = '' + User name. Part of your user@host hostmask that + appears to other on IRC. + ''; + }; + + servers = mkOption { + type = listOf str; + default = [ ]; + example = [ "chat.freenode.net" "irc.freenode.net" ]; + description = "IRC Server Address List."; + }; + }; + }; + + transformField = k: v: if (v != null) then "${k}=${v}" else null; + + listChar = c: l: + if l != [ ] then concatMapStringsSep "\n" (transformField c) l else null; + + computeFieldsValue = channel: + let + ifTrue = p: n: if p then n else 0; + result = with channel.options; + foldl' (a: b: a + b) 0 [ + (ifTrue (!connectToSelectedServerOnly) 1) + (ifTrue useGlobalUserInformation 2) + (ifTrue forceSSL 4) + (ifTrue autoconnect 8) + (ifTrue (!bypassProxy) 16) + (ifTrue acceptInvalidSSLCertificates 32) + ]; + in toString (if channel.options == null then 0 else result); + + loginMethodMap = { + nickServMsg = 1; + nickServ = 2; + challengeAuth = 4; + sasl = 6; + serverPassword = 7; + customCommands = 9; + saslExternal = 10; + }; + + loginMethod = channel: + transformField "L" (optionalString (channel.loginMethod != null) + (toString loginMethodMap.${channel.loginMethod})); + + # Note: Missing option `D=`. + transformChannel = channelName: + let channel = cfg.channels.${channelName}; + in concatStringsSep "\n" (filter (v: v != null) [ + "" # leave a space between one server and another + (transformField "N" channelName) + (loginMethod channel) + (transformField "E" channel.charset) + (transformField "F" (computeFieldsValue channel)) + (transformField "I" channel.nickname) + (transformField "i" channel.nickname2) + (transformField "R" channel.realName) + (transformField "U" channel.userName) + (transformField "P" channel.password) + (listChar "S" channel.servers) + (listChar "J" channel.autojoin) + (listChar "C" channel.commands) + ]); + +in { + meta.maintainers = with maintainers; [ superherointj thiagokokada ]; + + options.programs.hexchat = with types; { + enable = mkEnableOption "HexChat, a graphical IRC client"; + + channels = mkOption { + type = attrsOf modChannelOption; + default = { }; + example = literalExpression '' + { + freenode = { + autojoin = [ + "#home-manager" + "#linux" + "#nixos" + ]; + charset = "UTF-8 (Unicode)"; + commands = [ + "ECHO Buzz Lightyear sent you a message: 'To Infinity... and Beyond!'" + ]; + loginMethod = sasl; + nickname = "my_nickname"; + nickname2 = "my_secondchoice"; + options = { + acceptInvalidSSLCertificates = false; + autoconnect = true; + bypassProxy = true; + connectToSelectedServerOnly = true; + useGlobalUserInformation = false; + forceSSL = false; + }; + password = "my_password"; + realName = "my_realname"; + servers = [ + "chat.freenode.net" + "irc.freenode.net" + ]; + userName = "my_username"; + }; + }''; + description = '' + Configures ~/.config/hexchat/servlist.conf. + ''; + }; + + settings = mkOption { + default = null; + type = nullOr (attrsOf str); + example = literalExpression '' + { + irc_nick1 = "mynick"; + irc_username = "bob"; + irc_realname = "Bart Simpson"; + text_font = "Monospace 14"; + }; + ''; + description = '' + Configuration for ~/.config/hexchat/hexchat.conf, see + + for supported values. + ''; + }; + + overwriteConfigFiles = mkOption { + type = nullOr bool; + default = false; + description = '' + Enables overwriting HexChat configuration files + (hexchat.conf, servlist.conf). + Any existing HexChat configuration will be lost. Certify to back-up any + previous configuration before enabling this. + + Enabling this setting is recommended, because everytime HexChat + application is closed it overwrites Nix/Home Manager provided + configuration files, causing: + + + Nix/Home Manager provided configuration to be out of sync with + actual active HexChat configuration. + + + Blocking Nix/Home Manager updates until configuration files are + manually removed. + + + ''; + }; + + theme = mkOption { + type = nullOr package; + default = null; + example = literalExpression '' + source = pkgs.fetchzip { + url = "https://dl.hexchat.net/themes/Monokai.hct#Monokai.zip"; + sha256 = "sha256-WCdgEr8PwKSZvBMs0fN7E2gOjNM0c2DscZGSKSmdID0="; + stripRoot = false; + }; + ''; + description = '' + Theme package for HexChat. Expects a derivation containing decompressed + theme files. Note, .hct files are actually ZIP files, + as seen in example. + ''; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + (hm.assertions.assertPlatform "programs.hexchat" pkgs platforms.linux) + ]; + + home.packages = [ pkgs.hexchat ]; + + xdg.configFile."hexchat" = mkIf (cfg.theme != null) { + source = cfg.theme; + recursive = true; + }; + + xdg.configFile."hexchat/hexchat.conf" = mkIf (cfg.settings != null) { + force = cfg.overwriteConfigFiles; + text = concatMapStringsSep "\n" (x: x + " = " + cfg.settings.${x}) + (attrNames cfg.settings); + }; + + xdg.configFile."hexchat/servlist.conf" = mkIf (cfg.channels != { }) { + force = cfg.overwriteConfigFiles; + # Final line breaks is required to avoid cropping last field value. + text = concatMapStringsSep "\n" transformChannel (attrNames cfg.channels) + + "\n\n"; + }; + }; +} diff --git a/third_party/home-manager/modules/programs/himalaya.nix b/third_party/home-manager/modules/programs/himalaya.nix index d7b6d31ccd..f4a0ffb3fe 100644 --- a/third_party/home-manager/modules/programs/himalaya.nix +++ b/third_party/home-manager/modules/programs/himalaya.nix @@ -45,7 +45,7 @@ in { package = mkOption { type = types.package; default = pkgs.himalaya; - defaultText = literalExample "pkgs.himalaya"; + defaultText = literalExpression "pkgs.himalaya"; description = '' Package providing the himalaya mail client. ''; @@ -54,7 +54,7 @@ in { settings = mkOption { type = tomlFormat.type; default = { }; - example = lib.literalExample '' + example = lib.literalExpression '' { default-page-size = 50; } @@ -76,7 +76,7 @@ in { settings = mkOption { type = tomlFormat.type; default = { }; - example = lib.literalExample '' + example = lib.literalExpression '' { default-page-size = 50; } diff --git a/third_party/home-manager/modules/programs/htop.nix b/third_party/home-manager/modules/programs/htop.nix index 1edd0f7ab6..1506aab5b6 100644 --- a/third_party/home-manager/modules/programs/htop.nix +++ b/third_party/home-manager/modules/programs/htop.nix @@ -10,14 +10,10 @@ let let v' = if isBool v then (if v then "1" else "0") else toString v; in "${n}=${v'}"; - formatMeters = side: meters: - let - warn' = warn "htop: meters should be passed as a list"; - meters' = if isList meters then meters else warn' [ meters ]; - in { - "${side}_meters" = concatMap (mapAttrsToList (x: _: x)) meters'; - "${side}_meter_modes" = concatMap (mapAttrsToList (_: y: y)) meters'; - }; + formatMeters = side: meters: { + "${side}_meters" = concatMap (mapAttrsToList (x: _: x)) meters; + "${side}_meter_modes" = concatMap (mapAttrsToList (_: y: y)) meters; + }; leftMeters = formatMeters "left"; rightMeters = formatMeters "right"; @@ -92,169 +88,16 @@ let led = meter modes.LED; blank = text "Blank"; - # Mapping from names to defaults - meters = { - Clock = 2; - Date = 2; - DateTime = 2; - LoadAverage = 2; - Load = 2; - Memory = 1; - Swap = 1; - Zram = 2; - HugePages = 2; - Tasks = 2; - Uptime = 2; - Battery = 2; - Hostname = 2; - AllCPUs = 1; - AllCPUs2 = 1; - AllCPUs4 = 1; - AllCPUs8 = 1; - LeftCPUs = 1; - RightCPUs = 1; - Right = 1; - CPUs = 1; - LeftCPUs2 = 1; - RightCPUs2 = 1; - LeftCPUs4 = 1; - RightCPUs4 = 1; - LeftCPUs8 = 1; - RightCPUs8 = 1; - Blank = 2; - PressureStallCPUSome = 2; - PressureStallIOSome = 2; - PressureStallIOFull = 2; - PressureStallMemorySome = 2; - PressureStallMemoryFull = 2; - ZFSARC = 2; - ZFSCARC = 2; - CPU = 1; - "CPU(1)" = 1; - "CPU(2)" = 1; - "CPU(3)" = 1; - "CPU(4)" = 1; - "CPU(5)" = 1; - "CPU(6)" = 1; - "CPU(7)" = 1; - "CPU(8)" = 1; - SELinux = 2; - Systemd = 2; - DiskIO = 2; - NetworkIO = 2; - }; - - singleMeterType = let - meterEnum = types.enum (attrNames meters); - meterSubmodule = types.submodule { - options = { - kind = mkOption { - type = types.enum (attrNames meters); - example = "AllCPUs"; - description = "What kind of meter."; - }; - - mode = mkOption { - type = types.enum [ 1 2 3 4 ]; - example = 2; - description = - "Which mode the meter should use, one of 1(Bar) 2(Text) 3(Graph) 4(LED)."; - }; - }; - }; - in types.coercedTo meterEnum (m: { - kind = m; - mode = meters.${m}; - }) meterSubmodule; - - meterType = types.submodule { - options = { - left = mkOption { - description = "Meters shown in the left header."; - default = [ "AllCPUs" "Memory" "Swap" ]; - example = [ - "Memory" - "LeftCPUs2" - "RightCPUs2" - { - kind = "CPU"; - mode = 3; - } - ]; - type = types.listOf singleMeterType; - }; - right = mkOption { - description = "Meters shown in the right header."; - default = [ "Tasks" "LoadAverage" "Uptime" ]; - example = [ - { - kind = "Clock"; - mode = 4; - } - "Uptime" - "Tasks" - ]; - type = types.listOf singleMeterType; - }; - }; - }; - in { + meta.maintainers = [ maintainers.bjpbakker ]; + options.programs.htop = { enable = mkEnableOption "htop"; settings = mkOption { type = types.attrs; - default = { - account_guest_in_cpu_meter = false; - color_scheme = 0; - cpu_count_from_zero = false; - delay = 15; - detailed_cpu_time = false; - enable_mouse = true; - fields = with fields; [ - PID - USER - PRIORITY - NICE - M_SIZE - M_RESIDENT - M_SHARE - STATE - PERCENT_CPU - PERCENT_MEM - TIME - COMM - ]; - header_margin = true; - hide_kernel_threads = true; - hide_threads = false; - hide_userland_threads = false; - highlight_base_name = false; - highlight_megabytes = true; - highlight_threads = true; - shadow_other_users = false; - show_cpu_frequency = false; - show_cpu_usage = false; - show_program_path = true; - show_thread_names = false; - sort_direction = 1; - sort_key = fields.PERCENT_CPU; - tree_view = false; - update_process_names = false; - vim_mode = false; - } // (leftMeters [ - (bar "AllCPUs2") - (bar "Memory") - (bar "Swap") - (text "Zram") - ]) // (rightMeters [ - (text "Tasks") - (text "LoadAverage") - (text "Uptime") - (text "Systemd") - ]); - example = literalExample '' + default = { }; + example = literalExpression '' { color_scheme = 6; cpu_count_from_one = 0; @@ -291,301 +134,14 @@ in { description = '' Configuration options to add to ~/.config/htop/htoprc. - - This superseedes any other (deprecated) settings in this module. ''; }; - fields = mkOption { - type = types.nullOr (types.listOf (types.enum (attrNames fields))); - default = null; - example = [ - "PID" - "USER" - "PRIORITY" - "PERCENT_CPU" - "M_RESIDENT" - "PERCENT_MEM" - "TIME" - "COMM" - ]; - description = '' - Deprecated. Please use programs.htop.settings.fields instead. - - Active fields shown in the table. - ''; - }; - - sortKey = mkOption { - type = types.nullOr (types.enum (attrNames fields)); - default = null; - example = "TIME"; - description = '' - Deprecated. Please use programs.htop.settings.sort_key instead. - - Which field to use for sorting. - ''; - }; - - sortDescending = mkOption { - type = types.nullOr types.bool; - default = null; - description = '' - Deprecated. Please use programs.htop.settings.sort_direction instead. - - Whether to sort descending or not. - ''; - }; - - hideThreads = mkOption { - type = types.nullOr types.bool; - default = null; - description = '' - Deprecated. Please use programs.htop.settings.hide_threads instead. - - Hide threads. - ''; - }; - - hideKernelThreads = mkOption { - type = types.nullOr types.bool; - default = null; - description = '' - Deprecated. Please use programs.htop.settings.hide_kernel_threads instead. - - Hide kernel threads. - ''; - }; - - hideUserlandThreads = mkOption { - type = types.nullOr types.bool; - default = null; - description = '' - Deprecated. Please use programs.htop.settings.hide_userland_threads instead. - - Hide userland process threads. - ''; - }; - - shadowOtherUsers = mkOption { - type = types.nullOr types.bool; - default = null; - description = '' - Deprecated. Please use programs.htop.settings.shadow_other_users instead. - - Shadow other users' processes. - ''; - }; - - showThreadNames = mkOption { - type = types.nullOr types.bool; - default = null; - description = '' - Deprecated. Please use programs.htop.settings.show_thread_names instead. - - Show custom thread names. - ''; - }; - - showProgramPath = mkOption { - type = types.nullOr types.bool; - default = null; - description = '' - Deprecated. Please use programs.htop.settings.show_program_path instead. - - Show program path. - ''; - }; - - highlightBaseName = mkOption { - type = types.nullOr types.bool; - default = null; - description = '' - Deprecated. Please use programs.htop.settings.highlight_base_name instead. - - Highlight program basename. - ''; - }; - - highlightMegabytes = mkOption { - type = types.nullOr types.bool; - default = null; - description = '' - Deprecated. Please use programs.htop.settings.highlight_megabytes instead. - - Highlight large numbers in memory counters. - ''; - }; - - highlightThreads = mkOption { - type = types.nullOr types.bool; - default = null; - description = '' - Deprecated. Please use programs.htop.settings.highlight_threads instead. - - Display threads in a different color. - ''; - }; - - treeView = mkOption { - type = types.nullOr types.bool; - default = null; - description = '' - Deprecated. Please use programs.htop.settings.tree_view instead. - - Tree view. - ''; - }; - - headerMargin = mkOption { - type = types.nullOr types.bool; - default = null; - description = '' - Deprecated. Please use programs.htop.settings.header_margin instead. - - Leave a margin around header. - ''; - }; - - detailedCpuTime = mkOption { - type = types.nullOr types.bool; - default = null; - description = '' - Deprecated. Please use programs.htop.settings.detailed_cpu_time instead. - - Detailed CPU time (System/IO-Wait/Hard-IRQ/Soft-IRQ/Steal/Guest). - ''; - }; - - cpuCountFromZero = mkOption { - type = types.nullOr types.bool; - default = null; - description = '' - Deprecated. Please use programs.htop.settings.cpu_count_from_zero instead. - - Count CPUs from 0 instead of 1. - ''; - }; - - showCpuUsage = mkOption { - type = types.nullOr types.bool; - default = null; - description = '' - Deprecated. Please use programs.htop.settings.show_cpu_usage instead. - - Show CPU usage frequency. - ''; - }; - - showCpuFrequency = mkOption { - type = types.nullOr types.bool; - default = null; - description = '' - Deprecated. Please use programs.htop.settings.show_cpu_frequency instead. - - Show CPU frequency. - ''; - }; - - updateProcessNames = mkOption { - type = types.nullOr types.bool; - default = null; - description = '' - Deprecated. Please use programs.htop.settings.update_process_names instead. - - Update process names on every refresh. - ''; - }; - - accountGuestInCpuMeter = mkOption { - type = types.nullOr types.bool; - default = null; - description = '' - Deprecated. Please use programs.htop.settings.account_guest_in_cpu_meter instead. - - Add guest time in CPU meter percentage. - ''; - }; - - colorScheme = mkOption { - type = types.nullOr (types.enum [ 0 1 2 3 4 5 6 ]); - default = null; - example = 6; - description = '' - Deprecated. Please use programs.htop.settings.color_scheme instead. - - Which color scheme to use. - ''; - }; - - enableMouse = mkOption { - type = types.nullOr types.bool; - default = null; - description = '' - Deprecated. Please use programs.htop.settings.enable_mouse instead. - - Enable mouse support. - ''; - }; - - delay = mkOption { - type = types.nullOr types.int; - default = null; - example = 2; - description = '' - Deprecated. Please use programs.htop.settings.delay instead. - - Set the delay between updates, in tenths of seconds. - ''; - }; - - meters = mkOption { - description = '' - Deprecated. Please use programs.htop.settings.left_meters, - programs.htop.settings.left_meter_modes, - programs.htop.settings.right_meters and - programs.htop.settings.right_meter_modes instead. Or consider using - lib.htop.leftMeters and lib.htop.rightMeters. - - Meters shown in the header. - ''; - default = null; - example = { - left = [ - "Memory" - "CPU" - "LeftCPUs2" - "RightCPUs2" - { - kind = "CPU"; - mode = 3; - } - ]; - right = [ - { - kind = "Clock"; - mode = 4; - } - "Uptime" - "Tasks" - "LoadAverage" - { - kind = "Battery"; - mode = 1; - } - ]; - }; - type = types.nullOr meterType; - }; - - vimMode = mkOption { - type = types.nullOr types.bool; - default = null; - description = '' - Deprecated. Please use programs.htop.settings.vim_mode instead. - - Vim key bindings. - ''; + package = mkOption { + type = types.package; + default = pkgs.htop; + defaultText = literalExpression "pkgs.htop"; + description = "Package containing the htop program."; }; }; @@ -594,74 +150,38 @@ in { inherit fields modes leftMeters rightMeters bar text graph led blank; }; - home.packages = [ pkgs.htop ]; + home.packages = [ cfg.package ]; - xdg.configFile."htop/htoprc".text = let + xdg.configFile."htop/htoprc" = let + defaults = { + fields = with fields; [ + PID + USER + PRIORITY + NICE + M_SIZE + M_RESIDENT + M_SHARE + STATE + PERCENT_CPU + PERCENT_MEM + TIME + COMM + ]; + }; - deprecate = settingsKey: optionKey: optionValue: - let - warn' = warn - "htop: programs.htop.${optionKey} is deprecated; please is programs.htop.settings.${settingsKey} instead"; - in if !isNull optionValue then - warn' optionValue - else if hasAttr settingsKey cfg.settings then - cfg.settings.${settingsKey} - else - null; + before = optionalAttrs (cfg.settings ? header_layout) { + inherit (cfg.settings) header_layout; + }; - deprecate' = settingsKey: optionKey: - deprecate settingsKey optionKey cfg.${optionKey}; + settings = defaults // (removeAttrs cfg.settings (attrNames before)); - ifNonNull = x: y: if isNull x then null else y; + formatOptions = mapAttrsToList formatOption; - leftMeters = deprecate "left_meters" "meters.left" - (ifNonNull cfg.meters (map (m: m.kind) cfg.meters.left)); - leftModes = deprecate "left_meter_modes" "meters.left" - (ifNonNull cfg.meters (map (m: m.mode) cfg.meters.left)); - rightMeters = deprecate "right_meters" "meters.right" - (ifNonNull cfg.meters (map (m: m.kind) cfg.meters.right)); - rightModes = deprecate "right_meter_modes" "meters.right" - (ifNonNull cfg.meters (map (m: m.mode) cfg.meters.right)); - - settings' = cfg.settings // (filterAttrs (_: v: !isNull v) { - fields = deprecate "fields" "fields" - (ifNonNull cfg.fields (map (n: fields.${n}) cfg.fields)); - sort_key = deprecate "sort_key" "sortKey" - (ifNonNull cfg.sortKey fields.${cfg.sortKey}); - sort_direction = deprecate' "sort_direction" "sortDescending"; - hide_threads = deprecate' "hide_threads" "hideThreads"; - hide_kernel_threads = - deprecate' "hide_kernel_threads" "hideKernelThreads"; - hide_userland_threads = - deprecate' "hide_userland_threads" "hideUserlandThreads"; - shadow_other_users = deprecate' "shadow_other_users" "shadowOtherUsers"; - show_thread_names = deprecate' "show_thread_names" "showThreadNames"; - show_program_path = deprecate' "show_program_path" "showProgramPath"; - highlight_base_name = - deprecate' "highlight_base_name" "highlightBaseName"; - highlight_megabytes = - deprecate' "highlight_megabytes" "highlightMegabytes"; - highlight_threads = deprecate' "highlight_threads" "highlightThreads"; - tree_view = deprecate' "tree_view" "treeView"; - header_margin = deprecate' "header_margin" "headerMargin"; - detailed_cpu_time = deprecate' "detailed_cpu_time" "detailedCpuTime"; - cpu_count_from_zero = - deprecate' "cpu_count_from_zero" "cpuCountFromZero"; - show_cpu_usage = deprecate' "show_cpu_usage" "showCpuUsage"; - show_cpu_frequency = deprecate' "show_cpu_frequency" "showCpuFrequency"; - update_process_names = - deprecate' "update_process_names" "updateProcessNames"; - account_guest_in_cpu_meter = - deprecate' "account_guest_in_cpu_meter" "accountGuestInCpuMeter"; - color_scheme = deprecate' "color_scheme" "colorScheme"; - enable_mouse = deprecate' "enable_mouse" "enableMouse"; - delay = deprecate' "delay" "delay"; - left_meters = leftMeters; - left_meter_modes = leftModes; - right_meters = rightMeters; - right_meter_modes = rightModes; - vim_mode = deprecate' "vim_mode" "vimMode"; - }); - in concatStringsSep "\n" (mapAttrsToList formatOption settings'); + in mkIf (cfg.settings != { }) { + text = + concatStringsSep "\n" (formatOptions before ++ formatOptions settings) + + "\n"; + }; }; } diff --git a/third_party/home-manager/modules/programs/i3status-rust.nix b/third_party/home-manager/modules/programs/i3status-rust.nix index 5d721cc509..69785fea37 100644 --- a/third_party/home-manager/modules/programs/i3status-rust.nix +++ b/third_party/home-manager/modules/programs/i3status-rust.nix @@ -6,14 +6,6 @@ let cfg = config.programs.i3status-rust; - restartI3 = '' - i3Socket=''${XDG_RUNTIME_DIR:-/run/user/$UID}/i3/ipc-socket.* - if [ -S $i3Socket ]; then - echo "Reloading i3" - $DRY_RUN_CMD ${config.xsession.windowManager.i3.package}/bin/i3-msg -s $i3Socket restart 1>/dev/null - fi - ''; - settingsFormat = pkgs.formats.toml { }; in { @@ -67,7 +59,7 @@ in { for block options. ''; - example = literalExample '' + example = literalExpression '' [ { block = "disk_space"; @@ -99,7 +91,7 @@ in { Any extra options to add to i3status-rust config. ''; - example = literalExample '' + example = literalExpression '' { theme = { name = "solarized-dark"; @@ -189,7 +181,7 @@ in { for options. ''; - example = literalExample '' + example = literalExpression '' bottom = { blocks = [ { @@ -242,18 +234,28 @@ in { package = mkOption { type = types.package; default = pkgs.i3status-rust; - defaultText = literalExample "pkgs.i3status-rust"; + defaultText = literalExpression "pkgs.i3status-rust"; description = "Package providing i3status-rust"; }; }; config = mkIf cfg.enable { + assertions = [ + (hm.assertions.assertPlatform "programs.i3status-rust" pkgs + platforms.linux) + ]; + home.packages = [ cfg.package ]; xdg.configFile = mapAttrs' (cfgFileSuffix: cfg: nameValuePair ("i3status-rust/config-${cfgFileSuffix}.toml") ({ - onChange = mkIf config.xsession.windowManager.i3.enable restartI3; + onChange = mkIf config.xsession.windowManager.i3.enable '' + i3Socket="''${XDG_RUNTIME_DIR:-/run/user/$UID}/i3/ipc-socket.*" + if [[ -S $i3Socket ]]; then + ${config.xsession.windowManager.i3.package}/bin/i3-msg -s $i3Socket restart >/dev/null + fi + ''; source = settingsFormat.generate ("config-${cfgFileSuffix}.toml") ({ theme = cfg.theme; diff --git a/third_party/home-manager/modules/programs/i3status.nix b/third_party/home-manager/modules/programs/i3status.nix index c1e12fe71d..ca1f133e48 100644 --- a/third_party/home-manager/modules/programs/i3status.nix +++ b/third_party/home-manager/modules/programs/i3status.nix @@ -60,7 +60,7 @@ in { for options. ''; - example = literalExample '' + example = literalExpression '' { colors = true; color_good = "#e0e0e0"; @@ -99,7 +99,7 @@ in { for options. ''; - example = literalExample '' + example = literalExpression '' { format = "♪ %volume"; format_muted = "♪ muted (%volume)"; @@ -119,7 +119,7 @@ in { for options. ''; - example = literalExample '' + example = literalExpression '' { "volume master" = { position = 1; diff --git a/third_party/home-manager/modules/programs/irssi.nix b/third_party/home-manager/modules/programs/irssi.nix index af9e16fc72..a8f8a22ff7 100644 --- a/third_party/home-manager/modules/programs/irssi.nix +++ b/third_party/home-manager/modules/programs/irssi.nix @@ -7,53 +7,51 @@ let cfg = config.programs.irssi; boolStr = b: if b then "yes" else "no"; - quoteStr = s: escape ["\""] s; + quoteStr = s: escape [ ''"'' ] s; + + # Comma followed by newline. + cnl = '' + , + ''; assignFormat = set: concatStringsSep "\n" - (mapAttrsToList (k: v: " ${k} = \"${quoteStr v}\";") set); + (mapAttrsToList (k: v: " ${k} = \"${quoteStr v}\";") set); - chatnetString = - concatStringsSep "\n" - (flip mapAttrsToList cfg.networks - (k: v: '' - ${k} = { - type = "${v.type}"; - nick = "${quoteStr v.nick}"; - autosendcmd = "${concatMapStringsSep ";" quoteStr v.autoCommands}"; - }; - '')); + chatnetString = concatStringsSep "\n" (flip mapAttrsToList cfg.networks + (k: v: '' + ${k} = { + type = "${v.type}"; + nick = "${quoteStr v.nick}"; + autosendcmd = "${concatMapStringsSep ";" quoteStr v.autoCommands}"; + }; + '')); - serversString = - concatStringsSep ",\n" - (flip mapAttrsToList cfg.networks - (k: v: '' - { - chatnet = "${k}"; - address = "${v.server.address}"; - port = "${toString v.server.port}"; - use_ssl = "${boolStr v.server.ssl.enable}"; - ssl_verify = "${boolStr v.server.ssl.verify}"; - autoconnect = "${boolStr v.server.autoConnect}"; - ${lib.optionalString (v.server.ssl.certificateFile != null) '' - ssl_cert = "${v.server.ssl.certificateFile}"; - ''} + serversString = concatStringsSep cnl (flip mapAttrsToList cfg.networks + (k: v: '' + { + chatnet = "${k}"; + address = "${v.server.address}"; + port = "${toString v.server.port}"; + use_ssl = "${boolStr v.server.ssl.enable}"; + ssl_verify = "${boolStr v.server.ssl.verify}"; + autoconnect = "${boolStr v.server.autoConnect}"; + ${ + lib.optionalString (v.server.ssl.certificateFile != null) '' + ssl_cert = "${v.server.ssl.certificateFile}"; + '' } - '')); + } + '')); - channelString = - concatStringsSep ",\n" - (flip mapAttrsToList cfg.networks - (k: v: - concatStringsSep ",\n" - (flip mapAttrsToList v.channels - (c: cv: '' - { - chatnet = "${k}"; - name = "${c}"; - autojoin = "${boolStr cv.autoJoin}"; - } - '')))); + channelString = concatStringsSep cnl (flip mapAttrsToList cfg.networks (k: v: + concatStringsSep cnl (flip mapAttrsToList v.channels (c: cv: '' + { + chatnet = "${k}"; + name = "${c}"; + autojoin = "${boolStr cv.autoJoin}"; + } + '')))); channelType = types.submodule { options = { @@ -72,7 +70,7 @@ let }; }; - networkType = types.submodule ({ name, ...}: { + networkType = types.submodule ({ name, ... }: { options = { name = mkOption { visible = false; @@ -93,7 +91,7 @@ let autoCommands = mkOption { type = types.listOf types.str; - default = []; + default = [ ]; description = "List of commands to execute on connect."; }; @@ -142,14 +140,12 @@ let channels = mkOption { description = "Channels for the given network."; type = types.attrsOf channelType; - default = {}; + default = { }; }; }; }); -in - -{ +in { options = { programs.irssi = { @@ -162,15 +158,18 @@ in }; aliases = mkOption { - default = {}; - example = { J = "join"; BYE = "quit";}; + default = { }; + example = { + J = "join"; + BYE = "quit"; + }; description = "An attribute set that maps aliases to commands."; type = types.attrsOf types.str; }; networks = mkOption { - default = {}; - example = literalExample '' + default = { }; + example = literalExpression '' { freenode = { nick = "hmuser"; diff --git a/third_party/home-manager/modules/programs/java.nix b/third_party/home-manager/modules/programs/java.nix new file mode 100644 index 0000000000..5b2a012996 --- /dev/null +++ b/third_party/home-manager/modules/programs/java.nix @@ -0,0 +1,46 @@ +# This module provides JAVA_HOME, with a different way to install java locally. +# This module is modified from the NixOS module `programs.java` + +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.programs.java; + +in { + meta.maintainers = with maintainers; [ ShamrockLee ]; + + options = { + programs.java = { + enable = mkEnableOption "" // { + description = '' + Install the Java development kit and set the JAVA_HOME + variable. + ''; + }; + + package = mkOption { + type = types.package; + default = pkgs.jdk; + defaultText = "pkgs.jdk"; + description = '' + Java package to install. Typical values are + pkgs.jdk or pkgs.jre. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ cfg.package ]; + + home.sessionVariables = { + JAVA_HOME = fileContents (pkgs.runCommandLocal "java-home" { } '' + source "${cfg.package}/nix-support/setup-hook" + echo "$JAVA_HOME" > $out + ''); + }; + }; +} diff --git a/third_party/home-manager/modules/programs/jq.nix b/third_party/home-manager/modules/programs/jq.nix index 764629918a..e810f88451 100644 --- a/third_party/home-manager/modules/programs/jq.nix +++ b/third_party/home-manager/modules/programs/jq.nix @@ -33,7 +33,7 @@ in { package = mkOption { type = types.package; default = pkgs.jq; - defaultText = literalExample "pkgs.jq"; + defaultText = literalExpression "pkgs.jq"; description = "jq package to use."; }; @@ -44,7 +44,7 @@ in { See . ''; - example = literalExample '' + example = literalExpression '' { null = "1;30"; false = "0;31"; diff --git a/third_party/home-manager/modules/programs/kakoune.nix b/third_party/home-manager/modules/programs/kakoune.nix index 01b30167da..49f259d012 100644 --- a/third_party/home-manager/modules/programs/kakoune.nix +++ b/third_party/home-manager/modules/programs/kakoune.nix @@ -642,7 +642,7 @@ in { plugins = mkOption { type = with types; listOf package; default = [ ]; - example = literalExample "[ pkgs.kakounePlugins.kak-fzf ]"; + example = literalExpression "[ pkgs.kakounePlugins.kak-fzf ]"; description = '' List of kakoune plugins to install. To get a list of supported plugins run: diff --git a/third_party/home-manager/modules/programs/keychain.nix b/third_party/home-manager/modules/programs/keychain.nix index 6e26bd232c..9a25702f3f 100644 --- a/third_party/home-manager/modules/programs/keychain.nix +++ b/third_party/home-manager/modules/programs/keychain.nix @@ -24,7 +24,7 @@ in { package = mkOption { type = types.package; default = pkgs.keychain; - defaultText = literalExample "pkgs.keychain"; + defaultText = literalExpression "pkgs.keychain"; description = '' Keychain package to install. ''; diff --git a/third_party/home-manager/modules/programs/kitty.nix b/third_party/home-manager/modules/programs/kitty.nix index 3fa4452e64..6d3d4d00d8 100644 --- a/third_party/home-manager/modules/programs/kitty.nix +++ b/third_party/home-manager/modules/programs/kitty.nix @@ -25,14 +25,30 @@ let mkKeyValue = key: command: "map ${key} ${command}"; }; + toKittyEnv = + generators.toKeyValue { mkKeyValue = name: value: "env ${name}=${value}"; }; + in { options.programs.kitty = { enable = mkEnableOption "Kitty terminal emulator"; + darwinLaunchOptions = mkOption { + type = types.nullOr (types.listOf types.str); + default = null; + description = "Command-line options to use when launched by Mac OS GUI"; + example = literalExpression '' + [ + "--single-instance" + "--directory=/tmp/my-dir" + "--listen-on=unix:/tmp/my-socket" + ] + ''; + }; + settings = mkOption { type = types.attrsOf eitherStrBoolInt; default = { }; - example = literalExample '' + example = literalExpression '' { scrollback_lines = 10000; enable_audio_bell = false; @@ -57,7 +73,7 @@ in { type = types.attrsOf types.str; default = { }; description = "Mapping of keybindings to actions."; - example = literalExample '' + example = literalExpression '' { "ctrl+c" = "copy_or_interrupt"; "ctrl+f>2" = "set_font_size 20"; @@ -65,6 +81,17 @@ in { ''; }; + environment = mkOption { + type = types.attrsOf types.str; + default = { }; + description = "Environment variables to set or override."; + example = literalExpression '' + { + "LS_COLORS" = "1"; + } + ''; + }; + extraConfig = mkOption { default = ""; type = types.lines; @@ -73,23 +100,44 @@ in { }; config = mkIf cfg.enable { + assertions = [{ + assertion = (cfg.darwinLaunchOptions != null) + -> pkgs.stdenv.hostPlatform.isDarwin; + message = '' + The 'programs.kitty.darwinLaunchOptions' option is only available on darwin. + ''; + }]; + home.packages = [ pkgs.kitty ] ++ optionalPackage cfg.font; - xdg.configFile."kitty/kitty.conf".text = '' - # Generated by Home Manager. - # See https://sw.kovidgoyal.net/kitty/conf.html + xdg.configFile."kitty/kitty.conf" = { + text = '' + # Generated by Home Manager. + # See https://sw.kovidgoyal.net/kitty/conf.html - ${optionalString (cfg.font != null) '' - font_family ${cfg.font.name} - ${optionalString (cfg.font.size != null) - "font_size ${toString cfg.font.size}"} - ''} + ${optionalString (cfg.font != null) '' + font_family ${cfg.font.name} + ${optionalString (cfg.font.size != null) + "font_size ${toString cfg.font.size}"} + ''} - ${toKittyConfig cfg.settings} + ${toKittyConfig cfg.settings} - ${toKittyKeybindings cfg.keybindings} + ${toKittyKeybindings cfg.keybindings} - ${cfg.extraConfig} - ''; + ${toKittyEnv cfg.environment} + + ${cfg.extraConfig} + ''; + } // optionalAttrs pkgs.stdenv.hostPlatform.isLinux { + onChange = '' + ${pkgs.procps}/bin/pkill -USR1 -u $USER kitty || true + ''; + }; + + xdg.configFile."kitty/macos-launch-services-cmdline" = + mkIf (cfg.darwinLaunchOptions != null) { + text = concatStringsSep " " cfg.darwinLaunchOptions; + }; }; } diff --git a/third_party/home-manager/modules/programs/lazygit.nix b/third_party/home-manager/modules/programs/lazygit.nix index 6d4a2bd403..f2d516200f 100644 --- a/third_party/home-manager/modules/programs/lazygit.nix +++ b/third_party/home-manager/modules/programs/lazygit.nix @@ -19,8 +19,8 @@ in { settings = mkOption { type = yamlFormat.type; default = { }; - defaultText = literalExample "{ }"; - example = literalExample '' + defaultText = literalExpression "{ }"; + example = literalExpression '' { gui.theme = { lightTheme = true; diff --git a/third_party/home-manager/modules/programs/lf.nix b/third_party/home-manager/modules/programs/lf.nix index ee4e9b5bfc..06333e9c99 100644 --- a/third_party/home-manager/modules/programs/lf.nix +++ b/third_party/home-manager/modules/programs/lf.nix @@ -117,7 +117,7 @@ in { cmdKeybindings = mkOption { type = with types; attrsOf (nullOr str); default = { }; - example = literalExample ''{ "" = "cmd-escape"; }''; + example = literalExpression ''{ "" = "cmd-escape"; }''; description = '' Keys to bind to command line commands which can only be one of the builtin commands. Keys set to null or an empty string are deleted. @@ -127,7 +127,7 @@ in { previewer.source = mkOption { type = with types; nullOr path; default = null; - example = literalExample '' + example = literalExpression '' pkgs.writeShellScript "pv.sh" ''' #!/bin/sh diff --git a/third_party/home-manager/modules/programs/lieer-accounts.nix b/third_party/home-manager/modules/programs/lieer-accounts.nix deleted file mode 100644 index 238049065b..0000000000 --- a/third_party/home-manager/modules/programs/lieer-accounts.nix +++ /dev/null @@ -1,69 +0,0 @@ -{ lib, ... }: - -with lib; - -{ - options.lieer = { - enable = mkEnableOption "lieer Gmail synchronization for notmuch"; - - timeout = mkOption { - type = types.ints.unsigned; - default = 0; - description = '' - HTTP timeout in seconds. 0 means forever or system timeout. - ''; - }; - - replaceSlashWithDot = mkOption { - type = types.bool; - default = false; - description = '' - Replace '/' with '.' in Gmail labels. - ''; - }; - - dropNonExistingLabels = mkOption { - type = types.bool; - default = false; - description = '' - Allow missing labels on the Gmail side to be dropped. - ''; - }; - - ignoreTagsLocal = mkOption { - type = types.listOf types.str; - default = [ ]; - description = '' - Set custom tags to ignore when syncing from local to - remote (after translations). - ''; - }; - - ignoreTagsRemote = mkOption { - type = types.listOf types.str; - default = [ - "CATEGORY_FORUMS" - "CATEGORY_PROMOTIONS" - "CATEGORY_UPDATES" - "CATEGORY_SOCIAL" - "CATEGORY_PERSONAL" - ]; - description = '' - Set custom tags to ignore when syncing from remote to - local (before translations). - ''; - }; - - notmuchSetupWarning = mkOption { - type = types.bool; - default = true; - description = '' - Warn if Notmuch is not also enabled for this account. - - This can safely be disabled if notmuch init - has been used to configure this account outside of Home - Manager. - ''; - }; - }; -} diff --git a/third_party/home-manager/modules/programs/lieer.nix b/third_party/home-manager/modules/programs/lieer.nix index e34a247af4..e0369ffc66 100644 --- a/third_party/home-manager/modules/programs/lieer.nix +++ b/third_party/home-manager/modules/programs/lieer.nix @@ -23,30 +23,231 @@ let map (name: "accounts.email.accounts.${name}.notmuch.enable = true;") missingNotmuchAccounts; + settingsFormat = pkgs.formats.json { }; + configFile = account: { name = "${account.maildir.absPath}/.gmailieer.json"; - value = { - text = builtins.toJSON { - inherit (account.lieer) timeout; - account = account.address; - replace_slash_with_dot = account.lieer.replaceSlashWithDot; - drop_non_existing_label = account.lieer.dropNonExistingLabels; - ignore_tags = account.lieer.ignoreTagsLocal; - ignore_remote_labels = account.lieer.ignoreTagsRemote; - } + "\n"; + value.source = settingsFormat.generate "lieer-${account.address}.json" + ({ account = account.address; } // account.lieer.settings); + }; + + settingsOpts = { + drop_non_existing_label = mkOption { + type = types.bool; + default = false; + description = '' + Allow missing labels on the Gmail side to be dropped. + ''; + }; + + file_extension = mkOption { + type = types.str; + default = ""; + example = "mbox"; + description = '' + Extension to include in local file names, which can be useful + for indexing with third-party programs. + ''; + }; + + ignore_empty_history = mkOption { + type = types.bool; + default = false; + description = '' + Work around a Gmail API quirk where an empty change history + is sometimes returned. + + See this + GitHub issue + for more details. + ''; + }; + + ignore_remote_labels = mkOption { + type = types.listOf types.str; + default = [ + "CATEGORY_FORUMS" + "CATEGORY_PROMOTIONS" + "CATEGORY_UPDATES" + "CATEGORY_SOCIAL" + "CATEGORY_PERSONAL" + ]; + description = '' + Set Gmail labels to ignore when syncing from remote labels to + local tags (before translations). + ''; + }; + + ignore_tags = mkOption { + type = types.listOf types.str; + default = [ ]; + description = '' + Set labels to ignore when syncing from local tags to + remote labels (after translations). + ''; + }; + + local_trash_tag = mkOption { + type = types.str; + default = "trash"; + description = '' + Local tag to which the remote Gmail 'TRASH' label is translated. + ''; + }; + + remove_local_messages = mkOption { + type = types.bool; + default = true; + description = '' + Remove local messages that have been deleted on the remote. + ''; + }; + + replace_slash_with_dot = mkOption { + type = types.bool; + default = false; + description = '' + Replace '/' with '.' in Gmail labels. + ''; + }; + + timeout = mkOption { + type = types.ints.unsigned; + default = 600; + description = '' + HTTP timeout in seconds. 0 means forever or system timeout. + ''; }; }; + syncOpts = { + enable = mkEnableOption "lieer synchronization service"; + + frequency = mkOption { + type = types.str; + default = "*:0/5"; + description = '' + How often to synchronize the account. + + This value is passed to the systemd timer configuration as the + onCalendar option. See + + systemd.time + 7 + + for more information about the format. + ''; + }; + }; + + lieerOpts = { + enable = mkEnableOption "lieer Gmail synchronization for notmuch"; + + notmuchSetupWarning = mkOption { + type = types.bool; + default = true; + description = '' + Warn if Notmuch is not also enabled for this account. + + This can safely be disabled if notmuch init + has been used to configure this account outside of Home + Manager. + ''; + }; + + settings = mkOption { + type = types.submodule { + freeformType = settingsFormat.type; + options = settingsOpts; + }; + default = { }; + description = '' + Settings which are applied to .gmailieer.json + for the account. + + See the lieer manual + for documentation of settings not explicitly covered by this module. + ''; + }; + + sync = syncOpts; + }; + + lieerModule = types.submodule { + imports = [ + (mkRenamedOptionModule [ "lieer" "dropNonExistingLabels" ] [ + "lieer" + "settings" + "drop_non_existing_label" + ]) + (mkRenamedOptionModule [ "lieer" "ignoreTagsRemote" ] [ + "lieer" + "settings" + "ignore_remote_labels" + ]) + (mkRenamedOptionModule [ "lieer" "ignoreTagsLocal" ] [ + "lieer" + "settings" + "ignore_tags" + ]) + (mkRenamedOptionModule [ "lieer" "timeout" ] [ + "lieer" + "settings" + "timeout" + ]) + (mkRenamedOptionModule [ "lieer" "replaceSlashWithDot" ] [ + "lieer" + "settings" + "replace_slash_with_dot" + ]) + ]; + + options = { + lieer = lieerOpts; + + warnings = mkOption { + type = types.listOf types.str; + default = [ ]; + internal = true; + visible = false; + }; + }; + }; + + renamedOptions = account: + let prefix = [ "accounts" "email" "accounts" account.name "lieer" ]; + in [ + (mkRenamedOptionModule (prefix ++ [ "dropNonExistingLabels" ]) + (prefix ++ [ "settings" "drop_non_existing_label" ])) + (mkRenamedOptionModule (prefix ++ [ "ignoreTagsRemote" ]) + (prefix ++ [ "settings" "ignore_remote_labels" ])) + (mkRenamedOptionModule (prefix ++ [ "ignoreTagsLocal" ]) + (prefix ++ [ "settings" "ignore_tags" ])) + (mkRenamedOptionModule (prefix ++ [ "timeout" ]) + (prefix ++ [ "settings" "timeout" ])) + (mkRenamedOptionModule (prefix ++ [ "replaceSlashWithDot" ]) + (prefix ++ [ "settings" "replace_slash_with_dot" ])) + ]; + in { meta.maintainers = [ maintainers.tadfisher ]; options = { - programs.lieer.enable = - mkEnableOption "lieer Gmail synchronization for notmuch"; + programs.lieer = { + enable = mkEnableOption "lieer Gmail synchronization for notmuch"; - accounts.email.accounts = mkOption { - type = with types; attrsOf (submodule (import ./lieer-accounts.nix)); + package = mkOption { + type = types.package; + default = pkgs.gmailieer; + defaultText = "pkgs.gmailieer"; + description = '' + lieer package to use. + ''; + }; }; + + accounts.email.accounts = + mkOption { type = with types; attrsOf lieerModule; }; }; config = mkIf cfg.enable (mkMerge [ @@ -82,7 +283,9 @@ in { ''; }]; - home.packages = [ pkgs.gmailieer ]; + warnings = flatten (map (account: account.warnings) lieerAccounts); + + home.packages = [ cfg.package ]; # Notmuch should ignore non-mail files created by lieer. programs.notmuch.new.ignore = [ "/.*[.](json|lock|bak)$/" ]; diff --git a/third_party/home-manager/modules/programs/mangohud.nix b/third_party/home-manager/modules/programs/mangohud.nix index 3a2158e3d6..0f14a8c63a 100644 --- a/third_party/home-manager/modules/programs/mangohud.nix +++ b/third_party/home-manager/modules/programs/mangohud.nix @@ -31,7 +31,7 @@ in { package = mkOption { type = types.package; default = pkgs.mangohud; - defaultText = literalExample "pkgs.mangohud"; + defaultText = literalExpression "pkgs.mangohud"; description = "The Mangohud package to install."; }; @@ -47,7 +47,7 @@ in { settings = mkOption { type = with types; attrsOf settingsType; default = { }; - example = literalExample '' + example = literalExpression '' { output_folder = ~/Documents/mangohud/; full = true; @@ -64,7 +64,7 @@ in { settingsPerApplication = mkOption { type = with types; attrsOf (attrsOf settingsType); default = { }; - example = literalExample '' + example = literalExpression '' { mpv = { no_display = true; @@ -82,24 +82,25 @@ in { }; }; - config = mkIf cfg.enable (mkMerge [ - { - home.packages = [ cfg.package ]; + config = mkIf cfg.enable { + assertions = [ + (hm.assertions.assertPlatform "programs.mangohud" pkgs platforms.linux) + ]; - home.sessionVariables = mkIf cfg.enableSessionWide { - MANGOHUD = 1; - MANGOHUD_DLSYM = 1; - }; + home.packages = [ cfg.package ]; - xdg.configFile."MangoHud/MangoHud.conf" = + home.sessionVariables = mkIf cfg.enableSessionWide { + MANGOHUD = 1; + MANGOHUD_DLSYM = 1; + }; + + xdg.configFile = { + "MangoHud/MangoHud.conf" = mkIf (cfg.settings != { }) { text = renderSettings cfg.settings; }; - } - { - xdg.configFile = mapAttrs' - (n: v: nameValuePair "MangoHud/${n}.conf" { text = renderSettings v; }) - cfg.settingsPerApplication; - } - ]); + } // mapAttrs' + (n: v: nameValuePair "MangoHud/${n}.conf" { text = renderSettings v; }) + cfg.settingsPerApplication; + }; meta.maintainers = with maintainers; [ zeratax ]; } diff --git a/third_party/home-manager/modules/programs/matplotlib.nix b/third_party/home-manager/modules/programs/matplotlib.nix index 0d4e48c953..1edb9b1256 100644 --- a/third_party/home-manager/modules/programs/matplotlib.nix +++ b/third_party/home-manager/modules/programs/matplotlib.nix @@ -28,7 +28,7 @@ in { Add terms to the matplotlibrc file to control the default matplotlib behavior. ''; - example = literalExample '' + example = literalExpression '' { backend = "Qt5Agg"; axes = { diff --git a/third_party/home-manager/modules/programs/mbsync-accounts.nix b/third_party/home-manager/modules/programs/mbsync-accounts.nix index 3f3f2d14d4..fa3f00ab33 100644 --- a/third_party/home-manager/modules/programs/mbsync-accounts.nix +++ b/third_party/home-manager/modules/programs/mbsync-accounts.nix @@ -94,7 +94,7 @@ let extraConfig = mkOption { type = extraConfigType; default = { }; - example = '' + example = literalExpression '' { Create = "both"; CopyArrivalDate = "yes"; @@ -192,7 +192,7 @@ in { extraConfig.channel = mkOption { type = extraConfigType; default = { }; - example = literalExample '' + example = literalExpression '' { MaxMessages = 10000; MaxSize = "1m"; @@ -222,7 +222,7 @@ in { extraConfig.account = mkOption { type = extraConfigType; default = { }; - example = literalExample '' + example = literalExpression '' { PipelineDepth = 10; Timeout = 60; diff --git a/third_party/home-manager/modules/programs/mbsync.nix b/third_party/home-manager/modules/programs/mbsync.nix index 91e7d0f77e..1ba493dd83 100644 --- a/third_party/home-manager/modules/programs/mbsync.nix +++ b/third_party/home-manager/modules/programs/mbsync.nix @@ -197,15 +197,15 @@ in { package = mkOption { type = types.package; default = pkgs.isync; - defaultText = literalExample "pkgs.isync"; - example = literalExample "pkgs.isync"; + defaultText = literalExpression "pkgs.isync"; + example = literalExpression "pkgs.isync"; description = "The package to use for the mbsync binary."; }; groups = mkOption { type = types.attrsOf (types.attrsOf (types.listOf types.str)); default = { }; - example = literalExample '' + example = literalExpression '' { inboxes = { account1 = [ "Inbox" ]; diff --git a/third_party/home-manager/modules/programs/mcfly.nix b/third_party/home-manager/modules/programs/mcfly.nix index 7f73039163..e6b1640bb1 100644 --- a/third_party/home-manager/modules/programs/mcfly.nix +++ b/third_party/home-manager/modules/programs/mcfly.nix @@ -65,18 +65,15 @@ in { home.packages = [ pkgs.mcfly ]; programs.bash.initExtra = mkIf cfg.enableBashIntegration '' - source "${pkgs.mcfly}/share/mcfly/mcfly.bash" + eval "$(${pkgs.mcfly}/bin/mcfly init bash)" ''; programs.zsh.initExtra = mkIf cfg.enableZshIntegration '' - source "${pkgs.mcfly}/share/mcfly/mcfly.zsh" + eval "$(${pkgs.mcfly}/bin/mcfly init zsh)" ''; programs.fish.shellInit = mkIf cfg.enableFishIntegration '' - source "${pkgs.mcfly}/share/mcfly/mcfly.fish" - if status is-interactive - mcfly_key_bindings - end + ${pkgs.mcfly}/bin/mcfly init fish | source ''; home.sessionVariables.MCFLY_KEY_SCHEME = cfg.keyScheme; diff --git a/third_party/home-manager/modules/programs/mercurial.nix b/third_party/home-manager/modules/programs/mercurial.nix index 2fc6e0076a..07a7d626c6 100644 --- a/third_party/home-manager/modules/programs/mercurial.nix +++ b/third_party/home-manager/modules/programs/mercurial.nix @@ -17,7 +17,7 @@ in { package = mkOption { type = types.package; default = pkgs.mercurial; - defaultText = literalExample "pkgs.mercurial"; + defaultText = literalExpression "pkgs.mercurial"; description = "Mercurial package to install."; }; diff --git a/third_party/home-manager/modules/programs/mpv.nix b/third_party/home-manager/modules/programs/mpv.nix index ab82251112..a53f4c40d1 100644 --- a/third_party/home-manager/modules/programs/mpv.nix +++ b/third_party/home-manager/modules/programs/mpv.nix @@ -62,7 +62,7 @@ in { package = mkOption { type = types.package; default = pkgs.mpv; - example = literalExample + example = literalExpression "pkgs.wrapMpv (pkgs.mpv-unwrapped.override { vapoursynthSupport = true; }) { youtubeSupport = true; }"; description = '' Package providing mpv. @@ -81,7 +81,7 @@ in { scripts = mkOption { type = with types; listOf (either package str); default = [ ]; - example = literalExample "[ pkgs.mpvScripts.mpris ]"; + example = literalExpression "[ pkgs.mpvScripts.mpris ]"; description = '' List of scripts to use with mpv. ''; @@ -99,7 +99,7 @@ in { ''; type = mpvOptions; default = { }; - example = literalExample '' + example = literalExpression '' { profile = "gpu-hq"; force-window = true; @@ -117,7 +117,7 @@ in { ''; type = mpvProfiles; default = { }; - example = literalExample '' + example = literalExpression '' { fast = { vo = "vdpau"; @@ -152,7 +152,7 @@ in { ''; type = mpvBindings; default = { }; - example = literalExample '' + example = literalExpression '' { WHEEL_UP = "seek 10"; WHEEL_DOWN = "seek -10"; diff --git a/third_party/home-manager/modules/programs/msmtp.nix b/third_party/home-manager/modules/programs/msmtp.nix index f8ba6a6f72..e1fc35d2e8 100644 --- a/third_party/home-manager/modules/programs/msmtp.nix +++ b/third_party/home-manager/modules/programs/msmtp.nix @@ -21,11 +21,12 @@ let user = userName; tls = onOff smtp.tls.enable; tls_starttls = onOff smtp.tls.useStartTls; - tls_trust_file = smtp.tls.certificatesFile; } // optionalAttrs (msmtp.tls.fingerprint != null) { tls_fingerprint = msmtp.tls.fingerprint; } // optionalAttrs (smtp.port != null) { port = toString smtp.port; } - // optionalAttrs (passwordCommand != null) { + // optionalAttrs (smtp.tls.certificatesFile != null) { + tls_trust_file = smtp.tls.certificatesFile; + } // optionalAttrs (passwordCommand != null) { passwordeval = toString passwordCommand; } // msmtp.extraConfig) ++ optional primary '' diff --git a/third_party/home-manager/modules/programs/ncmpcpp.nix b/third_party/home-manager/modules/programs/ncmpcpp.nix index a39baab6ca..96013a9d84 100644 --- a/third_party/home-manager/modules/programs/ncmpcpp.nix +++ b/third_party/home-manager/modules/programs/ncmpcpp.nix @@ -53,12 +53,12 @@ in { package = mkOption { type = types.package; default = pkgs.ncmpcpp; - defaultText = literalExample "pkgs.ncmpcpp"; + defaultText = literalExpression "pkgs.ncmpcpp"; description = '' Package providing the ncmpcpp command. ''; example = - literalExample "pkgs.ncmpcpp.override { visualizerSupport = true; }"; + literalExpression "pkgs.ncmpcpp.override { visualizerSupport = true; }"; }; mpdMusicDir = mkOption { @@ -68,7 +68,7 @@ in { mpdCfg.musicDirectory else null; - defaultText = literalExample '' + defaultText = literalExpression '' if pkgs.stdenv.hostPlatform.isLinux && config.services.mpd.enable then config.services.mpd.musicDirectory else @@ -101,7 +101,7 @@ in { type = types.listOf bindingType; default = [ ]; description = "List of keybindings."; - example = literalExample '' + example = literalExpression '' [ { key = "j"; command = "scroll_down"; } { key = "k"; command = "scroll_up"; } diff --git a/third_party/home-manager/modules/programs/ncspot.nix b/third_party/home-manager/modules/programs/ncspot.nix index ea46c9fc29..7acb8d364d 100644 --- a/third_party/home-manager/modules/programs/ncspot.nix +++ b/third_party/home-manager/modules/programs/ncspot.nix @@ -17,14 +17,14 @@ in { package = mkOption { type = types.package; default = pkgs.ncspot; - defaultText = literalExample "pkgs.ncspot"; + defaultText = literalExpression "pkgs.ncspot"; description = "The package to use for ncspot."; }; settings = mkOption { type = tomlFormat.type; default = { }; - example = literalExample '' + example = literalExpression '' { shuffle = true; gapless = true; diff --git a/third_party/home-manager/modules/programs/ne.nix b/third_party/home-manager/modules/programs/ne.nix index a88d23d913..1596066bc9 100644 --- a/third_party/home-manager/modules/programs/ne.nix +++ b/third_party/home-manager/modules/programs/ne.nix @@ -49,7 +49,7 @@ in { automaticPreferences = mkOption { type = types.attrsOf types.lines; default = { }; - example = literalExample '' + example = literalExpression '' { nix = ''' TAB 0 diff --git a/third_party/home-manager/modules/programs/neomutt-accounts.nix b/third_party/home-manager/modules/programs/neomutt-accounts.nix index 009cf1fa7e..94f97e914e 100644 --- a/third_party/home-manager/modules/programs/neomutt-accounts.nix +++ b/third_party/home-manager/modules/programs/neomutt-accounts.nix @@ -2,7 +2,25 @@ with lib; -{ +let + extraMailboxOptions = { + options = { + mailbox = mkOption { + type = types.str; + example = "Sent"; + description = "Name of mailbox folder to be included"; + }; + + name = mkOption { + type = types.nullOr types.str; + example = "Junk"; + default = null; + description = "Name to display"; + }; + }; + }; + +in { options.neomutt = { enable = mkEnableOption "NeoMutt"; @@ -12,7 +30,7 @@ with lib; "msmtpq --read-envelope-from --read-recipients" else null; - defaultText = literalExample '' + defaultText = literalExpression '' if config.msmtp.enable then "msmtpq --read-envelope-from --read-recipients" else @@ -32,5 +50,18 @@ with lib; Extra lines to add to the folder hook for this account. ''; }; + + mailboxName = mkOption { + type = types.nullOr types.str; + default = null; + example = "==== ==="; + description = "Use a different name as mailbox name"; + }; + + extraMailboxes = mkOption { + type = with types; listOf (either str (submodule extraMailboxOptions)); + default = [ ]; + description = "List of extra mailboxes"; + }; }; } diff --git a/third_party/home-manager/modules/programs/neomutt.nix b/third_party/home-manager/modules/programs/neomutt.nix index dbfe889901..2a2f79fae3 100644 --- a/third_party/home-manager/modules/programs/neomutt.nix +++ b/third_party/home-manager/modules/programs/neomutt.nix @@ -30,7 +30,7 @@ let format = mkOption { type = types.str; - default = "%B%?F? [%F]?%* %?N?%N/?%S"; + default = "%D%?F? [%F]?%* %?N?%N/?%S"; description = '' Sidebar format. Check neomutt documentation for details. ''; @@ -133,10 +133,25 @@ let ''; registerAccount = account: - with account; '' + let + mailboxes = if account.neomutt.mailboxName == null then + "mailboxes" + else + ''named-mailboxes "${account.neomutt.mailboxName}"''; + extraMailboxes = concatMapStringsSep "\n" (extra: + if isString extra then + ''mailboxes "${account.maildir.absPath}/${extra}"'' + else if extra.name == null then + ''mailboxes "${account.maildir.absPath}/${extra.mailbox}"'' + else + '' + named-mailboxes "${extra.name}" "${account.maildir.absPath}/${extra.mailbox}"'') + account.neomutt.extraMailboxes; + in with account; '' # register account ${name} - mailboxes "${account.maildir.absPath}/${folders.inbox}" - folder-hook ${account.maildir.absPath}/ " \ + ${mailboxes} "${maildir.absPath}/${folders.inbox}" + ${extraMailboxes} + folder-hook ${maildir.absPath}/ " \ source ${accountFilename account} " ''; @@ -185,7 +200,7 @@ let '' # Generated by Home Manager. set ssl_force_tls = yes - set certificate_file=${config.accounts.email.certificatesFile} + set certificate_file=${toString config.accounts.email.certificatesFile} # GPG section set crypt_use_gpgme = yes @@ -216,6 +231,13 @@ in { programs.neomutt = { enable = mkEnableOption "the NeoMutt mail client"; + package = mkOption { + type = types.package; + default = pkgs.neomutt; + defaultText = literalExpression "pkgs.neomutt"; + description = "The neomutt package to use."; + }; + sidebar = mkOption { type = sidebarModule; default = { }; @@ -285,7 +307,7 @@ in { }; config = mkIf cfg.enable { - home.packages = [ pkgs.neomutt ]; + home.packages = [ cfg.package ]; home.file = let rcFile = account: { "${accountFilename account}".text = accountStr account; diff --git a/third_party/home-manager/modules/programs/neovim.nix b/third_party/home-manager/modules/programs/neovim.nix index 8cb93bf365..f57148cc06 100644 --- a/third_party/home-manager/modules/programs/neovim.nix +++ b/third_party/home-manager/modules/programs/neovim.nix @@ -6,6 +6,8 @@ let cfg = config.programs.neovim; + jsonFormat = pkgs.formats.json { }; + extraPython3PackageType = mkOptionType { name = "extra-python3-packages"; description = "python3 packages in python.withPackages format"; @@ -123,17 +125,26 @@ in { type = with types; either extraPython3PackageType (listOf package); default = (_: [ ]); defaultText = "ps: []"; - example = literalExample "(ps: with ps; [ python-language-server ])"; + example = literalExpression "(ps: with ps; [ python-language-server ])"; description = '' A function in python.withPackages format, which returns a list of Python 3 packages required for your plugins to work. ''; }; + generatedConfigViml = mkOption { + type = types.lines; + visible = true; + readOnly = true; + description = '' + Generated vimscript config. + ''; + }; + package = mkOption { type = types.package; default = pkgs.neovim-unwrapped; - defaultText = literalExample "pkgs.neovim-unwrapped"; + defaultText = literalExpression "pkgs.neovim-unwrapped"; description = "The package to use for the neovim binary."; }; @@ -147,7 +158,7 @@ in { configure = mkOption { type = types.attrsOf types.anything; default = { }; - example = literalExample '' + example = literalExpression '' configure = { customRC = $'''' " here your custom configuration goes! @@ -199,7 +210,7 @@ in { plugins = mkOption { type = with types; listOf (either package pluginWithConfigType); default = [ ]; - example = literalExample '' + example = literalExpression '' with pkgs.vimPlugins; [ yankring vim-nix @@ -217,6 +228,44 @@ in { This option is mutually exclusive with configure. ''; }; + + coc = { + enable = mkEnableOption "Coc"; + + settings = mkOption { + type = jsonFormat.type; + default = { }; + example = literalExpression '' + { + "suggest.noselect" = true; + "suggest.enablePreview" = true; + "suggest.enablePreselect" = false; + "suggest.disableKind" = true; + languageserver = { + haskell = { + command = "haskell-language-server-wrapper"; + args = [ "--lsp" ]; + rootPatterns = [ + "*.cabal" + "stack.yaml" + "cabal.project" + "package.yaml" + "hie.yaml" + ]; + filetypes = [ "haskell" "lhaskell" ]; + }; + }; + }; + ''; + description = '' + Extra configuration lines to add to + $XDG_CONFIG_HOME/nvim/coc-settings.json + See + + for options. + ''; + }; + }; }; }; @@ -225,7 +274,8 @@ in { inherit (cfg) extraPython3Packages withPython3 withNodeJs withRuby viAlias vimAlias; configure = cfg.configure // moduleConfigure; - plugins = cfg.plugins; + plugins = cfg.plugins + ++ optionals cfg.coc.enable [ pkgs.vimPlugins.coc-nvim ]; customRC = cfg.extraConfig; }; @@ -239,11 +289,17 @@ in { configure.customRC -> programs.neovim.extraConfig ''; + programs.neovim.generatedConfigViml = neovimConfig.neovimRcContent; + home.packages = [ cfg.finalPackage ]; - xdg.configFile = mkIf (neovimConfig.neovimRcContent != "") { - "nvim/init.vim".text = neovimConfig.neovimRcContent; + xdg.configFile."nvim/init.vim" = mkIf (neovimConfig.neovimRcContent != "") { + text = neovimConfig.neovimRcContent; }; + xdg.configFile."nvim/coc-settings.json" = mkIf cfg.coc.enable { + source = jsonFormat.generate "coc-settings.json" cfg.coc.settings; + }; + programs.neovim.finalPackage = pkgs.wrapNeovimUnstable cfg.package (neovimConfig // { wrapperArgs = (lib.escapeShellArgs neovimConfig.wrapperArgs) + " " diff --git a/third_party/home-manager/modules/programs/nix-index.nix b/third_party/home-manager/modules/programs/nix-index.nix index 38115d4c50..2593d8b7cb 100644 --- a/third_party/home-manager/modules/programs/nix-index.nix +++ b/third_party/home-manager/modules/programs/nix-index.nix @@ -9,7 +9,7 @@ in { package = mkOption { type = types.package; default = pkgs.nix-index; - defaultText = literalExample "pkgs.nix-index"; + defaultText = literalExpression "pkgs.nix-index"; description = "Package providing the nix-index tool."; }; diff --git a/third_party/home-manager/modules/programs/nnn.nix b/third_party/home-manager/modules/programs/nnn.nix new file mode 100644 index 0000000000..a32ac723b8 --- /dev/null +++ b/third_party/home-manager/modules/programs/nnn.nix @@ -0,0 +1,129 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.programs.nnn; + + renderSetting = key: value: "${key}:${value}"; + + renderSettings = settings: + concatStringsSep ";" (mapAttrsToList renderSetting settings); + + pluginModule = types.submodule ({ ... }: { + options = { + src = mkOption { + type = with types; nullOr path; + example = literalExpression '' + (pkgs.fetchFromGitHub { + owner = "jarun"; + repo = "nnn"; + rev = "v4.0"; + sha256 = "sha256-Hpc8YaJeAzJoEi7aJ6DntH2VLkoR6ToP6tPYn3llR7k="; + }) + "/plugins"; + ''; + default = null; + description = '' + Path to the plugin folder. + ''; + }; + + mappings = mkOption { + type = with types; attrsOf str; + description = '' + Key mappings to the plugins. + ''; + default = { }; + example = literalExpression '' + { + c = "fzcd"; + f = "finder"; + v = "imgview"; + }; + ''; + }; + }; + }); +in { + meta.maintainers = with maintainers; [ thiagokokada ]; + + options = { + programs.nnn = { + enable = mkEnableOption "nnn"; + + package = mkOption { + type = types.package; + default = pkgs.nnn; + defaultText = literalExpression "pkgs.nnn"; + example = + literalExpression "pkgs.nnn.override ({ withNerdIcons = true; });"; + description = '' + Package containing the nnn program. + ''; + }; + + finalPackage = mkOption { + type = types.package; + readOnly = true; + visible = false; + description = '' + Resulting nnn package. + ''; + }; + + bookmarks = mkOption { + type = with types; attrsOf str; + description = '' + Directory bookmarks. + ''; + example = literalExpression '' + { + d = "~/Documents"; + D = "~/Downloads"; + p = "~/Pictures"; + v = "~/Videos"; + }; + ''; + default = { }; + }; + + extraPackages = mkOption { + type = with types; listOf package; + example = + literalExpression "with pkgs; [ ffmpegthumbnailer mediainfo sxiv ]"; + description = '' + Extra packages available to nnn. + ''; + default = [ ]; + }; + + plugins = mkOption { + type = pluginModule; + description = '' + Manage nnn plugins. + ''; + default = { }; + }; + }; + }; + + config = let + nnnPackage = cfg.package.overrideAttrs (oldAttrs: { + nativeBuildInputs = (oldAttrs.nativeBuildInputs or [ ]) + ++ [ pkgs.makeWrapper ]; + postInstall = '' + ${oldAttrs.postInstall or ""} + + wrapProgram $out/bin/nnn \ + --prefix PATH : "${makeBinPath cfg.extraPackages}" \ + --prefix NNN_BMS : "${renderSettings cfg.bookmarks}" \ + --prefix NNN_PLUG : "${renderSettings cfg.plugins.mappings}" + ''; + }); + in mkIf cfg.enable { + programs.nnn.finalPackage = nnnPackage; + home.packages = [ nnnPackage ]; + xdg.configFile."nnn/plugins" = + mkIf (cfg.plugins.src != null) { source = cfg.plugins.src; }; + }; +} diff --git a/third_party/home-manager/modules/programs/noti.nix b/third_party/home-manager/modules/programs/noti.nix index 348555eef5..069d87e642 100644 --- a/third_party/home-manager/modules/programs/noti.nix +++ b/third_party/home-manager/modules/programs/noti.nix @@ -26,7 +26,7 @@ in { . for the full list of options. ''; - example = literalExample '' + example = literalExpression '' { say = { voice = "Alex"; diff --git a/third_party/home-manager/modules/programs/nushell.nix b/third_party/home-manager/modules/programs/nushell.nix index 1a53a71f4d..f37b889a1a 100644 --- a/third_party/home-manager/modules/programs/nushell.nix +++ b/third_party/home-manager/modules/programs/nushell.nix @@ -17,7 +17,7 @@ in { package = mkOption { type = types.package; default = pkgs.nushell; - defaultText = literalExample "pkgs.nushell"; + defaultText = literalExpression "pkgs.nushell"; description = "The package to use for nushell."; }; @@ -31,7 +31,7 @@ in { entries = entryOrAttrsOf (entryOrAttrsOf entry); in attrsOf entries // { description = "Nushell configuration"; }; default = { }; - example = literalExample '' + example = literalExpression '' { edit_mode = "vi"; startup = [ "alias la [] { ls -a }" "alias e [msg] { echo $msg }" ]; diff --git a/third_party/home-manager/modules/programs/obs-studio.nix b/third_party/home-manager/modules/programs/obs-studio.nix index 1ebde7f4bd..ba5c891915 100644 --- a/third_party/home-manager/modules/programs/obs-studio.nix +++ b/third_party/home-manager/modules/programs/obs-studio.nix @@ -16,7 +16,7 @@ in { package = mkOption { type = types.package; default = pkgs.obs-studio; - defaultText = literalExample "pkgs.obs-studio"; + defaultText = literalExpression "pkgs.obs-studio"; description = '' OBS Studio package to install. ''; @@ -31,7 +31,7 @@ in { plugins = mkOption { default = [ ]; - example = literalExample "[ pkgs.obs-studio-plugins.wlrobs ]"; + example = literalExpression "[ pkgs.obs-studio-plugins.wlrobs ]"; description = "Optional OBS plugins."; type = types.listOf types.package; }; diff --git a/third_party/home-manager/modules/programs/octant.nix b/third_party/home-manager/modules/programs/octant.nix index 347d0d4685..f3b810c904 100644 --- a/third_party/home-manager/modules/programs/octant.nix +++ b/third_party/home-manager/modules/programs/octant.nix @@ -28,14 +28,14 @@ in { package = mkOption { type = types.package; default = pkgs.octant; - defaultText = literalExample "pkgs.octant"; - example = literalExample "pkgs.octant-other"; + defaultText = literalExpression "pkgs.octant"; + example = literalExpression "pkgs.octant-other"; description = "The Octant package to use."; }; plugins = mkOption { default = [ ]; - example = literalExample "[ pkgs.starboard-octant-plugin ]"; + example = literalExpression "[ pkgs.starboard-octant-plugin ]"; description = "Optional Octant plugins."; type = types.listOf types.package; }; diff --git a/third_party/home-manager/modules/programs/offlineimap.nix b/third_party/home-manager/modules/programs/offlineimap.nix index edb6e73604..842daa3dca 100644 --- a/third_party/home-manager/modules/programs/offlineimap.nix +++ b/third_party/home-manager/modules/programs/offlineimap.nix @@ -56,7 +56,7 @@ let ssl = if imap.tls.enable then { ssl = true; - sslcacertfile = imap.tls.certificatesFile; + sslcacertfile = toString imap.tls.certificatesFile; starttls = imap.tls.useStartTls; } else { ssl = false; @@ -132,7 +132,7 @@ in { extraConfig.mbnames = mkOption { type = extraConfigType; default = { }; - example = literalExample '' + example = literalExpression '' { filename = "~/.config/mutt/mailboxes"; header = "'mailboxes '"; diff --git a/third_party/home-manager/modules/programs/opam.nix b/third_party/home-manager/modules/programs/opam.nix index a61ff7878d..9cd76d9565 100644 --- a/third_party/home-manager/modules/programs/opam.nix +++ b/third_party/home-manager/modules/programs/opam.nix @@ -15,7 +15,7 @@ in { package = mkOption { type = types.package; default = pkgs.opam; - defaultText = literalExample "pkgs.opam"; + defaultText = literalExpression "pkgs.opam"; description = "Opam package to install."; }; diff --git a/third_party/home-manager/modules/programs/password-store.nix b/third_party/home-manager/modules/programs/password-store.nix index 658750b8ef..e2f463ece6 100644 --- a/third_party/home-manager/modules/programs/password-store.nix +++ b/third_party/home-manager/modules/programs/password-store.nix @@ -15,8 +15,8 @@ in { package = mkOption { type = types.package; default = pkgs.pass; - defaultText = literalExample "pkgs.pass"; - example = literalExample '' + defaultText = literalExpression "pkgs.pass"; + example = literalExpression '' pkgs.pass.withExtensions (exts: [ exts.pass-otp ]) ''; description = '' @@ -31,10 +31,10 @@ in { default = { PASSWORD_STORE_DIR = "${config.xdg.dataHome}/password-store"; }; - defaultText = literalExample '' + defaultText = literalExpression '' { PASSWORD_STORE_DIR = "$XDG_DATA_HOME/password-store"; } ''; - example = literalExample '' + example = literalExpression '' { PASSWORD_STORE_DIR = "/some/directory"; PASSWORD_STORE_KEY = "12345678"; diff --git a/third_party/home-manager/modules/programs/pet.nix b/third_party/home-manager/modules/programs/pet.nix index 1de4f7e6f0..c1411b623d 100644 --- a/third_party/home-manager/modules/programs/pet.nix +++ b/third_party/home-manager/modules/programs/pet.nix @@ -40,7 +40,7 @@ let tag = mkOption { type = types.listOf types.str; default = [ ]; - example = literalExample ''["git" "nixpkgs"]''; + example = literalExpression ''["git" "nixpkgs"]''; description = '' List of tags attached to the command. ''; @@ -64,7 +64,7 @@ in { selectcmdPackage = mkOption { type = types.package; default = pkgs.fzf; - defaultText = literalExample "pkgs.fzf"; + defaultText = literalExpression "pkgs.fzf"; description = '' The package needed for the settings.selectcmd. ''; diff --git a/third_party/home-manager/modules/programs/pidgin.nix b/third_party/home-manager/modules/programs/pidgin.nix index a375fd1b2b..d7536be717 100644 --- a/third_party/home-manager/modules/programs/pidgin.nix +++ b/third_party/home-manager/modules/programs/pidgin.nix @@ -16,13 +16,13 @@ in { package = mkOption { type = types.package; default = pkgs.pidgin; - defaultText = literalExample "pkgs.pidgin"; + defaultText = literalExpression "pkgs.pidgin"; description = "The Pidgin package to use."; }; plugins = mkOption { default = [ ]; - example = literalExample "[ pkgs.pidgin-otr pkgs.pidgin-osd ]"; + example = literalExpression "[ pkgs.pidgin-otr pkgs.pidgin-osd ]"; description = "Plugins that should be available to Pidgin."; }; }; diff --git a/third_party/home-manager/modules/programs/piston-cli.nix b/third_party/home-manager/modules/programs/piston-cli.nix index d2e1373caa..6315cb5cec 100644 --- a/third_party/home-manager/modules/programs/piston-cli.nix +++ b/third_party/home-manager/modules/programs/piston-cli.nix @@ -14,14 +14,14 @@ in { package = mkOption { type = types.package; default = pkgs.piston-cli; - defaultText = literalExample "pkgs.piston-cli"; + defaultText = literalExpression "pkgs.piston-cli"; description = "The piston-cli package to use."; }; settings = mkOption { type = yamlFormat.type; default = { }; - example = literalExample '' + example = literalExpression '' { theme = "emacs"; box_style = "MINIMAL_DOUBLE_HEAD"; diff --git a/third_party/home-manager/modules/programs/powerline-go.nix b/third_party/home-manager/modules/programs/powerline-go.nix index 8f5db8f260..aed8449af1 100644 --- a/third_party/home-manager/modules/programs/powerline-go.nix +++ b/third_party/home-manager/modules/programs/powerline-go.nix @@ -73,7 +73,7 @@ in { may use '~' to represent your home directory but you should protect it to avoid shell substitution. ''; - example = literalExample '' + example = literalExpression '' { "\\~/projects/home-manager" = "prj:home-manager"; } ''; }; @@ -85,7 +85,7 @@ in { This can be any key/value pair as described in . ''; - example = literalExample '' + example = literalExpression '' { hostname-only-if-ssh = true; numeric-exit-codes = true; @@ -140,5 +140,14 @@ in { install_powerline_precmd fi ''; + + # https://github.com/justjanne/powerline-go#fish + programs.fish.interactiveShellInit = + mkIf (cfg.enable && config.programs.fish.enable) '' + function fish_prompt + eval ${pkgs.powerline-go}/bin/powerline-go -error $status -jobs (count (jobs -p)) ${commandLineArguments} + ${cfg.extraUpdatePS1} + end + ''; }; } diff --git a/third_party/home-manager/modules/programs/qutebrowser.nix b/third_party/home-manager/modules/programs/qutebrowser.nix index 8d4868fbb5..9220d496ae 100644 --- a/third_party/home-manager/modules/programs/qutebrowser.nix +++ b/third_party/home-manager/modules/programs/qutebrowser.nix @@ -41,7 +41,7 @@ in { package = mkOption { type = types.package; default = pkgs.qutebrowser; - defaultText = literalExample "pkgs.qutebrowser"; + defaultText = literalExpression "pkgs.qutebrowser"; description = "Qutebrowser package to install."; }; @@ -77,7 +77,7 @@ in { prepending the search engine name to the search term, for example :open google qutebrowser. ''; - example = literalExample '' + example = literalExpression '' { w = "https://en.wikipedia.org/wiki/Special:Search?search={}&go=Go&ns0=1"; aw = "https://wiki.archlinux.org/?search={}"; @@ -95,7 +95,7 @@ in { See for options. ''; - example = literalExample '' + example = literalExpression '' { colors = { hints = { @@ -239,7 +239,7 @@ in { ''; - example = literalExample '' + example = literalExpression '' { normal = { "" = "spawn mpv {url}"; @@ -260,7 +260,7 @@ in { Quickmarks to add to qutebrowser's quickmarks file. Note that when Home Manager manages your quickmarks, you cannot edit them at runtime. ''; - example = literalExample '' + example = literalExpression '' { nixpkgs = "https://github.com/NixOS/nixpkgs"; home-manager = "https://github.com/nix-community/home-manager"; @@ -306,7 +306,24 @@ in { }; xdg.configFile."qutebrowser/config.py" = - mkIf pkgs.stdenv.hostPlatform.isLinux { text = qutebrowserConfig; }; + mkIf pkgs.stdenv.hostPlatform.isLinux { + text = qutebrowserConfig; + onChange = '' + hash="$(echo -n "$USER" | md5sum | cut -d' ' -f1)" + socket="''${XDG_RUNTIME_DIR:-/run/user/$UID}/qutebrowser/ipc-$hash" + if [[ -S $socket ]]; then + command=${ + escapeShellArg (builtins.toJSON { + args = [ ":config-source" ]; + target_arg = null; + protocol_version = 1; + }) + } + echo "$command" | ${pkgs.socat}/bin/socat -lf /dev/null - UNIX-CONNECT:"$socket" + fi + unset hash socket command + ''; + }; xdg.configFile."qutebrowser/quickmarks" = mkIf (cfg.quickmarks != { } && pkgs.stdenv.hostPlatform.isLinux) { diff --git a/third_party/home-manager/modules/programs/rbw.nix b/third_party/home-manager/modules/programs/rbw.nix index 8c074aeaa3..f3a17ca5b6 100644 --- a/third_party/home-manager/modules/programs/rbw.nix +++ b/third_party/home-manager/modules/programs/rbw.nix @@ -73,7 +73,7 @@ in { package = mkOption { type = types.package; default = pkgs.rbw; - defaultText = literalExample "pkgs.rbw"; + defaultText = literalExpression "pkgs.rbw"; description = '' Package providing the rbw tool and its rbw-agent daemon. @@ -83,7 +83,7 @@ in { settings = mkOption { type = types.nullOr settingsModule; default = null; - example = literalExample '' + example = literalExpression '' { email = "name@example.com"; lock_timeout = 300; diff --git a/third_party/home-manager/modules/programs/readline.nix b/third_party/home-manager/modules/programs/readline.nix index 2f79df6e10..2658061f22 100644 --- a/third_party/home-manager/modules/programs/readline.nix +++ b/third_party/home-manager/modules/programs/readline.nix @@ -30,7 +30,7 @@ in { bindings = mkOption { default = { }; type = types.attrsOf types.str; - example = literalExample '' + example = literalExpression '' { "\\C-h" = "backward-kill-word"; } ''; description = "Readline bindings."; diff --git a/third_party/home-manager/modules/programs/rofi.nix b/third_party/home-manager/modules/programs/rofi.nix index f4f7594e13..1ae7016bc1 100644 --- a/third_party/home-manager/modules/programs/rofi.nix +++ b/third_party/home-manager/modules/programs/rofi.nix @@ -6,109 +6,12 @@ let cfg = config.programs.rofi; - colorOption = description: - mkOption { - type = types.str; - description = description; - }; - - rowColorSubmodule = types.submodule { - options = { - background = colorOption "Background color"; - foreground = colorOption "Foreground color"; - backgroundAlt = colorOption "Alternative background color"; - highlight = mkOption { - type = types.submodule { - options = { - background = colorOption "Highlight background color"; - foreground = colorOption "Highlight foreground color"; - }; - }; - description = "Color settings for highlighted row."; - }; - }; - }; - - windowColorSubmodule = types.submodule { - options = { - background = colorOption "Window background color"; - border = colorOption "Window border color"; - separator = colorOption "Separator color"; - }; - }; - - colorsSubmodule = types.submodule { - options = { - window = mkOption { - default = null; - type = windowColorSubmodule; - description = "Window color settings."; - }; - rows = mkOption { - default = null; - type = types.submodule { - options = { - normal = mkOption { - default = null; - type = types.nullOr rowColorSubmodule; - description = "Normal row color settings."; - }; - active = mkOption { - default = null; - type = types.nullOr rowColorSubmodule; - description = "Active row color settings."; - }; - urgent = mkOption { - default = null; - type = types.nullOr rowColorSubmodule; - description = "Urgent row color settings."; - }; - }; - }; - description = "Rows color settings."; - }; - }; - }; - - windowColorsToString = window: - concatStringsSep ", " (with window; [ background border separator ]); - - rowColorsToString = row: - concatStringsSep ", " (with row; [ - background - foreground - backgroundAlt - highlight.background - highlight.foreground - ]); - - mkColorScheme = colors: - if colors != null then - with colors; { - color-window = - if (window != null) then (windowColorsToString window) else null; - color-normal = if (rows != null && rows.normal != null) then - (rowColorsToString rows.normal) - else - null; - color-active = if (rows != null && rows.active != null) then - (rowColorsToString rows.active) - else - null; - color-urgent = if (rows != null && rows.active != null) then - (rowColorsToString rows.urgent) - else - null; - } - else - { }; - mkValueString = value: if isBool value then if value then "true" else "false" else if isInt value then toString value - else if value._type or "" == "literal" then + else if (value._type or "") == "literal" then value.value else if isString value then ''"${value}"'' @@ -202,7 +105,7 @@ in { description = '' Package providing the rofi binary. ''; - example = literalExample '' + example = literalExpression '' pkgs.rofi.override { plugins = [ pkgs.rofi-emoji ]; }; ''; }; @@ -213,42 +116,7 @@ in { description = '' List of rofi plugins to be installed. ''; - example = literalExample "[ pkgs.rofi-calc ]"; - }; - - width = mkOption { - default = null; - type = types.nullOr types.int; - description = "Window width"; - example = 100; - }; - - lines = mkOption { - default = null; - type = types.nullOr types.int; - description = "Number of lines"; - example = 10; - }; - - borderWidth = mkOption { - default = null; - type = types.nullOr types.int; - description = "Border width"; - example = 1; - }; - - rowHeight = mkOption { - default = null; - type = types.nullOr types.int; - description = "Row height (in chars)"; - example = 1; - }; - - padding = mkOption { - default = null; - type = types.nullOr types.int; - description = "Padding"; - example = 400; + example = literalExpression "[ pkgs.rofi-calc ]"; }; font = mkOption { @@ -258,12 +126,6 @@ in { description = "Font to use."; }; - scrollbar = mkOption { - default = null; - type = types.nullOr types.bool; - description = "Whether to show a scrollbar."; - }; - terminal = mkOption { default = null; type = types.nullOr types.str; @@ -273,25 +135,12 @@ in { example = "\${pkgs.gnome.gnome_terminal}/bin/gnome-terminal"; }; - separator = mkOption { - default = null; - type = types.nullOr (types.enum [ "none" "dash" "solid" ]); - description = "Separator style"; - example = "solid"; - }; - cycle = mkOption { default = null; type = types.nullOr types.bool; description = "Whether to cycle through the results list."; }; - fullscreen = mkOption { - default = null; - type = types.nullOr types.bool; - description = "Whether to run rofi fullscreen."; - }; - location = mkOption { default = "center"; type = types.enum (attrNames locationsMap); @@ -314,43 +163,17 @@ in { ''; }; - colors = mkOption { - default = null; - type = types.nullOr colorsSubmodule; - description = '' - Color scheme settings. Colors can be specified in CSS color - formats. This option may become deprecated in the future and - therefore the programs.rofi.theme option - should be used whenever possible. - ''; - example = literalExample '' - colors = { - window = { - background = "argb:583a4c54"; - border = "argb:582a373e"; - separator = "#c3c6c8"; - }; - - rows = { - normal = { - background = "argb:58455a64"; - foreground = "#fafbfc"; - backgroundAlt = "argb:58455a64"; - highlight = { - background = "#00bcd4"; - foreground = "#fafbfc"; - }; - }; - }; - }; - ''; - }; - theme = mkOption { default = null; type = with types; nullOr (oneOf [ str path themeType ]); - example = literalExample '' + example = literalExpression '' let + # Use `mkLiteral` for string-like values that should show without + # quotes, e.g.: + # { + # foo = "abc"; => foo: "abc"; + # bar = mkLiteral "abc"; => bar: abc; + # }; inherit (config.lib.formats.rasi) mkLiteral; in { "*" = { @@ -388,7 +211,7 @@ in { extraConfig = mkOption { default = { }; - example = literalExample '' + example = literalExpression '' { modi = "drun,emoji,ssh"; kb-primary-paste = "Control+V,Shift+Insert"; @@ -401,13 +224,25 @@ in { }; + imports = let + mkRemovedOptionRofi = option: + (mkRemovedOptionModule [ "programs" "rofi" option ] + "Please use a Rofi theme instead."); + in map mkRemovedOptionRofi [ + "width" + "lines" + "borderWidth" + "rowHeight" + "padding" + "separator" + "scrollbar" + "fullscreen" + "colors" + ]; + config = mkIf cfg.enable { - assertions = [{ - assertion = cfg.theme == null || cfg.colors == null; - message = '' - Cannot use the rofi options 'theme' and 'colors' simultaneously. - ''; - }]; + assertions = + [ (hm.assertions.assertPlatform "programs.rofi" pkgs platforms.linux) ]; lib.formats.rasi.mkLiteral = value: { _type = "literal"; @@ -425,23 +260,14 @@ in { home.file."${cfg.configPath}".text = toRasi { configuration = ({ - width = cfg.width; - lines = cfg.lines; font = cfg.font; - bw = cfg.borderWidth; - eh = cfg.rowHeight; - padding = cfg.padding; - separator-style = cfg.separator; - hide-scrollbar = - if (cfg.scrollbar != null) then (!cfg.scrollbar) else null; terminal = cfg.terminal; cycle = cfg.cycle; - fullscreen = cfg.fullscreen; location = (getAttr cfg.location locationsMap); xoffset = cfg.xoffset; yoffset = cfg.yoffset; theme = themeName; - } // (mkColorScheme cfg.colors) // cfg.extraConfig); + } // cfg.extraConfig); }; xdg.dataFile = mkIf (themePath != null) (if themePath == "custom" then { diff --git a/third_party/home-manager/modules/programs/sbt.nix b/third_party/home-manager/modules/programs/sbt.nix index d3ba31e193..4e10d61ea6 100644 --- a/third_party/home-manager/modules/programs/sbt.nix +++ b/third_party/home-manager/modules/programs/sbt.nix @@ -9,7 +9,7 @@ let ''; renderCredential = cred: '' - credentials += Credentials("${cred.realm}", "${cred.host}", "${cred.user}", "${cred.passwordCommand}".!!) + credentials += Credentials("${cred.realm}", "${cred.host}", "${cred.user}", "${cred.passwordCommand}".lazyLines.mkString("\n")) ''; renderCredentials = creds: '' @@ -76,7 +76,7 @@ in { package = mkOption { type = types.package; default = pkgs.sbt; - defaultText = literalExample "pkgs.sbt"; + defaultText = literalExpression "pkgs.sbt"; description = "The package with sbt to be installed."; }; @@ -89,7 +89,7 @@ in { plugins = mkOption { type = types.listOf (sbtTypes.plugin); default = [ ]; - example = literalExample '' + example = literalExpression '' [ { org = "net.virtual-void"; @@ -111,7 +111,7 @@ in { credentials = mkOption { type = types.listOf (sbtTypes.credential); default = [ ]; - example = literalExample '' + example = literalExpression '' [{ realm = "Sonatype Nexus Repository Manager"; host = "example.com"; diff --git a/third_party/home-manager/modules/programs/scmpuff.nix b/third_party/home-manager/modules/programs/scmpuff.nix index d2e6651e1e..5f36ca0213 100644 --- a/third_party/home-manager/modules/programs/scmpuff.nix +++ b/third_party/home-manager/modules/programs/scmpuff.nix @@ -12,7 +12,7 @@ in { package = mkOption { type = types.package; default = pkgs.scmpuff; - defaultText = literalExample "pkgs.scmpuff"; + defaultText = literalExpression "pkgs.scmpuff"; description = "Package providing the scmpuff tool."; }; diff --git a/third_party/home-manager/modules/programs/senpai.nix b/third_party/home-manager/modules/programs/senpai.nix index 6e5a4a0ae2..6320807114 100644 --- a/third_party/home-manager/modules/programs/senpai.nix +++ b/third_party/home-manager/modules/programs/senpai.nix @@ -11,7 +11,7 @@ in { package = mkOption { type = types.package; default = pkgs.senpai; - defaultText = literalExample "pkgs.senpai"; + defaultText = literalExpression "pkgs.senpai"; description = "The senpai package to use."; }; config = mkOption { @@ -48,7 +48,7 @@ in { }; }; }; - example = literalExample '' + example = literalExpression '' { addr = "libera.chat:6697"; nick = "nicholas"; diff --git a/third_party/home-manager/modules/programs/sm64ex.nix b/third_party/home-manager/modules/programs/sm64ex.nix new file mode 100644 index 0000000000..a5debee180 --- /dev/null +++ b/third_party/home-manager/modules/programs/sm64ex.nix @@ -0,0 +1,128 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.programs.sm64ex; + + # This is required for tests, we cannot overwrite the dummy package. + package = if cfg.region == null && cfg.baserom == null + && cfg.extraCompileFlags == null then + cfg.package + + else + cfg.package.override (attrs: + { } // optionalAttrs (cfg.region != null) { region = cfg.region; } + // optionalAttrs (cfg.baserom != null) { baseRom = cfg.baserom; } + // optionalAttrs (cfg.extraCompileFlags != null) { + compileFlags = cfg.extraCompileFlags; + }); + + mkConfig = key: value: + let + generatedValue = if isBool value then + (if value then "true" else "false") + else if isList value then + concatStringsSep " " value + else + toString value; + in "${key} ${generatedValue}"; + +in { + meta.maintainers = [ maintainers.ivar ]; + + options.programs.sm64ex = { + enable = mkEnableOption "sm64ex"; + + package = mkOption { + type = types.package; + default = pkgs.sm64ex; + description = "The sm64ex package to use."; + }; + + region = mkOption { + type = types.nullOr (types.enum [ "us" "eu" "jp" ]); + default = null; + defaultText = + literalExpression "us"; # This is set both in nixpkgs and upstream + description = '' + Your baserom's region. Note that only "us", "eu", and "jp" are supported. + ''; + example = literalExpression "jp"; + }; + + baserom = mkOption { + type = types.nullOr types.path; + default = null; + description = + "The path to the Super Mario 64 baserom to extract assets from."; + example = literalExpression "/home/foo/baserom.us.z64"; + }; + + extraCompileFlags = mkOption { + type = with types; nullOr (listOf str); + default = null; + description = '' + Extra flags to pass to the compiler. See + + for more information. + ''; + example = literalExpression '' + [ + "BETTERCAMERA=1" + "NODRAWINGDISTANCE=1" + ]; + ''; + }; + + settings = mkOption { + type = with types; + nullOr (attrsOf (either str (either int (either bool (listOf str))))); + default = null; + description = + "Settings for sm64ex's ~/.local/share/sm64pc/sm64config.txt file."; + example = literalExpression '' + { + fullscreen = false; + window_x = 0; + window_y = 0; + window_w = 1920; + window_h = 1080; + vsync = 1; + texture_filtering = 1; + master_volume = 127; + music_volume = 127; + sfx_volume = 127; + env_volume = 127; + key_a = [ "0026" "1000" "1103" ]; + key_b = [ "0033" "1002" "1101" ]; + key_start = [ "0039" "1006" "ffff" ]; + key_l = [ "0034" "1007" "1104" ]; + key_r = [ "0036" "100a" "1105" ]; + key_z = [ "0025" "1009" "1102" ]; + key_cup = [ "100b" "ffff" "ffff" ]; + key_cdown = [ "100c" "ffff" "ffff" ]; + key_cleft = [ "100d" "ffff" "ffff" ]; + key_cright = [ "100e" "ffff" "ffff" ]; + key_stickup = [ "0011" "ffff" "ffff" ]; + key_stickdown = [ "001f" "ffff" "ffff" ]; + key_stickleft = [ "001e" "ffff" "ffff" ]; + key_stickright = [ "0020" "ffff" "ffff" ]; + stick_deadzone = 16; + rumble_strength = 10; + skip_intro = 1; + }; + ''; + }; + }; + + config = let + configFile = optionals (cfg.settings != null) + (concatStringsSep "\n" ((mapAttrsToList mkConfig cfg.settings))); + in mkIf cfg.enable { + home.packages = [ package ]; + + xdg.dataFile."sm64pc/sm64config.txt" = + mkIf (cfg.settings != null) { text = configFile; }; + }; +} diff --git a/third_party/home-manager/modules/programs/ssh.nix b/third_party/home-manager/modules/programs/ssh.nix index b4940cbfab..abbde3f419 100644 --- a/third_party/home-manager/modules/programs/ssh.nix +++ b/third_party/home-manager/modules/programs/ssh.nix @@ -217,7 +217,7 @@ let localForwards = mkOption { type = types.listOf forwardModule; default = []; - example = literalExample '' + example = literalExpression '' [ { bind.port = 8080; @@ -238,7 +238,7 @@ let remoteForwards = mkOption { type = types.listOf forwardModule; default = []; - example = literalExample '' + example = literalExpression '' [ { bind.port = 8080; @@ -259,7 +259,7 @@ let dynamicForwards = mkOption { type = types.listOf dynamicForwardModule; default = []; - example = literalExample '' + example = literalExpression '' [ { port = 8080; } ]; ''; description = '' @@ -417,7 +417,7 @@ in matchBlocks = mkOption { type = hm.types.listOrDagOf matchBlockModule; default = {}; - example = literalExample '' + example = literalExpression '' { "john.example.com" = { hostname = "example.com"; diff --git a/third_party/home-manager/modules/programs/starship.nix b/third_party/home-manager/modules/programs/starship.nix index 33db8e6d6c..77a9cad31d 100644 --- a/third_party/home-manager/modules/programs/starship.nix +++ b/third_party/home-manager/modules/programs/starship.nix @@ -8,6 +8,8 @@ let tomlFormat = pkgs.formats.toml { }; + starshipCmd = "${config.home.profileDirectory}/bin/starship"; + in { meta.maintainers = [ maintainers.marsam ]; @@ -17,7 +19,7 @@ in { package = mkOption { type = types.package; default = pkgs.starship; - defaultText = literalExample "pkgs.starship"; + defaultText = literalExpression "pkgs.starship"; description = "The package to use for the starship binary."; }; @@ -31,7 +33,7 @@ in { entries = entryOrAttrsOf (entryOrAttrsOf entry); in attrsOf entries // { description = "Starship configuration"; }; default = { }; - example = literalExample '' + example = literalExpression '' { add_newline = false; format = lib.concatStrings [ @@ -90,19 +92,19 @@ in { programs.bash.initExtra = mkIf cfg.enableBashIntegration '' if [[ $TERM != "dumb" && (-z $INSIDE_EMACS || $INSIDE_EMACS == "vterm") ]]; then - eval "$(${cfg.package}/bin/starship init bash)" + eval "$(${starshipCmd} init bash)" fi ''; programs.zsh.initExtra = mkIf cfg.enableZshIntegration '' if [[ $TERM != "dumb" && (-z $INSIDE_EMACS || $INSIDE_EMACS == "vterm") ]]; then - eval "$(${cfg.package}/bin/starship init zsh)" + eval "$(${starshipCmd} init zsh)" fi ''; - programs.fish.promptInit = mkIf cfg.enableFishIntegration '' + programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration '' if test "$TERM" != "dumb" -a \( -z "$INSIDE_EMACS" -o "$INSIDE_EMACS" = "vterm" \) - eval (${cfg.package}/bin/starship init fish) + eval (${starshipCmd} init fish) end ''; }; diff --git a/third_party/home-manager/modules/programs/taskwarrior.nix b/third_party/home-manager/modules/programs/taskwarrior.nix index 6a887e0f5b..f0f5f1e92e 100644 --- a/third_party/home-manager/modules/programs/taskwarrior.nix +++ b/third_party/home-manager/modules/programs/taskwarrior.nix @@ -42,7 +42,7 @@ in { config = mkOption { type = types.attrsOf types.anything; default = { }; - example = literalExample '' + example = literalExpression '' { confirmation = false; report.minimal.filter = "status:pending"; @@ -98,8 +98,6 @@ in { config = mkIf cfg.enable { home.packages = [ pkgs.taskwarrior ]; - home.file."${cfg.dataLocation}/.keep".text = ""; - home.file.".taskrc".text = '' data.location=${cfg.dataLocation} ${includeTheme cfg.colorTheme} diff --git a/third_party/home-manager/modules/programs/terminator.nix b/third_party/home-manager/modules/programs/terminator.nix index d100a9cd98..4a5e367bc1 100644 --- a/third_party/home-manager/modules/programs/terminator.nix +++ b/third_party/home-manager/modules/programs/terminator.nix @@ -36,7 +36,7 @@ in { package = mkOption { type = types.package; default = pkgs.terminator; - example = literalExample "pkgs.terminator"; + example = literalExpression "pkgs.terminator"; description = "terminator package to install."; }; @@ -53,7 +53,7 @@ in { man page. ''; type = types.attrsOf types.anything; - example = literalExample '' + example = literalExpression '' { global_config.borderless = true; profiles.default.background_color = "#002b36"; @@ -63,7 +63,12 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (hm.assertions.assertPlatform "programs.terminator" pkgs platforms.linux) + ]; + home.packages = [ cfg.package ]; + xdg.configFile."terminator/config" = mkIf (cfg.config != { }) { text = toConfigObject cfg.config; }; }; diff --git a/third_party/home-manager/modules/programs/texlive.nix b/third_party/home-manager/modules/programs/texlive.nix index 0921417ba2..bd17025d47 100644 --- a/third_party/home-manager/modules/programs/texlive.nix +++ b/third_party/home-manager/modules/programs/texlive.nix @@ -18,14 +18,14 @@ in { packageSet = mkOption { default = pkgs.texlive; - defaultText = literalExample "pkgs.texlive"; + defaultText = literalExpression "pkgs.texlive"; description = "TeX Live package set to use."; }; extraPackages = mkOption { default = tpkgs: { inherit (tpkgs) collection-basic; }; defaultText = "tpkgs: { inherit (tpkgs) collection-basic; }"; - example = literalExample '' + example = literalExpression '' tpkgs: { inherit (tpkgs) collection-fontsrecommended algorithms; } ''; description = "Extra packages available to TeX Live."; diff --git a/third_party/home-manager/modules/programs/tmux.nix b/third_party/home-manager/modules/programs/tmux.nix index 8628155b88..4b5125966d 100644 --- a/third_party/home-manager/modules/programs/tmux.nix +++ b/third_party/home-manager/modules/programs/tmux.nix @@ -23,11 +23,11 @@ let }; }; - defaultKeyMode = "emacs"; - defaultResize = 5; + defaultKeyMode = "emacs"; + defaultResize = 5; defaultShortcut = "b"; defaultTerminal = "screen"; - defaultShell = null; + defaultShell = null; boolToStr = value: if value then "on" else "off"; @@ -56,7 +56,8 @@ let set -g status-keys ${cfg.keyMode} set -g mode-keys ${cfg.keyMode} - ${optionalString (cfg.keyMode == "vi" && cfg.customPaneNavigationAndResize) '' + ${optionalString + (cfg.keyMode == "vi" && cfg.customPaneNavigationAndResize) '' bind h select-pane -L bind j select-pane -D bind k select-pane -U @@ -68,21 +69,19 @@ let bind -r L resize-pane -R ${toString cfg.resizeAmount} ''} - ${if cfg.prefix != null - then '' - # rebind main key: ${cfg.prefix} - unbind C-${defaultShortcut} - set -g prefix ${cfg.prefix} - bind ${cfg.prefix} send-prefix - '' - else optionalString (cfg.shortcut != defaultShortcut) '' - # rebind main key: C-${cfg.shortcut} - unbind C-${defaultShortcut} - set -g prefix C-${cfg.shortcut} - bind ${cfg.shortcut} send-prefix - bind C-${cfg.shortcut} last-window - '' - } + ${if cfg.prefix != null then '' + # rebind main key: ${cfg.prefix} + unbind C-${defaultShortcut} + set -g prefix ${cfg.prefix} + bind ${cfg.prefix} send-prefix + '' else + optionalString (cfg.shortcut != defaultShortcut) '' + # rebind main key: C-${cfg.shortcut} + unbind C-${defaultShortcut} + set -g prefix C-${cfg.shortcut} + bind ${cfg.shortcut} send-prefix + bind C-${cfg.shortcut} last-window + ''} ${optionalString cfg.disableConfirmationPrompt '' bind-key & kill-window @@ -96,18 +95,16 @@ let ''; configPlugins = { - assertions = [( - let + assertions = [ + (let hasBadPluginName = p: !(hasPrefix "tmuxplugin" (pluginName p)); badPlugins = filter hasBadPluginName cfg.plugins; - in - { - assertion = badPlugins == []; - message = - "Invalid tmux plugin (not prefixed with \"tmuxplugins\"): " - + concatMapStringsSep ", " pluginName badPlugins; - } - )]; + in { + assertion = badPlugins == [ ]; + message = ''Invalid tmux plugin (not prefixed with "tmuxplugins"): '' + + concatMapStringsSep ", " pluginName badPlugins; + }) + ]; xdg.configFile."tmux/tmux.conf".text = '' # ============================================= # @@ -115,21 +112,16 @@ let # --------------------------------------------- # ${(concatMapStringsSep "\n\n" (p: '' - # ${pluginName p} - # --------------------- - ${p.extraConfig or ""} - run-shell ${ - if types.package.check p - then p.rtp - else p.plugin.rtp - } + # ${pluginName p} + # --------------------- + ${p.extraConfig or ""} + run-shell ${if types.package.check p then p.rtp else p.plugin.rtp} '') cfg.plugins)} # ============================================= # ''; }; -in -{ +in { options = { programs.tmux = { aggressiveResize = mkOption { @@ -180,7 +172,7 @@ in description = '' Time in milliseconds for which tmux waits after an escape is input. - ''; + ''; }; extraConfig = mkOption { @@ -218,8 +210,8 @@ in package = mkOption { type = types.package; default = pkgs.tmux; - defaultText = literalExample "pkgs.tmux"; - example = literalExample "pkgs.tmux"; + defaultText = literalExpression "pkgs.tmux"; + example = literalExpression "pkgs.tmux"; description = "The tmux package to install"; }; @@ -294,15 +286,16 @@ in plugins = mkOption { type = with types; - listOf (either package pluginModule) - // { description = "list of plugin packages or submodules"; }; + listOf (either package pluginModule) // { + description = "list of plugin packages or submodules"; + }; description = '' List of tmux plugins to be included at the end of your tmux configuration. The sensible plugin, however, is defaulted to run at the top of your configuration. ''; default = [ ]; - example = literalExample '' + example = literalExpression '' with pkgs; [ tmuxPlugins.cpu { @@ -322,22 +315,22 @@ in }; }; - config = mkIf cfg.enable ( - mkMerge ([ - { - home.packages = [ cfg.package ] - ++ optional cfg.tmuxinator.enable pkgs.tmuxinator - ++ optional cfg.tmuxp.enable pkgs.tmuxp; - } - (mkIf cfg.secureSocket { - home.sessionVariables = { - TMUX_TMPDIR = ''''${XDG_RUNTIME_DIR:-"/run/user/\$(id -u)"}''; - }; - }) + config = mkIf cfg.enable (mkMerge ([ + { + home.packages = [ cfg.package ] + ++ optional cfg.tmuxinator.enable pkgs.tmuxinator + ++ optional cfg.tmuxp.enable pkgs.tmuxp; + } - { xdg.configFile."tmux/tmux.conf".text = mkBefore tmuxConf; } - (mkIf (cfg.plugins != []) configPlugins) - { xdg.configFile."tmux/tmux.conf".text = mkAfter cfg.extraConfig; } - ]) - ); + { xdg.configFile."tmux/tmux.conf".text = mkBefore tmuxConf; } + { xdg.configFile."tmux/tmux.conf".text = mkAfter cfg.extraConfig; } + + (mkIf cfg.secureSocket { + home.sessionVariables = { + TMUX_TMPDIR = ''''${XDG_RUNTIME_DIR:-"/run/user/\$(id -u)"}''; + }; + }) + + (mkIf (cfg.plugins != [ ]) configPlugins) + ])); } diff --git a/third_party/home-manager/modules/programs/topgrade.nix b/third_party/home-manager/modules/programs/topgrade.nix index 878fdbb088..1511d4b45c 100644 --- a/third_party/home-manager/modules/programs/topgrade.nix +++ b/third_party/home-manager/modules/programs/topgrade.nix @@ -18,15 +18,15 @@ in { package = mkOption { type = types.package; default = pkgs.topgrade; - defaultText = literalExample "pkgs.topgrade"; + defaultText = literalExpression "pkgs.topgrade"; description = "The package to use for the topgrade binary."; }; settings = mkOption { type = tomlFormat.type; default = { }; - defaultText = literalExample "{ }"; - example = literalExample '' + defaultText = literalExpression "{ }"; + example = literalExpression '' { assume_yes = true; disable = [ diff --git a/third_party/home-manager/modules/programs/urxvt.nix b/third_party/home-manager/modules/programs/urxvt.nix index 5eb3d90d79..905e14c14a 100644 --- a/third_party/home-manager/modules/programs/urxvt.nix +++ b/third_party/home-manager/modules/programs/urxvt.nix @@ -13,7 +13,7 @@ in { package = mkOption { type = types.package; default = pkgs.rxvt_unicode; - defaultText = literalExample "pkgs.rxvt_unicode"; + defaultText = literalExpression "pkgs.rxvt_unicode"; description = "rxvt-unicode package to install."; }; @@ -28,7 +28,7 @@ in { type = types.attrsOf types.str; default = { }; description = "Mapping of keybindings to actions"; - example = literalExample '' + example = literalExpression '' { "Shift-Control-C" = "eval:selection_to_clipboard"; "Shift-Control-V" = "eval:paste_clipboard"; diff --git a/third_party/home-manager/modules/programs/vim.nix b/third_party/home-manager/modules/programs/vim.nix index 3325bf2251..a0168add85 100644 --- a/third_party/home-manager/modules/programs/vim.nix +++ b/third_party/home-manager/modules/programs/vim.nix @@ -68,7 +68,7 @@ in { plugins = mkOption { type = with types; listOf (either str package); default = defaultPlugins; - example = literalExample "[ pkgs.vimPlugins.YankRing ]"; + example = literalExpression "[ pkgs.vimPlugins.YankRing ]"; description = '' List of vim plugins to install. To get a list of supported plugins run: nix-env -f '<nixpkgs>' -qaP -A vimPlugins. @@ -82,7 +82,7 @@ in { settings = mkOption { type = vimSettingsType; default = { }; - example = literalExample '' + example = literalExpression '' { expandtab = true; history = 1000; @@ -124,6 +124,13 @@ in { description = "Resulting customized vim package"; readOnly = true; }; + + packageConfigurable = mkOption { + type = types.package; + description = "Configurable vim package"; + default = pkgs.vim_configurable; + defaultText = "pkgs.vim_configurable"; + }; }; }; @@ -135,7 +142,7 @@ in { ${cfg.extraConfig} ''; - vim = pkgs.vim_configurable.customize { + vim = cfg.packageConfigurable.customize { name = "vim"; vimrcConfig = { inherit customRC; diff --git a/third_party/home-manager/modules/programs/vscode.nix b/third_party/home-manager/modules/programs/vscode.nix index 473cd1705e..19420dc9d6 100644 --- a/third_party/home-manager/modules/programs/vscode.nix +++ b/third_party/home-manager/modules/programs/vscode.nix @@ -41,7 +41,7 @@ in { package = mkOption { type = types.package; default = pkgs.vscode; - example = literalExample "pkgs.vscodium"; + example = literalExpression "pkgs.vscodium"; description = '' Version of Visual Studio Code to install. ''; @@ -50,7 +50,7 @@ in { userSettings = mkOption { type = jsonFormat.type; default = { }; - example = literalExample '' + example = literalExpression '' { "update.channel" = "none"; "[nix]"."editor.tabSize" = 2; @@ -86,7 +86,7 @@ in { # https://code.visualstudio.com/docs/getstarted/keybindings#_command-arguments args = mkOption { - type = types.nullOr (types.attrs); + type = types.nullOr (jsonFormat.type); default = null; example = { direction = "up"; }; description = "Optional arguments for a command."; @@ -94,7 +94,7 @@ in { }; }); default = [ ]; - example = literalExample '' + example = literalExpression '' [ { key = "ctrl+c"; @@ -112,7 +112,7 @@ in { extensions = mkOption { type = types.listOf types.package; default = [ ]; - example = literalExample "[ pkgs.vscode-extensions.bbenoist.Nix ]"; + example = literalExpression "[ pkgs.vscode-extensions.bbenoist.Nix ]"; description = '' The extensions Visual Studio Code should be started with. These will override but not delete manually installed ones. diff --git a/third_party/home-manager/modules/programs/vscode/haskell.nix b/third_party/home-manager/modules/programs/vscode/haskell.nix index ee84e70710..7fe3235d82 100644 --- a/third_party/home-manager/modules/programs/vscode/haskell.nix +++ b/third_party/home-manager/modules/programs/vscode/haskell.nix @@ -8,7 +8,7 @@ let defaultHieNixExe = hie-nix.hies + "/bin/hie-wrapper"; defaultHieNixExeText = - literalExample ''"''${pkgs.hie-nix.hies}/bin/hie-wrapper"''; + literalExpression ''"''${pkgs.hie-nix.hies}/bin/hie-wrapper"''; hie-nix = pkgs.hie-nix or (abort '' vscode.haskell: pkgs.hie-nix missing. Please add an overlay such as: @@ -42,7 +42,7 @@ in { overlay or set this option. Example overlay configuration: ${exampleOverlay} ''; - example = literalExample '' + example = literalExpression '' (import ~/src/haskell-ide-engine {}).hies + "/bin/hie-wrapper"; ''; }; diff --git a/third_party/home-manager/modules/programs/waybar.nix b/third_party/home-manager/modules/programs/waybar.nix index 3cf919cc77..aa1f70984b 100644 --- a/third_party/home-manager/modules/programs/waybar.nix +++ b/third_party/home-manager/modules/programs/waybar.nix @@ -3,9 +3,9 @@ let inherit (lib) any attrByPath attrNames concatMap concatMapStringsSep elem elemAt filter - filterAttrs flip foldl' hasPrefix head length mergeAttrs optionalAttrs - stringLength subtractLists types unique; - inherit (lib.options) literalExample mkEnableOption mkOption; + filterAttrs flip foldl' hasPrefix head length literalExpression mergeAttrs + optionalAttrs stringLength subtractLists types unique; + inherit (lib.options) mkEnableOption mkOption; inherit (lib.modules) mkIf mkMerge; cfg = config.programs.waybar; @@ -82,7 +82,7 @@ let output = mkOption { type = nullOr (either str (listOf str)); default = null; - example = literalExample '' + example = literalExpression '' [ "DP-1" "!DP-2" "!DP-3" ] ''; description = '' @@ -118,7 +118,7 @@ let type = listOf str; default = [ ]; description = "Modules that will be displayed on the left."; - example = literalExample '' + example = literalExpression '' [ "sway/workspaces" "sway/mode" "wlr/taskbar" ] ''; }; @@ -127,7 +127,7 @@ let type = listOf str; default = [ ]; description = "Modules that will be displayed in the center."; - example = literalExample '' + example = literalExpression '' [ "sway/window" ] ''; }; @@ -136,7 +136,7 @@ let type = listOf str; default = [ ]; description = "Modules that will be displayed on the right."; - example = literalExample '' + example = literalExpression '' [ "mpd" "custom/mymodule#with-css-id" "temperature" ] ''; }; @@ -145,7 +145,7 @@ let type = jsonFormat.type; default = { }; description = "Modules configuration."; - example = literalExample '' + example = literalExpression '' { "sway/window" = { max-length = 50; @@ -206,7 +206,7 @@ in { xlink:href="https://github.com/Alexays/Waybar/wiki/Configuration"/> for supported values. ''; - example = literalExample '' + example = literalExpression '' [ { layer = "top"; @@ -353,16 +353,36 @@ in { in allWarnings; in mkIf cfg.enable (mkMerge [ - { home.packages = [ cfg.package ]; } + { + assertions = [ + (lib.hm.assertions.assertPlatform "programs.waybar" pkgs + lib.platforms.linux) + ]; + + home.packages = [ cfg.package ]; + } + (mkIf (cfg.settings != [ ]) { # Generate warnings about defined but unreferenced modules inherit warnings; - xdg.configFile."waybar/config".source = configSource; + xdg.configFile."waybar/config" = { + source = configSource; + onChange = '' + ${pkgs.procps}/bin/pkill -u $USER -USR2 waybar || true + ''; + }; }) + (mkIf (cfg.style != null) { - xdg.configFile."waybar/style.css".text = cfg.style; + xdg.configFile."waybar/style.css" = { + text = cfg.style; + onChange = '' + ${pkgs.procps}/bin/pkill -u $USER -USR2 waybar || true + ''; + }; }) + (mkIf cfg.systemd.enable { systemd.user.services.waybar = { Unit = { diff --git a/third_party/home-manager/modules/programs/xmobar.nix b/third_party/home-manager/modules/programs/xmobar.nix index 0ad5d7c190..9d8593b7bc 100644 --- a/third_party/home-manager/modules/programs/xmobar.nix +++ b/third_party/home-manager/modules/programs/xmobar.nix @@ -9,7 +9,7 @@ in { package = mkOption { default = pkgs.haskellPackages.xmobar; - defaultText = literalExample "pkgs.haskellPackages.xmobar"; + defaultText = literalExpression "pkgs.haskellPackages.xmobar"; type = types.package; description = '' Package providing the xmobar binary. @@ -18,7 +18,7 @@ in { extraConfig = mkOption { default = ""; - example = literalExample '' + example = literalExpression '' Config { font = "Fira Code" , borderColor = "#d0d0d0" diff --git a/third_party/home-manager/modules/programs/z-lua.nix b/third_party/home-manager/modules/programs/z-lua.nix index d722ac6a2f..f8ff3b014d 100644 --- a/third_party/home-manager/modules/programs/z-lua.nix +++ b/third_party/home-manager/modules/programs/z-lua.nix @@ -86,5 +86,7 @@ in { programs.bash.shellAliases = mkIf cfg.enableAliases aliases; programs.zsh.shellAliases = mkIf cfg.enableAliases aliases; + + programs.fish.shellAliases = mkIf cfg.enableAliases aliases; }; } diff --git a/third_party/home-manager/modules/programs/zoxide.nix b/third_party/home-manager/modules/programs/zoxide.nix index 842ff10929..21bc9632ec 100644 --- a/third_party/home-manager/modules/programs/zoxide.nix +++ b/third_party/home-manager/modules/programs/zoxide.nix @@ -15,7 +15,7 @@ in { package = mkOption { type = types.package; default = pkgs.zoxide; - defaultText = literalExample "pkgs.zoxide"; + defaultText = literalExpression "pkgs.zoxide"; description = '' Zoxide package to install. ''; diff --git a/third_party/home-manager/modules/programs/zplug.nix b/third_party/home-manager/modules/programs/zplug.nix index 6cb5e98e31..5f2b44311f 100644 --- a/third_party/home-manager/modules/programs/zplug.nix +++ b/third_party/home-manager/modules/programs/zplug.nix @@ -31,6 +31,14 @@ in { type = types.listOf pluginModule; description = "List of zplug plugins."; }; + + zplugHome = mkOption { + type = types.path; + default = "${config.home.homeDirectory}/.zplug"; + defaultText = "~/.zplug"; + apply = toString; + description = "Path to zplug home directory."; + }; }; config = mkIf cfg.enable { @@ -39,6 +47,8 @@ in { programs.zsh.initExtraBeforeCompInit = '' source ${pkgs.zplug}/init.zsh + export ZPLUG_HOME=${cfg.zplugHome} + ${optionalString (cfg.plugins != [ ]) '' ${concatStrings (map (plugin: '' zplug "${plugin.name}"${ diff --git a/third_party/home-manager/modules/programs/zsh.nix b/third_party/home-manager/modules/programs/zsh.nix index 5f6f7b89f4..6cd880309f 100644 --- a/third_party/home-manager/modules/programs/zsh.nix +++ b/third_party/home-manager/modules/programs/zsh.nix @@ -56,18 +56,18 @@ let default = if versionAtLeast stateVersion "20.03" then "$HOME/.zsh_history" else relToDotDir ".zsh_history"; - defaultText = literalExample '' + defaultText = literalExpression '' "$HOME/.zsh_history" if state version ≥ 20.03, "$ZDOTDIR/.zsh_history" otherwise ''; - example = literalExample ''"''${config.xdg.dataHome}/zsh/zsh_history"''; + example = literalExpression ''"''${config.xdg.dataHome}/zsh/zsh_history"''; description = "History file location"; }; ignorePatterns = mkOption { type = types.listOf types.str; default = []; - example = literalExample ''[ "rm *" "pkill *" ]''; + example = literalExpression ''[ "rm *" "pkill *" ]''; description = '' Do not enter command lines into the history list if they match any one of the given shell patterns. @@ -224,7 +224,7 @@ in shellAliases = mkOption { default = {}; - example = literalExample '' + example = literalExpression '' { ll = "ls -l"; ".." = "cd .."; @@ -239,7 +239,7 @@ in shellGlobalAliases = mkOption { default = {}; - example = literalExample '' + example = literalExpression '' { UUID = "$(uuidgen | tr -d \\n)"; G = "| grep"; @@ -254,7 +254,7 @@ in dirHashes = mkOption { default = {}; - example = literalExample '' + example = literalExpression '' { docs = "$HOME/Documents"; vids = "$HOME/Videos"; @@ -360,7 +360,7 @@ in plugins = mkOption { type = types.listOf pluginModule; default = []; - example = literalExample '' + example = literalExpression '' [ { # will source zsh-autosuggestions.plugin.zsh diff --git a/third_party/home-manager/modules/services/barrier.nix b/third_party/home-manager/modules/services/barrier.nix index ae9b7d9364..21364b7a3c 100644 --- a/third_party/home-manager/modules/services/barrier.nix +++ b/third_party/home-manager/modules/services/barrier.nix @@ -6,6 +6,12 @@ in { meta.maintainers = with maintainers; [ kritnich ]; + imports = [ + (mkRemovedOptionModule [ "services" "barrier" "client" "tray" ] '' + The tray option is non-functional and has been removed. + '') + ]; + options.services.barrier = { client = { @@ -29,8 +35,6 @@ in { ''; }; - tray = mkEnableOption "the system tray icon" // { default = true; }; - enableCrypto = mkEnableOption "crypto (SSL) plugin" // { default = true; }; @@ -40,7 +44,7 @@ in { extraFlags = mkOption { type = types.listOf types.str; default = [ "-f" ]; - defaultText = literalExample ''[ "-f" ]''; + defaultText = literalExpression ''[ "-f" ]''; description = '' Additional flags to pass to barrierc. See barrierc --help. @@ -51,6 +55,11 @@ in { }; config = mkIf cfg.client.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.barrier" pkgs + lib.platforms.linux) + ]; + systemd.user.services.barrierc = { Unit = { Description = "Barrier Client daemon"; @@ -61,7 +70,6 @@ in { Service.ExecStart = with cfg.client; toString ([ "${pkgs.barrier}/bin/barrierc" ] ++ optional (name != null) "--name ${name}" - ++ optional (!tray) "--no-tray" ++ optional enableCrypto "--enable-crypto" ++ optional enableDragDrop "--enable-drag-drop" ++ extraFlags ++ [ server ]); diff --git a/third_party/home-manager/modules/services/betterlockscreen.nix b/third_party/home-manager/modules/services/betterlockscreen.nix new file mode 100644 index 0000000000..b4b28b5f98 --- /dev/null +++ b/third_party/home-manager/modules/services/betterlockscreen.nix @@ -0,0 +1,55 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let cfg = config.services.betterlockscreen; + +in { + meta.maintainers = with maintainers; [ sebtm ]; + + options = { + services.betterlockscreen = { + enable = mkEnableOption "betterlockscreen, a screen-locker module"; + + package = mkOption { + type = types.package; + default = pkgs.betterlockscreen; + defaultText = literalExpression "pkgs.betterlockscreen"; + description = "Package providing betterlockscreen."; + }; + + arguments = mkOption { + type = types.listOf types.str; + default = [ ]; + description = + "List of arguments appended to ./betterlockscreen --lock [args]"; + }; + + inactiveInterval = mkOption { + type = types.int; + default = 10; + description = '' + Value used for . + ''; + }; + + }; + }; + + config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.betterlockscreen" pkgs + lib.platforms.linux) + ]; + + home.packages = [ cfg.package ]; + + services.screen-locker = { + enable = true; + inactiveInterval = cfg.inactiveInterval; + lockCmd = "${cfg.package}/bin/betterlockscreen --lock ${ + concatStringsSep " " cfg.arguments + }"; + }; + }; +} diff --git a/third_party/home-manager/modules/services/caffeine.nix b/third_party/home-manager/modules/services/caffeine.nix index bb24a0e052..28ebc7f13b 100644 --- a/third_party/home-manager/modules/services/caffeine.nix +++ b/third_party/home-manager/modules/services/caffeine.nix @@ -14,6 +14,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.caffeine" pkgs + lib.platforms.linux) + ]; + systemd.user.services.caffeine = { Unit = { Description = "caffeine"; }; diff --git a/third_party/home-manager/modules/services/cbatticon.nix b/third_party/home-manager/modules/services/cbatticon.nix index a86805ddca..1216878ca0 100644 --- a/third_party/home-manager/modules/services/cbatticon.nix +++ b/third_party/home-manager/modules/services/cbatticon.nix @@ -98,6 +98,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.cbatticon" pkgs + lib.platforms.linux) + ]; + home.packages = [ package ]; systemd.user.services.cbatticon = { diff --git a/third_party/home-manager/modules/services/clipmenu.nix b/third_party/home-manager/modules/services/clipmenu.nix index 2e1c10e43d..3f2055c9ac 100644 --- a/third_party/home-manager/modules/services/clipmenu.nix +++ b/third_party/home-manager/modules/services/clipmenu.nix @@ -21,6 +21,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.clipmenu" pkgs + lib.platforms.linux) + ]; + home.packages = [ cfg.package ]; systemd.user.services.clipmenu = { diff --git a/third_party/home-manager/modules/services/devilspie2.nix b/third_party/home-manager/modules/services/devilspie2.nix new file mode 100644 index 0000000000..fa77153e7f --- /dev/null +++ b/third_party/home-manager/modules/services/devilspie2.nix @@ -0,0 +1,47 @@ +{ config, lib, pkgs, ... }: + +with lib; +let cfg = config.services.devilspie2; +in { + meta.maintainers = [ maintainers.dawidsowa ]; + + options = { + services.devilspie2 = { + enable = mkEnableOption '' + Devilspie2, a window matching utility, allowing the user to + perform scripted actions on windows as they are created''; + + config = mkOption { + type = types.lines; + default = ""; + description = '' + Content of file placed in the devilspie2 config directory. + ''; + example = '' + if (get_window_class() == "Gnome-terminal") then + make_always_on_top(); + end + ''; + }; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.devilspie2" pkgs + lib.platforms.linux) + ]; + + systemd.user.services.devilspie2 = { + Service.ExecStart = "${pkgs.devilspie2}/bin/devilspie2"; + Unit = { + Description = "devilspie2"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + Install.WantedBy = [ "graphical-session.target" ]; + }; + + xdg.configFile."devilspie2/config.lua".text = cfg.config; + }; +} diff --git a/third_party/home-manager/modules/services/dropbox.nix b/third_party/home-manager/modules/services/dropbox.nix index bcf3ba2b45..941f4d82e9 100644 --- a/third_party/home-manager/modules/services/dropbox.nix +++ b/third_party/home-manager/modules/services/dropbox.nix @@ -20,7 +20,7 @@ in { type = types.path; default = "${config.home.homeDirectory}/Dropbox"; defaultText = - literalExample ''"''${config.home.homeDirectory}/Dropbox"''; + literalExpression ''"''${config.home.homeDirectory}/Dropbox"''; apply = toString; # Prevent copies to Nix store. description = "Where to put the Dropbox directory."; }; @@ -28,6 +28,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.dropbox" pkgs + lib.platforms.linux) + ]; + home.packages = [ pkgs.dropbox-cli ]; systemd.user.services.dropbox = { diff --git a/third_party/home-manager/modules/services/dunst.nix b/third_party/home-manager/modules/services/dunst.nix index cf832f4bf2..238abc297e 100644 --- a/third_party/home-manager/modules/services/dunst.nix +++ b/third_party/home-manager/modules/services/dunst.nix @@ -25,7 +25,7 @@ let options = { package = mkOption { type = types.package; - example = literalExample "pkgs.gnome.adwaita-icon-theme"; + example = literalExpression "pkgs.gnome.adwaita-icon-theme"; description = "Package providing the theme."; }; @@ -60,10 +60,25 @@ in { package = mkOption { type = types.package; default = pkgs.dunst; - defaultText = literalExample "pkgs.dunst"; + defaultText = literalExpression "pkgs.dunst"; description = "Package providing dunst."; }; + configFile = mkOption { + type = with types; either str path; + default = "${config.xdg.configHome}/dunst/dunstrc"; + defaultText = "$XDG_CONFIG_HOME/dunst/dunstrc"; + description = '' + Path to the configuration file read by dunst. + + Note that the configuration generated by Home Manager will be + written to $XDG_CONFIG_HOME/dunst/dunstrc + regardless. This allows using a mutable configuration file generated + from the immutable one, useful in scenarios where live reloading is + desired. + ''; + }; + iconTheme = mkOption { type = themeType; default = hicolorTheme; @@ -88,8 +103,9 @@ in { }; }; default = { }; - description = "Configuration written to ~/.config/dunst/dunstrc"; - example = literalExample '' + description = + "Configuration written to $XDG_CONFIG_HOME/dunst/dunstrc."; + example = literalExpression '' { global = { geometry = "300x5-30+50"; @@ -165,7 +181,7 @@ in { Service = { Type = "dbus"; BusName = "org.freedesktop.Notifications"; - ExecStart = "${cfg.package}/bin/dunst"; + ExecStart = "${cfg.package}/bin/dunst -config ${cfg.configFile}"; Environment = optionalString (cfg.waylandDisplay != "") "WAYLAND_DISPLAY=${cfg.waylandDisplay}"; }; @@ -176,12 +192,7 @@ in { xdg.configFile."dunst/dunstrc" = { text = toDunstIni cfg.settings; onChange = '' - pkillVerbose="" - if [[ -v VERBOSE ]]; then - pkillVerbose="-e" - fi - $DRY_RUN_CMD ${pkgs.procps}/bin/pkill -u $USER $pkillVerbose dunst || true - unset pkillVerbose + ${pkgs.procps}/bin/pkill -u "$USER" ''${VERBOSE+-e} dunst || true ''; }; }) diff --git a/third_party/home-manager/modules/services/dwm-status.nix b/third_party/home-manager/modules/services/dwm-status.nix index a0c2a72436..c3295faac6 100644 --- a/third_party/home-manager/modules/services/dwm-status.nix +++ b/third_party/home-manager/modules/services/dwm-status.nix @@ -21,7 +21,7 @@ in { package = mkOption { type = types.package; default = pkgs.dwm-status; - defaultText = literalExample "pkgs.dwm-status"; + defaultText = literalExpression "pkgs.dwm-status"; example = "pkgs.dwm-status.override { enableAlsaUtils = false; }"; description = "Which dwm-status package to use."; }; @@ -34,7 +34,7 @@ in { extraConfig = mkOption { type = jsonFormat.type; default = { }; - example = literalExample '' + example = literalExpression '' { separator = "#"; @@ -53,6 +53,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.dwm-status" pkgs + lib.platforms.linux) + ]; + systemd.user.services.dwm-status = { Unit = { Description = "DWM status service"; diff --git a/third_party/home-manager/modules/services/easyeffects.nix b/third_party/home-manager/modules/services/easyeffects.nix new file mode 100644 index 0000000000..001ff5d025 --- /dev/null +++ b/third_party/home-manager/modules/services/easyeffects.nix @@ -0,0 +1,62 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.easyeffects; + + presetOpts = optionalString (cfg.preset != "") "--load-preset ${cfg.preset}"; + +in { + meta.maintainers = [ maintainers.fufexan ]; + + options.services.easyeffects = { + enable = mkEnableOption '' + Easyeffects daemon. + Note, it is necessary to add + + programs.dconf.enable = true; + + to your system configuration for the daemon to work correctly''; + + preset = mkOption { + type = types.str; + default = ""; + description = '' + Which preset to use when starting easyeffects. + Will likely need to launch easyeffects to initially create preset. + ''; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + (hm.assertions.assertPlatform "services.easyeffects" pkgs platforms.linux) + ]; + + # running easyeffects will just attach itself to gapplication service + # at-spi2-core is to minimize journalctl noise of: + # "AT-SPI: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files" + home.packages = with pkgs; [ easyeffects at-spi2-core ]; + + systemd.user.services.easyeffects = { + Unit = { + Description = "Easyeffects daemon"; + Requires = [ "dbus.service" ]; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" "pipewire.service" ]; + }; + + Install.WantedBy = [ "graphical-session.target" ]; + + Service = { + ExecStart = + "${pkgs.easyeffects}/bin/easyeffects --gapplication-service ${presetOpts}"; + ExecStop = "${pkgs.easyeffects}/bin/easyeffects --quit"; + Restart = "on-failure"; + RestartSec = 5; + }; + }; + }; +} diff --git a/third_party/home-manager/modules/services/emacs.nix b/third_party/home-manager/modules/services/emacs.nix index 96c86ee782..1631275ba9 100644 --- a/third_party/home-manager/modules/services/emacs.nix +++ b/third_party/home-manager/modules/services/emacs.nix @@ -47,13 +47,22 @@ in { package = mkOption { type = types.package; default = if emacsCfg.enable then emacsCfg.finalPackage else pkgs.emacs; - defaultText = literalExample '' + defaultText = literalExpression '' if config.programs.emacs.enable then config.programs.emacs.finalPackage else pkgs.emacs ''; description = "The Emacs package to use."; }; + extraOptions = mkOption { + type = with types; listOf str; + default = [ ]; + example = [ "-f" "exwm-enable" ]; + description = '' + Extra command-line arguments to pass to emacs. + ''; + }; + client = { enable = mkEnableOption "generation of Emacs client desktop file"; arguments = mkOption { @@ -75,6 +84,11 @@ in { config = mkIf cfg.enable (mkMerge [ { + assertions = [ + (lib.hm.assertions.assertPlatform "services.emacs" pkgs + lib.platforms.linux) + ]; + systemd.user.services.emacs = { Unit = { Description = "Emacs text editor"; @@ -106,7 +120,7 @@ in { # when using socket activation. optionalString cfg.socketActivation.enable "=${escapeShellArg socketPath}" - }"''; + } ${escapeShellArgs cfg.extraOptions}"''; # Emacs will exit with status 15 after having received SIGTERM, which # is the default "KillSignal" value systemd uses to stop services. diff --git a/third_party/home-manager/modules/services/etesync-dav.nix b/third_party/home-manager/modules/services/etesync-dav.nix index 8bc5aa7a04..5fd58d0926 100644 --- a/third_party/home-manager/modules/services/etesync-dav.nix +++ b/third_party/home-manager/modules/services/etesync-dav.nix @@ -32,7 +32,7 @@ in { settings = mkOption { type = types.attrsOf (types.oneOf [ types.str types.int ]); default = { }; - example = literalExample '' + example = literalExpression '' { ETESYNC_LISTEN_ADDRESS = "localhost"; ETESYNC_LISTEN_PORT = 37358; @@ -45,6 +45,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.etesync-dav" pkgs + lib.platforms.linux) + ]; + home.packages = [ cfg.package ]; systemd.user.services.etesync-dav = { diff --git a/third_party/home-manager/modules/services/flameshot.nix b/third_party/home-manager/modules/services/flameshot.nix index 13fb7ea200..e30d82383f 100644 --- a/third_party/home-manager/modules/services/flameshot.nix +++ b/third_party/home-manager/modules/services/flameshot.nix @@ -5,22 +5,55 @@ with lib; let cfg = config.services.flameshot; + package = pkgs.flameshot; + iniFormat = pkgs.formats.ini { }; + + iniFile = iniFormat.generate "flameshot.ini" cfg.settings; + in { meta.maintainers = [ maintainers.hamhut1066 ]; - options = { services.flameshot = { enable = mkEnableOption "Flameshot"; }; }; + options.services.flameshot = { + enable = mkEnableOption "Flameshot"; + + settings = mkOption { + type = iniFormat.type; + default = { }; + example = { + General = { + disabledTrayIcon = true; + showStartupLaunchMessage = false; + }; + }; + description = '' + Configuration to use for Flameshot. See + + for available options. + ''; + }; + }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.flameshot" pkgs + lib.platforms.linux) + ]; + home.packages = [ package ]; + xdg.configFile = mkIf (cfg.settings != { }) { + "flameshot/flameshot.ini".source = iniFile; + }; + systemd.user.services.flameshot = { Unit = { Description = "Flameshot screenshot tool"; Requires = [ "tray.target" ]; After = [ "graphical-session-pre.target" "tray.target" ]; PartOf = [ "graphical-session.target" ]; + X-Restart-Triggers = mkIf (cfg.settings != { }) [ "${iniFile}" ]; }; Install = { WantedBy = [ "graphical-session.target" ]; }; @@ -29,6 +62,15 @@ in { Environment = "PATH=${config.home.profileDirectory}/bin"; ExecStart = "${package}/bin/flameshot"; Restart = "on-abort"; + + # Sandboxing. + LockPersonality = true; + MemoryDenyWriteExecute = true; + NoNewPrivileges = true; + PrivateUsers = true; + RestrictNamespaces = true; + SystemCallArchitectures = "native"; + SystemCallFilter = "@system-service"; }; }; }; diff --git a/third_party/home-manager/modules/services/fluidsynth.nix b/third_party/home-manager/modules/services/fluidsynth.nix index 18913fe542..bf1b76a0dd 100644 --- a/third_party/home-manager/modules/services/fluidsynth.nix +++ b/third_party/home-manager/modules/services/fluidsynth.nix @@ -21,6 +21,15 @@ in { ''; }; + soundService = mkOption { + type = types.enum [ "jack" "pipewire-pulse" "pulseaudio" ]; + default = "pulseaudio"; + example = "pipewire-pulse"; + description = '' + The systemd sound service to depend on. + ''; + }; + extraOptions = mkOption { type = types.listOf types.str; default = [ ]; @@ -37,12 +46,17 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.fluidsynth" pkgs + lib.platforms.linux) + ]; + systemd.user.services.fluidsynth = { Unit = { Description = "FluidSynth Daemon"; Documentation = "man:fluidsynth(1)"; - BindsTo = [ "pulseaudio.service" ]; - After = [ "pulseaudio.service" ]; + BindsTo = [ (cfg.soundService + ".service") ]; + After = [ (cfg.soundService + ".service") ]; }; Install = { WantedBy = [ "default.target" ]; }; diff --git a/third_party/home-manager/modules/services/fnott.nix b/third_party/home-manager/modules/services/fnott.nix new file mode 100644 index 0000000000..d4e2addb44 --- /dev/null +++ b/third_party/home-manager/modules/services/fnott.nix @@ -0,0 +1,112 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.fnott; + + concatStringsSep' = sep: list: + concatStringsSep sep (filter (x: x != "") list); + + iniFormat = pkgs.formats.ini { }; +in { + options = { + services.fnott = { + enable = mkEnableOption '' + fnott, a lightweight Wayland notification daemon for wlroots-based compositors + ''; + + package = mkOption { + type = types.package; + default = pkgs.fnott; + defaultText = literalExpression "pkgs.fnott"; + description = "Package providing fnott."; + }; + + extraFlags = mkOption { + type = types.listOf types.str; + default = [ ]; + example = [ "-s" ]; + description = '' + Extra arguments to use for executing fnott. + ''; + }; + + configFile = mkOption { + type = types.either types.str types.path; + default = "${config.xdg.configHome}/fnott/fnott.ini"; + defaultText = "$XDG_CONFIG_HOME/fnott/fnott.ini"; + description = '' + Path to the configuration file read by fnott. + + Note that environment variables in the path won't be properly expanded. + + The configuration specified under + will be generated and + written to $XDG_CONFIG_HOME/fnott/fnott.ini + regardless of this option. This allows using a mutable configuration file + generated from the immutable one, useful in scenarios where live reloading is desired. + ''; + }; + + settings = mkOption { + type = iniFormat.type; + default = { }; + description = '' + Configuration written to + $XDG_CONFIG_HOME/fnott/fnott.ini. + + See + + fnott.ini + 5 + for a list of avaliable options and + for an example configuration. + ''; + example = literalExpression '' + { + main = { + notification-margin = 5; + }; + + low = { + timeout = 5; + title-font = "Dina:weight=bold:slant=italic"; + title-color = "ffffff"; + }; + } + ''; + }; + }; + }; + + config = mkIf cfg.enable { + assertions = + [ (hm.assertions.assertPlatform "services.fnott" pkgs platforms.linux) ]; + + home.packages = [ cfg.package ]; + + systemd.user.services.fnott = { + Unit = { + Description = "Fnott notification daemon"; + Documentation = "man:fnott(1)"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Service = { + Type = "dbus"; + BusName = "org.freedesktop.Notifications"; + ExecStart = concatStringsSep' " " [ + "${cfg.package}/bin/fnott" + "-c ${escapeShellArg cfg.configFile}" + (escapeShellArgs cfg.extraFlags) + ]; + }; + }; + + xdg.configFile."fnott/fnott.ini".source = + iniFormat.generate "fnott.ini" cfg.settings; + }; +} diff --git a/third_party/home-manager/modules/services/getmail.nix b/third_party/home-manager/modules/services/getmail.nix index e7a1b1a462..83ed4ed456 100644 --- a/third_party/home-manager/modules/services/getmail.nix +++ b/third_party/home-manager/modules/services/getmail.nix @@ -37,6 +37,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.getmail" pkgs + lib.platforms.linux) + ]; + systemd.user.services.getmail = { Unit = { Description = "getmail email fetcher"; }; Service = { ExecStart = "${pkgs.getmail}/bin/getmail ${configFiles}"; }; diff --git a/third_party/home-manager/modules/services/git-sync.nix b/third_party/home-manager/modules/services/git-sync.nix new file mode 100644 index 0000000000..07a7927126 --- /dev/null +++ b/third_party/home-manager/modules/services/git-sync.nix @@ -0,0 +1,100 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.git-sync; + + mkUnit = name: repo: { + Unit.Description = "Git Sync ${name}"; + + Install.WantedBy = [ "default.target" ]; + + Service = { + Environment = [ + "GIT_SYNC_DIRECTORY=${repo.path}" + "GIT_SYNC_COMMAND=${cfg.package}/bin/git-sync" + "GIT_SYNC_REPOSITORY=${repo.uri}" + "GIT_SYNC_INTERVAL=${toString repo.interval}" + ]; + ExecStart = "${cfg.package}/bin/git-sync-on-inotify"; + Restart = "on-abort"; + }; + }; + + services = mapAttrs' (name: repo: { + name = "git-sync-${name}"; + value = mkUnit name repo; + }) cfg.repositories; + + repositoryType = types.submodule ({ name, ... }: { + options = { + name = mkOption { + internal = true; + default = name; + type = types.str; + description = "The name that should be given to this unit."; + }; + + path = mkOption { + type = types.path; + description = "The path at which to sync the repository"; + }; + + uri = mkOption { + type = types.str; + example = "git+ssh://user@example.com:/~[user]/path/to/repo.git"; + description = '' + The URI of the remote to be synchronized. This is only used in the + event that the directory does not already exist. See + + for the supported URIs. + ''; + }; + + interval = mkOption { + type = types.int; + default = 500; + description = '' + The interval, specified in seconds, at which the synchronization will + be triggered even without filesystem changes. + ''; + }; + }; + }); + +in { + meta.maintainers = [ maintainers.imalison ]; + + options = { + services.git-sync = { + enable = mkEnableOption "git-sync services"; + + package = mkOption { + type = types.package; + default = pkgs.git-sync; + defaultText = literalExpression "pkgs.git-sync"; + description = '' + Package containing the git-sync program. + ''; + }; + + repositories = mkOption { + type = with types; attrsOf repositoryType; + description = '' + The repositories that should be synchronized. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.git-sync" pkgs + lib.platforms.linux) + ]; + + systemd.user.services = services; + }; +} diff --git a/third_party/home-manager/modules/services/gnome-keyring.nix b/third_party/home-manager/modules/services/gnome-keyring.nix index 7e3f8bbce2..7267129d7e 100644 --- a/third_party/home-manager/modules/services/gnome-keyring.nix +++ b/third_party/home-manager/modules/services/gnome-keyring.nix @@ -25,6 +25,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.gnome-keyring" pkgs + lib.platforms.linux) + ]; + systemd.user.services.gnome-keyring = { Unit = { Description = "GNOME Keyring"; diff --git a/third_party/home-manager/modules/services/gpg-agent.nix b/third_party/home-manager/modules/services/gpg-agent.nix index 785c23b4b1..785f11141c 100644 --- a/third_party/home-manager/modules/services/gpg-agent.nix +++ b/third_party/home-manager/modules/services/gpg-agent.nix @@ -20,22 +20,19 @@ let # we cannot use `gpgconf` directly because it heavily depends on system # state, but we need the values at build time. original: # https://github.com/gpg/gnupg/blob/c6702d77d936b3e9d91b34d8fdee9599ab94ee1b/common/homedir.c#L672-L681 - gpgconf = dir: let - f = pkgs.runCommand dir {} '' - PATH=${pkgs.coreutils}/bin:${pkgs.xxd}/bin:$PATH + gpgconf = dir: + if homedir == options.programs.gpg.homedir.default then + "%t/gnupg/${dir}" + else + builtins.readFile (pkgs.runCommand dir {} '' + PATH=${pkgs.xxd}/bin:$PATH - if [[ ${homedir} = ${options.programs.gpg.homedir.default} ]] - then - echo -n "%t/gnupg/${dir}" > $out - else hash=$(echo -n ${homedir} | sha1sum -b | xxd -r -p | base32 | \ cut -c -24 | tr '[:upper:]' '[:lower:]' | \ tr abcdefghijklmnopqrstuvwxyz234567 \ ybndrfg8ejkmcpqxot1uwisza345h769) - echo -n "%t/gnupg/d.$hash/${dir}" > $out - fi - ''; - in "${builtins.readFile f}"; + echo -n "%t/gnupg/d.$hash/${dir}" > "$out" + ''); in @@ -203,10 +200,11 @@ in [ cfg.extraConfig ] ); - home.sessionVariables = - optionalAttrs cfg.enableSshSupport { - SSH_AUTH_SOCK = "$(${gpgPkg}/bin/gpgconf --list-dirs agent-ssh-socket)"; - }; + home.sessionVariablesExtra = optionalString cfg.enableSshSupport '' + if [[ -z "$SSH_AUTH_SOCK" ]]; then + export SSH_AUTH_SOCK="$(${gpgPkg}/bin/gpgconf --list-dirs agent-ssh-socket)" + fi + ''; programs.bash.initExtra = gpgInitStr; programs.zsh.initExtra = gpgInitStr; diff --git a/third_party/home-manager/modules/services/grobi.nix b/third_party/home-manager/modules/services/grobi.nix index 4dfc5d6331..2f64310996 100644 --- a/third_party/home-manager/modules/services/grobi.nix +++ b/third_party/home-manager/modules/services/grobi.nix @@ -31,7 +31,7 @@ in { rules = mkOption { type = with types; listOf (attrsOf eitherStrBoolIntList); default = [ ]; - example = literalExample '' + example = literalExpression '' [ { name = "Home"; @@ -71,6 +71,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.grobi" pkgs + lib.platforms.linux) + ]; + systemd.user.services.grobi = { Unit = { Description = "grobi display auto config daemon"; diff --git a/third_party/home-manager/modules/services/hound.nix b/third_party/home-manager/modules/services/hound.nix index 07b5d47653..ff18a381ad 100644 --- a/third_party/home-manager/modules/services/hound.nix +++ b/third_party/home-manager/modules/services/hound.nix @@ -45,7 +45,7 @@ in { repositories = mkOption { type = types.attrsOf jsonFormat.type; default = { }; - example = literalExample '' + example = literalExpression '' { SomeGitRepo = { url = "https://www.github.com/YourOrganization/RepoOne.git"; @@ -59,6 +59,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.hound" pkgs + lib.platforms.linux) + ]; + home.packages = [ pkgs.hound ]; systemd.user.services.hound = { diff --git a/third_party/home-manager/modules/services/imapnotify-accounts.nix b/third_party/home-manager/modules/services/imapnotify-accounts.nix index 94bdce5dfb..5d8418310a 100644 --- a/third_party/home-manager/modules/services/imapnotify-accounts.nix +++ b/third_party/home-manager/modules/services/imapnotify-accounts.nix @@ -29,5 +29,12 @@ with lib; example = [ "Inbox" "[Gmail]/MyLabel" ]; description = "IMAP folders to watch."; }; + + extraConfig = mkOption { + type = with types; attrsOf (oneOf [ bool int str ]); + default = { }; + example = { wait = 10; }; + description = "Additional configuration to add for this account."; + }; }; } diff --git a/third_party/home-manager/modules/services/imapnotify.nix b/third_party/home-manager/modules/services/imapnotify.nix index 4b3ebda71c..d33124522d 100644 --- a/third_party/home-manager/modules/services/imapnotify.nix +++ b/third_party/home-manager/modules/services/imapnotify.nix @@ -44,17 +44,19 @@ let 143; toJSON = builtins.toJSON; - in toJSON { + in toJSON ({ inherit (account.imap) host; inherit port; tls = account.imap.tls.enable; username = account.userName; passwordCmd = lib.concatMapStringsSep " " lib.escapeShellArg account.passwordCommand; - onNewMail = account.imapnotify.onNotify; - onNewMailPost = account.imapnotify.onNotifyPost; inherit (account.imapnotify) boxes; - }); + } // optionalAttrs (account.imapnotify.onNotify != "") { + onNewMail = account.imapnotify.onNotify; + } // optionalAttrs (account.imapnotify.onNotifyPost != "") { + onNewMailPost = account.imapnotify.onNotifyPost; + } // account.imapnotify.extraConfig)); in { meta.maintainers = [ maintainers.nickhu ]; @@ -77,6 +79,8 @@ 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") diff --git a/third_party/home-manager/modules/services/kanshi.nix b/third_party/home-manager/modules/services/kanshi.nix index 8df32121af..e482e9b8cb 100644 --- a/third_party/home-manager/modules/services/kanshi.nix +++ b/third_party/home-manager/modules/services/kanshi.nix @@ -104,23 +104,26 @@ let }; exec = mkOption { - type = types.nullOr types.str; - default = null; + type = with types; coercedTo str singleton (listOf str); + default = [ ]; example = - "\${pkg.sway}/bin/swaymsg workspace 1, move workspace to eDP-1"; + "[ \${pkg.sway}/bin/swaymsg workspace 1, move workspace to eDP-1 ]"; description = '' - Command executed after the profile is succesfully applied. + Commands executed after the profile is succesfully applied. + Note that if you provide multiple commands, they will be + executed asynchronously with no guaranteed ordering. ''; }; }; }; profileStr = name: - { outputs, exec, ... }: - '' + { outputs, exec, ... }: '' profile ${name} { - ${concatStringsSep "\n " (map outputStr outputs)} - '' + optionalString (exec != null) " exec ${exec}\n" + '' + ${ + concatStringsSep "\n " + (map outputStr outputs ++ map (cmd: "exec ${cmd}") exec) + } } ''; in { @@ -134,7 +137,7 @@ in { package = mkOption { type = types.package; default = pkgs.kanshi; - defaultText = literalExample "pkgs.kanshi"; + defaultText = literalExpression "pkgs.kanshi"; description = '' kanshi derivation to use. ''; @@ -146,7 +149,7 @@ in { description = '' List of profiles. ''; - example = literalExample '' + example = literalExpression '' undocked = { outputs = [ { @@ -187,6 +190,10 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.kanshi" pkgs + lib.platforms.linux) + ]; xdg.configFile."kanshi/config".text = '' ${concatStringsSep "\n" (mapAttrsToList profileStr cfg.profiles)} diff --git a/third_party/home-manager/modules/services/kbfs.nix b/third_party/home-manager/modules/services/kbfs.nix index d4be2592c0..4f1bfd8bfb 100644 --- a/third_party/home-manager/modules/services/kbfs.nix +++ b/third_party/home-manager/modules/services/kbfs.nix @@ -32,6 +32,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.kbfs" pkgs + lib.platforms.linux) + ]; + systemd.user.services.kbfs = { Unit = { Description = "Keybase File System"; diff --git a/third_party/home-manager/modules/services/keybase.nix b/third_party/home-manager/modules/services/keybase.nix index 0aec0bbc85..f6e4008662 100644 --- a/third_party/home-manager/modules/services/keybase.nix +++ b/third_party/home-manager/modules/services/keybase.nix @@ -10,6 +10,11 @@ in { options.services.keybase.enable = mkEnableOption "Keybase"; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.keybase" pkgs + lib.platforms.linux) + ]; + home.packages = [ pkgs.keybase ]; systemd.user.services.keybase = { diff --git a/third_party/home-manager/modules/services/keynav.nix b/third_party/home-manager/modules/services/keynav.nix index c7f1df373b..d83252e53b 100644 --- a/third_party/home-manager/modules/services/keynav.nix +++ b/third_party/home-manager/modules/services/keynav.nix @@ -10,6 +10,11 @@ in { options.services.keynav = { enable = mkEnableOption "keynav"; }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.keynav" pkgs + lib.platforms.linux) + ]; + systemd.user.services.keynav = { Unit = { Description = "keynav"; diff --git a/third_party/home-manager/modules/services/lieer-accounts.nix b/third_party/home-manager/modules/services/lieer-accounts.nix deleted file mode 100644 index 187f7dff98..0000000000 --- a/third_party/home-manager/modules/services/lieer-accounts.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ lib, ... }: - -with lib; - -{ - options.lieer.sync = { - enable = mkEnableOption "lieer synchronization service"; - - frequency = mkOption { - type = types.str; - default = "*:0/5"; - description = '' - How often to synchronize the account. - - This value is passed to the systemd timer configuration as the - onCalendar option. See - - systemd.time - 7 - - for more information about the format. - ''; - }; - }; -} diff --git a/third_party/home-manager/modules/services/lieer.nix b/third_party/home-manager/modules/services/lieer.nix index 71f0a66e5d..6e4be8ca05 100644 --- a/third_party/home-manager/modules/services/lieer.nix +++ b/third_party/home-manager/modules/services/lieer.nix @@ -51,16 +51,15 @@ let in { meta.maintainers = [ maintainers.tadfisher ]; - options = { - services.lieer.enable = - mkEnableOption "lieer Gmail synchronization service"; - - accounts.email.accounts = mkOption { - type = with types; attrsOf (submodule (import ./lieer-accounts.nix)); - }; - }; + options.services.lieer.enable = + mkEnableOption "lieer Gmail synchronization service"; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.lieer" pkgs + lib.platforms.linux) + ]; + programs.lieer.enable = true; systemd.user.services = listToAttrs (map serviceUnit syncAccounts); systemd.user.timers = listToAttrs (map timerUnit syncAccounts); diff --git a/third_party/home-manager/modules/services/lorri.nix b/third_party/home-manager/modules/services/lorri.nix index 6183699088..0a49cb5454 100644 --- a/third_party/home-manager/modules/services/lorri.nix +++ b/third_party/home-manager/modules/services/lorri.nix @@ -15,12 +15,17 @@ in { package = mkOption { type = types.package; default = pkgs.lorri; - defaultText = literalExample "pkgs.lorri"; + defaultText = literalExpression "pkgs.lorri"; description = "Which lorri package to install."; }; }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.lorri" pkgs + lib.platforms.linux) + ]; + home.packages = [ cfg.package ]; systemd.user = { diff --git a/third_party/home-manager/modules/services/mako.nix b/third_party/home-manager/modules/services/mako.nix index e8f4d38c2e..67c11e314f 100644 --- a/third_party/home-manager/modules/services/mako.nix +++ b/third_party/home-manager/modules/services/mako.nix @@ -274,7 +274,7 @@ in { extraConfig = mkOption { default = ""; type = types.lines; - example = literalExample '' + example = literalExpression '' [urgency=low] border-color=#b8bb26 ''; @@ -292,36 +292,45 @@ in { optionalString = name: val: lib.optionalString (val != null) "${name}=${val}"; in mkIf cfg.enable { + assertions = + [ (hm.assertions.assertPlatform "services.mako" pkgs platforms.linux) ]; + home.packages = [ pkgs.mako ]; - xdg.configFile."mako/config".text = '' - ${optionalInteger "max-visible" cfg.maxVisible} - ${optionalString "sort" cfg.sort} - ${optionalString "output" cfg.output} - ${optionalString "layer" cfg.layer} - ${optionalString "anchor" cfg.anchor} - ${optionalString "font" cfg.font} - ${optionalString "background-color" cfg.backgroundColor} - ${optionalString "text-color" cfg.textColor} - ${optionalInteger "width" cfg.width} - ${optionalInteger "height" cfg.height} - ${optionalString "margin" cfg.margin} - ${optionalString "padding" cfg.padding} - ${optionalInteger "border-size" cfg.borderSize} - ${optionalString "border-color" cfg.borderColor} - ${optionalInteger "border-radius" cfg.borderRadius} - ${optionalString "progress-color" cfg.progressColor} - ${optionalBoolean "icons" cfg.icons} - ${optionalInteger "max-icon-size" cfg.maxIconSize} - ${optionalString "icon-path" cfg.iconPath} - ${optionalBoolean "markup" cfg.markup} - ${optionalBoolean "actions" cfg.actions} - ${optionalString "format" cfg.format} - ${optionalInteger "default-timeout" cfg.defaultTimeout} - ${optionalBoolean "ignore-timeout" cfg.ignoreTimeout} - ${optionalString "group-by" cfg.groupBy} + xdg.configFile."mako/config" = { + onChange = '' + ${pkgs.mako}/bin/makoctl reload || true + ''; + text = '' + ${optionalInteger "max-visible" cfg.maxVisible} + ${optionalString "sort" cfg.sort} + ${optionalString "output" cfg.output} + ${optionalString "layer" cfg.layer} + ${optionalString "anchor" cfg.anchor} - ${cfg.extraConfig} - ''; + ${optionalString "font" cfg.font} + ${optionalString "background-color" cfg.backgroundColor} + ${optionalString "text-color" cfg.textColor} + ${optionalInteger "width" cfg.width} + ${optionalInteger "height" cfg.height} + ${optionalString "margin" cfg.margin} + ${optionalString "padding" cfg.padding} + ${optionalInteger "border-size" cfg.borderSize} + ${optionalString "border-color" cfg.borderColor} + ${optionalInteger "border-radius" cfg.borderRadius} + ${optionalString "progress-color" cfg.progressColor} + ${optionalBoolean "icons" cfg.icons} + ${optionalInteger "max-icon-size" cfg.maxIconSize} + ${optionalString "icon-path" cfg.iconPath} + ${optionalBoolean "markup" cfg.markup} + ${optionalBoolean "actions" cfg.actions} + ${optionalString "format" cfg.format} + ${optionalInteger "default-timeout" cfg.defaultTimeout} + ${optionalBoolean "ignore-timeout" cfg.ignoreTimeout} + ${optionalString "group-by" cfg.groupBy} + + ${cfg.extraConfig} + ''; + }; }; } diff --git a/third_party/home-manager/modules/services/mbsync.nix b/third_party/home-manager/modules/services/mbsync.nix index ac6ac1ef78..bdeda0ec9f 100644 --- a/third_party/home-manager/modules/services/mbsync.nix +++ b/third_party/home-manager/modules/services/mbsync.nix @@ -18,8 +18,8 @@ in { package = mkOption { type = types.package; default = pkgs.isync; - defaultText = literalExample "pkgs.isync"; - example = literalExample "pkgs.isync"; + defaultText = literalExpression "pkgs.isync"; + example = literalExpression "pkgs.isync"; description = "The package to use for the mbsync binary."; }; @@ -76,6 +76,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.mbsync" pkgs + lib.platforms.linux) + ]; + systemd.user.services.mbsync = { Unit = { Description = "mbsync mailbox synchronization"; }; diff --git a/third_party/home-manager/modules/services/mpd.nix b/third_party/home-manager/modules/services/mpd.nix index a6ed0a4831..5800a18c15 100644 --- a/third_party/home-manager/modules/services/mpd.nix +++ b/third_party/home-manager/modules/services/mpd.nix @@ -143,6 +143,10 @@ in { ###### implementation config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.mpd" pkgs + lib.platforms.linux) + ]; systemd.user.services.mpd = { Unit = { diff --git a/third_party/home-manager/modules/services/mpdris2.nix b/third_party/home-manager/modules/services/mpdris2.nix index cb8cefba6b..bf9b783b3b 100644 --- a/third_party/home-manager/modules/services/mpdris2.nix +++ b/third_party/home-manager/modules/services/mpdris2.nix @@ -40,7 +40,7 @@ in { package = mkOption { type = types.package; default = pkgs.mpdris2; - defaultText = literalExample "pkgs.mpdris2"; + defaultText = literalExpression "pkgs.mpdris2"; description = "The mpDris2 package to use."; }; @@ -74,10 +74,15 @@ in { }; config = mkIf cfg.enable { - assertions = [{ - assertion = config.services.mpd.enable; - message = "The mpdris2 module requires 'services.mpd.enable = true'."; - }]; + assertions = [ + (lib.hm.assertions.assertPlatform "services.mpdris2" pkgs + lib.platforms.linux) + + { + assertion = config.services.mpd.enable; + message = "The mpdris2 module requires 'services.mpd.enable = true'."; + } + ]; xdg.configFile."mpDris2/mpDris2.conf".text = toIni mpdris2Conf; diff --git a/third_party/home-manager/modules/services/mpris-proxy.nix b/third_party/home-manager/modules/services/mpris-proxy.nix index 69f56c21f5..9996b1376f 100644 --- a/third_party/home-manager/modules/services/mpris-proxy.nix +++ b/third_party/home-manager/modules/services/mpris-proxy.nix @@ -13,6 +13,11 @@ in { "a proxy forwarding Bluetooth MIDI controls via MPRIS2 to control media players"; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.mpris-proxy" pkgs + lib.platforms.linux) + ]; + systemd.user.services.mpris-proxy = { Unit = { Description = diff --git a/third_party/home-manager/modules/services/muchsync.nix b/third_party/home-manager/modules/services/muchsync.nix index b7004418d3..8c9e27014b 100644 --- a/third_party/home-manager/modules/services/muchsync.nix +++ b/third_party/home-manager/modules/services/muchsync.nix @@ -135,7 +135,7 @@ in { remotes = mkOption { type = with types; attrsOf (submodule syncOptions); default = { }; - example = literalExample '' + example = literalExpression '' { server = { frequency = "*:0/10"; @@ -156,12 +156,16 @@ in { (name: remoteCfg: nameValuePair "muchsync-${name}" (gen name remoteCfg)) cfg.remotes; in mkIf (cfg.remotes != { }) { - assertions = [{ - assertion = config.programs.notmuch.enable; - message = '' - The muchsync module requires 'programs.notmuch.enable = true'. - ''; - }]; + assertions = [ + (hm.assertions.assertPlatform "services.muchsync" pkgs platforms.linux) + + { + assertion = config.programs.notmuch.enable; + message = '' + The muchsync module requires 'programs.notmuch.enable = true'. + ''; + } + ]; systemd.user.services = mapRemotes (name: remoteCfg: { Unit = { Description = "muchsync sync service (${name})"; }; diff --git a/third_party/home-manager/modules/services/network-manager-applet.nix b/third_party/home-manager/modules/services/network-manager-applet.nix index b84861a998..f4abe86e0a 100644 --- a/third_party/home-manager/modules/services/network-manager-applet.nix +++ b/third_party/home-manager/modules/services/network-manager-applet.nix @@ -16,6 +16,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.network-manager-applet" pkgs + lib.platforms.linux) + ]; + systemd.user.services.network-manager-applet = { Unit = { Description = "Network Manager applet"; diff --git a/third_party/home-manager/modules/services/nextcloud-client.nix b/third_party/home-manager/modules/services/nextcloud-client.nix index 4e56c4f50f..b436488d16 100644 --- a/third_party/home-manager/modules/services/nextcloud-client.nix +++ b/third_party/home-manager/modules/services/nextcloud-client.nix @@ -14,7 +14,7 @@ in { package = mkOption { type = types.package; default = pkgs.nextcloud-client; - defaultText = literalExample "pkgs.nextcloud-client"; + defaultText = literalExpression "pkgs.nextcloud-client"; description = "The package to use for the nextcloud client binary."; }; @@ -28,6 +28,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.nextcloud-client" pkgs + lib.platforms.linux) + ]; + systemd.user.services.nextcloud-client = { Unit = { Description = "Nextcloud Client"; diff --git a/third_party/home-manager/modules/services/notify-osd.nix b/third_party/home-manager/modules/services/notify-osd.nix new file mode 100644 index 0000000000..6a75ce6e6f --- /dev/null +++ b/third_party/home-manager/modules/services/notify-osd.nix @@ -0,0 +1,48 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.notify-osd; + +in { + meta.maintainers = [ maintainers.imalison ]; + + options = { + services.notify-osd = { + enable = mkEnableOption "notify-osd"; + + package = mkOption { + type = types.package; + default = pkgs.notify-osd; + defaultText = literalExpression "pkgs.notify-osd"; + description = '' + Package containing the notify-osd program. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.notify-osd" pkgs + lib.platforms.linux) + ]; + + systemd.user.services.notify-osd = { + Unit = { + Description = "notify-osd"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install.WantedBy = [ "graphical-session.target" ]; + + Service = { + ExecStart = "${cfg.package}/bin/notify-osd"; + Restart = "on-abort"; + }; + }; + }; +} diff --git a/third_party/home-manager/modules/services/pantalaimon.nix b/third_party/home-manager/modules/services/pantalaimon.nix index 38662a346c..d833d45397 100644 --- a/third_party/home-manager/modules/services/pantalaimon.nix +++ b/third_party/home-manager/modules/services/pantalaimon.nix @@ -17,7 +17,7 @@ in { package = mkOption { type = types.package; default = pkgs.pantalaimon; - defaultText = literalExample "pkgs.pantalaimon"; + defaultText = literalExpression "pkgs.pantalaimon"; description = "Package providing the pantalaimon executable to use."; }; @@ -25,8 +25,8 @@ in { settings = mkOption { type = iniFmt.type; default = { }; - defaultText = literalExample "{ }"; - example = literalExample '' + defaultText = literalExpression "{ }"; + example = literalExpression '' { Default = { LogLevel = "Debug"; @@ -55,6 +55,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.pantalaimon" pkgs + lib.platforms.linux) + ]; + home.packages = [ cfg.package ]; systemd.user.services = { diff --git a/third_party/home-manager/modules/services/parcellite.nix b/third_party/home-manager/modules/services/parcellite.nix index dddb0631de..6ed9946b4d 100644 --- a/third_party/home-manager/modules/services/parcellite.nix +++ b/third_party/home-manager/modules/services/parcellite.nix @@ -15,13 +15,18 @@ in { package = mkOption { type = types.package; default = pkgs.parcellite; - defaultText = literalExample "pkgs.parcellite"; - example = literalExample "pkgs.clipit"; + defaultText = literalExpression "pkgs.parcellite"; + example = literalExpression "pkgs.clipit"; description = "Parcellite derivation to use."; }; }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.parcellite" pkgs + lib.platforms.linux) + ]; + home.packages = [ cfg.package ]; systemd.user.services.parcellite = { diff --git a/third_party/home-manager/modules/services/pass-secret-service.nix b/third_party/home-manager/modules/services/pass-secret-service.nix index d2ed11ee70..06b5be1f88 100644 --- a/third_party/home-manager/modules/services/pass-secret-service.nix +++ b/third_party/home-manager/modules/services/pass-secret-service.nix @@ -9,11 +9,16 @@ in { enable = mkEnableOption "Pass libsecret service"; }; config = mkIf serviceCfg.enable { - assertions = [{ - assertion = config.programs.password-store.enable; - message = "The 'services.pass-secret-service' module requires" - + " 'programs.password-store.enable = true'."; - }]; + assertions = [ + (hm.assertions.assertPlatform "services.pass-secret-service" pkgs + platforms.linux) + + { + assertion = config.programs.password-store.enable; + message = "The 'services.pass-secret-service' module requires" + + " 'programs.password-store.enable = true'."; + } + ]; systemd.user.services.pass-secret-service = { Unit = { Description = "Pass libsecret service"; }; diff --git a/third_party/home-manager/modules/services/password-store-sync.nix b/third_party/home-manager/modules/services/password-store-sync.nix index 8193391498..c8dbe808fb 100644 --- a/third_party/home-manager/modules/services/password-store-sync.nix +++ b/third_party/home-manager/modules/services/password-store-sync.nix @@ -33,11 +33,16 @@ in { }; config = mkIf serviceCfg.enable { - assertions = [{ - assertion = programCfg.enable; - message = "The 'services.password-store-sync' module requires" - + " 'programs.password-store.enable = true'."; - }]; + assertions = [ + (hm.assertions.assertPlatform "services.password-store-sync" pkgs + platforms.linux) + + { + assertion = programCfg.enable; + message = "The 'services.password-store-sync' module requires" + + " 'programs.password-store.enable = true'."; + } + ]; systemd.user.services.password-store-sync = { Unit = { Description = "Password store sync"; }; diff --git a/third_party/home-manager/modules/services/pbgopy.nix b/third_party/home-manager/modules/services/pbgopy.nix index f4fd4f53fe..487aa4f36b 100644 --- a/third_party/home-manager/modules/services/pbgopy.nix +++ b/third_party/home-manager/modules/services/pbgopy.nix @@ -50,6 +50,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.pbgopy" pkgs + lib.platforms.linux) + ]; + home.packages = [ package ]; systemd.user.services.pbgopy = { diff --git a/third_party/home-manager/modules/services/picom.nix b/third_party/home-manager/modules/services/picom.nix index 4c4da8de69..280a2a21ed 100644 --- a/third_party/home-manager/modules/services/picom.nix +++ b/third_party/home-manager/modules/services/picom.nix @@ -262,8 +262,8 @@ in { package = mkOption { type = types.package; default = pkgs.picom; - defaultText = literalExample "pkgs.picom"; - example = literalExample "pkgs.picom"; + defaultText = literalExpression "pkgs.picom"; + example = literalExpression "pkgs.picom"; description = '' picom derivation to use. ''; @@ -283,6 +283,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.picom" pkgs + lib.platforms.linux) + ]; + home.packages = [ cfg.package ]; systemd.user.services.picom = { diff --git a/third_party/home-manager/modules/services/plan9port.nix b/third_party/home-manager/modules/services/plan9port.nix index 0f5893f21b..249804724f 100644 --- a/third_party/home-manager/modules/services/plan9port.nix +++ b/third_party/home-manager/modules/services/plan9port.nix @@ -16,7 +16,10 @@ in { mkEnableOption "the Plan 9 file system for interprocess messaging"; }; - config = { + config = mkIf (cfg.fontsrv.enable || cfg.plumber.enable) { + assertions = [ + (hm.assertions.assertPlatform "services.plan9port" pkgs platforms.linux) + ]; systemd.user.services.fontsrv = mkIf cfg.fontsrv.enable { Unit.Description = "the Plan 9 file system access to host fonts"; diff --git a/third_party/home-manager/modules/services/playerctld.nix b/third_party/home-manager/modules/services/playerctld.nix index 63e7b8feb2..dccc1ecc00 100644 --- a/third_party/home-manager/modules/services/playerctld.nix +++ b/third_party/home-manager/modules/services/playerctld.nix @@ -15,12 +15,17 @@ in { package = mkOption { type = types.package; default = pkgs.playerctl; - defaultText = literalExample "pkgs.playerctl"; + defaultText = literalExpression "pkgs.playerctl"; description = "The playerctl package to use."; }; }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.playerctld" pkgs + lib.platforms.linux) + ]; + systemd.user.services.playerctld = { Unit.Description = "MPRIS media player daemon"; diff --git a/third_party/home-manager/modules/services/polybar.nix b/third_party/home-manager/modules/services/polybar.nix index 8a8e99942b..8d341252fe 100644 --- a/third_party/home-manager/modules/services/polybar.nix +++ b/third_party/home-manager/modules/services/polybar.nix @@ -68,9 +68,9 @@ in { package = mkOption { type = types.package; default = pkgs.polybar; - defaultText = literalExample "pkgs.polybar"; + defaultText = literalExpression "pkgs.polybar"; description = "Polybar package to install."; - example = literalExample '' + example = literalExpression '' pkgs.polybar.override { i3GapsSupport = true; alsaSupport = true; @@ -90,7 +90,7 @@ in { See also for a more nix-friendly format. ''; default = { }; - example = literalExample '' + example = literalExpression '' { "bar/top" = { monitor = "\''${env:MONITOR:eDP1}"; @@ -147,7 +147,7 @@ in { ''; default = { }; - example = literalExample '' + example = literalExpression '' { "module/volume" = { type = "internal/pulseaudio"; @@ -191,6 +191,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.polybar" pkgs + lib.platforms.linux) + ]; + home.packages = [ cfg.package ]; xdg.configFile."polybar/config".source = configFile; diff --git a/third_party/home-manager/modules/services/poweralertd.nix b/third_party/home-manager/modules/services/poweralertd.nix index 39fffd7cdd..cae44c753c 100644 --- a/third_party/home-manager/modules/services/poweralertd.nix +++ b/third_party/home-manager/modules/services/poweralertd.nix @@ -11,6 +11,11 @@ in { mkEnableOption "the Upower-powered power alerterd"; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.poweralertd" pkgs + lib.platforms.linux) + ]; + systemd.user.services.poweralertd = { Unit = { Description = "UPower-powered power alerter"; diff --git a/third_party/home-manager/modules/services/pulseeffects.nix b/third_party/home-manager/modules/services/pulseeffects.nix index 184c2af791..0181e39be9 100644 --- a/third_party/home-manager/modules/services/pulseeffects.nix +++ b/third_party/home-manager/modules/services/pulseeffects.nix @@ -12,14 +12,19 @@ in { meta.maintainers = [ maintainers.jonringer ]; options.services.pulseeffects = { - enable = mkEnableOption "Pulseeffects daemon"; + enable = mkEnableOption '' + Pulseeffects daemon + Note, it is necessary to add + + programs.dconf.enable = true; + + to your system configuration for the daemon to work correctly''; package = mkOption { type = types.package; - default = pkgs.pulseeffects; - defaultText = literalExample "pkgs.pulseeffects"; + default = pkgs.pulseeffects-legacy; + defaultText = literalExpression "pkgs.pulseeffects-legacy"; description = "Pulseeffects package to use."; - example = literalExample "pkgs.pulseeffects-pw"; }; preset = mkOption { @@ -33,14 +38,16 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.pulseeffects" pkgs + lib.platforms.linux) + ]; + # running pulseeffects will just attach itself to gapplication service # at-spi2-core is to minimize journalctl noise of: # "AT-SPI: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files" home.packages = [ cfg.package pkgs.at-spi2-core ]; - # Will need to add `services.dbus.packages = with pkgs; [ gnome.dconf ];` - # to /etc/nixos/configuration.nix for daemon to work correctly - systemd.user.services.pulseeffects = { Unit = { Description = "Pulseeffects daemon"; diff --git a/third_party/home-manager/modules/services/redshift-gammastep/lib/options.nix b/third_party/home-manager/modules/services/redshift-gammastep/lib/options.nix index 11ce9d7ce1..475cca57c3 100644 --- a/third_party/home-manager/modules/services/redshift-gammastep/lib/options.nix +++ b/third_party/home-manager/modules/services/redshift-gammastep/lib/options.nix @@ -106,7 +106,7 @@ in { package = mkOption { type = types.package; default = defaultPackage; - defaultText = literalExample examplePackage; + defaultText = literalExpression examplePackage; description = '' ${programName} derivation to use. ''; @@ -124,7 +124,7 @@ in { settings = mkOption { type = types.submodule { freeformType = settingsFormat.type; }; default = { }; - example = literalExample '' + example = literalExpression '' { ${mainSection} = { adjustment-method = "randr"; @@ -146,20 +146,25 @@ in { }; config = { - assertions = [{ - assertion = (cfg.settings ? ${mainSection}.dawn-time || cfg.settings - ? ${mainSection}.dusk-time) - || (cfg.settings.${mainSection}.location-provider) == "geoclue2" - || ((cfg.settings.${mainSection}.location-provider) == "manual" - && (cfg.settings ? manual.lat || cfg.settings ? manual.lon)); - message = '' - In order for ${programName} to know the time of action, you need to set one of - - services.${moduleName}.provider = "geoclue2" for automatically inferring your location - (you also need to enable Geoclue2 service separately) - - services.${moduleName}.longitude and .latitude for specifying your location manually - - services.${moduleName}.dawnTime and .duskTime for specifying the times manually - ''; - }]; + assertions = [ + (hm.assertions.assertPlatform "services.${moduleName}" pkgs + platforms.linux) + + { + assertion = (cfg.settings ? ${mainSection}.dawn-time || cfg.settings + ? ${mainSection}.dusk-time) + || (cfg.settings.${mainSection}.location-provider) == "geoclue2" + || ((cfg.settings.${mainSection}.location-provider) == "manual" + && (cfg.settings ? manual.lat || cfg.settings ? manual.lon)); + message = '' + In order for ${programName} to know the time of action, you need to set one of + - services.${moduleName}.provider = "geoclue2" for automatically inferring your location + (you also need to enable Geoclue2 service separately) + - services.${moduleName}.longitude and .latitude for specifying your location manually + - services.${moduleName}.dawnTime and .duskTime for specifying the times manually + ''; + } + ]; services.${moduleName}.settings = { ${mainSection} = { diff --git a/third_party/home-manager/modules/services/rsibreak.nix b/third_party/home-manager/modules/services/rsibreak.nix index 5f07e6a092..351632a026 100644 --- a/third_party/home-manager/modules/services/rsibreak.nix +++ b/third_party/home-manager/modules/services/rsibreak.nix @@ -14,6 +14,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.rsibreak" pkgs + lib.platforms.linux) + ]; + home.packages = [ pkgs.rsibreak ]; systemd.user.services.rsibreak = { Unit = { diff --git a/third_party/home-manager/modules/services/screen-locker.nix b/third_party/home-manager/modules/services/screen-locker.nix index 554d64f9ab..34794d1c14 100644 --- a/third_party/home-manager/modules/services/screen-locker.nix +++ b/third_party/home-manager/modules/services/screen-locker.nix @@ -7,6 +7,20 @@ let cfg = config.services.screen-locker; in { + meta.maintainers = [ lib.hm.maintainers.jrobsonchase ]; + + imports = let + origOpt = name: [ "services" "screen-locker" name ]; + xautolockOpt = name: [ "services" "screen-locker" "xautolock" name ]; + xssLockOpt = name: [ "services" "screen-locker" "xss-lock" name ]; + in [ + (mkRenamedOptionModule (origOpt "xssLockExtraOptions") + (xssLockOpt "extraOptions")) + (mkRenamedOptionModule (origOpt "xautolockExtraOptions") + (xautolockOpt "extraOptions")) + (mkRenamedOptionModule (origOpt "enableDetectSleep") + (xautolockOpt "detectSleep")) + ]; options.services.screen-locker = { enable = mkEnableOption "screen locker for X session"; @@ -17,76 +31,118 @@ in { example = "\${pkgs.i3lock}/bin/i3lock -n -c 000000"; }; - enableDetectSleep = mkOption { - type = types.bool; - default = true; - description = '' - Whether to reset timers when awaking from sleep. - ''; - }; - inactiveInterval = mkOption { type = types.int; default = 10; description = '' Inactive time interval in minutes after which session will be locked. The minimum is 1 minute, and the maximum is 1 hour. + If is true, it will use this setting. See . + Otherwise, this will be used with xset to configure + the X server's screensaver timeout. ''; }; - xautolockExtraOptions = mkOption { - type = types.listOf types.str; - default = [ ]; - description = '' - Extra command-line arguments to pass to xautolock. - ''; - }; - - xssLockExtraOptions = mkOption { - type = types.listOf types.str; - default = [ ]; - description = '' - Extra command-line arguments to pass to xss-lock. - ''; - }; - }; - - config = mkIf cfg.enable { - systemd.user.services.xautolock-session = { - Unit = { - Description = "xautolock, session locker service"; - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; + xautolock = { + enable = mkOption { + type = types.bool; + default = true; + description = "Use xautolock for time-based locking."; }; - Install = { WantedBy = [ "graphical-session.target" ]; }; + package = mkOption { + type = types.package; + default = pkgs.xautolock; + description = '' + Package providing the xautolock binary. + ''; + }; - Service = { - ExecStart = concatStringsSep " " ([ - "${pkgs.xautolock}/bin/xautolock" - "-time ${toString cfg.inactiveInterval}" - "-locker '${pkgs.systemd}/bin/loginctl lock-session $XDG_SESSION_ID'" - ] ++ optional cfg.enableDetectSleep "-detectsleep" - ++ cfg.xautolockExtraOptions); + detectSleep = mkOption { + type = types.bool; + default = true; + description = '' + Whether to reset xautolock timers when awaking from sleep. + No effect if is false. + ''; + }; + + extraOptions = mkOption { + type = types.listOf types.str; + default = [ ]; + description = '' + Extra command-line arguments to pass to xautolock. + No effect if is false. + ''; }; }; - systemd.user.services.xss-lock = { - Unit = { - Description = "xss-lock, session locker service"; - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; + xss-lock = { + package = mkOption { + type = types.package; + default = pkgs.xss-lock; + description = '' + Package providing the xss-lock binary. + ''; }; - Install = { WantedBy = [ "graphical-session.target" ]; }; - - Service = { - ExecStart = concatStringsSep " " - ([ "${pkgs.xss-lock}/bin/xss-lock" "-s \${XDG_SESSION_ID}" ] - ++ cfg.xssLockExtraOptions ++ [ "-- ${cfg.lockCmd}" ]); + extraOptions = mkOption { + type = types.listOf types.str; + default = [ ]; + description = '' + Extra command-line arguments to pass to xss-lock. + ''; }; }; }; + config = mkIf cfg.enable (mkMerge [ + { + assertions = [ + (lib.hm.assertions.assertPlatform "services.screen-locker" pkgs + lib.platforms.linux) + ]; + + systemd.user.services.xss-lock = { + Unit = { + Description = "xss-lock, session locker service"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { WantedBy = [ "graphical-session.target" ]; }; + + Service = { + ExecStart = concatStringsSep " " + ([ "${cfg.xss-lock.package}/bin/xss-lock" "-s \${XDG_SESSION_ID}" ] + ++ cfg.xss-lock.extraOptions ++ [ "-- ${cfg.lockCmd}" ]); + }; + }; + } + (mkIf (!cfg.xautolock.enable) { + systemd.user.services.xss-lock.Service.ExecStartPre = + "${pkgs.xorg.xset}/bin/xset s ${toString (cfg.inactiveInterval * 60)}"; + }) + (mkIf cfg.xautolock.enable { + systemd.user.services.xautolock-session = { + Unit = { + Description = "xautolock, session locker service"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { WantedBy = [ "graphical-session.target" ]; }; + + Service = { + ExecStart = concatStringsSep " " ([ + "${cfg.xautolock.package}/bin/xautolock" + "-time ${toString cfg.inactiveInterval}" + "-locker '${pkgs.systemd}/bin/loginctl lock-session \${XDG_SESSION_ID}'" + ] ++ optional cfg.xautolock.detectSleep "-detectsleep" + ++ cfg.xautolock.extraOptions); + }; + }; + }) + ]); } diff --git a/third_party/home-manager/modules/services/spotifyd.nix b/third_party/home-manager/modules/services/spotifyd.nix index ee5af34518..b06749a359 100644 --- a/third_party/home-manager/modules/services/spotifyd.nix +++ b/third_party/home-manager/modules/services/spotifyd.nix @@ -17,9 +17,9 @@ in { package = mkOption { type = types.package; default = pkgs.spotifyd; - defaultText = literalExample "pkgs.spotifyd"; + defaultText = literalExpression "pkgs.spotifyd"; example = - literalExample "(pkgs.spotifyd.override { withKeyring = true; })"; + literalExpression "(pkgs.spotifyd.override { withKeyring = true; })"; description = '' The spotifyd package to use. Can be used to specify extensions. @@ -30,7 +30,7 @@ in { type = tomlFormat.type; default = { }; description = "Configuration for spotifyd"; - example = literalExample '' + example = literalExpression '' { global = { username = "Alex"; @@ -43,6 +43,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.spotifyd" pkgs + lib.platforms.linux) + ]; + home.packages = [ cfg.package ]; systemd.user.services.spotifyd = { diff --git a/third_party/home-manager/modules/services/stalonetray.nix b/third_party/home-manager/modules/services/stalonetray.nix index ec83a9a496..93fff3e7b5 100644 --- a/third_party/home-manager/modules/services/stalonetray.nix +++ b/third_party/home-manager/modules/services/stalonetray.nix @@ -13,9 +13,9 @@ in { package = mkOption { default = pkgs.stalonetray; - defaultText = literalExample "pkgs.stalonetray"; + defaultText = literalExpression "pkgs.stalonetray"; type = types.package; - example = literalExample "pkgs.stalonetray"; + example = literalExpression "pkgs.stalonetray"; description = "The package to use for the Stalonetray binary."; }; diff --git a/third_party/home-manager/modules/services/status-notifier-watcher.nix b/third_party/home-manager/modules/services/status-notifier-watcher.nix index 8ff1caceb8..8de09d7ddb 100644 --- a/third_party/home-manager/modules/services/status-notifier-watcher.nix +++ b/third_party/home-manager/modules/services/status-notifier-watcher.nix @@ -16,9 +16,9 @@ in { package = mkOption { default = pkgs.haskellPackages.status-notifier-item; defaultText = - literalExample "pkgs.haskellPackages.status-notifier-item"; + literalExpression "pkgs.haskellPackages.status-notifier-item"; type = types.package; - example = literalExample "pkgs.haskellPackages.status-notifier-item"; + example = literalExpression "pkgs.haskellPackages.status-notifier-item"; description = "The package to use for the status notifier watcher binary."; }; @@ -26,6 +26,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.status-notifier-watcher" pkgs + lib.platforms.linux) + ]; + systemd.user.services.status-notifier-watcher = { Unit = { Description = "SNI watcher"; diff --git a/third_party/home-manager/modules/services/sxhkd.nix b/third_party/home-manager/modules/services/sxhkd.nix index 9a2027a83e..79f17e3cd3 100644 --- a/third_party/home-manager/modules/services/sxhkd.nix +++ b/third_party/home-manager/modules/services/sxhkd.nix @@ -1,4 +1,4 @@ -{config, lib, pkgs, ...}: +{ config, lib, pkgs, ... }: with lib; @@ -6,22 +6,16 @@ let cfg = config.services.sxhkd; - keybindingsStr = concatStringsSep "\n" ( - mapAttrsToList (hotkey: command: - optionalString (command != null) '' - ${hotkey} - ${command} - '' - ) - cfg.keybindings - ); + keybindingsStr = concatStringsSep "\n" (mapAttrsToList (hotkey: command: + optionalString (command != null) '' + ${hotkey} + ${command} + '') cfg.keybindings); -in - -{ +in { imports = [ - (mkRemovedOptionModule ["services" "sxhkd" "extraPath"] - "This option is no longer needed and can be removed.") + (mkRemovedOptionModule [ "services" "sxhkd" "extraPath" ] + "This option is no longer needed and can be removed.") ]; options.services.sxhkd = { @@ -31,21 +25,23 @@ in type = types.package; default = pkgs.sxhkd; defaultText = "pkgs.sxhkd"; - description = "Package containing the sxhkd executable."; + description = + "Package containing the sxhkd executable."; }; extraOptions = mkOption { type = types.listOf types.str; default = [ ]; - description = "Command line arguments to invoke sxhkd with."; - example = literalExample ''[ "-m 1" ]''; + description = + "Command line arguments to invoke sxhkd with."; + example = literalExpression ''[ "-m 1" ]''; }; keybindings = mkOption { type = types.attrsOf (types.nullOr types.str); - default = {}; + default = { }; description = "An attribute set that assigns hotkeys to commands."; - example = literalExample '' + example = literalExpression '' { "super + shift + {r,c}" = "i3-msg {restart,reload}"; "super + {s,w}" = "i3-msg {stacking,tabbed}"; @@ -57,7 +53,7 @@ in default = ""; type = types.lines; description = "Additional configuration to add."; - example = literalExample '' + example = literalExpression '' super + {_,shift +} {1-9,0} i3-msg {workspace,move container to workspace} {1-10} ''; @@ -65,19 +61,21 @@ in }; config = mkIf cfg.enable { - home.packages = [ cfg.package ]; - - xdg.configFile."sxhkd/sxhkdrc".text = concatStringsSep "\n" [ - keybindingsStr - cfg.extraConfig + assertions = [ + (lib.hm.assertions.assertPlatform "services.sxhkd" pkgs + lib.platforms.linux) ]; - xsession.initExtra = - let - sxhkdCommand = "${cfg.package}/bin/sxhkd ${toString cfg.extraOptions}"; - in '' - systemctl --user stop sxhkd.scope 2> /dev/null || true - systemd-cat -t sxhkd systemd-run --user --scope -u sxhkd ${sxhkdCommand} & - ''; + home.packages = [ cfg.package ]; + + xdg.configFile."sxhkd/sxhkdrc".text = + concatStringsSep "\n" [ keybindingsStr cfg.extraConfig ]; + + xsession.initExtra = let + sxhkdCommand = "${cfg.package}/bin/sxhkd ${toString cfg.extraOptions}"; + in '' + systemctl --user stop sxhkd.scope 2> /dev/null || true + systemd-cat -t sxhkd systemd-run --user --scope -u sxhkd ${sxhkdCommand} & + ''; }; } diff --git a/third_party/home-manager/modules/services/syncthing.nix b/third_party/home-manager/modules/services/syncthing.nix index e63f3707e9..d2f7f2964e 100644 --- a/third_party/home-manager/modules/services/syncthing.nix +++ b/third_party/home-manager/modules/services/syncthing.nix @@ -22,16 +22,16 @@ with lib; command = mkOption { type = types.str; default = "syncthingtray"; - defaultText = literalExample "syncthingtray"; - example = literalExample "qsyncthingtray"; + defaultText = literalExpression "syncthingtray"; + example = literalExpression "qsyncthingtray"; description = "Syncthing tray command to use."; }; package = mkOption { type = types.package; default = pkgs.syncthingtray-minimal; - defaultText = literalExample "pkgs.syncthingtray-minimal"; - example = literalExample "pkgs.qsyncthingtray"; + defaultText = literalExpression "pkgs.syncthingtray-minimal"; + example = literalExpression "pkgs.qsyncthingtray"; description = "Syncthing tray package to use."; }; }; @@ -61,6 +61,15 @@ with lib; Restart = "on-failure"; SuccessExitStatus = [ 3 4 ]; RestartForceExitStatus = [ 3 4 ]; + + # Sandboxing. + LockPersonality = true; + MemoryDenyWriteExecute = true; + NoNewPrivileges = true; + PrivateUsers = true; + RestrictNamespaces = true; + SystemCallArchitectures = "native"; + SystemCallFilter = "@system-service"; }; Install = { WantedBy = [ "default.target" ]; }; diff --git a/third_party/home-manager/modules/services/taffybar.nix b/third_party/home-manager/modules/services/taffybar.nix index ef4c62e42d..088827b955 100644 --- a/third_party/home-manager/modules/services/taffybar.nix +++ b/third_party/home-manager/modules/services/taffybar.nix @@ -15,9 +15,9 @@ in { package = mkOption { default = pkgs.taffybar; - defaultText = literalExample "pkgs.taffybar"; + defaultText = literalExpression "pkgs.taffybar"; type = types.package; - example = literalExample "pkgs.taffybar"; + example = literalExpression "pkgs.taffybar"; description = "The package to use for the Taffybar binary."; }; }; diff --git a/third_party/home-manager/modules/services/taskwarrior-sync.nix b/third_party/home-manager/modules/services/taskwarrior-sync.nix index d16c0681be..ddce6d6f0b 100644 --- a/third_party/home-manager/modules/services/taskwarrior-sync.nix +++ b/third_party/home-manager/modules/services/taskwarrior-sync.nix @@ -29,6 +29,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.taskwarrior-sync" pkgs + lib.platforms.linux) + ]; + systemd.user.services.taskwarrior-sync = { Unit = { Description = "Taskwarrior sync"; }; Service = { diff --git a/third_party/home-manager/modules/services/trayer.nix b/third_party/home-manager/modules/services/trayer.nix new file mode 100644 index 0000000000..6abfbf7d1b --- /dev/null +++ b/third_party/home-manager/modules/services/trayer.nix @@ -0,0 +1,183 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + boolTrue = { + type = types.bool; + values = "true|false"; + default = "true"; + }; + + number0 = { + type = types.int; + values = "number"; + default = "0"; + }; + + knownSettings = { + edge = { + type = types.str; + values = "left|right|top|bottom|none"; + default = "bottom"; + }; + + align = { + type = types.str; + values = "left|right|center"; + default = "center"; + }; + + margin = number0; + widthtype = { + type = types.str; + values = "request|pixel|percent"; + default = "percent"; + }; + + width = { + type = types.int; + values = "number"; + default = "100"; + }; + + heighttype = { + type = types.str; + values = "request|pixel"; + default = "pixel"; + }; + + height = { + type = types.int; + values = "number"; + default = "26"; + }; + + SetDockType = boolTrue; + + SetPartialStrut = boolTrue; + + transparent = { + type = types.bool; + values = "true|false"; + default = "false"; + }; + + alpha = { + type = types.int; + values = "number"; + default = "127"; + }; + + tint = { + type = types.str; + values = "int"; + default = "0xFFFFFFFF"; + }; + + distance = number0; + + distancefrom = { + type = types.str; + values = "left|right|top|bottom"; + default = "top"; + }; + + expand = boolTrue; + + padding = number0; + + monitor = { + values = "number|primary"; + type = types.str; + default = "0"; + }; + + iconspacing = number0; + }; + + cfg = config.services.trayer; + +in { + meta.maintainers = [ maintainers.mager ]; + + options = { + services.trayer = { + enable = mkEnableOption + "trayer, the lightweight GTK2+ systray for UNIX desktops"; + + package = mkOption { + default = pkgs.trayer; + defaultText = literalExpression "pkgs.trayer"; + type = types.package; + example = literalExpression "pkgs.trayer"; + description = "The package to use for the trayer binary."; + }; + + settings = mkOption { + type = with types; attrsOf (nullOr (either str (either bool int))); + description = '' + Trayer configuration as a set of attributes. Further details can be + found at . + + + + + Property Name + Type + Values + Default + + + ${concatStringsSep "\n" (mapAttrsToList (n: v: '' + + ${n} + ${v.type.description} + ${v.values} + ${v.default} + + '') knownSettings)} + + ''; + default = { }; + example = literalExpression '' + { + edge = "top"; + padding = 6; + SetDockType = true; + tint = "0x282c34"; + } + ''; + }; + }; + }; + + config = mkIf cfg.enable ({ + assertions = [ + (lib.hm.assertions.assertPlatform "services.trayer" pkgs + lib.platforms.linux) + ]; + + home.packages = [ cfg.package ]; + + systemd.user.services.trayer = let + valueToString = v: + if isBool v then (if v then "true" else "false") else "${toString v}"; + parameter = k: v: "--${k} ${valueToString v}"; + parameters = concatStringsSep " " (mapAttrsToList parameter cfg.settings); + in { + Unit = { + Description = "trayer -- lightweight GTK2+ systray for UNIX desktops"; + PartOf = [ "tray.target" ]; + }; + + Install.WantedBy = [ "tray.target" ]; + + Service = { + ExecStart = "${cfg.package}/bin/trayer ${parameters}"; + Restart = "on-failure"; + }; + }; + }); +} diff --git a/third_party/home-manager/modules/services/unclutter.nix b/third_party/home-manager/modules/services/unclutter.nix index 5e76063959..e08c23eb3e 100644 --- a/third_party/home-manager/modules/services/unclutter.nix +++ b/third_party/home-manager/modules/services/unclutter.nix @@ -13,7 +13,7 @@ in { description = "unclutter derivation to use."; type = types.package; default = pkgs.unclutter-xfixes; - defaultText = literalExample "pkgs.unclutter-xfixes"; + defaultText = literalExpression "pkgs.unclutter-xfixes"; }; timeout = mkOption { @@ -37,6 +37,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.unclutter" pkgs + lib.platforms.linux) + ]; + systemd.user.services.unclutter = { Unit = { Description = "unclutter"; diff --git a/third_party/home-manager/modules/services/unison.nix b/third_party/home-manager/modules/services/unison.nix index a9cf23fb66..1683e8851a 100644 --- a/third_party/home-manager/modules/services/unison.nix +++ b/third_party/home-manager/modules/services/unison.nix @@ -47,7 +47,7 @@ let roots = mkOption { type = pairOf types.str; - example = literalExample '' + example = literalExpression '' [ "/home/user/documents" "ssh://remote/documents" @@ -78,7 +78,7 @@ in { pairs = mkOption { type = with types; attrsOf (submodule pairOptions); default = { }; - example = literalExample '' + example = literalExpression '' { roots = [ "/home/user/documents" @@ -93,6 +93,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.unison" pkgs + lib.platforms.linux) + ]; + systemd.user.services = makeDefs (name: pairCfg: { Unit = { Description = "Unison pair sync (${name})"; diff --git a/third_party/home-manager/modules/services/volnoti.nix b/third_party/home-manager/modules/services/volnoti.nix new file mode 100644 index 0000000000..016fe7ab76 --- /dev/null +++ b/third_party/home-manager/modules/services/volnoti.nix @@ -0,0 +1,43 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.volnoti; + +in { + meta.maintainers = [ maintainers.imalison ]; + + options = { + services.volnoti = { + enable = mkEnableOption "Volnoti volume HUD daemon"; + + package = mkOption { + type = types.package; + default = pkgs.volnoti; + defaultText = literalExpression "pkgs.volnoti"; + description = '' + Package containing the volnoti program. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.volnoti" pkgs + lib.platforms.linux) + ]; + + home.packages = [ cfg.package ]; + + systemd.user.services.volnoti = { + Unit = { Description = "volnoti"; }; + + Install = { WantedBy = [ "graphical-session.target" ]; }; + + Service = { ExecStart = "${pkgs.volnoti}/bin/volnoti -v -n"; }; + }; + }; +} diff --git a/third_party/home-manager/modules/services/window-managers/awesome.nix b/third_party/home-manager/modules/services/window-managers/awesome.nix index d2e2903f83..9692bec7c6 100644 --- a/third_party/home-manager/modules/services/window-managers/awesome.nix +++ b/third_party/home-manager/modules/services/window-managers/awesome.nix @@ -19,7 +19,7 @@ in { package = mkOption { type = types.package; default = pkgs.awesome; - defaultText = literalExample "pkgs.awesome"; + defaultText = literalExpression "pkgs.awesome"; description = "Package to use for running the Awesome WM."; }; @@ -30,7 +30,7 @@ in { List of lua packages available for being used in the Awesome configuration. ''; - example = literalExample "[ luaPackages.oocairo ]"; + example = literalExpression "[ pkgs.luaPackages.vicious ]"; }; noArgb = mkOption { @@ -45,7 +45,13 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (hm.assertions.assertPlatform "xsession.windowManager.awesome" pkgs + platforms.linux) + ]; + home.packages = [ awesome ]; + xsession.windowManager.command = "${awesome}/bin/awesome " + optionalString cfg.noArgb "--no-argb " + makeSearchPath cfg.luaModules; }; diff --git a/third_party/home-manager/modules/services/window-managers/bspwm/default.nix b/third_party/home-manager/modules/services/window-managers/bspwm/default.nix index c43be07402..c2b8fd49c3 100644 --- a/third_party/home-manager/modules/services/window-managers/bspwm/default.nix +++ b/third_party/home-manager/modules/services/window-managers/bspwm/default.nix @@ -42,6 +42,11 @@ in { options = import ./options.nix { inherit pkgs lib; }; config = mkIf cfg.enable { + assertions = [ + (hm.assertions.assertPlatform "xsession.windowManager.bspwm" pkgs + platforms.linux) + ]; + home.packages = [ cfg.package ]; xdg.configFile."bspwm/bspwmrc".source = pkgs.writeShellScript "bspwmrc" '' diff --git a/third_party/home-manager/modules/services/window-managers/bspwm/options.nix b/third_party/home-manager/modules/services/window-managers/bspwm/options.nix index 25b2098017..124236309a 100644 --- a/third_party/home-manager/modules/services/window-managers/bspwm/options.nix +++ b/third_party/home-manager/modules/services/window-managers/bspwm/options.nix @@ -149,9 +149,9 @@ in { package = mkOption { type = types.package; default = pkgs.bspwm; - defaultText = literalExample "pkgs.bspwm"; + defaultText = literalExpression "pkgs.bspwm"; description = "The bspwm package to use."; - example = literalExample "pkgs.bspwm-unstable"; + example = literalExpression "pkgs.bspwm-unstable"; }; settings = mkOption { @@ -190,7 +190,7 @@ in { default = { }; description = "Rule configuration. The keys of the attribute set are the targets of the rules."; - example = literalExample '' + example = literalExpression '' { "Gimp" = { desktop = "^8"; diff --git a/third_party/home-manager/modules/services/window-managers/i3-sway/i3.nix b/third_party/home-manager/modules/services/window-managers/i3-sway/i3.nix index 6e779b4f1a..a5be60dd74 100644 --- a/third_party/home-manager/modules/services/window-managers/i3-sway/i3.nix +++ b/third_party/home-manager/modules/services/window-managers/i3-sway/i3.nix @@ -99,7 +99,7 @@ let Consider to use lib.mkOptionDefault function to extend or override default keybindings instead of specifying all of them from scratch. ''; - example = literalExample '' + example = literalExpression '' let modifier = config.xsession.windowManager.i3.config.modifier; in lib.mkOptionDefault { @@ -179,7 +179,7 @@ let ${keybindingsStr { keybindings = keybindingDefaultWorkspace; }} ${keybindingsStr { keybindings = keybindingsRest; }} ${keycodebindingsStr keycodebindings} - ${concatStringsSep "\n" (mapAttrsToList modeStr modes)} + ${concatStringsSep "\n" (mapAttrsToList (modeStr false) modes)} ${concatStringsSep "\n" (mapAttrsToList assignStr assigns)} ${concatStringsSep "\n" (map barStr bars)} ${optionalString (gaps != null) gapsStr} @@ -216,8 +216,8 @@ in { package = mkOption { type = types.package; default = pkgs.i3; - defaultText = literalExample "pkgs.i3"; - example = literalExample "pkgs.i3-gaps"; + defaultText = literalExpression "pkgs.i3"; + example = literalExpression "pkgs.i3-gaps"; description = '' i3 package to use. If 'i3.config.gaps' settings are specified, 'pkgs.i3-gaps' will be set as a default package. @@ -241,15 +241,21 @@ in { config = mkIf cfg.enable (mkMerge [ { + assertions = [ + (hm.assertions.assertPlatform "xsession.windowManager.i3" pkgs + platforms.linux) + ]; + home.packages = [ cfg.package ]; + xsession.windowManager.command = "${cfg.package}/bin/i3"; + xdg.configFile."i3/config" = { source = checkI3Config; onChange = '' i3Socket=''${XDG_RUNTIME_DIR:-/run/user/$UID}/i3/ipc-socket.* if [ -S $i3Socket ]; then - echo "Reloading i3" - $DRY_RUN_CMD ${cfg.package}/bin/i3-msg -s $i3Socket reload 1>/dev/null + ${cfg.package}/bin/i3-msg -s $i3Socket reload >/dev/null fi ''; }; diff --git a/third_party/home-manager/modules/services/window-managers/i3-sway/lib/functions.nix b/third_party/home-manager/modules/services/window-managers/i3-sway/lib/functions.nix index 1317f5dbb7..75b3f7b6f4 100644 --- a/third_party/home-manager/modules/services/window-managers/i3-sway/lib/functions.nix +++ b/third_party/home-manager/modules/services/window-managers/i3-sway/lib/functions.nix @@ -4,9 +4,13 @@ with lib; rec { criteriaStr = criteria: - "[${ - concatStringsSep " " (mapAttrsToList (k: v: ''${k}="${v}"'') criteria) - }]"; + let + toCriteria = k: v: + if builtins.isBool v then + (if v then "${k}" else "") + else + ''${k}="${v}"''; + in "[${concatStringsSep " " (mapAttrsToList toCriteria criteria)}]"; keybindingDefaultWorkspace = filterAttrs (n: v: cfg.config.defaultWorkspace != null && v == cfg.config.defaultWorkspace) @@ -37,9 +41,12 @@ rec { ]; barColorSetStr = c: concatStringsSep " " [ c.border c.background c.text ]; - modeStr = name: keybindings: '' + modeStr = bindkeysToCode: name: keybindings: '' mode "${name}" { - ${keybindingsStr { inherit keybindings; }} + ${keybindingsStr { + inherit keybindings; + bindsymArgs = lib.optionalString bindkeysToCode "--to-code"; + }} } ''; diff --git a/third_party/home-manager/modules/services/window-managers/i3-sway/lib/options.nix b/third_party/home-manager/modules/services/window-managers/i3-sway/lib/options.nix index af72f2e6bd..c4d1535a7c 100644 --- a/third_party/home-manager/modules/services/window-managers/i3-sway/lib/options.nix +++ b/third_party/home-manager/modules/services/window-managers/i3-sway/lib/options.nix @@ -12,12 +12,12 @@ let names = mkOption { type = types.listOf types.str; default = [ "monospace" ]; - defaultText = literalExample ''[ "monospace" ]''; + defaultText = literalExpression ''[ "monospace" ]''; description = '' List of font names list used for window titles. Only FreeType fonts are supported. The order here is important (e.g. icons font should go before the one used for text). ''; - example = literalExample ''[ "FontAwesome" "Terminus" ]''; + example = literalExpression ''[ "FontAwesome" "Terminus" ]''; }; style = mkOption { @@ -82,7 +82,7 @@ let mkOption (args // { type = types.nullOr type; default = if versionAtLeast2009 then null else default; - defaultText = literalExample '' + defaultText = literalExpression '' null for state version ≥ 20.09, as example otherwise ''; example = default; @@ -91,7 +91,7 @@ let fonts = mkOption { type = with types; either (listOf str) fontOptions; default = { }; - example = literalExample '' + example = literalExpression '' { names = [ "DejaVu Sans Mono" "FontAwesome5Free" ]; style = "Bold Semi-Condensed"; @@ -353,19 +353,28 @@ let criteria = mkOption { type = criteriaModule; - description = - "Criteria of the windows on which command should be executed."; - example = { title = "x200: ~/work"; }; + description = '' + Criteria of the windows on which command should be executed. + + A value of true is equivalent to using an empty + criteria (which is different from an empty string criteria). + ''; + example = literalExpression '' + { + title = "x200: ~/work"; + floating = true; + }; + ''; }; }; }; - criteriaModule = types.attrsOf types.str; + criteriaModule = types.attrsOf (types.either types.str types.bool); in { fonts = mkOption { type = with types; either (listOf str) fontOptions; default = { }; - example = literalExample '' + example = literalExpression '' { names = [ "DejaVu Sans Mono" "FontAwesome5Free" ]; style = "Bold Semi-Condensed"; @@ -522,7 +531,7 @@ in { An attribute set that assigns applications to workspaces based on criteria. ''; - example = literalExample '' + example = literalExpression '' { "1: web" = [{ class = "^Firefox$"; }]; "0: extra" = [{ class = "^Firefox$"; window_role = "About"; }]; @@ -538,7 +547,7 @@ in { }; workspaceLayout = mkOption { - type = types.enum [ "default" "stacked" "tabbed" ]; + type = types.enum [ "default" "stacking" "tabbed" ]; default = "default"; example = "tabbed"; description = '' @@ -705,7 +714,7 @@ in { }; }] else [ { } ]; - defaultText = literalExample "see code"; + defaultText = literalExpression "see code"; description = '' ${capitalModuleName} bars settings blocks. Set to empty list to remove bars completely. ''; @@ -720,7 +729,7 @@ in { See . ''; example = if isI3 then - literalExample '' + literalExpression '' [ { command = "systemctl --user restart polybar"; always = true; notification = false; } { command = "dropbox start"; notification = false; } @@ -728,7 +737,7 @@ in { ]; '' else - literalExample '' + literalExpression '' [ { command = "systemctl --user restart waybar"; always = true; } { command = "dropbox start"; } diff --git a/third_party/home-manager/modules/services/window-managers/i3-sway/sway.nix b/third_party/home-manager/modules/services/window-managers/i3-sway/sway.nix index 1dcd8662fb..ecd7bb5339 100644 --- a/third_party/home-manager/modules/services/window-managers/i3-sway/sway.nix +++ b/third_party/home-manager/modules/services/window-managers/i3-sway/sway.nix @@ -128,7 +128,7 @@ let Consider to use lib.mkOptionDefault function to extend or override default keybindings instead of specifying all of them from scratch. ''; - example = literalExample '' + example = literalExpression '' let modifier = config.wayland.windowManager.sway.config.modifier; in lib.mkOptionDefault { @@ -300,7 +300,7 @@ let mapAttrsToList inputStr input # inputs ++ mapAttrsToList outputStr output # outputs ++ mapAttrsToList seatStr seat # seats - ++ mapAttrsToList modeStr modes # modes + ++ mapAttrsToList (modeStr cfg.config.bindkeysToCode) modes # modes ++ mapAttrsToList assignStr assigns # assigns ++ map barStr bars # bars ++ optional (gaps != null) gapsStr # gaps @@ -332,7 +332,7 @@ in { package = mkOption { type = with types; nullOr package; default = defaultSwayPackage; - defaultText = literalExample "${pkgs.sway}"; + defaultText = literalExpression "${pkgs.sway}"; description = '' Sway package to use. Will override the options 'wrapperFeatures', 'extraSessionCommands', and 'extraOptions'. @@ -427,18 +427,24 @@ in { }) { + assertions = [ + (hm.assertions.assertPlatform "wayland.windowManager.sway" pkgs + platforms.linux) + ]; + home.packages = optional (cfg.package != null) cfg.package ++ optional cfg.xwayland pkgs.xwayland; + xdg.configFile."sway/config" = { source = configFile; onChange = '' - swaySocket=''${XDG_RUNTIME_DIR:-/run/user/$UID}/sway-ipc.$UID.$(${pkgs.procps}/bin/pgrep -x sway || ${pkgs.coreutils}/bin/true).sock + swaySocket=''${XDG_RUNTIME_DIR:-/run/user/$UID}/sway-ipc.$UID.$(${pkgs.procps}/bin/pgrep -x sway || true).sock if [ -S $swaySocket ]; then - echo "Reloading sway" - $DRY_RUN_CMD ${pkgs.sway}/bin/swaymsg -s $swaySocket reload + ${pkgs.sway}/bin/swaymsg -s $swaySocket reload fi ''; }; + systemd.user.targets.sway-session = mkIf cfg.systemdIntegration { Unit = { Description = "sway compositor session"; diff --git a/third_party/home-manager/modules/services/window-managers/xmonad.nix b/third_party/home-manager/modules/services/window-managers/xmonad.nix index 6d05d68ede..07dc9a981f 100644 --- a/third_party/home-manager/modules/services/window-managers/xmonad.nix +++ b/third_party/home-manager/modules/services/window-managers/xmonad.nix @@ -22,8 +22,8 @@ in { haskellPackages = mkOption { default = pkgs.haskellPackages; - defaultText = literalExample "pkgs.haskellPackages"; - example = literalExample "pkgs.haskell.packages.ghc784"; + defaultText = literalExpression "pkgs.haskellPackages"; + example = literalExpression "pkgs.haskell.packages.ghc784"; description = '' The haskellPackages used to build xmonad and other packages. This can be used to change the GHC @@ -35,7 +35,7 @@ in { extraPackages = mkOption { default = self: [ ]; defaultText = "self: []"; - example = literalExample '' + example = literalExpression '' haskellPackages: [ haskellPackages.xmonad-contrib haskellPackages.monad-logger @@ -58,7 +58,7 @@ in { config = mkOption { type = types.nullOr types.path; default = null; - example = literalExample '' + example = literalExpression '' pkgs.writeText "xmonad.hs" ''' import XMonad main = xmonad defaultConfig @@ -84,7 +84,7 @@ in { libFiles = mkOption { type = types.attrsOf (types.oneOf [ types.path ]); default = { }; - example = literalExample '' + example = literalExpression '' { "Tools.hs" = pkgs.writeText "Tools.hs" ''' module Tools where @@ -137,10 +137,23 @@ in { }/bin/xmonad-${pkgs.hostPlatform.system}"; in mkIf cfg.enable (mkMerge [ - { home.packages = [ (lowPrio xmonad) ]; } + { + assertions = [ + (hm.assertions.assertPlatform "xsession.windowManager.xmonad" pkgs + platforms.linux) + ]; + + home.packages = [ (lowPrio xmonad) ]; + + home.file = mapAttrs' (name: value: + attrsets.nameValuePair (".xmonad/lib/" + name) { source = value; }) + cfg.libFiles; + } + (mkIf (cfg.config == null) { xsession.windowManager.command = "${xmonad}/bin/xmonad"; }) + (mkIf (cfg.config != null) { xsession.windowManager.command = xmonadBin; home.file.".xmonad/xmonad.hs".source = cfg.config; @@ -148,18 +161,12 @@ in { source = xmonadBin; onChange = '' # Attempt to restart xmonad if X is running. - if [[ -v DISPLAY ]] ; then - echo "Restarting xmonad" - $DRY_RUN_CMD ${config.xsession.windowManager.command} --restart + if [[ -v DISPLAY ]]; then + ${config.xsession.windowManager.command} --restart fi ''; }; }) - { - home.file = mapAttrs' (name: value: - attrsets.nameValuePair (".xmonad/lib/" + name) { source = value; }) - cfg.libFiles; - } ]); } diff --git a/third_party/home-manager/modules/services/wlsunset.nix b/third_party/home-manager/modules/services/wlsunset.nix index 084dbdb7c3..28e595af95 100644 --- a/third_party/home-manager/modules/services/wlsunset.nix +++ b/third_party/home-manager/modules/services/wlsunset.nix @@ -73,6 +73,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.wlsunset" pkgs + lib.platforms.linux) + ]; + systemd.user.services.wlsunset = { Unit = { Description = "Day/night gamma adjustments for Wayland compositors."; diff --git a/third_party/home-manager/modules/services/xcape.nix b/third_party/home-manager/modules/services/xcape.nix index f4f77caa33..72b8303bb4 100644 --- a/third_party/home-manager/modules/services/xcape.nix +++ b/third_party/home-manager/modules/services/xcape.nix @@ -53,12 +53,22 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.xcape" pkgs + lib.platforms.linux) + ]; + systemd.user.services.xcape = { - Unit = { - Description = "xcape"; - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; - }; + Unit = mkMerge [ + { + Description = "xcape"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + } + (mkIf (config.home.keyboard != null && config.home.keyboard != { }) { + After = [ "graphical-session-pre.target" "setxkbmap.service" ]; + }) + ]; Service = { Type = "forking"; diff --git a/third_party/home-manager/modules/services/xembed-sni-proxy.nix b/third_party/home-manager/modules/services/xembed-sni-proxy.nix index ff63d108b7..54ea0599cb 100644 --- a/third_party/home-manager/modules/services/xembed-sni-proxy.nix +++ b/third_party/home-manager/modules/services/xembed-sni-proxy.nix @@ -16,7 +16,7 @@ in { package = mkOption { type = types.package; default = pkgs.plasma-workspace; - defaultText = literalExample "pkgs.plasma-workspace"; + defaultText = literalExpression "pkgs.plasma-workspace"; description = '' Package containing the xembedsniproxy program. @@ -26,6 +26,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.xembed-sni-proxy" pkgs + lib.platforms.linux) + ]; + systemd.user.services.xembed-sni-proxy = { Unit = { Description = "XEmbed SNI Proxy"; diff --git a/third_party/home-manager/modules/services/xidlehook.nix b/third_party/home-manager/modules/services/xidlehook.nix index da91de8504..f292504756 100644 --- a/third_party/home-manager/modules/services/xidlehook.nix +++ b/third_party/home-manager/modules/services/xidlehook.nix @@ -44,7 +44,7 @@ in { environment = mkOption { type = types.attrsOf types.str; default = { }; - example = literalExample '' + example = literalExpression '' { "primary-display" = "$(xrandr | awk '/ primary/{print $1}')"; } @@ -81,7 +81,7 @@ in { }; command = mkOption { type = types.nullOr types.str; - example = literalExample '' + example = literalExpression '' ''${pkgs.libnotify}/bin/notify-send "Idle" "Sleeping in 1 minute" ''; description = '' @@ -93,7 +93,7 @@ in { canceller = mkOption { type = types.str; default = ""; - example = literalExample '' + example = literalExpression '' ''${pkgs.libnotify}/bin/notify-send "Idle" "Resuming activity" ''; description = '' @@ -106,7 +106,7 @@ in { }; }); default = [ ]; - example = literalExample '' + example = literalExpression '' [ { delay = 60; @@ -132,6 +132,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.xidlehook" pkgs + lib.platforms.linux) + ]; + systemd.user.services.xidlehook = { Unit = { Description = "xidlehook service"; diff --git a/third_party/home-manager/modules/services/xscreensaver.nix b/third_party/home-manager/modules/services/xscreensaver.nix index ac6194e70c..3c0661e898 100644 --- a/third_party/home-manager/modules/services/xscreensaver.nix +++ b/third_party/home-manager/modules/services/xscreensaver.nix @@ -29,6 +29,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.xscreensaver" pkgs + lib.platforms.linux) + ]; + # To make the xscreensaver-command tool available. home.packages = [ pkgs.xscreensaver ]; diff --git a/third_party/home-manager/modules/services/xsettingsd.nix b/third_party/home-manager/modules/services/xsettingsd.nix new file mode 100644 index 0000000000..58eb2665ee --- /dev/null +++ b/third_party/home-manager/modules/services/xsettingsd.nix @@ -0,0 +1,93 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.xsettingsd; + + renderSettings = settings: + concatStrings (mapAttrsToList renderSetting settings); + + renderSetting = key: value: '' + ${key} ${renderValue value} + ''; + + renderValue = value: + { + int = toString value; + bool = if value then "1" else "0"; + string = ''"${value}"''; + }.${builtins.typeOf value}; + +in { + meta.maintainers = [ maintainers.imalison ]; + + options = { + services.xsettingsd = { + enable = mkEnableOption "xsettingsd"; + + package = mkOption { + type = types.package; + default = pkgs.xsettingsd; + defaultText = literalExpression "pkgs.xsettingsd"; + description = '' + Package containing the xsettingsd program. + ''; + }; + + settings = mkOption { + type = with types; attrsOf (oneOf [ bool int str ]); + default = { }; + example = literalExpression '' + { + "Net/ThemeName" = "Numix"; + "Xft/Antialias" = true; + "Xft/Hinting" = true; + "Xft/RGBA" = "rgb"; + } + ''; + description = '' + Xsettingsd options for configuration file. See + + for documentation on these values. + ''; + }; + + configFile = mkOption { + type = types.nullOr types.package; + internal = true; + readOnly = true; + default = if cfg.settings == { } then + null + else + pkgs.writeText "xsettingsd.conf" (renderSettings cfg.settings); + }; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.xsettingsd" pkgs + lib.platforms.linux) + ]; + + systemd.user.services.xsettingsd = { + Unit = { + Description = "xsettingsd"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install.WantedBy = [ "graphical-session.target" ]; + + Service = { + Environment = "PATH=${config.home.profileDirectory}/bin"; + ExecStart = "${cfg.package}/bin/xsettingsd" + + optionalString (cfg.configFile != null) + " -c ${escapeShellArg cfg.configFile}"; + Restart = "on-abort"; + }; + }; + }; +} diff --git a/third_party/home-manager/modules/services/xsuspender.nix b/third_party/home-manager/modules/services/xsuspender.nix index 7d855f05d5..54f13c8d5a 100644 --- a/third_party/home-manager/modules/services/xsuspender.nix +++ b/third_party/home-manager/modules/services/xsuspender.nix @@ -148,6 +148,11 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.xsuspender" pkgs + lib.platforms.linux) + ]; + services.xsuspender.iniContent = let mkSection = values: filterAttrs (_: v: v != null) { diff --git a/third_party/home-manager/modules/systemd.nix b/third_party/home-manager/modules/systemd.nix index a5a069c5d7..5a9c75082f 100644 --- a/third_party/home-manager/modules/systemd.nix +++ b/third_party/home-manager/modules/systemd.nix @@ -4,30 +4,31 @@ let cfg = config.systemd.user; - inherit (lib) getAttr hm isBool literalExample mkIf mkMerge mkOption types; + inherit (lib) getAttr hm isBool literalExpression mkIf mkMerge mkOption types; # From - mkPathSafeName = lib.replaceChars ["@" ":" "\\" "[" "]"] ["-" "-" "-" "" ""]; + mkPathSafeName = + lib.replaceChars [ "@" ":" "\\" "[" "]" ] [ "-" "-" "-" "" "" ]; - enabled = cfg.services != {} - || cfg.slices != {} - || cfg.sockets != {} - || cfg.targets != {} - || cfg.timers != {} - || cfg.paths != {} - || cfg.mounts != {} - || cfg.automounts != {} - || cfg.sessionVariables != {}; + enabled = cfg.services != { } # \ + || cfg.slices != { } # \ + || cfg.sockets != { } # \ + || cfg.targets != { } # \ + || cfg.timers != { } # \ + || cfg.paths != { } # \ + || cfg.mounts != { } # \ + || cfg.automounts != { } # \ + || cfg.sessionVariables != { }; toSystemdIni = lib.generators.toINI { listsAsDuplicateKeys = true; mkKeyValue = key: value: let - value' = - if isBool value then (if value then "true" else "false") - else toString value; - in - "${key}=${value'}"; + value' = if isBool value then + (if value then "true" else "false") + else + toString value; + in "${key}=${value'}"; }; buildService = style: name: serviceCfg: @@ -43,32 +44,26 @@ let destination = lib.escapeShellArg "/${filename}"; } + "/${filename}"; - wantedBy = target: - { - name = "systemd/user/${target}.wants/${filename}"; - value = { inherit source; }; - }; - in - lib.singleton { - name = "systemd/user/${filename}"; + wantedBy = target: { + name = "systemd/user/${target}.wants/${filename}"; value = { inherit source; }; - } - ++ - map wantedBy (serviceCfg.Install.WantedBy or []); + }; + in lib.singleton { + name = "systemd/user/${filename}"; + value = { inherit source; }; + } ++ map wantedBy (serviceCfg.Install.WantedBy or [ ]); buildServices = style: serviceCfgs: lib.concatLists (lib.mapAttrsToList (buildService style) serviceCfgs); servicesStartTimeoutMs = builtins.toString cfg.servicesStartTimeoutMs; - unitType = unitKind: with types; - let - primitive = either bool (either int str); - in - attrsOf (attrsOf (attrsOf (either primitive (listOf primitive)))) - // { - description = "systemd ${unitKind} unit configuration"; - }; + unitType = unitKind: + with types; + let primitive = either bool (either int str); + in attrsOf (attrsOf (attrsOf (either primitive (listOf primitive)))) // { + description = "systemd ${unitKind} unit configuration"; + }; unitDescription = type: '' Definition of systemd per-user ${type} units. Attributes are @@ -82,31 +77,29 @@ let . ''; - unitExample = type: literalExample '' - { - ${lib.toLower type}-name = { - Unit = { - Description = "Example description"; - Documentation = [ "man:example(1)" "man:example(5)" ]; - }; + unitExample = type: + literalExpression '' + { + ${lib.toLower type}-name = { + Unit = { + Description = "Example description"; + Documentation = [ "man:example(1)" "man:example(5)" ]; + }; - ${type} = { - … + ${type} = { + … + }; }; }; - }; - ''; + ''; - sessionVariables = mkIf (cfg.sessionVariables != {}) { - "environment.d/10-home-manager.conf".text = - lib.concatStringsSep "\n" ( - lib.mapAttrsToList (n: v: "${n}=${toString v}") cfg.sessionVariables - ) + "\n"; - }; + sessionVariables = mkIf (cfg.sessionVariables != { }) { + "environment.d/10-home-manager.conf".text = lib.concatStringsSep "\n" + (lib.mapAttrsToList (n: v: "${n}=${toString v}") cfg.sessionVariables) + + "\n"; + }; -in - -{ +in { meta.maintainers = [ lib.maintainers.rycee ]; options = { @@ -123,56 +116,56 @@ in }; services = mkOption { - default = {}; + default = { }; type = unitType "service"; description = unitDescription "service"; example = unitExample "Service"; }; slices = mkOption { - default = {}; + default = { }; type = unitType "slices"; description = unitDescription "slices"; example = unitExample "Slices"; }; sockets = mkOption { - default = {}; + default = { }; type = unitType "socket"; description = unitDescription "socket"; example = unitExample "Socket"; }; targets = mkOption { - default = {}; + default = { }; type = unitType "target"; description = unitDescription "target"; example = unitExample "Target"; }; timers = mkOption { - default = {}; + default = { }; type = unitType "timer"; description = unitDescription "timer"; example = unitExample "Timer"; }; paths = mkOption { - default = {}; + default = { }; type = unitType "path"; description = unitDescription "path"; example = unitExample "Path"; }; mounts = mkOption { - default = {}; + default = { }; type = unitType "mount"; description = unitDescription "mount"; example = unitExample "Mount"; }; automounts = mkOption { - default = {}; + default = { }; type = unitType "automount"; description = unitDescription "automount"; example = unitExample "Automount"; @@ -180,10 +173,9 @@ in startServices = mkOption { default = "suggest"; - type = with types; either bool (enum ["suggest" "legacy" "sd-switch"]); - apply = p: - if isBool p then if p then "legacy" else "suggest" - else p; + type = with types; + either bool (enum [ "suggest" "legacy" "sd-switch" ]); + apply = p: if isBool p then if p then "legacy" else "suggest" else p; description = '' Whether new or changed services that are wanted by active targets should be started. Additionally, stop obsolete services from the @@ -231,7 +223,7 @@ in }; sessionVariables = mkOption { - default = {}; + default = { }; type = with types; attrsOf (either int str); example = { EDITOR = "vim"; }; description = '' @@ -248,54 +240,44 @@ in config = mkMerge [ { - assertions = [ - { - assertion = enabled -> pkgs.stdenv.isLinux; - message = - let - names = lib.concatStringsSep ", " ( - lib.attrNames ( - cfg.services // cfg.slices // cfg.sockets // cfg.targets - // cfg.timers // cfg.paths // cfg.mounts // cfg.sessionVariables - ) - ); - in - "Must use Linux for modules that require systemd: " + names; - } - ]; + assertions = [{ + assertion = enabled -> pkgs.stdenv.isLinux; + message = let + names = lib.concatStringsSep ", " (lib.attrNames ( # \ + cfg.services # \ + // cfg.slices # \ + // cfg.sockets # \ + // cfg.targets # \ + // cfg.timers # \ + // cfg.paths # \ + // cfg.mounts # \ + // cfg.sessionVariables)); + in "Must use Linux for modules that require systemd: " + names; + }]; } # If we run under a Linux system we assume that systemd is # available, in particular we assume that systemctl is in PATH. (mkIf pkgs.stdenv.isLinux { xdg.configFile = mkMerge [ - (lib.listToAttrs ( - (buildServices "service" cfg.services) - ++ - (buildServices "slices" cfg.slices) - ++ - (buildServices "socket" cfg.sockets) - ++ - (buildServices "target" cfg.targets) - ++ - (buildServices "timer" cfg.timers) - ++ - (buildServices "path" cfg.paths) - ++ - (buildServices "mount" cfg.mounts) - ++ - (buildServices "automount" cfg.automounts) - )) + (lib.listToAttrs ((buildServices "service" cfg.services) + ++ (buildServices "slices" cfg.slices) + ++ (buildServices "socket" cfg.sockets) + ++ (buildServices "target" cfg.targets) + ++ (buildServices "timer" cfg.timers) + ++ (buildServices "path" cfg.paths) + ++ (buildServices "mount" cfg.mounts) + ++ (buildServices "automount" cfg.automounts))) - sessionVariables - ]; + sessionVariables + ]; # Run systemd service reload if user is logged in. If we're # running this from the NixOS module then XDG_RUNTIME_DIR is not # set and systemd commands will fail. We'll therefore have to # set it ourselves in that case. - home.activation.reloadSystemd = hm.dag.entryAfter ["linkGeneration"] ( - let + home.activation.reloadSystemd = hm.dag.entryAfter [ "linkGeneration" ] + (let cmd = { suggest = '' PATH=${dirOf cfg.systemctlPath}:$PATH \ @@ -306,44 +288,41 @@ in ${pkgs.ruby}/bin/ruby ${./systemd-activate.rb} \ "''${oldGenPath=}" "$newGenPath" "${servicesStartTimeoutMs}" ''; - sd-switch = - let - timeoutArg = - if cfg.servicesStartTimeoutMs != 0 then - "--timeout " + servicesStartTimeoutMs - else - ""; - in '' - ${pkgs.sd-switch}/bin/sd-switch \ - ''${DRY_RUN:+--dry-run} $VERBOSE_ARG ${timeoutArg} \ - ''${oldGenPath:+--old-units $oldGenPath/home-files/.config/systemd/user} \ - --new-units $newGenPath/home-files/.config/systemd/user - ''; + sd-switch = let + timeoutArg = if cfg.servicesStartTimeoutMs != 0 then + "--timeout " + servicesStartTimeoutMs + else + ""; + in '' + ${pkgs.sd-switch}/bin/sd-switch \ + ''${DRY_RUN:+--dry-run} $VERBOSE_ARG ${timeoutArg} \ + ''${oldGenPath:+--old-units $oldGenPath/home-files/.config/systemd/user} \ + --new-units $newGenPath/home-files/.config/systemd/user + ''; }; - ensureRuntimeDir = "XDG_RUNTIME_DIR=\${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"; + ensureRuntimeDir = + "XDG_RUNTIME_DIR=\${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"; systemctl = "${ensureRuntimeDir} ${cfg.systemctlPath}"; - in - '' - systemdStatus=$(${systemctl} --user is-system-running 2>&1 || true) + in '' + systemdStatus=$(${systemctl} --user is-system-running 2>&1 || true) - if [[ $systemdStatus == 'running' || $systemdStatus == 'degraded' ]]; then - if [[ $systemdStatus == 'degraded' ]]; then - warnEcho "The user systemd session is degraded:" - ${systemctl} --user --no-pager --state=failed - warnEcho "Attempting to reload services anyway..." - fi - - ${ensureRuntimeDir} \ - ${getAttr cfg.startServices cmd} - else - echo "User systemd daemon not running. Skipping reload." + if [[ $systemdStatus == 'running' || $systemdStatus == 'degraded' ]]; then + if [[ $systemdStatus == 'degraded' ]]; then + warnEcho "The user systemd session is degraded:" + ${systemctl} --user --no-pager --state=failed + warnEcho "Attempting to reload services anyway..." fi - unset systemdStatus - '' - ); + ${ensureRuntimeDir} \ + ${getAttr cfg.startServices cmd} + else + echo "User systemd daemon not running. Skipping reload." + fi + + unset systemdStatus + ''); }) ]; } diff --git a/third_party/home-manager/modules/targets/darwin/default.nix b/third_party/home-manager/modules/targets/darwin/default.nix index b971e18d21..d2764bd1ae 100644 --- a/third_party/home-manager/modules/targets/darwin/default.nix +++ b/third_party/home-manager/modules/targets/darwin/default.nix @@ -43,6 +43,11 @@ in { }; config = mkIf (activationCmds != [ ]) { + assertions = [ + (hm.assertions.assertPlatform "targets.darwin.defaults" pkgs + platforms.darwin) + ]; + home.activation.setDarwinDefaults = hm.dag.entryAfter [ "writeBoundary" ] '' $VERBOSE_ECHO "Configuring macOS user defaults" ${concatStringsSep "\n" activationCmds} diff --git a/third_party/home-manager/modules/targets/darwin/fonts.nix b/third_party/home-manager/modules/targets/darwin/fonts.nix index bc4042a8d7..cd26fa0872 100644 --- a/third_party/home-manager/modules/targets/darwin/fonts.nix +++ b/third_party/home-manager/modules/targets/darwin/fonts.nix @@ -12,16 +12,18 @@ let fonts = "${fontsEnv}/share/fonts"; in { # macOS won't recognize symlinked fonts - config.home.activation.copyFonts = hm.dag.entryAfter [ "writeBoundary" ] '' - copyFonts() { - rm -rf ${homeDir}/Library/Fonts/HomeManager || : + config = mkIf pkgs.hostPlatform.isDarwin { + home.activation.copyFonts = hm.dag.entryAfter [ "writeBoundary" ] '' + copyFonts() { + rm -rf ${homeDir}/Library/Fonts/HomeManager || : - local f - find -L "${fonts}" -type f -printf '%P\0' | while IFS= read -rd "" f; do - $DRY_RUN_CMD install $VERBOSE_ARG -Dm644 -T \ - "${fonts}/$f" "${homeDir}/Library/Fonts/HomeManager/$f" - done - } - copyFonts - ''; + local f + find -L "${fonts}" -type f -printf '%P\0' | while IFS= read -rd "" f; do + $DRY_RUN_CMD install $VERBOSE_ARG -Dm644 -T \ + "${fonts}/$f" "${homeDir}/Library/Fonts/HomeManager/$f" + done + } + copyFonts + ''; + }; } diff --git a/third_party/home-manager/modules/targets/darwin/keybindings.nix b/third_party/home-manager/modules/targets/darwin/keybindings.nix index 4481f33bd8..824daa5721 100644 --- a/third_party/home-manager/modules/targets/darwin/keybindings.nix +++ b/third_party/home-manager/modules/targets/darwin/keybindings.nix @@ -31,6 +31,11 @@ in { }; config = mkIf (cfg.keybindings != { }) { + assertions = [ + (hm.assertions.assertPlatform "targets.darwin.keybindings" pkgs + platforms.darwin) + ]; + # NOTE: just copy the files because symlinks won't be recognized by macOS home.activation.setCocoaKeybindings = hm.dag.entryAfter [ "writeBoundary" ] '' diff --git a/third_party/home-manager/modules/targets/darwin/search.nix b/third_party/home-manager/modules/targets/darwin/search.nix index 2afbae4af3..8e0df3b203 100644 --- a/third_party/home-manager/modules/targets/darwin/search.nix +++ b/third_party/home-manager/modules/targets/darwin/search.nix @@ -20,6 +20,11 @@ in { }; config = mkIf (cfg.search != null) { + assertions = [ + (hm.assertions.assertPlatform "targets.darwin.search" pkgs + platforms.darwin) + ]; + targets.darwin.defaults = { NSGlobalDomain.NSPreferredWebServices = { NSWebServicesProviderWebSearch = { diff --git a/third_party/home-manager/modules/targets/generic-linux.nix b/third_party/home-manager/modules/targets/generic-linux.nix index 6e17bd2829..9132d8898b 100644 --- a/third_party/home-manager/modules/targets/generic-linux.nix +++ b/third_party/home-manager/modules/targets/generic-linux.nix @@ -27,6 +27,10 @@ in { }; config = mkIf cfg.enable { + assertions = [ + (hm.assertions.assertPlatform "targets.genericLinux" pkgs platforms.linux) + ]; + xdg.systemDirs.data = [ # Nix profiles "\${NIX_STATE_DIR:-/nix/var/nix}/profiles/default/share" @@ -53,6 +57,24 @@ in { . "${profileDirectory}/etc/profile.d/hm-session-vars.sh" ''; + programs.zsh.envExtra = '' + # Make system functions available to zsh + () { + setopt LOCAL_OPTIONS CASE_GLOB EXTENDED_GLOB + + local system_fpaths=( + # Package default + /usr/share/zsh/site-functions(/-N) + + # Debian + /usr/share/zsh/functions/**/*(/-N) + /usr/share/zsh/vendor-completions/(/-N) + /usr/share/zsh/vendor-functions/(/-N) + ) + fpath=(''${fpath} ''${system_fpaths}) + } + ''; + systemd.user.sessionVariables = let # https://github.com/archlinux/svntogit-packages/blob/packages/ncurses/trunk/PKGBUILD # https://salsa.debian.org/debian/ncurses/-/blob/master/debian/rules diff --git a/third_party/home-manager/modules/xcursor.nix b/third_party/home-manager/modules/xcursor.nix index 65b5c77068..3ec2a354db 100644 --- a/third_party/home-manager/modules/xcursor.nix +++ b/third_party/home-manager/modules/xcursor.nix @@ -10,7 +10,7 @@ let options = { package = mkOption { type = types.package; - example = literalExample "pkgs.vanilla-dmz"; + example = literalExpression "pkgs.vanilla-dmz"; description = "Package providing the cursor theme."; }; @@ -55,6 +55,10 @@ in { }; config = mkIf (cfg != null) { + assertions = [ + (hm.assertions.assertPlatform "xsession.pointerCursor" pkgs + platforms.linux) + ]; home.packages = [ cfg.package ]; diff --git a/third_party/home-manager/modules/xresources.nix b/third_party/home-manager/modules/xresources.nix index ef91906e00..31eb6eaadd 100644 --- a/third_party/home-manager/modules/xresources.nix +++ b/third_party/home-manager/modules/xresources.nix @@ -36,7 +36,7 @@ in { entry = either prim (listOf prim); in nullOr (attrsOf entry); default = null; - example = literalExample '' + example = literalExpression '' { "Emacs*toolBar" = 0; "XTerm*faceName" = "dejavu sans mono"; @@ -58,7 +58,7 @@ in { xresources.extraConfig = mkOption { type = types.lines; default = ""; - example = literalExample '' + example = literalExpression '' builtins.readFile ( pkgs.fetchFromGitHub { owner = "solarized"; @@ -93,8 +93,8 @@ in { ++ optionals (cfg.properties != null) (mapAttrsToList formatLine cfg.properties)) + "\n"; onChange = '' - if [[ -v DISPLAY ]] ; then - $DRY_RUN_CMD ${xrdbMerge} + if [[ -v DISPLAY ]]; then + ${xrdbMerge} fi ''; }; diff --git a/third_party/home-manager/modules/xsession.nix b/third_party/home-manager/modules/xsession.nix index 6dc2968a63..35e517a021 100644 --- a/third_party/home-manager/modules/xsession.nix +++ b/third_party/home-manager/modules/xsession.nix @@ -35,7 +35,7 @@ in { windowManager.command = mkOption { type = types.str; - example = literalExample '' + example = literalExpression '' let xmonad = pkgs.xmonad-with-packages.override { packages = self: [ self.xmonad-contrib self.taffybar ]; @@ -43,8 +43,13 @@ in { in "''${xmonad}/bin/xmonad"; ''; + default = ''test -n "$1" && eval "$@"''; description = '' - Window manager start command. + Command to use to start the window manager. + + The default value allows integration with NixOS' generated xserver configuration. + + Extra actions and commands can be specified in . ''; }; @@ -85,6 +90,9 @@ in { }; config = mkIf cfg.enable { + assertions = + [ (hm.assertions.assertPlatform "xsession" pkgs platforms.linux) ]; + xsession.importedVariables = [ "DBUS_SESSION_BUS_ADDRESS" "DISPLAY" @@ -114,7 +122,7 @@ in { args = optional (layout != null) "-layout '${layout}'" ++ optional (variant != null) "-variant '${variant}'" ++ optional (model != null) "-model '${model}'" - ++ map (v: "-option '${v}'") options; + ++ [ "-option ''" ] ++ map (v: "-option '${v}'") options; in "${pkgs.xorg.setxkbmap}/bin/setxkbmap ${toString args}"; }; }; diff --git a/third_party/home-manager/nix-darwin/default.nix b/third_party/home-manager/nix-darwin/default.nix index 9e37f35824..f400c9ce21 100644 --- a/third_party/home-manager/nix-darwin/default.nix +++ b/third_party/home-manager/nix-darwin/default.nix @@ -12,6 +12,8 @@ let specialArgs = { lib = extendedLib; darwinConfig = config; + osConfig = config; + modulesPath = ../modules; } // cfg.extraSpecialArgs; modules = [ ({ name, ... }: { @@ -61,7 +63,6 @@ in extraSpecialArgs = mkOption { type = types.attrs; default = { }; - example = literalExample "{ modulesPath = ../modules; }"; description = '' Extra specialArgs passed to Home Manager. ''; @@ -69,12 +70,15 @@ in sharedModules = mkOption { type = with types; - listOf (anything // { + # TODO: use types.raw once this PR is merged: https://github.com/NixOS/nixpkgs/pull/132448 + listOf (mkOptionType { + name = "submodule"; inherit (submodule { }) check; + merge = lib.options.mergeOneOption; description = "Home Manager modules"; }); default = [ ]; - example = literalExample "[ { home.packages = [ nixpkgs-fmt ]; } ]"; + example = literalExpression "[ { home.packages = [ nixpkgs-fmt ]; } ]"; description = '' Extra modules added to all users. ''; diff --git a/third_party/home-manager/nixos/default.nix b/third_party/home-manager/nixos/default.nix index fec59c624c..e971cdc8c7 100644 --- a/third_party/home-manager/nixos/default.nix +++ b/third_party/home-manager/nixos/default.nix @@ -12,6 +12,8 @@ let specialArgs = { lib = extendedLib; nixosConfig = config; + osConfig = config; + modulesPath = ../modules; } // cfg.extraSpecialArgs; modules = [ ({ name, ... }: { @@ -32,6 +34,10 @@ let home.username = config.users.users.${name}.name; home.homeDirectory = config.users.users.${name}.home; + + # Make activation script use same version of Nix as system as a whole. + # This avoids problems with Nix not being in PATH. + home.extraActivationPath = [ config.nix.package ]; }; }) ] ++ cfg.sharedModules; @@ -68,7 +74,6 @@ in { extraSpecialArgs = mkOption { type = types.attrs; default = { }; - example = literalExample "{ modulesPath = ../modules; }"; description = '' Extra specialArgs passed to Home Manager. ''; @@ -76,12 +81,15 @@ in { sharedModules = mkOption { type = with types; - listOf (anything // { + # TODO: use types.raw once this PR is merged: https://github.com/NixOS/nixpkgs/pull/132448 + listOf (mkOptionType { + name = "submodule"; inherit (submodule { }) check; + merge = lib.options.mergeOneOption; description = "Home Manager modules"; }); default = [ ]; - example = literalExample "[ { home.packages = [ nixpkgs-fmt ]; } ]"; + example = literalExpression "[ { home.packages = [ nixpkgs-fmt ]; } ]"; description = '' Extra modules added to all users. ''; @@ -125,6 +133,7 @@ in { wantedBy = [ "multi-user.target" ]; wants = [ "nix-daemon.socket" ]; after = [ "nix-daemon.socket" ]; + before = [ "systemd-user-sessions.service" ]; environment = serviceEnvironment; @@ -136,15 +145,38 @@ in { User = usercfg.home.username; Type = "oneshot"; RemainAfterExit = "yes"; + TimeoutStartSec = 90; SyslogIdentifier = "hm-activate-${username}"; - # The activation script is run by a login shell to make sure - # that the user is given a sane Nix environment. - ExecStart = pkgs.writeScript "activate-${username}" '' - #! ${pkgs.runtimeShell} -el - echo Activating home-manager configuration for ${username} - exec ${usercfg.home.activationPackage}/activate - ''; + ExecStart = let + systemctl = + "XDG_RUNTIME_DIR=\${XDG_RUNTIME_DIR:-/run/user/$UID} systemctl"; + + sed = "${pkgs.gnused}/bin/sed"; + + exportedSystemdVariables = concatStringsSep "|" [ + "DBUS_SESSION_BUS_ADDRESS" + "DISPLAY" + "WAYLAND_DISPLAY" + "XAUTHORITY" + "XDG_RUNTIME_DIR" + ]; + + setupEnv = pkgs.writeScript "hm-setup-env" '' + #! ${pkgs.runtimeShell} -el + + # The activation script is run by a login shell to make sure + # that the user is given a sane environment. + # If the user is logged in, import variables from their current + # session environment. + eval "$( + ${systemctl} --user show-environment 2> /dev/null \ + | ${sed} -En '/^(${exportedSystemdVariables})=/s/^/export /p' + )" + + exec "$1/activate" + ''; + in "${setupEnv} ${usercfg.home.activationPackage}"; }; }) cfg.users; }; diff --git a/third_party/home-manager/tests/asserts.nix b/third_party/home-manager/tests/asserts.nix index 6d1b100227..c1fe177ee6 100644 --- a/third_party/home-manager/tests/asserts.nix +++ b/third_party/home-manager/tests/asserts.nix @@ -37,37 +37,45 @@ with lib; }; }; - config = mkIf config.test.asserts.warnings.enable { - home.file = { - "asserts/warnings.actual".text = concatStringsSep '' + config = mkMerge [ + (mkIf config.test.asserts.warnings.enable { + home.file = { + "asserts/warnings.actual".text = concatStringsSep '' - -- - '' config.warnings; + -- + '' config.warnings; + }; - "asserts/assertions.actual".text = concatStringsSep '' + nmt.script = '' + assertFileContent \ + home-files/asserts/warnings.actual \ + ${ + pkgs.writeText "warnings.expected" (concatStringsSep '' - -- - '' (map (x: x.message) (filter (x: !x.assertion) config.assertions)); - }; + -- + '' config.test.asserts.warnings.expected) + } + ''; + }) - nmt.script = '' - assertFileContent \ - home-files/asserts/warnings.actual \ - ${ - pkgs.writeText "warnings.expected" (concatStringsSep '' + (mkIf config.test.asserts.assertions.enable { + home.file = { + "asserts/assertions.actual".text = concatStringsSep '' - -- - '' config.test.asserts.warnings.expected) - } + -- + '' (map (x: x.message) (filter (x: !x.assertion) config.assertions)); + }; - assertFileContent \ - home-files/asserts/assertions.actual \ - ${ - pkgs.writeText "assertions.expected" (concatStringsSep '' + nmt.script = '' + assertFileContent \ + home-files/asserts/assertions.actual \ + ${ + pkgs.writeText "assertions.expected" (concatStringsSep '' - -- - '' config.test.asserts.assertions.expected) - } - ''; - }; + -- + '' config.test.asserts.assertions.expected) + } + ''; + }) + ]; } diff --git a/third_party/home-manager/tests/default.nix b/third_party/home-manager/tests/default.nix index 130eab4c0e..63b062c734 100644 --- a/third_party/home-manager/tests/default.nix +++ b/third_party/home-manager/tests/default.nix @@ -1,4 +1,4 @@ -{ pkgs ? import {} }: +{ pkgs ? import {}, enableBig ? true }: let @@ -26,10 +26,13 @@ let # unnecessary rebuilds of the tests. manual.manpages.enable = false; - imports = [ ./asserts.nix ]; + imports = [ ./asserts.nix ./stubs.nix ]; } ]; + isDarwin = pkgs.stdenv.hostPlatform.isDarwin; + isLinux = pkgs.stdenv.hostPlatform.isLinux; + in import nmt { @@ -43,8 +46,12 @@ import nmt { ./modules/programs/alacritty ./modules/programs/alot ./modules/programs/aria2 + ./modules/programs/atuin ./modules/programs/autojump ./modules/programs/bash + ./modules/programs/bat + ./modules/programs/bottom + ./modules/programs/broot ./modules/programs/browserpass ./modules/programs/dircolors ./modules/programs/direnv @@ -56,7 +63,7 @@ import nmt { ./modules/programs/himalaya ./modules/programs/htop ./modules/programs/i3status - ./modules/programs/irsii + ./modules/programs/irssi ./modules/programs/kakoune ./modules/programs/kitty ./modules/programs/lf @@ -69,6 +76,7 @@ import nmt { ./modules/programs/neomutt ./modules/programs/newsboat ./modules/programs/nix-index + ./modules/programs/nnn ./modules/programs/nushell ./modules/programs/pet ./modules/programs/powerline-go @@ -76,6 +84,7 @@ import nmt { ./modules/programs/readline ./modules/programs/sbt ./modules/programs/scmpuff + ./modules/programs/sm64ex ./modules/programs/ssh ./modules/programs/starship ./modules/programs/texlive @@ -85,12 +94,11 @@ import nmt { ./modules/programs/zplug ./modules/programs/zsh ./modules/xresources - ] ++ lib.optionals pkgs.stdenv.hostPlatform.isDarwin [ + ] ++ lib.optionals isDarwin [ ./modules/targets-darwin - ] ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [ + ] ++ lib.optionals isLinux [ ./modules/config/i18n ./modules/i18n/input-method - ./modules/misc/debug ./modules/misc/gtk ./modules/misc/numlock ./modules/misc/pam @@ -99,10 +107,10 @@ import nmt { ./modules/misc/xsession ./modules/programs/abook ./modules/programs/autorandr - ./modules/programs/firefox ./modules/programs/foot ./modules/programs/getmail ./modules/programs/gnome-terminal + ./modules/programs/hexchat ./modules/programs/i3status-rust ./modules/programs/mangohud ./modules/programs/ncmpcpp-linux @@ -114,9 +122,13 @@ import nmt { ./modules/programs/waybar ./modules/programs/xmobar ./modules/services/barrier + ./modules/services/devilspie2 ./modules/services/dropbox ./modules/services/emacs + ./modules/services/flameshot ./modules/services/fluidsynth + ./modules/services/fnott + ./modules/services/git-sync ./modules/services/kanshi ./modules/services/lieer ./modules/services/pantalaimon @@ -124,13 +136,21 @@ import nmt { ./modules/services/playerctld ./modules/services/polybar ./modules/services/redshift-gammastep + ./modules/services/screen-locker ./modules/services/sxhkd ./modules/services/syncthing + ./modules/services/trayer ./modules/services/window-managers/bspwm ./modules/services/window-managers/i3 ./modules/services/window-managers/sway ./modules/services/wlsunset + ./modules/services/xsettingsd ./modules/systemd ./modules/targets-linux + ] ++ lib.optionals enableBig [ + ./modules/programs/emacs + ] ++ lib.optionals (enableBig && isLinux) [ + ./modules/misc/debug + ./modules/programs/firefox ]); } diff --git a/third_party/home-manager/tests/lib/types/dag-merge.nix b/third_party/home-manager/tests/lib/types/dag-merge.nix index 40214bb45d..5e361cd7e7 100644 --- a/third_party/home-manager/tests/lib/types/dag-merge.nix +++ b/third_party/home-manager/tests/lib/types/dag-merge.nix @@ -1,8 +1,7 @@ { config, lib, pkgs, ... }: -with lib; - let + inherit (lib) concatStringsSep hm mkMerge mkOption types; dag = lib.hm.dag; diff --git a/third_party/home-manager/tests/lib/types/dag-submodule.nix b/third_party/home-manager/tests/lib/types/dag-submodule.nix index 29819ceb66..809b1a59b6 100644 --- a/third_party/home-manager/tests/lib/types/dag-submodule.nix +++ b/third_party/home-manager/tests/lib/types/dag-submodule.nix @@ -1,8 +1,7 @@ { config, lib, pkgs, ... }: -with lib; - let + inherit (lib) concatStringsSep hm mkOption types; dag = lib.hm.dag; diff --git a/third_party/home-manager/tests/lib/types/gvariant-merge.nix b/third_party/home-manager/tests/lib/types/gvariant-merge.nix index 867534c1f1..c4de6827f8 100644 --- a/third_party/home-manager/tests/lib/types/gvariant-merge.nix +++ b/third_party/home-manager/tests/lib/types/gvariant-merge.nix @@ -1,9 +1,6 @@ { config, lib, pkgs, ... }: -with lib; - -let - +let inherit (lib) concatStringsSep hm mapAttrsToList mkMerge mkOption types; in { options.examples = mkOption { type = types.attrsOf hm.types.gvariant; }; @@ -15,18 +12,39 @@ in { { float = 3.14; } - { int = 42; } - { int = 42; } + { int = -42; } + { int = -42; } - { list = [ "one" ]; } - { list = mkArray type.string [ "two" ]; } + { uint32 = mkUint32 42; } + { uint32 = mkUint32 42; } + + { int16 = mkInt16 (-42); } + { int16 = mkInt16 (-42); } + + { uint16 = mkUint16 42; } + { uint16 = mkUint16 42; } + + { int64 = mkInt64 (-42); } + { int64 = mkInt64 (-42); } + + { uint64 = mkUint64 42; } + { uint64 = mkUint64 42; } + + { array1 = [ "one" ]; } + { array1 = mkArray type.string [ "two" ]; } + { array2 = mkArray type.uint32 [ 1 ]; } + { array2 = mkArray type.uint32 [ 2 ]; } { emptyArray1 = [ ]; } { emptyArray2 = mkEmptyArray type.uint32; } { string = "foo"; } { string = "foo"; } - { escapedString = "' \\"; } + { + escapedString = '' + '\ + ''; + } { tuple = mkTuple [ 1 [ "foo" ] ]; } @@ -44,17 +62,23 @@ in { home-files/result.txt \ ${ pkgs.writeText "expected.txt" '' + array1 = @as ['one','two'] + array2 = @au [1,2] bool = true emptyArray1 = @as [] - emptyArray2 = @as [] - escapedString = '\' \\' + emptyArray2 = @au [] + escapedString = '\'\\\n' float = 3.140000 - int = 42 - list = @as ['one','two'] + int = -42 + int16 = @n -42 + int64 = @x -42 maybe1 = @ms nothing maybe2 = just @u 4 string = 'foo' tuple = @(ias) (1,@as ['foo']) + uint16 = @q 42 + uint32 = @u 42 + uint64 = @t 42 '' } ''; diff --git a/third_party/home-manager/tests/lib/types/list-or-dag-merge.nix b/third_party/home-manager/tests/lib/types/list-or-dag-merge.nix index 389938774a..4706c5cede 100644 --- a/third_party/home-manager/tests/lib/types/list-or-dag-merge.nix +++ b/third_party/home-manager/tests/lib/types/list-or-dag-merge.nix @@ -1,8 +1,7 @@ { config, lib, pkgs, ... }: -with lib; - let + inherit (lib) concatStringsSep hm mkMerge mkOption types; dag = lib.hm.dag; diff --git a/third_party/home-manager/tests/modules/home-environment/session-variables.nix b/third_party/home-manager/tests/modules/home-environment/session-variables.nix index d939c05eba..eae7830f35 100644 --- a/third_party/home-manager/tests/modules/home-environment/session-variables.nix +++ b/third_party/home-manager/tests/modules/home-environment/session-variables.nix @@ -15,6 +15,7 @@ let export XDG_CACHE_HOME="/home/hm-user/.cache" export XDG_CONFIG_HOME="/home/hm-user/.config" export XDG_DATA_HOME="/home/hm-user/.local/share" + export XDG_STATE_HOME="/home/hm-user/.local/state" ''; darwinExpected = '' @@ -27,6 +28,7 @@ let export XDG_CACHE_HOME="/home/hm-user/.cache" export XDG_CONFIG_HOME="/home/hm-user/.config" export XDG_DATA_HOME="/home/hm-user/.local/share" + export XDG_STATE_HOME="/home/hm-user/.local/state" ''; expected = pkgs.writeText "expected" (if isDarwin then darwinExpected else linuxExpected); diff --git a/third_party/home-manager/tests/modules/i18n/input-method/fcitx5-configuration.nix b/third_party/home-manager/tests/modules/i18n/input-method/fcitx5-configuration.nix index b29a94aa5e..59738fb01a 100644 --- a/third_party/home-manager/tests/modules/i18n/input-method/fcitx5-configuration.nix +++ b/third_party/home-manager/tests/modules/i18n/input-method/fcitx5-configuration.nix @@ -1,15 +1,14 @@ { config, pkgs, ... }: { - config = { - nixpkgs.overlays = [ (import ./fcitx5-overlay.nix) ]; - i18n.inputMethod = { - enabled = "fcitx5"; - fcitx5.addons = with pkgs; [ fcitx5-chinese-addons ]; - }; + imports = [ ./fcitx5-stubs.nix ]; - nmt.script = '' - assertFileExists home-files/.config/systemd/user/fcitx5-daemon.service - ''; + i18n.inputMethod = { + enabled = "fcitx5"; + fcitx5.addons = with pkgs; [ fcitx5-chinese-addons ]; }; + + nmt.script = '' + assertFileExists home-files/.config/systemd/user/fcitx5-daemon.service + ''; } diff --git a/third_party/home-manager/tests/modules/i18n/input-method/fcitx5-overlay.nix b/third_party/home-manager/tests/modules/i18n/input-method/fcitx5-overlay.nix deleted file mode 100644 index 4007552cb9..0000000000 --- a/third_party/home-manager/tests/modules/i18n/input-method/fcitx5-overlay.nix +++ /dev/null @@ -1,22 +0,0 @@ -final: prev: - -let - - dummy = prev.runCommandLocal "dummy-package" { } "mkdir $out"; - -in { - fcitx5 = prev.runCommandLocal "fcitx5" { version = "0"; } '' - mkdir -p $out/bin $out/share/applications $out/etc/xdg/autostart - touch $out/bin/fcitx5 \ - $out/share/applications/org.fcitx.Fcitx5.desktop \ - $out/etc/xdg/autostart/org.fcitx.Fcitx5.desktop - chmod +x $out/bin/fcitx5 - ''; - fcitx5-configtool = dummy; - fcitx5-lua = dummy; - fcitx5-qt = dummy; - fcitx5-gtk = dummy; - fcitx5-with-addons = - prev.fcitx5-with-addons.override { inherit (final) fcitx5-qt; }; - fcitx5-chinese-addons = dummy; -} diff --git a/third_party/home-manager/tests/modules/i18n/input-method/fcitx5-stubs.nix b/third_party/home-manager/tests/modules/i18n/input-method/fcitx5-stubs.nix new file mode 100644 index 0000000000..cdf707de6c --- /dev/null +++ b/third_party/home-manager/tests/modules/i18n/input-method/fcitx5-stubs.nix @@ -0,0 +1,27 @@ +{ + test.stubs = { + fcitx5 = { + version = "0"; + outPath = null; + buildScript = '' + mkdir -p $out/bin $out/share/applications $out/etc/xdg/autostart + touch $out/bin/fcitx5 \ + $out/share/applications/org.fcitx.Fcitx5.desktop \ + $out/etc/xdg/autostart/org.fcitx.Fcitx5.desktop + chmod +x $out/bin/fcitx5 + ''; + }; + fcitx5-configtool = { outPath = null; }; + fcitx5-lua = { outPath = null; }; + fcitx5-qt = { outPath = null; }; + fcitx5-gtk = { outPath = null; }; + fcitx5-chinese-addons = { outPath = null; }; + }; + + nixpkgs.overlays = [ + (self: super: { + fcitx5-with-addons = + super.fcitx5-with-addons.override { inherit (self) fcitx5-qt; }; + }) + ]; +} diff --git a/third_party/home-manager/tests/modules/misc/gtk/gtk-basic-config-expected.conf b/third_party/home-manager/tests/modules/misc/gtk/gtk-basic-config-expected.conf index 3970b6e917..2e4c1c368e 100644 --- a/third_party/home-manager/tests/modules/misc/gtk/gtk-basic-config-expected.conf +++ b/third_party/home-manager/tests/modules/misc/gtk/gtk-basic-config-expected.conf @@ -1,2 +1 @@ - gtk-can-change-accels = 1 \ No newline at end of file diff --git a/third_party/home-manager/tests/modules/misc/gtk/gtk2-basic-config.nix b/third_party/home-manager/tests/modules/misc/gtk/gtk2-basic-config.nix index 4ac7299a20..a49cc44e7e 100644 --- a/third_party/home-manager/tests/modules/misc/gtk/gtk2-basic-config.nix +++ b/third_party/home-manager/tests/modules/misc/gtk/gtk2-basic-config.nix @@ -9,6 +9,8 @@ with lib; gtk2.extraConfig = "gtk-can-change-accels = 1"; }; + test.stubs.dconf = { }; + nmt.script = '' assertFileExists home-files/.gtkrc-2.0 assertFileContent home-files/.gtkrc-2.0 ${ diff --git a/third_party/home-manager/tests/modules/misc/gtk/gtk2-config-file-location.nix b/third_party/home-manager/tests/modules/misc/gtk/gtk2-config-file-location.nix index 41de2877f9..a089983842 100644 --- a/third_party/home-manager/tests/modules/misc/gtk/gtk2-config-file-location.nix +++ b/third_party/home-manager/tests/modules/misc/gtk/gtk2-config-file-location.nix @@ -7,6 +7,8 @@ with lib; gtk.enable = true; gtk.gtk2.configLocation = "${config.xdg.configHome}/gtk-2.0/gtkrc"; + test.stubs.dconf = { }; + nmt.script = '' assertFileExists home-files/.config/gtk-2.0/gtkrc assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \ diff --git a/third_party/home-manager/tests/modules/misc/numlock/numlock.nix b/third_party/home-manager/tests/modules/misc/numlock/numlock.nix index aa468c212c..5616de1c57 100644 --- a/third_party/home-manager/tests/modules/misc/numlock/numlock.nix +++ b/third_party/home-manager/tests/modules/misc/numlock/numlock.nix @@ -6,9 +6,7 @@ with lib; config = { xsession.numlock.enable = true; - nixpkgs.overlays = [ - (self: super: { numlockx = pkgs.writeScriptBin "dummy-numlockx" ""; }) - ]; + test.stubs.numlockx = { }; nmt.script = '' serviceFile=home-files/.config/systemd/user/numlockx.service diff --git a/third_party/home-manager/tests/modules/misc/qt/qt-platform-theme-gnome.nix b/third_party/home-manager/tests/modules/misc/qt/qt-platform-theme-gnome.nix index e9aa1a2506..80baeae6f4 100644 --- a/third_party/home-manager/tests/modules/misc/qt/qt-platform-theme-gnome.nix +++ b/third_party/home-manager/tests/modules/misc/qt/qt-platform-theme-gnome.nix @@ -7,15 +7,11 @@ platformTheme = "gnome"; style = { name = "adwaita"; - package = pkgs.dummyTheme; + package = config.lib.test.mkStubPackage { }; }; }; - nixpkgs.overlays = [ - (self: super: { - dummyTheme = pkgs.runCommandLocal "theme" { } "mkdir $out"; - }) - ]; + test.stubs.qgnomeplatform = { }; nmt.script = '' assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \ diff --git a/third_party/home-manager/tests/modules/misc/xdg/default.nix b/third_party/home-manager/tests/modules/misc/xdg/default.nix index b637cd1bf5..e3104dd9ca 100644 --- a/third_party/home-manager/tests/modules/misc/xdg/default.nix +++ b/third_party/home-manager/tests/modules/misc/xdg/default.nix @@ -1,6 +1,6 @@ { xdg-mime-apps-basics = ./mime-apps-basics.nix; - xdg-file-attr-names = ./file-attr-names.nix; xdg-system-dirs = ./system-dirs.nix; xdg-desktop-entries = ./desktop-entries.nix; + xdg-file-gen = ./file-gen.nix; } diff --git a/third_party/home-manager/tests/modules/misc/xdg/file-attr-names.nix b/third_party/home-manager/tests/modules/misc/xdg/file-attr-names.nix deleted file mode 100644 index 0aa8fcffe6..0000000000 --- a/third_party/home-manager/tests/modules/misc/xdg/file-attr-names.nix +++ /dev/null @@ -1,26 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; - -{ - config = { - xdg.configFile.test.text = "config"; - xdg.dataFile.test.text = "data"; - home.file.test.text = "home"; - - nmt.script = '' - assertFileExists home-files/.config/test - assertFileExists home-files/.local/share/test - assertFileExists home-files/test - assertFileContent \ - home-files/.config/test \ - ${builtins.toFile "test" "config"} - assertFileContent \ - home-files/.local/share/test \ - ${builtins.toFile "test" "data"} - assertFileContent \ - home-files/test \ - ${builtins.toFile "test" "home"} - ''; - }; -} diff --git a/third_party/home-manager/tests/modules/misc/xdg/file-gen.nix b/third_party/home-manager/tests/modules/misc/xdg/file-gen.nix new file mode 100644 index 0000000000..47a3102c27 --- /dev/null +++ b/third_party/home-manager/tests/modules/misc/xdg/file-gen.nix @@ -0,0 +1,36 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + xdg.configHome = /. + "${config.home.homeDirectory}/.dummy-config"; + xdg.dataHome = /. + "${config.home.homeDirectory}/.dummy-data"; + xdg.cacheHome = /. + "${config.home.homeDirectory}/.dummy-cache"; + xdg.stateHome = /. + "${config.home.homeDirectory}/.dummy-state"; + + xdg.configFile.test.text = "config"; + xdg.dataFile.test.text = "data"; + home.file."${config.xdg.cacheHome}/test".text = "cache"; + home.file."${config.xdg.stateHome}/test".text = "state"; + + nmt.script = '' + assertFileExists home-files/.dummy-config/test + assertFileExists home-files/.dummy-cache/test + assertFileExists home-files/.dummy-data/test + assertFileExists home-files/.dummy-state/test + assertFileContent \ + home-files/.dummy-config/test \ + ${builtins.toFile "test" "config"} + assertFileContent \ + home-files/.dummy-data/test \ + ${builtins.toFile "test" "data"} + assertFileContent \ + home-files/.dummy-cache/test \ + ${builtins.toFile "test" "cache"} + assertFileContent \ + home-files/.dummy-state/test \ + ${builtins.toFile "test" "state"} + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/misc/xsession/basic-setxkbmap-expected.service b/third_party/home-manager/tests/modules/misc/xsession/basic-setxkbmap-expected.service index 39f876dd60..980721171f 100644 --- a/third_party/home-manager/tests/modules/misc/xsession/basic-setxkbmap-expected.service +++ b/third_party/home-manager/tests/modules/misc/xsession/basic-setxkbmap-expected.service @@ -2,7 +2,7 @@ WantedBy=graphical-session.target [Service] -ExecStart=@setxkbmap@/bin/setxkbmap -layout 'us' -variant '' +ExecStart=@setxkbmap@/bin/setxkbmap -layout 'us' -variant '' -option '' RemainAfterExit=true Type=oneshot diff --git a/third_party/home-manager/tests/modules/misc/xsession/keyboard-without-layout-expected.service b/third_party/home-manager/tests/modules/misc/xsession/keyboard-without-layout-expected.service index a04af53dad..4dbc100452 100644 --- a/third_party/home-manager/tests/modules/misc/xsession/keyboard-without-layout-expected.service +++ b/third_party/home-manager/tests/modules/misc/xsession/keyboard-without-layout-expected.service @@ -2,7 +2,7 @@ WantedBy=graphical-session.target [Service] -ExecStart=@setxkbmap@/bin/setxkbmap -option 'ctrl:nocaps' -option 'altwin:no_win' +ExecStart=@setxkbmap@/bin/setxkbmap -option '' -option 'ctrl:nocaps' -option 'altwin:no_win' RemainAfterExit=true Type=oneshot diff --git a/third_party/home-manager/tests/modules/programs/abook/no-settings.nix b/third_party/home-manager/tests/modules/programs/abook/no-settings.nix index ad04acd236..f8b096fb18 100644 --- a/third_party/home-manager/tests/modules/programs/abook/no-settings.nix +++ b/third_party/home-manager/tests/modules/programs/abook/no-settings.nix @@ -6,8 +6,7 @@ with lib; config = { programs.abook.enable = true; - nixpkgs.overlays = - [ (self: super: { abook = pkgs.writeScriptBin "dummy-abook" ""; }) ]; + test.stubs.abook = { }; nmt.script = '' assertPathNotExists home-files/.config/abook/abookrc diff --git a/third_party/home-manager/tests/modules/programs/abook/with-settings.nix b/third_party/home-manager/tests/modules/programs/abook/with-settings.nix index 3cb02a2666..e89ad7dad6 100644 --- a/third_party/home-manager/tests/modules/programs/abook/with-settings.nix +++ b/third_party/home-manager/tests/modules/programs/abook/with-settings.nix @@ -28,8 +28,7 @@ with lib; ''; }; - nixpkgs.overlays = - [ (self: super: { abook = pkgs.writeScriptBin "dummy-abook" ""; }) ]; + test.stubs.abook = { }; nmt.script = '' assertFileExists home-files/.config/abook/abookrc diff --git a/third_party/home-manager/tests/modules/programs/alacritty/empty-settings.nix b/third_party/home-manager/tests/modules/programs/alacritty/empty-settings.nix index 65470473c1..ecc6df35a7 100644 --- a/third_party/home-manager/tests/modules/programs/alacritty/empty-settings.nix +++ b/third_party/home-manager/tests/modules/programs/alacritty/empty-settings.nix @@ -6,9 +6,7 @@ with lib; config = { programs.alacritty.enable = true; - nixpkgs.overlays = [ - (self: super: { alacritty = pkgs.writeScriptBin "dummy-alacritty" ""; }) - ]; + test.stubs.alacritty = { }; nmt.script = '' assertPathNotExists home-files/.config/alacritty diff --git a/third_party/home-manager/tests/modules/programs/alacritty/example-settings.nix b/third_party/home-manager/tests/modules/programs/alacritty/example-settings.nix index c3671aa0ca..61b8b4b4e5 100644 --- a/third_party/home-manager/tests/modules/programs/alacritty/example-settings.nix +++ b/third_party/home-manager/tests/modules/programs/alacritty/example-settings.nix @@ -6,7 +6,7 @@ with lib; config = { programs.alacritty = { enable = true; - package = pkgs.writeScriptBin "dummy-alacritty" ""; + package = config.lib.test.mkStubPackage { }; settings = { window.dimensions = { diff --git a/third_party/home-manager/tests/modules/programs/alacritty/settings-merging.nix b/third_party/home-manager/tests/modules/programs/alacritty/settings-merging.nix index 1b8559d69d..c7962fb52f 100644 --- a/third_party/home-manager/tests/modules/programs/alacritty/settings-merging.nix +++ b/third_party/home-manager/tests/modules/programs/alacritty/settings-merging.nix @@ -6,7 +6,7 @@ with lib; config = { programs.alacritty = { enable = true; - package = pkgs.writeScriptBin "dummy-alacritty" ""; + package = config.lib.test.mkStubPackage { }; settings = { window.dimensions = { diff --git a/third_party/home-manager/tests/modules/programs/alot/alot.nix b/third_party/home-manager/tests/modules/programs/alot/alot.nix index 3f74ef21c0..6316fbd76e 100644 --- a/third_party/home-manager/tests/modules/programs/alot/alot.nix +++ b/third_party/home-manager/tests/modules/programs/alot/alot.nix @@ -23,8 +23,7 @@ with lib; programs.alot = { enable = true; }; - nixpkgs.overlays = - [ (self: super: { alot = pkgs.writeScriptBin "dummy-alot" ""; }) ]; + test.stubs.alot = { }; nmt.script = '' assertFileExists home-files/.config/alot/config diff --git a/third_party/home-manager/tests/modules/programs/aria2/settings.nix b/third_party/home-manager/tests/modules/programs/aria2/settings.nix index 0b5a52d90c..346de96794 100644 --- a/third_party/home-manager/tests/modules/programs/aria2/settings.nix +++ b/third_party/home-manager/tests/modules/programs/aria2/settings.nix @@ -20,8 +20,7 @@ with lib; ''; }; - nixpkgs.overlays = - [ (self: super: { aria2 = pkgs.writeScriptBin "dummy-aria2" ""; }) ]; + test.stubs.aria2 = { }; nmt.script = '' assertFileContent \ diff --git a/third_party/home-manager/tests/modules/programs/atuin/bash.nix b/third_party/home-manager/tests/modules/programs/atuin/bash.nix new file mode 100644 index 0000000000..f8c3140998 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/atuin/bash.nix @@ -0,0 +1,20 @@ +{ ... }: + +{ + programs = { + atuin.enable = true; + bash.enable = true; + }; + + test.stubs = { + atuin = { }; + bash-preexec = { }; + }; + + nmt.script = '' + assertFileExists home-files/.bashrc + assertFileContains \ + home-files/.bashrc \ + 'eval "$(@atuin@/bin/atuin init bash)"' + ''; +} diff --git a/third_party/home-manager/tests/modules/programs/atuin/default.nix b/third_party/home-manager/tests/modules/programs/atuin/default.nix new file mode 100644 index 0000000000..386a172883 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/atuin/default.nix @@ -0,0 +1,7 @@ +{ + atuin-bash = ./bash.nix; + atuin-empty-settings = ./empty-settings.nix; + atuin-example-settings = ./example-settings.nix; + atuin-no-shell = ./no-shell.nix; + atuin-zsh = ./zsh.nix; +} diff --git a/third_party/home-manager/tests/modules/programs/atuin/empty-settings.nix b/third_party/home-manager/tests/modules/programs/atuin/empty-settings.nix new file mode 100644 index 0000000000..58f126965d --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/atuin/empty-settings.nix @@ -0,0 +1,14 @@ +{ ... }: + +{ + programs.atuin.enable = true; + + test.stubs = { + atuin = { }; + bash-preexec = { }; + }; + + nmt.script = '' + assertPathNotExists home-files/.config/atuin/config.toml + ''; +} diff --git a/third_party/home-manager/tests/modules/programs/atuin/example-settings-expected.toml b/third_party/home-manager/tests/modules/programs/atuin/example-settings-expected.toml new file mode 100644 index 0000000000..c1e92f1463 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/atuin/example-settings-expected.toml @@ -0,0 +1,4 @@ +db_path = "~/.atuin-history.db" +dialect = "us" +auto_sync = true +search-mode = "fulltext" \ No newline at end of file diff --git a/third_party/home-manager/tests/modules/programs/atuin/example-settings.nix b/third_party/home-manager/tests/modules/programs/atuin/example-settings.nix new file mode 100644 index 0000000000..f2d3a88769 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/atuin/example-settings.nix @@ -0,0 +1,32 @@ +{ ... }: + +{ + programs.atuin = { + enable = true; + + settings = { + db_path = "~/.atuin-history.db"; + dialect = "us"; + auto_sync = true; + search-mode = "fulltext"; + }; + }; + + test.stubs = { + atuin = { }; + bash-preexec = { }; + }; + + nmt.script = '' + assertFileContent \ + home-files/.config/atuin/config.toml \ + ${ + builtins.toFile "example-settings-expected.toml" '' + auto_sync = true + db_path = "~/.atuin-history.db" + dialect = "us" + search-mode = "fulltext" + '' + } + ''; +} diff --git a/third_party/home-manager/tests/modules/programs/atuin/no-shell.nix b/third_party/home-manager/tests/modules/programs/atuin/no-shell.nix new file mode 100644 index 0000000000..ef3bfe5d6b --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/atuin/no-shell.nix @@ -0,0 +1,23 @@ +{ ... }: + +{ + programs = { + atuin = { + enable = true; + enableBashIntegration = false; + enableZshIntegration = false; + }; + bash.enable = true; + zsh.enable = true; + }; + + test.stubs = { + atuin = { }; + bash-preexec = { }; + }; + + nmt.script = '' + assertFileNotRegex home-files/.zshrc '@atuin@ init zsh' + assertFileNotRegex home-files/.bashrc '@atuin@ init bash' + ''; +} diff --git a/third_party/home-manager/tests/modules/programs/atuin/zsh.nix b/third_party/home-manager/tests/modules/programs/atuin/zsh.nix new file mode 100644 index 0000000000..45f0254ca9 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/atuin/zsh.nix @@ -0,0 +1,20 @@ +{ ... }: + +{ + programs = { + atuin.enable = true; + zsh.enable = true; + }; + + test.stubs = { + atuin = { }; + bash-preexec = { }; + }; + + nmt.script = '' + assertFileExists home-files/.zshrc + assertFileContains \ + home-files/.zshrc \ + 'eval "$(@atuin@/bin/atuin init zsh)"' + ''; +} diff --git a/third_party/home-manager/tests/modules/programs/autojump/default-settings.nix b/third_party/home-manager/tests/modules/programs/autojump/default-settings.nix index 2f66702727..2cca7de88c 100644 --- a/third_party/home-manager/tests/modules/programs/autojump/default-settings.nix +++ b/third_party/home-manager/tests/modules/programs/autojump/default-settings.nix @@ -6,6 +6,10 @@ with lib; config = { programs.autojump.enable = true; + test.stubs.autojump = { + buildScript = "mkdir -p $out/bin; touch $out/bin/autojump"; + }; + nmt.script = '' assertFileExists home-path/bin/autojump ''; diff --git a/third_party/home-manager/tests/modules/programs/autorandr/basic-configuration.nix b/third_party/home-manager/tests/modules/programs/autorandr/basic-configuration.nix index fad18f7542..c28edaa2af 100644 --- a/third_party/home-manager/tests/modules/programs/autorandr/basic-configuration.nix +++ b/third_party/home-manager/tests/modules/programs/autorandr/basic-configuration.nix @@ -28,6 +28,8 @@ }; }; + test.stubs.autorandr = { }; + nmt.script = '' config=home-files/.config/autorandr/default/config setup=home-files/.config/autorandr/default/setup diff --git a/third_party/home-manager/tests/modules/programs/autorandr/scale.nix b/third_party/home-manager/tests/modules/programs/autorandr/scale.nix index 9092e61dcd..095778a43e 100644 --- a/third_party/home-manager/tests/modules/programs/autorandr/scale.nix +++ b/third_party/home-manager/tests/modules/programs/autorandr/scale.nix @@ -17,6 +17,8 @@ }; }; + test.stubs.autorandr = { }; + nmt.script = '' config=home-files/.config/autorandr/default/config diff --git a/third_party/home-manager/tests/modules/programs/bat/bat.nix b/third_party/home-manager/tests/modules/programs/bat/bat.nix new file mode 100644 index 0000000000..e986129223 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/bat/bat.nix @@ -0,0 +1,42 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.bat = { + enable = true; + + config = { + theme = "TwoDark"; + pager = "less -FR"; + map-syntax = [ "*.jenkinsfile:Groovy" "*.props:Java Properties" ]; + }; + + themes.testtheme = '' + This is a test theme. + ''; + }; + + test.stubs.bat = { }; + + nmt.script = '' + assertFileExists home-files/.config/bat/config + assertFileContent home-files/.config/bat/config ${ + pkgs.writeText "bat.expected" '' + --map-syntax='*.jenkinsfile:Groovy' + --map-syntax='*.props:Java Properties' + --pager='less -FR' + --theme='TwoDark' + '' + } + + assertFileExists home-files/.config/bat/themes/testtheme.tmTheme + assertFileContent home-files/.config/bat/themes/testtheme.tmTheme ${ + pkgs.writeText "bat.expected" '' + This is a test theme. + '' + } + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/programs/bat/default.nix b/third_party/home-manager/tests/modules/programs/bat/default.nix new file mode 100644 index 0000000000..001d4bca6e --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/bat/default.nix @@ -0,0 +1 @@ +{ bat = ./bat.nix; } diff --git a/third_party/home-manager/tests/modules/programs/bottom/default.nix b/third_party/home-manager/tests/modules/programs/bottom/default.nix new file mode 100644 index 0000000000..ed6e241fc8 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/bottom/default.nix @@ -0,0 +1,4 @@ +{ + bottom-empty-settings = ./empty-settings.nix; + bottom-example-settings = ./example-settings.nix; +} diff --git a/third_party/home-manager/tests/modules/programs/bottom/empty-settings.nix b/third_party/home-manager/tests/modules/programs/bottom/empty-settings.nix new file mode 100644 index 0000000000..71799c8318 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/bottom/empty-settings.nix @@ -0,0 +1,16 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.bottom = { + enable = true; + package = config.lib.test.mkStubPackage { }; + }; + + nmt.script = '' + assertPathNotExists home-files/.config/bottom + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/programs/bottom/example-settings.nix b/third_party/home-manager/tests/modules/programs/bottom/example-settings.nix new file mode 100644 index 0000000000..30d8e21bf5 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/bottom/example-settings.nix @@ -0,0 +1,41 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.bottom = { + enable = true; + package = config.lib.test.mkStubPackage { }; + + settings = { + flags = { + avg_cpu = true; + temperature_type = "c"; + }; + + colors = { low_battery_color = "red"; }; + }; + }; + + nmt.script = let + configDir = if pkgs.stdenv.isDarwin then + "home-files/Library/Application Support" + else + "home-files/.config"; + in '' + assertFileContent \ + "${configDir}/bottom/bottom.toml" \ + ${ + builtins.toFile "example-settings-expected.toml" '' + [colors] + low_battery_color = "red" + + [flags] + avg_cpu = true + temperature_type = "c" + '' + } + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/programs/broot/broot.nix b/third_party/home-manager/tests/modules/programs/broot/broot.nix new file mode 100644 index 0000000000..a2dddca38d --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/broot/broot.nix @@ -0,0 +1,42 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.broot = { + enable = true; + modal = true; + }; + + test.stubs.broot = { }; + + nmt.script = '' + assertFileExists home-files/.config/broot/conf.toml + assertFileContent home-files/.config/broot/conf.toml ${ + pkgs.writeText "broot.expected" '' + modal = true + + [[verbs]] + execution = ":parent" + invocation = "p" + + [[verbs]] + execution = "$EDITOR {file}" + invocation = "edit" + shortcut = "e" + + [[verbs]] + execution = "$EDITOR {directory}/{subpath}" + invocation = "create {subpath}" + + [[verbs]] + execution = "less {file}" + invocation = "view" + + [skin] + '' + } + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/programs/broot/default.nix b/third_party/home-manager/tests/modules/programs/broot/default.nix new file mode 100644 index 0000000000..4f991f68bf --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/broot/default.nix @@ -0,0 +1 @@ +{ broot = ./broot.nix; } diff --git a/third_party/home-manager/tests/modules/programs/emacs/default.nix b/third_party/home-manager/tests/modules/programs/emacs/default.nix new file mode 100644 index 0000000000..b1b0c566d7 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/emacs/default.nix @@ -0,0 +1 @@ +{ emacs-extra-config = ./extra-config.nix; } diff --git a/third_party/home-manager/tests/modules/programs/emacs/extra-config.nix b/third_party/home-manager/tests/modules/programs/emacs/extra-config.nix new file mode 100644 index 0000000000..67778c3514 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/emacs/extra-config.nix @@ -0,0 +1,26 @@ +{ config, lib, pkgs, ... }: + +let + + testScript = pkgs.writeText "test.el" '' + ;; Emacs won't automatically load default.el when --script is specified + (load "default") + (kill-emacs (if (eq hm 'home-manager) 0 1)) + ''; + + emacsBin = "${config.programs.emacs.finalPackage}/bin/emacs"; + +in { + programs.emacs = { + enable = true; + package = pkgs.emacs-nox; + extraConfig = "(setq hm 'home-manager)"; + }; + + # running emacs with --script would enable headless mode + nmt.script = '' + if ! ${emacsBin} --script ${testScript}; then + fail "Failed to load default.el." + fi + ''; +} diff --git a/third_party/home-manager/tests/modules/programs/feh/feh-bindings.nix b/third_party/home-manager/tests/modules/programs/feh/feh-bindings.nix index f6b9e5b6e9..787b02d7ce 100644 --- a/third_party/home-manager/tests/modules/programs/feh/feh-bindings.nix +++ b/third_party/home-manager/tests/modules/programs/feh/feh-bindings.nix @@ -17,8 +17,7 @@ prev_img = [ "h" "Left" ]; }; - nixpkgs.overlays = - [ (self: super: { feh = pkgs.writeScriptBin "dummy-feh" ""; }) ]; + test.stubs.feh = { }; nmt.script = '' assertFileContent \ diff --git a/third_party/home-manager/tests/modules/programs/feh/feh-empty-settings.nix b/third_party/home-manager/tests/modules/programs/feh/feh-empty-settings.nix index ad0d15153d..62feb8230e 100644 --- a/third_party/home-manager/tests/modules/programs/feh/feh-empty-settings.nix +++ b/third_party/home-manager/tests/modules/programs/feh/feh-empty-settings.nix @@ -4,8 +4,7 @@ config = { programs.feh.enable = true; - nixpkgs.overlays = - [ (self: super: { feh = pkgs.writeScriptBin "dummy-feh" ""; }) ]; + test.stubs.feh = { }; nmt.script = '' assertPathNotExists home-files/.config/feh/buttons diff --git a/third_party/home-manager/tests/modules/programs/firefox/deprecated-native-messenger.nix b/third_party/home-manager/tests/modules/programs/firefox/deprecated-native-messenger.nix index 95e9d31827..cf5f188b48 100644 --- a/third_party/home-manager/tests/modules/programs/firefox/deprecated-native-messenger.nix +++ b/third_party/home-manager/tests/modules/programs/firefox/deprecated-native-messenger.nix @@ -13,6 +13,7 @@ with lib; (self: super: { firefox-unwrapped = pkgs.runCommandLocal "firefox-0" { meta.description = "I pretend to be Firefox"; + passthru.gtk3 = null; } '' mkdir -p "$out/bin" touch "$out/bin/firefox" diff --git a/third_party/home-manager/tests/modules/programs/firefox/profile-settings-expected-bookmarks-user.js b/third_party/home-manager/tests/modules/programs/firefox/profile-settings-expected-bookmarks-user.js new file mode 100644 index 0000000000..922d3651e2 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/firefox/profile-settings-expected-bookmarks-user.js @@ -0,0 +1,8 @@ +// Generated by Home Manager. + +user_pref("browser.bookmarks.file", "/nix/store/00000000000000000000000000000000-firefox-bookmarks.html"); +user_pref("browser.places.importBookmarksHTML", true); +user_pref("general.smoothScroll", false); + + + diff --git a/third_party/home-manager/tests/modules/programs/firefox/profile-settings-expected-bookmarks.html b/third_party/home-manager/tests/modules/programs/firefox/profile-settings-expected-bookmarks.html new file mode 100644 index 0000000000..15ce487b0e --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/firefox/profile-settings-expected-bookmarks.html @@ -0,0 +1,12 @@ + + + +Bookmarks +

Bookmarks Menu

+

+

kernel.org +
wikipedia + +

diff --git a/third_party/home-manager/tests/modules/programs/firefox/profile-settings.nix b/third_party/home-manager/tests/modules/programs/firefox/profile-settings.nix index b90fd9192d..605ff6692c 100644 --- a/third_party/home-manager/tests/modules/programs/firefox/profile-settings.nix +++ b/third_party/home-manager/tests/modules/programs/firefox/profile-settings.nix @@ -12,6 +12,19 @@ with lib; id = 1; settings = { "general.smoothScroll" = false; }; }; + + profiles.bookmarks = { + id = 2; + settings = { "general.smoothScroll" = false; }; + bookmarks = { + wikipedia = { + keyword = "wiki"; + url = + "https://en.wikipedia.org/wiki/Special:Search?search=%s&go=Go"; + }; + "kernel.org" = { url = "https://www.kernel.org"; }; + }; + }; }; nixpkgs.overlays = [ @@ -20,6 +33,7 @@ with lib; meta.description = "I pretend to be Firefox"; preferLocalBuild = true; allowSubstitutes = false; + passthru.gtk3 = null; } '' mkdir -p "$out/bin" touch "$out/bin/firefox" @@ -38,6 +52,21 @@ with lib; assertFileContent \ home-files/.mozilla/firefox/test/user.js \ ${./profile-settings-expected-user.js} + + bookmarksUserJs=$(normalizeStorePaths \ + home-files/.mozilla/firefox/bookmarks/user.js) + + assertFileContent \ + $bookmarksUserJs \ + ${./profile-settings-expected-bookmarks-user.js} + + bookmarksFile="$(sed -n \ + '/browser.bookmarks.file/ {s|^.*\(/nix/store[^"]*\).*|\1|;p}' \ + $TESTED/home-files/.mozilla/firefox/bookmarks/user.js)" + + assertFileContent \ + $bookmarksFile \ + ${./profile-settings-expected-bookmarks.html} ''; }; } diff --git a/third_party/home-manager/tests/modules/programs/firefox/state-version-19_09.nix b/third_party/home-manager/tests/modules/programs/firefox/state-version-19_09.nix index 27dc867ad2..82fa039ca5 100644 --- a/third_party/home-manager/tests/modules/programs/firefox/state-version-19_09.nix +++ b/third_party/home-manager/tests/modules/programs/firefox/state-version-19_09.nix @@ -14,6 +14,7 @@ with lib; meta.description = "I pretend to be Firefox"; preferLocalBuild = true; allowSubstitutes = false; + passthru.gtk3 = null; } '' mkdir -p "$out/bin" touch "$out/bin/firefox" diff --git a/third_party/home-manager/tests/modules/programs/fish/functions.nix b/third_party/home-manager/tests/modules/programs/fish/functions.nix index 424d0a288c..67f8ba0d56 100644 --- a/third_party/home-manager/tests/modules/programs/fish/functions.nix +++ b/third_party/home-manager/tests/modules/programs/fish/functions.nix @@ -30,6 +30,12 @@ in { }; }; + # Needed to avoid error with dummy fish package. + xdg.dataFile."fish/home-manager_generated_completions".source = + lib.mkForce (builtins.toFile "empty" ""); + + test.stubs.fish = { }; + nmt = { description = "if fish.function is set, check file exists and contents match"; diff --git a/third_party/home-manager/tests/modules/programs/fish/no-functions.nix b/third_party/home-manager/tests/modules/programs/fish/no-functions.nix index c817b38895..0ab38a09e7 100644 --- a/third_party/home-manager/tests/modules/programs/fish/no-functions.nix +++ b/third_party/home-manager/tests/modules/programs/fish/no-functions.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ config, lib, pkgs, ... }: with lib; @@ -10,6 +10,12 @@ with lib; functions = { }; }; + # Needed to avoid error with dummy fish package. + xdg.dataFile."fish/home-manager_generated_completions".source = + lib.mkForce (builtins.toFile "empty" ""); + + test.stubs.fish = { }; + nmt = { description = "if fish.functions is blank, the functions folder should not exist."; diff --git a/third_party/home-manager/tests/modules/programs/fish/plugins.nix b/third_party/home-manager/tests/modules/programs/fish/plugins.nix index 657c33f39b..6b02dd46f0 100644 --- a/third_party/home-manager/tests/modules/programs/fish/plugins.nix +++ b/third_party/home-manager/tests/modules/programs/fish/plugins.nix @@ -46,6 +46,12 @@ in { }]; }; + # Needed to avoid error with dummy fish package. + xdg.dataFile."fish/home-manager_generated_completions".source = + lib.mkForce (builtins.toFile "empty" ""); + + test.stubs.fish = { }; + nmt = { description = "if fish.plugins set, check conf.d file exists and contents match"; diff --git a/third_party/home-manager/tests/modules/programs/foot/empty-settings.nix b/third_party/home-manager/tests/modules/programs/foot/empty-settings.nix index 3935fd9dcd..26b82e7fbc 100644 --- a/third_party/home-manager/tests/modules/programs/foot/empty-settings.nix +++ b/third_party/home-manager/tests/modules/programs/foot/empty-settings.nix @@ -6,8 +6,7 @@ with lib; config = { programs.foot.enable = true; - nixpkgs.overlays = - [ (self: super: { foot = pkgs.writeScriptBin "dummy-foot" ""; }) ]; + test.stubs.foot = { }; nmt.script = '' assertPathNotExists home-files/.config/foot diff --git a/third_party/home-manager/tests/modules/programs/foot/example-settings.nix b/third_party/home-manager/tests/modules/programs/foot/example-settings.nix index c230638233..8390305eac 100644 --- a/third_party/home-manager/tests/modules/programs/foot/example-settings.nix +++ b/third_party/home-manager/tests/modules/programs/foot/example-settings.nix @@ -6,7 +6,7 @@ with lib; config = { programs.foot = { enable = true; - package = pkgs.writeShellScriptBin "dummy-foot" ""; + package = config.lib.test.mkStubPackage { }; settings = { main = { diff --git a/third_party/home-manager/tests/modules/programs/foot/systemd-user-service.nix b/third_party/home-manager/tests/modules/programs/foot/systemd-user-service.nix index 1eff14f9fd..5ebd906750 100644 --- a/third_party/home-manager/tests/modules/programs/foot/systemd-user-service.nix +++ b/third_party/home-manager/tests/modules/programs/foot/systemd-user-service.nix @@ -1,11 +1,9 @@ { config, lib, pkgs, ... }: -let - package = pkgs.writeShellScriptBin "dummy-foot" "" // { outPath = "@foot@"; }; -in { +{ config = { programs.foot = { - inherit package; + package = config.lib.test.mkStubPackage { outPath = "@foot@"; }; enable = true; server.enable = true; }; diff --git a/third_party/home-manager/tests/modules/programs/gh/config-file.nix b/third_party/home-manager/tests/modules/programs/gh/config-file.nix index 71fd74d32e..58600e7f4b 100644 --- a/third_party/home-manager/tests/modules/programs/gh/config-file.nix +++ b/third_party/home-manager/tests/modules/programs/gh/config-file.nix @@ -4,18 +4,21 @@ config = { programs.gh = { enable = true; - aliases = { co = "pr checkout"; }; - editor = "vim"; + settings.aliases = { co = "pr checkout"; }; + settings.editor = "vim"; }; - nixpkgs.overlays = - [ (self: super: { gh = pkgs.writeScriptBin "dummy-gh" ""; }) ]; + test.stubs.gh = { }; nmt.script = '' assertFileExists home-files/.config/gh/config.yml assertFileContent home-files/.config/gh/config.yml ${ builtins.toFile "config-file.yml" '' - {"aliases":{"co":"pr checkout"},"editor":"vim","git_protocol":"https"}'' + aliases: + co: pr checkout + editor: vim + git_protocol: https + '' } ''; }; diff --git a/third_party/home-manager/tests/modules/programs/gh/credential-helper.git.conf b/third_party/home-manager/tests/modules/programs/gh/credential-helper.git.conf new file mode 100644 index 0000000000..ea2c61ee46 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/gh/credential-helper.git.conf @@ -0,0 +1,2 @@ +[credential "https://github.com"] + helper = "@gh@/bin/gh auth git-credential" diff --git a/third_party/home-manager/tests/modules/programs/gh/credential-helper.nix b/third_party/home-manager/tests/modules/programs/gh/credential-helper.nix new file mode 100644 index 0000000000..e7ee8e42bf --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/gh/credential-helper.nix @@ -0,0 +1,21 @@ +{ config, lib, pkgs, ... }: + +{ + programs.gh = { + enable = true; + enableGitCredentialHelper = true; + }; + + programs.git.enable = true; + + test.stubs = { + gh = { }; + git = { }; + }; + + nmt.script = '' + assertFileExists home-files/.config/git/config + assertFileContent home-files/.config/git/config \ + ${./credential-helper.git.conf} + ''; +} diff --git a/third_party/home-manager/tests/modules/programs/gh/default.nix b/third_party/home-manager/tests/modules/programs/gh/default.nix index 680e8b2756..c683b484e6 100644 --- a/third_party/home-manager/tests/modules/programs/gh/default.nix +++ b/third_party/home-manager/tests/modules/programs/gh/default.nix @@ -1 +1,5 @@ -{ gh-config-file = ./config-file.nix; } +{ + gh-config-file = ./config-file.nix; + gh-credential-helper = ./credential-helper.nix; + gh-warnings = ./warnings.nix; +} diff --git a/third_party/home-manager/tests/modules/programs/gh/warnings.nix b/third_party/home-manager/tests/modules/programs/gh/warnings.nix new file mode 100644 index 0000000000..53937a7c01 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/gh/warnings.nix @@ -0,0 +1,35 @@ +{ config, options, lib, pkgs, ... }: + +{ + config = { + programs.gh = { + enable = true; + aliases = { co = "pr checkout"; }; + editor = "vim"; + }; + + test.stubs.gh = { }; + + test.asserts.warnings.expected = [ + "The option `programs.gh.editor' defined in ${ + lib.showFiles options.programs.gh.editor.files + } has been renamed to `programs.gh.settings.editor'." + "The option `programs.gh.aliases' defined in ${ + lib.showFiles options.programs.gh.aliases.files + } has been renamed to `programs.gh.settings.aliases'." + ]; + test.asserts.warnings.enable = true; + + nmt.script = '' + assertFileExists home-files/.config/gh/config.yml + assertFileContent home-files/.config/gh/config.yml ${ + builtins.toFile "config-file.yml" '' + aliases: + co: pr checkout + editor: vim + git_protocol: https + '' + } + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/programs/git/git-with-msmtp.nix b/third_party/home-manager/tests/modules/programs/git/git-with-msmtp.nix index abe32af8ec..dc6ba465e9 100644 --- a/third_party/home-manager/tests/modules/programs/git/git-with-msmtp.nix +++ b/third_party/home-manager/tests/modules/programs/git/git-with-msmtp.nix @@ -16,6 +16,8 @@ with lib; home.stateVersion = "20.09"; + test.stubs.msmtp = { }; + nmt.script = '' function assertGitConfig() { local value @@ -29,12 +31,7 @@ with lib; assertFileExists home-files/.config/git/config assertFileContent home-files/.config/git/config \ - ${ - pkgs.substituteAll { - inherit (pkgs) msmtp; - src = ./git-with-msmtp-expected.conf; - } - } + ${./git-with-msmtp-expected.conf} assertGitConfig "sendemail.hm@example.com.from" "hm@example.com" assertGitConfig "sendemail.hm-account.from" "hm@example.org" diff --git a/third_party/home-manager/tests/modules/programs/git/git.nix b/third_party/home-manager/tests/modules/programs/git/git.nix index 5417f7ea09..6c7320604b 100644 --- a/third_party/home-manager/tests/modules/programs/git/git.nix +++ b/third_party/home-manager/tests/modules/programs/git/git.nix @@ -79,14 +79,10 @@ in { } ]; - nixpkgs.overlays = [ - (self: super: { - git-lfs = pkgs.writeScriptBin "dummy-git-lfs" ""; - delta = pkgs.writeScriptBin "dummy-delta" "" // { - outPath = "@delta@"; - }; - }) - ]; + test.stubs = { + git-lfs = { }; + delta = { }; + }; nmt.script = '' assertFileExists home-files/.config/git/config diff --git a/third_party/home-manager/tests/modules/programs/gnome-terminal/gnome-terminal-1.nix b/third_party/home-manager/tests/modules/programs/gnome-terminal/gnome-terminal-1.nix index 44d95cb3b1..bb58983feb 100644 --- a/third_party/home-manager/tests/modules/programs/gnome-terminal/gnome-terminal-1.nix +++ b/third_party/home-manager/tests/modules/programs/gnome-terminal/gnome-terminal-1.nix @@ -4,13 +4,6 @@ with lib; { config = { - nixpkgs.overlays = [ - (self: super: { - gnome.gnome-terminal = - pkgs.writeScriptBin "dummy-gnome3-gnome-terminal" ""; - }) - ]; - programs.gnome-terminal = { enable = true; profile = { @@ -55,6 +48,14 @@ with lib; showMenubar = false; }; + nixpkgs.overlays = [ + (self: super: { + gnome.gnome-terminal = config.lib.test.mkStubPackage { }; + }) + ]; + + test.stubs.dconf = { }; + nmt.script = '' dconfIni=$(grep -oPm 1 '/nix/store/[a-z0-9]*?-hm-dconf.ini' $TESTED/activate) assertFileContent $dconfIni ${./gnome-terminal-1.conf} diff --git a/third_party/home-manager/tests/modules/programs/hexchat/basic-configuration-expected-main-config b/third_party/home-manager/tests/modules/programs/hexchat/basic-configuration-expected-main-config new file mode 100644 index 0000000000..e3617ca821 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/hexchat/basic-configuration-expected-main-config @@ -0,0 +1,10 @@ +dcc_dir = /home/user/Downloads +gui_quit_dialog = 0 +gui_slist_skip = 1 +irc_nick1 = user +irc_nick2 = user_ +irc_nick3 = user__ +irc_real_name = real user +irc_user_name = user +text_font = Monospace 14 +text_font_main = Monospace 14 \ No newline at end of file diff --git a/third_party/home-manager/tests/modules/programs/hexchat/basic-configuration-expected-serverlist-config b/third_party/home-manager/tests/modules/programs/hexchat/basic-configuration-expected-serverlist-config new file mode 100644 index 0000000000..29d232842b --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/hexchat/basic-configuration-expected-serverlist-config @@ -0,0 +1,24 @@ + +N=efnet +L= +F=4 +S=irc.choopa.net +S=irc.colosolutions.net +S=irc.mzima.net +S=irc.prison.net +J=#computers + +N=freenode +L=6 +E=UTF-8 (Unicode) +F=12 +I=user +i=user_ +R=real_user +U=user +P=password +S=chat.freenode.net +S=irc.freenode.net +J=#home-manager +J=#nixos + diff --git a/third_party/home-manager/tests/modules/programs/hexchat/basic-configuration.nix b/third_party/home-manager/tests/modules/programs/hexchat/basic-configuration.nix new file mode 100644 index 0000000000..1aa39bd49a --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/hexchat/basic-configuration.nix @@ -0,0 +1,61 @@ +{ config, lib, pkgs, ... }: + +{ + config = { + programs.hexchat = { + enable = true; + overwriteConfigFiles = true; + channels = { + freenode = { + charset = "UTF-8 (Unicode)"; + userName = "user"; + password = "password"; + loginMethod = "sasl"; + nickname = "user"; + nickname2 = "user_"; + realName = "real_user"; + options = { + autoconnect = true; + forceSSL = true; + }; + servers = [ "chat.freenode.net" "irc.freenode.net" ]; + autojoin = [ "#home-manager" "#nixos" ]; + }; + efnet = { + options = { forceSSL = true; }; + servers = [ + "irc.choopa.net" + "irc.colosolutions.net" + "irc.mzima.net" + "irc.prison.net" + ]; + autojoin = [ "#computers" ]; + }; + }; + settings = { + dcc_dir = "/home/user/Downloads"; + irc_nick1 = "user"; + irc_nick2 = "user_"; + irc_nick3 = "user__"; + irc_user_name = "user"; + irc_real_name = "real user"; + text_font = "Monospace 14"; + text_font_main = "Monospace 14"; + gui_slist_skip = "1"; # Skip network list on start-up + gui_quit_dialog = "0"; + }; + }; + + test.stubs.hexchat = { }; + + nmt.script = '' + assertFileContent \ + home-files/.config/hexchat/hexchat.conf \ + ${./basic-configuration-expected-main-config} + assertFileContent \ + home-files/.config/hexchat/servlist.conf \ + ${./basic-configuration-expected-serverlist-config} + ''; + }; + +} diff --git a/third_party/home-manager/tests/modules/programs/hexchat/default.nix b/third_party/home-manager/tests/modules/programs/hexchat/default.nix new file mode 100644 index 0000000000..e70c4610c6 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/hexchat/default.nix @@ -0,0 +1 @@ +{ hexchat-basic-configuration = ./basic-configuration.nix; } diff --git a/third_party/home-manager/tests/modules/programs/himalaya/himalaya.nix b/third_party/home-manager/tests/modules/programs/himalaya/himalaya.nix index ce5385d14e..827a09bef1 100644 --- a/third_party/home-manager/tests/modules/programs/himalaya/himalaya.nix +++ b/third_party/home-manager/tests/modules/programs/himalaya/himalaya.nix @@ -5,34 +5,31 @@ with lib; { imports = [ ../../accounts/email-test-accounts.nix ]; - config = { - accounts.email.accounts = { - "hm@example.com" = { - himalaya = { - enable = true; + accounts.email.accounts = { + "hm@example.com" = { + himalaya = { + enable = true; - settings = { default-page-size = 50; }; - }; - - imap.port = 995; - smtp.port = 465; + settings = { default-page-size = 50; }; }; + + imap.port = 995; + smtp.port = 465; }; - - programs.himalaya = { - enable = true; - settings = { downloads-dir = "/data/download"; }; - }; - - nixpkgs.overlays = - [ (self: super: { himalaya = pkgs.writeScriptBin "dummy-alot" ""; }) ]; - - nmt.script = '' - assertFileExists home-files/.config/himalaya/config.toml - assertFileContent home-files/.config/himalaya/config.toml ${ - ./himalaya-expected.toml - } - ''; }; + + programs.himalaya = { + enable = true; + settings = { downloads-dir = "/data/download"; }; + }; + + test.stubs.himalaya = { }; + + nmt.script = '' + assertFileExists home-files/.config/himalaya/config.toml + assertFileContent home-files/.config/himalaya/config.toml ${ + ./himalaya-expected.toml + } + ''; } diff --git a/third_party/home-manager/tests/modules/programs/htop/default.nix b/third_party/home-manager/tests/modules/programs/htop/default.nix index 53653285ea..e63d74fd39 100644 --- a/third_party/home-manager/tests/modules/programs/htop/default.nix +++ b/third_party/home-manager/tests/modules/programs/htop/default.nix @@ -1,4 +1,6 @@ { - htop-default-settings = ./default-settings.nix; + htop-empty-settings = ./empty-settings.nix; htop-example-settings = ./example-settings.nix; + htop-header_layout = ./header_layout.nix; + htop-settings-without-fields = ./settings-without-fields.nix; } diff --git a/third_party/home-manager/tests/modules/programs/htop/default-settings.nix b/third_party/home-manager/tests/modules/programs/htop/empty-settings.nix similarity index 61% rename from third_party/home-manager/tests/modules/programs/htop/default-settings.nix rename to third_party/home-manager/tests/modules/programs/htop/empty-settings.nix index f67e58276c..b8e43600f7 100644 --- a/third_party/home-manager/tests/modules/programs/htop/default-settings.nix +++ b/third_party/home-manager/tests/modules/programs/htop/empty-settings.nix @@ -6,8 +6,10 @@ with lib; config = { programs.htop.enable = true; + test.stubs.htop = { }; + nmt.script = '' - assertFileExists home-files/.config/htop/htoprc + assertPathNotExists home-files/.config/htop ''; }; } diff --git a/third_party/home-manager/tests/modules/programs/htop/example-htoprc.txt b/third_party/home-manager/tests/modules/programs/htop/example-htoprc.txt new file mode 100644 index 0000000000..ff06ed5ea8 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/htop/example-htoprc.txt @@ -0,0 +1,11 @@ +color_scheme=6 +cpu_count_from_one=0 +delay=15 +fields=0 48 17 18 38 39 40 2 46 47 49 1 +highlight_base_name=1 +highlight_megabytes=1 +highlight_threads=1 +left_meter_modes=1 1 1 2 +left_meters=AllCPUs2 Memory Swap Zram +right_meter_modes=2 2 2 2 +right_meters=Tasks LoadAverage Uptime Systemd diff --git a/third_party/home-manager/tests/modules/programs/htop/example-settings.nix b/third_party/home-manager/tests/modules/programs/htop/example-settings.nix index 66698c844e..71685434ad 100644 --- a/third_party/home-manager/tests/modules/programs/htop/example-settings.nix +++ b/third_party/home-manager/tests/modules/programs/htop/example-settings.nix @@ -36,8 +36,12 @@ with lib; (text "Systemd") ]); + test.stubs.htop = { }; + nmt.script = '' - assertFileExists home-files/.config/htop/htoprc + htoprc=home-files/.config/htop/htoprc + assertFileExists $htoprc + assertFileContent $htoprc ${./example-htoprc.txt} ''; }; } diff --git a/third_party/home-manager/tests/modules/programs/htop/header_layout.nix b/third_party/home-manager/tests/modules/programs/htop/header_layout.nix new file mode 100644 index 0000000000..2cf34998d6 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/htop/header_layout.nix @@ -0,0 +1,37 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = with config.lib.htop; { + programs.htop.enable = true; + programs.htop.settings = { + header_layout = "two_50_50"; + column_meters_0 = [ "AllCPUs2" "Memory" "Swap" "Zram" ]; + column_meters_modes_0 = [ modes.Bar modes.Bar modes.Bar modes.Text ]; + column_meters_1 = [ "Tasks" "LoadAverage" "Uptime" "Systemd" ]; + column_meters_modes_1 = [ modes.Text modes.Text modes.Text modes.Text ]; + }; + + test.stubs.htop = { }; + + # Test that the 'fields' key is written in addition to the customized + # settings or htop won't read the options. + nmt.script = '' + htoprc=home-files/.config/htop/htoprc + assertFileExists $htoprc + assertFileContent $htoprc \ + ${ + builtins.toFile "htoprc-expected" '' + header_layout=two_50_50 + column_meters_0=AllCPUs2 Memory Swap Zram + column_meters_1=Tasks LoadAverage Uptime Systemd + column_meters_modes_0=1 1 1 2 + column_meters_modes_1=2 2 2 2 + fields=0 48 17 18 38 39 40 2 46 47 49 1 + '' + } + ''; + }; + +} diff --git a/third_party/home-manager/tests/modules/programs/htop/settings-without-fields.nix b/third_party/home-manager/tests/modules/programs/htop/settings-without-fields.nix new file mode 100644 index 0000000000..2f4b3e864c --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/htop/settings-without-fields.nix @@ -0,0 +1,27 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.htop.enable = true; + programs.htop.settings = { color_scheme = 6; }; + + test.stubs.htop = { }; + + # Test that the 'fields' key is written in addition to the customized + # settings or htop won't read the options. + nmt.script = '' + htoprc=home-files/.config/htop/htoprc + assertFileExists $htoprc + assertFileContent $htoprc \ + ${ + builtins.toFile "htoprc-expected" '' + color_scheme=6 + fields=0 48 17 18 38 39 40 2 46 47 49 1 + '' + } + ''; + }; + +} diff --git a/third_party/home-manager/tests/modules/programs/i3status-rust/with-custom.nix b/third_party/home-manager/tests/modules/programs/i3status-rust/with-custom.nix index 4ced6add57..b53963ddba 100644 --- a/third_party/home-manager/tests/modules/programs/i3status-rust/with-custom.nix +++ b/third_party/home-manager/tests/modules/programs/i3status-rust/with-custom.nix @@ -92,11 +92,7 @@ with lib; }; }; - nixpkgs.overlays = [ - (self: super: { - i3status-rust = pkgs.writeScriptBin "dummy-i3status-rust" ""; - }) - ]; + test.stubs.i3status-rust = { }; nmt.script = '' assertFileExists home-files/.config/i3status-rust/config-custom.toml diff --git a/third_party/home-manager/tests/modules/programs/i3status-rust/with-default.nix b/third_party/home-manager/tests/modules/programs/i3status-rust/with-default.nix index b62c248c8a..4a0d4a4c4d 100644 --- a/third_party/home-manager/tests/modules/programs/i3status-rust/with-default.nix +++ b/third_party/home-manager/tests/modules/programs/i3status-rust/with-default.nix @@ -6,11 +6,7 @@ with lib; config = { programs.i3status-rust = { enable = true; }; - nixpkgs.overlays = [ - (self: super: { - i3status-rust = pkgs.writeScriptBin "dummy-i3status-rust" ""; - }) - ]; + test.stubs.i3status-rust = { }; nmt.script = '' assertFileExists home-files/.config/i3status-rust/config-default.toml diff --git a/third_party/home-manager/tests/modules/programs/i3status-rust/with-extra-settings.nix b/third_party/home-manager/tests/modules/programs/i3status-rust/with-extra-settings.nix index 16f3428a0f..4a0442732b 100644 --- a/third_party/home-manager/tests/modules/programs/i3status-rust/with-extra-settings.nix +++ b/third_party/home-manager/tests/modules/programs/i3status-rust/with-extra-settings.nix @@ -102,11 +102,7 @@ with lib; }; }; - nixpkgs.overlays = [ - (self: super: { - i3status-rust = pkgs.writeScriptBin "dummy-i3status-rust" ""; - }) - ]; + test.stubs.i3status-rust = { }; nmt.script = '' assertFileExists home-files/.config/i3status-rust/config-extra-settings.toml diff --git a/third_party/home-manager/tests/modules/programs/i3status-rust/with-multiple-bars.nix b/third_party/home-manager/tests/modules/programs/i3status-rust/with-multiple-bars.nix index 9cbbe2854a..eab7f42d47 100644 --- a/third_party/home-manager/tests/modules/programs/i3status-rust/with-multiple-bars.nix +++ b/third_party/home-manager/tests/modules/programs/i3status-rust/with-multiple-bars.nix @@ -52,11 +52,7 @@ with lib; }; - nixpkgs.overlays = [ - (self: super: { - i3status-rust = pkgs.writeScriptBin "dummy-i3status-rust" ""; - }) - ]; + test.stubs.i3status-rust = { }; nmt.script = '' assertFileExists home-files/.config/i3status-rust/config-top.toml diff --git a/third_party/home-manager/tests/modules/programs/i3status/with-custom.nix b/third_party/home-manager/tests/modules/programs/i3status/with-custom.nix index 4aa01773e4..830bc6c98d 100644 --- a/third_party/home-manager/tests/modules/programs/i3status/with-custom.nix +++ b/third_party/home-manager/tests/modules/programs/i3status/with-custom.nix @@ -32,9 +32,7 @@ with lib; }; }; - nixpkgs.overlays = [ - (self: super: { i3status = pkgs.writeScriptBin "dummy-i3status" ""; }) - ]; + test.stubs.i3status = { }; nmt.script = '' assertFileContent \ diff --git a/third_party/home-manager/tests/modules/programs/i3status/with-default.nix b/third_party/home-manager/tests/modules/programs/i3status/with-default.nix index 0b7e4ee2fa..d56ecc2054 100644 --- a/third_party/home-manager/tests/modules/programs/i3status/with-default.nix +++ b/third_party/home-manager/tests/modules/programs/i3status/with-default.nix @@ -9,9 +9,7 @@ with lib; enableDefault = true; }; - nixpkgs.overlays = [ - (self: super: { i3status = pkgs.writeScriptBin "dummy-i3status" ""; }) - ]; + test.stubs.i3status = { }; nmt.script = '' assertFileContent \ diff --git a/third_party/home-manager/tests/modules/programs/irsii/default.nix b/third_party/home-manager/tests/modules/programs/irsii/default.nix deleted file mode 100644 index ff8fe12a7c..0000000000 --- a/third_party/home-manager/tests/modules/programs/irsii/default.nix +++ /dev/null @@ -1 +0,0 @@ -{ irsii-example-settings = ./example-settings.nix; } diff --git a/third_party/home-manager/tests/modules/programs/irssi/default.nix b/third_party/home-manager/tests/modules/programs/irssi/default.nix new file mode 100644 index 0000000000..fc5e7ed904 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/irssi/default.nix @@ -0,0 +1 @@ +{ irssi-example-settings = ./example-settings.nix; } diff --git a/third_party/home-manager/tests/modules/programs/irsii/example-settings-expected.config b/third_party/home-manager/tests/modules/programs/irssi/example-settings-expected.config similarity index 100% rename from third_party/home-manager/tests/modules/programs/irsii/example-settings-expected.config rename to third_party/home-manager/tests/modules/programs/irssi/example-settings-expected.config diff --git a/third_party/home-manager/tests/modules/programs/irsii/example-settings.nix b/third_party/home-manager/tests/modules/programs/irssi/example-settings.nix similarity index 85% rename from third_party/home-manager/tests/modules/programs/irsii/example-settings.nix rename to third_party/home-manager/tests/modules/programs/irssi/example-settings.nix index d7b9ff1e67..93cf9f2d7c 100644 --- a/third_party/home-manager/tests/modules/programs/irsii/example-settings.nix +++ b/third_party/home-manager/tests/modules/programs/irssi/example-settings.nix @@ -19,13 +19,12 @@ with lib; }; }; + test.stubs.irssi = { }; + nmt.script = '' assertFileContent \ home-files/.irssi/config \ ${./example-settings-expected.config} ''; - - nixpkgs.overlays = - [ (self: super: { irsii = pkgs.writeScriptBin "dummy-irsii" ""; }) ]; }; } diff --git a/third_party/home-manager/tests/modules/programs/kitty/example-macos-launch-services-cmdline b/third_party/home-manager/tests/modules/programs/kitty/example-macos-launch-services-cmdline new file mode 100644 index 0000000000..e104109ee5 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/kitty/example-macos-launch-services-cmdline @@ -0,0 +1 @@ +--single-instance --directory=/tmp/my-dir --listen-on=unix:/tmp/my-socket \ No newline at end of file diff --git a/third_party/home-manager/tests/modules/programs/kitty/example-settings-expected.conf b/third_party/home-manager/tests/modules/programs/kitty/example-settings-expected.conf index 23cd3a85a8..0afd7a9a06 100644 --- a/third_party/home-manager/tests/modules/programs/kitty/example-settings-expected.conf +++ b/third_party/home-manager/tests/modules/programs/kitty/example-settings-expected.conf @@ -14,4 +14,7 @@ map ctrl+c copy_or_interrupt map ctrl+f>2 set_font_size 20 +env LS_COLORS=1 + + diff --git a/third_party/home-manager/tests/modules/programs/kitty/example-settings.nix b/third_party/home-manager/tests/modules/programs/kitty/example-settings.nix index 8b5c0c330b..8d609a5abb 100644 --- a/third_party/home-manager/tests/modules/programs/kitty/example-settings.nix +++ b/third_party/home-manager/tests/modules/programs/kitty/example-settings.nix @@ -6,6 +6,13 @@ with lib; config = { programs.kitty = { enable = true; + + darwinLaunchOptions = lib.mkIf pkgs.stdenv.hostPlatform.isDarwin [ + "--single-instance" + "--directory=/tmp/my-dir" + "--listen-on=unix:/tmp/my-socket" + ]; + settings = { scrollback_lines = 10000; enable_audio_bell = false; @@ -19,16 +26,21 @@ with lib; "ctrl+c" = "copy_or_interrupt"; "ctrl+f>2" = "set_font_size 20"; }; + + environment = { LS_COLORS = "1"; }; }; - nixpkgs.overlays = - [ (self: super: { kitty = pkgs.writeScriptBin "dummy-kitty" ""; }) ]; + test.stubs.kitty = { }; nmt.script = '' assertFileExists home-files/.config/kitty/kitty.conf assertFileContent \ home-files/.config/kitty/kitty.conf \ ${./example-settings-expected.conf} + '' + lib.optionalString pkgs.stdenv.hostPlatform.isDarwin '' + assertFileContent \ + home-files/.config/kitty/macos-launch-services-cmdline \ + ${./example-macos-launch-services-cmdline} ''; }; } diff --git a/third_party/home-manager/tests/modules/programs/lf/all-options.nix b/third_party/home-manager/tests/modules/programs/lf/all-options.nix index a25467a26b..35d7901d6c 100644 --- a/third_party/home-manager/tests/modules/programs/lf/all-options.nix +++ b/third_party/home-manager/tests/modules/programs/lf/all-options.nix @@ -75,8 +75,7 @@ in { }; }; - nixpkgs.overlays = - [ (self: super: { lf = pkgs.writeScriptBin "dummy-lf" ""; }) ]; + test.stubs.lf = { }; nmt.script = '' assertFileExists home-files/.config/lf/lfrc diff --git a/third_party/home-manager/tests/modules/programs/lf/minimal-options.nix b/third_party/home-manager/tests/modules/programs/lf/minimal-options.nix index b3c26ba9b5..078c776e78 100644 --- a/third_party/home-manager/tests/modules/programs/lf/minimal-options.nix +++ b/third_party/home-manager/tests/modules/programs/lf/minimal-options.nix @@ -7,8 +7,7 @@ in { config = { programs.lf = { enable = true; }; - nixpkgs.overlays = - [ (self: super: { lf = pkgs.writeScriptBin "dummy-lf" ""; }) ]; + test.stubs.lf = { }; nmt.script = '' assertFileExists home-files/.config/lf/lfrc diff --git a/third_party/home-manager/tests/modules/programs/lf/no-pv-keybind.nix b/third_party/home-manager/tests/modules/programs/lf/no-pv-keybind.nix index 524a41a364..c948cf0b5f 100644 --- a/third_party/home-manager/tests/modules/programs/lf/no-pv-keybind.nix +++ b/third_party/home-manager/tests/modules/programs/lf/no-pv-keybind.nix @@ -32,8 +32,7 @@ in { previewer = { source = pvScript; }; }; - nixpkgs.overlays = - [ (self: super: { lf = pkgs.writeScriptBin "dummy-lf" ""; }) ]; + test.stubs.lf = { }; nmt.script = '' assertFileExists home-files/.config/lf/lfrc diff --git a/third_party/home-manager/tests/modules/programs/lieer/lieer-expected.json b/third_party/home-manager/tests/modules/programs/lieer/lieer-expected.json index e7318f65dc..332e2d598a 100644 --- a/third_party/home-manager/tests/modules/programs/lieer/lieer-expected.json +++ b/third_party/home-manager/tests/modules/programs/lieer/lieer-expected.json @@ -1 +1,18 @@ -{"account":"hm@example.com","drop_non_existing_label":false,"ignore_remote_labels":["CATEGORY_FORUMS","CATEGORY_PROMOTIONS","CATEGORY_UPDATES","CATEGORY_SOCIAL","CATEGORY_PERSONAL"],"ignore_tags":[],"replace_slash_with_dot":false,"timeout":0} +{ + "account": "hm@example.com", + "drop_non_existing_label": false, + "file_extension": "", + "ignore_empty_history": false, + "ignore_remote_labels": [ + "CATEGORY_FORUMS", + "CATEGORY_PROMOTIONS", + "CATEGORY_UPDATES", + "CATEGORY_SOCIAL", + "CATEGORY_PERSONAL" + ], + "ignore_tags": [], + "local_trash_tag": "trash", + "remove_local_messages": true, + "replace_slash_with_dot": false, + "timeout": 600 +} diff --git a/third_party/home-manager/tests/modules/programs/lieer/lieer.nix b/third_party/home-manager/tests/modules/programs/lieer/lieer.nix index c5771b67d0..5e78474647 100644 --- a/third_party/home-manager/tests/modules/programs/lieer/lieer.nix +++ b/third_party/home-manager/tests/modules/programs/lieer/lieer.nix @@ -7,6 +7,7 @@ with lib; config = { programs.lieer.enable = true; + programs.lieer.package = config.lib.test.mkStubPackage { }; accounts.email.accounts."hm@example.com" = { flavor = "gmail.com"; @@ -14,14 +15,11 @@ with lib; notmuch.enable = true; }; - nixpkgs.overlays = [ - (self: super: { gmailieer = pkgs.writeScriptBin "dummy-gmailieer" ""; }) - ]; - nmt.script = '' assertFileExists home-files/Mail/hm@example.com/.gmailieer.json - assertFileContent home-files/Mail/hm@example.com/.gmailieer.json \ - ${./lieer-expected.json} + assertFileContent home-files/Mail/hm@example.com/.gmailieer.json ${ + ./lieer-expected.json + } ''; }; } diff --git a/third_party/home-manager/tests/modules/programs/mangohud/basic-configuration.nix b/third_party/home-manager/tests/modules/programs/mangohud/basic-configuration.nix index 7ff4a89018..6af57d281a 100644 --- a/third_party/home-manager/tests/modules/programs/mangohud/basic-configuration.nix +++ b/third_party/home-manager/tests/modules/programs/mangohud/basic-configuration.nix @@ -4,7 +4,7 @@ config = { programs.mangohud = { enable = true; - package = pkgs.writeScriptBin "dummy-mangohud" ""; + package = config.lib.test.mkStubPackage { }; settings = { output_folder = /home/user/Documents/mangohud; fps_limit = [ 30 60 ]; diff --git a/third_party/home-manager/tests/modules/programs/mbsync/mbsync-master-slave-change.nix b/third_party/home-manager/tests/modules/programs/mbsync/mbsync-master-slave-change.nix index 96f02d9068..2e87732087 100644 --- a/third_party/home-manager/tests/modules/programs/mbsync/mbsync-master-slave-change.nix +++ b/third_party/home-manager/tests/modules/programs/mbsync/mbsync-master-slave-change.nix @@ -85,6 +85,8 @@ with lib; "mbsync channels no longer use slavePattern. Use nearPattern in its place." ]; + test.stubs.isync = { }; + nmt.script = '' assertFileExists home-files/.mbsyncrc assertFileContent home-files/.mbsyncrc ${./mbsync-expected.conf} diff --git a/third_party/home-manager/tests/modules/programs/mbsync/mbsync.nix b/third_party/home-manager/tests/modules/programs/mbsync/mbsync.nix index d80421d6da..7042760a5b 100644 --- a/third_party/home-manager/tests/modules/programs/mbsync/mbsync.nix +++ b/third_party/home-manager/tests/modules/programs/mbsync/mbsync.nix @@ -75,6 +75,8 @@ with lib; }; }; + test.stubs.isync = { }; + nmt.script = '' assertFileExists home-files/.mbsyncrc assertFileContent home-files/.mbsyncrc ${./mbsync-expected.conf} diff --git a/third_party/home-manager/tests/modules/programs/mpv/mpv-example-settings.nix b/third_party/home-manager/tests/modules/programs/mpv/mpv-example-settings.nix index 5701d9eaba..9bb53e57d4 100644 --- a/third_party/home-manager/tests/modules/programs/mpv/mpv-example-settings.nix +++ b/third_party/home-manager/tests/modules/programs/mpv/mpv-example-settings.nix @@ -29,9 +29,7 @@ defaultProfiles = [ "gpu-hq" ]; }; - nixpkgs.overlays = [ - (self: super: { mpvDummy = pkgs.runCommandLocal "mpv" { } "mkdir $out"; }) - ]; + test.stubs.mpvDummy = { }; nmt.script = '' assertFileContent \ diff --git a/third_party/home-manager/tests/modules/programs/mpv/mpv-invalid-settings.nix b/third_party/home-manager/tests/modules/programs/mpv/mpv-invalid-settings.nix index f7fd390a98..1c4a80c112 100644 --- a/third_party/home-manager/tests/modules/programs/mpv/mpv-invalid-settings.nix +++ b/third_party/home-manager/tests/modules/programs/mpv/mpv-invalid-settings.nix @@ -22,7 +22,7 @@ touch $out/bin/{,u}mpv $out/Applications/mpv.app/Contents/MacOS/mpv chmod 755 $out/bin/{,u}mpv $out/Applications/mpv.app/Contents/MacOS/mpv ''; - mpvDummy = pkgs.runCommandLocal "mpv" { } "mkdir $out"; + mpvDummy = config.lib.test.mkStubPackage { }; mpvScript = pkgs.runCommandLocal "mpvScript" { scriptName = "something"; } "mkdir $out"; diff --git a/third_party/home-manager/tests/modules/programs/ncmpcpp-linux/ncmpcpp-use-mpd-config.nix b/third_party/home-manager/tests/modules/programs/ncmpcpp-linux/ncmpcpp-use-mpd-config.nix index 5262f03147..f977bddece 100644 --- a/third_party/home-manager/tests/modules/programs/ncmpcpp-linux/ncmpcpp-use-mpd-config.nix +++ b/third_party/home-manager/tests/modules/programs/ncmpcpp-linux/ncmpcpp-use-mpd-config.nix @@ -7,12 +7,10 @@ services.mpd.enable = true; services.mpd.musicDirectory = "/home/user/music"; - nixpkgs.overlays = [ - (self: super: { - ncmpcpp = pkgs.writeScriptBin "dummy-ncmpcpp" ""; - mpd = pkgs.writeScriptBin "dummy-mpd" ""; - }) - ]; + test.stubs = { + ncmpcpp = { }; + mpd = { }; + }; nmt.script = '' assertFileContent \ diff --git a/third_party/home-manager/tests/modules/programs/ncmpcpp/ncmpcpp-empty-settings.nix b/third_party/home-manager/tests/modules/programs/ncmpcpp/ncmpcpp-empty-settings.nix index e5134002d3..5543665097 100644 --- a/third_party/home-manager/tests/modules/programs/ncmpcpp/ncmpcpp-empty-settings.nix +++ b/third_party/home-manager/tests/modules/programs/ncmpcpp/ncmpcpp-empty-settings.nix @@ -4,8 +4,7 @@ config = { programs.ncmpcpp.enable = true; - nixpkgs.overlays = - [ (self: super: { ncmpcpp = pkgs.writeScriptBin "dummy-ncmpcpp" ""; }) ]; + test.stubs.ncmpcpp = { }; nmt.script = '' assertPathNotExists home-files/.config/ncmpcpp/config diff --git a/third_party/home-manager/tests/modules/programs/ncmpcpp/ncmpcpp-example-settings.nix b/third_party/home-manager/tests/modules/programs/ncmpcpp/ncmpcpp-example-settings.nix index 02a1f09c90..a85ea552ca 100644 --- a/third_party/home-manager/tests/modules/programs/ncmpcpp/ncmpcpp-example-settings.nix +++ b/third_party/home-manager/tests/modules/programs/ncmpcpp/ncmpcpp-example-settings.nix @@ -44,8 +44,7 @@ ]; }; - nixpkgs.overlays = - [ (self: super: { ncmpcpp = pkgs.writeScriptBin "dummy-ncmpcpp" ""; }) ]; + test.stubs.ncmpcpp = { }; nmt.script = '' assertFileContent \ diff --git a/third_party/home-manager/tests/modules/programs/ne/defprefs.nix b/third_party/home-manager/tests/modules/programs/ne/defprefs.nix index dce98b2864..64d78d276d 100644 --- a/third_party/home-manager/tests/modules/programs/ne/defprefs.nix +++ b/third_party/home-manager/tests/modules/programs/ne/defprefs.nix @@ -19,8 +19,7 @@ in { automaticPreferences.".default" = autopref; }; - nixpkgs.overlays = - [ (self: super: { ne = pkgs.writeScriptBin "dummy-ne" ""; }) ]; + test.stubs.ne = { }; nmt = { description = diff --git a/third_party/home-manager/tests/modules/programs/ne/passthroughs.nix b/third_party/home-manager/tests/modules/programs/ne/passthroughs.nix index 4c129e9448..f753826f3d 100644 --- a/third_party/home-manager/tests/modules/programs/ne/passthroughs.nix +++ b/third_party/home-manager/tests/modules/programs/ne/passthroughs.nix @@ -53,8 +53,7 @@ in { inherit automaticPreferences; }; - nixpkgs.overlays = - [ (self: super: { ne = pkgs.writeScriptBin "dummy-ne" ""; }) ]; + test.stubs.ne = { }; nmt = { description = "Check that configuration files are correctly written"; diff --git a/third_party/home-manager/tests/modules/programs/neomutt/default.nix b/third_party/home-manager/tests/modules/programs/neomutt/default.nix index d24813545c..62319dd365 100644 --- a/third_party/home-manager/tests/modules/programs/neomutt/default.nix +++ b/third_party/home-manager/tests/modules/programs/neomutt/default.nix @@ -8,4 +8,5 @@ ./neomutt-with-binds-invalid-settings.nix; neomutt-with-gpg = ./neomutt-with-gpg.nix; neomutt-no-folder-change = ./neomutt-no-folder-change.nix; + neomutt-with-named-mailboxes = ./neomutt-with-named-mailboxes.nix; } diff --git a/third_party/home-manager/tests/modules/programs/neomutt/neomutt-expected.conf b/third_party/home-manager/tests/modules/programs/neomutt/neomutt-expected.conf index 6d51da816f..7c0e5d28a8 100644 --- a/third_party/home-manager/tests/modules/programs/neomutt/neomutt-expected.conf +++ b/third_party/home-manager/tests/modules/programs/neomutt/neomutt-expected.conf @@ -19,6 +19,7 @@ set delete = yes # Register accounts # register account hm@example.com mailboxes "/home/hm-user/Mail/hm@example.com/Inbox" + folder-hook /home/hm-user/Mail/hm@example.com/ " \ source /home/hm-user/.config/neomutt/hm@example.com " diff --git a/third_party/home-manager/tests/modules/programs/neomutt/neomutt-no-folder-change.nix b/third_party/home-manager/tests/modules/programs/neomutt/neomutt-no-folder-change.nix index db7246604f..0e874c2286 100644 --- a/third_party/home-manager/tests/modules/programs/neomutt/neomutt-no-folder-change.nix +++ b/third_party/home-manager/tests/modules/programs/neomutt/neomutt-no-folder-change.nix @@ -17,8 +17,7 @@ with lib; programs.neomutt.enable = true; programs.neomutt.changeFolderWhenSourcingAccount = false; - nixpkgs.overlays = - [ (self: super: { neomutt = pkgs.writeScriptBin "dummy-neomutt" ""; }) ]; + test.stubs.neomutt = { }; nmt.script = '' assertFileExists home-files/.config/neomutt/hm@example.com diff --git a/third_party/home-manager/tests/modules/programs/neomutt/neomutt-not-primary-expected.conf b/third_party/home-manager/tests/modules/programs/neomutt/neomutt-not-primary-expected.conf index ed64124d99..4a583a02d6 100644 --- a/third_party/home-manager/tests/modules/programs/neomutt/neomutt-not-primary-expected.conf +++ b/third_party/home-manager/tests/modules/programs/neomutt/neomutt-not-primary-expected.conf @@ -19,6 +19,7 @@ set delete = yes # Register accounts # register account hm-account mailboxes "/home/hm-user/Mail/hm-account/Inbox" + folder-hook /home/hm-user/Mail/hm-account/ " \ source /home/hm-user/.config/neomutt/hm-account " diff --git a/third_party/home-manager/tests/modules/programs/neomutt/neomutt-not-primary.nix b/third_party/home-manager/tests/modules/programs/neomutt/neomutt-not-primary.nix index 10e9791de5..ccf5444a99 100644 --- a/third_party/home-manager/tests/modules/programs/neomutt/neomutt-not-primary.nix +++ b/third_party/home-manager/tests/modules/programs/neomutt/neomutt-not-primary.nix @@ -13,8 +13,7 @@ with lib; programs.neomutt.enable = true; - nixpkgs.overlays = - [ (self: super: { neomutt = pkgs.writeScriptBin "dummy-neomutt" ""; }) ]; + test.stubs.neomutt = { }; nmt.script = '' assertFileExists home-files/.config/neomutt/neomuttrc diff --git a/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-binds-expected.conf b/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-binds-expected.conf index 7f89c3178a..8b4bb7bce2 100644 --- a/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-binds-expected.conf +++ b/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-binds-expected.conf @@ -21,6 +21,7 @@ macro index,pager c "?^K=" # Register accounts # register account hm@example.com mailboxes "/home/hm-user/Mail/hm@example.com/Inbox" + folder-hook /home/hm-user/Mail/hm@example.com/ " \ source /home/hm-user/.config/neomutt/hm@example.com " diff --git a/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-binds-with-warning.nix b/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-binds-with-warning.nix index 529d284758..54012e9dd2 100644 --- a/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-binds-with-warning.nix +++ b/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-binds-with-warning.nix @@ -50,8 +50,7 @@ with lib; ]; }; - nixpkgs.overlays = - [ (self: super: { neomutt = pkgs.writeScriptBin "dummy-neomutt" ""; }) ]; + test.stubs.neomutt = { }; test.asserts.warnings.expected = [ "Specifying 'programs.neomutt.(binds|macros).map' as a string is deprecated, use a list of strings instead. See https://github.com/nix-community/home-manager/pull/1885." diff --git a/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-binds.nix b/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-binds.nix index bd40cd8934..64ebf80f87 100644 --- a/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-binds.nix +++ b/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-binds.nix @@ -50,8 +50,7 @@ with lib; ]; }; - nixpkgs.overlays = - [ (self: super: { neomutt = pkgs.writeScriptBin "dummy-neomutt" ""; }) ]; + test.stubs.neomutt = { }; nmt.script = '' assertFileExists home-files/.config/neomutt/neomuttrc diff --git a/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-gpg.nix b/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-gpg.nix index 164e4b58cd..2eed535830 100644 --- a/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-gpg.nix +++ b/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-gpg.nix @@ -16,8 +16,7 @@ with lib; { programs.neomutt.enable = true; - nixpkgs.overlays = - [ (self: super: { neomutt = pkgs.writeScriptBin "dummy-neomutt" ""; }) ]; + test.stubs.neomutt = { }; nmt.script = '' assertFileExists home-files/.config/neomutt/neomuttrc diff --git a/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-msmtp.nix b/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-msmtp.nix index 1d5db5f908..48b2197d04 100644 --- a/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-msmtp.nix +++ b/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-msmtp.nix @@ -21,8 +21,7 @@ with lib; programs.neomutt.enable = true; - nixpkgs.overlays = - [ (self: super: { neomutt = pkgs.writeScriptBin "dummy-neomutt" ""; }) ]; + test.stubs.neomutt = { }; nmt.script = '' assertFileExists home-files/.config/neomutt/neomuttrc diff --git a/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-named-mailboxes-expected.conf b/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-named-mailboxes-expected.conf new file mode 100644 index 0000000000..e58660fc76 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-named-mailboxes-expected.conf @@ -0,0 +1,35 @@ +# Generated by Home Manager. +set header_cache = "/home/hm-user/.cache/neomutt/headers/" +set message_cachedir = "/home/hm-user/.cache/neomutt/messages/" +set editor = "$EDITOR" +set implicit_autoview = yes + +alternative_order text/enriched text/plain text + +set delete = yes + +# Binds + + +# Macros + + + + +# Register accounts +# register account hm@example.com +named-mailboxes "someCustomName" "/home/hm-user/Mail/hm@example.com/Inbox" +mailboxes "/home/hm-user/Mail/hm@example.com/Sent" +named-mailboxes "Spam" "/home/hm-user/Mail/hm@example.com/Junk Email" +mailboxes "/home/hm-user/Mail/hm@example.com/Trash" +folder-hook /home/hm-user/Mail/hm@example.com/ " \ + source /home/hm-user/.config/neomutt/hm@example.com " + + +# Source primary account +source /home/hm-user/.config/neomutt/hm@example.com + +# Extra configuration + + + diff --git a/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-named-mailboxes.nix b/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-named-mailboxes.nix new file mode 100644 index 0000000000..fd4fedf013 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/neomutt/neomutt-with-named-mailboxes.nix @@ -0,0 +1,49 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + imports = [ ../../accounts/email-test-accounts.nix ]; + + config = { + accounts.email.accounts = { + "hm@example.com" = { + notmuch.enable = true; + neomutt = { + enable = true; + extraConfig = '' + color status cyan default + ''; + mailboxName = "someCustomName"; + extraMailboxes = [ + "Sent" + { + mailbox = "Junk Email"; + name = "Spam"; + } + { mailbox = "Trash"; } + ]; + }; + imap.port = 993; + }; + }; + + programs.neomutt = { + enable = true; + vimKeys = false; + }; + + test.stubs.neomutt = { }; + + nmt.script = '' + assertFileExists home-files/.config/neomutt/neomuttrc + assertFileExists home-files/.config/neomutt/hm@example.com + assertFileContent home-files/.config/neomutt/neomuttrc ${ + ./neomutt-with-named-mailboxes-expected.conf + } + assertFileContent home-files/.config/neomutt/hm@example.com ${ + ./hm-example.com-expected + } + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/programs/neomutt/neomutt.nix b/third_party/home-manager/tests/modules/programs/neomutt/neomutt.nix index d4419d93ec..08c8f5bf3f 100644 --- a/third_party/home-manager/tests/modules/programs/neomutt/neomutt.nix +++ b/third_party/home-manager/tests/modules/programs/neomutt/neomutt.nix @@ -24,8 +24,7 @@ with lib; vimKeys = false; }; - nixpkgs.overlays = - [ (self: super: { neomutt = pkgs.writeScriptBin "dummy-neomutt" ""; }) ]; + test.stubs.neomutt = { }; nmt.script = '' assertFileExists home-files/.config/neomutt/neomuttrc diff --git a/third_party/home-manager/tests/modules/programs/neovim/coc-config.expected b/third_party/home-manager/tests/modules/programs/neovim/coc-config.expected new file mode 100644 index 0000000000..c8c4105eb5 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/neovim/coc-config.expected @@ -0,0 +1,3 @@ +{ + "foo": "bar" +} diff --git a/third_party/home-manager/tests/modules/programs/neovim/coc-config.nix b/third_party/home-manager/tests/modules/programs/neovim/coc-config.nix new file mode 100644 index 0000000000..c16514134d --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/neovim/coc-config.nix @@ -0,0 +1,27 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.neovim = { + enable = true; + coc = { + enable = true; + settings = { + # my variable + foo = "bar"; + }; + }; + }; + + nmt.script = '' + cocSettings="$TESTED/home-files/.config/nvim/coc-settings.json" + cocSettingsNormalized="$(normalizeStorePaths "$cocSettings")" + + assertFileExists "$cocSettings" + assertFileContent "$cocSettingsNormalized" "${./coc-config.expected}" + ''; + }; +} + diff --git a/third_party/home-manager/tests/modules/programs/neovim/default.nix b/third_party/home-manager/tests/modules/programs/neovim/default.nix index 13efac9b68..8a6c316ea5 100644 --- a/third_party/home-manager/tests/modules/programs/neovim/default.nix +++ b/third_party/home-manager/tests/modules/programs/neovim/default.nix @@ -1,5 +1,6 @@ { neovim-plugin-config = ./plugin-config.nix; + neovim-coc-config = ./coc-config.nix; # waiting for a nixpkgs patch # neovim-no-init = ./no-init.nix; } diff --git a/third_party/home-manager/tests/modules/programs/newsboat/newsboat-basics-2003.nix b/third_party/home-manager/tests/modules/programs/newsboat/newsboat-basics-2003.nix index 587a31bb25..26d5f4b328 100644 --- a/third_party/home-manager/tests/modules/programs/newsboat/newsboat-basics-2003.nix +++ b/third_party/home-manager/tests/modules/programs/newsboat/newsboat-basics-2003.nix @@ -22,9 +22,7 @@ with lib; queries = { "foo" = ''rssurl =~ "example.com"''; }; }; - nixpkgs.overlays = [ - (self: super: { newsboat = pkgs.writeScriptBin "dummy-newsboat" ""; }) - ]; + test.stubs.newsboat = { }; nmt.script = '' assertFileContent \ diff --git a/third_party/home-manager/tests/modules/programs/newsboat/newsboat-basics-2105.nix b/third_party/home-manager/tests/modules/programs/newsboat/newsboat-basics-2105.nix index e7a17c5d7f..ec0f337281 100644 --- a/third_party/home-manager/tests/modules/programs/newsboat/newsboat-basics-2105.nix +++ b/third_party/home-manager/tests/modules/programs/newsboat/newsboat-basics-2105.nix @@ -22,9 +22,7 @@ with lib; queries = { "foo" = ''rssurl =~ "example.com"''; }; }; - nixpkgs.overlays = [ - (self: super: { newsboat = pkgs.writeScriptBin "dummy-newsboat" ""; }) - ]; + test.stubs.newsboat = { }; # The format didn't change since 20.03, just the location. nmt.script = '' diff --git a/third_party/home-manager/tests/modules/programs/newsboat/newsboat-basics.nix b/third_party/home-manager/tests/modules/programs/newsboat/newsboat-basics.nix index e6eb415177..fe7f85070b 100644 --- a/third_party/home-manager/tests/modules/programs/newsboat/newsboat-basics.nix +++ b/third_party/home-manager/tests/modules/programs/newsboat/newsboat-basics.nix @@ -20,9 +20,7 @@ with lib; queries = { "foo" = ''rssurl =~ "example.com"''; }; }; - nixpkgs.overlays = [ - (self: super: { newsboat = pkgs.writeScriptBin "dummy-newsboat" ""; }) - ]; + test.stubs.newsboat = { }; nmt.script = '' assertFileContent \ diff --git a/third_party/home-manager/tests/modules/programs/nix-index/assert-on-command-not-found.nix b/third_party/home-manager/tests/modules/programs/nix-index/assert-on-command-not-found.nix index 757ac65b5d..0fa6ee7998 100644 --- a/third_party/home-manager/tests/modules/programs/nix-index/assert-on-command-not-found.nix +++ b/third_party/home-manager/tests/modules/programs/nix-index/assert-on-command-not-found.nix @@ -1,4 +1,6 @@ -{ pkgs, ... }: { +{ lib, pkgs, ... }: + +{ config = { programs.bash.enable = true; programs.fish.enable = true; @@ -6,8 +8,14 @@ programs.command-not-found.enable = true; - nixpkgs.overlays = - [ (self: super: { zsh = pkgs.writeScriptBin "dummy-zsh" ""; }) ]; + # Needed to avoid error with dummy fish package. + xdg.dataFile."fish/home-manager_generated_completions".source = + lib.mkForce (builtins.toFile "empty" ""); + + test.stubs = { + zsh = { }; + fish = { }; + }; programs.nix-index.enable = true; diff --git a/third_party/home-manager/tests/modules/programs/nix-index/integrations.nix b/third_party/home-manager/tests/modules/programs/nix-index/integrations.nix index 6da5fd0490..1ae46df55e 100644 --- a/third_party/home-manager/tests/modules/programs/nix-index/integrations.nix +++ b/third_party/home-manager/tests/modules/programs/nix-index/integrations.nix @@ -1,4 +1,5 @@ -{ pkgs, ... }: +{ lib, pkgs, ... }: + let fishRegex = '' function __fish_command_not_found_handler --on-event fish_command_not_found @@ -11,8 +12,14 @@ in { programs.fish.enable = true; programs.zsh.enable = true; - nixpkgs.overlays = - [ (self: super: { zsh = pkgs.writeScriptBin "dummy-zsh" ""; }) ]; + # Needed to avoid error with dummy fish package. + xdg.dataFile."fish/home-manager_generated_completions".source = + lib.mkForce (builtins.toFile "empty" ""); + + test.stubs = { + zsh = { }; + fish = { }; + }; programs.nix-index.enable = true; diff --git a/third_party/home-manager/tests/modules/programs/nnn/default.nix b/third_party/home-manager/tests/modules/programs/nnn/default.nix new file mode 100644 index 0000000000..6ba66beb2e --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/nnn/default.nix @@ -0,0 +1 @@ +{ nnn = ./nnn.nix; } diff --git a/third_party/home-manager/tests/modules/programs/nnn/nnn.nix b/third_party/home-manager/tests/modules/programs/nnn/nnn.nix new file mode 100644 index 0000000000..aeb7d3fc51 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/nnn/nnn.nix @@ -0,0 +1,57 @@ +{ config, lib, 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"; + }; + }; + }; + + test.stubs = { + nnnDummy.buildScript = '' + 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 + + assertFileRegex \ + home-path/bin/nnn \ + "^export NNN_BMS='D:~/Downloads;d:~/Documents;p:~/Pictures;v:~/Videos'\''${NNN_BMS:+':'}\$NNN_BMS$" + + assertFileRegex \ + home-path/bin/nnn \ + "^export NNN_PLUG='c:fzcd;f:finder;v:imgview'\''${NNN_PLUG:+':'}\$NNN_PLUG$" + + assertFileRegex \ + home-path/bin/nnn \ + "/nix/store/.*-"{foo,bar}"/bin" + ''; + }; + }; +} diff --git a/third_party/home-manager/tests/modules/programs/nnn/plugins/.keep b/third_party/home-manager/tests/modules/programs/nnn/plugins/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/third_party/home-manager/tests/modules/programs/nushell/settings.nix b/third_party/home-manager/tests/modules/programs/nushell/settings.nix index 09c192b3ba..7eef0909ca 100644 --- a/third_party/home-manager/tests/modules/programs/nushell/settings.nix +++ b/third_party/home-manager/tests/modules/programs/nushell/settings.nix @@ -22,8 +22,7 @@ with lib; ]; }; - nixpkgs.overlays = - [ (self: super: { nushell = pkgs.writeScriptBin "dummy-nushell" ""; }) ]; + test.stubs.nushell = { }; nmt.script = '' assertFileContent \ diff --git a/third_party/home-manager/tests/modules/programs/powerline-go/bash.nix b/third_party/home-manager/tests/modules/programs/powerline-go/bash.nix index 945bde7312..34017d8848 100644 --- a/third_party/home-manager/tests/modules/programs/powerline-go/bash.nix +++ b/third_party/home-manager/tests/modules/programs/powerline-go/bash.nix @@ -18,8 +18,7 @@ with lib; }; }; - nixpkgs.overlays = - [ (self: super: { powerline-go = pkgs.writeScriptBin "dummy-pkg" ""; }) ]; + test.stubs.powerline-go = { }; nmt.script = '' assertFileExists home-files/.bashrc diff --git a/third_party/home-manager/tests/modules/programs/powerline-go/default.nix b/third_party/home-manager/tests/modules/programs/powerline-go/default.nix index e89d7c6cde..49ed71d26a 100644 --- a/third_party/home-manager/tests/modules/programs/powerline-go/default.nix +++ b/third_party/home-manager/tests/modules/programs/powerline-go/default.nix @@ -1,4 +1,5 @@ { powerline-go-bash = ./bash.nix; powerline-go-zsh = ./zsh.nix; + powerline-go-fish = ./fish.nix; } diff --git a/third_party/home-manager/tests/modules/programs/powerline-go/fish.nix b/third_party/home-manager/tests/modules/programs/powerline-go/fish.nix new file mode 100644 index 0000000000..b7891bbfba --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/powerline-go/fish.nix @@ -0,0 +1,37 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs = { + fish.enable = true; + + powerline-go = { + enable = true; + newline = true; + modules = [ "nix-shell" ]; + pathAliases = { "\\~/project/foo" = "prj-foo"; }; + settings = { + ignore-repos = [ "/home/me/project1" "/home/me/project2" ]; + }; + }; + }; + + # Needed to avoid error with dummy fish package. + xdg.dataFile."fish/home-manager_generated_completions".source = + mkForce (builtins.toFile "empty" ""); + + test.stubs = { + powerline-go = { }; + fish = { }; + }; + + nmt.script = '' + assertFileExists home-files/.config/fish/config.fish + assertFileContains \ + home-files/.config/fish/config.fish \ + '/bin/powerline-go -error $status -jobs (count (jobs -p)) -modules nix-shell -newline -path-aliases \~/project/foo=prj-foo -ignore-repos /home/me/project1,/home/me/project2' + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/programs/powerline-go/zsh.nix b/third_party/home-manager/tests/modules/programs/powerline-go/zsh.nix index 0ed88215d2..161499c9a1 100644 --- a/third_party/home-manager/tests/modules/programs/powerline-go/zsh.nix +++ b/third_party/home-manager/tests/modules/programs/powerline-go/zsh.nix @@ -18,12 +18,10 @@ with lib; }; }; - nixpkgs.overlays = [ - (self: super: { - powerline-go = pkgs.writeScriptBin "dummy-pkg" ""; - zsh = pkgs.writeScriptBin "dummy-pkg" ""; - }) - ]; + test.stubs = { + powerline-go = { }; + zsh = { }; + }; nmt.script = '' assertFileExists home-files/.zshrc diff --git a/third_party/home-manager/tests/modules/programs/qutebrowser/keybindings.nix b/third_party/home-manager/tests/modules/programs/qutebrowser/keybindings.nix index 1236c058dc..a719d9f763 100644 --- a/third_party/home-manager/tests/modules/programs/qutebrowser/keybindings.nix +++ b/third_party/home-manager/tests/modules/programs/qutebrowser/keybindings.nix @@ -18,11 +18,7 @@ with lib; }; }; - nixpkgs.overlays = [ - (self: super: { - qutebrowser = pkgs.writeScriptBin "dummy-qutebrowser" ""; - }) - ]; + test.stubs.qutebrowser = { }; nmt.script = let qutebrowserConfig = if pkgs.stdenv.hostPlatform.isDarwin then diff --git a/third_party/home-manager/tests/modules/programs/qutebrowser/quickmarks.nix b/third_party/home-manager/tests/modules/programs/qutebrowser/quickmarks.nix index 30d1856c82..1491a1e67f 100644 --- a/third_party/home-manager/tests/modules/programs/qutebrowser/quickmarks.nix +++ b/third_party/home-manager/tests/modules/programs/qutebrowser/quickmarks.nix @@ -13,11 +13,7 @@ with lib; }; }; - nixpkgs.overlays = [ - (self: super: { - qutebrowser = pkgs.writeScriptBin "dummy-qutebrowser" ""; - }) - ]; + test.stubs.qutebrowser = { }; nmt.script = let quickmarksFile = if pkgs.stdenv.hostPlatform.isDarwin then diff --git a/third_party/home-manager/tests/modules/programs/qutebrowser/settings.nix b/third_party/home-manager/tests/modules/programs/qutebrowser/settings.nix index e9bedcaa3d..dca6ae6f53 100644 --- a/third_party/home-manager/tests/modules/programs/qutebrowser/settings.nix +++ b/third_party/home-manager/tests/modules/programs/qutebrowser/settings.nix @@ -24,11 +24,7 @@ with lib; ''; }; - nixpkgs.overlays = [ - (self: super: { - qutebrowser = pkgs.writeScriptBin "dummy-qutebrowser" ""; - }) - ]; + test.stubs.qutebrowser = { }; nmt.script = let qutebrowserConfig = if pkgs.stdenv.hostPlatform.isDarwin then diff --git a/third_party/home-manager/tests/modules/programs/rbw/empty-settings.nix b/third_party/home-manager/tests/modules/programs/rbw/empty-settings.nix index 3e4c821d84..aa25c876c0 100644 --- a/third_party/home-manager/tests/modules/programs/rbw/empty-settings.nix +++ b/third_party/home-manager/tests/modules/programs/rbw/empty-settings.nix @@ -1,4 +1,5 @@ { pkgs, ... }: + let inherit (pkgs.stdenv.hostPlatform) isDarwin; @@ -7,13 +8,11 @@ let else ".config/rbw/config.json"; in { - config = { - programs.rbw.enable = true; + imports = [ ./rbw-stubs.nix ]; - nixpkgs.overlays = [ (import ./overlay.nix) ]; + programs.rbw.enable = true; - nmt.script = '' - assertPathNotExists home-files/${path} - ''; - }; + nmt.script = '' + assertPathNotExists home-files/${path} + ''; } diff --git a/third_party/home-manager/tests/modules/programs/rbw/overlay.nix b/third_party/home-manager/tests/modules/programs/rbw/overlay.nix deleted file mode 100644 index f10b1955fb..0000000000 --- a/third_party/home-manager/tests/modules/programs/rbw/overlay.nix +++ /dev/null @@ -1,12 +0,0 @@ -self: super: { - rbw = self.writeScriptBin "dummy-rbw" ""; - pinentry = { - gnome3 = self.writeScriptBin "pinentry-gnome3" "" // { - outPath = "@pinentry-gnome3@"; - }; - gtk2 = self.writeScriptBin "pinentry-gtk2" "" // { - outPath = "@pinentry-gtk2@"; - }; - flavors = [ "gnome3" "gtk2" ]; - }; -} diff --git a/third_party/home-manager/tests/modules/programs/rbw/rbw-stubs.nix b/third_party/home-manager/tests/modules/programs/rbw/rbw-stubs.nix new file mode 100644 index 0000000000..c48d88be61 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/rbw/rbw-stubs.nix @@ -0,0 +1,16 @@ +{ config, ... }: + +{ + test.stubs.rbw = { }; + + nixpkgs.overlays = [ + (self: super: { + pinentry = { + gnome3 = + config.lib.test.mkStubPackage { outPath = "@pinentry-gnome3@"; }; + gtk2 = config.lib.test.mkStubPackage { outPath = "@pinentry-gtk2@"; }; + flavors = [ "gnome3" "gtk2" ]; + }; + }) + ]; +} diff --git a/third_party/home-manager/tests/modules/programs/rbw/settings.nix b/third_party/home-manager/tests/modules/programs/rbw/settings.nix index de08ec830f..8cf9572bb5 100644 --- a/third_party/home-manager/tests/modules/programs/rbw/settings.nix +++ b/third_party/home-manager/tests/modules/programs/rbw/settings.nix @@ -1,4 +1,5 @@ { pkgs, ... }: + let inherit (pkgs.stdenv.hostPlatform) isDarwin; @@ -17,23 +18,21 @@ let } ''; in { - config = { - programs.rbw = { - enable = true; - settings = { - email = "name@example.com"; - base_url = "bitwarden.example.com"; - identity_url = "identity.example.com"; - lock_timeout = 300; - pinentry = "gnome3"; - }; + imports = [ ./rbw-stubs.nix ]; + + programs.rbw = { + enable = true; + settings = { + email = "name@example.com"; + base_url = "bitwarden.example.com"; + identity_url = "identity.example.com"; + lock_timeout = 300; + pinentry = "gnome3"; }; - - nixpkgs.overlays = [ (import ./overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/${path} - assertFileContent home-files/${path} '${expected}' - ''; }; + + nmt.script = '' + assertFileExists home-files/${path} + assertFileContent home-files/${path} '${expected}' + ''; } diff --git a/third_party/home-manager/tests/modules/programs/rbw/simple-settings.nix b/third_party/home-manager/tests/modules/programs/rbw/simple-settings.nix index 4e05b69fe3..becf9fad19 100644 --- a/third_party/home-manager/tests/modules/programs/rbw/simple-settings.nix +++ b/third_party/home-manager/tests/modules/programs/rbw/simple-settings.nix @@ -1,4 +1,5 @@ { pkgs, ... }: + let inherit (pkgs.stdenv.hostPlatform) isDarwin; @@ -17,17 +18,15 @@ let } ''; in { - config = { - programs.rbw = { - enable = true; - settings = { email = "name@example.com"; }; - }; + imports = [ ./rbw-stubs.nix ]; - nixpkgs.overlays = [ (import ./overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/${path} - assertFileContent home-files/${path} '${expected}' - ''; + programs.rbw = { + enable = true; + settings = { email = "name@example.com"; }; }; + + nmt.script = '' + assertFileExists home-files/${path} + assertFileContent home-files/${path} '${expected}' + ''; } diff --git a/third_party/home-manager/tests/modules/programs/rofi-pass/rofi-pass-config.nix b/third_party/home-manager/tests/modules/programs/rofi-pass/rofi-pass-config.nix index e70ad9ab16..2028e840e8 100644 --- a/third_party/home-manager/tests/modules/programs/rofi-pass/rofi-pass-config.nix +++ b/third_party/home-manager/tests/modules/programs/rofi-pass/rofi-pass-config.nix @@ -16,9 +16,10 @@ with lib; }; }; - nixpkgs.overlays = [ - (self: super: { rofi-pass = pkgs.writeScriptBin "dummy-rofi-pass" ""; }) - ]; + test.stubs = { + rofi = { }; + rofi-pass = { }; + }; nmt.script = '' assertFileContent \ diff --git a/third_party/home-manager/tests/modules/programs/rofi-pass/rofi-pass-root.nix b/third_party/home-manager/tests/modules/programs/rofi-pass/rofi-pass-root.nix index 15c86ef629..300e89db90 100644 --- a/third_party/home-manager/tests/modules/programs/rofi-pass/rofi-pass-root.nix +++ b/third_party/home-manager/tests/modules/programs/rofi-pass/rofi-pass-root.nix @@ -13,9 +13,10 @@ with lib; }; }; - nixpkgs.overlays = [ - (self: super: { rofi-pass = pkgs.writeScriptBin "dummy-rofi-pass" ""; }) - ]; + test.stubs = { + rofi = { }; + rofi-pass = { }; + }; nmt.script = '' assertFileContent \ diff --git a/third_party/home-manager/tests/modules/programs/rofi/assert-on-both-theme-and-colors.nix b/third_party/home-manager/tests/modules/programs/rofi/assert-on-both-theme-and-colors.nix deleted file mode 100644 index 087ca472a6..0000000000 --- a/third_party/home-manager/tests/modules/programs/rofi/assert-on-both-theme-and-colors.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; - -{ - config = { - programs.rofi = { - enable = true; - theme = "foo"; - colors = { - window = { - background = "background"; - border = "border"; - separator = "separator"; - }; - rows = { }; - }; - }; - - nixpkgs.overlays = - [ (self: super: { rofi = pkgs.writeScriptBin "dummy-rofi" ""; }) ]; - - test.asserts.assertions.expected = ['' - Cannot use the rofi options 'theme' and 'colors' simultaneously. - '']; - }; -} diff --git a/third_party/home-manager/tests/modules/programs/rofi/config-with-deprecated-options.nix b/third_party/home-manager/tests/modules/programs/rofi/config-with-deprecated-options.nix new file mode 100644 index 0000000000..b77c5ac9cf --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/rofi/config-with-deprecated-options.nix @@ -0,0 +1,17 @@ +{ ... }: + +{ + programs.rofi = { + enable = true; + colors = { }; + }; + + test.stubs.rofi = { }; + test.asserts.assertions.expected = [ + (let offendingFile = toString ./config-with-deprecated-options.nix; + in '' + The option definition `programs.rofi.colors' in `${offendingFile}' no longer has any effect; please remove it. + Please use a Rofi theme instead. + '') + ]; +} diff --git a/third_party/home-manager/tests/modules/programs/rofi/custom-theme.nix b/third_party/home-manager/tests/modules/programs/rofi/custom-theme.nix index 2d318a4e42..99c9a9896c 100644 --- a/third_party/home-manager/tests/modules/programs/rofi/custom-theme.nix +++ b/third_party/home-manager/tests/modules/programs/rofi/custom-theme.nix @@ -29,8 +29,7 @@ with lib; }; }; - nixpkgs.overlays = - [ (self: super: { rofi = pkgs.writeScriptBin "dummy-rofi" ""; }) ]; + test.stubs.rofi = { }; nmt.script = '' assertFileContent \ diff --git a/third_party/home-manager/tests/modules/programs/rofi/default.nix b/third_party/home-manager/tests/modules/programs/rofi/default.nix index 057ef0039d..2f8c0a95f6 100644 --- a/third_party/home-manager/tests/modules/programs/rofi/default.nix +++ b/third_party/home-manager/tests/modules/programs/rofi/default.nix @@ -1,5 +1,5 @@ { rofi-valid-config = ./valid-config.nix; rofi-custom-theme = ./custom-theme.nix; - rofi-assert-on-both-theme-and-colors = ./assert-on-both-theme-and-colors.nix; + rofi-config-with-deprecated-options = ./config-with-deprecated-options.nix; } diff --git a/third_party/home-manager/tests/modules/programs/rofi/valid-config-expected.rasi b/third_party/home-manager/tests/modules/programs/rofi/valid-config-expected.rasi index 23cf246067..d9d4aa0beb 100644 --- a/third_party/home-manager/tests/modules/programs/rofi/valid-config-expected.rasi +++ b/third_party/home-manager/tests/modules/programs/rofi/valid-config-expected.rasi @@ -1,20 +1,11 @@ configuration { -bw: 1; -color-normal: "argb:58455a64, #fafbfc, argb:58455a64, #00bcd4, #fafbfc"; -color-window: "argb:583a4c54, argb:582a373e, #c3c6c8"; cycle: false; -eh: 1; font: "Droid Sans Mono 14"; -hide-scrollbar: false; kb-primary-paste: "Control+V,Shift+Insert"; kb-secondary-paste: "Control+v,Insert"; -lines: 10; location: 0; modi: "drun,emoji,ssh"; -padding: 400; -separator-style: "solid"; terminal: "/some/path"; -width: 100; xoffset: 0; yoffset: 0; } diff --git a/third_party/home-manager/tests/modules/programs/rofi/valid-config.nix b/third_party/home-manager/tests/modules/programs/rofi/valid-config.nix index efcb1acdc5..c581c0efd8 100644 --- a/third_party/home-manager/tests/modules/programs/rofi/valid-config.nix +++ b/third_party/home-manager/tests/modules/programs/rofi/valid-config.nix @@ -6,36 +6,9 @@ with lib; config = { programs.rofi = { enable = true; - width = 100; - lines = 10; - borderWidth = 1; - rowHeight = 1; - padding = 400; font = "Droid Sans Mono 14"; - scrollbar = true; terminal = "/some/path"; - separator = "solid"; cycle = false; - fullscren = true; - colors = { - window = { - background = "argb:583a4c54"; - border = "argb:582a373e"; - separator = "#c3c6c8"; - }; - - rows = { - normal = { - background = "argb:58455a64"; - foreground = "#fafbfc"; - backgroundAlt = "argb:58455a64"; - highlight = { - background = "#00bcd4"; - foreground = "#fafbfc"; - }; - }; - }; - }; window = { background = "background"; border = "border"; @@ -48,8 +21,7 @@ with lib; }; }; - nixpkgs.overlays = - [ (self: super: { rofi = pkgs.writeScriptBin "dummy-rofi" ""; }) ]; + test.stubs.rofi = { }; nmt.script = '' assertFileContent \ diff --git a/third_party/home-manager/tests/modules/programs/sbt/credentials.nix b/third_party/home-manager/tests/modules/programs/sbt/credentials.nix index 5aa4c2f776..83ec904c9a 100644 --- a/third_party/home-manager/tests/modules/programs/sbt/credentials.nix +++ b/third_party/home-manager/tests/modules/programs/sbt/credentials.nix @@ -19,8 +19,8 @@ let ]; expectedCredentialsSbt = pkgs.writeText "credentials.sbt" '' import scala.sys.process._ - credentials += Credentials("Sonatype Nexus Repository Manager", "example.com", "user", "echo password".!!) - credentials += Credentials("Sonatype Nexus Repository Manager X", "v2.example.com", "user1", "echo password1".!!) + credentials += Credentials("Sonatype Nexus Repository Manager", "example.com", "user", "echo password".lazyLines.mkString("\n")) + credentials += Credentials("Sonatype Nexus Repository Manager X", "v2.example.com", "user1", "echo password1".lazyLines.mkString("\n")) ''; credentialsSbtPath = ".sbt/1.0/credentials.sbt"; in { diff --git a/third_party/home-manager/tests/modules/programs/scmpuff/no-shell.nix b/third_party/home-manager/tests/modules/programs/scmpuff/no-shell.nix index df85176716..ddc40773e4 100644 --- a/third_party/home-manager/tests/modules/programs/scmpuff/no-shell.nix +++ b/third_party/home-manager/tests/modules/programs/scmpuff/no-shell.nix @@ -10,6 +10,8 @@ zsh.enable = true; }; + test.stubs.zsh = { }; + nmt.script = '' assertFileNotRegex home-files/.zshrc '${pkgs.scmpuff} init -s' assertFileNotRegex home-files/.bashrc '${pkgs.scmpuff} init -s' diff --git a/third_party/home-manager/tests/modules/programs/scmpuff/no-zsh.nix b/third_party/home-manager/tests/modules/programs/scmpuff/no-zsh.nix index 18480add15..5854fdd6f6 100644 --- a/third_party/home-manager/tests/modules/programs/scmpuff/no-zsh.nix +++ b/third_party/home-manager/tests/modules/programs/scmpuff/no-zsh.nix @@ -8,6 +8,8 @@ zsh.enable = true; }; + test.stubs.zsh = { }; + nmt.script = '' assertFileNotRegex home-files/.zshrc '${pkgs.scmpuff} init -s' ''; diff --git a/third_party/home-manager/tests/modules/programs/scmpuff/zsh.nix b/third_party/home-manager/tests/modules/programs/scmpuff/zsh.nix index d6f7cc5edf..d132945f60 100644 --- a/third_party/home-manager/tests/modules/programs/scmpuff/zsh.nix +++ b/third_party/home-manager/tests/modules/programs/scmpuff/zsh.nix @@ -5,6 +5,8 @@ zsh.enable = true; }; + test.stubs.zsh = { }; + nmt.script = '' assertFileExists home-files/.zshrc assertFileContains \ diff --git a/third_party/home-manager/tests/modules/programs/sm64ex/default.nix b/third_party/home-manager/tests/modules/programs/sm64ex/default.nix new file mode 100644 index 0000000000..699c23f578 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/sm64ex/default.nix @@ -0,0 +1 @@ +{ sm64ex = import ./settings.nix; } diff --git a/third_party/home-manager/tests/modules/programs/sm64ex/settings.nix b/third_party/home-manager/tests/modules/programs/sm64ex/settings.nix new file mode 100644 index 0000000000..04499f1583 --- /dev/null +++ b/third_party/home-manager/tests/modules/programs/sm64ex/settings.nix @@ -0,0 +1,80 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.sm64ex = { + enable = true; + + settings = { + fullscreen = true; + window_x = 0; + window_y = 0; + window_w = 1920; + window_h = 1080; + vsync = 1; + texture_filtering = 1; + master_volume = 127; + music_volume = 127; + sfx_volume = 127; + env_volume = 127; + key_a = [ "0026" "1000" "1103" ]; + key_b = [ "0033" "1002" "1101" ]; + key_start = [ "0039" "1006" "ffff" ]; + key_l = [ "0034" "1007" "1104" ]; + key_r = [ "0036" "100a" "1105" ]; + key_z = [ "0025" "1009" "1102" ]; + key_cup = [ "100b" "ffff" "ffff" ]; + key_cdown = [ "100c" "ffff" "ffff" ]; + key_cleft = [ "100d" "ffff" "ffff" ]; + key_cright = [ "100e" "ffff" "ffff" ]; + key_stickup = [ "0011" "ffff" "ffff" ]; + key_stickdown = [ "001f" "ffff" "ffff" ]; + key_stickleft = [ "001e" "ffff" "ffff" ]; + key_stickright = [ "0020" "ffff" "ffff" ]; + stick_deadzone = 16; + rumble_strength = 10; + skip_intro = 1; + }; + }; + + test.stubs.sm64ex = { }; + + nmt.script = '' + assertFileContent \ + home-files/.local/share/sm64pc/sm64config.txt \ + ${ + pkgs.writeText "sm64ex-expected-settings" '' + env_volume 127 + fullscreen true + key_a 0026 1000 1103 + key_b 0033 1002 1101 + key_cdown 100c ffff ffff + key_cleft 100d ffff ffff + key_cright 100e ffff ffff + key_cup 100b ffff ffff + key_l 0034 1007 1104 + key_r 0036 100a 1105 + key_start 0039 1006 ffff + key_stickdown 001f ffff ffff + key_stickleft 001e ffff ffff + key_stickright 0020 ffff ffff + key_stickup 0011 ffff ffff + key_z 0025 1009 1102 + master_volume 127 + music_volume 127 + rumble_strength 10 + sfx_volume 127 + skip_intro 1 + stick_deadzone 16 + texture_filtering 1 + vsync 1 + window_h 1080 + window_w 1920 + window_x 0 + window_y 0'' + } + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/programs/starship/settings.nix b/third_party/home-manager/tests/modules/programs/starship/settings.nix index 4c506c9e81..c3517cae7b 100644 --- a/third_party/home-manager/tests/modules/programs/starship/settings.nix +++ b/third_party/home-manager/tests/modules/programs/starship/settings.nix @@ -44,9 +44,7 @@ with lib; ]; }; - nixpkgs.overlays = [ - (self: super: { starship = pkgs.writeScriptBin "dummy-starship" ""; }) - ]; + test.stubs.starship = { }; nmt.script = '' assertFileContent \ diff --git a/third_party/home-manager/tests/modules/programs/terminator/config-file.nix b/third_party/home-manager/tests/modules/programs/terminator/config-file.nix index 1ae06fdc93..50b9c42e79 100644 --- a/third_party/home-manager/tests/modules/programs/terminator/config-file.nix +++ b/third_party/home-manager/tests/modules/programs/terminator/config-file.nix @@ -8,8 +8,7 @@ }; }; - nixpkgs.overlays = - [ (self: super: { terminator = pkgs.writeScriptBin "dummy" ""; }) ]; + test.stubs.terminator = { }; nmt.script = '' assertFileContent home-files/.config/terminator/config ${ diff --git a/third_party/home-manager/tests/modules/programs/topgrade/settings.nix b/third_party/home-manager/tests/modules/programs/topgrade/settings.nix index a7436b5efc..a8f5c6d105 100644 --- a/third_party/home-manager/tests/modules/programs/topgrade/settings.nix +++ b/third_party/home-manager/tests/modules/programs/topgrade/settings.nix @@ -25,9 +25,7 @@ with lib; ]; }; - nixpkgs.overlays = [ - (self: super: { topgrade = pkgs.writeScriptBin "dummy-topgrade" ""; }) - ]; + test.stubs.topgrade = { }; nmt.script = '' assertFileContent \ diff --git a/third_party/home-manager/tests/modules/programs/waybar/settings-complex.nix b/third_party/home-manager/tests/modules/programs/waybar/settings-complex.nix index 1756ae120a..1297f55798 100644 --- a/third_party/home-manager/tests/modules/programs/waybar/settings-complex.nix +++ b/third_party/home-manager/tests/modules/programs/waybar/settings-complex.nix @@ -2,12 +2,10 @@ with lib; -let - package = pkgs.writeScriptBin "dummy-waybar" "" // { outPath = "@waybar@"; }; -in { +{ config = { programs.waybar = { - inherit package; + package = config.lib.test.mkStubPackage { outPath = "@waybar@"; }; enable = true; settings = [{ layer = "top"; @@ -41,9 +39,7 @@ in { format = "hello from {}"; exec = let dummyScript = - pkgs.writeShellScriptBin "dummy" "echo within waybar" // { - outPath = "@dummy@"; - }; + config.lib.test.mkStubPackage { outPath = "@dummy@"; }; in "${dummyScript}/bin/dummy"; }; }; diff --git a/third_party/home-manager/tests/modules/programs/waybar/styling.nix b/third_party/home-manager/tests/modules/programs/waybar/styling.nix index bd73f2aafd..6e34847ed1 100644 --- a/third_party/home-manager/tests/modules/programs/waybar/styling.nix +++ b/third_party/home-manager/tests/modules/programs/waybar/styling.nix @@ -2,12 +2,10 @@ with lib; -let - package = pkgs.writeScriptBin "dummy-waybar" "" // { outPath = "@waybar@"; }; -in { +{ config = { programs.waybar = { - inherit package; + package = config.lib.test.mkStubPackage { outPath = "@waybar@"; }; enable = true; style = '' * { diff --git a/third_party/home-manager/tests/modules/programs/waybar/systemd-with-graphical-session-target.nix b/third_party/home-manager/tests/modules/programs/waybar/systemd-with-graphical-session-target.nix index e751d804da..eff5af9cc5 100644 --- a/third_party/home-manager/tests/modules/programs/waybar/systemd-with-graphical-session-target.nix +++ b/third_party/home-manager/tests/modules/programs/waybar/systemd-with-graphical-session-target.nix @@ -2,12 +2,10 @@ with lib; -let - package = pkgs.writeScriptBin "dummy-waybar" "" // { outPath = "@waybar@"; }; -in { +{ config = { programs.waybar = { - inherit package; + package = config.lib.test.mkStubPackage { outPath = "@waybar@"; }; enable = true; systemd.enable = true; }; diff --git a/third_party/home-manager/tests/modules/programs/waybar/warnings-tests.nix b/third_party/home-manager/tests/modules/programs/waybar/warnings-tests.nix index f7912dba73..e844cc61d0 100644 --- a/third_party/home-manager/tests/modules/programs/waybar/warnings-tests.nix +++ b/third_party/home-manager/tests/modules/programs/waybar/warnings-tests.nix @@ -2,12 +2,10 @@ with lib; -let - package = pkgs.writeScriptBin "dummy-waybar" "" // { outPath = "@waybar@"; }; -in { +{ config = { programs.waybar = { - inherit package; + package = config.lib.test.mkStubPackage { outPath = "@waybar@"; }; enable = true; settings = [{ modules-left = [ "custom/my-module" ]; diff --git a/third_party/home-manager/tests/modules/programs/xmobar/basic-configuration.nix b/third_party/home-manager/tests/modules/programs/xmobar/basic-configuration.nix index 360cc4c3dc..bbd9420eaa 100644 --- a/third_party/home-manager/tests/modules/programs/xmobar/basic-configuration.nix +++ b/third_party/home-manager/tests/modules/programs/xmobar/basic-configuration.nix @@ -6,6 +6,7 @@ with lib; config = { programs.xmobar = { enable = true; + package = config.lib.test.mkStubPackage { }; extraConfig = '' Config { font = "Fira Code" diff --git a/third_party/home-manager/tests/modules/programs/zplug/modules.nix b/third_party/home-manager/tests/modules/programs/zplug/modules.nix index 704c5c5e2e..7c4abbc425 100644 --- a/third_party/home-manager/tests/modules/programs/zplug/modules.nix +++ b/third_party/home-manager/tests/modules/programs/zplug/modules.nix @@ -8,6 +8,7 @@ with lib; enable = true; zplug = { enable = true; + zplugHome = ~/.customZplugHome; plugins = [ { name = "plugins/git"; @@ -21,16 +22,14 @@ with lib; }; }; - nixpkgs.overlays = [ - (self: super: { - zsh = pkgs.writeScriptBin "dummy-zsh" ""; - zplug = pkgs.writeScriptBin "dummy-zplug" ""; - }) - ]; + test.stubs = { + zplug = { }; + zsh = { }; + }; nmt.script = '' - assertFileRegex home-files/.zshrc \ - '^source ${builtins.storeDir}/.*zplug.*/init\.zsh$' + assertFileContains home-files/.zshrc \ + 'source @zplug@/init.zsh' assertFileContains home-files/.zshrc \ 'zplug "plugins/git", from:oh-my-zsh' @@ -45,6 +44,9 @@ with lib; assertFileRegex home-files/.zshrc \ '^zplug load$' + + assertFileContains home-files/.zshrc \ + 'export ZPLUG_HOME=${config.programs.zsh.zplug.zplugHome}' ''; }; } diff --git a/third_party/home-manager/tests/modules/programs/zsh/history-ignore-pattern.nix b/third_party/home-manager/tests/modules/programs/zsh/history-ignore-pattern.nix index ba423efe23..68be58fe86 100644 --- a/third_party/home-manager/tests/modules/programs/zsh/history-ignore-pattern.nix +++ b/third_party/home-manager/tests/modules/programs/zsh/history-ignore-pattern.nix @@ -11,8 +11,7 @@ with lib; config = { programs.zsh.enable = true; - nixpkgs.overlays = - [ (self: super: { zsh = pkgs.writeScriptBin "dummy-zsh" ""; }) ]; + test.stubs.zsh = { }; nmt.script = '' assertFileContains home-files/.zshrc "HISTORY_IGNORE='(echo *|rm *)'" diff --git a/third_party/home-manager/tests/modules/programs/zsh/history-path-new-custom.nix b/third_party/home-manager/tests/modules/programs/zsh/history-path-new-custom.nix index 0c052d6949..1a691f1ca6 100644 --- a/third_party/home-manager/tests/modules/programs/zsh/history-path-new-custom.nix +++ b/third_party/home-manager/tests/modules/programs/zsh/history-path-new-custom.nix @@ -10,8 +10,7 @@ with lib; history.path = "$HOME/some/directory/zsh_history"; }; - nixpkgs.overlays = - [ (self: super: { zsh = pkgs.writeScriptBin "dummy-zsh" ""; }) ]; + test.stubs.zsh = { }; nmt.script = '' assertFileRegex home-files/.zshrc '^HISTFILE="$HOME/some/directory/zsh_history"$' diff --git a/third_party/home-manager/tests/modules/programs/zsh/history-path-new-default.nix b/third_party/home-manager/tests/modules/programs/zsh/history-path-new-default.nix index 6d1f58a29d..06fe88d06c 100644 --- a/third_party/home-manager/tests/modules/programs/zsh/history-path-new-default.nix +++ b/third_party/home-manager/tests/modules/programs/zsh/history-path-new-default.nix @@ -7,8 +7,7 @@ with lib; home.stateVersion = "20.03"; programs.zsh.enable = true; - nixpkgs.overlays = - [ (self: super: { zsh = pkgs.writeScriptBin "dummy-zsh" ""; }) ]; + test.stubs.zsh = { }; nmt.script = '' assertFileRegex home-files/.zshrc '^HISTFILE="$HOME/.zsh_history"$' diff --git a/third_party/home-manager/tests/modules/programs/zsh/history-path-old-custom.nix b/third_party/home-manager/tests/modules/programs/zsh/history-path-old-custom.nix index f5b178b5e9..42a85d0047 100644 --- a/third_party/home-manager/tests/modules/programs/zsh/history-path-old-custom.nix +++ b/third_party/home-manager/tests/modules/programs/zsh/history-path-old-custom.nix @@ -10,8 +10,7 @@ with lib; history.path = "some/directory/zsh_history"; }; - nixpkgs.overlays = - [ (self: super: { zsh = pkgs.writeScriptBin "dummy-zsh" ""; }) ]; + test.stubs.zsh = { }; nmt.script = '' assertFileRegex home-files/.zshrc '^HISTFILE="$HOME/some/directory/zsh_history"$' diff --git a/third_party/home-manager/tests/modules/programs/zsh/history-path-old-default.nix b/third_party/home-manager/tests/modules/programs/zsh/history-path-old-default.nix index d880d96645..490a2715d8 100644 --- a/third_party/home-manager/tests/modules/programs/zsh/history-path-old-default.nix +++ b/third_party/home-manager/tests/modules/programs/zsh/history-path-old-default.nix @@ -7,8 +7,7 @@ with lib; home.stateVersion = "19.03"; programs.zsh.enable = true; - nixpkgs.overlays = - [ (self: super: { zsh = pkgs.writeScriptBin "dummy-zsh" ""; }) ]; + test.stubs.zsh = { }; nmt.script = '' assertFileRegex home-files/.zshrc '^HISTFILE="$HOME/.zsh_history"$' diff --git a/third_party/home-manager/tests/modules/programs/zsh/prezto.nix b/third_party/home-manager/tests/modules/programs/zsh/prezto.nix index 5bc95510d4..922112ef9e 100644 --- a/third_party/home-manager/tests/modules/programs/zsh/prezto.nix +++ b/third_party/home-manager/tests/modules/programs/zsh/prezto.nix @@ -3,23 +3,20 @@ with lib; { - config = { - programs.zsh.prezto.enable = true; + programs.zsh.prezto.enable = true; - nixpkgs.overlays = [ - (self: super: { - zsh-prezto = super.runCommandLocal "dummy-zsh-prezto" { } '' - mkdir -p $out/share/zsh-prezto/runcoms - echo '# zprofile' > $out/share/zsh-prezto/runcoms/zprofile - echo '# zlogin' > $out/share/zsh-prezto/runcoms/zlogin - echo '# zlogout' > $out/share/zsh-prezto/runcoms/zlogout - echo '# zshenv' > $out/share/zsh-prezto/runcoms/zshenv - ''; - }) - ]; - - nmt.script = '' - assertFileExists home-files/.zpreztorc + test.stubs.zsh-prezto = { + outPath = null; + buildScript = '' + mkdir -p $out/share/zsh-prezto/runcoms + echo '# zprofile' > $out/share/zsh-prezto/runcoms/zprofile + echo '# zlogin' > $out/share/zsh-prezto/runcoms/zlogin + echo '# zlogout' > $out/share/zsh-prezto/runcoms/zlogout + echo '# zshenv' > $out/share/zsh-prezto/runcoms/zshenv ''; }; + + nmt.script = '' + assertFileExists home-files/.zpreztorc + ''; } diff --git a/third_party/home-manager/tests/modules/programs/zsh/session-variables.nix b/third_party/home-manager/tests/modules/programs/zsh/session-variables.nix index ca903619d6..638b41c9f4 100644 --- a/third_party/home-manager/tests/modules/programs/zsh/session-variables.nix +++ b/third_party/home-manager/tests/modules/programs/zsh/session-variables.nix @@ -13,11 +13,7 @@ with lib; }; }; - nixpkgs.overlays = [ - (self: super: { - zsh = pkgs.writeScriptBin "dummy-zsh" ""; - }) - ]; + test.stubs.zsh = { }; nmt.script = '' assertFileExists home-files/.zshrc diff --git a/third_party/home-manager/tests/modules/services/barrier/basic-configuration.nix b/third_party/home-manager/tests/modules/services/barrier/basic-configuration.nix index 83a9365e4e..03b1beae77 100644 --- a/third_party/home-manager/tests/modules/services/barrier/basic-configuration.nix +++ b/third_party/home-manager/tests/modules/services/barrier/basic-configuration.nix @@ -7,8 +7,7 @@ server = "testServer"; }; - nixpkgs.overlays = - [ (self: super: { barrier = pkgs.writeScriptBin "dummy-barrier" ""; }) ]; + test.stubs.barrier = { }; nmt.script = '' clientServiceFile=home-files/.config/systemd/user/barrierc.service diff --git a/third_party/home-manager/tests/modules/services/devilspie2/config.lua b/third_party/home-manager/tests/modules/services/devilspie2/config.lua new file mode 100644 index 0000000000..3024d3c316 --- /dev/null +++ b/third_party/home-manager/tests/modules/services/devilspie2/config.lua @@ -0,0 +1,11 @@ +if (get_window_class() == "Gnome-terminal") then + make_always_on_top(); +end + +if string.match(get_window_name(), "LibreOffice Writer") then + maximize(); +end + +if (get_window_class()=="Org.gnome.Nautilus") then + set_window_geometry(1600,300,900,700); +end diff --git a/third_party/home-manager/tests/modules/services/devilspie2/configuration.nix b/third_party/home-manager/tests/modules/services/devilspie2/configuration.nix new file mode 100644 index 0000000000..2072d4d844 --- /dev/null +++ b/third_party/home-manager/tests/modules/services/devilspie2/configuration.nix @@ -0,0 +1,37 @@ +{ config, pkgs, ... }: { + config = { + services.devilspie2 = { + enable = true; + + config = '' + if (get_window_class() == "Gnome-terminal") then + make_always_on_top(); + end + + if string.match(get_window_name(), "LibreOffice Writer") then + maximize(); + end + + 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/third_party/home-manager/tests/modules/services/devilspie2/default.nix b/third_party/home-manager/tests/modules/services/devilspie2/default.nix new file mode 100644 index 0000000000..b62380ee63 --- /dev/null +++ b/third_party/home-manager/tests/modules/services/devilspie2/default.nix @@ -0,0 +1 @@ +{ devilspie2-configuration = ./configuration.nix; } diff --git a/third_party/home-manager/tests/modules/services/dropbox/basic-configuration.nix b/third_party/home-manager/tests/modules/services/dropbox/basic-configuration.nix index 96a17cd738..9b8a6d651c 100644 --- a/third_party/home-manager/tests/modules/services/dropbox/basic-configuration.nix +++ b/third_party/home-manager/tests/modules/services/dropbox/basic-configuration.nix @@ -7,13 +7,7 @@ path = "${config.home.homeDirectory}/dropbox"; }; - nixpkgs.overlays = [ - (self: super: { - dropbox-cli = pkgs.writeScriptBin "dummy-dropbox-cli" "" // { - outPath = "@dropbox-cli@"; - }; - }) - ]; + test.stubs.dropbox-cli = { }; nmt.script = '' serviceFile=home-files/.config/systemd/user/dropbox.service diff --git a/third_party/home-manager/tests/modules/services/emacs/emacs-service-27.nix b/third_party/home-manager/tests/modules/services/emacs/emacs-service-27.nix index fa5f9f62bb..6bc99ced46 100644 --- a/third_party/home-manager/tests/modules/services/emacs/emacs-service-27.nix +++ b/third_party/home-manager/tests/modules/services/emacs/emacs-service-27.nix @@ -17,6 +17,7 @@ with lib; 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 diff --git a/third_party/home-manager/tests/modules/services/emacs/emacs-service-28.nix b/third_party/home-manager/tests/modules/services/emacs/emacs-service-28.nix index 092cd14533..febfe8288f 100644 --- a/third_party/home-manager/tests/modules/services/emacs/emacs-service-28.nix +++ b/third_party/home-manager/tests/modules/services/emacs/emacs-service-28.nix @@ -17,6 +17,7 @@ with lib; 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 diff --git a/third_party/home-manager/tests/modules/services/emacs/emacs-service-emacs.service b/third_party/home-manager/tests/modules/services/emacs/emacs-service-emacs.service index 00b0c8eb2f..64120f4c05 100644 --- a/third_party/home-manager/tests/modules/services/emacs/emacs-service-emacs.service +++ b/third_party/home-manager/tests/modules/services/emacs/emacs-service-emacs.service @@ -2,7 +2,7 @@ WantedBy=default.target [Service] -ExecStart=@runtimeShell@ -l -c "@emacs@/bin/emacs --fg-daemon" +ExecStart=@runtimeShell@ -l -c "@emacs@/bin/emacs --fg-daemon '-f' 'exwm-enable'" Restart=on-failure SuccessExitStatus=15 Type=notify diff --git a/third_party/home-manager/tests/modules/services/emacs/emacs-socket-27.nix b/third_party/home-manager/tests/modules/services/emacs/emacs-socket-27.nix index 0fd1be1be7..b3b71e0273 100644 --- a/third_party/home-manager/tests/modules/services/emacs/emacs-socket-27.nix +++ b/third_party/home-manager/tests/modules/services/emacs/emacs-socket-27.nix @@ -19,6 +19,7 @@ in { programs.emacs.enable = true; services.emacs.enable = true; services.emacs.client.enable = true; + services.emacs.extraOptions = [ "-f" "exwm-enable" ]; services.emacs.socketActivation.enable = true; nmt.script = '' diff --git a/third_party/home-manager/tests/modules/services/emacs/emacs-socket-28.nix b/third_party/home-manager/tests/modules/services/emacs/emacs-socket-28.nix index d2c04239c7..9110666568 100644 --- a/third_party/home-manager/tests/modules/services/emacs/emacs-socket-28.nix +++ b/third_party/home-manager/tests/modules/services/emacs/emacs-socket-28.nix @@ -19,6 +19,7 @@ in { programs.emacs.enable = true; services.emacs.enable = true; services.emacs.client.enable = true; + services.emacs.extraOptions = [ "-f" "exwm-enable" ]; services.emacs.socketActivation.enable = true; nmt.script = '' diff --git a/third_party/home-manager/tests/modules/services/emacs/emacs-socket-emacs.service b/third_party/home-manager/tests/modules/services/emacs/emacs-socket-emacs.service index a3687ead3e..b44694d39a 100644 --- a/third_party/home-manager/tests/modules/services/emacs/emacs-socket-emacs.service +++ b/third_party/home-manager/tests/modules/services/emacs/emacs-socket-emacs.service @@ -1,5 +1,5 @@ [Service] -ExecStart=@runtimeShell@ -l -c "@emacs@/bin/emacs --fg-daemon='%t/emacs/server'" +ExecStart=@runtimeShell@ -l -c "@emacs@/bin/emacs --fg-daemon='%t/emacs/server' '-f' 'exwm-enable'" ExecStartPost=@coreutils@/bin/chmod --changes -w %t/emacs ExecStopPost=@coreutils@/bin/chmod --changes +w %t/emacs Restart=on-failure diff --git a/third_party/home-manager/tests/modules/services/flameshot/default.nix b/third_party/home-manager/tests/modules/services/flameshot/default.nix new file mode 100644 index 0000000000..826051f306 --- /dev/null +++ b/third_party/home-manager/tests/modules/services/flameshot/default.nix @@ -0,0 +1,4 @@ +{ + flameshot-empty-settings = ./empty-settings.nix; + flameshot-example-settings = ./example-settings.nix; +} diff --git a/third_party/home-manager/tests/modules/services/flameshot/empty-settings.nix b/third_party/home-manager/tests/modules/services/flameshot/empty-settings.nix new file mode 100644 index 0000000000..a5205660b3 --- /dev/null +++ b/third_party/home-manager/tests/modules/services/flameshot/empty-settings.nix @@ -0,0 +1,13 @@ +{ ... }: + +{ + config = { + services.flameshot = { enable = true; }; + + test.stubs.flameshot = { }; + + nmt.script = '' + assertPathNotExists home-files/.config/flameshot/flameshot.ini + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/services/flameshot/example-settings.nix b/third_party/home-manager/tests/modules/services/flameshot/example-settings.nix new file mode 100644 index 0000000000..213e86b341 --- /dev/null +++ b/third_party/home-manager/tests/modules/services/flameshot/example-settings.nix @@ -0,0 +1,30 @@ +{ ... }: + +{ + config = { + services.flameshot = { + enable = true; + + 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 + '' + } + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/services/fluidsynth/service.nix b/third_party/home-manager/tests/modules/services/fluidsynth/service.nix index 8d53e75c03..7fbfa79ce9 100644 --- a/third_party/home-manager/tests/modules/services/fluidsynth/service.nix +++ b/third_party/home-manager/tests/modules/services/fluidsynth/service.nix @@ -1,16 +1,11 @@ { config, pkgs, ... }: { config = { services.fluidsynth.enable = true; + services.fluidsynth.soundService = "pipewire-pulse"; services.fluidsynth.soundFont = "/path/to/soundFont"; services.fluidsynth.extraOptions = [ "--sample-rate 96000" ]; - nixpkgs.overlays = [ - (self: super: { - fluidsynth = pkgs.writeScriptBin "dummy-fluidsynth" "" // { - outPath = "@fluidsynth@"; - }; - }) - ]; + test.stubs.fluidsynth = { }; nmt.script = '' serviceFile=home-files/.config/systemd/user/fluidsynth.service @@ -19,6 +14,12 @@ assertFileContains $serviceFile \ 'ExecStart=@fluidsynth@/bin/fluidsynth -a pulseaudio -si --sample-rate 96000 /path/to/soundFont' + + assertFileContains $serviceFile \ + 'After=pipewire-pulse.service' + + assertFileContains $serviceFile \ + 'BindsTo=pipewire-pulse.service' ''; }; } diff --git a/third_party/home-manager/tests/modules/services/fnott/default.nix b/third_party/home-manager/tests/modules/services/fnott/default.nix new file mode 100644 index 0000000000..e28250a484 --- /dev/null +++ b/third_party/home-manager/tests/modules/services/fnott/default.nix @@ -0,0 +1,4 @@ +{ + fnott-example-settings = ./example-settings.nix; + fnott-systemd-user-service = ./systemd-user-service.nix; +} diff --git a/third_party/home-manager/tests/modules/services/fnott/example-settings-expected.ini b/third_party/home-manager/tests/modules/services/fnott/example-settings-expected.ini new file mode 100644 index 0000000000..6293f63d28 --- /dev/null +++ b/third_party/home-manager/tests/modules/services/fnott/example-settings-expected.ini @@ -0,0 +1,7 @@ +[low] +timeout=5 +title-color=ffffff +title-font=Dina:weight=bold:slant=italic + +[main] +notification-margin=5 diff --git a/third_party/home-manager/tests/modules/services/fnott/example-settings.nix b/third_party/home-manager/tests/modules/services/fnott/example-settings.nix new file mode 100644 index 0000000000..16b591ff7f --- /dev/null +++ b/third_party/home-manager/tests/modules/services/fnott/example-settings.nix @@ -0,0 +1,26 @@ +{ config, lib, pkgs, ... }: + +{ + config = { + services.fnott = { + enable = true; + package = config.lib.test.mkStubPackage { }; + + settings = { + main = { notification-margin = 5; }; + + low = { + timeout = 5; + title-font = "Dina:weight=bold:slant=italic"; + title-color = "ffffff"; + }; + }; + }; + + nmt.script = '' + assertFileContent \ + home-files/.config/fnott/fnott.ini \ + ${./example-settings-expected.ini} + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/services/fnott/systemd-user-service-expected.service b/third_party/home-manager/tests/modules/services/fnott/systemd-user-service-expected.service new file mode 100644 index 0000000000..1d09bfad55 --- /dev/null +++ b/third_party/home-manager/tests/modules/services/fnott/systemd-user-service-expected.service @@ -0,0 +1,10 @@ +[Service] +BusName=org.freedesktop.Notifications +ExecStart=@fnott@/bin/fnott -c '/home/hm-user/.config/fnott/fnott.ini' +Type=dbus + +[Unit] +After=graphical-session-pre.target +Description=Fnott notification daemon +Documentation=man:fnott(1) +PartOf=graphical-session.target diff --git a/third_party/home-manager/tests/modules/services/fnott/systemd-user-service.nix b/third_party/home-manager/tests/modules/services/fnott/systemd-user-service.nix new file mode 100644 index 0000000000..7efa06435a --- /dev/null +++ b/third_party/home-manager/tests/modules/services/fnott/systemd-user-service.nix @@ -0,0 +1,16 @@ +{ config, lib, pkgs, ... }: + +{ + config = { + services.fnott = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@fnott@"; }; + }; + + nmt.script = '' + assertFileContent \ + home-files/.config/systemd/user/fnott.service \ + ${./systemd-user-service-expected.service} + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/services/git-sync/basic.nix b/third_party/home-manager/tests/modules/services/git-sync/basic.nix new file mode 100644 index 0000000000..0e9c7ad65b --- /dev/null +++ b/third_party/home-manager/tests/modules/services/git-sync/basic.nix @@ -0,0 +1,37 @@ +{ config, pkgs, ... }: + +{ + config = { + services.git-sync = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@git-sync@"; }; + repositories.test = { + path = "/a/path"; + uri = "git+ssh://user@example.com:/~user/path/to/repo.git"; + }; + }; + + nmt.script = '' + serviceFile=home-files/.config/systemd/user/git-sync-test.service + + assertFileExists $serviceFile + assertFileContent $serviceFile ${ + builtins.toFile "expected" '' + [Install] + WantedBy=default.target + + [Service] + Environment=GIT_SYNC_DIRECTORY=/a/path + Environment=GIT_SYNC_COMMAND=@git-sync@/bin/git-sync + Environment=GIT_SYNC_REPOSITORY=git+ssh://user@example.com:/~user/path/to/repo.git + Environment=GIT_SYNC_INTERVAL=500 + ExecStart=@git-sync@/bin/git-sync-on-inotify + Restart=on-abort + + [Unit] + Description=Git Sync test + '' + } + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/services/git-sync/default.nix b/third_party/home-manager/tests/modules/services/git-sync/default.nix new file mode 100644 index 0000000000..0e9db79d0a --- /dev/null +++ b/third_party/home-manager/tests/modules/services/git-sync/default.nix @@ -0,0 +1 @@ +{ git-sync = ./basic.nix; } diff --git a/third_party/home-manager/tests/modules/services/gpg-agent/default-homedir.nix b/third_party/home-manager/tests/modules/services/gpg-agent/default-homedir.nix index f7ebf5739e..1b4333e126 100644 --- a/third_party/home-manager/tests/modules/services/gpg-agent/default-homedir.nix +++ b/third_party/home-manager/tests/modules/services/gpg-agent/default-homedir.nix @@ -7,8 +7,7 @@ with lib; services.gpg-agent.enable = true; programs.gpg.enable = true; - nixpkgs.overlays = - [ (self: super: { gnupg = pkgs.writeScriptBin "dummy-gnupg" ""; }) ]; + test.stubs.gnupg = { }; nmt.script = '' in="${config.systemd.user.sockets.gpg-agent.Socket.ListenStream}" diff --git a/third_party/home-manager/tests/modules/services/gpg-agent/override-homedir.nix b/third_party/home-manager/tests/modules/services/gpg-agent/override-homedir.nix index 6705a0014a..6c231a3b2b 100644 --- a/third_party/home-manager/tests/modules/services/gpg-agent/override-homedir.nix +++ b/third_party/home-manager/tests/modules/services/gpg-agent/override-homedir.nix @@ -10,8 +10,7 @@ with lib; homedir = "${config.home.homeDirectory}/foo/bar"; }; - nixpkgs.overlays = - [ (self: super: { gnupg = pkgs.writeScriptBin "dummy-gnupg" ""; }) ]; + test.stubs.gnupg = { }; nmt.script = '' in="${config.systemd.user.sockets.gpg-agent.Socket.ListenStream}" diff --git a/third_party/home-manager/tests/modules/services/kanshi/basic-configuration.conf b/third_party/home-manager/tests/modules/services/kanshi/basic-configuration.conf index 9d6442b985..a305f28f2b 100644 --- a/third_party/home-manager/tests/modules/services/kanshi/basic-configuration.conf +++ b/third_party/home-manager/tests/modules/services/kanshi/basic-configuration.conf @@ -1,8 +1,14 @@ +profile backwardsCompat { + output "LVDS-1" enable + exec echo "7 eight 9" +} + profile desktop { output "eDP-1" disable output "Iiyama North America PLE2483H-DP" enable position 0,0 output "Iiyama North America PLE2483H-DP 1158765348486" enable mode 1920x1080 position 1920,0 scale 2.100000 transform flipped-270 exec echo "1 two 3" + exec echo "4 five 6" } profile nomad { diff --git a/third_party/home-manager/tests/modules/services/kanshi/basic-configuration.nix b/third_party/home-manager/tests/modules/services/kanshi/basic-configuration.nix index 15fbbb9ceb..c5706e635a 100644 --- a/third_party/home-manager/tests/modules/services/kanshi/basic-configuration.nix +++ b/third_party/home-manager/tests/modules/services/kanshi/basic-configuration.nix @@ -2,7 +2,7 @@ config = { services.kanshi = { enable = true; - package = pkgs.writeScriptBin "dummy-kanshi" ""; + package = config.lib.test.mkStubPackage { }; profiles = { nomad = { outputs = [{ @@ -11,7 +11,7 @@ }]; }; desktop = { - exec = ''echo "1 two 3"''; + exec = [ ''echo "1 two 3"'' ''echo "4 five 6"'' ]; outputs = [ { criteria = "eDP-1"; @@ -32,6 +32,13 @@ } ]; }; + backwardsCompat = { + outputs = [{ + criteria = "LVDS-1"; + status = "enable"; + }]; + exec = ''echo "7 eight 9"''; + }; }; extraConfig = '' profile test { diff --git a/third_party/home-manager/tests/modules/services/lieer/lieer-service-expected.service b/third_party/home-manager/tests/modules/services/lieer/lieer-service-expected.service index 8437b9895b..1d282eb980 100644 --- a/third_party/home-manager/tests/modules/services/lieer/lieer-service-expected.service +++ b/third_party/home-manager/tests/modules/services/lieer/lieer-service-expected.service @@ -1,6 +1,6 @@ [Service] Environment=NOTMUCH_CONFIG=/home/hm-user/.config/notmuch/notmuchrc -ExecStart=@lieer@/bin/gmi sync +ExecStart=@gmailieer@/bin/gmi sync Type=oneshot WorkingDirectory=/home/hm-user/Mail/hm@example.com diff --git a/third_party/home-manager/tests/modules/services/lieer/lieer-service.nix b/third_party/home-manager/tests/modules/services/lieer/lieer-service.nix index af3074b0f3..f624ae8268 100644 --- a/third_party/home-manager/tests/modules/services/lieer/lieer-service.nix +++ b/third_party/home-manager/tests/modules/services/lieer/lieer-service.nix @@ -19,13 +19,7 @@ with lib; }; }; - nixpkgs.overlays = [ - (self: super: { - gmailieer = pkgs.writeScriptBin "dummy-gmailieer" "" // { - outPath = "@lieer@"; - }; - }) - ]; + test.stubs.gmailieer = { }; nmt.script = '' assertFileExists home-files/.config/systemd/user/lieer-hm-example-com.service diff --git a/third_party/home-manager/tests/modules/services/pantalaimon/basic-configuration.nix b/third_party/home-manager/tests/modules/services/pantalaimon/basic-configuration.nix index f04101c052..ac36c0b87c 100644 --- a/third_party/home-manager/tests/modules/services/pantalaimon/basic-configuration.nix +++ b/third_party/home-manager/tests/modules/services/pantalaimon/basic-configuration.nix @@ -4,9 +4,7 @@ config = { services.pantalaimon = { enable = true; - package = pkgs.writeScriptBin "dummy-pantalaimon" "" // { - outPath = "@pantalaimon@"; - }; + package = config.lib.test.mkStubPackage { outPath = "@pantalaimon@"; }; settings = { Default = { LogLevel = "Debug"; diff --git a/third_party/home-manager/tests/modules/services/pbgopy/service.nix b/third_party/home-manager/tests/modules/services/pbgopy/service.nix index fb03c355cd..465024537a 100644 --- a/third_party/home-manager/tests/modules/services/pbgopy/service.nix +++ b/third_party/home-manager/tests/modules/services/pbgopy/service.nix @@ -2,13 +2,7 @@ config = { services.pbgopy.enable = true; - nixpkgs.overlays = [ - (self: super: { - pbgopy = pkgs.writeScriptBin "dummy-pbgopy" "" // { - outPath = "@pbgopy@"; - }; - }) - ]; + test.stubs.pbgopy = { }; nmt.script = '' serviceFile=home-files/.config/systemd/user/pbgopy.service diff --git a/third_party/home-manager/tests/modules/services/polybar/basic-configuration.nix b/third_party/home-manager/tests/modules/services/polybar/basic-configuration.nix index fd23256c3d..b6374acd89 100644 --- a/third_party/home-manager/tests/modules/services/polybar/basic-configuration.nix +++ b/third_party/home-manager/tests/modules/services/polybar/basic-configuration.nix @@ -4,7 +4,7 @@ config = { services.polybar = { enable = true; - package = pkgs.writeScriptBin "dummy-polybar" ""; + package = config.lib.test.mkStubPackage { }; script = "polybar bar &"; config = { "bar/top" = { diff --git a/third_party/home-manager/tests/modules/services/redshift-gammastep/gammastep-basic-configuration.nix b/third_party/home-manager/tests/modules/services/redshift-gammastep/gammastep-basic-configuration.nix index 9ccf38528c..6f0454bf35 100644 --- a/third_party/home-manager/tests/modules/services/redshift-gammastep/gammastep-basic-configuration.nix +++ b/third_party/home-manager/tests/modules/services/redshift-gammastep/gammastep-basic-configuration.nix @@ -16,13 +16,7 @@ }; }; - nixpkgs.overlays = [ - (self: super: { - gammastep = pkgs.writeScriptBin "dummy-gammastep" "" // { - outPath = "@gammastep@"; - }; - }) - ]; + test.stubs.gammastep = { }; nmt.script = '' assertFileContent \ diff --git a/third_party/home-manager/tests/modules/services/redshift-gammastep/redshift-basic-configuration.nix b/third_party/home-manager/tests/modules/services/redshift-gammastep/redshift-basic-configuration.nix index 5e2fe40e0e..691d01e257 100644 --- a/third_party/home-manager/tests/modules/services/redshift-gammastep/redshift-basic-configuration.nix +++ b/third_party/home-manager/tests/modules/services/redshift-gammastep/redshift-basic-configuration.nix @@ -16,13 +16,7 @@ }; }; - nixpkgs.overlays = [ - (self: super: { - redshift = pkgs.writeScriptBin "dummy-redshift" "" // { - outPath = "@redshift@"; - }; - }) - ]; + test.stubs.redshift = { }; nmt.script = '' assertFileContent \ diff --git a/third_party/home-manager/tests/modules/services/screen-locker/basic-configuration.nix b/third_party/home-manager/tests/modules/services/screen-locker/basic-configuration.nix new file mode 100644 index 0000000000..9eee2a8e2a --- /dev/null +++ b/third_party/home-manager/tests/modules/services/screen-locker/basic-configuration.nix @@ -0,0 +1,30 @@ +{ config, pkgs, ... }: + +{ + config = { + services.screen-locker = { + enable = true; + inactiveInterval = 5; + lockCmd = "${pkgs.i3lock}/bin/i3lock -n -c AA0000"; + xss-lock = { extraOptions = [ "-test" ]; }; + xautolock = { + enable = true; + detectSleep = true; + extraOptions = [ "-test" ]; + }; + }; + + test.stubs.i3lock = { }; + test.stubs.xss-lock = { }; + + nmt.script = '' + xssService=home-files/.config/systemd/user/xss-lock.service + xautolockService=home-files/.config/systemd/user/xautolock-session.service + + assertFileExists $xssService + assertFileRegex $xssService 'ExecStart=.*/bin/xss-lock.*-test.*i3lock -n -c AA0000' + assertFileExists $xautolockService + assertFileRegex $xautolockService 'ExecStart=.*/bin/xautolock.*-time 5.*-detectsleep.*-test.*' + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/services/screen-locker/default.nix b/third_party/home-manager/tests/modules/services/screen-locker/default.nix new file mode 100644 index 0000000000..667defc517 --- /dev/null +++ b/third_party/home-manager/tests/modules/services/screen-locker/default.nix @@ -0,0 +1,5 @@ +{ + screen-locker-basic-configuration = ./basic-configuration.nix; + screen-locker-no-xautolock = ./no-xautolock.nix; + screen-locker-moved-options = ./moved-options.nix; +} diff --git a/third_party/home-manager/tests/modules/services/screen-locker/moved-options.nix b/third_party/home-manager/tests/modules/services/screen-locker/moved-options.nix new file mode 100644 index 0000000000..4c9cad19ee --- /dev/null +++ b/third_party/home-manager/tests/modules/services/screen-locker/moved-options.nix @@ -0,0 +1,36 @@ +{ config, pkgs, options, lib, ... }: + +{ + config = { + services.screen-locker = { + enable = true; + inactiveInterval = 5; + lockCmd = "${pkgs.i3lock}/bin/i3lock -n -c AA0000"; + xssLockExtraOptions = [ "-test" ]; + xautolockExtraOptions = [ "-test" ]; + enableDetectSleep = true; + }; + + test.stubs.i3lock = { }; + test.stubs.xss-lock = { }; + + # Use the same verification script as the basic configuration. The result + # with the old options should be identical. + nmt.script = (import ./basic-configuration.nix { + inherit config pkgs; + }).config.nmt.script; + + test.asserts.warnings.expected = with lib; + let + renamed = { + xssLockExtraOptions = "xss-lock.extraOptions"; + xautolockExtraOptions = "xautolock.extraOptions"; + enableDetectSleep = "xautolock.detectSleep"; + }; + in mapAttrsToList (old: new: + builtins.replaceStrings [ "\n" ] [ " " ] '' + The option `services.screen-locker.${old}' defined in + ${showFiles options.services.screen-locker.${old}.files} + has been renamed to `services.screen-locker.${new}'.'') renamed; + }; +} diff --git a/third_party/home-manager/tests/modules/services/screen-locker/no-xautolock.nix b/third_party/home-manager/tests/modules/services/screen-locker/no-xautolock.nix new file mode 100644 index 0000000000..03ab0868cb --- /dev/null +++ b/third_party/home-manager/tests/modules/services/screen-locker/no-xautolock.nix @@ -0,0 +1,24 @@ +{ config, pkgs, ... }: + +{ + config = { + services.screen-locker = { + enable = true; + inactiveInterval = 5; + lockCmd = "${pkgs.i3lock}/bin/i3lock -n -c AA0000"; + xss-lock = { extraOptions = [ "-test" ]; }; + xautolock = { enable = false; }; + }; + + test.stubs.i3lock = { }; + test.stubs.xss-lock = { }; + + nmt.script = '' + xssService=home-files/.config/systemd/user/xss-lock.service + + assertFileExists $xssService + assertFileRegex $xssService 'ExecStart=.*/bin/xss-lock.*-test.*i3lock -n -c AA0000' + assertFileRegex $xssService 'ExecStartPre=.*/xset s 300' + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/services/sxhkd/configuration.nix b/third_party/home-manager/tests/modules/services/sxhkd/configuration.nix index e9d85477b0..9e99650519 100644 --- a/third_party/home-manager/tests/modules/services/sxhkd/configuration.nix +++ b/third_party/home-manager/tests/modules/services/sxhkd/configuration.nix @@ -1,34 +1,32 @@ -{ config, pkgs, ... }: { - config = { - services.sxhkd = { - enable = true; +{ config, pkgs, ... }: - package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out" // { - outPath = "@sxhkd@"; - }; +{ + services.sxhkd = { + enable = true; - keybindings = { - "super + a" = "run command a"; - "super + b" = null; - "super + Shift + b" = "run command b"; - }; + package = config.lib.test.mkStubPackage { outPath = "@sxhkd@"; }; - extraConfig = '' - super + c - call command c - - # comment - super + d - call command d - ''; + keybindings = { + "super + a" = "run command a"; + "super + b" = null; + "super + Shift + b" = "run command b"; }; - nmt.script = '' - sxhkdrc=home-files/.config/sxhkd/sxhkdrc + extraConfig = '' + super + c + call command c - assertFileExists $sxhkdrc - - assertFileContent $sxhkdrc ${./sxhkdrc} + # comment + super + d + call command d ''; }; + + nmt.script = '' + sxhkdrc=home-files/.config/sxhkd/sxhkdrc + + assertFileExists $sxhkdrc + + assertFileContent $sxhkdrc ${./sxhkdrc} + ''; } diff --git a/third_party/home-manager/tests/modules/services/sxhkd/service.nix b/third_party/home-manager/tests/modules/services/sxhkd/service.nix index be51f544c5..84f3086a8b 100644 --- a/third_party/home-manager/tests/modules/services/sxhkd/service.nix +++ b/third_party/home-manager/tests/modules/services/sxhkd/service.nix @@ -1,28 +1,26 @@ { config, pkgs, ... }: { - config = { - xsession = { - enable = true; - windowManager.command = ""; - }; - - services.sxhkd = { - enable = true; - package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out" // { outPath = "@sxhkd@"; }; - extraOptions = [ "-m 1" ]; - }; - - nmt.script = '' - xsessionFile=home-files/.xsession - - assertFileExists $xsessionFile - - assertFileContains $xsessionFile \ - 'systemctl --user stop sxhkd.scope 2> /dev/null || true' - - assertFileContains $xsessionFile \ - 'systemd-cat -t sxhkd systemd-run --user --scope -u sxhkd @sxhkd@/bin/sxhkd -m 1 &' - ''; + xsession = { + enable = true; + windowManager.command = ""; }; + + services.sxhkd = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@sxhkd@"; }; + extraOptions = [ "-m 1" ]; + }; + + nmt.script = '' + xsessionFile=home-files/.xsession + + assertFileExists $xsessionFile + + assertFileContains $xsessionFile \ + 'systemctl --user stop sxhkd.scope 2> /dev/null || true' + + assertFileContains $xsessionFile \ + 'systemd-cat -t sxhkd systemd-run --user --scope -u sxhkd @sxhkd@/bin/sxhkd -m 1 &' + ''; } diff --git a/third_party/home-manager/tests/modules/services/syncthing/tray-as-bool-triggers-warning.nix b/third_party/home-manager/tests/modules/services/syncthing/tray-as-bool-triggers-warning.nix index 9f9dc2ba90..ca018c2d8a 100644 --- a/third_party/home-manager/tests/modules/services/syncthing/tray-as-bool-triggers-warning.nix +++ b/third_party/home-manager/tests/modules/services/syncthing/tray-as-bool-triggers-warning.nix @@ -6,14 +6,12 @@ with lib; config = { services.syncthing.tray = true; - nixpkgs.overlays = [ - (self: super: { syncthingtray-minimal = pkgs.writeScriptBin "dummy" ""; }) - ]; - test.asserts.warnings.expected = [ "Specifying 'services.syncthing.tray' as a boolean is deprecated, set 'services.syncthing.tray.enable' instead. See https://github.com/nix-community/home-manager/pull/1257." ]; + test.stubs.syncthingtray-minimal = { }; + nmt.script = '' assertFileExists home-files/.config/systemd/user/syncthingtray.service ''; diff --git a/third_party/home-manager/tests/modules/services/trayer/basic-configuration.nix b/third_party/home-manager/tests/modules/services/trayer/basic-configuration.nix new file mode 100644 index 0000000000..3020e6310f --- /dev/null +++ b/third_party/home-manager/tests/modules/services/trayer/basic-configuration.nix @@ -0,0 +1,27 @@ +{ config, pkgs, ... }: + +{ + config = { + services.trayer = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@trayer@"; }; + settings = { + edge = "top"; + padding = 6; + SetDockType = true; + tint = "0x282c34"; + SetPartialStrut = true; + expand = true; + monitor = 1; + }; + }; + + nmt.script = '' + serviceFile=home-files/.config/systemd/user/trayer.service + + assertFileExists $serviceFile + assertFileContains $serviceFile \ + 'ExecStart=@trayer@/bin/trayer --SetDockType true --SetPartialStrut true --edge top --expand true --monitor 1 --padding 6 --tint 0x282c34' + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/services/trayer/default.nix b/third_party/home-manager/tests/modules/services/trayer/default.nix new file mode 100644 index 0000000000..f8672b59e5 --- /dev/null +++ b/third_party/home-manager/tests/modules/services/trayer/default.nix @@ -0,0 +1 @@ +{ trayer-basic-configuration = ./basic-configuration.nix; } diff --git a/third_party/home-manager/tests/modules/services/window-managers/bspwm/configuration.nix b/third_party/home-manager/tests/modules/services/window-managers/bspwm/configuration.nix index 6c1effb628..8018a3ac18 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/bspwm/configuration.nix +++ b/third_party/home-manager/tests/modules/services/window-managers/bspwm/configuration.nix @@ -28,6 +28,8 @@ with lib; startupPrograms = [ "foo" "bar || qux" ]; }; + test.stubs.bspwm = { }; + nmt.script = '' bspwmrc=home-files/.config/bspwm/bspwmrc assertFileExists "$bspwmrc" diff --git a/third_party/home-manager/tests/modules/services/window-managers/i3/i3-bar-focused-colors.nix b/third_party/home-manager/tests/modules/services/window-managers/i3/i3-bar-focused-colors.nix index aaa6809f5b..66b4ca87a4 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/i3/i3-bar-focused-colors.nix +++ b/third_party/home-manager/tests/modules/services/window-managers/i3/i3-bar-focused-colors.nix @@ -1,25 +1,21 @@ { config, lib, ... }: -with lib; - { - config = { - xsession.windowManager.i3 = { - enable = true; + imports = [ ./i3-stubs.nix ]; - config.bars = [{ - colors.focusedBackground = "#ffffff"; - colors.focusedStatusline = "#000000"; - colors.focusedSeparator = "#999999"; - }]; - }; + xsession.windowManager.i3 = { + enable = true; - nixpkgs.overlays = [ (import ./i3-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/i3/config - assertFileContent home-files/.config/i3/config \ - ${./i3-bar-focused-colors-expected.conf} - ''; + config.bars = [{ + colors.focusedBackground = "#ffffff"; + colors.focusedStatusline = "#000000"; + colors.focusedSeparator = "#999999"; + }]; }; + + nmt.script = '' + assertFileExists home-files/.config/i3/config + assertFileContent home-files/.config/i3/config \ + ${./i3-bar-focused-colors-expected.conf} + ''; } diff --git a/third_party/home-manager/tests/modules/services/window-managers/i3/i3-fonts-deprecated.nix b/third_party/home-manager/tests/modules/services/window-managers/i3/i3-fonts-deprecated.nix index c5142ed457..7e4532e571 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/i3/i3-fonts-deprecated.nix +++ b/third_party/home-manager/tests/modules/services/window-managers/i3/i3-fonts-deprecated.nix @@ -1,29 +1,25 @@ { config, lib, ... }: -with lib; - { - config = { - xsession.windowManager.i3 = { - enable = true; + imports = [ ./i3-stubs.nix ]; - config = { - bars = [{ fonts = [ "FontAwesome" "Iosevka 11.500000" ]; }]; - fonts = [ "DejaVuSansMono" "Terminus Bold Semi-Condensed 13.500000" ]; - }; + xsession.windowManager.i3 = { + enable = true; + + config = { + bars = [{ fonts = [ "FontAwesome" "Iosevka 11.500000" ]; }]; + fonts = [ "DejaVuSansMono" "Terminus Bold Semi-Condensed 13.500000" ]; }; - - nixpkgs.overlays = [ (import ./i3-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/i3/config - assertFileContent home-files/.config/i3/config \ - ${./i3-fonts-expected.conf} - ''; - - test.asserts.warnings.expected = [ - "Specifying i3.config.fonts as a list is deprecated. Use the attrset version instead." - "Specifying i3.config.bars[].fonts as a list is deprecated. Use the attrset version instead." - ]; }; + + nmt.script = '' + assertFileExists home-files/.config/i3/config + assertFileContent home-files/.config/i3/config \ + ${./i3-fonts-expected.conf} + ''; + + test.asserts.warnings.expected = [ + "Specifying i3.config.fonts as a list is deprecated. Use the attrset version instead." + "Specifying i3.config.bars[].fonts as a list is deprecated. Use the attrset version instead." + ]; } diff --git a/third_party/home-manager/tests/modules/services/window-managers/i3/i3-fonts.nix b/third_party/home-manager/tests/modules/services/window-managers/i3/i3-fonts.nix index 20ea5cabe3..3618451f84 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/i3/i3-fonts.nix +++ b/third_party/home-manager/tests/modules/services/window-managers/i3/i3-fonts.nix @@ -1,33 +1,29 @@ { config, lib, ... }: -with lib; - { - config = { - xsession.windowManager.i3 = { - enable = true; + imports = [ ./i3-stubs.nix ]; - config = { - bars = [{ - fonts = { - names = [ "FontAwesome" "Iosevka" ]; - size = 11.5; - }; - }]; + xsession.windowManager.i3 = { + enable = true; + + config = { + bars = [{ fonts = { - names = [ "DejaVuSansMono" "Terminus" ]; - style = "Bold Semi-Condensed"; - size = 13.5; + names = [ "FontAwesome" "Iosevka" ]; + size = 11.5; }; + }]; + fonts = { + names = [ "DejaVuSansMono" "Terminus" ]; + style = "Bold Semi-Condensed"; + size = 13.5; }; }; - - nixpkgs.overlays = [ (import ./i3-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/i3/config - assertFileContent home-files/.config/i3/config \ - ${./i3-fonts-expected.conf} - ''; }; + + nmt.script = '' + assertFileExists home-files/.config/i3/config + assertFileContent home-files/.config/i3/config \ + ${./i3-fonts-expected.conf} + ''; } diff --git a/third_party/home-manager/tests/modules/services/window-managers/i3/i3-keybindings.nix b/third_party/home-manager/tests/modules/services/window-managers/i3/i3-keybindings.nix index bc3cae6e0f..2137c53edb 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/i3/i3-keybindings.nix +++ b/third_party/home-manager/tests/modules/services/window-managers/i3/i3-keybindings.nix @@ -1,27 +1,23 @@ { config, lib, ... }: -with lib; - { - config = { - xsession.windowManager.i3 = { - enable = true; + imports = [ ./i3-stubs.nix ]; - config.keybindings = - let modifier = config.xsession.windowManager.i3.config.modifier; - in lib.mkOptionDefault { - "${modifier}+Left" = "overridden-command"; - "${modifier}+Right" = null; - "${modifier}+Invented" = "invented-key-command"; - }; - }; + xsession.windowManager.i3 = { + enable = true; - nixpkgs.overlays = [ (import ./i3-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/i3/config - assertFileContent home-files/.config/i3/config \ - ${./i3-keybindings-expected.conf} - ''; + config.keybindings = + let modifier = config.xsession.windowManager.i3.config.modifier; + in lib.mkOptionDefault { + "${modifier}+Left" = "overridden-command"; + "${modifier}+Right" = null; + "${modifier}+Invented" = "invented-key-command"; + }; }; + + nmt.script = '' + assertFileExists home-files/.config/i3/config + assertFileContent home-files/.config/i3/config \ + ${./i3-keybindings-expected.conf} + ''; } diff --git a/third_party/home-manager/tests/modules/services/window-managers/i3/i3-null-config.nix b/third_party/home-manager/tests/modules/services/window-managers/i3/i3-null-config.nix index a9b3788245..1c221319b2 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/i3/i3-null-config.nix +++ b/third_party/home-manager/tests/modules/services/window-managers/i3/i3-null-config.nix @@ -1,20 +1,16 @@ { config, lib, pkgs, ... }: -with lib; - { - config = { - xsession.windowManager.i3 = { - enable = true; - config = null; - }; + imports = [ ./i3-stubs.nix ]; - nixpkgs.overlays = [ (import ./i3-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/i3/config - assertFileContent home-files/.config/i3/config \ - ${pkgs.writeText "expected" "\n"} - ''; + xsession.windowManager.i3 = { + enable = true; + config = null; }; + + nmt.script = '' + assertFileExists home-files/.config/i3/config + assertFileContent home-files/.config/i3/config \ + ${pkgs.writeText "expected" "\n"} + ''; } diff --git a/third_party/home-manager/tests/modules/services/window-managers/i3/i3-overlay.nix b/third_party/home-manager/tests/modules/services/window-managers/i3/i3-overlay.nix deleted file mode 100644 index fead262f47..0000000000 --- a/third_party/home-manager/tests/modules/services/window-managers/i3/i3-overlay.nix +++ /dev/null @@ -1,12 +0,0 @@ -self: super: -# Avoid unnecessary downloads in CI jobs and/or make out paths -# constant, i.e., not containing hashes, version numbers etc. -{ - dmenu = super.dmenu // { outPath = "@dmenu@"; }; - - i3 = super.writeScriptBin "i3" "" // { outPath = "@i3@"; }; - - i3-gaps = super.writeScriptBin "i3" "" // { outPath = "@i3-gaps@"; }; - - i3status = super.i3status // { outPath = "@i3status@"; }; -} diff --git a/third_party/home-manager/tests/modules/services/window-managers/i3/i3-stubs.nix b/third_party/home-manager/tests/modules/services/window-managers/i3/i3-stubs.nix new file mode 100644 index 0000000000..cfb892ace8 --- /dev/null +++ b/third_party/home-manager/tests/modules/services/window-managers/i3/i3-stubs.nix @@ -0,0 +1,19 @@ +{ + # Avoid unnecessary downloads in CI jobs and/or make out paths constant, i.e., + # not containing hashes, version numbers etc. + test.stubs = { + dmenu = { }; + + i3 = { + buildScript = '' + mkdir -p $out/bin + echo '#!/bin/sh' > $out/bin/i3 + chmod 755 $out/bin/i3 + ''; + }; + + i3-gaps = { }; + + i3status = { }; + }; +} diff --git a/third_party/home-manager/tests/modules/services/window-managers/i3/i3-workspace-default.nix b/third_party/home-manager/tests/modules/services/window-managers/i3/i3-workspace-default.nix index 0a825b1e86..521b5f5d75 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/i3/i3-workspace-default.nix +++ b/third_party/home-manager/tests/modules/services/window-managers/i3/i3-workspace-default.nix @@ -1,21 +1,17 @@ { config, lib, ... }: -with lib; - { - config = { - xsession.windowManager.i3 = { - enable = true; + imports = [ ./i3-stubs.nix ]; - config.defaultWorkspace = "workspace number 1"; - }; + xsession.windowManager.i3 = { + enable = true; - nixpkgs.overlays = [ (import ./i3-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/i3/config - assertFileContent home-files/.config/i3/config \ - ${./i3-workspace-default-expected.conf} - ''; + config.defaultWorkspace = "workspace number 1"; }; + + nmt.script = '' + assertFileExists home-files/.config/i3/config + assertFileContent home-files/.config/i3/config \ + ${./i3-workspace-default-expected.conf} + ''; } diff --git a/third_party/home-manager/tests/modules/services/window-managers/i3/i3-workspace-output.nix b/third_party/home-manager/tests/modules/services/window-managers/i3/i3-workspace-output.nix index b2ff90e028..df4a2c7890 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/i3/i3-workspace-output.nix +++ b/third_party/home-manager/tests/modules/services/window-managers/i3/i3-workspace-output.nix @@ -1,46 +1,42 @@ { config, lib, ... }: -with lib; - -{ - config = let - i3 = { - ws1 = "1"; - ws2 = "ABC"; - ws3 = "3: Test"; - ws4 = ''!"§$%&/(){}[]=?\*#<>-_.:,;²³''; - }; - - in { - xsession.windowManager.i3 = { - enable = true; - - config.workspaceOutputAssign = [ - { - workspace = "${i3.ws1}"; - output = "eDP"; - } - { - workspace = "${i3.ws2}"; - output = "DP"; - } - { - workspace = "${i3.ws3}"; - output = "HDMI"; - } - { - workspace = "${i3.ws4}"; - output = "DVI"; - } - ]; - }; - - nixpkgs.overlays = [ (import ./i3-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/i3/config - assertFileContent home-files/.config/i3/config \ - ${./i3-workspace-output-expected.conf} - ''; +let + i3 = { + ws1 = "1"; + ws2 = "ABC"; + ws3 = "3: Test"; + ws4 = ''!"§$%&/(){}[]=?\*#<>-_.:,;²³''; }; + +in { + imports = [ ./i3-stubs.nix ]; + + xsession.windowManager.i3 = { + enable = true; + + config.workspaceOutputAssign = [ + { + workspace = "${i3.ws1}"; + output = "eDP"; + } + { + workspace = "${i3.ws2}"; + output = "DP"; + } + { + workspace = "${i3.ws3}"; + output = "HDMI"; + } + { + workspace = "${i3.ws4}"; + output = "DVI"; + } + ]; + }; + + nmt.script = '' + assertFileExists home-files/.config/i3/config + assertFileContent home-files/.config/i3/config \ + ${./i3-workspace-output-expected.conf} + ''; } diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/default.nix b/third_party/home-manager/tests/modules/services/window-managers/sway/default.nix index 16f7751cb0..9ee4798787 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/sway/default.nix +++ b/third_party/home-manager/tests/modules/services/window-managers/sway/default.nix @@ -1,12 +1,13 @@ { sway-bar-focused-colors = ./sway-bar-focused-colors.nix; + sway-bindkeys-to-code = ./sway-bindkeys-to-code.nix; sway-default = ./sway-default.nix; - sway-post-2003 = ./sway-post-2003.nix; sway-followmouse = ./sway-followmouse.nix; sway-followmouse-legacy = ./sway-followmouse-legacy.nix; + sway-modules = ./sway-modules.nix; sway-null-config = ./sway-null-config.nix; sway-null-package = ./sway-null-package.nix; - sway-modules = ./sway-modules.nix; + sway-post-2003 = ./sway-post-2003.nix; sway-workspace-default = ./sway-workspace-default.nix; sway-workspace-output = ./sway-workspace-output.nix; } diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-bar-focused-colors.conf b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-bar-focused-colors.conf index dc8319d6b8..558e579aee 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-bar-focused-colors.conf +++ b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-bar-focused-colors.conf @@ -90,7 +90,7 @@ bar { hidden_state hide position bottom status_command @i3status@/bin/i3status - swaybar_command @sway/bin/swaybar + swaybar_command @sway@/bin/swaybar workspace_buttons yes strip_workspace_numbers no tray_output primary diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-bar-focused-colors.nix b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-bar-focused-colors.nix index 8b3df36ef1..9746d05038 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-bar-focused-colors.nix +++ b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-bar-focused-colors.nix @@ -1,32 +1,24 @@ { config, lib, pkgs, ... }: -with lib; +{ + imports = [ ./sway-stubs.nix ]; -let + wayland.windowManager.sway = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@sway@"; }; + # overriding findutils causes issues + config.menu = "${pkgs.dmenu}/bin/dmenu_run"; - dummy-package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out"; - -in { - config = { - wayland.windowManager.sway = { - enable = true; - package = dummy-package // { outPath = "@sway"; }; - # overriding findutils causes issues - config.menu = "${pkgs.dmenu}/bin/dmenu_run"; - - config.bars = [{ - colors.focusedBackground = "#ffffff"; - colors.focusedStatusline = "#000000"; - colors.focusedSeparator = "#999999"; - }]; - }; - - nixpkgs.overlays = [ (import ./sway-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/sway/config - assertFileContent home-files/.config/sway/config \ - ${./sway-bar-focused-colors.conf} - ''; + config.bars = [{ + colors.focusedBackground = "#ffffff"; + colors.focusedStatusline = "#000000"; + colors.focusedSeparator = "#999999"; + }]; }; + + nmt.script = '' + assertFileExists home-files/.config/sway/config + assertFileContent home-files/.config/sway/config \ + ${./sway-bar-focused-colors.conf} + ''; } diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-bindkeys-to-code.conf b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-bindkeys-to-code.conf new file mode 100644 index 0000000000..7879ceab1b --- /dev/null +++ b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-bindkeys-to-code.conf @@ -0,0 +1,114 @@ +font pango:monospace 8.000000 +floating_modifier Mod1 +default_border pixel 2 +default_floating_border pixel 2 +hide_edge_borders none +focus_wrapping no +focus_follows_mouse yes +focus_on_window_activation smart +mouse_warping output +workspace_layout default +workspace_auto_back_and_forth no + +client.focused #4c7899 #285577 #ffffff #2e9ef4 #285577 +client.focused_inactive #333333 #5f676a #ffffff #484e50 #5f676a +client.unfocused #333333 #222222 #888888 #292d2e #222222 +client.urgent #2f343a #900000 #ffffff #900000 #900000 +client.placeholder #000000 #0c0c0c #ffffff #000000 #0c0c0c +client.background #ffffff + + +bindsym --to-code Mod1+1 workspace number 1 +bindsym --to-code Mod1+2 workspace number 2 +bindsym --to-code Mod1+3 workspace number 3 +bindsym --to-code Mod1+4 workspace number 4 +bindsym --to-code Mod1+5 workspace number 5 +bindsym --to-code Mod1+6 workspace number 6 +bindsym --to-code Mod1+7 workspace number 7 +bindsym --to-code Mod1+8 workspace number 8 +bindsym --to-code Mod1+9 workspace number 9 +bindsym --to-code Mod1+Down focus down +bindsym --to-code Mod1+Left focus left +bindsym --to-code Mod1+Return exec @rxvt-unicode-unwrapped@/bin/urxvt +bindsym --to-code Mod1+Right focus right +bindsym --to-code Mod1+Shift+1 move container to workspace number 1 +bindsym --to-code Mod1+Shift+2 move container to workspace number 2 +bindsym --to-code Mod1+Shift+3 move container to workspace number 3 +bindsym --to-code Mod1+Shift+4 move container to workspace number 4 +bindsym --to-code Mod1+Shift+5 move container to workspace number 5 +bindsym --to-code Mod1+Shift+6 move container to workspace number 6 +bindsym --to-code Mod1+Shift+7 move container to workspace number 7 +bindsym --to-code Mod1+Shift+8 move container to workspace number 8 +bindsym --to-code Mod1+Shift+9 move container to workspace number 9 +bindsym --to-code Mod1+Shift+Down move down +bindsym --to-code Mod1+Shift+Left move left +bindsym --to-code Mod1+Shift+Right move right +bindsym --to-code Mod1+Shift+Up move up +bindsym --to-code Mod1+Shift+c reload +bindsym --to-code Mod1+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'swaymsg exit' +bindsym --to-code Mod1+Shift+h move left +bindsym --to-code Mod1+Shift+j move down +bindsym --to-code Mod1+Shift+k move up +bindsym --to-code Mod1+Shift+l move right +bindsym --to-code Mod1+Shift+minus move scratchpad +bindsym --to-code Mod1+Shift+q kill +bindsym --to-code Mod1+Shift+space floating toggle +bindsym --to-code Mod1+Up focus up +bindsym --to-code Mod1+a focus parent +bindsym --to-code Mod1+b splith +bindsym --to-code Mod1+d exec @dmenu@/bin/dmenu_run +bindsym --to-code Mod1+e layout toggle split +bindsym --to-code Mod1+f fullscreen toggle +bindsym --to-code Mod1+h focus left +bindsym --to-code Mod1+j focus down +bindsym --to-code Mod1+k focus up +bindsym --to-code Mod1+l focus right +bindsym --to-code Mod1+minus scratchpad show +bindsym --to-code Mod1+r mode resize +bindsym --to-code Mod1+s layout stacking +bindsym --to-code Mod1+space focus mode_toggle +bindsym --to-code Mod1+v splitv +bindsym --to-code Mod1+w layout tabbed + +mode "resize" { +bindsym --to-code Down resize grow height 10 px +bindsym --to-code Escape mode default +bindsym --to-code Left resize shrink width 10 px +bindsym --to-code Return mode default +bindsym --to-code Right resize grow width 10 px +bindsym --to-code Up resize shrink height 10 px +bindsym --to-code h resize shrink width 10 px +bindsym --to-code j resize grow height 10 px +bindsym --to-code k resize shrink height 10 px +bindsym --to-code l resize grow width 10 px +} + +bar { + + font pango:monospace 8.000000 + mode dock + hidden_state hide + position bottom + status_command @i3status@/bin/i3status + swaybar_command @sway@/bin/swaybar + workspace_buttons yes + strip_workspace_numbers no + tray_output primary + colors { + background #000000 + statusline #ffffff + separator #666666 + + + + focused_workspace #4c7899 #285577 #ffffff + active_workspace #333333 #5f676a #ffffff + inactive_workspace #333333 #222222 #888888 + urgent_workspace #2f343a #900000 #ffffff + binding_mode #2f343a #900000 #ffffff + } + +} + + +exec "systemctl --user import-environment; systemctl --user start sway-session.target" diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-bindkeys-to-code.nix b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-bindkeys-to-code.nix new file mode 100644 index 0000000000..5e62748cb9 --- /dev/null +++ b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-bindkeys-to-code.nix @@ -0,0 +1,19 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ ./sway-stubs.nix ]; + + wayland.windowManager.sway = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@sway@"; }; + # overriding findutils causes issues + config.menu = "${pkgs.dmenu}/bin/dmenu_run"; + config.bindkeysToCode = true; + }; + + nmt.script = '' + assertFileExists home-files/.config/sway/config + assertFileContent home-files/.config/sway/config \ + ${./sway-bindkeys-to-code.conf} + ''; +} diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-default.conf b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-default.conf index cbcd2d8320..1cd75fd522 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-default.conf +++ b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-default.conf @@ -90,7 +90,7 @@ bar { hidden_state hide position bottom status_command @i3status@/bin/i3status - swaybar_command @sway/bin/swaybar + swaybar_command @sway@/bin/swaybar workspace_buttons yes strip_workspace_numbers no tray_output primary diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-default.nix b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-default.nix index 141f6303e2..7bd4373174 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-default.nix +++ b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-default.nix @@ -1,26 +1,18 @@ { config, lib, pkgs, ... }: -with lib; +{ + imports = [ ./sway-stubs.nix ]; -let - - dummy-package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out"; - -in { - config = { - wayland.windowManager.sway = { - enable = true; - package = dummy-package // { outPath = "@sway"; }; - # overriding findutils causes issues - config.menu = "${pkgs.dmenu}/bin/dmenu_run"; - }; - - nixpkgs.overlays = [ (import ./sway-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/sway/config - assertFileContent home-files/.config/sway/config \ - ${./sway-default.conf} - ''; + wayland.windowManager.sway = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@sway@"; }; + # overriding findutils causes issues + config.menu = "${pkgs.dmenu}/bin/dmenu_run"; }; + + nmt.script = '' + assertFileExists home-files/.config/sway/config + assertFileContent home-files/.config/sway/config \ + ${./sway-default.conf} + ''; } diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-followmouse-legacy.nix b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-followmouse-legacy.nix index b83c8d1ba2..ce69d9f7fb 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-followmouse-legacy.nix +++ b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-followmouse-legacy.nix @@ -2,29 +2,23 @@ with lib; -let +{ + imports = [ ./sway-stubs.nix ]; - dummy-package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out"; + wayland.windowManager.sway = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@sway@"; }; -in { - config = { - wayland.windowManager.sway = { - enable = true; - package = dummy-package // { outPath = "@sway"; }; - - config = { - focus.followMouse = false; - menu = "${pkgs.dmenu}/bin/dmenu_run"; - bars = [ ]; - }; + config = { + focus.followMouse = false; + menu = "${pkgs.dmenu}/bin/dmenu_run"; + bars = [ ]; }; - - nixpkgs.overlays = [ (import ./sway-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/sway/config - assertFileContent home-files/.config/sway/config \ - ${./sway-followmouse-legacy-expected.conf} - ''; }; + + nmt.script = '' + assertFileExists home-files/.config/sway/config + assertFileContent home-files/.config/sway/config \ + ${./sway-followmouse-legacy-expected.conf} + ''; } diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-followmouse.nix b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-followmouse.nix index 9d18b6913e..7065dd1ca5 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-followmouse.nix +++ b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-followmouse.nix @@ -1,30 +1,22 @@ { config, lib, pkgs, ... }: -with lib; +{ + imports = [ ./sway-stubs.nix ]; -let + wayland.windowManager.sway = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@sway@"; }; - dummy-package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out"; - -in { - config = { - wayland.windowManager.sway = { - enable = true; - package = dummy-package // { outPath = "@sway"; }; - - config = { - focus.followMouse = "always"; - menu = "${pkgs.dmenu}/bin/dmenu_run"; - bars = [ ]; - }; + config = { + focus.followMouse = "always"; + menu = "${pkgs.dmenu}/bin/dmenu_run"; + bars = [ ]; }; - - nixpkgs.overlays = [ (import ./sway-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/sway/config - assertFileContent home-files/.config/sway/config \ - ${./sway-followmouse-expected.conf} - ''; }; + + nmt.script = '' + assertFileExists home-files/.config/sway/config + assertFileContent home-files/.config/sway/config \ + ${./sway-followmouse-expected.conf} + ''; } diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-modules.conf b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-modules.conf index ee63330544..1cec60e8bb 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-modules.conf +++ b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-modules.conf @@ -102,7 +102,7 @@ bar { hidden_state hide position bottom status_command @i3status@/bin/i3status - swaybar_command @sway/bin/swaybar + swaybar_command @sway@/bin/swaybar workspace_buttons yes strip_workspace_numbers no tray_output primary diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-modules.nix b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-modules.nix index fbe927f35b..96366ab0a2 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-modules.nix +++ b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-modules.nix @@ -1,32 +1,24 @@ { config, lib, pkgs, ... }: -with lib; +{ + imports = [ ./sway-stubs.nix ]; -let + wayland.windowManager.sway = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@sway@"; }; + # overriding findutils causes issues + config = { + menu = "${pkgs.dmenu}/bin/dmenu_run"; - dummy-package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out"; - -in { - config = { - wayland.windowManager.sway = { - enable = true; - package = dummy-package // { outPath = "@sway"; }; - # overriding findutils causes issues - config = { - menu = "${pkgs.dmenu}/bin/dmenu_run"; - - input = { "*" = { xkb_variant = "dvorak"; }; }; - output = { "HDMI-A-2" = { bg = "~/path/to/background.png fill"; }; }; - seat = { "*" = { hide_cursor = "when-typing enable"; }; }; - }; + input = { "*" = { xkb_variant = "dvorak"; }; }; + output = { "HDMI-A-2" = { bg = "~/path/to/background.png fill"; }; }; + seat = { "*" = { hide_cursor = "when-typing enable"; }; }; }; - - nixpkgs.overlays = [ (import ./sway-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/sway/config - assertFileContent home-files/.config/sway/config \ - ${./sway-modules.conf} - ''; }; + + nmt.script = '' + assertFileExists home-files/.config/sway/config + assertFileContent home-files/.config/sway/config \ + ${./sway-modules.conf} + ''; } diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-null-config.nix b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-null-config.nix index fc01660cbd..4033903d37 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-null-config.nix +++ b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-null-config.nix @@ -1,22 +1,18 @@ { config, lib, pkgs, ... }: -with lib; - { - config = { - wayland.windowManager.sway = { - enable = true; - config = null; - systemdIntegration = false; - package = pkgs.sway; - }; + imports = [ ./sway-stubs.nix ]; - nixpkgs.overlays = [ (import ./sway-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/sway/config - assertFileContent home-files/.config/sway/config \ - ${pkgs.writeText "expected" "\n"} - ''; + wayland.windowManager.sway = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@sway@"; }; + config = null; + systemdIntegration = false; }; + + nmt.script = '' + assertFileExists home-files/.config/sway/config + assertFileContent home-files/.config/sway/config \ + ${pkgs.writeText "expected" "\n"} + ''; } diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-null-package.nix b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-null-package.nix index 3993d6389e..fe2a451961 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-null-package.nix +++ b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-null-package.nix @@ -1,35 +1,27 @@ { config, lib, pkgs, ... }: -with lib; +{ + imports = [ ./sway-stubs.nix ]; -let + # Enables the default bar configuration + home.stateVersion = "20.09"; - dummy-package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out"; - -in { - config = { - # Enables the default bar configuration - home.stateVersion = "20.09"; - - wayland.windowManager.sway = { - enable = true; - package = null; - config.menu = "${pkgs.dmenu}/bin/dmenu_run"; - }; - - nixpkgs.overlays = [ (import ./sway-overlay.nix) ]; - - assertions = [{ - assertion = - !elem config.wayland.windowManager.sway.config.bars [ [ { } ] [ ] ]; - message = - "The default Sway bars configuration should be set for this test (sway-null-package) to work."; - }]; - - nmt.script = '' - assertFileExists home-files/.config/sway/config - assertFileContent home-files/.config/sway/config \ - ${./sway-null-package.conf} - ''; + wayland.windowManager.sway = { + enable = true; + package = null; + config.menu = "${pkgs.dmenu}/bin/dmenu_run"; }; + + assertions = [{ + assertion = + !lib.elem config.wayland.windowManager.sway.config.bars [ [ { } ] [ ] ]; + message = + "The default Sway bars configuration should be set for this test (sway-null-package) to work."; + }]; + + nmt.script = '' + assertFileExists home-files/.config/sway/config + assertFileContent home-files/.config/sway/config \ + ${./sway-null-package.conf} + ''; } diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-overlay.nix b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-overlay.nix deleted file mode 100644 index 4edfb20557..0000000000 --- a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-overlay.nix +++ /dev/null @@ -1,17 +0,0 @@ -self: super: -# Avoid unnecessary downloads in CI jobs. -let dummy-package = super.runCommandLocal "dummy-package" { } "mkdir $out"; -in { - dmenu = dummy-package // { outPath = "@dmenu@"; }; - rxvt-unicode-unwrapped = dummy-package // { - outPath = "@rxvt-unicode-unwrapped@"; - }; - i3status = dummy-package // { outPath = "@i3status@"; }; - sway = dummy-package // { outPath = "@sway@"; }; - sway-unwrapped = dummy-package // { - outPath = "@sway-unwrapped@"; - version = "1"; - }; - swaybg = dummy-package // { outPath = "@swaybg@"; }; - xwayland = dummy-package // { outPath = "@xwayland@"; }; -} diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-post-2003.nix b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-post-2003.nix index ddcf2b234f..7596250ec3 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-post-2003.nix +++ b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-post-2003.nix @@ -1,28 +1,20 @@ { config, lib, pkgs, ... }: -with lib; +{ + imports = [ ./sway-stubs.nix ]; -let + home.stateVersion = "20.09"; - dummy-package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out"; - -in { - config = { - home.stateVersion = "20.09"; - - wayland.windowManager.sway = { - enable = true; - package = dummy-package // { outPath = "@sway"; }; - # overriding findutils causes issues - config.menu = "${pkgs.dmenu}/bin/dmenu_run"; - }; - - nixpkgs.overlays = [ (import ./sway-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/sway/config - assertFileContent home-files/.config/sway/config \ - ${./sway-default.conf} - ''; + wayland.windowManager.sway = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@sway@"; }; + # overriding findutils causes issues + config.menu = "${pkgs.dmenu}/bin/dmenu_run"; }; + + nmt.script = '' + assertFileExists home-files/.config/sway/config + assertFileContent home-files/.config/sway/config \ + ${./sway-default.conf} + ''; } diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-stubs.nix b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-stubs.nix new file mode 100644 index 0000000000..55a74e1c47 --- /dev/null +++ b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-stubs.nix @@ -0,0 +1,13 @@ +{ + # Avoid unnecessary downloads in CI jobs and/or make out paths constant, i.e., + # not containing hashes, version numbers etc. + test.stubs = { + dmenu = { }; + rxvt-unicode-unwrapped = { }; + i3status = { }; + sway = { }; + sway-unwrapped = { version = "1"; }; + swaybg = { }; + xwayland = { }; + }; +} diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-workspace-default-expected.conf b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-workspace-default-expected.conf index 9441bf5cfd..7aa1e1e478 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-workspace-default-expected.conf +++ b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-workspace-default-expected.conf @@ -89,7 +89,7 @@ bar { hidden_state hide position bottom status_command @i3status@/bin/i3status - swaybar_command @sway/bin/swaybar + swaybar_command @sway@/bin/swaybar workspace_buttons yes strip_workspace_numbers no tray_output primary diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-workspace-default.nix b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-workspace-default.nix index 52f4f3ec18..d941109805 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-workspace-default.nix +++ b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-workspace-default.nix @@ -1,27 +1,19 @@ { config, lib, pkgs, ... }: -with lib; +{ + imports = [ ./sway-stubs.nix ]; -let - - dummy-package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out"; - -in { - config = { - wayland.windowManager.sway = { - enable = true; - package = dummy-package // { outPath = "@sway"; }; - # overriding findutils causes issues - config.menu = "${pkgs.dmenu}/bin/dmenu_run"; - config.defaultWorkspace = "workspace number 9"; - }; - - nixpkgs.overlays = [ (import ./sway-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/sway/config - assertFileContent home-files/.config/sway/config \ - ${./sway-workspace-default-expected.conf} - ''; + wayland.windowManager.sway = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@sway@"; }; + # overriding findutils causes issues + config.menu = "${pkgs.dmenu}/bin/dmenu_run"; + config.defaultWorkspace = "workspace number 9"; }; + + nmt.script = '' + assertFileExists home-files/.config/sway/config + assertFileContent home-files/.config/sway/config \ + ${./sway-workspace-default-expected.conf} + ''; } diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-workspace-output-expected.conf b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-workspace-output-expected.conf index 6ef9f6d134..e4a4f6cfd3 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-workspace-output-expected.conf +++ b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-workspace-output-expected.conf @@ -90,7 +90,7 @@ bar { hidden_state hide position bottom status_command @i3status@/bin/i3status - swaybar_command @sway/bin/swaybar + swaybar_command @sway@/bin/swaybar workspace_buttons yes strip_workspace_numbers no tray_output primary diff --git a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-workspace-output.nix b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-workspace-output.nix index 5791a3da43..ce51c1f519 100644 --- a/third_party/home-manager/tests/modules/services/window-managers/sway/sway-workspace-output.nix +++ b/third_party/home-manager/tests/modules/services/window-managers/sway/sway-workspace-output.nix @@ -1,53 +1,45 @@ { config, lib, pkgs, ... }: -with lib; - let - - dummy-package = pkgs.runCommandLocal "dummy-package" { } "mkdir $out"; + i3 = { + ws1 = "1"; + ws2 = "ABC"; + ws3 = "3: Test"; + ws4 = ''!"§$%&/(){}[]=?\*#<>-_.:,;²³''; + }; in { - config = let - i3 = { - ws1 = "1"; - ws2 = "ABC"; - ws3 = "3: Test"; - ws4 = ''!"§$%&/(){}[]=?\*#<>-_.:,;²³''; - }; + imports = [ ./sway-stubs.nix ]; - in { - wayland.windowManager.sway = { - enable = true; - package = dummy-package // { outPath = "@sway"; }; - # overriding findutils causes issues - config.menu = "${pkgs.dmenu}/bin/dmenu_run"; + wayland.windowManager.sway = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@sway@"; }; + # overriding findutils causes issues + config.menu = "${pkgs.dmenu}/bin/dmenu_run"; - config.workspaceOutputAssign = [ - { - workspace = "${i3.ws1}"; - output = "eDP"; - } - { - workspace = "${i3.ws2}"; - output = "DP"; - } - { - workspace = "${i3.ws3}"; - output = "HDMI"; - } - { - workspace = "${i3.ws4}"; - output = "DVI"; - } - ]; - }; - - nixpkgs.overlays = [ (import ./sway-overlay.nix) ]; - - nmt.script = '' - assertFileExists home-files/.config/sway/config - assertFileContent home-files/.config/sway/config \ - ${./sway-workspace-output-expected.conf} - ''; + config.workspaceOutputAssign = [ + { + workspace = "${i3.ws1}"; + output = "eDP"; + } + { + workspace = "${i3.ws2}"; + output = "DP"; + } + { + workspace = "${i3.ws3}"; + output = "HDMI"; + } + { + workspace = "${i3.ws4}"; + output = "DVI"; + } + ]; }; + + nmt.script = '' + assertFileExists home-files/.config/sway/config + assertFileContent home-files/.config/sway/config \ + ${./sway-workspace-output-expected.conf} + ''; } diff --git a/third_party/home-manager/tests/modules/services/wlsunset/wlsunset-service.nix b/third_party/home-manager/tests/modules/services/wlsunset/wlsunset-service.nix index de32a8270b..e3f816505e 100644 --- a/third_party/home-manager/tests/modules/services/wlsunset/wlsunset-service.nix +++ b/third_party/home-manager/tests/modules/services/wlsunset/wlsunset-service.nix @@ -4,9 +4,7 @@ config = { services.wlsunset = { enable = true; - package = pkgs.writeScriptBin "dummy-wlsunset" "" // { - outPath = "@wlsunset@"; - }; + package = config.lib.test.mkStubPackage { outPath = "@wlsunset@"; }; latitude = "12.3"; longitude = "128.8"; temperature.day = 6000; diff --git a/third_party/home-manager/tests/modules/services/xsettingsd/basic-configuration.conf b/third_party/home-manager/tests/modules/services/xsettingsd/basic-configuration.conf new file mode 100644 index 0000000000..4e502c98f8 --- /dev/null +++ b/third_party/home-manager/tests/modules/services/xsettingsd/basic-configuration.conf @@ -0,0 +1,4 @@ +Net/ThemeName "Numix" +Xft/Antialias 1 +Xft/Hinting 1 +Xft/RGBA "rgb" diff --git a/third_party/home-manager/tests/modules/services/xsettingsd/basic-configuration.nix b/third_party/home-manager/tests/modules/services/xsettingsd/basic-configuration.nix new file mode 100644 index 0000000000..8ea2ec7821 --- /dev/null +++ b/third_party/home-manager/tests/modules/services/xsettingsd/basic-configuration.nix @@ -0,0 +1,26 @@ +{ config, pkgs, ... }: + +{ + config = { + services.xsettingsd = { + enable = true; + package = config.lib.test.mkStubPackage { }; + settings = { + "Net/ThemeName" = "Numix"; + "Xft/Antialias" = true; + "Xft/Hinting" = true; + "Xft/RGBA" = "rgb"; + }; + }; + nmt.script = '' + serviceFile=home-files/.config/systemd/user/xsettingsd.service + + assertFileExists $serviceFile + assertFileRegex $serviceFile 'ExecStart=.*/bin/xsettingsd.*' + + assertFileExists ${config.services.xsettingsd.configFile} + assertFileContent ${config.services.xsettingsd.configFile} \ + ${./basic-configuration.conf} + ''; + }; +} diff --git a/third_party/home-manager/tests/modules/services/xsettingsd/default.nix b/third_party/home-manager/tests/modules/services/xsettingsd/default.nix new file mode 100644 index 0000000000..98c99f4c8e --- /dev/null +++ b/third_party/home-manager/tests/modules/services/xsettingsd/default.nix @@ -0,0 +1 @@ +{ xsettingsd-basic-configuration = ./basic-configuration.nix; } diff --git a/third_party/home-manager/tests/modules/systemd/services.nix b/third_party/home-manager/tests/modules/systemd/services.nix index 4f73c5568f..fbef7b9c2e 100644 --- a/third_party/home-manager/tests/modules/systemd/services.nix +++ b/third_party/home-manager/tests/modules/systemd/services.nix @@ -5,9 +5,7 @@ with lib; { config = { systemd.user.services."test-service@" = { - Unit = { - Description = "A basic test service"; - }; + Unit = { Description = "A basic test service"; }; Service = { Environment = [ "VAR1=1" "VAR2=2" ]; @@ -19,15 +17,17 @@ with lib; serviceFile=home-files/.config/systemd/user/test-service@.service assertFileExists $serviceFile assertFileContent $serviceFile \ - ${builtins.toFile "services-expected.conf" '' - [Service] - Environment=VAR1=1 - Environment=VAR2=2 - ExecStart=/some/exec/start/command --with-arguments "%i" + ${ + builtins.toFile "services-expected.conf" '' + [Service] + Environment=VAR1=1 + Environment=VAR2=2 + ExecStart=/some/exec/start/command --with-arguments "%i" - [Unit] - Description=A basic test service - ''} + [Unit] + Description=A basic test service + '' + } ''; }; } diff --git a/third_party/home-manager/tests/modules/systemd/session-variables.nix b/third_party/home-manager/tests/modules/systemd/session-variables.nix index 59d1a4d3aa..8722a9ab3e 100644 --- a/third_party/home-manager/tests/modules/systemd/session-variables.nix +++ b/third_party/home-manager/tests/modules/systemd/session-variables.nix @@ -10,11 +10,13 @@ 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 - ''} + assertFileContent $envFile ${ + pkgs.writeText "expected" '' + LOCALE_ARCHIVE_2_27=${pkgs.glibcLocales}/lib/locale/locale-archive + V_int=1 + V_str=2 + '' + } ''; }; } diff --git a/third_party/home-manager/tests/stubs.nix b/third_party/home-manager/tests/stubs.nix new file mode 100644 index 0000000000..01f4606547 --- /dev/null +++ b/third_party/home-manager/tests/stubs.nix @@ -0,0 +1,61 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + stubType = types.submodule ({ name, ... }: { + options = { + name = mkOption { + type = types.str; + default = "dummy"; + description = "The stub package name."; + }; + + outPath = mkOption { + type = types.nullOr types.str; + default = "@${name}@"; + defaultText = "@\${name}@"; + }; + + version = mkOption { + type = types.nullOr types.str; + default = null; + }; + + buildScript = mkOption { + type = types.str; + default = defaultBuildScript; + }; + }; + }); + + defaultBuildScript = "mkdir $out"; + + dummyPackage = pkgs.runCommandLocal "dummy" { } defaultBuildScript; + + mkStubPackage = { name ? "dummy", outPath ? null, version ? null + , buildScript ? defaultBuildScript }: + let + pkg = if name == "dummy" && buildScript == defaultBuildScript then + dummyPackage + else + pkgs.runCommandLocal name { } buildScript; + in pkg // optionalAttrs (outPath != null) { inherit outPath; } + // optionalAttrs (version != null) { inherit version; }; + +in { + options.test.stubs = mkOption { + type = types.attrsOf stubType; + default = { }; + description = + "Package attributes that should be replaced by a stub package."; + }; + + config = { + lib.test.mkStubPackage = mkStubPackage; + + nixpkgs.overlays = mkIf (config.test.stubs != { }) + [ (self: super: mapAttrs (n: mkStubPackage) config.test.stubs) ]; + }; +}