treewide: Format all Nix files
Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:
nix-build ci -A fmt.check
This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).
This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).
Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase).
If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.programs.sway;
|
||||
@@ -14,33 +19,43 @@ in
|
||||
<https://github.com/swaywm/sway/wiki> and
|
||||
"man 5 sway" for more information'';
|
||||
|
||||
package = lib.mkPackageOption pkgs "sway" {
|
||||
nullable = true;
|
||||
extraDescription = ''
|
||||
If the package is not overridable with `extraSessionCommands`, `extraOptions`,
|
||||
`withBaseWrapper`, `withGtkWrapper`, `enableXWayland` and `isNixOS`,
|
||||
then the module options {option}`wrapperFeatures`, {option}`extraSessionCommands`,
|
||||
{option}`extraOptions` and {option}`xwayland` will have no effect.
|
||||
package =
|
||||
lib.mkPackageOption pkgs "sway" {
|
||||
nullable = true;
|
||||
extraDescription = ''
|
||||
If the package is not overridable with `extraSessionCommands`, `extraOptions`,
|
||||
`withBaseWrapper`, `withGtkWrapper`, `enableXWayland` and `isNixOS`,
|
||||
then the module options {option}`wrapperFeatures`, {option}`extraSessionCommands`,
|
||||
{option}`extraOptions` and {option}`xwayland` will have no effect.
|
||||
|
||||
Set to `null` to not add any Sway package to your path.
|
||||
This should be done if you want to use the Home Manager Sway module to install Sway.
|
||||
'';
|
||||
} // {
|
||||
apply = p: if p == null then null else
|
||||
wayland-lib.genFinalPackage p {
|
||||
extraSessionCommands = cfg.extraSessionCommands;
|
||||
extraOptions = cfg.extraOptions;
|
||||
withBaseWrapper = cfg.wrapperFeatures.base;
|
||||
withGtkWrapper = cfg.wrapperFeatures.gtk;
|
||||
enableXWayland = cfg.xwayland.enable;
|
||||
isNixOS = true;
|
||||
};
|
||||
};
|
||||
Set to `null` to not add any Sway package to your path.
|
||||
This should be done if you want to use the Home Manager Sway module to install Sway.
|
||||
'';
|
||||
}
|
||||
// {
|
||||
apply =
|
||||
p:
|
||||
if p == null then
|
||||
null
|
||||
else
|
||||
wayland-lib.genFinalPackage p {
|
||||
extraSessionCommands = cfg.extraSessionCommands;
|
||||
extraOptions = cfg.extraOptions;
|
||||
withBaseWrapper = cfg.wrapperFeatures.base;
|
||||
withGtkWrapper = cfg.wrapperFeatures.gtk;
|
||||
enableXWayland = cfg.xwayland.enable;
|
||||
isNixOS = true;
|
||||
};
|
||||
};
|
||||
|
||||
wrapperFeatures = {
|
||||
base = lib.mkEnableOption ''
|
||||
the base wrapper to execute extra session commands and prepend a
|
||||
dbus-run-session to the sway command'' // { default = true; };
|
||||
base =
|
||||
lib.mkEnableOption ''
|
||||
the base wrapper to execute extra session commands and prepend a
|
||||
dbus-run-session to the sway command''
|
||||
// {
|
||||
default = true;
|
||||
};
|
||||
gtk = lib.mkEnableOption ''
|
||||
the wrapGAppsHook wrapper to execute sway with required environment
|
||||
variables for GTK applications'';
|
||||
@@ -69,7 +84,7 @@ in
|
||||
|
||||
extraOptions = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [];
|
||||
default = [ ];
|
||||
example = [
|
||||
"--verbose"
|
||||
"--debug"
|
||||
@@ -81,12 +96,22 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
xwayland.enable = lib.mkEnableOption "XWayland" // { default = true; };
|
||||
xwayland.enable = lib.mkEnableOption "XWayland" // {
|
||||
default = true;
|
||||
};
|
||||
|
||||
extraPackages = lib.mkOption {
|
||||
type = with lib.types; listOf package;
|
||||
# Packages used in default config
|
||||
default = with pkgs; [ brightnessctl foot grim pulseaudio swayidle swaylock wmenu ];
|
||||
default = with pkgs; [
|
||||
brightnessctl
|
||||
foot
|
||||
grim
|
||||
pulseaudio
|
||||
swayidle
|
||||
swaylock
|
||||
wmenu
|
||||
];
|
||||
defaultText = lib.literalExpression ''
|
||||
with pkgs; [ brightnessctl foot grim pulseaudio swayidle swaylock wmenu ];
|
||||
'';
|
||||
@@ -102,18 +127,19 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable (lib.mkMerge [
|
||||
{
|
||||
assertions = [
|
||||
{
|
||||
assertion = cfg.extraSessionCommands != "" -> cfg.wrapperFeatures.base;
|
||||
message = ''
|
||||
The extraSessionCommands for Sway will not be run if wrapperFeatures.base is disabled.
|
||||
'';
|
||||
}
|
||||
];
|
||||
config = lib.mkIf cfg.enable (
|
||||
lib.mkMerge [
|
||||
{
|
||||
assertions = [
|
||||
{
|
||||
assertion = cfg.extraSessionCommands != "" -> cfg.wrapperFeatures.base;
|
||||
message = ''
|
||||
The extraSessionCommands for Sway will not be run if wrapperFeatures.base is disabled.
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
warnings =
|
||||
warnings =
|
||||
lib.mkIf
|
||||
(
|
||||
(lib.elem "nvidia" config.services.xserver.videoDrivers)
|
||||
@@ -123,58 +149,64 @@ in
|
||||
"Using Sway with Nvidia driver version <= 550 may result in a broken system. Configure hardware.nvidia.package to use a newer version."
|
||||
];
|
||||
|
||||
environment = {
|
||||
systemPackages = lib.optional (cfg.package != null) cfg.package ++ cfg.extraPackages;
|
||||
environment = {
|
||||
systemPackages = lib.optional (cfg.package != null) cfg.package ++ cfg.extraPackages;
|
||||
|
||||
# Needed for the default wallpaper:
|
||||
pathsToLink = lib.optional (cfg.package != null) "/share/backgrounds/sway";
|
||||
# Needed for the default wallpaper:
|
||||
pathsToLink = lib.optional (cfg.package != null) "/share/backgrounds/sway";
|
||||
|
||||
etc = {
|
||||
"sway/config.d/nixos.conf".source = pkgs.writeText "nixos.conf" ''
|
||||
# Import the most important environment variables into the D-Bus and systemd
|
||||
# user environments (e.g. required for screen sharing and Pinentry prompts):
|
||||
exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP
|
||||
# enable systemd-integration
|
||||
exec "systemctl --user import-environment {,WAYLAND_}DISPLAY SWAYSOCK; systemctl --user start sway-session.target"
|
||||
exec swaymsg -t subscribe '["shutdown"]' && systemctl --user stop sway-session.target
|
||||
'';
|
||||
} // lib.optionalAttrs (cfg.package != null) {
|
||||
"sway/config".source = lib.mkOptionDefault "${cfg.package}/etc/sway/config";
|
||||
etc =
|
||||
{
|
||||
"sway/config.d/nixos.conf".source = pkgs.writeText "nixos.conf" ''
|
||||
# Import the most important environment variables into the D-Bus and systemd
|
||||
# user environments (e.g. required for screen sharing and Pinentry prompts):
|
||||
exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP
|
||||
# enable systemd-integration
|
||||
exec "systemctl --user import-environment {,WAYLAND_}DISPLAY SWAYSOCK; systemctl --user start sway-session.target"
|
||||
exec swaymsg -t subscribe '["shutdown"]' && systemctl --user stop sway-session.target
|
||||
'';
|
||||
}
|
||||
// lib.optionalAttrs (cfg.package != null) {
|
||||
"sway/config".source = lib.mkOptionDefault "${cfg.package}/etc/sway/config";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
systemd.user.targets.sway-session = {
|
||||
description = "sway compositor session";
|
||||
documentation = [ "man:systemd.special(7)" ];
|
||||
bindsTo = [ "graphical-session.target" ];
|
||||
wants = [ "graphical-session-pre.target" ];
|
||||
after = [ "graphical-session-pre.target" ];
|
||||
};
|
||||
systemd.user.targets.sway-session = {
|
||||
description = "sway compositor session";
|
||||
documentation = [ "man:systemd.special(7)" ];
|
||||
bindsTo = [ "graphical-session.target" ];
|
||||
wants = [ "graphical-session-pre.target" ];
|
||||
after = [ "graphical-session-pre.target" ];
|
||||
};
|
||||
|
||||
# To make a Sway session available if a display manager like SDDM is enabled:
|
||||
services.displayManager.sessionPackages = lib.optional (cfg.package != null) cfg.package;
|
||||
# To make a Sway session available if a display manager like SDDM is enabled:
|
||||
services.displayManager.sessionPackages = lib.optional (cfg.package != null) cfg.package;
|
||||
|
||||
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050913
|
||||
# https://github.com/emersion/xdg-desktop-portal-wlr/blob/master/contrib/wlroots-portals.conf
|
||||
# https://github.com/emersion/xdg-desktop-portal-wlr/pull/315
|
||||
xdg.portal.config.sway = {
|
||||
# Use xdg-desktop-portal-gtk for every portal interface...
|
||||
default = [ "gtk" ];
|
||||
# ... except for the ScreenCast, Screenshot and Secret
|
||||
"org.freedesktop.impl.portal.ScreenCast" = "wlr";
|
||||
"org.freedesktop.impl.portal.Screenshot" = "wlr";
|
||||
# ignore inhibit bc gtk portal always returns as success,
|
||||
# despite sway/the wlr portal not having an implementation,
|
||||
# stopping firefox from using wayland idle-inhibit
|
||||
"org.freedesktop.impl.portal.Inhibit" = "none";
|
||||
};
|
||||
}
|
||||
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050913
|
||||
# https://github.com/emersion/xdg-desktop-portal-wlr/blob/master/contrib/wlroots-portals.conf
|
||||
# https://github.com/emersion/xdg-desktop-portal-wlr/pull/315
|
||||
xdg.portal.config.sway = {
|
||||
# Use xdg-desktop-portal-gtk for every portal interface...
|
||||
default = [ "gtk" ];
|
||||
# ... except for the ScreenCast, Screenshot and Secret
|
||||
"org.freedesktop.impl.portal.ScreenCast" = "wlr";
|
||||
"org.freedesktop.impl.portal.Screenshot" = "wlr";
|
||||
# ignore inhibit bc gtk portal always returns as success,
|
||||
# despite sway/the wlr portal not having an implementation,
|
||||
# stopping firefox from using wayland idle-inhibit
|
||||
"org.freedesktop.impl.portal.Inhibit" = "none";
|
||||
};
|
||||
}
|
||||
|
||||
(import ./wayland-session.nix {
|
||||
inherit lib pkgs;
|
||||
enableXWayland = cfg.xwayland.enable;
|
||||
})
|
||||
]);
|
||||
(import ./wayland-session.nix {
|
||||
inherit lib pkgs;
|
||||
enableXWayland = cfg.xwayland.enable;
|
||||
})
|
||||
]
|
||||
);
|
||||
|
||||
meta.maintainers = with lib.maintainers; [ primeos colemickens ];
|
||||
meta.maintainers = with lib.maintainers; [
|
||||
primeos
|
||||
colemickens
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user