Personal Nix setup

Add XDG module

Changed files
+82 -19
home
modules
+1
home/base/default.nix
···
./git.nix
./shell.nix
./tmux.nix
+
./xdg.nix
];
}
+10 -6
home/base/gpg.nix
···
with lib;
let
cfg = config.modules.gpg;
-
home = config.home.homeDirectory;
+
home = "${config.xdg.dataHome}/gnupg";
in {
options.modules.gpg = {
enable = mkOption {
···
config = mkIf cfg.enable {
modules.git.signingKey = mkDefault "303B6A9A312AA035";
+
home.sessionVariables = {
+
GNUPGHOME = home;
+
};
+
age.secrets."pubring.kbx" = {
symlink = true;
-
path = "${home}/.gnupg/pubring.kbx";
+
path = "${home}/pubring.kbx";
file = ./encrypt/pubring.kbx.age;
};
age.secrets."75EF1DBB30A59CFB56BCE06A88CCF363DA63B1A7.key" = {
symlink = true;
-
path = "${home}/.gnupg/private-keys-v1.d/75EF1DBB30A59CFB56BCE06A88CCF363DA63B1A7.key";
+
path = "${home}/private-keys-v1.d/75EF1DBB30A59CFB56BCE06A88CCF363DA63B1A7.key";
file = ./encrypt/75EF1DBB30A59CFB56BCE06A88CCF363DA63B1A7.key.age;
};
age.secrets."E2BFF19637FDC25A02F45583176FAD1ED1F6BDD6.key" = {
symlink = true;
-
path = "${home}/.gnupg/private-keys-v1.d/E2BFF19637FDC25A02F45583176FAD1ED1F6BDD6.key";
+
path = "${home}/private-keys-v1.d/E2BFF19637FDC25A02F45583176FAD1ED1F6BDD6.key";
file = ./encrypt/E2BFF19637FDC25A02F45583176FAD1ED1F6BDD6.key.age;
};
age.secrets."CA84692E3CC846C8EC7272468E962B63FC599E49.key" = {
symlink = true;
-
path = "${home}/.gnupg/private-keys-v1.d/CA84692E3CC846C8EC7272468E962B63FC599E49.key";
+
path = "${home}/private-keys-v1.d/CA84692E3CC846C8EC7272468E962B63FC599E49.key";
file = ./encrypt/CA84692E3CC846C8EC7272468E962B63FC599E49.key.age;
};
-
home.file.".gnupg/sshcontrol".text = ''
+
xdg.dataFile."gnupg/sshcontrol".text = ''
E2BFF19637FDC25A02F45583176FAD1ED1F6BDD6
75EF1DBB30A59CFB56BCE06A88CCF363DA63B1A7
'';
+8 -1
home/base/shell.nix
···
};
config = mkIf cfg.enable {
-
programs.zsh = {
+
programs.zsh = rec {
enable = true;
enableCompletion = true;
enableVteIntegration = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
+
dotDir = ".config/zsh";
shellAliases = {
ls = "ls --color=auto";
ll = "ls -l";
wx = "wezmux";
http = "xh";
};
+
history = {
+
append = true;
+
expireDuplicatesFirst = true;
+
path = "${config.xdg.stateHome}/zsh/zsh_history";
+
};
sessionVariables = {
KEYTIMEOUT = "1";
VIM_MODE_TRACK_KEYMAP = "no";
···
PURE_GIT_UP_ARROW = " ";
PURE_GIT_DOWN_ARROW = " ";
PURE_GIT_STASH_SYMBOL = " ";
+
ZDOTDIR = "${config.xdg.configHome}/zsh";
};
plugins = [
{
+36
home/base/xdg.nix
···
+
{ lib, helpers, config, pkgs, ... }:
+
+
with lib;
+
let
+
cfg = config.modules.xdg;
+
in {
+
options = {
+
modules.xdg = {
+
enable = mkOption {
+
default = true;
+
description = "XDG Configuration";
+
type = types.bool;
+
};
+
};
+
xdg.runtimeDir = mkOption {
+
type = types.nullOr types.string;
+
default = if helpers.isDarwin then "$(mktemp -d --suffix=$UID)" else null;
+
apply = (val: if val != null then (toString val) else null);
+
};
+
};
+
+
config = mkIf cfg.enable {
+
xdg = {
+
enable = true;
+
userDirs.enable = mkDefault helpers.isLinux;
+
systemDirs.data = mkIf helpers.isLinux [
+
"/usr/share"
+
"/usr/local/share"
+
];
+
};
+
+
home.sessionVariables = {
+
XDG_RUNTIME_DIR = optionalString (config.xdg.runtimeDir != null) config.xdg.runtimeDir;
+
};
+
};
+
}
+21 -12
home/development/js.nix
···
with lib;
let
cfg = config.modules.development;
-
home = config.home.homeDirectory;
+
NPMRC_PATH = "${config.xdg.configHome}/npm/npmrc";
+
BUNFIG_PATH = "${config.xdg.configHome}/.bunfig.toml";
+
BUN_HOME = "${config.xdg.dataHome}/bun";
+
PNPM_HOME = "${config.xdg.dataHome}/pnpm";
in {
options.modules.development.js = {
enable = mkOption {
···
};
config = mkIf cfg.js.enable {
-
age.secrets."npmrc" = {
+
age.secrets."${NPMRC_PATH}" = {
symlink = true;
-
path = "${home}/.npmrc";
+
path = "${NPMRC_PATH}";
file = ./encrypt/npmrc.age;
};
home.sessionPath = [
"./node_modules/.bin"
-
"$HOME/.local/share/pnpm"
-
];
+
PNPM_HOME
+
] ++ optionals cfg.js.bun [ BUN_HOME ];
home.sessionVariables = {
-
PNPM_HOME = "$HOME/.local/share/pnpm";
-
BUN_RUNTIME_TRANSPILER_CACHE_PATH = mkIf cfg.js.bun "$HOME/.cache/bun/install/cache/@t@";
-
COREPACK_ENABLE_AUTO_PIN = "0";
+
inherit PNPM_HOME;
+
BUN_RUNTIME_TRANSPILER_CACHE_PATH = mkIf cfg.js.bun "${config.xdg.cacheHome}/bun/install/cache/@t@";
+
NODE_REPL_HISTORY = "${config.xdg.stateHome}/node_repl_history";
+
NPM_CONFIG_USERCONFIG = "${NPMRC_PATH}";
+
NPM_CONFIG_CACHE = "${config.xdg.cacheHome}/npm";
+
NPM_CONFIG_TMP = "${config.xdg.runtimeDir}/npm";
+
VOLTA_HOME = "${config.xdg.dataHome}/volta";
+
+
COREPACK_ENABLE_AUTO_PIN = "0"; # disable corepack creating packageManager entries
};
home.file.".yarnrc".text = ''
disable-self-update-check true
'';
-
home.file.".bunfig.toml".text = mkIf cfg.js.bun ''
+
home.file."${BUNFIG_PATH}".text = mkIf cfg.js.bun ''
telemetry = false
[install]
auto = "disable"
-
globalDir = "~/.local/share/bun/global"
-
globalBinDir = "~/.local/share/bun"
+
globalDir = "${BUN_HOME}/global"
+
globalBinDir = "${BUN_HOME}"
[install.cache]
-
dir = "~/.cache/bun/install/cache"
+
dir = "${config.xdg.cacheHome}/bun"
'';
home.packages = with pkgs; [
+4
home/development/react-native.nix
···
home.packages = with pkgs; []
++ optionals cfg.react-native.cocoapods [ cocoapods ]
++ optionals cfg.react-native.fastlane [ fastlane ];
+
home.sessionVariables = {
+
CP_HOME_DIR = mkIf cfg.react-native.cocoapods "$XDG_DATA_HOME/cocoapods";
+
};
})
(mkIf cfg.react-native.android-sdk {
···
JAVA_HOME = pkgs.jdk.home;
ANDROID_USER_HOME = "${config.xdg.stateHome}/android";
ANDROID_AVD_HOME = "${ANDROID_USER_HOME}/avd";
+
GRADLE_USER_HOME = "${config.xdg.dataHome}/gradle";
};
android-sdk = {
+2
modules/base/nix-config.nix
···
flake-registry = "";
# Workaround for https://github.com/NixOS/nix/issues/9574
nix-path = config.nix.nixPath;
+
# Use xdg spec for .nix-defexpr
+
use-xdg-base-directories = true;
# binary caches
substituters = [
"https://cache.nixos.org"