modules.services.harmonia: fix

This commit is contained in:
2025-12-07 12:29:04 +08:00
parent 7fd61ef0cb
commit 188694ef8c
7 changed files with 208 additions and 34 deletions

View File

@@ -14,6 +14,7 @@ inputs: let inherit (inputs) topInputs; in
topInputs.nixvirt.nixosModules.default
topInputs.niri.nixosModules.niri
{ config.niri-flake.cache.enable = false; }
topInputs.harmonia.nixosModules.harmonia
{ config.home-manager.sharedModules =
[
topInputs.catppuccin.homeModules.catppuccin

View File

@@ -1,26 +0,0 @@
inputs:
{
options.nixos.services.harmonia = let inherit (inputs.lib) mkOption types; in mkOption
{
type = types.nullOr (types.submodule { options =
{
hostname = mkOption { type = types.nonEmptyStr; default = "nix-store.chn.moe"; };
store = mkOption { type = types.nullOr types.nonEmptyStr; default = null; };
};});
default = null;
};
config = let inherit (inputs.config.nixos.services) harmonia; in inputs.lib.mkIf (harmonia != null)
{
services.harmonia =
{
enable = true;
signKeyPaths = [ inputs.config.nixos.system.sops.secrets."store/signingKey".path ];
settings = inputs.lib.mkIf (harmonia.store != null) { real_nix_store = harmonia.store; };
};
nixos =
{
system.sops.secrets."store/signingKey" = {};
services.nginx.https.${harmonia.hostname}.location."/".proxy.upstream = "http://127.0.0.1:5000";
};
};
}

View File

@@ -0,0 +1,41 @@
inputs:
{
options.nixos.services.harmonia = let inherit (inputs.lib) mkOption types; in mkOption
{
type = types.nullOr (types.submodule { options =
{
hostname = mkOption { type = types.nonEmptyStr; default = "nix-store.chn.moe"; };
store = mkOption { type = types.nullOr types.nonEmptyStr; default = null; };
};});
default = null;
};
config = let inherit (inputs.config.nixos.services) harmonia; in inputs.lib.mkIf (harmonia != null)
{
services.harmonia-dev =
{
package = inputs.options.services.harmonia-dev.package.default.overrideAttrs
(prev: { patches = prev.patches or [] ++ [ ./harmonia.patch ]; });
cache =
{
enable = true;
signKeyPaths = [ inputs.config.nixos.system.sops.secrets."store/signingKey".path ];
settings = inputs.lib.mkIf (harmonia.store != null)
{
virtual_nix_store = "/nix/store";
real_nix_store = "${harmonia.store}/nix/store";
daemon_store = "/nix/store";
};
};
daemon =
{
enable = true;
dbPath = inputs.lib.mkIf (harmonia.store != null) "${harmonia.store}/nix/var/nix/db/db.sqlite";
};
};
nixos =
{
system.sops.secrets."store/signingKey" = {};
services.nginx.https.${harmonia.hostname}.location."/".proxy.upstream = "http://127.0.0.1:5000";
};
};
}

View File

@@ -0,0 +1,45 @@
From 310e2b2c6583710c52531785f1245d9621284310 Mon Sep 17 00:00:00 2001
From: Jack O'Sullivan <jackos1998@gmail.com>
Date: Sat, 6 Dec 2025 14:50:23 +0000
Subject: [PATCH] Expose `daemon_store` in cache as config option
---
harmonia-cache/src/config.rs | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/harmonia-cache/src/config.rs b/harmonia-cache/src/config.rs
index a683d78a..5dd9f801 100644
--- a/harmonia-cache/src/config.rs
+++ b/harmonia-cache/src/config.rs
@@ -68,6 +68,8 @@ pub(crate) struct Config {
#[serde(default = "default_daemon_socket")]
pub(crate) daemon_socket: PathBuf,
+ #[serde(default)]
+ pub(crate) daemon_store: Option<PathBuf>,
#[serde(skip, default)]
pub(crate) secret_keys: Vec<SecretKey>,
@@ -152,13 +154,19 @@ pub(crate) fn load(pool_metrics: Option<Arc<PoolMetrics>>) -> Result<Config> {
.as_encoded_bytes()
.to_vec()
});
- // For daemon communication, use real_nix_store if set (chroot mode),
+ // For daemon communication, use daemon_store, then real_nix_store if set (chroot mode),
// otherwise use the virtual store path
let daemon_store_dir = settings
- .real_nix_store
+ .daemon_store
.as_ref()
.map(|p| p.as_os_str().as_encoded_bytes().to_vec())
- .unwrap_or_else(|| virtual_store_dir.clone());
+ .unwrap_or_else(|| {
+ settings
+ .real_nix_store
+ .as_ref()
+ .map(|p| p.as_os_str().as_encoded_bytes().to_vec())
+ .unwrap_or_else(|| virtual_store_dir.clone())
+ });
settings.store = Store::new(
virtual_store_dir,
daemon_store_dir,