Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 129 lines 6.9 kB view raw
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2From: Raito Bezarius <masterancpp@gmail.com> 3Date: Mon, 19 Jun 2023 02:13:42 +0200 4Subject: [PATCH] Add some NixOS-specific unit directories 5 6Look in `/nix/var/nix/profiles/default/lib/systemd/{system,user}` for 7units provided by packages installed into the default profile via 8`nix-env -iA nixos.$package`. 9 10Also, remove /usr and /lib as these don't exist on NixOS. 11 12Original-Author: Eelco Dolstra <eelco.dolstra@logicblox.com> 13--- 14 src/core/systemd.pc.in | 8 ++++---- 15 src/libsystemd/sd-path/path-lookup.c | 20 +++----------------- 16 2 files changed, 7 insertions(+), 21 deletions(-) 17 18diff --git a/src/core/systemd.pc.in b/src/core/systemd.pc.in 19index f3b85b0190..f7aa5fca50 100644 20--- a/src/core/systemd.pc.in 21+++ b/src/core/systemd.pc.in 22@@ -43,10 +43,10 @@ systemdsystemconfdir=${systemd_system_conf_dir} 23 systemd_user_conf_dir=${sysconfdir}/systemd/user 24 systemduserconfdir=${systemd_user_conf_dir} 25 26-systemd_system_unit_path=${systemd_system_conf_dir}:/etc/systemd/system:/run/systemd/system:/usr/local/lib/systemd/system:${systemd_system_unit_dir}:/usr/lib/systemd/system:/lib/systemd/system 27+systemd_system_unit_path=${systemd_system_conf_dir}:/etc/systemd/system:/nix/var/nix/profiles/default/lib/systemd/system:/run/systemd/system:${systemd_system_unit_dir} 28 systemdsystemunitpath=${systemd_system_unit_path} 29 30-systemd_user_unit_path=${systemd_user_conf_dir}:/etc/systemd/user:/run/systemd/user:/usr/local/lib/systemd/user:/usr/local/share/systemd/user:${systemd_user_unit_dir}:/usr/lib/systemd/user:/usr/share/systemd/user 31+systemd_user_unit_path=${systemd_user_conf_dir}:/etc/systemd/user:/nix/var/nix/profiles/default/lib/systemd/user:/run/systemd/user:${systemd_user_unit_dir} 32 systemduserunitpath=${systemd_user_unit_path} 33 34 systemd_system_generator_dir=${prefix}/lib/systemd/system-generators 35@@ -55,10 +55,10 @@ systemdsystemgeneratordir=${systemd_system_generator_dir} 36 systemd_user_generator_dir=${prefix}/lib/systemd/user-generators 37 systemdusergeneratordir=${systemd_user_generator_dir} 38 39-systemd_system_generator_path=/run/systemd/system-generators:/etc/systemd/system-generators:/usr/local/lib/systemd/system-generators:${systemd_system_generator_dir} 40+systemd_system_generator_path=/run/systemd/system-generators:/etc/systemd/system-generators:${systemd_system_generator_dir} 41 systemdsystemgeneratorpath=${systemd_system_generator_path} 42 43-systemd_user_generator_path=/run/systemd/user-generators:/etc/systemd/user-generators:/usr/local/lib/systemd/user-generators:${systemd_user_generator_dir} 44+systemd_user_generator_path=/run/systemd/user-generators:/etc/systemd/user-generators:${systemd_user_generator_dir} 45 systemdusergeneratorpath=${systemd_user_generator_path} 46 47 systemd_sleep_dir=${prefix}/lib/systemd/system-sleep 48diff --git a/src/libsystemd/sd-path/path-lookup.c b/src/libsystemd/sd-path/path-lookup.c 49index a3b09208cb..91a085c6bc 100644 50--- a/src/libsystemd/sd-path/path-lookup.c 51+++ b/src/libsystemd/sd-path/path-lookup.c 52@@ -69,11 +69,7 @@ int runtime_directory(RuntimeScope scope, const char *suffix, char **ret) { 53 } 54 55 static const char* const user_data_unit_paths[] = { 56- "/usr/local/lib/systemd/user", 57- "/usr/local/share/systemd/user", 58 USER_DATA_UNIT_DIR, 59- "/usr/lib/systemd/user", 60- "/usr/share/systemd/user", 61 NULL 62 }; 63 64@@ -481,16 +477,13 @@ int lookup_paths_init( 65 persistent_config, 66 SYSTEM_CONFIG_UNIT_DIR, 67 "/etc/systemd/system", 68+ "/nix/var/nix/profiles/default/lib/systemd/system", 69 ASSERT_PTR(persistent_attached), 70 ASSERT_PTR(runtime_config), 71 "/run/systemd/system", 72 ASSERT_PTR(runtime_attached), 73 STRV_IFNOTNULL(generator), 74- "/usr/local/lib/systemd/system", 75 SYSTEM_DATA_UNIT_DIR, 76- "/usr/lib/systemd/system", 77- /* To be used ONLY for images which might be legacy split-usr */ 78- FLAGS_SET(flags, LOOKUP_PATHS_SPLIT_USR) ? "/lib/systemd/system" : STRV_IGNORE, 79 STRV_IFNOTNULL(generator_late)); 80 break; 81 82@@ -508,13 +501,10 @@ int lookup_paths_init( 83 add = strv_new(persistent_config, 84 USER_CONFIG_UNIT_DIR, 85 "/etc/systemd/user", 86+ "/nix/var/nix/profiles/default/lib/systemd/user", 87 ASSERT_PTR(runtime_config), 88 "/run/systemd/user", 89- "/usr/local/share/systemd/user", 90- "/usr/share/systemd/user", 91- "/usr/local/lib/systemd/user", 92- USER_DATA_UNIT_DIR, 93- "/usr/lib/systemd/user"); 94+ USER_DATA_UNIT_DIR); 95 break; 96 97 case RUNTIME_SCOPE_USER: 98@@ -653,7 +643,6 @@ void lookup_paths_log(LookupPaths *lp) { 99 static const char* const system_generator_paths[] = { 100 "/run/systemd/system-generators", 101 "/etc/systemd/system-generators", 102- "/usr/local/lib/systemd/system-generators", 103 SYSTEM_GENERATOR_DIR, 104 NULL, 105 }; 106@@ -661,7 +650,6 @@ static const char* const system_generator_paths[] = { 107 static const char* const user_generator_paths[] = { 108 "/run/systemd/user-generators", 109 "/etc/systemd/user-generators", 110- "/usr/local/lib/systemd/user-generators", 111 USER_GENERATOR_DIR, 112 NULL, 113 }; 114@@ -669,7 +657,6 @@ static const char* const user_generator_paths[] = { 115 static const char* const system_env_generator_paths[] = { 116 "/run/systemd/system-environment-generators", 117 "/etc/systemd/system-environment-generators", 118- "/usr/local/lib/systemd/system-environment-generators", 119 SYSTEM_ENV_GENERATOR_DIR, 120 NULL, 121 }; 122@@ -677,7 +664,6 @@ static const char* const system_env_generator_paths[] = { 123 static const char* const user_env_generator_paths[] = { 124 "/run/systemd/user-environment-generators", 125 "/etc/systemd/user-environment-generators", 126- "/usr/local/lib/systemd/user-environment-generators", 127 USER_ENV_GENERATOR_DIR, 128 NULL, 129 };