From c3a8a171734bfeced58f4611365e85a6daed7db9 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 29 Aug 2025 23:06:55 +0200 Subject: ... --- home-modules/quickshell.nix | 68 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 home-modules/quickshell.nix (limited to 'home-modules/quickshell.nix') diff --git a/home-modules/quickshell.nix b/home-modules/quickshell.nix new file mode 100644 index 00000000..dac7089f --- /dev/null +++ b/home-modules/quickshell.nix @@ -0,0 +1,68 @@ +{ 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" ]; + }; + }; + }; +} -- cgit v1.2.3