From 15010f04369429e582a4e152143f125108837002 Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Sat, 27 Apr 2019 22:38:18 +0200 Subject: [PATCH] sway: Read the configuration from /etc before /nix/store (#60319) This change will load all configuration files from /etc, to make it easy to override them, but fallback to /nix/store/.../etc/sway/config to make Sway work out-of-the-box with the default configuration on non NixOS systems. --- nixos/modules/programs/sway.nix | 6 +-- .../window-managers/sway/default.nix | 1 + .../sway/load-configuration-from-etc.patch | 42 +++++++++++++++++++ 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 pkgs/applications/window-managers/sway/load-configuration-from-etc.patch diff --git a/nixos/modules/programs/sway.nix b/nixos/modules/programs/sway.nix index 457faaa3c102..b4f03151cdc1 100644 --- a/nixos/modules/programs/sway.nix +++ b/nixos/modules/programs/sway.nix @@ -78,9 +78,9 @@ in { environment = { systemPackages = [ swayJoined ] ++ cfg.extraPackages; etc = { - "sway/config".source = "${swayPackage}/etc/sway/config"; - #"sway/security.d".source = "${swayPackage}/etc/sway/security.d/"; - #"sway/config.d".source = "${swayPackage}/etc/sway/config.d/"; + "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/"; }; }; security.pam.services.swaylock = {}; diff --git a/pkgs/applications/window-managers/sway/default.nix b/pkgs/applications/window-managers/sway/default.nix index ad06b1ee832c..3299811c4978 100644 --- a/pkgs/applications/window-managers/sway/default.nix +++ b/pkgs/applications/window-managers/sway/default.nix @@ -26,6 +26,7 @@ stdenv.mkDerivation rec { sha256 = "0r583nmqvq43ib93yv6flw8pj833v32lbs0q0xld56s3rnzvvdcp"; }) ./sway-config-no-nix-store-references.patch + ./load-configuration-from-etc.patch ]; nativeBuildInputs = [ pkgconfig meson ninja scdoc ]; diff --git a/pkgs/applications/window-managers/sway/load-configuration-from-etc.patch b/pkgs/applications/window-managers/sway/load-configuration-from-etc.patch new file mode 100644 index 000000000000..26a3d40d66cb --- /dev/null +++ b/pkgs/applications/window-managers/sway/load-configuration-from-etc.patch @@ -0,0 +1,42 @@ +From 26f9c65ef037892977a824f0d7d7111066856b53 Mon Sep 17 00:00:00 2001 +From: Michael Weiss +Date: Sat, 27 Apr 2019 14:26:16 +0200 +Subject: [PATCH] Load configs from /etc but fallback to /nix/store + +This change will load all configuration files from /etc, to make it easy +to override them, but fallback to /nix/store/.../etc/sway/config to make +Sway work out-of-the-box with the default configuration on non NixOS +systems. +--- + meson.build | 3 ++- + sway/config.c | 1 + + 2 files changed, 3 insertions(+), 1 deletion(-) + +diff --git a/meson.build b/meson.build +index 02b5d606..c03a9c0f 100644 +--- a/meson.build ++++ b/meson.build +@@ -129,7 +129,8 @@ if scdoc.found() + endforeach + endif + +-add_project_arguments('-DSYSCONFDIR="/@0@"'.format(join_paths(prefix, sysconfdir)), language : 'c') ++add_project_arguments('-DSYSCONFDIR="/@0@"'.format(sysconfdir), language : 'c') ++add_project_arguments('-DNIX_SYSCONFDIR="/@0@"'.format(join_paths(prefix, sysconfdir)), language : 'c') + + version = '"@0@"'.format(meson.project_version()) + if git.found() +diff --git a/sway/config.c b/sway/config.c +index 4cd21bbc..dd855753 100644 +--- a/sway/config.c ++++ b/sway/config.c +@@ -317,6 +317,7 @@ static char *get_config_path(void) { + "$XDG_CONFIG_HOME/i3/config", + SYSCONFDIR "/sway/config", + SYSCONFDIR "/i3/config", ++ NIX_SYSCONFDIR "/sway/config", + }; + + char *config_home = getenv("XDG_CONFIG_HOME"); +-- +2.19.2