summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorK900 <me@0upti.me>2023-03-20 21:22:22 +0300
committerK900 <me@0upti.me>2023-03-20 21:38:40 +0300
commit0d95358320c0317120615f572db1bc4d675e4fc3 (patch)
tree53ac97c98a478bb3aa245b0e8bed62388b9a8905
parentMerge pull request #218166 from ConnorBaker/feat/tiny-cuda-nn (diff)
downloadnixpkgs-origin/bye-dpi.tar.gz
nixos/hidpi: removeorigin/bye-dpi
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
-rw-r--r--nixos/doc/manual/release-notes/rl-2305.section.md2
-rw-r--r--nixos/modules/config/fonts/fonts.nix49
-rw-r--r--nixos/modules/hardware/video/hidpi.nix25
-rw-r--r--nixos/modules/installer/tools/nixos-generate-config.pl15
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/x11/xserver.nix37
6 files changed, 59 insertions, 70 deletions
diff --git a/nixos/doc/manual/release-notes/rl-2305.section.md b/nixos/doc/manual/release-notes/rl-2305.section.md
index 2c56b7e23747..2ac1270c0db9 100644
--- a/nixos/doc/manual/release-notes/rl-2305.section.md
+++ b/nixos/doc/manual/release-notes/rl-2305.section.md
@@ -320,3 +320,5 @@ In addition to numerous new and upgraded packages, this release has the followin
- The option `services.prometheus.exporters.pihole.interval` does not exist anymore and has been removed.
- `k3s` can now be configured with an EnvironmentFile for its systemd service, allowing secrets to be provided without ending up in the Nix Store.
+
+- The `hardware.video.hidpi.enable` was renamed to `fonts.optimizeForVeryHighDPI` to be consistent with what it actually does. Please see the documentation for the new option to decide if you want to keep it enabled.
diff --git a/nixos/modules/config/fonts/fonts.nix b/nixos/modules/config/fonts/fonts.nix
index c0619fa31a32..b622a8b61ee7 100644
--- a/nixos/modules/config/fonts/fonts.nix
+++ b/nixos/modules/config/fonts/fonts.nix
@@ -3,29 +3,7 @@
with lib;
let
- # 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 * 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;
+ cfg = config.fonts;
defaultFonts =
[ pkgs.dejavu_fonts
@@ -36,16 +14,12 @@ let
pkgs.noto-fonts-emoji
];
- defaultXFonts =
- [ (if hasHidpi then fontcursormisc_hidpi else pkgs.xorg.fontcursormisc)
- pkgs.xorg.fontmiscmisc
- ];
-
in
{
imports = [
(mkRemovedOptionModule [ "fonts" "enableCoreFonts" ] "Use fonts.fonts = [ pkgs.corefonts ]; instead.")
+ (mkRenamedOptionModule [ "hardware" "video" "hidpi" "enable" ] [ "fonts" "optimizeForVeryHighDPI" ])
];
options = {
@@ -69,13 +43,30 @@ 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 [
{ fonts.fonts = mkIf config.fonts.enableDefaultFonts defaultFonts; }
- { fonts.fonts = mkIf config.services.xserver.enable defaultXFonts; }
+ (mkIf cfg.optimizeForVeryHighDPI {
+ config.services.xserver.upscaleDefaultCursor = mkDefault true;
+ fonts.fontconfig = {
+ antialias = mkDefault false;
+ hinting.enable = mkDefault false;
+ subpixel.lcdfilter = mkDefault "none";
+ };
+ })
];
}
diff --git a/nixos/modules/hardware/video/hidpi.nix b/nixos/modules/hardware/video/hidpi.nix
deleted file mode 100644
index fe63784e57f5..000000000000
--- a/nixos/modules/hardware/video/hidpi.nix
+++ /dev/null
@@ -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
- };
-}
diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl
index db530533e428..946e73dac586 100644
--- a/nixos/modules/installer/tools/nixos-generate-config.pl
+++ b/nixos/modules/installer/tools/nixos-generate-config.pl
@@ -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.
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 1c976de0ef0e..026924e971a1 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -95,7 +95,6 @@
./hardware/video/bumblebee.nix
./hardware/video/capture/mwprocapture.nix
./hardware/video/displaylink.nix
- ./hardware/video/hidpi.nix
./hardware/video/nvidia.nix
./hardware/video/switcheroo-control.nix
./hardware/video/uvcvideo/default.nix
diff --git a/nixos/modules/services/x11/xserver.nix b/nixos/modules/services/x11/xserver.nix
index 0f5dce40640a..fcc18c9a26fd 100644
--- a/nixos/modules/services/x11/xserver.nix
+++ b/nixos/modules/services/x11/xserver.nix
@@ -138,6 +138,26 @@ let
concatMapStringsSep "\n" (line: prefix + line) (splitString "\n" str);
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
{
@@ -576,6 +596,15 @@ in
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: "
+ concatMapStringsSep ", " (x: x.output) primaryHeads;
})
+ {
+ assertion = cfg.upscaleDefaultCursor -> cfg.dpi != null;
+ message = "Specify `config.services.xserver.dpi` to upscale the default cursor.";
+ }
];
environment.etc =
@@ -851,6 +884,10 @@ in
'';
fonts.enableDefaultFonts = mkDefault true;
+ fonts.fonts = [
+ (if cfg.upscaleDefaultCursor then fontcursormisc_hidpi else pkgs.xorg.fontcursormisc)
+ pkgs.xorg.fontmiscmisc
+ ];
};