forked from mirrors/nixpkgs
987400b848
Running `nixos/tests/keepassxc.nix` shows:
```
machine # [ 18.705390] xsession[985]: /nix/store/2g2jx5c6x3p152wbiijr0rmky7byqivc-xsession: line 13: nn: command not found
```
This garbled bash script runs without `set -o errexit` and thus skips
"\n\n" as invalid command:
```
$ cat -n /nix/store/2g2jx5c6x3p152wbiijr0rmky7byqivc-xsession
...
\n\n
if [ -e $HOME/.background-image ]; then
/nix/store/wq1d1ph8wj4alpx78akvpbd0a0m9qkd1-feh-3.8/bin/feh --bg-scale $HOME/.background-image
fi
...
```
KeePassXC uses it through
`nixos/modules/services/x11/display-managers/default.nix`:
```
...
# Script responsible for starting the window manager and the desktop manager.
xsession = dm: wm: pkgs.writeScript "xsession" ''
#! ${pkgs.bash}/bin/bash
# Legacy session script used to construct .desktop files from
# `services.xserver.displayManager.session` entries. Called from
# `sessionWrapper`.
# Start the window manager.
${wm.start}
# Start the desktop manager.
${dm.start}
...
'';
...
```
The bogus line was introduced in PR #160752:
```
commit 0bc0dc8090
Author: Shaw Vrana <shaw@vranix.com>
Date: Fri Feb 18 11:27:42 2022 -0800
desktop manager script: start properly
Adds a missing line feed when X is enabled to the start script name
and the appended if check. Resolves #160735
```
I have not tried to reproduce the original issue and thus don't know
why "\n\n" apparently gets interpreted fine in one place but remains
literal the `xsession` case.
However, using a literal newline must be valid for all cases and
certainly fixes the warning seen in KeePassXC tests.
Furthermore, starting the nix string (`''`) with a newline as usual also
fixes its overall indentation.
102 lines
3.6 KiB
Nix
102 lines
3.6 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
xcfg = config.services.xserver;
|
|
cfg = xcfg.desktopManager;
|
|
|
|
# If desktop manager `d' isn't capable of setting a background and
|
|
# the xserver is enabled, `feh' or `xsetroot' are used as a fallback.
|
|
needBGCond = d: ! (d ? bgSupport && d.bgSupport) && xcfg.enable;
|
|
|
|
in
|
|
|
|
{
|
|
# Note: the order in which desktop manager modules are imported here
|
|
# determines the default: later modules (if enabled) are preferred.
|
|
# E.g., if Plasma 5 is enabled, it supersedes xterm.
|
|
imports = [
|
|
./none.nix ./xterm.nix ./phosh.nix ./xfce.nix ./plasma5.nix ./lumina.nix
|
|
./lxqt.nix ./enlightenment.nix ./gnome.nix ./retroarch.nix ./kodi.nix
|
|
./mate.nix ./pantheon.nix ./surf-display.nix ./cde.nix
|
|
./cinnamon.nix
|
|
];
|
|
|
|
options = {
|
|
|
|
services.xserver.desktopManager = {
|
|
|
|
wallpaper = {
|
|
mode = mkOption {
|
|
type = types.enum [ "center" "fill" "max" "scale" "tile" ];
|
|
default = "scale";
|
|
example = "fill";
|
|
description = ''
|
|
The file <filename>~/.background-image</filename> is used as a background image.
|
|
This option specifies the placement of this image onto your desktop.
|
|
|
|
Possible values:
|
|
<literal>center</literal>: Center the image on the background. If it is too small, it will be surrounded by a black border.
|
|
<literal>fill</literal>: Like <literal>scale</literal>, but preserves aspect ratio by zooming the image until it fits. Either a horizontal or a vertical part of the image will be cut off.
|
|
<literal>max</literal>: Like <literal>fill</literal>, but scale the image to the maximum size that fits the screen with black borders on one side.
|
|
<literal>scale</literal>: Fit the file into the background without repeating it, cutting off stuff or using borders. But the aspect ratio is not preserved either.
|
|
<literal>tile</literal>: Tile (repeat) the image in case it is too small for the screen.
|
|
'';
|
|
};
|
|
|
|
combineScreens = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = ''
|
|
When set to <literal>true</literal> the wallpaper will stretch across all screens.
|
|
When set to <literal>false</literal> the wallpaper is duplicated to all screens.
|
|
'';
|
|
};
|
|
};
|
|
|
|
session = mkOption {
|
|
internal = true;
|
|
default = [];
|
|
example = singleton
|
|
{ name = "kde";
|
|
bgSupport = true;
|
|
start = "...";
|
|
};
|
|
description = ''
|
|
Internal option used to add some common line to desktop manager
|
|
scripts before forwarding the value to the
|
|
<varname>displayManager</varname>.
|
|
'';
|
|
apply = map (d: d // {
|
|
manage = "desktop";
|
|
start = d.start
|
|
# literal newline to ensure d.start's last line is not appended to
|
|
+ optionalString (needBGCond d) ''
|
|
|
|
if [ -e $HOME/.background-image ]; then
|
|
${pkgs.feh}/bin/feh --bg-${cfg.wallpaper.mode} ${optionalString cfg.wallpaper.combineScreens "--no-xinerama"} $HOME/.background-image
|
|
fi
|
|
'';
|
|
});
|
|
};
|
|
|
|
default = mkOption {
|
|
type = types.nullOr types.str;
|
|
default = null;
|
|
example = "none";
|
|
description = ''
|
|
<emphasis role="strong">Deprecated</emphasis>, please use <xref linkend="opt-services.xserver.displayManager.defaultSession"/> instead.
|
|
|
|
Default desktop manager loaded if none have been chosen.
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config.services.xserver.displayManager.session = cfg.session;
|
|
}
|