home: make bashrc.d
This commit is contained in:
parent
d4aad12c32
commit
94c12e9cdb
11
users/pbsds/home/profiles/bashrc.d/default.nix
Normal file
11
users/pbsds/home/profiles/bashrc.d/default.nix
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{ lib, ... }:
|
||||||
|
{
|
||||||
|
programs.bash.initExtra = lib.pipe (builtins.readDir ./.) [
|
||||||
|
(lib.filterAttrs (k: v: v == "regular"))
|
||||||
|
(lib.filterAttrs (k: v: lib.hasSuffix ".sh" k))
|
||||||
|
lib.attrNames
|
||||||
|
/* (map (x: builtins.readFile ./${x})) */
|
||||||
|
(map (x: "source ${./${x}}"))
|
||||||
|
lib.concatLines
|
||||||
|
];
|
||||||
|
}
|
20
users/pbsds/home/profiles/bashrc.d/destore.sh
Normal file
20
users/pbsds/home/profiles/bashrc.d/destore.sh
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
destore() {
|
||||||
|
for dst in "$@"; do
|
||||||
|
test -L "$dst" || continue
|
||||||
|
# TODO: assert dst is in the store
|
||||||
|
src="$(realpath "$dst")"
|
||||||
|
if test -d "$src"; then
|
||||||
|
(set -x
|
||||||
|
rm -v "$dst"
|
||||||
|
cp -r --dereference --one-file-system "$src/" "$dst/"
|
||||||
|
chmod -R +rw "$dst"
|
||||||
|
)
|
||||||
|
elif test -f "$src"; then
|
||||||
|
(set -x
|
||||||
|
rm -v "$dst"
|
||||||
|
cp -v "$src" "$dst"
|
||||||
|
chmod -v +rw "$dst"
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
20
users/pbsds/home/profiles/bashrc.d/mnix.sh
Normal file
20
users/pbsds/home/profiles/bashrc.d/mnix.sh
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
_choose_nix_systems() {
|
||||||
|
# x86_64-linux aarch64-linux aarch64-darwin x86_64-darwin i686-linux riscv64-linux x86_64-freebsd aarch64-freebsd i686-freebsd riscv64-freebsd
|
||||||
|
gum choose --no-limit --ordered --height 15 {linux,darwin,freebsd}-{x86_64,aarch64,i686,riscv64} \
|
||||||
|
| sed -E 's/^([^-]*)-([^-]*)$/\2-\1/'
|
||||||
|
}
|
||||||
|
|
||||||
|
mnix-build() {
|
||||||
|
# TODO: somehow store the out-links
|
||||||
|
_choose_nix_systems | xe -j0 -s 'nix-instantiate --system "$1" '"$(printf " %q" "$@")" | xargs nix-build --keep-going --no-out-link
|
||||||
|
}
|
||||||
|
mnom-build() {
|
||||||
|
# TODO: somehow store the out-links
|
||||||
|
_choose_nix_systems | xe -j0 -s 'nix-instantiate --system "$1" '"$(printf " %q" "$@")" | xargs nom-build --keep-going --no-out-link
|
||||||
|
}
|
||||||
|
mnixpkgs-review() {
|
||||||
|
# TODO: use /run/user/...
|
||||||
|
# mkdir -p /dev/shm/nixpkgs-review
|
||||||
|
# ln -sfn /dev/shm/nixpkgs-review $HOME/.cache/nixpkgs-review
|
||||||
|
nixpkgs-review --systems "$(_choose_nix_systems | xargs)" "$@"
|
||||||
|
}
|
@ -6,8 +6,8 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
programs.bash.initExtra = ''
|
programs.bash.initExtra = ''
|
||||||
function vpn (
|
vpn() (
|
||||||
ip="$(dig +short -x a $1 | tail -n 1)"
|
ip="$(dig +short -x a $1 | tail -n 1)"
|
||||||
set -x
|
set -x
|
||||||
#sshuttle 0.0.0.0/0 --disable-ipv6 --dns -r "$1" -x $ip -x 127.0.0.1 -x 172.0.0.0/8
|
#sshuttle 0.0.0.0/0 --disable-ipv6 --dns -r "$1" -x $ip -x 127.0.0.1 -x 172.0.0.0/8
|
||||||
sshuttle 0.0.0.0/0 ::/0 --dns -r "$1" -x $ip -x 127.0.0.1 -x 172.0.0.0/8
|
sshuttle 0.0.0.0/0 ::/0 --dns -r "$1" -x $ip -x 127.0.0.1 -x 172.0.0.0/8
|
||||||
|
@ -35,52 +35,12 @@ in
|
|||||||
if command -v tldr >/dev/null; then
|
if command -v tldr >/dev/null; then
|
||||||
complete -F _command tldr
|
complete -F _command tldr
|
||||||
fi
|
fi
|
||||||
|
|
||||||
destore() {
|
|
||||||
for dst in "$@"; do
|
|
||||||
test -L "$dst" || continue
|
|
||||||
# TODO: assert dst is in the store
|
|
||||||
src="$(realpath "$dst")"
|
|
||||||
if test -d "$src"; then
|
|
||||||
(set -x
|
|
||||||
rm -v "$dst"
|
|
||||||
cp -r --dereference --one-file-system "$src/" "$dst/"
|
|
||||||
chmod -R +rw "$dst"
|
|
||||||
)
|
|
||||||
elif test -f "$src"; then
|
|
||||||
(set -x
|
|
||||||
rm -v "$dst"
|
|
||||||
cp -v "$src" "$dst"
|
|
||||||
chmod -v +rw "$dst"
|
|
||||||
)
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
_choose_nix_systems() {
|
|
||||||
# x86_64-linux aarch64-linux aarch64-darwin x86_64-darwin i686-linux riscv64-linux x86_64-freebsd aarch64-freebsd i686-freebsd riscv64-freebsd
|
|
||||||
gum choose --no-limit --ordered --height 15 {linux,darwin,freebsd}-{x86_64,aarch64,i686,riscv64} \
|
|
||||||
| sed -E 's/^([^-]*)-([^-]*)$/\2-\1/'
|
|
||||||
}
|
|
||||||
|
|
||||||
mnix-build() {
|
|
||||||
# TODO: somehow store the out-links
|
|
||||||
_choose_nix_systems | xe -j0 -s 'nix-instantiate --system "$1" '"$(printf " %q" "$@")" | xargs nix-build --keep-going --no-out-link
|
|
||||||
}
|
|
||||||
mnom-build() {
|
|
||||||
# TODO: somehow store the out-links
|
|
||||||
_choose_nix_systems | xe -j0 -s 'nix-instantiate --system "$1" '"$(printf " %q" "$@")" | xargs nom-build --keep-going --no-out-link
|
|
||||||
}
|
|
||||||
mnixpkgs-review() {
|
|
||||||
# TODO: use /run/user/...
|
|
||||||
# mkdir -p /dev/shm/nixpkgs-review
|
|
||||||
# ln -sfn /dev/shm/nixpkgs-review $HOME/.cache/nixpkgs-review
|
|
||||||
nixpkgs-review --systems "$(_choose_nix_systems | xargs)" "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
imports = [ ../modules/jump.nix ];
|
imports = [
|
||||||
|
../profiles/bashrc.d
|
||||||
|
../modules/jump.nix
|
||||||
|
];
|
||||||
programs.jump.enableBash = true;
|
programs.jump.enableBash = true;
|
||||||
|
|
||||||
programs.nix-index.enable = true;
|
programs.nix-index.enable = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user