From 4daf75938f53470e52a6907cebd4525bbd46bb49 Mon Sep 17 00:00:00 2001 From: Dmitriy Kholkin Date: Sat, 7 Jun 2025 18:15:44 +0300 Subject: [PATCH] feat: add modprobed-db service --- hosts/andromedae/default.nix | 1 + modules/home/services/modprobed-db.nix | 46 ++++++++++++++++++++++++++ overlays/default.nix | 20 +++++++++-- 3 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 modules/home/services/modprobed-db.nix diff --git a/hosts/andromedae/default.nix b/hosts/andromedae/default.nix index 8438b1c..b95d204 100644 --- a/hosts/andromedae/default.nix +++ b/hosts/andromedae/default.nix @@ -64,6 +64,7 @@ in home-manager.users.${defaultUser} = { ataraxia.defaults.role = "desktop"; ataraxia.theme.catppuccin.enable = true; + ataraxia.services.modprobed-db.enable = true; persist.state.directories = [ ".config/sops/age" diff --git a/modules/home/services/modprobed-db.nix b/modules/home/services/modprobed-db.nix new file mode 100644 index 0000000..62044dc --- /dev/null +++ b/modules/home/services/modprobed-db.nix @@ -0,0 +1,46 @@ +{ + config, + lib, + pkgs, + ... +}: +let + inherit (lib) mkEnableOption mkPackageOption mkIf; + cfg = config.ataraxia.services.modprobed-db; +in +{ + options = { + ataraxia.services.modprobed-db = { + enable = mkEnableOption "modprobed-db service to scan and store new kernel modules"; + package = mkPackageOption pkgs "modprobed-db" { }; + }; + }; + + config = mkIf cfg.enable { + systemd.user = { + services.modprobed-db = { + Unit = { + Description = "modprobed-db service to scan and store new kernel modules"; + Wants = [ "modprobed-db.timer" ]; + }; + Service = { + ExecStart = "${cfg.package}/bin/modprobed-db storesilent"; + Type = "simple"; + }; + Install.WantedBy = [ "default.target" ]; + }; + timers.modprobed-db = { + Unit.PartOf = [ "modprobed-db.service" ]; + Timer = { + Persistent = true; + OnUnitActiveSec = "1h"; + }; + Install.WantedBy = [ "timers.target" ]; + }; + }; + + persist.state.directories = [ + ".config/modprobed-db" + ]; + }; +} diff --git a/overlays/default.nix b/overlays/default.nix index e2d81b4..92265be 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,6 +1,5 @@ -inputs: _final: prev: +inputs: final: prev: let - inherit inputs; inherit (prev.hostPlatform) system; unstable = import inputs.nixpkgs-unstable { config = { @@ -47,6 +46,7 @@ in # Move modprobed config to subdir. Easier to use with impermanence modprobed-db = prev.modprobed-db.overrideAttrs (oa: { + nativeBuildInputs = [ prev.makeWrapper ] ++ oa.nativeBuildInputs or [ ]; postPatch = (oa.postPatch or "") + '' @@ -55,6 +55,22 @@ in substituteInPlace ./common/modprobed-db.skel \ --replace-fail "/.config" "/.config/modprobed-db" ''; + postInstall = + (oa.postInstall or "") + + '' + wrapProgram $out/bin/modprobed-db \ + --set PATH ${ + with final; + lib.makeBinPath [ + gawk + getent + coreutils + gnugrep + gnused + kmod + ] + } + ''; }); pass-secret-service = prev.pass-secret-service.overrideAttrs (_: {