Skip to content

Instantly share code, notes, and snippets.

@ottidmes
Last active December 2, 2018 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ottidmes/838b10345e480ce493aef0057a931237 to your computer and use it in GitHub Desktop.
Save ottidmes/838b10345e480ce493aef0057a931237 to your computer and use it in GitHub Desktop.
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.desktop;
in {
options.desktop = {
gtk2Theme = mkOption {
default = "Arc";
type = types.string;
description = ''
The GTK 2 theme to apply.
'';
};
gtk2IconTheme = mkOption {
default = "Arc";
type = types.string;
description = ''
The GTK 2 icon theme to apply.
'';
};
gtk3Theme = mkOption {
default = "Arc";
type = types.string;
description = ''
The GTK 3 theme to apply.
'';
};
gtk3IconTheme = mkOption {
default = "Arc";
type = types.string;
description = ''
The GTK 3 icon theme to apply.
'';
};
qt4Theme = mkOption {
default = "Breeze";
type = types.string;
description = ''
The Qt 4 theme to apply.
'';
};
qt5Theme = mkOption {
default = "Breeze";
type = types.string;
description = ''
The Qt 5 theme to apply.
'';
};
xcursorTheme = mkOption {
default = "Premium";
type = types.string;
description = ''
The X cursor theme to apply.
'';
};
removeUserSettings = mkOption {
default = false;
type = types.bool;
description = ''
Remove user settings in order to enforce global settings.
'';
};
};
config = mkMerge [
{
environment.extraInit = "export XDG_CONFIG_DIRS=/etc/xdg:$XDG_CONFIG_DIRS";
environment.pathsToLink = [ "/share" ]; # needed for themes and backgrounds
}
{
environment.variables.QT_STYLE_OVERRIDE = cfg.qt5Theme; # overrides the style since Qt 5.7
}
{
environment.shellInit = mkIf cfg.removeUserSettings "rm -f ~/.config/Trolltech.conf";
environment.etc."xdg/Trolltech.conf" = {
text = ''
[Qt]
style=${cfg.qt4Theme}
'';
mode = "444";
};
}
{
environment.extraInit = ''
export GDK_PIXBUF_MODULEDIR=$(echo ${pkgs.librsvg.out}/lib/gdk-pixbuf-2.0/*/loaders)
export GDK_PIXBUF_MODULE_FILE=$(echo ${pkgs.librsvg.out}/lib/gdk-pixbuf-2.0/*/loaders.cache)
export GTK2_RC_FILES=${pkgs.writeText "iconrc" ''gtk-icon-theme-name="${cfg.gtk2IconTheme}"''}:${toString config.system.path}/share/themes/${cfg.gtk2Theme}/gtk-2.0/gtkrc:$GTK2_RC_FILES
'';
environment.variables.GTK_DATA_PREFIX = toString config.system.path; # needed for GTK to find theme data
}
{
environment.shellInit = mkIf cfg.removeUserSettings "rm -f ~/.config/gtk-3.0/settings.ini";
environment.etc."xdg/gtk-3.0/settings.ini" = {
text = ''
[Settings]
gtk-theme-name=${cfg.gtk3Theme}
gtk-icon-theme-name=${cfg.gtk3IconTheme}
gtk-cursor-theme-name=${cfg.xcursorTheme}
'';
mode = "444";
};
}
{
environment.profileRelativeEnvVars.XCURSOR_PATH = [ "/share/icons" ];
environment.extraInit = mkIf (!cfg.removeUserSettings) "export XCURSOR_PATH=~/.icons:$XCURSOR_PATH";
}
{
environment.shellInit = mkIf cfg.removeUserSettings "rm -fR ~/.icons/default";
environment.systemPackages = singleton (pkgs.callPackage ({ stdenv }: stdenv.mkDerivation rec {
name = "default-xcursor-theme";
phases = [ "installPhase" ];
installPhase = ''
mkdir -p $out/share/icons/default
cat <<'EOL' > $out/share/icons/default/icon.theme
[Icon Theme]
Inherits=${cfg.xcursorTheme}
EOL
ln -s /run/current-system/sw/share/icons/${cfg.xcursorTheme}/cursors $out/share/icons/default/cursors
'';
meta = {
description = "Install the default X cursor theme globally.";
};
}) { });
}
];
}
{
fonts = {
enableCoreFonts = true;
enableFontDir = true;
enableGhostscriptFonts = true;
fonts = with pkgs; [
dejavu_fonts
fira-code
font-awesome-ttf
font-droid
freefont_ttf
inconsolata
liberation_ttf
noto-fonts
powerline-fonts
siji
terminus_font
ttf_bitstream_vera
ubuntu_font_family
unifont
vistafonts
iosevka
];
};
}
{ config, lib, pkgs, ... }:
with lib;
{
config = mkMerge [
{
# If I want a custom X startup script:
# https://www.reddit.com/r/xmonad/comments/40nem8/first_install_of_xmonad_on_nixos_and_having_some/
services.xserver = {
updateDbusEnvironment = true;
displayManager = {
lightdm = {
enable = true;
autoLogin = {
enable = true;
user = "<your_user_name>";
};
};
};
desktopManager = {
xterm.enable = false;
default = mkDefault "none";
};
};
}
{
environment.systemPackages = with pkgs; [
# Shared by desktops
shared_mime_info
hicolor_icon_theme # default icon theme
gnome3.gnome_themes_standard # default Gnome theme (incl. icons and engines)
oxygen-icons5 # default KDE icon theme
];
}
{
security.polkit = {
enable = true;
extraConfig = ''
polkit.addRule(function(action, subject) {
if ((action.id == "org.freedesktop.udisks2.filesystem-mount-system" ||
action.id == "org.freedesktop.udisks2.encrypted-unlock-system") &&
subject.local && subject.active && subject.isInGroup("wheel")) {
return polkit.Result.YES;
}
});
'';
};
# Gnome 3 GVFS has Android support.
environment.variables.GIO_EXTRA_MODULES = [ "${pkgs.gnome3.gvfs}/lib/gio/modules" ];
services.gnome3.gvfs.enable = true;
services.udisks2.enable = true; # needed by GVFS
# The XFCE version has not been packaged yet.
environment.systemPackages = singleton pkgs.lxqt.lxqt-policykit;
}
{
environment.systemPackages = with pkgs; [
# Apps from Gnome 3 desktop
gnome3.dconf
gnome3.file-roller # ark or peazip would be alternatives
(hiPrio gnome3.nautilus)
# Apps from KDE desktop
okular
# Apps from XFCE 4 desktop
xfce.exo # manages preferred applications
xfce.terminal
xfce.xfce4-screenshooter
xfce.xfce4taskmanager
xfce.xfconf # same as dconf / gconf for Gnome
# Apps from LXQT desktop
lxqt.pavucontrol-qt # sound manager
lxqt.lxqt-sudo
# Apps unaffiliated to any desktop
arandr
mirage # image viewer
nitrogen # wallpaper manager
# qarma # qt variant of zenity
udiskie
];
}
{
desktop = {
gtk2IconTheme = "Arc";
gtk2Theme = "Arc";
gtk3IconTheme = "Arc";
gtk3Theme = "Arc";
# qt4Theme = "Breeze";
qt5Theme = "Breeze";
removeUserSettings = true;
xcursorTheme = "Premium";
};
environment.systemPackages = with pkgs; [
arc-icon-theme
arc-theme
# breeze-qt4
breeze-qt5
gtk-engine-murrine # needed by Arc GTK theme
# polar-xcursor-theme
# (premium-xcursor-theme.override { variants = [ "Premium" ]; })
];
}
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment