modules: users: have user services inherit PATH from environment rather than forcibly overwriting it
This commit is contained in:
parent
d19907a38d
commit
0d3adcdc5c
|
@ -195,13 +195,15 @@ output "Unknown 0x0637 0x00000000" {
|
||||||
res 1920x1080
|
res 1920x1080
|
||||||
}
|
}
|
||||||
|
|
||||||
# XXX: needed for xdg-desktop-portal-* to work.
|
# XXX: `include /etc/sway/config.d/*` is needed for xdg-desktop-portal-* to work.
|
||||||
# this is how we expose these env vars to user dbus services:
|
# this is how we expose these env vars to user dbus services:
|
||||||
# - DISPLAY
|
# - DISPLAY
|
||||||
# - WAYLAND_DISPLAY
|
# - WAYLAND_DISPLAY
|
||||||
# - SWAYSOCK
|
# - SWAYSOCK
|
||||||
# - XDG_CURRENT_DESKTOP
|
# - XDG_CURRENT_DESKTOP
|
||||||
|
# also, manually export PATH here, since all my user services need that, and sane-sandboxed implementation depends on it.
|
||||||
# for more, see: <repo:nixos/nixpkgs:nixos/modules/programs/wayland/sway.nix>
|
# for more, see: <repo:nixos/nixpkgs:nixos/modules/programs/wayland/sway.nix>
|
||||||
|
exec dbus-update-activation-environment --systemd PATH
|
||||||
include /etc/sway/config.d/*
|
include /etc/sway/config.d/*
|
||||||
|
|
||||||
# signal to systemd that sway is active,
|
# signal to systemd that sway is active,
|
||||||
|
|
|
@ -47,7 +47,10 @@ let
|
||||||
|
|
||||||
services = mkOption {
|
services = mkOption {
|
||||||
# see: <repo:nixos/nixpkgs:nixos/lib/utils.nix>
|
# see: <repo:nixos/nixpkgs:nixos/lib/utils.nix>
|
||||||
type = utils.systemdUtils.types.services;
|
# type = utils.systemdUtils.types.services;
|
||||||
|
# `utils.systemdUtils.types.services` is nearly what we want, but remove `stage2ServiceConfig`,
|
||||||
|
# as we don't want to force a PATH for every service.
|
||||||
|
type = types.attrsOf (types.submodule [ utils.systemdUtils.unitOptions.stage2ServiceOptions utils.systemdUtils.lib.unitConfig ]);
|
||||||
default = {};
|
default = {};
|
||||||
description = ''
|
description = ''
|
||||||
systemd user-services to define for this user.
|
systemd user-services to define for this user.
|
||||||
|
@ -130,17 +133,14 @@ let
|
||||||
# see: <repo:nix-community/home-manager:modules/systemd.nix>
|
# see: <repo:nix-community/home-manager:modules/systemd.nix>
|
||||||
cleanName = utils.systemdUtils.lib.mkPathSafeName serviceName;
|
cleanName = utils.systemdUtils.lib.mkPathSafeName serviceName;
|
||||||
generatedUnit = utils.systemdUtils.lib.serviceToUnit serviceName (value // {
|
generatedUnit = utils.systemdUtils.lib.serviceToUnit serviceName (value // {
|
||||||
environment = (value.environment or {}) // {
|
environment = {
|
||||||
# replicate the default NixOS user PATH (omitting dirs which don't exist)
|
# clear PATH to allow inheriting it from environment.
|
||||||
# N.B.: user PATH SHOULD be before the service's path.
|
# otherwise, nixos would force it to `systemd.globalEnvironment.PATH`, which is mostly tools like sed/find/etc.
|
||||||
# this allows to user to override preferences for things like e.g. bemenu (for theming)
|
# clearing PATH here allows user services to inherit whatever PATH the graphical session sets
|
||||||
PATH = lib.removeSuffix ":" (
|
# (see `dbus-update-activation-environment` call in ~/.config/sway/config),
|
||||||
"/run/wrappers/bin:"
|
# which is critical to making it so user services can see user *programs*/packages.
|
||||||
+ "/etc/profiles/per-user/${name}/bin:"
|
PATH = null;
|
||||||
+ "/run/current-system/sw/bin:"
|
} // (value.environment or {});
|
||||||
+ (value.environment.PATH or "")
|
|
||||||
);
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
#^ generatedUnit contains keys:
|
#^ generatedUnit contains keys:
|
||||||
# - text
|
# - text
|
||||||
|
|
Loading…
Reference in New Issue
Block a user