1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +01:00

Move platform check into modules

Before, loading a module would be guarded by an optional platform
condition. This made it possible to avoid loading and evaluating a
module if it did not support the host platform.

Unfortunately, this made it impossible to share a single configuration
between GNU/Linux and Darwin hosts, which some wish to do.

This removes the conditional load and instead inserts host platform
assertions in the modules that are platform specific.

Fixes #1906
This commit is contained in:
Robert Helgesson 2021-07-07 23:24:27 +02:00
parent 1617e56c2f
commit 5f433eb164
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
90 changed files with 743 additions and 307 deletions

View file

@ -9,7 +9,29 @@ section is therefore not final.
This release has the following notable changes: This release has the following notable changes:
* Nothing has happened. * 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].
[[sec-release-21.11-state-version-changes]] [[sec-release-21.11-state-version-changes]]
=== State Version Changes === State Version Changes

View file

@ -36,7 +36,7 @@ let
in { in {
meta.maintainers = with maintainers; [ midchildan ]; meta.maintainers = with maintainers; [ midchildan ];
config = { config = mkIf pkgs.hostPlatform.isLinux {
# For shell sessions. # For shell sessions.
home.sessionVariables = localeVars; home.sessionVariables = localeVars;

View file

@ -95,6 +95,10 @@ in {
}; };
config = mkIf (cfg.enabled != null) { config = mkIf (cfg.enabled != null) {
assertions = [
(hm.assertions.assertPlatform "i18n.inputMethod" pkgs platforms.linux)
];
home.packages = [ cfg.package gtk2Cache gtk3Cache ]; home.packages = [ cfg.package gtk2Cache gtk3Cache ];
}; };

View file

@ -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}'';
};
}

View file

@ -16,6 +16,8 @@ rec {
entryBefore = d.dagEntryBefore; entryBefore = d.dagEntryBefore;
}; };
assertions = import ./assertions.nix { inherit lib; };
gvariant = import ./gvariant.nix { inherit lib; }; gvariant = import ./gvariant.nix { inherit lib; };
maintainers = import ./maintainers.nix; maintainers = import ./maintainers.nix;
strings = import ./strings.nix { inherit lib; }; strings = import ./strings.nix { inherit lib; };

View file

@ -12,6 +12,10 @@ in {
options = { xsession.numlock.enable = mkEnableOption "Num Lock"; }; options = { xsession.numlock.enable = mkEnableOption "Num Lock"; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(hm.assertions.assertPlatform "xsession.numlock" pkgs platforms.linux)
];
systemd.user.services.numlockx = { systemd.user.services.numlockx = {
Unit = { Unit = {
Description = "NumLockX"; Description = "NumLockX";

View file

@ -25,6 +25,11 @@ in {
}; };
config = mkIf (cfg.rules != [ ]) { config = mkIf (cfg.rules != [ ]) {
assertions = [
(hm.assertions.assertPlatform "systemd.user.tmpfiles" pkgs
platforms.linux)
];
xdg = { xdg = {
dataFile."user-tmpfiles.d/home-manager.conf" = { dataFile."user-tmpfiles.d/home-manager.conf" = {
text = '' text = ''

View file

@ -171,8 +171,13 @@ in {
''; '';
}; };
config.home.packages = mkIf (config.xdg.desktopEntries != { }) config = mkIf (config.xdg.desktopEntries != { }) {
(map hiPrio # we need hiPrio to override existing entries 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)); (attrsets.mapAttrsToList makeFile config.xdg.desktopEntries));
};
} }

View file

@ -73,6 +73,9 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions =
[ (hm.assertions.assertPlatform "xdg.mimeApps" pkgs platforms.linux) ];
# Deprecated but still used by some applications. # Deprecated but still used by some applications.
xdg.dataFile."applications/mimeapps.list".source = xdg.dataFile."applications/mimeapps.list".source =
config.xdg.configFile."mimeapps.list".source; config.xdg.configFile."mimeapps.list".source;

View file

@ -10,7 +10,9 @@ in {
options = { options = {
xdg.mime.enable = mkOption { xdg.mime.enable = mkOption {
type = types.bool; type = types.bool;
default = true; default = pkgs.hostPlatform.isLinux;
defaultText =
literalExample "true if host platform is Linux, false otherwise";
description = '' description = ''
Whether to install programs and files to support the Whether to install programs and files to support the
XDG Shared MIME-info specification and XDG MIME Applications XDG Shared MIME-info specification and XDG MIME Applications
@ -24,6 +26,9 @@ in {
}; };
config = mkIf config.xdg.mime.enable { config = mkIf config.xdg.mime.enable {
assertions =
[ (hm.assertions.assertPlatform "xdg.mime" pkgs platforms.linux) ];
home.packages = [ home.packages = [
# Explicitly install package to provide basic mime types. # Explicitly install package to provide basic mime types.
pkgs.shared-mime-info pkgs.shared-mime-info

View file

@ -36,6 +36,12 @@ in {
}; };
config = mkMerge [ config = mkMerge [
(mkIf (cfg.config != [ ] || cfg.data != [ ]) {
assertions = [
(hm.assertions.assertPlatform "xdg.systemDirs" pkgs platforms.linux)
];
})
(mkIf (cfg.config != [ ]) { (mkIf (cfg.config != [ ]) {
home.sessionVariables.XDG_CONFIG_DIRS = home.sessionVariables.XDG_CONFIG_DIRS =
"${configDirs}\${XDG_CONFIG_DIRS:+:$XDG_CONFIG_DIRS}"; "${configDirs}\${XDG_CONFIG_DIRS:+:$XDG_CONFIG_DIRS}";

View file

@ -103,6 +103,9 @@ in {
XDG_VIDEOS_DIR = cfg.videos; XDG_VIDEOS_DIR = cfg.videos;
} // cfg.extraConfig; } // cfg.extraConfig;
in mkIf cfg.enable { in mkIf cfg.enable {
assertions =
[ (hm.assertions.assertPlatform "xdg.userDirs" pkgs platforms.linux) ];
xdg.configFile."user-dirs.dirs".text = let xdg.configFile."user-dirs.dirs".text = let
# For some reason, these need to be wrapped with quotes to be valid. # For some reason, these need to be wrapped with quotes to be valid.
wrapped = mapAttrs (_: value: ''"${value}"'') directories; wrapped = mapAttrs (_: value: ''"${value}"'') directories;

View file

@ -14,234 +14,225 @@ with lib;
let let
hostPlatform = pkgs.stdenv.hostPlatform; modules = [
./accounts/email.nix
loadModule = file: { condition ? true }: { ./config/i18n.nix
inherit file condition; ./files.nix
}; ./home-environment.nix
./i18n/input-method/default.nix
allModules = [ ./manual.nix
(loadModule ./accounts/email.nix { }) ./misc/dconf.nix
(loadModule ./config/i18n.nix { condition = hostPlatform.isLinux; }) ./misc/debug.nix
(loadModule ./files.nix { }) ./misc/fontconfig.nix
(loadModule ./home-environment.nix { }) ./misc/gtk.nix
(loadModule ./i18n/input-method/default.nix { condition = hostPlatform.isLinux; }) ./misc/lib.nix
(loadModule ./manual.nix { }) ./misc/news.nix
(loadModule ./misc/dconf.nix { }) ./misc/numlock.nix
(loadModule ./misc/debug.nix { }) ./misc/pam.nix
(loadModule ./misc/fontconfig.nix { }) ./misc/qt.nix
(loadModule ./misc/gtk.nix { }) ./misc/submodule-support.nix
(loadModule ./misc/lib.nix { }) ./misc/tmpfiles.nix
(loadModule ./misc/news.nix { }) ./misc/version.nix
(loadModule ./misc/nixpkgs.nix { condition = useNixpkgsModule; }) ./misc/vte.nix
(loadModule ./misc/numlock.nix { condition = hostPlatform.isLinux; }) ./misc/xdg-desktop-entries.nix
(loadModule ./misc/pam.nix { }) ./misc/xdg-mime-apps.nix
(loadModule ./misc/qt.nix { }) ./misc/xdg-mime.nix
(loadModule ./misc/submodule-support.nix { }) ./misc/xdg-system-dirs.nix
(loadModule ./misc/tmpfiles.nix { condition = hostPlatform.isLinux; }) ./misc/xdg-user-dirs.nix
(loadModule ./misc/version.nix { }) ./misc/xdg.nix
(loadModule ./misc/vte.nix { }) ./programs/abook.nix
(loadModule ./misc/xdg-system-dirs.nix { condition = hostPlatform.isLinux; }) ./programs/afew.nix
(loadModule ./misc/xdg-desktop-entries.nix { condition = hostPlatform.isLinux; }) ./programs/alacritty.nix
(loadModule ./misc/xdg-mime.nix { condition = hostPlatform.isLinux; }) ./programs/alot.nix
(loadModule ./misc/xdg-mime-apps.nix { condition = hostPlatform.isLinux; }) ./programs/aria2.nix
(loadModule ./misc/xdg-user-dirs.nix { condition = hostPlatform.isLinux; }) ./programs/astroid.nix
(loadModule ./misc/xdg.nix { }) ./programs/autojump.nix
(loadModule ./programs/abook.nix { condition = hostPlatform.isLinux; }) ./programs/autorandr.nix
(loadModule ./programs/afew.nix { }) ./programs/bash.nix
(loadModule ./programs/alacritty.nix { }) ./programs/bat.nix
(loadModule ./programs/alot.nix { }) ./programs/beets.nix
(loadModule ./programs/aria2.nix { }) ./programs/broot.nix
(loadModule ./programs/astroid.nix { }) ./programs/browserpass.nix
(loadModule ./programs/autojump.nix { }) ./programs/chromium.nix
(loadModule ./programs/autorandr.nix { }) ./programs/command-not-found/command-not-found.nix
(loadModule ./programs/bash.nix { }) ./programs/dircolors.nix
(loadModule ./programs/bat.nix { }) ./programs/direnv.nix
(loadModule ./programs/beets.nix { }) ./programs/eclipse.nix
(loadModule ./programs/broot.nix { }) ./programs/emacs.nix
(loadModule ./programs/browserpass.nix { }) ./programs/exa.nix
(loadModule ./programs/chromium.nix { }) ./programs/feh.nix
(loadModule ./programs/command-not-found/command-not-found.nix { }) ./programs/firefox.nix
(loadModule ./programs/dircolors.nix { }) ./programs/fish.nix
(loadModule ./programs/direnv.nix { }) ./programs/foot.nix
(loadModule ./programs/eclipse.nix { }) ./programs/fzf.nix
(loadModule ./programs/emacs.nix { }) ./programs/getmail.nix
(loadModule ./programs/exa.nix { }) ./programs/gh.nix
(loadModule ./programs/feh.nix { }) ./programs/git.nix
(loadModule ./programs/firefox.nix { }) ./programs/gnome-terminal.nix
(loadModule ./programs/fish.nix { }) ./programs/go.nix
(loadModule ./programs/foot.nix { condition = hostPlatform.isLinux; }) ./programs/gpg.nix
(loadModule ./programs/fzf.nix { }) ./programs/himalaya.nix
(loadModule ./programs/getmail.nix { condition = hostPlatform.isLinux; }) ./programs/home-manager.nix
(loadModule ./programs/gh.nix { }) ./programs/htop.nix
(loadModule ./programs/git.nix { }) ./programs/i3status-rust.nix
(loadModule ./programs/gnome-terminal.nix { }) ./programs/i3status.nix
(loadModule ./programs/go.nix { }) ./programs/info.nix
(loadModule ./programs/gpg.nix { }) ./programs/irssi.nix
(loadModule ./programs/himalaya.nix { }) ./programs/jq.nix
(loadModule ./programs/home-manager.nix { }) ./programs/kakoune.nix
(loadModule ./programs/htop.nix { }) ./programs/keychain.nix
(loadModule ./programs/i3status.nix { }) ./programs/kitty.nix
(loadModule ./programs/i3status-rust.nix { condition = hostPlatform.isLinux; }) ./programs/lazygit.nix
(loadModule ./programs/info.nix { }) ./programs/lesspipe.nix
(loadModule ./programs/irssi.nix { }) ./programs/lf.nix
(loadModule ./programs/lieer.nix { }) ./programs/lieer.nix
(loadModule ./programs/jq.nix { }) ./programs/lsd.nix
(loadModule ./programs/kakoune.nix { }) ./programs/man.nix
(loadModule ./programs/keychain.nix { }) ./programs/mangohud.nix
(loadModule ./programs/kitty.nix { }) ./programs/matplotlib.nix
(loadModule ./programs/lazygit.nix { }) ./programs/mbsync.nix
(loadModule ./programs/lesspipe.nix { }) ./programs/mcfly.nix
(loadModule ./programs/lf.nix { }) ./programs/mercurial.nix
(loadModule ./programs/lsd.nix { }) ./programs/mpv.nix
(loadModule ./programs/man.nix { }) ./programs/msmtp.nix
(loadModule ./programs/mangohud.nix { condition = hostPlatform.isLinux; }) ./programs/mu.nix
(loadModule ./programs/matplotlib.nix { }) ./programs/ncmpcpp.nix
(loadModule ./programs/mbsync.nix { }) ./programs/ncspot.nix
(loadModule ./programs/mcfly.nix { }) ./programs/ne.nix
(loadModule ./programs/mercurial.nix { }) ./programs/neomutt.nix
(loadModule ./programs/mpv.nix { }) ./programs/neovim.nix
(loadModule ./programs/msmtp.nix { }) ./programs/newsboat.nix
(loadModule ./programs/mu.nix { }) ./programs/nix-index.nix
(loadModule ./programs/ncmpcpp.nix { }) ./programs/noti.nix
(loadModule ./programs/ncspot.nix { }) ./programs/notmuch.nix
(loadModule ./programs/ne.nix { }) ./programs/nushell.nix
(loadModule ./programs/neomutt.nix { }) ./programs/obs-studio.nix
(loadModule ./programs/neovim.nix { }) ./programs/octant.nix
(loadModule ./programs/newsboat.nix { }) ./programs/offlineimap.nix
(loadModule ./programs/nix-index.nix { }) ./programs/opam.nix
(loadModule ./programs/noti.nix { }) ./programs/password-store.nix
(loadModule ./programs/notmuch.nix { }) ./programs/pazi.nix
(loadModule ./programs/nushell.nix { }) ./programs/pet.nix
(loadModule ./programs/obs-studio.nix { }) ./programs/pidgin.nix
(loadModule ./programs/octant.nix { }) ./programs/piston-cli.nix
(loadModule ./programs/offlineimap.nix { }) ./programs/powerline-go.nix
(loadModule ./programs/opam.nix { }) ./programs/qutebrowser.nix
(loadModule ./programs/password-store.nix { }) ./programs/rbw.nix
(loadModule ./programs/pazi.nix { }) ./programs/readline.nix
(loadModule ./programs/pet.nix { }) ./programs/rofi-pass.nix
(loadModule ./programs/pidgin.nix { }) ./programs/rofi.nix
(loadModule ./programs/piston-cli.nix { }) ./programs/rtorrent.nix
(loadModule ./programs/powerline-go.nix { }) ./programs/sbt.nix
(loadModule ./programs/qutebrowser.nix { }) ./programs/scmpuff.nix
(loadModule ./programs/rbw.nix { }) ./programs/senpai.nix
(loadModule ./programs/readline.nix { }) ./programs/skim.nix
(loadModule ./programs/rofi.nix { }) ./programs/sm64ex.nix
(loadModule ./programs/rofi-pass.nix { }) ./programs/ssh.nix
(loadModule ./programs/rtorrent.nix { }) ./programs/starship.nix
(loadModule ./programs/scmpuff.nix { }) ./programs/taskwarrior.nix
(loadModule ./programs/senpai.nix { }) ./programs/terminator.nix
(loadModule ./programs/skim.nix { }) ./programs/termite.nix
(loadModule ./programs/sm64ex.nix { }) ./programs/texlive.nix
(loadModule ./programs/starship.nix { }) ./programs/tmux.nix
(loadModule ./programs/sbt.nix { }) ./programs/topgrade.nix
(loadModule ./programs/ssh.nix { }) ./programs/urxvt.nix
(loadModule ./programs/taskwarrior.nix { }) ./programs/vim.nix
(loadModule ./programs/termite.nix { }) ./programs/vscode.nix
(loadModule ./programs/texlive.nix { }) ./programs/vscode/haskell.nix
(loadModule ./programs/tmux.nix { }) ./programs/waybar.nix
(loadModule ./programs/terminator.nix { condition = hostPlatform.isLinux; }) ./programs/xmobar.nix
(loadModule ./programs/topgrade.nix { }) ./programs/z-lua.nix
(loadModule ./programs/urxvt.nix { }) ./programs/zathura.nix
(loadModule ./programs/vim.nix { }) ./programs/zoxide.nix
(loadModule ./programs/vscode.nix { }) ./programs/zplug.nix
(loadModule ./programs/vscode/haskell.nix { }) ./programs/zsh.nix
(loadModule ./programs/waybar.nix { condition = hostPlatform.isLinux; }) ./programs/zsh/prezto.nix
(loadModule ./programs/xmobar.nix { }) ./services/barrier.nix
(loadModule ./programs/z-lua.nix { }) ./services/blueman-applet.nix
(loadModule ./programs/zathura.nix { }) ./services/caffeine.nix
(loadModule ./programs/zoxide.nix { }) ./services/cbatticon.nix
(loadModule ./programs/zplug.nix { }) ./services/clipmenu.nix
(loadModule ./programs/zsh.nix { }) ./services/compton.nix
(loadModule ./programs/zsh/prezto.nix { }) ./services/devilspie2.nix
(loadModule ./services/barrier.nix { condition = hostPlatform.isLinux; }) ./services/dropbox.nix
(loadModule ./services/blueman-applet.nix { }) ./services/dunst.nix
(loadModule ./services/caffeine.nix { condition = hostPlatform.isLinux; }) ./services/dwm-status.nix
(loadModule ./services/cbatticon.nix { condition = hostPlatform.isLinux; }) ./services/emacs.nix
(loadModule ./services/clipmenu.nix { condition = hostPlatform.isLinux; }) ./services/etesync-dav.nix
(loadModule ./services/compton.nix { }) ./services/flameshot.nix
(loadModule ./services/devilspie2.nix { condition = hostPlatform.isLinux; }) ./services/fluidsynth.nix
(loadModule ./services/dropbox.nix { condition = hostPlatform.isLinux; }) ./services/getmail.nix
(loadModule ./services/dunst.nix { }) ./services/gnome-keyring.nix
(loadModule ./services/dwm-status.nix { condition = hostPlatform.isLinux; }) ./services/gpg-agent.nix
(loadModule ./services/emacs.nix { condition = hostPlatform.isLinux; }) ./services/grobi.nix
(loadModule ./services/etesync-dav.nix { condition = hostPlatform.isLinux; }) ./services/hound.nix
(loadModule ./services/flameshot.nix { }) ./services/imapnotify.nix
(loadModule ./services/fluidsynth.nix { condition = hostPlatform.isLinux; }) ./services/kanshi.nix
(loadModule ./services/redshift-gammastep/gammastep.nix { condition = hostPlatform.isLinux; }) ./services/kbfs.nix
(loadModule ./services/getmail.nix { condition = hostPlatform.isLinux; }) ./services/kdeconnect.nix
(loadModule ./services/gnome-keyring.nix { }) ./services/keepassx.nix
(loadModule ./services/gpg-agent.nix { }) ./services/keybase.nix
(loadModule ./services/grobi.nix { condition = hostPlatform.isLinux; }) ./services/keynav.nix
(loadModule ./services/hound.nix { condition = hostPlatform.isLinux; }) ./services/lieer.nix
(loadModule ./services/imapnotify.nix { condition = hostPlatform.isLinux; }) ./services/lorri.nix
(loadModule ./services/kanshi.nix { condition = hostPlatform.isLinux; }) ./services/mako.nix
(loadModule ./services/kbfs.nix { }) ./services/mbsync.nix
(loadModule ./services/kdeconnect.nix { }) ./services/mpd.nix
(loadModule ./services/keepassx.nix { }) ./services/mpdris2.nix
(loadModule ./services/keybase.nix { }) ./services/mpris-proxy.nix
(loadModule ./services/keynav.nix { condition = hostPlatform.isLinux; }) ./services/muchsync.nix
(loadModule ./services/lieer.nix { condition = hostPlatform.isLinux; }) ./services/network-manager-applet.nix
(loadModule ./services/lorri.nix { condition = hostPlatform.isLinux; }) ./services/nextcloud-client.nix
(loadModule ./services/mako.nix { condition = hostPlatform.isLinux; }) ./services/owncloud-client.nix
(loadModule ./services/mbsync.nix { }) ./services/pantalaimon.nix
(loadModule ./services/mpd.nix { }) ./services/parcellite.nix
(loadModule ./services/mpdris2.nix { condition = hostPlatform.isLinux; }) ./services/pass-secret-service.nix
(loadModule ./services/mpris-proxy.nix { condition = hostPlatform.isLinux; }) ./services/password-store-sync.nix
(loadModule ./services/muchsync.nix { condition = hostPlatform.isLinux; }) ./services/pasystray.nix
(loadModule ./services/network-manager-applet.nix { }) ./services/pbgopy.nix
(loadModule ./services/nextcloud-client.nix { }) ./services/picom.nix
(loadModule ./services/owncloud-client.nix { }) ./services/plan9port.nix
(loadModule ./services/pantalaimon.nix { condition = hostPlatform.isLinux; }) ./services/playerctld.nix
(loadModule ./services/parcellite.nix { }) ./services/polybar.nix
(loadModule ./services/pass-secret-service.nix { condition = hostPlatform.isLinux; }) ./services/poweralertd.nix
(loadModule ./services/password-store-sync.nix { condition = hostPlatform.isLinux; }) ./services/pulseeffects.nix
(loadModule ./services/pasystray.nix { }) ./services/random-background.nix
(loadModule ./services/pbgopy.nix { condition = hostPlatform.isLinux; }) ./services/redshift-gammastep/gammastep.nix
(loadModule ./services/picom.nix { }) ./services/redshift-gammastep/redshift.nix
(loadModule ./services/plan9port.nix { condition = hostPlatform.isLinux; }) ./services/rsibreak.nix
(loadModule ./services/playerctld.nix { condition = hostPlatform.isLinux; }) ./services/screen-locker.nix
(loadModule ./services/polybar.nix { }) ./services/spotifyd.nix
(loadModule ./services/poweralertd.nix { condition = hostPlatform.isLinux; }) ./services/stalonetray.nix
(loadModule ./services/pulseeffects.nix { condition = hostPlatform.isLinux; }) ./services/status-notifier-watcher.nix
(loadModule ./services/random-background.nix { }) ./services/sxhkd.nix
(loadModule ./services/redshift-gammastep/redshift.nix { }) ./services/syncthing.nix
(loadModule ./services/rsibreak.nix { condition = hostPlatform.isLinux; }) ./services/taffybar.nix
(loadModule ./services/screen-locker.nix { }) ./services/tahoe-lafs.nix
(loadModule ./services/stalonetray.nix { }) ./services/taskwarrior-sync.nix
(loadModule ./services/status-notifier-watcher.nix { }) ./services/udiskie.nix
(loadModule ./services/spotifyd.nix { condition = hostPlatform.isLinux; }) ./services/unclutter.nix
(loadModule ./services/sxhkd.nix { condition = hostPlatform.isLinux; }) ./services/unison.nix
(loadModule ./services/syncthing.nix { }) ./services/window-managers/awesome.nix
(loadModule ./services/taffybar.nix { }) ./services/window-managers/bspwm/default.nix
(loadModule ./services/tahoe-lafs.nix { }) ./services/window-managers/i3-sway/i3.nix
(loadModule ./services/taskwarrior-sync.nix { condition = hostPlatform.isLinux; }) ./services/window-managers/i3-sway/sway.nix
(loadModule ./services/udiskie.nix { }) ./services/window-managers/xmonad.nix
(loadModule ./services/unclutter.nix { }) ./services/wlsunset.nix
(loadModule ./services/unison.nix { condition = hostPlatform.isLinux; }) ./services/xcape.nix
(loadModule ./services/window-managers/awesome.nix { }) ./services/xembed-sni-proxy.nix
(loadModule ./services/window-managers/bspwm/default.nix { condition = hostPlatform.isLinux; }) ./services/xidlehook.nix
(loadModule ./services/window-managers/i3-sway/i3.nix { }) ./services/xscreensaver.nix
(loadModule ./services/window-managers/i3-sway/sway.nix { condition = hostPlatform.isLinux; }) ./services/xsettingsd.nix
(loadModule ./services/window-managers/xmonad.nix { }) ./services/xsuspender.nix
(loadModule ./services/wlsunset.nix { condition = hostPlatform.isLinux; }) ./systemd.nix
(loadModule ./services/xcape.nix { condition = hostPlatform.isLinux; }) ./targets/darwin
(loadModule ./services/xembed-sni-proxy.nix { condition = hostPlatform.isLinux; }) ./targets/generic-linux.nix
(loadModule ./services/xidlehook.nix { condition = hostPlatform.isLinux; }) ./xcursor.nix
(loadModule ./services/xscreensaver.nix { }) ./xresources.nix
(loadModule ./services/xsettingsd.nix { condition = hostPlatform.isLinux; }) ./xsession.nix
(loadModule ./services/xsuspender.nix { condition = hostPlatform.isLinux; }) (pkgs.path + "/nixos/modules/misc/assertions.nix")
(loadModule ./systemd.nix { }) (pkgs.path + "/nixos/modules/misc/meta.nix")
(loadModule ./targets/darwin { condition = hostPlatform.isDarwin; }) ] ++ optional useNixpkgsModule ./misc/nixpkgs.nix;
(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);
pkgsModule = { config, ... }: { pkgsModule = { config, ... }: {
config = { config = {

View file

@ -27,7 +27,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions =
[ (hm.assertions.assertPlatform "programs.abook" pkgs platforms.linux) ];
home.packages = [ pkgs.abook ]; home.packages = [ pkgs.abook ];
xdg.configFile."abook/abookrc" = mkIf (cfg.extraConfig != "") { xdg.configFile."abook/abookrc" = mkIf (cfg.extraConfig != "") {
text = '' text = ''
# Generated by Home Manager. # Generated by Home Manager.

View file

@ -49,6 +49,9 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions =
[ (hm.assertions.assertPlatform "programs.foot" pkgs platforms.linux) ];
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
xdg.configFile."foot/foot.ini" = mkIf (cfg.settings != { }) { xdg.configFile."foot/foot.ini" = mkIf (cfg.settings != { }) {

View file

@ -55,6 +55,10 @@ in {
}; };
config = mkIf getmailEnabled { config = mkIf getmailEnabled {
assertions = [
(hm.assertions.assertPlatform "programs.getmail" pkgs platforms.linux)
];
home.file = foldl' (a: b: a // b) { } home.file = foldl' (a: b: a // b) { }
(map (a: { "${renderConfigFilepath a}".text = renderAccountConfig a; }) (map (a: { "${renderConfigFilepath a}".text = renderAccountConfig a; })
accounts); accounts);

View file

@ -249,6 +249,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(hm.assertions.assertPlatform "programs.i3status-rust" pkgs
platforms.linux)
];
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
xdg.configFile = mapAttrs' (cfgFileSuffix: cfg: xdg.configFile = mapAttrs' (cfgFileSuffix: cfg:

View file

@ -82,24 +82,25 @@ in {
}; };
}; };
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable {
{ assertions = [
home.packages = [ cfg.package ]; (hm.assertions.assertPlatform "programs.mangohud" pkgs platforms.linux)
];
home.sessionVariables = mkIf cfg.enableSessionWide { home.packages = [ cfg.package ];
MANGOHUD = 1;
MANGOHUD_DLSYM = 1;
};
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; }; mkIf (cfg.settings != { }) { text = renderSettings cfg.settings; };
} } // mapAttrs'
{ (n: v: nameValuePair "MangoHud/${n}.conf" { text = renderSettings v; })
xdg.configFile = mapAttrs' cfg.settingsPerApplication;
(n: v: nameValuePair "MangoHud/${n}.conf" { text = renderSettings v; }) };
cfg.settingsPerApplication;
}
]);
meta.maintainers = with maintainers; [ zeratax ]; meta.maintainers = with maintainers; [ zeratax ];
} }

View file

@ -402,12 +402,15 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [{ assertions = [
assertion = cfg.theme == null || cfg.colors == null; (hm.assertions.assertPlatform "programs.rofi" pkgs platforms.linux)
message = '' {
Cannot use the rofi options 'theme' and 'colors' simultaneously. assertion = cfg.theme == null || cfg.colors == null;
''; message = ''
}]; Cannot use the rofi options 'theme' and 'colors' simultaneously.
'';
}
];
lib.formats.rasi.mkLiteral = value: { lib.formats.rasi.mkLiteral = value: {
_type = "literal"; _type = "literal";

View file

@ -63,7 +63,12 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(hm.assertions.assertPlatform "programs.terminator" pkgs platforms.linux)
];
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
xdg.configFile."terminator/config" = xdg.configFile."terminator/config" =
mkIf (cfg.config != { }) { text = toConfigObject cfg.config; }; mkIf (cfg.config != { }) { text = toConfigObject cfg.config; };
}; };

View file

@ -353,16 +353,26 @@ in {
in allWarnings; in allWarnings;
in mkIf cfg.enable (mkMerge [ 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 != [ ]) { (mkIf (cfg.settings != [ ]) {
# Generate warnings about defined but unreferenced modules # Generate warnings about defined but unreferenced modules
inherit warnings; inherit warnings;
xdg.configFile."waybar/config".source = configSource; xdg.configFile."waybar/config".source = configSource;
}) })
(mkIf (cfg.style != null) { (mkIf (cfg.style != null) {
xdg.configFile."waybar/style.css".text = cfg.style; xdg.configFile."waybar/style.css".text = cfg.style;
}) })
(mkIf cfg.systemd.enable { (mkIf cfg.systemd.enable {
systemd.user.services.waybar = { systemd.user.services.waybar = {
Unit = { Unit = {

View file

@ -51,6 +51,11 @@ in {
}; };
config = mkIf cfg.client.enable { config = mkIf cfg.client.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.barrier" pkgs
lib.platforms.linux)
];
systemd.user.services.barrierc = { systemd.user.services.barrierc = {
Unit = { Unit = {
Description = "Barrier Client daemon"; Description = "Barrier Client daemon";

View file

@ -14,6 +14,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.caffeine" pkgs
lib.platforms.linux)
];
systemd.user.services.caffeine = { systemd.user.services.caffeine = {
Unit = { Description = "caffeine"; }; Unit = { Description = "caffeine"; };

View file

@ -98,6 +98,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.cbatticon" pkgs
lib.platforms.linux)
];
home.packages = [ package ]; home.packages = [ package ];
systemd.user.services.cbatticon = { systemd.user.services.cbatticon = {

View file

@ -21,6 +21,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.clipmenu" pkgs
lib.platforms.linux)
];
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
systemd.user.services.clipmenu = { systemd.user.services.clipmenu = {

View file

@ -27,6 +27,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.devilspie2" pkgs
lib.platforms.linux)
];
systemd.user.services.devilspie2 = { systemd.user.services.devilspie2 = {
Service.ExecStart = "${pkgs.devilspie2}/bin/devilspie2"; Service.ExecStart = "${pkgs.devilspie2}/bin/devilspie2";
Unit = { Unit = {

View file

@ -28,6 +28,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.dropbox" pkgs
lib.platforms.linux)
];
home.packages = [ pkgs.dropbox-cli ]; home.packages = [ pkgs.dropbox-cli ];
systemd.user.services.dropbox = { systemd.user.services.dropbox = {

View file

@ -53,6 +53,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.dwm-status" pkgs
lib.platforms.linux)
];
systemd.user.services.dwm-status = { systemd.user.services.dwm-status = {
Unit = { Unit = {
Description = "DWM status service"; Description = "DWM status service";

View file

@ -75,6 +75,11 @@ in {
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
{ {
assertions = [
(lib.hm.assertions.assertPlatform "services.emacs" pkgs
lib.platforms.linux)
];
systemd.user.services.emacs = { systemd.user.services.emacs = {
Unit = { Unit = {
Description = "Emacs text editor"; Description = "Emacs text editor";

View file

@ -45,6 +45,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.etesync-dav" pkgs
lib.platforms.linux)
];
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
systemd.user.services.etesync-dav = { systemd.user.services.etesync-dav = {

View file

@ -13,6 +13,11 @@ in {
options = { services.flameshot = { enable = mkEnableOption "Flameshot"; }; }; options = { services.flameshot = { enable = mkEnableOption "Flameshot"; }; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.flameshot" pkgs
lib.platforms.linux)
];
home.packages = [ package ]; home.packages = [ package ];
systemd.user.services.flameshot = { systemd.user.services.flameshot = {

View file

@ -37,6 +37,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.fluidsynth" pkgs
lib.platforms.linux)
];
systemd.user.services.fluidsynth = { systemd.user.services.fluidsynth = {
Unit = { Unit = {
Description = "FluidSynth Daemon"; Description = "FluidSynth Daemon";

View file

@ -37,6 +37,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.getmail" pkgs
lib.platforms.linux)
];
systemd.user.services.getmail = { systemd.user.services.getmail = {
Unit = { Description = "getmail email fetcher"; }; Unit = { Description = "getmail email fetcher"; };
Service = { ExecStart = "${pkgs.getmail}/bin/getmail ${configFiles}"; }; Service = { ExecStart = "${pkgs.getmail}/bin/getmail ${configFiles}"; };

View file

@ -25,6 +25,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.gnome-keyring" pkgs
lib.platforms.linux)
];
systemd.user.services.gnome-keyring = { systemd.user.services.gnome-keyring = {
Unit = { Unit = {
Description = "GNOME Keyring"; Description = "GNOME Keyring";

View file

@ -71,6 +71,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.grobi" pkgs
lib.platforms.linux)
];
systemd.user.services.grobi = { systemd.user.services.grobi = {
Unit = { Unit = {
Description = "grobi display auto config daemon"; Description = "grobi display auto config daemon";

View file

@ -59,6 +59,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.hound" pkgs
lib.platforms.linux)
];
home.packages = [ pkgs.hound ]; home.packages = [ pkgs.hound ];
systemd.user.services.hound = { systemd.user.services.hound = {

View file

@ -77,6 +77,8 @@ in {
+ concatMapStringsSep ", " (a: a.name) badAccounts; + concatMapStringsSep ", " (a: a.name) badAccounts;
}; };
in [ in [
(lib.hm.assertions.assertPlatform "services.imapnotify" pkgs
lib.platforms.linux)
(checkAccounts (a: a.maildir == null) "maildir configuration") (checkAccounts (a: a.maildir == null) "maildir configuration")
(checkAccounts (a: a.imap == null) "IMAP configuration") (checkAccounts (a: a.imap == null) "IMAP configuration")
(checkAccounts (a: a.passwordCommand == null) "password command") (checkAccounts (a: a.passwordCommand == null) "password command")

View file

@ -187,6 +187,10 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.kanshi" pkgs
lib.platforms.linux)
];
xdg.configFile."kanshi/config".text = '' xdg.configFile."kanshi/config".text = ''
${concatStringsSep "\n" (mapAttrsToList profileStr cfg.profiles)} ${concatStringsSep "\n" (mapAttrsToList profileStr cfg.profiles)}

View file

@ -32,6 +32,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.kbfs" pkgs
lib.platforms.linux)
];
systemd.user.services.kbfs = { systemd.user.services.kbfs = {
Unit = { Unit = {
Description = "Keybase File System"; Description = "Keybase File System";

View file

@ -10,6 +10,11 @@ in {
options.services.keybase.enable = mkEnableOption "Keybase"; options.services.keybase.enable = mkEnableOption "Keybase";
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.keybase" pkgs
lib.platforms.linux)
];
home.packages = [ pkgs.keybase ]; home.packages = [ pkgs.keybase ];
systemd.user.services.keybase = { systemd.user.services.keybase = {

View file

@ -10,6 +10,11 @@ in {
options.services.keynav = { enable = mkEnableOption "keynav"; }; options.services.keynav = { enable = mkEnableOption "keynav"; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.keynav" pkgs
lib.platforms.linux)
];
systemd.user.services.keynav = { systemd.user.services.keynav = {
Unit = { Unit = {
Description = "keynav"; Description = "keynav";

View file

@ -61,6 +61,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.lieer" pkgs
lib.platforms.linux)
];
programs.lieer.enable = true; programs.lieer.enable = true;
systemd.user.services = listToAttrs (map serviceUnit syncAccounts); systemd.user.services = listToAttrs (map serviceUnit syncAccounts);
systemd.user.timers = listToAttrs (map timerUnit syncAccounts); systemd.user.timers = listToAttrs (map timerUnit syncAccounts);

View file

@ -21,6 +21,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.lorri" pkgs
lib.platforms.linux)
];
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
systemd.user = { systemd.user = {

View file

@ -292,7 +292,11 @@ in {
optionalString = name: val: optionalString = name: val:
lib.optionalString (val != null) "${name}=${val}"; lib.optionalString (val != null) "${name}=${val}";
in mkIf cfg.enable { in mkIf cfg.enable {
assertions =
[ (hm.assertions.assertPlatform "services.mako" pkgs platforms.linux) ];
home.packages = [ pkgs.mako ]; home.packages = [ pkgs.mako ];
xdg.configFile."mako/config".text = '' xdg.configFile."mako/config".text = ''
${optionalInteger "max-visible" cfg.maxVisible} ${optionalInteger "max-visible" cfg.maxVisible}
${optionalString "sort" cfg.sort} ${optionalString "sort" cfg.sort}

View file

@ -76,6 +76,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.mbsync" pkgs
lib.platforms.linux)
];
systemd.user.services.mbsync = { systemd.user.services.mbsync = {
Unit = { Description = "mbsync mailbox synchronization"; }; Unit = { Description = "mbsync mailbox synchronization"; };

View file

@ -143,6 +143,10 @@ in {
###### implementation ###### implementation
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.mpd" pkgs
lib.platforms.linux)
];
systemd.user.services.mpd = { systemd.user.services.mpd = {
Unit = { Unit = {

View file

@ -74,10 +74,15 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [{ assertions = [
assertion = config.services.mpd.enable; (lib.hm.assertions.assertPlatform "services.mpdris2" pkgs
message = "The mpdris2 module requires 'services.mpd.enable = true'."; 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; xdg.configFile."mpDris2/mpDris2.conf".text = toIni mpdris2Conf;

View file

@ -13,6 +13,11 @@ in {
"a proxy forwarding Bluetooth MIDI controls via MPRIS2 to control media players"; "a proxy forwarding Bluetooth MIDI controls via MPRIS2 to control media players";
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.mpris-proxy" pkgs
lib.platforms.linux)
];
systemd.user.services.mpris-proxy = { systemd.user.services.mpris-proxy = {
Unit = { Unit = {
Description = Description =

View file

@ -156,12 +156,16 @@ in {
(name: remoteCfg: nameValuePair "muchsync-${name}" (gen name remoteCfg)) (name: remoteCfg: nameValuePair "muchsync-${name}" (gen name remoteCfg))
cfg.remotes; cfg.remotes;
in mkIf (cfg.remotes != { }) { in mkIf (cfg.remotes != { }) {
assertions = [{ assertions = [
assertion = config.programs.notmuch.enable; (hm.assertions.assertPlatform "services.muchsync" pkgs platforms.linux)
message = ''
The muchsync module requires 'programs.notmuch.enable = true'. {
''; assertion = config.programs.notmuch.enable;
}]; message = ''
The muchsync module requires 'programs.notmuch.enable = true'.
'';
}
];
systemd.user.services = mapRemotes (name: remoteCfg: { systemd.user.services = mapRemotes (name: remoteCfg: {
Unit = { Description = "muchsync sync service (${name})"; }; Unit = { Description = "muchsync sync service (${name})"; };

View file

@ -16,6 +16,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.network-manager-applet" pkgs
lib.platforms.linux)
];
systemd.user.services.network-manager-applet = { systemd.user.services.network-manager-applet = {
Unit = { Unit = {
Description = "Network Manager applet"; Description = "Network Manager applet";

View file

@ -28,6 +28,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.nextcloud-client" pkgs
lib.platforms.linux)
];
systemd.user.services.nextcloud-client = { systemd.user.services.nextcloud-client = {
Unit = { Unit = {
Description = "Nextcloud Client"; Description = "Nextcloud Client";

View file

@ -55,6 +55,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.pantalaimon" pkgs
lib.platforms.linux)
];
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
systemd.user.services = { systemd.user.services = {

View file

@ -22,6 +22,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.parcellite" pkgs
lib.platforms.linux)
];
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
systemd.user.services.parcellite = { systemd.user.services.parcellite = {

View file

@ -9,11 +9,16 @@ in {
enable = mkEnableOption "Pass libsecret service"; enable = mkEnableOption "Pass libsecret service";
}; };
config = mkIf serviceCfg.enable { config = mkIf serviceCfg.enable {
assertions = [{ assertions = [
assertion = config.programs.password-store.enable; (hm.assertions.assertPlatform "services.pass-secret-service" pkgs
message = "The 'services.pass-secret-service' module requires" platforms.linux)
+ " 'programs.password-store.enable = true'.";
}]; {
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 = { systemd.user.services.pass-secret-service = {
Unit = { Description = "Pass libsecret service"; }; Unit = { Description = "Pass libsecret service"; };

View file

@ -33,11 +33,16 @@ in {
}; };
config = mkIf serviceCfg.enable { config = mkIf serviceCfg.enable {
assertions = [{ assertions = [
assertion = programCfg.enable; (hm.assertions.assertPlatform "services.password-store-sync" pkgs
message = "The 'services.password-store-sync' module requires" platforms.linux)
+ " 'programs.password-store.enable = true'.";
}]; {
assertion = programCfg.enable;
message = "The 'services.password-store-sync' module requires"
+ " 'programs.password-store.enable = true'.";
}
];
systemd.user.services.password-store-sync = { systemd.user.services.password-store-sync = {
Unit = { Description = "Password store sync"; }; Unit = { Description = "Password store sync"; };

View file

@ -50,6 +50,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.pbgopy" pkgs
lib.platforms.linux)
];
home.packages = [ package ]; home.packages = [ package ];
systemd.user.services.pbgopy = { systemd.user.services.pbgopy = {

View file

@ -283,6 +283,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.picom" pkgs
lib.platforms.linux)
];
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
systemd.user.services.picom = { systemd.user.services.picom = {

View file

@ -16,7 +16,10 @@ in {
mkEnableOption "the Plan 9 file system for interprocess messaging"; 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 { systemd.user.services.fontsrv = mkIf cfg.fontsrv.enable {
Unit.Description = "the Plan 9 file system access to host fonts"; Unit.Description = "the Plan 9 file system access to host fonts";

View file

@ -21,6 +21,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.playerctld" pkgs
lib.platforms.linux)
];
systemd.user.services.playerctld = { systemd.user.services.playerctld = {
Unit.Description = "MPRIS media player daemon"; Unit.Description = "MPRIS media player daemon";

View file

@ -191,6 +191,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.polybar" pkgs
lib.platforms.linux)
];
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
xdg.configFile."polybar/config".source = configFile; xdg.configFile."polybar/config".source = configFile;

View file

@ -11,6 +11,11 @@ in {
mkEnableOption "the Upower-powered power alerterd"; mkEnableOption "the Upower-powered power alerterd";
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.poweralertd" pkgs
lib.platforms.linux)
];
systemd.user.services.poweralertd = { systemd.user.services.poweralertd = {
Unit = { Unit = {
Description = "UPower-powered power alerter"; Description = "UPower-powered power alerter";

View file

@ -33,6 +33,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.pulseeffects" pkgs
lib.platforms.linux)
];
# running pulseeffects will just attach itself to gapplication service # running pulseeffects will just attach itself to gapplication service
# at-spi2-core is to minimize journalctl noise of: # 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" # "AT-SPI: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files"

View file

@ -146,20 +146,25 @@ in {
}; };
config = { config = {
assertions = [{ assertions = [
assertion = (cfg.settings ? ${mainSection}.dawn-time || cfg.settings (hm.assertions.assertPlatform "services.${moduleName}" pkgs
? ${mainSection}.dusk-time) platforms.linux)
|| (cfg.settings.${mainSection}.location-provider) == "geoclue2"
|| ((cfg.settings.${mainSection}.location-provider) == "manual" {
&& (cfg.settings ? manual.lat || cfg.settings ? manual.lon)); assertion = (cfg.settings ? ${mainSection}.dawn-time || cfg.settings
message = '' ? ${mainSection}.dusk-time)
In order for ${programName} to know the time of action, you need to set one of || (cfg.settings.${mainSection}.location-provider) == "geoclue2"
- services.${moduleName}.provider = "geoclue2" for automatically inferring your location || ((cfg.settings.${mainSection}.location-provider) == "manual"
(you also need to enable Geoclue2 service separately) && (cfg.settings ? manual.lat || cfg.settings ? manual.lon));
- services.${moduleName}.longitude and .latitude for specifying your location manually message = ''
- services.${moduleName}.dawnTime and .duskTime for specifying the times manually 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 = { services.${moduleName}.settings = {
${mainSection} = { ${mainSection} = {

View file

@ -14,6 +14,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.rsibreak" pkgs
lib.platforms.linux)
];
home.packages = [ pkgs.rsibreak ]; home.packages = [ pkgs.rsibreak ];
systemd.user.services.rsibreak = { systemd.user.services.rsibreak = {
Unit = { Unit = {

View file

@ -53,6 +53,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.screen-locker" pkgs
lib.platforms.linux)
];
systemd.user.services.xautolock-session = { systemd.user.services.xautolock-session = {
Unit = { Unit = {
Description = "xautolock, session locker service"; Description = "xautolock, session locker service";

View file

@ -43,6 +43,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.spotifyd" pkgs
lib.platforms.linux)
];
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
systemd.user.services.spotifyd = { systemd.user.services.spotifyd = {

View file

@ -26,6 +26,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.status-notifier-watcher" pkgs
lib.platforms.linux)
];
systemd.user.services.status-notifier-watcher = { systemd.user.services.status-notifier-watcher = {
Unit = { Unit = {
Description = "SNI watcher"; Description = "SNI watcher";

View file

@ -65,6 +65,11 @@ in
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.sxhkd" pkgs
lib.platforms.linux)
];
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
xdg.configFile."sxhkd/sxhkdrc".text = concatStringsSep "\n" [ xdg.configFile."sxhkd/sxhkdrc".text = concatStringsSep "\n" [

View file

@ -29,6 +29,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.taskwarrior-sync" pkgs
lib.platforms.linux)
];
systemd.user.services.taskwarrior-sync = { systemd.user.services.taskwarrior-sync = {
Unit = { Description = "Taskwarrior sync"; }; Unit = { Description = "Taskwarrior sync"; };
Service = { Service = {

View file

@ -37,6 +37,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.unclutter" pkgs
lib.platforms.linux)
];
systemd.user.services.unclutter = { systemd.user.services.unclutter = {
Unit = { Unit = {
Description = "unclutter"; Description = "unclutter";

View file

@ -93,6 +93,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.unison" pkgs
lib.platforms.linux)
];
systemd.user.services = makeDefs (name: pairCfg: { systemd.user.services = makeDefs (name: pairCfg: {
Unit = { Unit = {
Description = "Unison pair sync (${name})"; Description = "Unison pair sync (${name})";

View file

@ -45,7 +45,13 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(hm.assertions.assertPlatform "xsession.windowManager.awesome" pkgs
platforms.linux)
];
home.packages = [ awesome ]; home.packages = [ awesome ];
xsession.windowManager.command = "${awesome}/bin/awesome " xsession.windowManager.command = "${awesome}/bin/awesome "
+ optionalString cfg.noArgb "--no-argb " + makeSearchPath cfg.luaModules; + optionalString cfg.noArgb "--no-argb " + makeSearchPath cfg.luaModules;
}; };

View file

@ -42,6 +42,11 @@ in {
options = import ./options.nix { inherit pkgs lib; }; options = import ./options.nix { inherit pkgs lib; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(hm.assertions.assertPlatform "xsession.windowManager.bspwm" pkgs
platforms.linux)
];
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
xdg.configFile."bspwm/bspwmrc".source = pkgs.writeShellScript "bspwmrc" '' xdg.configFile."bspwm/bspwmrc".source = pkgs.writeShellScript "bspwmrc" ''

View file

@ -241,8 +241,15 @@ in {
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
{ {
assertions = [
(hm.assertions.assertPlatform "xsession.windowManager.i3" pkgs
platforms.linux)
];
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
xsession.windowManager.command = "${cfg.package}/bin/i3"; xsession.windowManager.command = "${cfg.package}/bin/i3";
xdg.configFile."i3/config" = { xdg.configFile."i3/config" = {
source = checkI3Config; source = checkI3Config;
onChange = '' onChange = ''

View file

@ -427,8 +427,14 @@ in {
}) })
{ {
assertions = [
(hm.assertions.assertPlatform "wayland.windowManager.sway" pkgs
platforms.linux)
];
home.packages = optional (cfg.package != null) cfg.package home.packages = optional (cfg.package != null) cfg.package
++ optional cfg.xwayland pkgs.xwayland; ++ optional cfg.xwayland pkgs.xwayland;
xdg.configFile."sway/config" = { xdg.configFile."sway/config" = {
source = configFile; source = configFile;
onChange = '' onChange = ''
@ -439,6 +445,7 @@ in {
fi fi
''; '';
}; };
systemd.user.targets.sway-session = mkIf cfg.systemdIntegration { systemd.user.targets.sway-session = mkIf cfg.systemdIntegration {
Unit = { Unit = {
Description = "sway compositor session"; Description = "sway compositor session";

View file

@ -137,10 +137,23 @@ in {
}/bin/xmonad-${pkgs.hostPlatform.system}"; }/bin/xmonad-${pkgs.hostPlatform.system}";
in mkIf cfg.enable (mkMerge [ 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) { (mkIf (cfg.config == null) {
xsession.windowManager.command = "${xmonad}/bin/xmonad"; xsession.windowManager.command = "${xmonad}/bin/xmonad";
}) })
(mkIf (cfg.config != null) { (mkIf (cfg.config != null) {
xsession.windowManager.command = xmonadBin; xsession.windowManager.command = xmonadBin;
home.file.".xmonad/xmonad.hs".source = cfg.config; home.file.".xmonad/xmonad.hs".source = cfg.config;
@ -156,10 +169,5 @@ in {
}; };
}) })
{
home.file = mapAttrs' (name: value:
attrsets.nameValuePair (".xmonad/lib/" + name) { source = value; })
cfg.libFiles;
}
]); ]);
} }

View file

@ -73,6 +73,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.wlsunset" pkgs
lib.platforms.linux)
];
systemd.user.services.wlsunset = { systemd.user.services.wlsunset = {
Unit = { Unit = {
Description = "Day/night gamma adjustments for Wayland compositors."; Description = "Day/night gamma adjustments for Wayland compositors.";

View file

@ -53,6 +53,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.xcape" pkgs
lib.platforms.linux)
];
systemd.user.services.xcape = { systemd.user.services.xcape = {
Unit = { Unit = {
Description = "xcape"; Description = "xcape";

View file

@ -26,6 +26,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.xembed-sni-proxy" pkgs
lib.platforms.linux)
];
systemd.user.services.xembed-sni-proxy = { systemd.user.services.xembed-sni-proxy = {
Unit = { Unit = {
Description = "XEmbed SNI Proxy"; Description = "XEmbed SNI Proxy";

View file

@ -132,6 +132,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.xidlehook" pkgs
lib.platforms.linux)
];
systemd.user.services.xidlehook = { systemd.user.services.xidlehook = {
Unit = { Unit = {
Description = "xidlehook service"; Description = "xidlehook service";

View file

@ -29,6 +29,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.xscreensaver" pkgs
lib.platforms.linux)
];
# To make the xscreensaver-command tool available. # To make the xscreensaver-command tool available.
home.packages = [ pkgs.xscreensaver ]; home.packages = [ pkgs.xscreensaver ];

View file

@ -25,6 +25,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.xsettingsd" pkgs
lib.platforms.linux)
];
systemd.user.services.xsettingsd = { systemd.user.services.xsettingsd = {
Unit = { Unit = {
Description = "xsettingsd"; Description = "xsettingsd";

View file

@ -148,6 +148,11 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.xsuspender" pkgs
lib.platforms.linux)
];
services.xsuspender.iniContent = let services.xsuspender.iniContent = let
mkSection = values: mkSection = values:
filterAttrs (_: v: v != null) { filterAttrs (_: v: v != null) {

View file

@ -43,6 +43,11 @@ in {
}; };
config = mkIf (activationCmds != [ ]) { config = mkIf (activationCmds != [ ]) {
assertions = [
(hm.assertions.assertPlatform "targets.darwin.defaults" pkgs
platforms.darwin)
];
home.activation.setDarwinDefaults = hm.dag.entryAfter [ "writeBoundary" ] '' home.activation.setDarwinDefaults = hm.dag.entryAfter [ "writeBoundary" ] ''
$VERBOSE_ECHO "Configuring macOS user defaults" $VERBOSE_ECHO "Configuring macOS user defaults"
${concatStringsSep "\n" activationCmds} ${concatStringsSep "\n" activationCmds}

View file

@ -12,16 +12,18 @@ let
fonts = "${fontsEnv}/share/fonts"; fonts = "${fontsEnv}/share/fonts";
in { in {
# macOS won't recognize symlinked fonts # macOS won't recognize symlinked fonts
config.home.activation.copyFonts = hm.dag.entryAfter [ "writeBoundary" ] '' config = mkIf pkgs.hostPlatform.isDarwin {
copyFonts() { home.activation.copyFonts = hm.dag.entryAfter [ "writeBoundary" ] ''
rm -rf ${homeDir}/Library/Fonts/HomeManager || : copyFonts() {
rm -rf ${homeDir}/Library/Fonts/HomeManager || :
local f local f
find -L "${fonts}" -type f -printf '%P\0' | while IFS= read -rd "" f; do find -L "${fonts}" -type f -printf '%P\0' | while IFS= read -rd "" f; do
$DRY_RUN_CMD install $VERBOSE_ARG -Dm644 -T \ $DRY_RUN_CMD install $VERBOSE_ARG -Dm644 -T \
"${fonts}/$f" "${homeDir}/Library/Fonts/HomeManager/$f" "${fonts}/$f" "${homeDir}/Library/Fonts/HomeManager/$f"
done done
} }
copyFonts copyFonts
''; '';
};
} }

View file

@ -31,6 +31,11 @@ in {
}; };
config = mkIf (cfg.keybindings != { }) { 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 # NOTE: just copy the files because symlinks won't be recognized by macOS
home.activation.setCocoaKeybindings = home.activation.setCocoaKeybindings =
hm.dag.entryAfter [ "writeBoundary" ] '' hm.dag.entryAfter [ "writeBoundary" ] ''

View file

@ -20,6 +20,11 @@ in {
}; };
config = mkIf (cfg.search != null) { config = mkIf (cfg.search != null) {
assertions = [
(hm.assertions.assertPlatform "targets.darwin.search" pkgs
platforms.darwin)
];
targets.darwin.defaults = { targets.darwin.defaults = {
NSGlobalDomain.NSPreferredWebServices = { NSGlobalDomain.NSPreferredWebServices = {
NSWebServicesProviderWebSearch = { NSWebServicesProviderWebSearch = {

View file

@ -27,6 +27,10 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [
(hm.assertions.assertPlatform "targets.genericLinux" pkgs platforms.linux)
];
xdg.systemDirs.data = [ xdg.systemDirs.data = [
# Nix profiles # Nix profiles
"\${NIX_STATE_DIR:-/nix/var/nix}/profiles/default/share" "\${NIX_STATE_DIR:-/nix/var/nix}/profiles/default/share"

View file

@ -55,6 +55,10 @@ in {
}; };
config = mkIf (cfg != null) { config = mkIf (cfg != null) {
assertions = [
(hm.assertions.assertPlatform "xsession.pointerCursor" pkgs
platforms.linux)
];
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];

View file

@ -85,6 +85,9 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions =
[ (hm.assertions.assertPlatform "xsession" pkgs platforms.linux) ];
xsession.importedVariables = [ xsession.importedVariables = [
"DBUS_SESSION_BUS_ADDRESS" "DBUS_SESSION_BUS_ADDRESS"
"DISPLAY" "DISPLAY"