feat: nixos module
Some checks failed
build / build (push) Failing after 4s

This commit is contained in:
2026-04-18 20:12:20 -06:00
parent 7e6fb22d03
commit 7374f646b3
6 changed files with 94 additions and 20 deletions

View File

@@ -5,7 +5,7 @@
, doerg-temml-worker , doerg-temml-worker
, ibm-plex-web , ibm-plex-web
, test-emacs ? callPackage ./test-emacs.nix {} , test-emacs ? callPackage ./test-emacs.nix {}
, fake-git , fake-git ? null
, our-tex , our-tex
, makeWrapper , makeWrapper
, writeText , writeText
@@ -33,7 +33,7 @@ let
]; ];
doerg-config = writeText "doerg-extra-config.edn" '' doerg-config = writeText "doerg-extra-config.edn" ''
#:net.deertopia.doerg #:net.deertopia.doerg.config
{:ibm-plex-web "${ibm-plex-web}" {:ibm-plex-web "${ibm-plex-web}"
:latex "${lib.getExe' our-tex "xelatex"}" :latex "${lib.getExe' our-tex "xelatex"}"
:dvisvgm "${lib.getExe' our-tex "dvisvgm"}" :dvisvgm "${lib.getExe' our-tex "dvisvgm"}"
@@ -74,4 +74,5 @@ in mkCljBin' {
clojure -M:test clojure -M:test
''; '';
passthru = { inherit plex our-tex test-emacs; }; passthru = { inherit plex our-tex test-emacs; };
meta.mainProgram = "doerg";
} }

View File

@@ -14,17 +14,18 @@
"x86_64-linux" "x86_64-linux"
]; ];
overlays = [
inputs.sydpkgs.overlays.default
clj-nix.overlays.default
self.overlays.default
];
each-system = f: nixpkgs.lib.genAttrs supportedSystems (system: f rec { each-system = f: nixpkgs.lib.genAttrs supportedSystems (system: f rec {
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
overlays = [
inputs.sydpkgs.overlays.default
clj-nix.overlays.default
self.overlays.default
];
}; };
inherit (pkgs) lib; inherit (pkgs) lib;
inherit system; inherit system overlays;
}); });
in { in {
# Exposed as a REPL convenience. # Exposed as a REPL convenience.
@@ -36,13 +37,17 @@
}); });
overlays.default = final: prev: overlays.default = final: prev:
let graal = x: final.mkGraalBin { cljDrv = x; }; let
# is this really the correct way to satisfy our
# dependencies? lmfao
final' = final.appendOverlays overlays;
graal = x: final'.mkGraalBin { cljDrv = x; };
in { in {
ibm-plex-web = final.callPackage ./ibm-plex-web.nix {}; ibm-plex-web = final'.callPackage ./ibm-plex-web.nix {};
doerg = final.callPackage ./. {}; doerg = final'.callPackage ./. {};
doerg-parser = final.callPackage ./doerg-parser {}; doerg-parser = final'.callPackage ./doerg-parser {};
doerg-temml-worker = final.callPackage ./doerg-temml-worker {}; doerg-temml-worker = final'.callPackage ./doerg-temml-worker {};
our-tex = final.callPackage ./our-tex.nix {}; our-tex = final'.callPackage ./our-tex.nix {};
}; };
checks = each-system ({ pkgs, system, ... }: { checks = each-system ({ pkgs, system, ... }: {
@@ -52,6 +57,8 @@
(pkgs.lib.attrValues self.packages.${system}); (pkgs.lib.attrValues self.packages.${system});
}); });
nixosModules.default = import ./module.nix { inherit self; };
devShells = each-system ({ pkgs, system, ... }: { devShells = each-system ({ pkgs, system, ... }: {
default = pkgs.mkShell { default = pkgs.mkShell {
inputsFrom = [ inputsFrom = [

64
module.nix Normal file
View File

@@ -0,0 +1,64 @@
{ self, ... }:
{ config, lib, pkgs, ... }:
let
cfg = config.services.doerg;
doerg-config = pkgs.writeText "doerg-config.edn" ''
#:net.deertopia.doerg.config
{:org-roam-db-path "${cfg.databasePath}"
:state-directory "${cfg.stateDir}"}
'';
inherit (lib) types;
in {
options.services.doerg = {
enable = lib.mkEnableOption "Doerg";
org-roam-db-sync.enable = lib.mkEnableOption "Org-roam db sync";
port = lib.mkOption {
default = 21984;
type = lib.types.port;
description = ''
The port on which Doerg will listen.
'';
};
stateDir = lib.mkOption {
type = types.path;
default = "/var/lib/private/doerg";
description = "Daemon's state directory.";
};
orgDir = lib.mkOption {
type = types.path;
description = "Org roam directory.";
};
package = lib.mkPackageOption pkgs "doerg" {};
databasePath = lib.mkOption {
type = types.path;
description = "Org roam database path";
default = cfg.orgDir + "org-roam.db";
};
};
config = lib.mkIf cfg.enable {
nixpkgs.overlays = [ self.overlays.default ];
systemd.services.doerg = {
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
environment.DOERG_CONFIG = doerg-config;
serviceConfig = {
# WorkingDirectory = cfg.stateDir;
StateDirectory = "doerg";
ExecStart = lib.getExe cfg.package;
DynamicUser = true;
ProtectSystem = "strict";
PrivateTmp = true;
BindReadOnlyPaths = [
cfg.orgDir
cfg.databasePath
"/nix"
];
};
};
};
}

View File

@@ -1,9 +1,8 @@
#:net.deertopia.doerg.config #:net.deertopia.doerg.config
{:ibm-plex-web #or [#xdg-data-dir "ibm-plex-web" {:ibm-plex-web #or [#env IBM_PLEX_WEB
#env IBM_PLEX_WEB] #xdg-data-dir "ibm-plex-web"]
:latex "xelatex" :latex "xelatex"
:dvisvgm "dvisvgm" :dvisvgm "dvisvgm"
:debug-unimplemented? #profile {:dev true :default false}
:doerg-temml-worker :doerg-temml-worker
#profile {:dev #file "../../../../doerg-temml-worker/index.js" #profile {:dev #file "../../../../doerg-temml-worker/index.js"
:default "doerg-temml-worker"} :default "doerg-temml-worker"}

View File

@@ -18,8 +18,10 @@
calling `compute` with no arguments only if stale? is logical true." calling `compute` with no arguments only if stale? is logical true."
[& {:keys [file stale? compute]}] [& {:keys [file stale? compute]}]
(when (or (not *use-cache?*) stale?) (when (or (not *use-cache?*) stale?)
(let [r (compute)] (let [r (compute)
dir (fs/parent file)]
(assert (string? r)) (assert (string? r))
(fs/create-dirs (fs/parent file)) (when-not (fs/exists? dir)
(fs/create-dirs dir))
(spit file r))) (spit file r)))
file) file)

View File

@@ -46,7 +46,8 @@
"Aero tag to search for a directory on $XDG_DATA_DIRS." "Aero tag to search for a directory on $XDG_DATA_DIRS."
(some #(let [x (fs/path % value)] (some #(let [x (fs/path % value)]
(and (fs/exists? x) x)) (and (fs/exists? x) x))
(fs/split-paths (System/getenv "XDG_DATA_DIRS")))) (some-> (System/getenv "XDG_DATA_DIRS")
fs/split-paths)))
(defmethod aero/reader 'file (defmethod aero/reader 'file
[{:keys [source]} tag value] [{:keys [source]} tag value]