diff --git a/flake.lock b/flake.lock index d72a575..7bfcab4 100644 --- a/flake.lock +++ b/flake.lock @@ -1048,11 +1048,11 @@ "quickshell": "quickshell" }, "locked": { - "lastModified": 1756054748, - "narHash": "sha256-2foGqHuyLmaZb59MEKbWmLubsLApH/b+nJEu/SQePS8=", + "lastModified": 1756691994, + "narHash": "sha256-DeFBhcUJs4JHRKsRAaG+j9GjWgPIiW3JQmsneFGkc9Q=", "ref": "refs/heads/main", - "rev": "7a5635507eb857c544f22c76d9c5e7a6624d01ea", - "revCount": 3761, + "rev": "ee37fc5f6d585da93bf87a861d3c54baa5f4f168", + "revCount": 3762, "type": "git", "url": "https://git.sakamoto.dev/kenji/illogical-impulse.git" }, diff --git a/modules/default/apps.nix b/modules/default/apps.nix index 2a48a1d..e745dab 100644 --- a/modules/default/apps.nix +++ b/modules/default/apps.nix @@ -8,20 +8,13 @@ protontricks wl-clipboard tldr - lact anki ]; imports = [ ../../packages/virtualbox/default.nix + ../../packages/lact/default.nix ]; - - systemd.services.lact = { - description = "AMDGPU Control Daemon"; - after = ["multi-user.target"]; - wantedBy = ["multi-user.target"]; - serviceConfig = { - ExecStart = "${pkgs.lact}/bin/lact daemon"; - }; + custom.lact = { enable = true; }; # services = { diff --git a/packages/lact/default.nix b/packages/lact/default.nix new file mode 100644 index 0000000..2846195 --- /dev/null +++ b/packages/lact/default.nix @@ -0,0 +1,50 @@ +{ + config, + lib, + pkgs, + ... +}: let + inherit (lib) mkEnableOption mkOption mkIf; + this = config.custom.lact; + + configFile = + pkgs.runCommand "lact-config.yaml" { + json = pkgs.writers.writeJSON "lact-config.json" this.settings; + } '' + # Merge with the defaults + ${lib.getExe pkgs.yq} -s '.[0] * .[1]' $json ${./lact-default-config.yaml} > config.json + # Convert keys to numeric values where possible. It depends on this for some reason. + ${lib.getExe pkgs.yj} -jy -k < config.json > $out + ''; +in { + options.custom.lact = { + enable = mkEnableOption "my LACT module"; + settings = mkOption { + default = {}; + type = lib.types.submodule { + freeformType = (pkgs.formats.yaml {}).type; + }; + description = '' + Settings for LACT. Settings are merged with the defaults. + + The easiest method of acquiring the settings is to delete + `/etc/lact/config.yaml`, enter your settings and look at the file. + ''; + }; + }; + + config = mkIf this.enable { + systemd.packages = with pkgs; [ + lact + ]; + systemd.services.lactd.wantedBy = ["multi-user.target"]; + + environment.etc."lact/config.yaml" = mkIf (this.settings != {}) { + source = configFile; + }; + systemd.services.lactd = { + # Restart if config changed + restartTriggers = mkIf (this.settings != {}) [configFile]; + }; + }; +} diff --git a/packages/lact/lact-default-config.yaml b/packages/lact/lact-default-config.yaml new file mode 100644 index 0000000..0feb893 --- /dev/null +++ b/packages/lact/lact-default-config.yaml @@ -0,0 +1,8 @@ +daemon: + log_level: info + admin_groups: + - wheel + - sudo + disable_clocks_cleanup: false +apply_settings_timer: 5 +gpus: {}