Skip to content

Commit

Permalink
Merge pull request #122605 from primeos/nixos-sway-extend-default-con…
Browse files Browse the repository at this point in the history
…figuration

nixos/sway: Extend the default configuration for NixOS
  • Loading branch information
primeos authored May 13, 2021
2 parents 7500267 + 00e8e5b commit 60f2af5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
8 changes: 6 additions & 2 deletions nixos/modules/programs/sway.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ let
extraOptions = cfg.extraOptions;
withBaseWrapper = cfg.wrapperFeatures.base;
withGtkWrapper = cfg.wrapperFeatures.gtk;
isNixOS = true;
};
in {
options.programs.sway = {
Expand Down Expand Up @@ -120,8 +121,11 @@ in {
systemPackages = [ swayPackage ] ++ cfg.extraPackages;
etc = {
"sway/config".source = mkOptionDefault "${swayPackage}/etc/sway/config";
#"sway/security.d".source = mkOptionDefault "${swayPackage}/etc/sway/security.d/";
#"sway/config.d".source = mkOptionDefault "${swayPackage}/etc/sway/config.d/";
"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
'';
};
};
security.pam.services.swaylock = {};
Expand Down
6 changes: 6 additions & 0 deletions pkgs/applications/window-managers/sway/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
, pango, cairo, libinput, libcap, pam, gdk-pixbuf, librsvg
, wlroots, wayland-protocols, libdrm
, nixosTests
# Used by the NixOS module:
, isNixOS ? false
}:

stdenv.mkDerivation rec {
Expand All @@ -27,6 +29,10 @@ stdenv.mkDerivation rec {
})
];

postPatch = lib.optionalString isNixOS ''
echo -e '\ninclude /etc/sway/config.d/*' >> config.in
'';

nativeBuildInputs = [
meson ninja pkg-config wayland scdoc
];
Expand Down
13 changes: 8 additions & 5 deletions pkgs/applications/window-managers/sway/wrapper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
, withBaseWrapper ? true, extraSessionCommands ? "", dbus
, withGtkWrapper ? false, wrapGAppsHook, gdk-pixbuf, glib, gtk3
, extraOptions ? [] # E.g.: [ "--verbose" ]
# Used by the NixOS module:
, isNixOS ? false
}:

assert extraSessionCommands != "" -> withBaseWrapper;

with lib;

let
sway = sway-unwrapped.override { inherit isNixOS; };
baseWrapper = writeShellScriptBin "sway" ''
set -o errexit
if [ ! "$_SWAY_WRAPPER_ALREADY_EXECUTED" ]; then
Expand All @@ -20,16 +23,16 @@ let
fi
if [ "$DBUS_SESSION_BUS_ADDRESS" ]; then
export DBUS_SESSION_BUS_ADDRESS
exec ${sway-unwrapped}/bin/sway "$@"
exec ${sway}/bin/sway "$@"
else
exec ${dbus}/bin/dbus-run-session ${sway-unwrapped}/bin/sway "$@"
exec ${dbus}/bin/dbus-run-session ${sway}/bin/sway "$@"
fi
'';
in symlinkJoin {
name = "sway-${sway-unwrapped.version}";
name = "sway-${sway.version}";

paths = (optional withBaseWrapper baseWrapper)
++ [ sway-unwrapped ];
++ [ sway ];

nativeBuildInputs = [ makeWrapper ]
++ (optional withGtkWrapper wrapGAppsHook);
Expand All @@ -49,5 +52,5 @@ in symlinkJoin {

passthru.providedSessions = [ "sway" ];

inherit (sway-unwrapped) meta;
inherit (sway) meta;
}

0 comments on commit 60f2af5

Please sign in to comment.