Skip to content

Instantly share code, notes, and snippets.

@ottidmes
Created July 21, 2017 01:12
Show Gist options
  • Save ottidmes/dcdb4dcb2a02392860e0b3c7e9a7ace0 to your computer and use it in GitHub Desktop.
Save ottidmes/dcdb4dcb2a02392860e0b3c7e9a7ace0 to your computer and use it in GitHub Desktop.
Custom X cursor in NixOS
{ stdenv, lib, fetchurl, variants ? [ "Premium" "Premium-left" ] }:
with lib;
stdenv.mkDerivation rec {
name = "${package-name}-${version}";
package-name = "premium-xcursor-theme";
version = "0.3";
src = fetchurl {
url = "https://dl.opendesktop.org/api/files/download/id/1460735120/14485-Premium-${version}.tar.bz2";
sha256 = "15lmfgpzq8zfsd6q80zp3ylqdxsqmdrl5ykvwlw11qhxzl34viz4";
};
installPhase = ''
for theme in ${concatStringsSep " " variants}; do
mkdir -p $out/share/icons/$theme
cp -R $theme/{cursors,index.theme} $out/share/icons/$theme/
done
'';
meta = {
description = "Premium X cursor theme";
homepage = http://www.kde-look.org/content/show.php?content=14485;
platforms = platforms.all;
license = licenses.gpl3;
maintainers = with maintainers; [ msteen ];
};
}
{ config, lib, pkgs, ... }:
with lib;
let cfg = config.xcursor;
in {
options.xcursor = {
theme = mkOption {
default = "Premium";
type = types.string;
description = ''
The X cursor theme to apply.
'';
};
};
config = {
environment = {
profileRelativeEnvVars.XCURSOR_PATH = [ "/share/icons" ];
etc."xdg/gtk-3.0/settings.ini" = {
text = ''
[Settings]
gtk-cursor-theme-name=${cfg.theme}
'';
mode = "444";
};
systemPackages = [
(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.theme}
EOL
ln -s /run/current-system/sw/share/icons/${cfg.theme}/cursors $out/share/icons/default/cursors
'';
meta = {
description = "Install the default X cursor theme globally.";
};
}) { })
];
pathsToLink = [ "/share/icons" ];
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment