Work on properly implementing the activation of systemd services.
This commit is contained in:
parent
c3be9ceb19
commit
9aa059887b
10 changed files with 205 additions and 86 deletions
16
src/lib.rs
16
src/lib.rs
|
|
@ -9,10 +9,11 @@ use std::path::Path;
|
|||
use std::{fs, str};
|
||||
|
||||
const FLAKE_ATTR: &str = "serviceConfig";
|
||||
const PROFILE_PATH: &str = "/nix/var/nix/profiles/service-manager";
|
||||
const GCROOT_PATH: &str = "/nix/var/nix/gcroots/service-manager-current";
|
||||
const PROFILE_PATH: &str = "/nix/var/nix/profiles/system-manager";
|
||||
const GCROOT_PATH: &str = "/nix/var/nix/gcroots/system-manager-current";
|
||||
const SYSTEMD_UNIT_DIR: &str = "/run/systemd/system";
|
||||
const SERVICE_MANAGER_STATE_DIR: &str = "/var/lib/service-manager/state";
|
||||
const SYSTEM_MANAGER_STATE_DIR: &str = "/var/lib/system-manager/state";
|
||||
const STATE_FILE_NAME: &str = "services.json";
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
|
@ -42,6 +43,15 @@ fn create_store_link(store_path: &StorePath, from: &Path) -> Result<()> {
|
|||
unix::fs::symlink(&store_path.store_path, from).map_err(anyhow::Error::from)
|
||||
}
|
||||
|
||||
fn remove_store_link(from: &Path) -> Result<()> {
|
||||
log::info!("Removing symlink: {}", from.display());
|
||||
if from.is_symlink() {
|
||||
fs::remove_file(from)?;
|
||||
return Ok(());
|
||||
}
|
||||
anyhow::bail!("Not a symlink!")
|
||||
}
|
||||
|
||||
pub fn compose<A, B, C, G, F>(f: F, g: G) -> impl Fn(A) -> C
|
||||
where
|
||||
F: Fn(B) -> C,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue