- Shell 40.7%
- Scheme 34.7%
- Perl 23.4%
- Common Lisp 1.2%
Iz's OpenBSD Dotfiles
Shameless Unixporn for internet points.
DISCLAIMER
- I'm not responsible for any system breakage due to my code.
- If you're unsure, refer to THE LICENSE to see how seriously I take this.
- Use with caution.
Crucial Information
- While there is a setup script in this project, it's not meant to be plug-and-play. It's a bare-bones setup, that is fairly non-portable and will require some tinkering to work perfectly. If you want a solid experience, use Linux Mint or GhostBSD. I don't see this as a problem because I'm comfortable customizing it to my needs. If you need assistance with this, I expect that as a bare minimum you read this entire ORG-mode file and have basic understanding of the function of these configs. I try not to hand-hold people. You learn nothing by blindly copy-pasting. Take this as a word of caution.
Note:
- My script doesn't perform any performance tweaking. I say to install the sysctl.conf file in /sshvoid/dotopenbsd/src/branch/main/%2AHow%20To%20Use but you should read the comments I put there. Users should refer to the FAQ, manpages, or the unofficial OpenBSD Handbook for more info for that. For more of a newb-friendly (albeit detailed) explanation video of some optimization tricks, Watch The OpenBSD Guy's Video
- For laptops, I highly recommend Solene%'s power management daemon obsdfreqd, Its a no-brainer. It's defaults are quite sane. It sets throttling for CPU frequency to avoid overheating when on line power. As of 7.1, OpenBSD maxes the CPU when on line power, but from my personal experience, this makes my laptop hardware thermal throttle like hell. In theory- the idea is sane. However, in practice, it tends to have adverse affects that are dependent on hardware. As Solene% says, this is not meant to "replace" the kernel scheduler. It tries to "nudge" the existing scheduling system to be better suited for laptop hardware.
How To Use
Please read the /sshvoid/dotopenbsd/src/branch/main/*DISCLAIMER, I am not your mother.
- Install OpenBSD on a machine with these specs
>=32GB install disk size with default partitioning (minimum reccomended)
4gb or more RAM
2 logical cores or more
OpenGL >=2.0 Capable GFX Card
- Switch to -CURRENT
# sysupgrade -sn
- Add
:doasgroup
# groupadd doas
# usermod -G wheel,operator,doas [your username]
- Add user to staff login class
# usermod -L staff [your username]
- grab my doas and sysctl configs
READ THESE FILES, and edit them as needed. they are documented in this README.org
# ftp -o /etc/doas.conf https://codeberg.org/Izder456/dotfiles/raw/branch/main/doas.conf
# ftp -o /etc/sysctl.conf https://codeberg.org/Izder456/dotfiles/raw/branch/main/sysctl.conf
- reboot, let sysupgrade finish, and merge changes:
# reboot
# sysmerge -d
- Download and run
setup.kshas your regular user
READ THIS FILE: it, and its accompanying Rexfile are documented in this README.org
Choose the a option for the smoothest experience. You will need to be ready to type your doas password a lot.
$ cd $HOME
$ ftp https://codeberg.org/Izder456/dotfiles/raw/branch/main/setup.ksh
$ ksh setup.ksh
- Reboot again
# reboot
Dotfiles management
I use the dfm install script, see the dfm dir in this repo. This is the config.
.fonts recurse
.git recurse
.icons recurse
.themes recurse
.moc recurse
.config recurse
.local recurse
.claws-mail recurse
LICENSE.txt skip
COPYING skip
README.org skip
quicklisp-setup.lisp skip
doas.conf skip
sysctl.conf skip
mk.conf skip
pf.conf skip
hostname.veb0 skip
hostname.vport0 skip
relayd.conf skip
vm.conf skip
torrc skip
setup.pl skip
dfm skip
assets skip
backgrounds skip
Emacs-Config skip
Emwm-Config skip
StumpWM-Config skip
XenoDM-Config skip
APM-Config skip
Automation
p5-Rex is an automation thingy I use. It's definitely overkill, but I like perl. I split this up to the names of the files:
setup.kshis the inital bootstrap script. I set a personal constraint that I can't use any stuff outside of base OpenBSD for bootstrapping. For this reason, the initial bootstrap must function with korn shell in vanilla OpenBSD 7.5 or higher, as that is the default shell on OpenBSD, and includes some nice primitives that POSIX sh lacks.Rexfileis the config file for p5-Rex. It is perl code, but with a teeny bit of extensions. Think of it as an even more extensible ansible playbook, if that makes sense. You can manually run "tasks" with therexcommand in your shell. You can see the tasks available to run withrex -T. Besides, mysetup.kshsorta automates some basic tasks for you.
Korn Shell
The initial setup for the system.
Rust Deps
The list of packages to be installed via Cargo.
cargo-update cargo-cache tere zoxide
Lisp Deps
Quicklisp Install
You probably want this if you want to write with StumpWM and modules...
(quicklisp-quickstart:install :path "~/.quicklisp")
(ql:add-to-init-file)
(ql-dist:install-dist "http://dist.ultralisp.org/"
:prompt nil)
(ql:quickload '("clx"
"cl-ppcre"
"alexandria"
"cl-fad"
"xembed"
"anaphora"
"drakma"
"slynk"))
USE: (this is as a reference if you need to quickly set up quicklisp for x11/stumpwm hacking, and don't wanna use all of my dotfiles. the script automates this for you)
$ ftp -o /tmp/quicklisp.lisp https://beta.quicklisp.org/quicklisp.lisp
$ ftp -o /tmp/quicklisp-setup.lisp https://codeberg.org/Izder456/dotfiles/raw/branch/main/quicklisp-setup.lisp
$ sbcl --load /tmp/quicklisp.lisp --script /tmp/quicklisp-setup.lisp
Boilerplate
#!/bin/ksh
# Constants
USERHOME=$HOME
CODEBERG="https://codeberg.org"
SLEEPTIME=2
LOG_FILE="$HOME/setup.log"
# Set PATH explicitly
export PATH='/bin:/usr/bin:/sbin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:$HOME/bin'
Menu
Handlers
# Throw an error!
function exception {
error=1ドル
echo "Error: $error"
exit 1
}
# Log setup messages with timestamp
function log {
message=1ドル
stdout=${2:-1} # Default to logging to stdout if not specified
timestamp=$(date +"%Y%m%d%H%M%S")
if [[ $stdout -eq 1 ]]; then
echo "$message"
fi
echo "[$timestamp] $message" >> "$LOG_FILE" 2>&1 || exception "Could not write to $LOG_FILE"
}
Is the user reading?
# check for config sanity
for configfile in "/etc/doas.conf" "/etc/sysctl.conf"; do
if [ -f $configfile ]; then
grep -q "pickles" "${configfile}" && \
exception "Pickles error. Please read the config file you just installed." || \
echo "Pickles are fine. Thanks for reading."
else
exception "Did you read the readme? Install the doas.conf and sysctl.conf and read them over."
fi
done
Early bootstrap functions
# Clean unnecessary files
function clean {
log "Removing Cruft..."
rex remove_default_cruft
}
# Ensure Lisp environment is set up
function ensure_lisp {
log "Quicklisp Setup"
if [[ "${quicklisp}" == "on" ]]; then
log "quicklisp set on."
log "Installing quicklisp and related deps..."
if [ -d $HOME/.quicklisp ]; then
log "Quicklisp install dir found... removing that..."
printf "Press any key..."
read
rm -Rvf $HOME/.quicklisp
fi
doas pkg_add -m sbcl rlwrap || exception "Could not install sbcl or rlwrap"
ftp -o /tmp/quicklisp.lisp "https://beta.quicklisp.org/quicklisp.lisp" || exception "Failed to download quicklisp.lisp"
ftp -o /tmp/quicklisp-setup.lisp "$CODEBERG/izder456/dotfiles/raw//branch/main/quicklisp-setup.lisp" || exception "Failed to download quicklisp-setup.lisp"
sbcl --load /tmp/quicklisp.lisp --script /tmp/quicklisp-setup.lisp || exception "Failed to run quicklisp setup"
elif [[ "${quicklisp}" == "off" ]]; then
log "quicklisp set off."
log "Skipping..."
else
exception "Invalid quicklisp setting. how did we get here?"
fi
}
# Install port dependencies
function ports_deps {
log "Installing port dependencies..."
if [[ "${pkglite}" == "off" ]]; then
log "pkglite set off."
log "Installing full package set."
doas pkg_add -m -l ~/.pkglist || exception "Failed to install port dependencies"
elif [[ "${pkglite}" == "on" ]]; then
log "pkglite set on."
log "Installing lite package set."
doas pkg_add -m -l ~/.pkglistlite || exeption "Failed to install port dependencies"
else
exception "Invalid pkglite setting. how did we get here?"
fi
}
# Install cargo dependencies
function cargo_deps {
if [[ "${rustdeps}" == "on" ]]; then
log "rustdeps set on."
log "Installing cargo dependencies."
doas pkg_add rust || exception "Failed to install Rust"
xargs cargo install < ~/.cargolist || exception "Failed to install rust dependencies"
elif [[ "${rustdeps}" == "off" ]]; then
log "rustdeps set off."
log "Skipping..."
else
exception "Invalid rustdep setting. how did we get here?"
fi
}
function setup_gtkicons {
log "Setting up gtk themes..."
rex configure_gtk
log "Setting up icon themes..."
rex configure_icons
}
# Clone or update dotfiles repository and run setup scripts
function config_install {
log "Cloning/Installing Dotfiles..."
if [ -d "$USERHOME/.dotfiles" ]; then
cd $USERHOME/.dotfiles || exception "Failed to change directory to .dotfiles"
GIT_TRACE=1 git pull --recurse-submodules --depth 1 --verbose || exception "Failed to pull dotfiles"
else
GIT_TRACE=1 git clone --recurse-submodules --depth 1 --single-branch --verbose $CODEBERG/Izder456/dotfiles.git $USERHOME/.dotfiles || exception "Failed to clone dotfiles"
fi
if [[ "${gtkicons}" == "on" ]]; then
log "gtkicons set on"
setup_gtkicons
elif [[ "${gtkicons}" == "off" ]]; then
log "gtkicons set off"
log "Skipping..."
else
exception "Invalid gtkicons setting. how did we get here?"
fi
$USERHOME/.dotfiles/dfm/dfm install
}
# Setup ZSH shell
function setup_shell {
log "Setting up FiZSH..."
rex configure_default_shell
rex compile_afetch
}
# Setup URxvt
function setup_urxvt {
log "Setting up urxvt..."
rex configure_urxvt
}
# Setup background images
function setup_backgrounds {
log "Installing Backgrounds..."
rex install_backgrounds
}
# Setup Emacs
function setup_emacs {
log "Setting up Emacs..."
rex configure_emacs
}
# Setup Enhanced Motif WM
function setup_emwm {
log "Setting up Enhanced Motif WM..."
rex configure_emwm
}
# Setup StumpWM
function setup_stumpwm {
ensure_lisp
log "Setting up StumpWM..."
rex configure_stumpwm
}
# Miscellaneous setup tasks
function setup_misc {
setup_shell
log "Miscellaneous setup..."
rex compile_shuf
rex compile_slock
rex compile_st
rex compile_surf
rex configure_apmd
rex install_backgrounds
rex update_xdg
}
# Setup XenoDM
function setup_xenodm {
log "Setting up XenoDM..."
rex configure_xenodm
}
# Check for internet connection
function is_internet_up {
log "Checking internet connection..."
nc -zw1 OpenBSD.org 443 || exception "You need internet for this dumdum!"
log "Internet connection is up!"
}
# Ensure necessary tools are installed
function ensure_needed {
log "Installing necessary tools: git, git-lfs and p5-Rex..."
doas pkg_add -m p5-Rex git git-lfs || exception "Failed to install git, git-lfs and p5-Rex"
log "Setting up git-lfs..."
git lfs install
ftp -o $USERHOME/Rexfile $CODEBERG/Izder456/dotfiles/raw/branch/main/Rexfile || exception "Failed to download Rexfile"
}
# Ensure all prerequisites
function do_ensure {
echo "Log file is at ${LOG_FILE}"
echo "Refer to it for debugging"
printf "Press any key..."
read
is_internet_up
ensure_needed
}
do_ensure
Handling toggles
# Default states
pkglite="off" # set full package set by default
gtkicons="on" # set downloading gtk themes and icons enabled by default
rustdeps="on" # set rust/cargo deps by default
quicklisp="on" # install/set up quicklisp and dependencies
# Function to confirm toggles
function confirm_toggles {
log ''
log 'Current toggles:'
log "pkglite: $pkglite"
log "gtkicons: $gtkicons"
log "rustdeps: $rustdeps"
log "quicklisp: $quicklisp"
log ''
printf "Are these settings correct? (y/N) "
}
# Function to prompt for toggles
function toggle_prompt {
log ''
log 'Fine tuned toggles:'
log '---------------------------------------------------------'
log ' Key: '
log ' - pkglite means: "lite packages" '
log ' - gtkicons means: "gtk themes and icons" '
log ' - rustdeps means: "rust deps on supported archs" '
log ' - quicklisp means: "common lisp deps needed for stumpwm"'
log '---------------------------------------------------------'
while true; do
confirm_toggles # Confirm toggles with the end user.
read confirmation
if [[ "$confirmation" == "y" ]]; then
break
else
# Loop through each variable and prompt user to set its value directly
for toggle in pkglite gtkicons rustdeps quicklisp; do
eval current_value=\$$toggle
# Adjust capitalization of the prompt dynamically
if [ "$current_value" = "on" ]; then
default_prompt="ON/off"
else
default_prompt="on/OFF"
fi
while true; do
# Prompt user
printf "Turn $toggle on or off? ($default_prompt): "
read answer
# Handle user input
case "$answer" in
"on"|"ON"|"y"|"Y")
eval "$toggle=on"
log "$toggle set to on." 0
break
;;
"off"|"OFF"|"n"|"N")
eval "$toggle=off"
log "$toggle set to off." 0
break
;;
"")
# Keep current value if no input is given
log "Keeping $toggle as $current_value." 0
break
;;
,*)
log "Invalid input. Please enter 'on' or 'off', or press Enter to keep the current value." 0
;;
esac
done
done
fi
done
}
Menu loop
This is the menuing system I hacked together. All it does is run rex tasks we defined in the functions we wrote earlier. If you do choose to not grab gtk/icons, the full package list, or rust deps, know that you will only get a barebones install. Coming back later to get the rest is perfectly a.o.k.
# Display menu and handle user input
function menu {
while true; do
clear
echo 'Srcerizder Dotfiles Setup'
echo 'Options:'
echo '---------------------------------------'
echo '0) Packages (lite) 1) Packages (all)'
echo '2) StumpWM 3) Emwm'
echo '4) Emacs 5) XenoDM'
echo '6) Rust Packages 7) GTK/Icons'
echo '8) Misc. Config 9) Misc. Software'
echo
echo 'Other Options:'
echo '----------------'
echo 'a) All (recommended)'
echo 'r) Reload Menu'
echo 'q) Quit'
echo
printf "Enter your selection: "
read selection # Move the input prompt to the same line
[ -z $selection ] && selection="r"
# reset these vars incase the user selected otherwise and it failed.
pkglite="off" # set full package set by default
gtkicons="on" # set downloading gtk themes and icons enabled by default
rustdeps="on" # set rust/cargo deps by default
quicklisp="on" # install/set up quicklisp and dependencies
case $selection in
0)
echo "Selected Lite Package List Install..."; sleep $SLEEPTIME; pkglite="on"; ports_deps;
;;
1)
echo "Selected Full Package List Install..."; sleep $SLEEPTIME; pkglite="off"; ports_deps
;;
2)
echo "Selected StumpWM Config..."; sleep $SLEEPTIME; quicklisp="on"; setup_stupmwm;
;;
3)
echo "Selected Emwm Config..."; sleep $SLEEPTIME; setup_emwm;
;;
4)
echo "Selected Emacs Config..."; sleep $SLEEPTIME; setup_emacs;
;;
5)
echo "Selected XenoDM Config..."; sleep $SLEEPTIME; setup_xenodm;
;;
6)
echo "Selected Rust Deps..."; sleep $SLEEPTIME; cargo_deps;
;;
7)
echo "Selected GTK Theme/Icon Theme Setup..."; sleep $SLEEPTIME; setup_gtkicon;
;;
8)
echo "Selected Misc. Configs..."; sleep $SLEEPTIME; config_install;
;;
9)
echo "Selected Misc. Software..."; sleep $SLEEPTIME; setup_misc;
;;
"a")
echo "Running All...";
toggle_prompt; # let the use toggle what they wish
sleep $SLEEPTIME; clean;
config_install; ports_deps; cargo_deps;
setup_emwm; setup_stumpwm; setup_urxvt; setup_emacs; setup_xenodm;
setup_misc;
;;
"r")
continue;
;;
"q")
echo "";
exit;
;;
,*)
echo "Invalid selection";
sleep $SLEEPTIME;
;;
esac
done
}
menu
Rexfile
Boilerplate
use 5.36.0;
use Rex -feature => ['1.4'];
# No Magic
my $USERHOME = "$ENV{HOME}";
my $CODEBERG = "https://codeberg.org";
my $GITHUB = "https://github.com";
# Set PATH explicitly
$ENV{'PATH'} = '/bin:/usr/bin:/sbin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:$HOME/bin';
# Generic function to clone or update a Git repository
sub sync_repo {
my ($repo, $dest) = @_;
if (is_dir($dest)) {
say "Updating $dest...";
run "git -C $dest pull";
} else {
say "Cloning $repo into $dest...";
run "git clone --depth 1 $repo $dest";
}
}
# Generic function to build and install from source
sub build_and_install {
my ($repo, $dest, $commands) = @_;
sync_repo($repo, $dest);
chdir $dest;
for my $cmd (@$commands) {
run $cmd;
}
};
# Generic function to create symlinks
sub create_symlink {
my ($source, $dest) = @_;
run "ln -sf $source $dest";
};
Remove-Cruft
I don't need some of these defaults
# Remove default files task
task 'remove_default_cruft', sub {
for my $file (qw(.cshrc .login .mailrc .profile .Xdefaults .cvsrc)) {
my $filepath = "$USERHOME/$file";
unlink $filepath if -e $filepath;
}
say "Setting home directory permissions...";
run "chmod 0700 $USERHOME";
};
Urxvt-Setup
This is my fallback terminal
# Setup urxvt extensions
task 'configure_urxvt', sub {
my $urxvtdir = "$USERHOME/.urxvt/ext";
my %perls = (
"resize-font" => "$GITHUB/simmel/urxvt-resize-font/raw/master/resize-font",
"clipboard" => "$GITHUB/xyb3rt/urxvt-perls/raw/master/deprecated/clipboard"
);
mkdir $urxvtdir unless is_dir($urxvtdir);
for my $key (keys %perls) {
my $dest = "$urxvtdir/$key";
run "ftp -o $dest $perls{$key}";
}
};
ZSH-Setup
# Setup ZSH plugins
task 'configure_default_shell', sub {
my $zshdir = "$USERHOME/.zshrc.d";
mkdir $zshdir unless is_dir($zshdir);
my %plugins = (
"openbsd" => "$GITHUB/sizeofvoid/openbsd-zsh-completions.git",
"completions" => "$GITHUB/zsh-users/zsh-completions.git",
"fzf-comp" => "$GITHUB/lincheney/fzf-tab-completion.git",
"suggest" => "$GITHUB/zsh-users/zsh-autosuggestions.git",
"substring" => "$GITHUB/zsh-users/zsh-history-substring-search.git",
"fzf" => "$GITHUB/Aloxaf/fzf-tab.git",
"fsh" => "$GITHUB/zdharma-continuum/fast-syntax-highlighting.git",
"autopair" => "$GITHUB/hlissner/zsh-autopair",
"defer" => "$GITHUB/romkatv/zsh-defer",
"vim-mode" => "$GITHUB/softmoth/zsh-vim-mode"
);
for my $key (keys %plugins) {
sync_repo($plugins{$key}, "$zshdir/$key");
}
run "chsh -s /usr/local/bin/zsh";
};
Icons and GTK stuffs
# GTK Themes
task 'configure_gtk', sub {
my $tmp_dir = "/tmp/gruvbox-plus-gtk";
sync_repo("$GITHUB/SylEleuth/gruvbox-plus-gtk.git", $tmp_dir);
run "mkdir -p $USERHOME/.dotfiles/.themes";
run "cp -R $tmp_dir/* $USERHOME/.dotfiles/.themes/";
run "rm -rf $tmp_dir";
run "fc-cache -fv";
};
# GTK Icons
task 'configure_icons', sub {
my $tmp_dir = "/tmp/gruvbox-round-icons";
sync_repo("$GITHUB/Fausto-Korpsvart/Gruvbox-GTK-Theme.git", $tmp_dir);
run "mkdir -p $USERHOME/.dotfiles/.icons";
run "cp -R $tmp_dir/icons/* $USERHOME/.dotfiles/.icons/";
run "rm -rf $tmp_dir";
};
Emacs-Setup
I use Emacs, btw
# Emacs setup
task 'configure_emacs', sub {
create_symlink("$USERHOME/.dotfiles/Emacs-Config", "$USERHOME/.emacs.d");
};
StumpWM-Setup
Yeah, this weird WM...
# StumpWM setup
task 'configure_stumpwm', sub {
create_symlink("$USERHOME/.dotfiles/StumpWM-Config", "$USERHOME/.stumpwm.d");
};
Enhanced Motif WM Setup
Yeah, I sometimes float things
# Enhanced Motif WM setup
task 'configure_emwm', sub {
create_symlink("$USERHOME/.dotfiles/Emwm-Config/.emwmrc", "$USERHOME/.emwmrc");
create_symlink("$USERHOME/.dotfiles/Emwm-Config/.toolboxrc", "$USERHOME/.toolboxrc");
run "mkdir -p $USERHOME/.xresources.d";
create_symlink("$USERHOME/.dotfiles/Emwm-Config/.xresources", "$USERHOME/.xresources.d/emwm");
};
XenoDM/Background-Setup
Because XDM wasn't cutting it...
# XenoDM setup
task 'install_backgrounds', sub {
run "doas mkdir -p /usr/local/share/backgrounds";
run "doas cp -R $USERHOME/.dotfiles/backgrounds/* /usr/local/share/backgrounds";
};
task 'configure_xenodm', sub {
run "chmod +x $USERHOME/.dotfiles/XenoDM-Config/Xsetup_* $USERHOME/.dotfiles/XenoDM-Config/GiveConsole";
run "doas cp -R $USERHOME/.dotfiles/XenoDM-Config/* /etc/X11/xenodm/";
};
APMD_AutoHook-Lock
Setup Laptop Slock shell-close autohook
# APMD setup
task 'configure_apmd', sub {
run "doas mkdir -p /etc/apm";
run "doas cp -R $USERHOME/.dotfiles/APM-Config/* /etc/apm/";
};
Extra-Packages
Extra stuff thats not in ports, cargo or base
# Compile and install various packages
task 'compile_shuf', sub {
build_and_install("$GITHUB/ibara/shuf.git", "$USERHOME/.shuf", ["./configure", "make", "doas make install"]);
};
task 'compile_slock', sub {
build_and_install("$CODEBERG/Izder456/slock.git", "$USERHOME/.slock", ["make", "doas make install"]);
};
task 'compile_surf', sub {
build_and_install("$CODEBERG/Izder456/surf.git", "$USERHOME/.surf-src", ["make", "doas make install"]);
};
task 'compile_st', sub {
build_and_install("$CODEBERG/Izder456/st.git", "$USERHOME/.st", ["make", "doas make install"]);
};
task 'compile_afetch', sub {
build_and_install("$GITHUB/13-CF/afetch.git", "$USERHOME/.afetch", ["make", "doas make install"]);
};
Xdg
Setup Homedir Paths & Enable dbus
# XDG setup
task 'update_xdg', sub {
run "xdg-user-dirs-update";
run "mkdir -p $USERHOME/Projects";
run "doas gdk-pixbuf-query-loaders --update-cache";
run "doas rcctl enable messagebus";
};
Ports
Set up my ports config
# Ports configuration
my $ports_dir = "/usr/ports";
my $wip_dir = "$ports_dir/openbsd-wip";
my $myports_dir = "$ports_dir/mystuff";
my $mk_conf_source = "$USERHOME/.dotfiles/mk.conf";
my $mk_conf_dest = "/etc/mk.conf";
my $group = "wsrc";
task 'sync_ports', sub {
for my $repo (
{ url => "$GITHUB/openbsd/ports", dest => $ports_dir },
{ url => "$GITHUB/jasperla/openbsd-wip", dest => $wip_dir },
{ url => "$CODEBERG/izder456/myports", dest => $myports_dir }
) {
if ( is_dir( $repo->{dest} ) ) {
say "Updating $repo->{dest}...";
run "doas git -C $repo->{dest} pull";
} else {
say "Cloning $repo->{url} into $repo->{dest}...";
run "doas git clone $repo->{url} $repo->{dest}";
}
}
};
task "reset_ports", sub {
if ( is_dir($ports_dir) ) {
say "Removing $ports_dir...";
run "doas rm -rf $ports_dir";
}
Rex::TaskList->run("sync_ports"); # Re-run cloning task
};
task 'fix_port_permissions', sub {
my $ports_dir = "/usr/ports";
my $group = "wsrc";
my $mk_conf_source = "$USERHOME/.dotfiles/mk.conf";
my $mk_conf_dest = "/etc/mk.conf";
my $user = getpwuid($<);
say "Adding user $user to group $group...";
run "doas usermod -G $group $user";
say "Setting group $group on $ports_dir...";
run "doas chgrp -R $group $ports_dir";
say "Setting group rwx on $ports_dir...";
run "doas chmod -R g+rwx $ports_dir";
say "Running make fix-permissions...";
run "cd $ports_dir && doas make fix-permissions";
say "Installing mk.conf...";
if (is_file($mk_conf_source)) {
run "doas cp $mk_conf_source $mk_conf_dest && doas chmod 644 $mk_conf_dest";
} else {
say "Warning: $mk_conf_source not found!";
}
};
Configs
.Xsession/.Xresources/.Xprofile
The settings for X session, resources, and profile. The .xsession file also starts a window manager selector program using xmessage
Xresources
.xresources
!!
! Includes
!!
#include ".xresources.d/colors"
#include ".xresources.d/apps"
!!
! XWindow Stuffs
!!
,*imLocale: en_US.UTF-8
,*lookAndFeel: motif
,*shapeStyle: Rectangle
!!
! Font Rendering Stuffs
!!
Xft.dpi: 96
Xft.rgba: rgb
Xft.antialias: true
Xft.autohint: false
Xft.hintstyle: hintfull
Xft.lcdfilter: lcddefault
,*faceName: fixed
,*faceSize: 14
Colors
,*background: #282828
! regular contrast: *background: #282828
! soft contrast: *background: #32302f
! high contrast: *background: #1d2021
,*foreground: #ebdbb2
! regular contrast: *foreground: #ebdbb2
! soft-contrast: *foreground: #f2e5bc
! high contrast: *foreground #f9f5d7
! Black + DarkGrey
,*color0: #282828
,*color8: #928374
! DarkRed + Red
,*color1: #cc241d
,*color9: #fb4934
! DarkGreen + Green
,*color2: #98971a
,*color10: #b8bb26
! DarkYellow + Yellow
,*color3: #d79921
,*color11: #fabd2f
! DarkBlue + Blue
,*color4: #458588
,*color12: #83a598
! DarkMagenta + Magenta
,*color5: #b16286
,*color13: #d3869b
! DarkCyan + Cyan
,*color6: #689d6a
,*color14: #8ec07c
! LightGrey + White
,*color7: #a89984
,*color15: #ebdbb2
Apps
!!
! XMessage
!!
xmessage*background: #1d2021
xmessage*foreground: #fbf1c7
xmessage.borderWidth: 1
xmessage*borderColor: #ebdbb2
xmessage*timeout: 0
xmessage*printValue: false
xmessage*font: -misc-fixed-*-*-*-*-15-*-*-*-*-*-*-*
xmessage*ShapeStyle: Rectangle
xmessage*Buttons: motif
xmessage*Command.highlightThickness: 1
xmessage*Command.borderWidth: 1
xmessage*Command.shapeStyle: Rectangle
!!
! SSH-Askpass
!!
SshAskpass*background: #1d2021
SshAskpass*foreground: #fcf1c7
SshAskpass.borderWidth: 1
SshAskpass*borderColor: #ebdbb2
SshAskpass*font: -misc-fixed-*-*-*-*-15-*-*-*-*-*-*-*
SshAskpass*ShapeStyle: Rectangle
SshAskpass*internalBorder: 12
SshAskpass*Button.background: #1d2021
SshAskpass*Button.foreground: #fcf1c7
SshAskpass*Button.highlightThickness: 1
SshAskpass*Button.borderWidth: 1
SshAskpass*Button.borderColor: #ebdbb2
SshAskpass*Button.shapeStyle: Rectangle
SshAskpass*Text.background: #1d2021
SshAskpass*Text.foreground: #fcf1c7
SshAskpass*Text.borderColor: #ebdbb2
SshAskpass*Text.borderWidth: 1
SshAskpass*shadowThickness: 1
SshAskpass*highlightThickness: 1
!!
! XTerm
!!
,*allowSendEvents: true
xterm*scrollBar: false
xterm*faceName: fixed
xterm*faceSize: 14
xterm*renderFont: true
xterm*internalBorder: 12
xterm*letterSpace: 1
xterm*loginShell: true
xterm*savelines: 16384
!!
! Urxvt
!!
URxvt.font: xft:fixed:antialias=False:pixelsize=15,\
xft:Symbols Nerd Font Mono:pixelsize=15,\
xft:Symbola:pixelsize=15
URxvt.boldFont: xft:fixed:antialias=False:pixelsize=15,\
xft:Symbols Nerd Font Mono:pixelsize=15,\
xft:Symbola:bold:pixelsize=15
URxvt.italicFont: xft:fixed:antialias=False:pixelsize=15,\
xft:Symbols Nerd Font Mono:pixelsize=15,\
xft:Symbola:italic:pixelsize=15
URxvt.boldItalicFont: xft:fixed:antialias=False:pixelsize=15,\
xft:Symbols Nerd Font Mono:pixelsize=15,\
xft:Symbola:italic:bold:pixelsize=15
URxvt.perl-lib: ~/.urxvt/ext
URxvt.perl-ext-common: default,clipboard,resize-font
URxvt.copyCommand: xclip -i -selection clipboard
URxvt.pasteCommand: xclip -o -selection clipboard
URxvt.keysym.C-C: perl:clipboard:copy
URxvt.keysym.C-V: perl:clipboard:paste
URxvt.keysym.C-A-V: perl:clipboard:paste_escaped
URxvt.depth: 32
URxvt.fading: 5
URxvt.background: [95]#282828
URxvt.loginShell: true
URxvt.letterSpace: 0
URxvt.lineSpace: 0
URxvt.geometry: 240x120
URxvt.internalBorder: 14
URxvt.borderWidth: 0
URxvt.externalBorder: 0
URxvt.cursorBlink: true
URxvt.cursorUnderline: false
URxvt.urgentOnBell: true
URxvt.iso14755: false
URxvt.saveLines: 65535
URxvt.scrollBar: false
URxvt.keysym.C-minus: resize-font:smaller
URxvt.keysym.C-plus: resize-font:bigger
URxvt.keysym.C-equal: resize-font:equal
URxvt.keysym.Control-Up: 033円[1;5A
URxvt.keysym.Control-Down: 033円[1;5B
URxvt.keysym.Control-Right: 033円[1;5C
URxvt.keysym.Control-Left: 033円[1;5D
!!
! XClock Stuffs
!!
XClock*Background: #32302f
XClock*Foreground: #ebdbb2
.xsession
PS: You can optionally put an ~/.autostart script with a bunch of programs in it. It will be ran with /bin/sh so you don't need a she-bang or anything. For the case of stumpwm, you may want to change the defaults for the toggles, such at dunst for example, if you so choose to run dunst on startup. By default, we wait 10 seconds before running it.
#!/bin/ksh
# Load in .zshrc environment
. ~/.zshrc
# Define variables at the top for easy access
readonly XMESG_WIDTH=512
readonly XMESG_HEIGHT=128
# Set environment up, .xprofile isn't respected
# Set Default LOCALE
export LC_CTYPE="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
export LANG="en_US.UTF-8"
# Enable HWACCEL for Firefox
export MOZ_ACCELERATED=1
export MOZ_WEBRENDER=1
# set qt apps to use kvantum widgets if avail
export QT_STYLE_OVERRIDE=kvantum
# make sdl mouse cursor lag go away
export SDL_VIDEO_X11_DGAMOUSE=0
# set XDG stuff
function xdg_runtime {
export XDG_RUNTIME_DIR=/tmp/run/$(id -u)
export XDG_CONFIG_HOME=$HOME/.config
export XDG_CACHE_HOME=$HOME/.cache
export XDG_DATA_DIR=$HOME/.local/share
export XDG_STATE_HOME=$HOME/.local/state
[ -n "${selected_wm}" ] && export XDG_CURRENT_DESKTOP="${selected_wm}"
if [ ! -d $XDG_RUNTIME_DIR ]; then
mkdir -m 700 -p $XDG_RUNTIME_DIR
fi
}
function gpg_agent {
eval $(gpg-agent --daemon \
--write-env-file $HOME/.gpg-agent-info)
if [ -f $HOME/.gpg-agent-info ]; then
. $HOME/.gpg-agent-info
export GPG_AGENT_INFO
export SSH_AUTH_SOCK
fi
}
# Function to get screen dimensions
function get_screen_dimension {
typeset dimension=$(xrandr --current | grep '*' | uniq | awk '{print 1ドル}' | head -n1)
case 1ドル in
0) echo "${dimension%x*}" ;;
1) echo "${dimension#*x}" ;;
,*) echo "Invalid argument. Use 0 for width or 1 for height." ;;
esac
}
# Function to load environment
function load_environment {
set -A files "$@"
for file in "${files[@]}"; do
[ -f "$file" ] && . "$file"
done
}
# Function to load resources
function load_resources {
set -A resources "$@"
for resource in "${resources[@]}"; do
[ -f "$resource" ] && xrdb -merge "$resource"
done
}
# Function to manage autostarts
function manage_autostarts {
for process in "$@"; do
process_name="${process% *}"
if pgrep "$process_name" > /dev/null; then
pkill "$process_name"
fi
eval "$process" &
done
}
# Sleep 1s, then play random wav-format startup sound from directory passed as argument
function play_startup_sound {
if command -v aucat &>/dev/null; then
sleep 1
aucat -i $(find 1ドル -type f -name '*.wav' | sort -R | head -n1)
fi
}
# set default volume of input and output devices. this is useful for audio calls so people don't get ear-raped with your mic feedback on laptops
function set_default_volume {
sndioctl input.level=0.45
sndioctl output.level=1.00
}
# Function to select a window manager
function select_wm {
# WM Session Prompt
typeset xwidth=$(get_screen_dimension 0)
typeset xheight=$(get_screen_dimension 1)
typeset xmesg_xpos=$((($xwidth - $XMESG_WIDTH) / 2))
typeset xmesg_yoffset=$((($xheight - $XMESG_HEIGHT) / 2))
xmessage "Please Choose a Session to load" \
-buttons "StumpWM[]":1,"EMWM[]":2 \
-default "StumpWM[]" \
-geometry ${XMESG_WIDTH}x${XMESG_HEIGHT}+${xmesg_xpos}-${xmesg_yoffset}
typeset choice=$?
case ${choice} in
1) echo "stumpwm" ;;
2) echo "emwm" ;;
,*) echo "stumpwm" ;;
esac
}
# Load in environment & resources
load_environment /etc/xprofile ~/.xprofile
load_resources ~/.Xresources ~/.xresources.d/emwm
# Select Window Manager
selected_wm=$(select_wm)
# Launch the selected window manager
case ${selected_wm} in
stumpwm)
wm=$(command -v stumpwm)
wm_args=""
;;
emwm)
wm=$(command -v xmsm)
wm_args=""
;;
esac
# No .core files
ulimit -Sc 0
# Cleanup
trap 'pkill -U $(id -u) -P $$' EXIT
# Set XDG Stuffs
xdg_runtime
# Set GnuPG Stuffs
gpg_agent
# ^ these need to be here so autostarts can work
# Autostarts
manage_autostarts "picom -b" \
"emacs --daemon" \
"nxbelld -t 150 -v100 -d200 -f ~/.local/alert/Funk.wav -b " \
"feh --bg-fill --randomize /usr/local/share/backgrounds" \
"xidle -delay 5 -nw -program /usr/local/bin/slock -timeout 1800" \
"dunst --startup_notification true"
# Check if ~/.autostart exists, and if so, run it!
test -f ~/.autostart && (sleep 10 && sh ~/.autostart) &
# set the default volume
set_default_volume
# Play the startup sound in a subshell
(play_startup_sound ~/.local/sfx/) &
# Launch the window manager
if ! exec dbus-run-session "${wm}" ${wm_args}; then
echo "Failed to launch window manager ${wm}."
exit 1
fi
exit 0
Misc Configs
.zshrc
#!/usr/bin/env zsh
##
# Check if TTY if on OpenBSD
##
if [[ "$(uname)" == "OpenBSD" ]]; then
if [[ "$(tty)" == "/dev/ttyC"* ]]; then
export TERM=wsvt25
fi
fi
##
# ENV VARS
##
export PAGER=less
export MANPAGER=less
export LC_CTYPE="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
if command -v aee &> /dev/null; then
export EDITOR="aee"
export VISUAL="aee"
elif command -v ee &> /dev/null; then
export EDITOR="ee"
export VISUAL="ee"
elif command -v nvi &> /dev/null; then
export EDITOR="nvi"
export VISUAL="nvi"
elif command -v vi &> /dev/null; then
export EDITOR="vi"
export VISUAL="vi"
fi
##
# export $PATH
##
export PATH=/usr/games:$HOME/.cargo/bin:$HOME/.local/bin:$HOME/go/bin:$PATH
if [[ "$(uname)" == "OpenBSD" ]]; then
export PATH=/usr/ports/infrastructure/bin:$PATH
elif [[ "$(uname)" == "Linux" ]]; then
export PATH=/usr/sbin:/sbin:$PATH
fi
##
# Prompt
##
if [[ "$(uname)" == "OpenBSD" ]]; then
PROMPT='%B%F{yellow}%n%f%b %B%F{gray}[%~]%f%b %F{white}%m%f
--> '
elif [[ "$(uname)" == "FreeBSD" ]]; then
PROMPT='%B%F{red}%n%f%b %B%F{gray}[%~]%f%b %F{white}%m%f
--> '
else
PROMPT='%B%F{blue}%n%f%b %B%F{gray}[%~]%f%b %F{white}%m%f
--> '
fi
##
# Lazy Loading
##
source ~/.zshrc.d/defer/zsh-defer.plugin.zsh
##
# Autoload zmv
##
zsh-defer autoload -Uz zmv
##
# Setup Completions
##
zsh-defer autoload -U compinit
zsh-defer compinit
zsh-defer autoload -U bashcompinit
zsh-defer bashcompinit
# We don't need to load OpenBSD completions on non-OpenBSD Systems
if [[ "$(uname)" == "OpenBSD" ]]; then
fpath=($HOME/.zshrc.d/openbsd/completions $HOME/.zshrc.d/completions/src $fpath)
else
fpath=($HOME/.zshrc.d/completions/src $fpath)
fi
setopt MENU_COMPLETE
setopt AUTO_LIST
setopt COMPLETE_IN_WORD
zsh-defer eval "$(register-python-argcomplete pipx)"
##
# Java Stuff
##
export PATH=$PATH:/usr/local/jdk-17/bin
export JAVA_HOME=/usr/local/jdk-17/
##
# Elixir/Erlang Stuff
##
export PATH=$PATH:/usr/local/lib/erlang27/bin
##
# Go Stuff
##
export GOPATH=$HOME/.go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
##
# Autopair
##
zsh-defer source ~/.zshrc.d/autopair/autopair.zsh
zsh-defer autopair-init
##
# Suggestions
##
zsh-defer source ~/.zshrc.d/suggest/zsh-autosuggestions.plugin.zsh
##
# Syntax Highlight
##
zsh-defer source ~/.zshrc.d/fsh/fast-syntax-highlighting.plugin.zsh
##
# History substring search
##
zsh-defer source ~/.zshrc.d/substring/zsh-history-substring-search.plugin.zsh
HISTFILE="$HOME/.zshrc.d/.history"
HISTSIZE=100
SAVEHIST=100
##
# Vim-mode
##
MODE_INDICATOR=""
VIM_MODE_TRACK_KEYMAP=no
VIM_MODE_INITIAL_KEYMAP=viins
zsh-defer source ~/.zshrc.d/vim-mode/zsh-vim-mode.plugin.zsh
##
# FZF-Zsh
##
if command -v fzf &> /dev/null; then
zsh-defer source ~/.zshrc.d/fzf/fzf-tab.plugin.zsh
zsh-defer source ~/.zshrc.d/fzf-comp/zsh/fzf-zsh-completion.sh
fi
##
# Ruby Stuff
##
export GEM_HOME="$HOME/.gems"
export PATH=$PATH:$HOME/.gems/bin
##
# Alias for muscle memory
##
if command -v doas &> /dev/null; then
alias sudo="doas"
alias su="echo 'did you mean to run doas -s? '"
elif command -v sudo &> /dev/null; then
alias doas="sudo"
alias su="echo 'did you mean to run sudo -i? '"
fi
##
# Alias for CD
##
if command -v zoxide &> /dev/null; then
zsh-defer eval "$(zoxide init --cmd cd zsh)"
fi
##
# Alias for listing files
##
if command -v eza &> /dev/null; then
alias ls="eza --icons=never -Hh"
alias la="eza --icons=never -ah"
alias ll="eza --icons=never -lh"
alias lh="eza --icons=never -lAh"
alias tree="eza --icons=never -Th"
elif command -v colorls &> /dev/null; then
alias ls="colorls -G -Hh"
alias la="colorls -G -ah"
alias ll="colorls -G -lh"
alias lh="colorls -G -lAh"
elif command -v ls &> /dev/null; then
alias ls="ls -Hh"
alias la="ls -ah"
alias ll="ls -lh"
alias lh="ls -lAh"
fi
##
# Alias for parsing
##
if command -v bat &> /dev/null; then
export BAT_THEME=ansi
alias cat="bat -pp"
alias bat="bat -p"
fi
if command -v rg &> /dev/null; then
alias rgrep="rg"
fi
##
# Alias for editing
##
alias edit=$EDITOR
alias vedit=$VISUAL
##
# Alias for media
##
alias audio-dlp="yt-dlp -x --audio-quality 0 --audio-format vorbis \
--concurrent-fragments 5"
alias video-dlp="yt-dlp --write-subs --sub-format srt --remux-video mkv \
--embed-subs --concurrent-fragments 5"
alias tidal-dlp="tidal-dl -o /home/izder456/Music -q Master -r P1080 -l "
##
# Tere config
##
function tere {
local result=$(command tere "$@")
[ -n "$result" ] && cd -- "$result"
}
##
# Binds
##
bindkey "^[[1;5C" forward-word
bindkey "^[[1;5D" backward-word
bindkey "^[[1;5A" previous-history
bindkey "^[[1;5B" next-history
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
##
# the r/unixporn rite of passage
##
if command -v crfetch &> /dev/null; then
crfetch
fi
zsh-defer . $HOME/.shellrc.load
picom.conf
##
# Opacity
##
opacity-rule = [
"100:class_g = 'emacs' && focused",
"85:class_g = 'emacs' && !focused",
"100:class_g = 'st' && focused",
"85:class_g = 'st' && !focused",
"100:class_g = 'xterm' && focused",
"85:class_g = 'xterm' && !focused",
"100:class_g = 'URxvt' && focused",
"85:class_g = 'URxvt' && !focused",
];
##
# Wintypes
##
wintypes: {
normal = { blur-background = true; };
splash = { blur-background = false; };
};
##
# Fading
##
fading = true;
fade-in-step = 0.03;
fade-out-step = 0.03;
##
# Misc
##
unredir-if-possible = true;
##
# Shadows
##
shadow = false;
##
# QT-Apps Fixes For Blurs
##
blur-background-exclude = [
"(_NET_WM_WINDOW_TYPE@:a *= 'MENU' || _NET_WM_WINDOW_TYPE@:a *= 'COMBO')",
];
##
# Backend
##
backend = "xrender";
Dunstrc
[global]
monitor = 0
follow = keyboard
width = 300
height = 256
origin = bottom-right
offset = 0x0
scale = 0
notification_limit = 3
progress_bar = true
progress_bar_height = 10
progress_bar_frame_width = 1
progress_bar_min_width = 150
progress_bar_max_width = 300
progress_bar_corner_radius = 0
icon_corner_radius = 0
indicate_hidden = yes
transparency = 0
separator_height = 2
padding = 8
horizontal_padding = 10
text_icon_padding = 0
frame_width = 1
frame_color = "#d5c4a1"
gap_size = 2
separator_color = foreground
sort = yes
idle_threshold = 120
font = Spleen 8x16 12
line_height = 0
markup = full
format = "<b>%a</b>\n%s\n<i>%b</i> "
alignment = left
vertical_alignment = center
show_age_threshold = 60
ellipsize = middle
ignore_newline = no
stack_duplicates = true
hide_duplicate_count = false
show_indicators = yes
enable_recursive_icon_lookup = false
icon_theme = Gruvbox_Dark
icon_position = left
min_icon_size = 32
max_icon_size = 64
sticky_history = yes
history_length = 20
browser = /usr/bin/xdg-open
always_run_script = false
title = Dunst
class = Dunst
corner_radius = 0
ignore_dbusclose = true
force_xinerama = false
mouse_left_click = do_action, open_url
mouse_middle_click = context
mouse_right_click = close_current
[experimental]
per_monitor_dpi = false
[urgency_low]
background = "#282828"
foreground = "#928374"
timeout = 10
[urgency_normal]
background = "#282828"
foreground = "#ebdbb2"
timeout = 10
[urgency_critical]
background = "#282828"
foreground = "#fb4934"
frame_color = "#fabd2f"
timeout = 25
.exrc
for BSD Vi If you install or use editors/vim, these settings are incompatible, and will break things. If you want a good text mode editor that isn't BSD vi, use editors/neovim. I use editors/emacs for "real" editing, and BSD vi for everything else. Editor wars are stupid. Use what works for you.
" display current mode
set showmode
" show matching parens, brackets, etc
set showmatch
" display row/column info
set ruler
" autoindent tab = 2 space
set shiftwidth=2
" tab = 2 space
set tabstop=2
" display errors
set verbose
" enable horiz scroll
set leftright
" use extend regex
set extend
" case-less searching, unless uppercase
set iclower
" incremental searching
set searchincr
" print helpful messages (eg, 4 lines yanked)
set report=1
Sysctl.conf
The kernel parameters settings. Everything is commented, so uncomment as needed. Very hardware specific see
# Allow Kernel Memory Access
## Some programs, like sysutils/hw-probe, or sysutils/dmidecode need this.
## Be aware of security implications.
#kern.allowkmem=0 # default 0
# Enable Multithreading
## WARNING! Has security implications related to Spectre/Meltdown vulnerabilities.
## Keep this disabled, unless you have significant performance hits without it.
## OpenBSD has a tendancy to spin while waiting for kernel lock jobs to free on many CPU cores.
## Keeping SMT or "Hyperthreading" disabled helps minimize this from happening.
## Only applicable on architectures with SMT-support (e.g., amd64 or arm64).
#hw.smt=1 # default 0
##
# Perfpolicy (for laptops)
##
#hw.perfpolicy=high,auto
##
# Networking
##
# IP Forwarding
## Useful for if using vmd(8), or any other daemon that needs NAT.
#net.inet.ip.forwarding=1 # default 0
#net.inet6.ip6.forwarding=1 # default 0
##
# Memory
##
## Uncomment *ONLY* if your machine is slow. Could be helpful on older generation laptop CPUs
#kern.maxproc=8192 # default 1310
#kern.maxfiles=32768 # default 7030
#kern.maxthread=16384 # default 2620
#kern.shminfo.shmall=5242880 # default 8192
#kern.shminfo.shmmax=2147483647 # default 33554432
#kern.shminfo.shmmni=4096 # default 128
##
# Misc
##
# Video/Audio recording enable/disable
## Change these to 1 if you want microphone or webcam access globally.
## Although, its probably better to enable manually with sysctl(8) if paranoid
#kern.audio.record=0 # default 0
#kern.video.record=0 # default 0
pickles # remove this line if you read this whole file.
Doas.conf
(削除) this is totally overkill (削除ここまで)
fine now
# Change this top line to nopass instead of persist if you wanna avoid typing your password alot
permit keepenv persist :doas
# allow root to doas, cos well, it's root
permit keepenv nopass root
# these are useful for PORTS_PRIVSEP in mk.conf. see the bsd.port.mk(5)
permit keepenv nopass :operator as _pbuild
permit keepenv nopass :operator as _pfetch
pickles # remove this line if you read this whole file.
Ports
TODO: Testing on automation needed
mk.conf
This configures my ports/src build environment, it goes in /etc/mk.conf. This script does not install this, as ports aren't enabled OOTB on OpenBSD. You need to manually add this.
PORTSDIR_PATH=${PORTSDIR}:${PORTSDIR}/openbsd-wip:${PORTSDIR}/mystuff
SUDO=doas
PORTS_PRIVSEP=Yes
.include "/usr/ports/infrastructure/templates/mk.conf.template"
Networking & Tor virtualization using vmm(4)
FIXME: Update documentaion and add automation for this.
These go in /etc, use with caution. They are not installed by setup.ksh or Rexfile, you will need to grab these manually. I sometimes find that IMAP/SMTP, XMPP or even IRC ports are blocked on public networks. So, I have a really rudimentary workaround using Tor and obfs4 bridging. I have some sample configuration for virtualizing a tor daemon using vmm(4).
pf.conf
# See pf.conf(5) and /etc/examples/pf.conf
# Ports and networks
forwarded_ports = "{ 9050 }"
vmm_networks = "{ vport0:network }"
# Rules
set skip on lo
set fingerprints "/etc/pf.os"
set block-policy drop
set ruleset-optimization basic
set optimization normal
block in log on egress
pass out on egress
# Allow mdns
## Multicast
pass proto udp from any to 224.0.0.251 port mdns allow-opts
pass inet6 proto udp from any to ff02::fb port mdns allow-opts
## SSDP
pass proto udp from any to 239.255.255.250 port ssdp allow-opts
pass inet6 proto udp from any to { ff02::c, ff05::c, ff08::c } port ssdp allow-opts
# Allow ICMP
pass in on egress inet proto icmp all icmp-type { echoreq unreach }
# NAT for vmm(4)
match out log on egress from $vmm_networks to any nat-to (egress)
# Forward Tor
pass in log on egress inet proto tcp from any to 10.0.1.2 port 9050
hostname.veb0
add vport0
up
hostname.vport0
inet 10.0.1.1 255.255.255.0
up
vm.conf
Be sure to enable vmd(8) using rcctl(8)
switch "uplink" {
interface veb0
}
vm "tor" {
disable # change to "enable" if you want it to run on startup
memory 512M
cdrom "/path/to/openbsd/install76.iso"
disk "/path/to/vm/disk.qcow2"
interface { switch "uplink" }
owner youruser
}
relayd.conf
To relay port 9050 to the VM
relay "port 9050 relay" {
listen on 127.0.0.1 port 9050
forward to 10.0.1.2 port 9050
}
torrc
Put in /etc/tor/torrc on the Tor virtual machine. The non-HTTP/S bridges are commented, as I often found some networks flat-out block non-HTTP/S ports, which renders them useless.
# data
DataDirectory /var/tor
# run as daemon
RunAsDaemon 1
# Bridge
UseBridges 1
ClientTransportPlugin obfs4 exec /usr/local/bin/obfs4proxy
# Bridge lines
## HTTP/S
Bridge obfs4 192.95.36.142:443 CDF2E852BF539B82BD10E27E9115A31734E378C2 cert=qUVQ0srL1JI/vO6V6m/24anYXiJD3QP2HgzUKQtQ7GRqqUvs7P+tG43RtAqdhLOALP7DJQ iat-mode=1
Bridge obfs4 85.31.186.98:443 011F2599C0E9B27EE74B353155E244813763C3E5 cert=ayq0XzCwhpdysn5o0EyDUbmSOx3X/oTEbzDMvczHOdBJKlvIdHHLJGkZARtT4dcBFArPPg iat-mode=0
Bridge obfs4 85.31.186.26:443 91A6354697E6B02A386312F68D82CF86824D3606 cert=PBwr+S8JTVZo6MPdHnkTwXJPILWADLqfMGoVvhZClMq/Urndyd42BwX9YFJHZnBB3H0XCw iat-mode=0
Bridge obfs4 209.148.46.65:443 74FAD13168806246602538555B5521A0383A1875 cert=ssH+9rP8dG2NLDN2XuFw63hIO/9MNNinLmxQDpVa+7kTOa9/m+tGWT1SmSYpQ9uTBGa6Hw iat-mode=0
Bridge obfs4 51.222.13.177:80 5EDAC3B810E12B01F6FD8050D2FD3E277B289A08 cert=2uplIpLQ0q9+0qMFrK5pkaYRDOe460LL9WHBvatgkuRr/SL31wBOEupaMMJ6koRE6Ld0ew iat-mode=0
## non-HTTP/S
#Bridge obfs4 37.218.245.14:38224 D9A82D2F9C2F65A18407B1D2B764F130847F8B5D cert=bjRaMrr1BRiAW8IE9U5z27fQaYgOhX1UCmOpg2pFpoMvo6ZgQMzLsaTzzQNTlm7hNcb+Sg iat-mode=0
#Bridge obfs4 193.11.166.194:27015 2D82C2E354D531A68469ADF7F878FA6060C6BACA cert=4TLQPJrTSaDffMK7Nbao6LC7G9OW/NHkUwIdjLSS3KYf0Nv4/nQiiI8dY2TcsQx01NniOg iat-mode=0
#Bridge obfs4 193.11.166.194:27020 86AC7B8D430DAC4117E9F42C9EAED18133863AAF cert=0LDeJH4JzMDtkJJrFphJCiPqKx7loozKN7VNfuukMGfHO0Z8OGdzHVkhVAOfo1mUdv9cMg iat-mode=0
#Bridge obfs4 193.11.166.194:27025 1AE2C08904527FEA90C4C4F8C1083EA59FBC6FAF cert=ItvYZzW5tn6v3G4UnQa6Qz04Npro6e81AP70YujmK/KXwDFPTs3aHXcHp4n8Vt6w/bv8cA iat-mode=0
#Bridge obfs4 146.57.248.225:22 10A6CD36A537FCE513A322361547444B393989F0 cert=K1gDtDAIcUfeLqbstggjIw2rtgIKqdIhUlHp82XRqNSq/mtAjp1BIC9vHKJ2FAEpGssTPw iat-mode=0
#Bridge obfs4 45.145.95.6:27015 C5B7CD6946FF10C5B3E89691A7D3F2C122D2117C cert=TD7PbUO0/0k6xYHMPW3vJxICfkMZNdkRrb63Zhl5j9dW3iRGiCx0A7mPhe5T2EDzQ35+Zw iat-mode=0
# log
Log notice syslog
# user to run as
User _tor
# socks port
SOCKSPort 10.0.1.2:9050
# Libera
MapAddress palladium.libera.chat libera75jm6of4wxpxt4aynol3xjmbtxgfyjpu34ss4d7r7q2v5zrpyd.onion