{ config, pkgs, lib, ... }: let cfg = config.programs.quickshell; in { disabledModules = ["programs/quickshell.nix"]; options = { programs.quickshell = { enable = lib.mkEnableOption "quickshell"; package = lib.mkPackageOption pkgs "quickshell" { nullable = true; }; config.src = lib.mkOption { type = lib.types.path; }; config.replacements = lib.mkOption { type = lib.types.attrsOf lib.types.str; default = {}; }; }; }; config = lib.mkIf cfg.enable { home.packages = [ cfg.package ]; xdg.configFile."quickshell".source = pkgs.stdenvNoCC.mkDerivation { name = "quickshell"; preferLocalBuild = true; allowSubstitutes = false; dontUnpack = true; inherit (cfg.config) src; buildPhase = '' runHook preBuild while IFS= read -r -d $'\0' file <&3; do [[ -z $file ]] && continue mkdir -p "$out"/"$(dirname "$file")" substitute "$src"/"$file" "$out"/"$file" \ ${lib.concatStringsSep " " ( lib.concatLists (lib.mapAttrsToList (name: value: [ "--replace-quiet" (lib.escapeShellArg "@${name}@") (lib.escapeShellArg value) ]) cfg.config.replacements) )} done 3< <(find "$src" -type f -printf '%P\0') runHook postBuild ''; }; systemd.user.services.quickshell = { Unit = { Description = "quickshell"; Documentation = "https://quickshell.org/docs/v${cfg.package.version}"; PartOf = [ "graphical-session.target" ]; After = [ "graphical-session-pre.target" ]; }; Service = { ExecStart = lib.getExe cfg.package; Restart = "always"; }; Install = { WantedBy = [ "graphical-session.target" ]; }; }; }; }