summaryrefslogtreecommitdiff
path: root/home-modules/lmu-hausschrift/default.nix
blob: c33449475fad06c55d151164baa9ad6763229d11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{ config, pkgs, lib, ... }:

with lib;

{
  options = {
    fonts.lmu-hausschrift.enable = mkEnableOption "LMU Hausschrift";
  };

  config = mkIf config.fonts.lmu-hausschrift.enable {
    sops.secrets."lmu-hausschrift.tar.zstd" = {
      format = "binary";
      sopsFile = ./lmu-hausschrift.tar.zstd;
    };

    xdg.configFile = {
      "fontconfig/conf.d/20-lmu-hausschrift.conf".text = ''
        <?xml version='1.0'?>

        <!DOCTYPE fontconfig SYSTEM 'urn:fontconfig:fonts.dtd'>
        <fontconfig>
          <dir>${config.home.homeDirectory}/.local/share/lmu-hausschrift</dir>
        </fontconfig>
      '';
    };

    systemd.user.services.sops-nix = {
      Service = {
        ExecStartPost = pkgs.writeShellScript "unpack-lmu-hausschrift.sh" ''
          set -xe

          out=''${XDG_RUNTIME_DIR:-/tmp}/lmu-hausschrift
          src="${config.sops.secrets."lmu-hausschrift.tar.zstd".path}"
          src=''${src#"%r/"}
          src=''${XDG_RUNTIME_DIR:-/tmp}/"''${src}"

          umask 07077

          if [[ ! -d "''${out}" ]]; then
            ${pkgs.coreutils}/bin/mkdir -p "''${out}"
            ${pkgs.gnutar}/bin/tar -xaf "''${src}" -C "''${out}"

            ${pkgs.coreutils}/bin/ln -sfT "''${out}" "${config.home.homeDirectory}/.local/share/lmu-hausschrift"
          fi
        '';
      };
    };
  };
}