Repository navigation
Expand file tree
/
Copy pathshell.nix
More file actions
executable file
·114 lines (99 loc) · 3.38 KB
/
Copy pathshell.nix
File metadata and controls
executable file
·114 lines (99 loc) · 3.38 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
{ pkgs ? import <nixpkgs> {
overlays = [
(import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"))
];
}
}:
let
rustToolchain = pkgs.rust-bin.stable."1.91.0".default;
in
pkgs.mkShell ({
nativeBuildInputs = with pkgs; [
perl
perlPackages.locallib
perlPackages.Appcpanminus
perlPackages.LWPProtocolHttps
perlPackages.IOSocketSSL
perlPackages.MozillaCA
cacert
caddy
mariadb
# Native deps for XML::Parser
expat
pkg-config
# Native deps for LWP::UserAgent and friends
openssl
zlib
which
emacs-nox
fish
tmux
fishPlugins.nvm
virtualenv
gitFull
ansible
curl
docker
docker-compose
go
wget
#packer
imagemagick
libusb1
rustToolchain
awscli2
(php.withExtensions ({ enabled, all }: enabled ++ [
all.xdebug
all.imagick
all.mailparse
]))
];
shellHook = ''
export NIX_ENFORCE_PURITY=0 # For compiling Perl modules
if [ -z "$TMUX" ]; then
SESSION_NAME=default
FISH=$(command -v fish)
# Get the absolute path to the repo root (where .config lives)
# Try git first, then fall back to resolving from current directory
REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || realpath . 2>/dev/null || pwd)"
CONFIG_HOME="$REPO_ROOT/.config"
# New panes must be fish with this repo's config. tmux drops a server
# that has no sessions (exit-empty), so start-server + set-option in a
# later command never reaches the session new-session actually creates.
# One client runs the options and creates the session before that exit.
export XDG_CONFIG_HOME="$CONFIG_HOME"
PANE_CMD="exec \"$FISH\""
if tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
tmux set-option -g default-shell "$FISH"
tmux set-option -g default-command "$PANE_CMD"
tmux set-environment -g XDG_CONFIG_HOME "$CONFIG_HOME"
tmux set-environment -g IN_NIX_SHELL "$IN_NIX_SHELL"
tmux set-environment -t "$SESSION_NAME" XDG_CONFIG_HOME "$CONFIG_HOME"
tmux set-environment -t "$SESSION_NAME" IN_NIX_SHELL "$IN_NIX_SHELL"
if [ -n "''${LOCALE_ARCHIVE:-}" ]; then
tmux set-environment -g LOCALE_ARCHIVE "$LOCALE_ARCHIVE"
tmux set-environment -t "$SESSION_NAME" LOCALE_ARCHIVE "$LOCALE_ARCHIVE"
fi
exec tmux attach-session -t "$SESSION_NAME"
else
# LOCALE_ARCHIVE exists only on glibc. Keep it in this same tmux
# invocation: a server with no sessions exits before a later command.
LOCALE_TMUX=()
if [ -n "''${LOCALE_ARCHIVE:-}" ]; then
LOCALE_TMUX=(set-environment -g LOCALE_ARCHIVE "$LOCALE_ARCHIVE" ";")
fi
exec tmux \
set-option -g default-shell "$FISH" ";" \
set-option -g default-command "$PANE_CMD" ";" \
set-environment -g XDG_CONFIG_HOME "$CONFIG_HOME" ";" \
"''${LOCALE_TMUX[@]}" \
set-environment -g IN_NIX_SHELL "$IN_NIX_SHELL" ";" \
new-session -s "$SESSION_NAME"
fi
fi
'';
} // pkgs.lib.optionalAttrs (pkgs.glibcLocales != null) {
# Nix glibc does not include host locales. New tmux panes are login shells,
# and /etc/locale.conf sets LANG=en_GB.UTF-8. Darwin has no glibcLocales.
LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";
})