summaryrefslogtreecommitdiff
path: root/users/ryan/linux/guix.nix
blob: 21fea520bd63e053fd57a7e265ecafd484607ec7 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{ config, pkgs, lib, inputs, ... }:

{
  systemd.user.startServices = false;

  programs.zsh.profileExtra = ''
    if [ -f "$HOME/.guix-home/setup-environment" ]; then
      HOME_ENVIRONMENT="$HOME/.guix-home"
      . "$HOME_ENVIRONMENT/setup-environment"
      "$HOME_ENVIRONMENT/on-first-login"
      unset HOME_ENVIRONMENT
    fi

    # /etc/profile normally puts ~/.config/guix/current (the guix pull
    # profile with our actual channels: nonguix, rosenthal, ...) ahead of
    # /run/current-system/profile on PATH, but that only happens for bash
    # login shells -- zsh never sources /etc/profile. Without this, `guix`
    # resolves to the bare system profile's guix, which doesn't know about
    # our channels.
    if [ -d "$HOME/.config/guix/current" ]; then
      export PATH="$HOME/.config/guix/current/bin:$PATH"
      export INFOPATH="$HOME/.config/guix/current/share/info''${INFOPATH:+:}$INFOPATH"
    fi
  '';

  dconf.enable = false;

  wayland.windowManager.hyprland.extraConfig = ''
    exec-once = sh -c 'gpgconf --launch gpg-agent; hyprctl setenv SSH_AUTH_SOCK "$(gpgconf --list-dirs agent-ssh-socket)"'
  '';

  programs.gpg.scdaemonSettings.disable-ccid = true;

  # Guix needs a special fonts.conf file in the user env since it doesn't
  # have one in /etc/fonts/fonts.conf from nixos
  xdg.configFile."fontconfig-nix/fonts.conf".text = ''
    <?xml version='1.0'?>
    <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
    <fontconfig>
      <include ignore_missing="yes">${pkgs.fontconfig.out}/etc/fonts/conf.d</include>
      <include ignore_missing="yes">${config.home.homeDirectory}/.config/fontconfig/conf.d</include>
      <dir>${config.home.homeDirectory}/.guix-home/profile/share/fonts</dir>
      <cachedir>${config.home.homeDirectory}/.cache/fontconfig</cachedir>
    </fontconfig>
  '';

  home.sessionVariables.FONTCONFIG_FILE = "${config.home.homeDirectory}/.config/fontconfig-nix/fonts.conf";

  home.packages = [
    (pkgs.writeScriptBin "hyprlock" ''
      #! ${pkgs.bash}/bin/bash
      export LD_PRELOAD="/run/current-system/profile/lib/libpam.so.0:$LD_PRELOAD"
      exec ${pkgs.hyprlock}/bin/hyprlock "$@"
    '')

    # Guix's mesa doesn't match nixpkgs', so GL apps built by nix need nixGL.
    inputs.nixgl.packages.${pkgs.stdenv.hostPlatform.system}.nixGLIntel
  ];

  # We need to correct the ssh config file's permissions on guix
  # Remove the symlink and just install the store file directly
  home.activation = {
    fixSshPermissions = lib.hm.dag.entryAfter [ "linkGeneration" ] ''
      run install -d -m 0700 "$HOME/.ssh"
      if [ -L "$HOME/.ssh/config" ]; then
        src="$(readlink -f "$HOME/.ssh/config")"
        run rm -f "$HOME/.ssh/config"
        run install -m 0600 "$src" "$HOME/.ssh/config"
      fi
    '';
  };
}