Skip to content

Commit

Permalink
modules: add platform conditions
Browse files Browse the repository at this point in the history
This marks Linux-specific modules as such and will not load them on
Darwin.
  • Loading branch information
rycee committed Dec 16, 2018
1 parent 38ee75d commit fed722b
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 54 deletions.
50 changes: 39 additions & 11 deletions modules/misc/news.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ let

cfg = config.news;

hostPlatform = pkgs.stdenv.hostPlatform;

entryModule = types.submodule ({ config, ... }: {
options = {
id = mkOption {
Expand Down Expand Up @@ -176,20 +178,23 @@ in

{
time = "2017-09-12T14:22:18+00:00";
condition = hostPlatform.isLinux;
message = ''
A new service is available: 'services.blueman-applet'.
'';
}

{
time = "2017-09-13T11:30:22+00:00";
condition = hostPlatform.isLinux;
message = ''
A new service is available: 'services.compton'.
'';
}

{
time = "2017-09-20T14:47:14+00:00";
condition = hostPlatform.isLinux;
message = ''
A new service is available: 'services.screen-locker'.
'';
Expand Down Expand Up @@ -242,7 +247,7 @@ in

{
time = "2017-10-02T11:15:03+00:00";
condition = config.services.udiskie.enable;
condition = hostPlatform.isLinux && config.services.udiskie.enable;
message = ''
The udiskie service now defaults to automatically mounting
new devices. Previous behavior was to not automatically
Expand All @@ -256,13 +261,15 @@ in

{
time = "2017-10-04T18:36:07+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'xsession.windowManager.xmonad'.
'';
}

{
time = "2017-10-06T08:21:43+00:00";
condition = hostPlatform.isLinux;
message = ''
A new service is available: 'services.polybar'.
'';
Expand Down Expand Up @@ -306,8 +313,11 @@ in

{
time = "2017-10-20T12:15:27+00:00";
condition = with config.systemd.user;
services != {} || sockets != {} || targets != {} || timers != {};
condition =
hostPlatform.isLinux
&& (with config.systemd.user;
services != {} || sockets != {} || targets != {} || timers != {}
);
message = ''
Home Manager's interaction with systemd is now done using
'systemctl' from Nixpkgs, not the 'systemctl' in '$PATH'.
Expand Down Expand Up @@ -392,6 +402,7 @@ in

{
time = "2017-10-31T11:46:07+00:00";
condition = hostPlatform.isLinux;
message = ''
A new window manager module is available: 'xsession.windowManager.i3'.
'';
Expand All @@ -406,9 +417,11 @@ in

{
time = "2017-11-14T19:56:49+00:00";
condition = with config.xsession.windowManager; (
i3.enable && i3.config != null && i3.config.startup != []
);
condition =
hostPlatform.isLinux
&& (with config.xsession.windowManager;
i3.enable && i3.config != null && i3.config.startup != []
);
message = ''
A new 'notification' option was added to
xsession.windowManager.i3.startup submodule.
Expand All @@ -421,7 +434,7 @@ in

{
time = "2017-11-17T10:36:10+00:00";
condition = config.xsession.windowManager.i3.enable;
condition = hostPlatform.isLinux && config.xsession.windowManager.i3.enable;
message = ''
The i3 window manager module has been extended with the following options:
Expand All @@ -434,6 +447,7 @@ in

{
time = "2017-11-26T21:57:23+00:00";
condition = hostPlatform.isLinux;
message = ''
Two new modules are available:
Expand All @@ -443,14 +457,17 @@ in

{
time = "2017-12-07T22:23:11+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.parcellite'
'';
}

{
time = "2017-12-11T17:23:12+00:00";
condition = config.home.activation ? reloadSystemD;
condition =
hostPlatform.isLinux
&& config.home.activation ? reloadSystemD;
message = ''
The Boolean option 'systemd.user.startServices' is now
available. When enabled the current naive systemd unit
Expand All @@ -469,14 +486,15 @@ in

{
time = "2018-02-03T10:00:00+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.stalonetray'
'';
}

{
time = "2018-02-04T22:58:49+00:00";
condition = config.xsession.enable;
condition = hostPlatform.isLinux && config.xsession.enable;
message = ''
A new option 'xsession.pointerCursor' is now available. It
allows specifying the pointer cursor theme and size. The
Expand Down Expand Up @@ -557,6 +575,7 @@ in

{
time = "2018-03-04T06:54:26+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.unclutter'
'';
Expand Down Expand Up @@ -618,19 +637,22 @@ in

{
time = "2018-05-01T20:49:31+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.mbsync'.
'';
}
{
time = "2018-05-03T12:34:47+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.flameshot'.
'';
}

{
time = "2018-05-18T18:34:15+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'qt'
Expand All @@ -641,6 +663,7 @@ in

{
time = "2018-06-05T01:36:45+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.kdeconnect'.
'';
Expand Down Expand Up @@ -688,20 +711,23 @@ in

{
time = "2018-07-07T15:48:56+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'xsession.windowManager.awesome'.
'';
}

{
time = "2018-07-18T20:14:11+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.mpd'.
'';
}

{
time = "2018-07-31T13:33:39+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.status-notifier-watcher'.
'';
Expand All @@ -723,7 +749,7 @@ in

{
time = "2018-08-18T19:03:42+00:00";
condition = config.services.gpg-agent.enable;
condition = hostPlatform.isLinux && config.services.gpg-agent.enable;
message = ''
A new option is available: 'services.gpg-agent.extraConfig'.
Expand All @@ -734,7 +760,7 @@ in

{
time = "2018-08-19T20:46:09+00:00";
condition = pkgs.stdenv.isLinux;
condition = hostPlatform.isLinux;
message = ''
A new modules is available: 'programs.chromium'.
'';
Expand All @@ -749,6 +775,7 @@ in

{
time = "2018-08-21T20:13:50+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.pasystray'.
'';
Expand Down Expand Up @@ -867,6 +894,7 @@ in

{
time = "2018-11-25T22:10:15+00:00";
condition = hostPlatform.isLinux;
message = ''
A new module is available: 'services.nextcloud-client'.
'';
Expand Down
83 changes: 41 additions & 42 deletions modules/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let
(loadModule { file = ./misc/news.nix; })
(loadModule { file = ./misc/nixpkgs.nix; })
(loadModule { file = ./misc/pam.nix; })
(loadModule { file = ./misc/qt.nix; })
(loadModule { file = ./misc/qt.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./misc/version.nix; })
(loadModule { file = ./misc/xdg.nix; })
(loadModule { file = ./programs/afew.nix; })
Expand All @@ -41,6 +41,7 @@ let
(loadModule { file = ./programs/bash.nix; })
(loadModule { file = ./programs/beets.nix; })
(loadModule { file = ./programs/browserpass.nix; })
(loadModule { file = ./programs/chromium.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./programs/command-not-found/command-not-found.nix; })
(loadModule { file = ./programs/direnv.nix; })
(loadModule { file = ./programs/eclipse.nix; })
Expand All @@ -50,7 +51,7 @@ let
(loadModule { file = ./programs/fish.nix; })
(loadModule { file = ./programs/fzf.nix; })
(loadModule { file = ./programs/git.nix; })
(loadModule { file = ./programs/gnome-terminal.nix; })
(loadModule { file = ./programs/gnome-terminal.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./programs/go.nix; })
(loadModule { file = ./programs/home-manager.nix; })
(loadModule { file = ./programs/htop.nix; })
Expand All @@ -74,52 +75,50 @@ let
(loadModule { file = ./programs/termite.nix; })
(loadModule { file = ./programs/texlive.nix; })
(loadModule { file = ./programs/tmux.nix; })
(loadModule { file = ./programs/urxvt.nix; })
(loadModule { file = ./programs/urxvt.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./programs/vim.nix; })
(loadModule { file = ./programs/vscode.nix; })
(loadModule { file = ./programs/zathura.nix; })
(loadModule { file = ./programs/zsh.nix; })
(loadModule { file = ./services/blueman-applet.nix; })
(loadModule { file = ./services/compton.nix; })
(loadModule { file = ./services/dunst.nix; })
(loadModule { file = ./services/flameshot.nix; })
(loadModule { file = ./services/gnome-keyring.nix; })
(loadModule { file = ./services/gpg-agent.nix; })
(loadModule { file = ./services/kbfs.nix; })
(loadModule { file = ./services/kdeconnect.nix; })
(loadModule { file = ./services/keepassx.nix; })
(loadModule { file = ./services/keybase.nix; })
(loadModule { file = ./services/mbsync.nix; })
(loadModule { file = ./services/mpd.nix; })
(loadModule { file = ./services/network-manager-applet.nix; })
(loadModule { file = ./services/nextcloud-client.nix; })
(loadModule { file = ./services/owncloud-client.nix; })
(loadModule { file = ./services/parcellite.nix; })
(loadModule { file = ./services/pasystray.nix; })
(loadModule { file = ./services/polybar.nix; })
(loadModule { file = ./services/random-background.nix; })
(loadModule { file = ./services/redshift.nix; })
(loadModule { file = ./services/screen-locker.nix; })
(loadModule { file = ./services/stalonetray.nix; })
(loadModule { file = ./services/status-notifier-watcher.nix; })
(loadModule { file = ./services/syncthing.nix; })
(loadModule { file = ./services/taffybar.nix; })
(loadModule { file = ./services/tahoe-lafs.nix; })
(loadModule { file = ./services/udiskie.nix; })
(loadModule { file = ./services/unclutter.nix; })
(loadModule { file = ./services/window-managers/awesome.nix; })
(loadModule { file = ./services/window-managers/i3.nix; })
(loadModule { file = ./services/window-managers/xmonad.nix; })
(loadModule { file = ./services/xscreensaver.nix; })
(loadModule { file = ./systemd.nix; })
(loadModule { file = ./xcursor.nix; })
(loadModule { file = ./xresources.nix; })
(loadModule { file = ./xsession.nix; })
(loadModule { file = ./services/blueman-applet.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/compton.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/dunst.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/flameshot.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/gnome-keyring.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/gpg-agent.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/kbfs.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/kdeconnect.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/keepassx.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/keybase.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/mbsync.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/mpd.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/network-manager-applet.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/nextcloud-client.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/owncloud-client.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/parcellite.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/pasystray.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/polybar.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/random-background.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/redshift.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/screen-locker.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/stalonetray.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/status-notifier-watcher.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/syncthing.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/taffybar.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/tahoe-lafs.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/udiskie.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/unclutter.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/window-managers/awesome.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/window-managers/i3.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/window-managers/xmonad.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./services/xscreensaver.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./systemd.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./xcursor.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./xresources.nix; condition = hostPlatform.isLinux; })
(loadModule { file = ./xsession.nix; condition = hostPlatform.isLinux; })
(loadModule { file = <nixpkgs/nixos/modules/misc/assertions.nix>; })
(loadModule { file = <nixpkgs/nixos/modules/misc/meta.nix>; })
]
++
optional pkgs.stdenv.isLinux (loadModule { file = ./programs/chromium.nix; });
];

modules = map (getAttr "file") (filter (getAttr "condition") allModules);

Expand Down
6 changes: 5 additions & 1 deletion tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

let

lib = pkgs.lib;

nmt = pkgs.fetchFromGitLab {
owner = "rycee";
repo = "nmt";
Expand All @@ -13,11 +15,13 @@ in

import nmt {
inherit pkgs;
modules = import ../modules/modules.nix { inherit pkgs; lib = pkgs.lib; };
modules = import ../modules/modules.nix { inherit lib pkgs; };
testedAttrPath = [ "home" "activationPackage" ];
tests = {
"git/with-most-options" = ./modules/programs/git.nix;
"git/with-str-extra-config" = ./modules/programs/git-with-str-extra-config.nix;
}
// lib.optionalAttrs pkgs.hostPlatform.isLinux {
xresources = ./modules/xresources.nix;
};
}

0 comments on commit fed722b

Please sign in to comment.