Reorganize imports

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2024-12-21 23:32:29 +02:00
parent 0ae56e6e25
commit 98ce774210
189 changed files with 253 additions and 260 deletions

View File

@@ -0,0 +1,26 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ config, pkgs, ... }:
{
nixpkgs.overlays = [
(final: prev: {
android-tools = prev.android-tools.overrideAttrs (oldAttrs: {
patches = oldAttrs.patches or [ ] ++ [ ./env-var-user-home.patch ];
});
})
];
programs.adb.enable = true;
services.gvfs.enable = true;
users.users.${user}.extraGroups = [ "adbusers" ];
environment.persistence."/persist" = {
"${home}/.local/share/android/adbkey" = { };
"${home}/.local/share/android/adbkey.pub" = { };
};
home-manager.users.${user}.home.sessionVariables.ANDROID_USER_HOME = "${home}/.local/share/android";
}

View File

@@ -0,0 +1,21 @@
--- a/vendor/adb/adb_utils.cpp
+++ b/vendor/adb/adb_utils.cpp
@@ -308,8 +308,16 @@
}
std::string adb_get_android_dir_path() {
- std::string user_dir = adb_get_homedir_path();
- std::string android_dir = user_dir + OS_PATH_SEPARATOR + ".android";
+ const char* android_user_home = getenv("ANDROID_USER_HOME");
+ std::string android_dir;
+
+ if (android_user_home) {
+ android_dir = std::string(android_user_home);
+ } else {
+ std::string user_dir = adb_get_homedir_path();
+ android_dir = user_dir + OS_PATH_SEPARATOR + ".android";
+ }
+
struct stat buf;
if (stat(android_dir.c_str(), &buf) == -1) {
if (adb_mkdir(android_dir, 0750) == -1) {

View File

@@ -0,0 +1,8 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ lib, pkgs, ... }:
{
home-manager.users.${user}.programs.bashmount.enable = true;
}

View File

@@ -0,0 +1,32 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{
config,
lib,
pkgs,
...
}:
{
home-manager.users.${user}.systemd.user.services.mpris-proxy = {
Unit = {
Description = "MPRIS proxy";
Requires = [ "sound.target" ];
After = [
"network.target"
"sound.target"
];
};
Service.ExecStart = lib.meta.getExe (
pkgs.writeShellApplication {
name = "init-mpris-proxy";
runtimeInputs = with pkgs; [ bluez ];
text = "exec mpris-proxy";
}
);
Install.WantedBy = [ "default.target" ];
};
}

View File

@@ -0,0 +1,13 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ lib, pkgs, ... }:
{
users.users.${user}.extraGroups = [
"video"
"inputs"
];
home-manager.users.${user}.home.packages = with pkgs; [ brightnessctl ];
}

View File

@@ -0,0 +1,20 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ ... }:
{
home-manager.users.${user}.programs.btop = {
enable = true;
settings = {
theme_background = false;
presets = "";
vim_keys = true;
shown_boxes = "cpu mem net proc gpu0 gpu1";
update_ms = 1000;
proc_tree = true;
cpu_single_graph = true;
disks_filter = "/ /nix /persist /cache";
};
};
}

View File

@@ -0,0 +1,43 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{
config,
inputs,
utils,
pkgs,
...
}:
{
virtualisation.docker.rootless = {
enable = true;
setSocketVariable = true;
enableOnBoot = false;
storageDriver = "btrfs";
daemon.settings = {
experimental = true;
ipv6 = true;
fixed-cidr-v6 = "fd00::/80";
};
autoPrune = {
enable = true;
flags = [ "--all" ];
};
};
environment.persistence."/persist"."${home}/.local/share/docker" = { };
systemd.user = {
services.docker.after = [
config.environment.persistence."/persist"."${home}/.local/share/docker".mount
];
sockets.docker.after = [
config.environment.persistence."/persist"."${home}/.local/share/docker".mount
];
};
home-manager.users.${user}.home.packages = with pkgs; [ docker-compose ];
}

View File

@@ -0,0 +1,8 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ ... }:
{
home-manager.users.${user}.programs.fastfetch.enable = true;
}

View File

@@ -0,0 +1,8 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ pkgs, ... }:
{
home-manager.users.${user}.home.packages = with pkgs; [ ffmpeg ];
}

View File

@@ -0,0 +1,3 @@
git interpret-trailers --if-exists doNothing --trailer \
"Signed-off-by: $(git config user.name) <$(git config user.email)>" \
--in-place "$1"

View File

@@ -0,0 +1,47 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{
config,
lib,
pkgs,
...
}:
let
userConfig = config.users.users.${user};
in
{
home-manager.users.${user} = {
programs.git = {
enable = true;
lfs.enable = true;
userName = userConfig.fullName;
userEmail = userConfig.email;
signing = {
signByDefault = true;
key = null;
};
extraConfig = {
credential.helper = "store";
push.autoSetupRemote = true;
core.fsmonitor = true;
feature.manyFiles = true;
fetch.writeCommitGraph = true;
http.cookiefile = "${home}/.config/git/cookies";
};
hooks = {
commit-msg = lib.meta.getExe (
pkgs.writeShellApplication {
name = "git-commit-msg-hook";
runtimeInputs = with pkgs; [ git ];
text = builtins.readFile ./commit-msg.sh;
}
);
};
};
};
}

View File

@@ -0,0 +1,69 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{
config,
lib,
pkgs,
...
}:
{
home-manager.users.${user} = {
# gpg --full-generate-key
# gpg --list-secret-keys --keyid-format LONG
# gpg --export-secret-keys -a $signature > priv.key
# gpg --export -a $signature > pub.key
programs.gpg = {
enable = true;
homedir = "${home}/.local/share/gnupg";
};
services.gpg-agent = {
enable = true;
defaultCacheTtl = 31536000;
maxCacheTtl = 31536000;
};
systemd.user = {
services.gpg-agent-import =
let
init = lib.meta.getExe (
pkgs.writeShellApplication {
name = "import-gpg-keys";
runtimeInputs = with pkgs; [
coreutils
gnugrep
gnupg
];
runtimeEnv = {
GNUPGHOME = "${home}/.local/share/gnupg";
HOME = home;
};
text = builtins.readFile ./import-gpg-keys.sh;
}
);
in
{
Unit = {
Description = "Auto-import GPG keys";
Requires = [
"sops-nix.service"
"gpg-agent.socket"
];
After = [
"sops-nix.service"
"gpg-agent.socket"
];
};
Service = {
Type = "oneshot";
ExecStart = init;
};
Install.WantedBy = [ "default.target" ];
};
};
};
}

View File

@@ -0,0 +1,23 @@
install -d -m 700 "${GNUPGHOME}"
for dir in "${HOME}"/.config/sops-nix/secrets/gpg/*; do
keyfile="${dir}/key"
passfile="${dir}/pass"
if [[ ! -f "${keyfile}" ]]; then
continue
fi
if [[ -f "${passfile}" ]]; then
gpg2 --batch --yes --pinentry-mode loopback --passphrase-file "${passfile}" --import "${keyfile}"
else
gpg2 --batch --yes --import "${keyfile}"
fi
gpg2 --with-colons --import-options show-only --import "${keyfile}" | grep '^fpr' | cut -d: -f10 | while read -r KEY_ID; do
echo "${KEY_ID}:6:" >> "${GNUPGHOME}"/otrust.txt
done
done
gpg2 --import-ownertrust "${GNUPGHOME}"/otrust.txt
rm "${GNUPGHOME}"/otrust.txt

View File

@@ -0,0 +1,29 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ config, inputs, ... }:
{
imports = [ inputs.home-manager.nixosModules.default ];
programs.dconf.enable = true;
home-manager = {
extraSpecialArgs = {
inherit inputs;
};
backupFileExtension = "bak";
useUserPackages = true;
useGlobalPkgs = true;
users.${user} = {
home.stateVersion = "24.11";
systemd.user.startServices = true;
nix.settings.experimental-features = [
"nix-command"
"flakes"
];
};
};
}

View File

@@ -0,0 +1,8 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ pkgs, ... }:
{
home-manager.users.${user}.home.packages = with pkgs; [ imagemagick ];
}

View File

@@ -0,0 +1,16 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ pkgs, ... }:
{
home-manager.users.${user}.dconf.settings = {
"org/virt-manager/virt-manager/connections" = {
autoconnect = [ "qemu:///system" ];
uris = [ "qemu:///system" ];
};
"org/virt-manager/virt-manager".xmleditor-enabled = true;
};
users.users.${user}.extraGroups = [ "libvirtd" ];
}

View File

@@ -0,0 +1,17 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ pkgs, ... }:
{
home-manager.users.${user} = {
home.packages = with pkgs; [ ncdu ];
xdg.configFile."ncdu/config".text = ''
-1
-e
-t 0
--confirm-quit
'';
};
}

View File

@@ -0,0 +1,20 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ ... }:
{
home-manager.users.${user}.programs.neovim = {
enable = true;
defaultEditor = true;
viAlias = true;
vimAlias = true;
vimdiffAlias = true;
extraConfig = ''
set tabstop=2
set shiftwidth=2
set expandtab
set smartindent
'';
};
}

View File

@@ -0,0 +1,16 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ ... }:
{
home-manager.users.${user}.programs.zsh.initExtra = ''
nix-develop() {
if [ -z "$1" ]; then
echo "Usage: nix-develop <shell>"
return 1
fi
nix develop self#"$1" -c "$SHELL"
}
'';
}

View File

@@ -0,0 +1,33 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ inputs, ... }:
{
home-manager.users.${user} = {
programs.direnv = {
enable = true;
silent = true;
nix-direnv.enable = true;
enableZshIntegration = true;
};
# https://github.com/direnv/direnv/wiki/Customizing-cache-location
xdg.configFile."direnv/direnvrc".text = ''
declare -A direnv_layout_dirs
direnv_layout_dir() {
local hash path
echo "''${direnv_layout_dirs[$PWD]:=$(
hash="$(sha1sum - <<< "$PWD" | head -c40)"
path="''${PWD//[^a-zA-Z0-9]/-}"
echo "${home}/.cache/direnv/layouts/''${hash}''${path}"
)}"
}
'';
};
environment.persistence = {
"/persist"."${home}/.local/share/direnv/allow" = { };
"/cache"."${home}/.cache/direnv" = { };
};
}

View File

@@ -0,0 +1,10 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ inputs, ... }:
{
home-manager.users.${user} = {
imports = [ inputs.nur.modules.homeManager.default ];
};
}

View File

@@ -0,0 +1,21 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ config, pkgs, ... }:
{
environment.persistence."/persist"."${home}/.local/state/wireplumber" = { };
systemd.user.services.wireplumber.after = [
config.environment.persistence."/persist"."${home}/.local/state/wireplumber".mount
];
home-manager.users.${user} = {
home.packages = with pkgs; [
wireplumber
playerctl
];
services.playerctld.enable = true;
};
}

View File

@@ -0,0 +1,17 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ ... }:
{
environment.persistence."/cache"."${home}/.cache/ranger" = { };
home-manager.users.${user}.programs.ranger = {
enable = true;
settings = {
preview_images = true;
preview_images_method = "kitty";
};
};
}

View File

@@ -0,0 +1,18 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ config, inputs, ... }:
{
environment.persistence."/persist"."${home}/.config/sops-nix/key.txt" = { };
home-manager.users.${user} = {
imports = [ inputs.sops-nix.homeManagerModules.sops ];
sops.age.keyFile = "${home}/.config/sops-nix/key.txt";
home.sessionVariables.SOPS_AGE_KEY_FILE = "${home}/.config/sops-nix/key.txt";
systemd.user.services.sops-nix.Unit.After = [
config.environment.persistence."/persist"."${home}/.config/sops-nix/key.txt".mount
];
};
}

View File

@@ -0,0 +1,25 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{
config,
lib,
pkgs,
...
}:
{
home-manager.users.${user} = {
programs.ssh = {
enable = true;
addKeysToAgent = "yes";
userKnownHostsFile = lib.strings.concatStringsSep " " [
../../../../../installer/secrets/ssh_host_ed25519_key.pub
../../../../../eirene/secrets/ssh_host_ed25519_key.pub
../../../../../elara/secrets/ssh_host_ed25519_key.pub
];
};
services.ssh-agent.enable = true;
};
}

View File

@@ -0,0 +1,49 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ config, utils, ... }:
{
networking.firewall = {
allowedTCPPorts = [ 22000 ];
allowedUDPPorts = [
21027
22000
];
};
sops.secrets = {
# openssl genpkey -algorithm RSA -out key.pem -pkeyopt rsa_keygen_bits:3072
"syncthing/key" = {
owner = user;
group = "users";
};
# openssl req -new -x509 -key key.pem -out cert.pem -days 9999 -subj "/CN=syncthing"
"syncthing/cert" = {
owner = user;
group = "users";
};
};
home-manager.users.${user} = {
services.syncthing = {
enable = true;
key = config.sops.secrets."syncthing/key".path;
cert = config.sops.secrets."syncthing/cert".path;
extraOptions = [ "-no-default-folder" ];
settings = {
options.urAccepted = -1;
devices = {
amalthea.id = "2W7YT6Q-TO7CYMW-JH6QZXE-7Q6MDQQ-HPHKP4A-VI5HP7G-KLMGMST-MNRYHQG"; # Google Pixel 8 Pro
ganymede.id = "DXJPEJA-JNGF6I4-VIZYTX7-U345C5V-HIUTSFC-D36N2EM-Y3FAKJM-PRKYQAI"; # Samsung Galaxy Tab S7+
};
};
};
systemd.user.services.syncthing.Unit.After = [
"sops-nix.service"
"local-fs.target"
];
};
}

View File

@@ -0,0 +1,8 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ ... }:
{
home-manager.users.${user}.programs.tmux.enable = true;
}

View File

@@ -0,0 +1,8 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ pkgs, ... }:
{
home-manager.users.${user}.home.packages = with pkgs; [ tree ];
}

View File

@@ -0,0 +1,8 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ pkgs, ... }:
{
home-manager.users.${user}.home.packages = with pkgs; [ wget ];
}

View File

@@ -0,0 +1,40 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ config, pkgs, ... }:
{
environment.persistence."/persist" = {
"${home}/Desktop" = { };
"${home}/Documents" = { };
"${home}/Downloads" = { };
"${home}/Music" = { };
"${home}/Pictures" = { };
"${home}/Templates" = { };
"${home}/Videos" = { };
"${home}/Games" = { };
"${home}/VMs" = { };
"${home}/git" = { };
};
home-manager.users.${user} = {
imports = [ (import ./options.nix { inherit home; }) ];
xdg = {
enable = true;
mimeApps.enable = true;
userDirs = {
enable = true;
createDirectories = true;
extraConfig = {
XDG_GAME_DIR = "${home}/Games";
XDG_VM_DIR = "${home}/VMs";
XDG_GIT_DIR = "${home}/git";
};
};
};
home.packages = with pkgs; [ xdg-utils ];
};
}

View File

@@ -0,0 +1,112 @@
{
home ? throw "home argument is required",
}:
{ config, lib, ... }:
let
cfg = config.xdg;
in
{
options.xdg =
with lib;
with types;
{
relativeCacheHome = mkOption {
type = str;
readOnly = true;
default = ".cache";
description = "Relative path to directory holding application caches.";
};
relativeConfigHome = mkOption {
type = str;
readOnly = true;
default = ".config";
description = "Relative path to directory holding application configurations.";
};
relativeDataHome = mkOption {
type = str;
readOnly = true;
default = ".local/share";
description = "Relative path to directory holding application data.";
};
relativeStateHome = mkOption {
type = str;
readOnly = true;
default = ".local/state";
description = "Relative path to directory holding application states.";
};
userDirs = {
relativeDesktop = mkOption {
type = str;
readOnly = true;
default = "Desktop";
description = "Relative path to the Desktop directory.";
};
relativeDocuments = mkOption {
type = str;
readOnly = true;
default = "Documents";
description = "Relative path to the Documents directory.";
};
relativeDownload = mkOption {
type = str;
readOnly = true;
default = "Downloads";
description = "Relative path to the Downloads directory.";
};
relativeMusic = mkOption {
type = str;
readOnly = true;
default = "Music";
description = "Relative path to the Music directory.";
};
relativePictures = mkOption {
type = str;
readOnly = true;
default = "Pictures";
description = "Relative path to the Pictures directory.";
};
relativeTemplates = mkOption {
type = str;
readOnly = true;
default = "Templates";
description = "Relative path to the Templates directory.";
};
relativeVideos = mkOption {
type = str;
readOnly = true;
default = "Videos";
description = "Relative path to the Videos directory.";
};
};
};
config.xdg =
with lib;
with cfg;
{
cacheHome = mkDefault "${home}/${relativeCacheHome}";
configHome = mkDefault "${home}/${relativeConfigHome}";
dataHome = mkDefault "${home}/${relativeDataHome}";
stateHome = mkDefault "${home}/${relativeStateHome}";
userDirs = with userDirs; {
desktop = mkDefault "${home}/${relativeDesktop}";
documents = mkDefault "${home}/${relativeDocuments}";
download = mkDefault "${home}/${relativeDownload}";
music = mkDefault "${home}/${relativeMusic}";
pictures = mkDefault "${home}/${relativePictures}";
templates = mkDefault "${home}/${relativeTemplates}";
videos = mkDefault "${home}/${relativeVideos}";
};
};
}

View File

@@ -0,0 +1,20 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ config, ... }:
{
home-manager.users.${user}.programs.yt-dlp = {
enable = true;
settings = {
live-from-start = true;
concurrent-fragments = config.hardware.cpu.threads;
lazy-playlist = true;
cookies-from-browser = "firefox";
embed-subs = true;
sub-langs = "all,-live_chat";
embed-thumbnail = true;
fixup = "detect_or_warn";
};
};
}

View File

@@ -0,0 +1,249 @@
'builtin' 'local' '-a' 'p10k_config_opts'
[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases')
[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob')
[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand')
'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand'
() {
emulate -L zsh -o extended_glob
unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR'
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
# =========================[ Line #1 ]=========================
dir
vcs
# =========================[ Line #2 ]=========================
newline
prompt_char
)
typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
# =========================[ Line #1 ]=========================
status
command_execution_time
background_jobs
direnv
ranger
vim_shell
nix_shell
per_directory_history
"${P10K_EXTRA_RIGHT_PROMPT_ELEMENTS[@]}"
context
# =========================[ Line #2 ]=========================
newline
)
typeset -g POWERLEVEL9K_MODE=ascii
typeset -g POWERLEVEL9K_ICON_PADDING=none
typeset -g POWERLEVEL9K_BACKGROUND=
typeset -g POWERLEVEL9K_{LEFT,RIGHT}_{LEFT,RIGHT}_WHITESPACE=
typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR=' '
typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_SEPARATOR=
typeset -g POWERLEVEL9K_ICON_BEFORE_CONTENT=true
typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
typeset -g POWERLEVEL9K_SHOW_RULER=false
typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' '
################################[ prompt_char: prompt symbol ]################################
typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=76
typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=196
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='>'
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='<'
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='V'
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='^'
typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true
typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL=''
##################################[ dir: current directory ]##################################
typeset -g POWERLEVEL9K_DIR_FOREGROUND=31
typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_unique
typeset -g POWERLEVEL9K_DIR_SHORTENED_FOREGROUND=103
typeset -g POWERLEVEL9K_DIR_ANCHOR_FOREGROUND=39
typeset -g POWERLEVEL9K_DIR_ANCHOR_BOLD=true
local anchor_files=(
.git
flake.nix
Cargo.toml
go.mod
package.json
)
typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})"
typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false
typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
typeset -g POWERLEVEL9K_DIR_MAX_LENGTH=80
typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS=40
typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT=50
typeset -g POWERLEVEL9K_DIR_HYPERLINK=false
typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v3
typeset -g POWERLEVEL9K_DIR_CLASSES=()
#####################################[ vcs: git status ]######################################
typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?'
function my_git_formatter() {
emulate -L zsh
if [[ -n $P9K_CONTENT ]]; then
typeset -g my_git_format=$P9K_CONTENT
return
fi
if (( $1 )); then
local meta='%f'
local clean='%76F'
local modified='%178F'
local untracked='%39F'
local conflicted='%196F'
else
local meta='%244F'
local clean='%244F'
local modified='%244F'
local untracked='%244F'
local conflicted='%244F'
fi
local res
if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then
local branch=${(V)VCS_STATUS_LOCAL_BRANCH}
(( $#branch > 32 )) && branch[13,-13]=".."
res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}"
fi
if [[ -n $VCS_STATUS_TAG
&& -z $VCS_STATUS_LOCAL_BRANCH
]]; then
local tag=${(V)VCS_STATUS_TAG}
(( $#tag > 32 )) && tag[13,-13]=".."
res+="${meta}#${clean}${tag//\%/%%}"
fi
[[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_TAG ]] &&
res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}"
if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then
res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}"
fi
if [[ $VCS_STATUS_COMMIT_SUMMARY == (|*[^[:alnum:]])(wip|WIP)(|[^[:alnum:]]*) ]]; then
res+=" ${modified}wip"
fi
if (( VCS_STATUS_COMMITS_AHEAD || VCS_STATUS_COMMITS_BEHIND )); then
(( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}<${VCS_STATUS_COMMITS_BEHIND}"
(( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" "
(( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}>${VCS_STATUS_COMMITS_AHEAD}"
fi
(( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}<-${VCS_STATUS_PUSH_COMMITS_BEHIND}"
(( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" "
(( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}->${VCS_STATUS_PUSH_COMMITS_AHEAD}"
(( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}"
[[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}"
(( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}"
(( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}"
(( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}"
(( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}"
(( VCS_STATUS_HAS_UNSTAGED == -1 )) && res+=" ${modified}-"
typeset -g my_git_format=$res
}
functions -M my_git_formatter 2>/dev/null
typeset -g POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY=-1
typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~'
typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true
typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter(1)))+${my_git_format}}'
typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION='${$((my_git_formatter(0)))+${my_git_format}}'
typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1
typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=76
typeset -g POWERLEVEL9K_VCS_LOADING_VISUAL_IDENTIFIER_COLOR=244
typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION=
typeset -g POWERLEVEL9K_VCS_BACKENDS=(git)
typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76
typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=76
typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=178
##########################[ status: exit code of the last command ]###########################
typeset -g POWERLEVEL9K_STATUS_EXTENDED_STATES=true
typeset -g POWERLEVEL9K_STATUS_OK=true
typeset -g POWERLEVEL9K_STATUS_OK_FOREGROUND=70
typeset -g POWERLEVEL9K_STATUS_OK_VISUAL_IDENTIFIER_EXPANSION='ok'
typeset -g POWERLEVEL9K_STATUS_OK_PIPE=true
typeset -g POWERLEVEL9K_STATUS_OK_PIPE_FOREGROUND=70
typeset -g POWERLEVEL9K_STATUS_OK_PIPE_VISUAL_IDENTIFIER_EXPANSION='ok'
typeset -g POWERLEVEL9K_STATUS_ERROR=false
typeset -g POWERLEVEL9K_STATUS_ERROR_FOREGROUND=160
typeset -g POWERLEVEL9K_STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION='err'
typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL=true
typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_FOREGROUND=160
typeset -g POWERLEVEL9K_STATUS_VERBOSE_SIGNAME=true
typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_VISUAL_IDENTIFIER_EXPANSION=
typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE=true
typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_FOREGROUND=160
typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION='err'
###################[ command_execution_time: duration of the last command ]###################
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=2
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=101
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s'
#######################[ background_jobs: presence of background jobs ]#######################
typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=false
typeset -g POWERLEVEL9K_BACKGROUND_JOBS_FOREGROUND=70
#######################[ direnv: direnv status (https://direnv.net/) ]########################
typeset -g POWERLEVEL9K_DIRENV_FOREGROUND=178
#################[ ranger: ranger shell (https://github.com/ranger/ranger) ]##################
typeset -g POWERLEVEL9K_RANGER_FOREGROUND=178
###########################[ vim_shell: vim shell indicator (:sh) ]###########################
typeset -g POWERLEVEL9K_VIM_SHELL_FOREGROUND=34
#[ nix_shell: nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) ]##
typeset -g POWERLEVEL9K_NIX_SHELL_FOREGROUND=74
typeset -g POWERLEVEL9K_NIX_SHELL_INFER_FROM_PATH=true
######[ per_directory_history: Oh My Zsh per-directory-history local/global indicator ]#######
typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_FOREGROUND=135
typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_FOREGROUND=130
##################################[ context: user@hostname ]##################################
typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=178
typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_FOREGROUND=180
typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=180
typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%B%n@%m'
typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_TEMPLATE='%n@%m'
typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%n@%m'
typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION=
#####################################[ Other Settings ]#######################################
typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=always
typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet
typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true
(( ! $+functions[p10k] )) || p10k reload
}
typeset -g POWERLEVEL9K_CONFIG_FILE=${${(%):-%x}:a}
(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]}
'builtin' 'unset' 'p10k_config_opts'

View File

@@ -0,0 +1,39 @@
{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{ config, pkgs, ... }:
{
environment = {
sessionVariables.ZDOTDIR = "$HOME/.config/zsh";
persistence."/persist"."${home}/.local/share/zsh" = { };
};
home-manager.users.${user} = {
programs.zsh = {
enable = true;
dotDir = ".config/zsh";
autocd = true;
history = {
path = "${home}/.local/share/zsh/history";
expireDuplicatesFirst = true;
append = true;
};
historySubstringSearch.enable = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
plugins = [
{
name = "powerlevel10k";
src = pkgs.zsh-powerlevel10k;
file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme";
}
];
initExtra = ''
source ${./.p10k.zsh}
'';
};
home.file.".zshenv".enable = false;
};
}