mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-12 04:35:41 +03:00
nixos/hidpi: remove
The single option tries to do too much work, which just ends up confusing people. So: - don't force the console font, the kernel can figure this out as of #210205 - don't force the systemd-boot mode, it's an awkward mode that's not supported on most things and will break flicker-free boot - add a separate option for the xorg cursor scaling trick and move it under the xorg namespace - add a general `fonts.optimizeForVeryHighDPI` option that explicitly says what it does - alias the old option to that - don't set any of those automatically in nixos-generate-config
This commit is contained in:
parent
49fd723a69
commit
4787ebf7ae
6 changed files with 64 additions and 75 deletions
|
@ -246,10 +246,10 @@ In addition to numerous new and upgraded packages, this release has the followin
|
||||||
[headscale's example configuration](https://github.com/juanfont/headscale/blob/main/config-example.yaml)
|
[headscale's example configuration](https://github.com/juanfont/headscale/blob/main/config-example.yaml)
|
||||||
can be directly written as attribute-set in Nix within this option.
|
can be directly written as attribute-set in Nix within this option.
|
||||||
|
|
||||||
- `hardware.video.hidpi` now provides defaults that are consistent with `fontconfig`'s documentation:
|
- The `hardware.video.hidpi.enable` was renamed to `fonts.optimizeForVeryHighDPI` to be consistent with what it actually does.
|
||||||
- antialiasing and font hinting are disabled, as they have no visible effects at high pixel densities;
|
They disable by default: antialiasing, hinting and LCD filter for subpixel rendering. They can be overridden if you experience problems with font rendering.
|
||||||
- subpixel order isn't set: it was irrelevant with the above disabled, and the module *cannot* know the correct
|
On Xorg, the default cursor is upscaled.
|
||||||
setting for the user's screen.
|
Please see the documentation for the new option to decide if you want to keep it enabled.
|
||||||
|
|
||||||
- `nixos/lib/make-disk-image.nix` can now mutate EFI variables, run user-provided EFI firmware or variable templates. This is now extensively documented in the NixOS manual.
|
- `nixos/lib/make-disk-image.nix` can now mutate EFI variables, run user-provided EFI firmware or variable templates. This is now extensively documented in the NixOS manual.
|
||||||
|
|
||||||
|
|
|
@ -3,29 +3,7 @@
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
# A scalable variant of the X11 "core" cursor
|
cfg = config.fonts;
|
||||||
#
|
|
||||||
# If not running a fancy desktop environment, the cursor is likely set to
|
|
||||||
# the default `cursor.pcf` bitmap font. This is 17px wide, so it's very
|
|
||||||
# small and almost invisible on 4K displays.
|
|
||||||
fontcursormisc_hidpi = pkgs.xorg.fontxfree86type1.overrideAttrs (old:
|
|
||||||
let
|
|
||||||
# The scaling constant is 230/96: the scalable `left_ptr` glyph at
|
|
||||||
# about 23 points is rendered as 17px, on a 96dpi display.
|
|
||||||
# Note: the XLFD font size is in decipoints.
|
|
||||||
size = 2.39583 * config.services.xserver.dpi;
|
|
||||||
sizeString = builtins.head (builtins.split "\\." (toString size));
|
|
||||||
in
|
|
||||||
{
|
|
||||||
postInstall = ''
|
|
||||||
alias='cursor -xfree86-cursor-medium-r-normal--0-${sizeString}-0-0-p-0-adobe-fontspecific'
|
|
||||||
echo "$alias" > $out/lib/X11/fonts/Type1/fonts.alias
|
|
||||||
'';
|
|
||||||
});
|
|
||||||
|
|
||||||
hasHidpi =
|
|
||||||
config.hardware.video.hidpi.enable &&
|
|
||||||
config.services.xserver.dpi != null;
|
|
||||||
|
|
||||||
defaultFonts =
|
defaultFonts =
|
||||||
[ pkgs.dejavu_fonts
|
[ pkgs.dejavu_fonts
|
||||||
|
@ -36,16 +14,12 @@ let
|
||||||
pkgs.noto-fonts-emoji
|
pkgs.noto-fonts-emoji
|
||||||
];
|
];
|
||||||
|
|
||||||
defaultXFonts =
|
|
||||||
[ (if hasHidpi then fontcursormisc_hidpi else pkgs.xorg.fontcursormisc)
|
|
||||||
pkgs.xorg.fontmiscmisc
|
|
||||||
];
|
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
(mkRemovedOptionModule [ "fonts" "enableCoreFonts" ] "Use fonts.fonts = [ pkgs.corefonts ]; instead.")
|
(mkRemovedOptionModule [ "fonts" "enableCoreFonts" ] "Use fonts.fonts = [ pkgs.corefonts ]; instead.")
|
||||||
|
(mkRenamedOptionModule [ "hardware" "video" "hidpi" "enable" ] [ "fonts" "optimizeForVeryHighDPI" ])
|
||||||
];
|
];
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
|
@ -69,13 +43,32 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
optimizeForVeryHighDPI = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
Optimize configuration for very high-density (>200 DPI) displays:
|
||||||
|
- disable subpixel anti-aliasing
|
||||||
|
- disable hinting
|
||||||
|
- automatically upscale the default X11 cursor
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkMerge [
|
config = mkMerge [
|
||||||
{ fonts.fonts = mkIf config.fonts.enableDefaultFonts defaultFonts; }
|
{ fonts.fonts = mkIf cfg.enableDefaultFonts defaultFonts; }
|
||||||
{ fonts.fonts = mkIf config.services.xserver.enable defaultXFonts; }
|
(mkIf cfg.optimizeForVeryHighDPI {
|
||||||
|
services.xserver.upscaleDefaultCursor = mkDefault true;
|
||||||
|
# Conforms to the recommendation in fonts/fontconfig.nix
|
||||||
|
# for > 200DPI.
|
||||||
|
fonts.fontconfig = {
|
||||||
|
antialias = mkDefault false;
|
||||||
|
hinting.enable = mkDefault false;
|
||||||
|
subpixel.lcdfilter = mkDefault "none";
|
||||||
|
};
|
||||||
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
{ lib, pkgs, config, ...}:
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
{
|
|
||||||
options.hardware.video.hidpi.enable = mkEnableOption (lib.mdDoc "Font/DPI configuration optimized for HiDPI displays");
|
|
||||||
|
|
||||||
config = mkIf config.hardware.video.hidpi.enable {
|
|
||||||
console.font = lib.mkDefault "${pkgs.terminus_font}/share/consolefonts/ter-v32n.psf.gz";
|
|
||||||
|
|
||||||
# Needed when typing in passwords for full disk encryption
|
|
||||||
console.earlySetup = mkDefault true;
|
|
||||||
boot.loader.systemd-boot.consoleMode = mkDefault "1";
|
|
||||||
|
|
||||||
|
|
||||||
# Disable font anti-aliasing, hinting, and sub-pixel rendering by default
|
|
||||||
# See recommendations in fonts/fontconfig.nix
|
|
||||||
fonts.fontconfig = {
|
|
||||||
antialias = mkDefault false;
|
|
||||||
hinting.enable = mkDefault false;
|
|
||||||
subpixel.lcdfilter = mkDefault "none";
|
|
||||||
};
|
|
||||||
|
|
||||||
# TODO Find reasonable defaults X11 & wayland
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -518,21 +518,6 @@ EOF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# For lack of a better way to determine it, guess whether we should use a
|
|
||||||
# bigger font for the console from the display mode on the first
|
|
||||||
# framebuffer. A way based on the physical size/actual DPI reported by
|
|
||||||
# the monitor would be nice, but I don't know how to do this without X :)
|
|
||||||
my $fb_modes_file = "/sys/class/graphics/fb0/modes";
|
|
||||||
if (-f $fb_modes_file && -r $fb_modes_file) {
|
|
||||||
my $modes = read_file($fb_modes_file);
|
|
||||||
$modes =~ m/([0-9]+)x([0-9]+)/;
|
|
||||||
my $console_width = $1, my $console_height = $2;
|
|
||||||
if ($console_width > 1920) {
|
|
||||||
push @attrs, "# high-resolution display";
|
|
||||||
push @attrs, 'hardware.video.hidpi.enable = lib.mkDefault true;';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Generate the hardware configuration file.
|
# Generate the hardware configuration file.
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,6 @@
|
||||||
./hardware/video/bumblebee.nix
|
./hardware/video/bumblebee.nix
|
||||||
./hardware/video/capture/mwprocapture.nix
|
./hardware/video/capture/mwprocapture.nix
|
||||||
./hardware/video/displaylink.nix
|
./hardware/video/displaylink.nix
|
||||||
./hardware/video/hidpi.nix
|
|
||||||
./hardware/video/nvidia.nix
|
./hardware/video/nvidia.nix
|
||||||
./hardware/video/switcheroo-control.nix
|
./hardware/video/switcheroo-control.nix
|
||||||
./hardware/video/uvcvideo/default.nix
|
./hardware/video/uvcvideo/default.nix
|
||||||
|
|
|
@ -138,6 +138,26 @@ let
|
||||||
concatMapStringsSep "\n" (line: prefix + line) (splitString "\n" str);
|
concatMapStringsSep "\n" (line: prefix + line) (splitString "\n" str);
|
||||||
|
|
||||||
indent = prefixStringLines " ";
|
indent = prefixStringLines " ";
|
||||||
|
|
||||||
|
# A scalable variant of the X11 "core" cursor
|
||||||
|
#
|
||||||
|
# If not running a fancy desktop environment, the cursor is likely set to
|
||||||
|
# the default `cursor.pcf` bitmap font. This is 17px wide, so it's very
|
||||||
|
# small and almost invisible on 4K displays.
|
||||||
|
fontcursormisc_hidpi = pkgs.xorg.fontxfree86type1.overrideAttrs (old:
|
||||||
|
let
|
||||||
|
# The scaling constant is 230/96: the scalable `left_ptr` glyph at
|
||||||
|
# about 23 points is rendered as 17px, on a 96dpi display.
|
||||||
|
# Note: the XLFD font size is in decipoints.
|
||||||
|
size = 2.39583 * cfg.dpi;
|
||||||
|
sizeString = builtins.head (builtins.split "\\." (toString size));
|
||||||
|
in
|
||||||
|
{
|
||||||
|
postInstall = ''
|
||||||
|
alias='cursor -xfree86-cursor-medium-r-normal--0-${sizeString}-0-0-p-0-adobe-fontspecific'
|
||||||
|
echo "$alias" > $out/lib/X11/fonts/Type1/fonts.alias
|
||||||
|
'';
|
||||||
|
});
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -576,6 +596,15 @@ in
|
||||||
Whether to terminate X upon server reset.
|
Whether to terminate X upon server reset.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
upscaleDefaultCursor = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
Upscale the default X cursor to be more visible on high-density displays.
|
||||||
|
Requires `config.services.xserver.dpi` to be set.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -627,6 +656,10 @@ in
|
||||||
+ "${toString (length primaryHeads)} heads set to primary: "
|
+ "${toString (length primaryHeads)} heads set to primary: "
|
||||||
+ concatMapStringsSep ", " (x: x.output) primaryHeads;
|
+ concatMapStringsSep ", " (x: x.output) primaryHeads;
|
||||||
})
|
})
|
||||||
|
{
|
||||||
|
assertion = cfg.upscaleDefaultCursor -> cfg.dpi != null;
|
||||||
|
message = "Specify `config.services.xserver.dpi` to upscale the default cursor.";
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
environment.etc =
|
environment.etc =
|
||||||
|
@ -851,6 +884,10 @@ in
|
||||||
'';
|
'';
|
||||||
|
|
||||||
fonts.enableDefaultFonts = mkDefault true;
|
fonts.enableDefaultFonts = mkDefault true;
|
||||||
|
fonts.fonts = [
|
||||||
|
(if cfg.upscaleDefaultCursor then fontcursormisc_hidpi else pkgs.xorg.fontcursormisc)
|
||||||
|
pkgs.xorg.fontmiscmisc
|
||||||
|
];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue