我想更改systemd-logind服务的Environment参数。这不是由configuration.nix中提供的logind选项所涵盖的,所以我试过了
systemd = {
services.systemd-logind.serviceConfig = {
environment = {
SYSTEMD_LOG_LEVEL = "debug";
};
};
};
然而,在构建时我遇到了一个错误,我认为这是抱怨我试图在两个地方定义systemd-logind - 一次在这里,一次在NixOS的内部。错误看起来像
$ nixos-rebuild switch --show-trace
building Nix...
building the system configuration...
error: while evaluating the attribute ‘buildCommand’ of the derivation ‘nixos-15.08pre67312.2c933ad’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/nixos/modules/system/activation/top-level.nix:102:7:
while evaluating the attribute ‘sources’ of the derivation ‘etc’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/nixos/modules/system/etc/etc.nix:12:5:
while evaluating anonymous function at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/nixos/modules/system/etc/etc.nix:20:20, called from undefined position:
while evaluating the attribute ‘source’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/attrsets.nix:134:44:
while evaluating anonymous function at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/modules.nix:74:45, called from /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/attrsets.nix:134:52:
while evaluating the attribute ‘value’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/modules.nix:287:9:
while evaluating the option `environment.etc.systemd/system.source':
while evaluating the attribute ‘mergedValue’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/modules.nix:314:5:
while evaluating ‘foldl’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/lists.nix:31:20, called from /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/modules.nix:314:19:
while evaluating ‘foldl'’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/lists.nix:34:16, called from /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/lists.nix:38:8:
while evaluating anonymous function at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/modules.nix:314:32, called from /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/lists.nix:37:14:
while evaluating ‘check’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/types.nix:106:15, called from /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/modules.nix:315:10:
while evaluating the attribute ‘buildCommand’ of the derivation ‘system-units’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/pkgs/build-support/trivial-builders.nix:10:14:
while evaluating the attribute ‘text’ of the derivation ‘unit-systemd-logind.service’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/pkgs/build-support/trivial-builders.nix:10:14:
while evaluating the attribute ‘text’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/attrsets.nix:134:44:
while evaluating anonymous function at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/modules.nix:74:45, called from /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/attrsets.nix:134:52:
while evaluating the attribute ‘value’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/modules.nix:287:9:
while evaluating the option `systemd.units.systemd-logind.service.text':
while evaluating the attribute ‘isDefined’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/modules.nix:319:5:
while evaluating ‘fold’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/lists.nix:20:19, called from /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/modules.nix:308:14:
while evaluating ‘fold'’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/lists.nix:23:15, called from /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/lists.nix:27:8:
while evaluating ‘filterOverrides’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/modules.nix:391:21, called from /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/modules.nix:303:18:
while evaluating ‘concatMap’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/lists.nix:62:18, called from /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/modules.nix:397:8:
while evaluating ‘concatMap’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/lists.nix:62:18, called from /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/modules.nix:298:17:
while evaluating anonymous function at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/modules.nix:298:28, called from undefined position:
while evaluating ‘dischargeProperties’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/modules.nix:361:25, called from /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/modules.nix:299:62:
while evaluating the attribute ‘value’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/modules.nix:199:48:
while evaluating the attribute ‘config.text’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/nixos/modules/system/boot/systemd.nix:295:7:
while evaluating ‘attrsToSection’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/nixos/modules/system/boot/systemd-lib.nix:90:20, called from /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/nixos/modules/system/boot/systemd.nix:309:13:
while evaluating ‘foldl’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/lists.nix:31:20, called from /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/nixos/modules/system/boot/systemd-lib.nix:91:5:
while evaluating ‘foldl'’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/lists.nix:34:16, called from /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/lists.nix:38:8:
while evaluating anonymous function at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/strings.nix:19:22, called from /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/lib/lists.nix:37:14:
while evaluating anonymous function at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/nixos/modules/system/boot/systemd-lib.nix:92:12, called from undefined position:
while evaluating ‘toOption’ at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/nixos/modules/system/boot/systemd-lib.nix:85:14, called from /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/nixos/modules/system/boot/systemd-lib.nix:93:21:
cannot coerce a set to a string, at /nix/store/m803kk24n58kkkzf2y26ws89jpx69czf-nixos-15.08pre67312.2c933ad/nixos/nixpkgs/nixos/modules/system/boot/systemd-lib.nix:88:10
鉴于此,如何在systemd-logind单元文件中设置Environment参数?
答案 0 :(得分:2)
services.systemd-logind.environment.SYSTEMD_LOG_LEVEL
,而不是services.systemd-logind.serviceConfig.environment.SYSTEMD_LOG_LEVEL