infra/modules/user/session-variables.nix
Benjamin Yule Bädorf 56ea689de6
feat: add nix config to this repository
This used to live in the old pub-solar/os repository in the `momo/main`
branch. This commit changes that so this repository has all code from
terraform to nix.
2024-02-25 17:41:25 +01:00

120 lines
3.4 KiB
Nix

{
config,
pkgs,
lib,
...
}: let
psCfg = config.pub-solar;
xdg = config.home-manager.users."${psCfg.user.name}".xdg;
variables = {
XDG_CONFIG_HOME = xdg.configHome;
XDG_CACHE_HOME = xdg.cacheHome;
XDG_DATA_HOME = xdg.dataHome;
XDG_CURRENT_DESKTOP = "sway";
QT_QPA_PLATFORM = "wayland";
# Wayland fixes
ECORE_EVAS_ENGINE = "wayland_egl";
ELM_ENGINE = "wayland_egl";
SDL_VIDEODRIVER = "wayland";
EDITOR = "/etc/profiles/per-user/${psCfg.user.name}/bin/nvim";
VISUAL = "/etc/profiles/per-user/${psCfg.user.name}/bin/nvim";
# fix "xdg-open fork-bomb" your preferred browser from here
BROWSER = "${pkgs.firefox-wayland}/bin/firefox";
# node
NODE_REPL_HISTORY = "${xdg.dataHome}/node_repl_history";
NVM_DIR = "${xdg.dataHome}/nvm";
PKG_CACHE_PATH = "${xdg.cacheHome}/pkg-cache";
# npm
NPM_CONFIG_USERCONFIG = "${xdg.configHome}/npm/config";
NPM_CONFIG_CACHE = "${xdg.configHome}/npm";
# TODO: used to be XDG_RUNTIME_DIR NPM_CONFIG_TMP = "/tmp/npm";
# Make sure virsh runs without root
LIBVIRT_DEFAULT_URI = "qemu:///system";
# wine
WINEPREFIX = "${xdg.dataHome}/wineprefixes/default";
# z
_Z_DATA = "${xdg.dataHome}/z";
# wget
WGETRC = "${xdg.configHome}/wgetrc";
# rust
RUSTUP_HOME = "${xdg.dataHome}/rustup";
CARGO_HOME = "${xdg.dataHome}/cargo";
# Java
_JAVA_OPTIONS = "-Djava.util.prefs.userRoot='${xdg.configHome}/java'";
_JAVA_AWT_WM_NONREPARENTING = "1";
# docker
DOCKER_CONFIG = "${xdg.configHome}/docker";
# experimental wayland in firefox/thunderbird
MOZ_ENABLE_WAYLAND = "1";
# chromium / electron on wayland: enable ozone (native wayland mode)
NIXOS_OZONE_WL = "1";
# Vagrant
VAGRANT_HOME = "${xdg.dataHome}/vagrant";
VAGRANT_DEFAULT_PROVIDER = "libvirt";
# Android
ANDROID_SDK_ROOT = "${xdg.configHome}/android";
ANDROID_AVD_HOME = "${xdg.dataHome}/android";
ANDROID_EMULATOR_HOME = "${xdg.dataHome}/android";
ADB_VENDOR_KEY = "${xdg.configHome}/android";
# TELEMETRY BS
VUEDX_TELEMETRY = "off";
# FZF shell history widget default colors
FZF_DEFAULT_OPTS = lib.mkForce "--color=bg+:#2d2a2e,bg:#1a181a,spinner:#ef9062,hl:#7accd7 --color=fg:#d3d1d4,header:#7accd7,info:#e5c463,pointer:#ef9062 --color=marker:#ef9062,fg+:#d3d1d4,prompt:#e5c463,hl+:#7accd7";
# nnn theme colors
NNN_FCOLORS = let
BLK = "04";
CHR = "04";
DIR = "04";
EXE = "02";
REG = "00";
HARDLINK = "01";
SYMLINK = "01";
MISSING = "01";
ORPHAN = "07";
FIFO = "05";
SOCK = "05";
OTHER = "02";
in
BLK + CHR + DIR + EXE + REG + HARDLINK + SYMLINK + MISSING + ORPHAN + FIFO + SOCK + OTHER;
};
envListNames = lib.attrsets.mapAttrsToList (name: value: name) variables;
# Here we merge an extra variable into the attrset called FULL_ENV_LIST.
# It's a list of the variable names defined above.
# We can use this to tell `systemctl import-environment` to import the full list above.
variablesWithMeta = lib.attrsets.zipAttrsWith (name: values: builtins.head values) [
variables
{IMPORT_ENVIRONMENT_ENV_LIST = lib.lists.foldl (a: b: a + " " + b) "IMPORT_ENVIRONMENT_ENV_LIST" envListNames;}
];
in {
home-manager.users."${psCfg.user.name}" = {
home.sessionVariables = variablesWithMeta;
systemd.user.sessionVariables = variablesWithMeta;
};
environment.variables = variablesWithMeta;
}