add a new, experimental laptop configuration

This commit is contained in:
stupidcomputer 2024-11-26 15:37:54 -06:00
parent 7fa808dcca
commit 9712d03b24
24 changed files with 579 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "lappy/builds/dwm"]
path = lappy/builds/dwm
url = https://git.beepboop.systems/stupidcomputer/dwm

4
lappy/README.md Normal file
View File

@ -0,0 +1,4 @@
# lappy
within this directory are some experimental configurations for a laptop.
that is all.

8
lappy/builds/default.nix Normal file
View File

@ -0,0 +1,8 @@
{ config, pkgs, ... }:
{
environment.systemPackages = with pkgs; [
(callPackage ./utils.nix {})
(callPackage ./dwm.nix {})
];
}

1
lappy/builds/dmenu Submodule

@ -0,0 +1 @@
Subproject commit 86f0b5119eaa39943013d009967432ffd9d18365

1
lappy/builds/dwm Submodule

@ -0,0 +1 @@
Subproject commit f972a39b880bc2a631c3804b6c9b41faeb9a3898

22
lappy/builds/dwm.nix Normal file
View File

@ -0,0 +1,22 @@
{ stdenv
, lib
, pkgs
, libX11
, libXinerama
, libXft
}:
stdenv.mkDerivation rec {
pname = "dwm";
version = "6.5";
src = ./dwm;
buildInputs = [ libX11 libXinerama libXft ];
installPhase = ''
mkdir -p $out/bin
cp dwm $out/bin
cp dwm-setstatus $out/bin
'';
}

1
lappy/builds/st Submodule

@ -0,0 +1 @@
Subproject commit a0274bc20e11d8672bb2953fdd1d3010c0e708c5

25
lappy/builds/utils.nix Normal file
View File

@ -0,0 +1,25 @@
{ stdenv
, lib
, pkgs
# shell scripts stuff
, makeWrapper
}:
stdenv.mkDerivation rec {
pname = "utils";
version = "1.01";
src = ./utils;
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ ];
installPhase = ''
mkdir -p $out/bin
for i in $(ls $src/); do
cp $src/$i $out/bin
wrapProgram $out/bin/$i --prefix PATH : ${lib.makeBinPath [ ]}
done
'';
}

View File

@ -0,0 +1,34 @@
#!/bin/sh
# see original at
# https://github.com/cmus/cmus/blob/master/cmus-status-display
output()
{
printf "%s" "$*" > /dev/shm/status/cmus 2>&1
}
while test $# -ge 2
do
eval _$1='$2'
shift
shift
done
if test "$_status" = "playing"; then _status=">"; else _status="="; fi
if test -n "$_file"
then
h=$(($_duration / 3600))
m=$(($_duration % 3600))
duration=""
test $h -gt 0 && dur="$h:"
duration="$dur$(printf '%02d:%02d' $(($m / 60)) $(($m % 60)))"
output "${_status}$_artist($_album)-$_title"
elif test -n "$_url"
then
output "${_status}$_url-$_title"
else
output "${_status}"
fi

30
lappy/builds/utils/paperless Executable file
View File

@ -0,0 +1,30 @@
#!/bin/sh
case "$1" in
"start")
printf "[] starting paperless\n"
systemctl start redis-paperless paperless-scheduler
;;
"stop")
printf "[] stopping paperless\n"
systemctl stop paperless-web paperless-task-queue paperless-scheduler paperless-consumer redis-paperless
;;
"query")
exit $([ $(systemctl | grep -c paperless) -gt 0 ])
;;
*)
cat <<EOF
paperless -- start and stop the paperless web service easily
paperless start
start the paperless systemd services if they haven't already
been started
paperless stop
stop the paperless systemd services
paperless query
return 0 if paperless is running, 1 if not
EOF
;;
esac

3
lappy/builds/utils/rebuild Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
cd $HOME/dots/lappy; sudo nixos-rebuild switch -I nixos-config=./configuration.nix

31
lappy/builds/utils/status Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
# try to load the sleep builtin dynamically, because otherwise there's
# a *lot* of overhead (in terms of PID count)
if [[ $(</proc/cmdline) = *"nixos-system"* ]]; then
enable -f /run/current-system/sw/lib/bash/sleep sleep
else
enable -f /lib/bash/sleep sleep
fi
get_cmus_info () {
if [ /dev/shm/status/cmus -nt /dev/shm/status/modified ]; then
cmus_status=$(</dev/shm/status/cmus)
touch /dev/shm/status/modified
fi
}
while true; do
# use /dev/shm to minimize the amount of i/o on disk
if [ ! -d /dev/shm/status ]; then
mkdir -p /dev/shm/status
touch /dev/shm/status/modified
fi
battery=$(</sys/class/power_supply/BAT0/capacity)
printf -v date '%(%H)T:%(%M)T' -1
get_cmus_info
printf "%s/%s/%s\n" "$cmus_status" "$date" "$battery"
sleep 1
done | dwm-setstatus

38
lappy/config/bash/bashrc Normal file
View File

@ -0,0 +1,38 @@
#!/bin/bash
# if not interactive, don't do anything
[ -z "$PS1" ] && return
# some housekeeping
alias ls="ls --color=auto --group-directories-first"
function cd() {
builtin cd "$@" && ls --color=auto --group-directories-first
}
# history
HISTCONTROL=ignorespace:ignoredups:erasedups
HISTFILESIZE=9999999999
HISTSIZE=9999999999
# bash specific settings
set -o vi # vim mode
shopt -s autocd
shopt -s cmdhist
shopt -s histreedit
shopt -s histappend
shopt -s histverify
PS1="\w\$ "
if [ -n "$IN_NIX_SHELL" ]; then
NIX_SHELL_PS1="nix:"
fi
if [ "$USER" = "root" ]; then
USER_PREFIX="\[\033[41m\]root:\[\033[0;0m\]"
elif [ "$USER" != "usr" ]; then
USER_PREFIX="$USER:"
fi
PS1="$USER_PREFIX\[\033[36;1m\]${NIX_SHELL_PS1}arist:$PS1\[\033[0;0m\]"

47
lappy/config/bash/profile Normal file
View File

@ -0,0 +1,47 @@
#!/bin/bash
# paths and stuff
export PATH="$PATH:$HOME/.local/bin"
export MANPATH="$(manpath -q):$HOME/.local/share/man"
export EDITOR="nvim"
mkdir -p "$HOME/.local/bin" "$HOME/.share/man"
# program exports to keep the $HOME neat and tidy
# bash
export HISTFILE="$HOME/.config/bash/hist"
export HISTFILESIZE=3000
# python
export PYTHONSTARTUP="$HOME/.config/python/pythonrc.py"
# less
export LESSHISTFILE="-"
# gnupg
export GNUPGHOME="$HOME/.local/share/gnupg"
# XDG config
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_STATE_HOME="$HOME/.local/state"
# ls
export LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:';
export $(dbus-launch)
export GTK_THEME="earth"
# elinks
export ELINKS_CONFDIR="$HOME/.config/elinks"
# dbus configuration
export DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus"
# make nix-shell respect our PS1
export NIX_SHELL_PRESERVE_PROMPT=1
# source the bashrc(s)
[ -f $HOME/.config/bash/bashrc ] && . $HOME/.config/bash/bashrc
[ -f $HOME/.bashrc ] && . $HOME/.bashrc

3
lappy/config/cmus/rc Normal file
View File

@ -0,0 +1,3 @@
set show_current_bitrate=true
set pause_on_output_change=true
set status_display_program=cmus-status-update

45
lappy/config/default.nix Normal file
View File

@ -0,0 +1,45 @@
{ config, pkgs, ... }:
{
imports = [
./sx
];
# make the bashrc go in .config/bash, not the home directory
environment.etc = {
"profile.local" = {
text = "source /home/usr/.config/bash/profile";
};
"bashrc.local" = {
text = "source /home/usr/.config/bash/bashrc";
};
};
system.userActivationScripts = {
copyEssentialConfiguration = {
text = ''
mkdir -p /home/usr/.config
mkdir -p /home/usr/.config/nvim
${pkgs.coreutils}/bin/ln -sf /home/usr/dots/lappy/config/nvim/init.lua /home/usr/.config/nvim/init.lua
mkdir -p /home/usr/.config/sx
${pkgs.coreutils}/bin/ln -sf /home/usr/dots/lappy/config/sx/sxrc /home/usr/.config/sx/sxrc
mkdir -p /home/usr/.config/bash
${pkgs.coreutils}/bin/ln -sf /home/usr/dots/lappy/config/bash/bashrc /home/usr/.config/bash/bashrc
${pkgs.coreutils}/bin/ln -sf /home/usr/dots/lappy/config/bash/profile /home/usr/.config/bash/profile
mkdir -p /home/usr/.config/git
${pkgs.coreutils}/bin/ln -sf /home/usr/dots/lappy/config/git/config /home/usr/.config/git/config
mkdir -p /home/usr/.config/rbw
${pkgs.coreutils}/bin/ln -sf /home/usr/dots/lappy/config/rbw/config.json /home/usr/.config/rbw/config.json
mkdir -p /home/usr/.config/cmus
${pkgs.coreutils}/bin/ln -sf /home/usr/dots/lappy/config/cmus/rc /home/usr/.config/cmus/rc
'';
deps = [];
};
};
}

21
lappy/config/git/config Normal file
View File

@ -0,0 +1,21 @@
[user]
email = ryan@beepboop.systems
name = stupidcomputer
[credential "https://git.beepboop.systems"]
helper = !git-rbw-wrap gitea
[credential "https://github.com"]
helper = !git-rbw-wrap github-pat
[advice]
addIgnoredFile = false
[init]
defaultBranch = main
[help]
autocorrect = prompt
[push]
autoSetupRemote = true

113
lappy/config/nvim/init.lua Normal file
View File

@ -0,0 +1,113 @@
-- helper functions {{{
local keymapper = vim.keymap
local globals = vim.g
local opt = vim.o
local cmd = vim.cmd
function nnoremap(l, r)
keymapper.set('n', l, r) -- noremap is implied
end
function inoremap(l, r)
keymapper.set('i', l, r)
end
function tnoremap(l, r)
keymapper.set('t', l, r)
end
-- }}}
-- custom mappings {{{
globals.mapleader = ' '
nnoremap(';', ':')
nnoremap(':', ';')
nnoremap('<leader><leader>', ':')
-- source init.vim
-- requires rebuilding the configuration first
nnoremap('<leader>rr', function()
cmd.source('~/.config/nvim/init.lua')
end)
-- edit init.vim
nnoremap('<leader>re', function()
cmd.edit('~/.config/nvim/init.lua')
end)
-- openup netrw
nnoremap('<leader>fs', function()
cmd.Lexplore()
end)
inoremap('qp', '<c-g>u<Esc>[s1z=`]a<c-g>u')
inoremap("<C-a>", "<Esc>mZ0i<Tab><Esc>`ZlA")
inoremap('jk', '<Esc>')
inoremap('zz', '<Esc>:w!<CR>a')
tnoremap('<Esc>', '<C-\\><C-n>')
-- }}}
-- vim options {{{
opt.compatible = false
opt.number = true
opt.foldmethod = 'marker'
opt.encoding = 'utf8'
opt.list = true
opt.lcs = 'tab:->,trail:_,eol:^'
opt.clipboard = 'unnamedplus'
opt.spell = true
opt.spelllang = "en_us"
opt.title = true
opt.ts = 2
opt.sw = 2
opt.hlsearch = true
opt.incsearch = true
opt.ignorecase = true
opt.smartcase = true
opt.inccommand = 'nosplit'
opt.hidden = true
opt.linebreak = true
opt.path = '.,/usr/include,**'
opt.statusline="%f %r%m%q%h%=%y 0x%02B %04l:%03c:%03p"
vim.api.nvim_exec("let &titlestring='%{expand(\"%:p\")}'", true)
globals.vimtex_view_method = 'zathura'
-- }}}
-- autocommands {{{
function setTabbing(lang, width)
vim.api.nvim_create_autocmd({"Filetype"}, {
pattern = {lang},
callback = function()
vim.bo.expandtab = true
vim.bo.tabstop = width
vim.bo.shiftwidth = width
end
})
end
setTabbing("python", 4)
setTabbing("htmldjango", 4)
setTabbing("javascript", 4)
setTabbing("css", 4)
setTabbing("html", 4)
setTabbing("nix", 2)
vim.api.nvim_create_autocmd({"TermOpen"}, {
pattern = {"*"},
callback = function()
vim.wo.number = false
end
})
vim.api.nvim_create_autocmd({"TermOpen"}, {
pattern = {"*"},
command = "setlocal nospell",
})
-- }}}
-- netrw options {{{
globals.netrw_winsize = -28
globals.netrw_banner = 0
-- for tree view
globals.netrw_liststyle = 3
-- use previous window to open files
globals.netrw_browser_split = 4
-- }}}

View File

@ -0,0 +1,6 @@
{
"base_url": "https://bitwarden.beepboop.systems",
"email": "bit@beepboop.systems",
"identity_url": null,
"lock_timeout": 3600
}

View File

@ -0,0 +1,16 @@
{ lib, config, pkgs, ...}:
{
services.xserver = {
enable = true;
xkb.layout = "us";
displayManager.sx.enable = true;
};
environment.systemPackages = with pkgs; [
xorg.xset
xorg.setxkbmap
xcape
];
}

8
lappy/config/sx/sxrc Executable file
View File

@ -0,0 +1,8 @@
status &
xset r rate 200 80
setxkbmap -option caps:super
pkill xcape
xcape -e 'Super_L=Escape'
dwm

75
lappy/configuration.nix Normal file
View File

@ -0,0 +1,75 @@
{ config, pkgs, ... }:
{
imports = [
./builds
./config
./paperless.nix
./hardware-configuration.nix
];
boot.loader.grub = {
enable = true;
device = "/dev/nvme0n1";
};
networking = {
hostName = "aristotle";
networkmanager.enable = true;
};
hardware = {
pulseaudio.enable = true;
bluetooth = {
enable = true;
settings.General.ControllerMode = "bredr";
};
};
time.timeZone = "America/Chicago";
i18n.defaultLocale = "en_US.UTF-8";
users.users.usr = {
isNormalUser = true;
description = "usr";
extraGroups = [ "networkmanager" "wheel" ];
packages = with pkgs; [];
};
nixpkgs.config.allowUnfree = true;
environment.systemPackages = with pkgs; [
neovim
git
brave
(pkgs.st.overrideAttrs (old: {
patches = [
./builds/st/scrollback.patch
./builds/st/clipboard.patch
];
conf = ./builds/st/config.h;
})
)
dmenu
cmus
htop
rbw
pinentry-tty
ncpamixer
bluetuith
];
services = {
xserver = {
enable = true;
xkb = {
layout = "us";
variant = "";
};
};
libinput.enable = true;
tlp.enable = true;
};
system.stateVersion = "24.05";
}

View File

@ -0,0 +1,26 @@
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/installer/scan/not-detected.nix")
];
boot = {
initrd.availableKernelModules = [ "xhci_pci" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ];
initrd.kernelModules = [ ];
kernelModules = [ "kvm-intel" ];
extraModulePackages = [ ];
};
fileSystems."/" =
{ device = "/dev/disk/by-uuid/e10eea5c-4dca-40f7-86cc-02105bc6d4e0";
fsType = "ext4";
};
swapDevices = [ ];
networking.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

18
lappy/paperless.nix Normal file
View File

@ -0,0 +1,18 @@
{ config, pkgs, lib, ... }:
{
services.paperless = {
enable = true;
# we're only hosting on loopback, so this is safe
passwordFile = builtins.toFile "admin_pass" "admin";
address = "127.0.0.1"; # see above comment
port = 5000;
};
# start paperless manually so as to not destroy battery life
systemd.services = {
paperless-scheduler.wantedBy = lib.mkForce [];
redis-paperless.wantedBy = lib.mkForce [];
redis-paperless.after = lib.mkForce [];
};
}