From 9712d03b2495cab0b11dad38d4a629154b27e922 Mon Sep 17 00:00:00 2001 From: stupidcomputer Date: Tue, 26 Nov 2024 15:37:54 -0600 Subject: [PATCH] add a new, experimental laptop configuration --- .gitmodules | 3 + lappy/README.md | 4 + lappy/builds/default.nix | 8 ++ lappy/builds/dmenu | 1 + lappy/builds/dwm | 1 + lappy/builds/dwm.nix | 22 +++++ lappy/builds/st | 1 + lappy/builds/utils.nix | 25 ++++++ lappy/builds/utils/cmus-status-update | 34 ++++++++ lappy/builds/utils/paperless | 30 +++++++ lappy/builds/utils/rebuild | 3 + lappy/builds/utils/status | 31 +++++++ lappy/config/bash/bashrc | 38 +++++++++ lappy/config/bash/profile | 47 +++++++++++ lappy/config/cmus/rc | 3 + lappy/config/default.nix | 45 ++++++++++ lappy/config/git/config | 21 +++++ lappy/config/nvim/init.lua | 113 ++++++++++++++++++++++++++ lappy/config/rbw/config.json | 6 ++ lappy/config/sx/default.nix | 16 ++++ lappy/config/sx/sxrc | 8 ++ lappy/configuration.nix | 75 +++++++++++++++++ lappy/hardware-configuration.nix | 26 ++++++ lappy/paperless.nix | 18 ++++ 24 files changed, 579 insertions(+) create mode 100644 .gitmodules create mode 100644 lappy/README.md create mode 100644 lappy/builds/default.nix create mode 160000 lappy/builds/dmenu create mode 160000 lappy/builds/dwm create mode 100644 lappy/builds/dwm.nix create mode 160000 lappy/builds/st create mode 100644 lappy/builds/utils.nix create mode 100755 lappy/builds/utils/cmus-status-update create mode 100755 lappy/builds/utils/paperless create mode 100755 lappy/builds/utils/rebuild create mode 100755 lappy/builds/utils/status create mode 100644 lappy/config/bash/bashrc create mode 100644 lappy/config/bash/profile create mode 100644 lappy/config/cmus/rc create mode 100644 lappy/config/default.nix create mode 100644 lappy/config/git/config create mode 100644 lappy/config/nvim/init.lua create mode 100644 lappy/config/rbw/config.json create mode 100644 lappy/config/sx/default.nix create mode 100755 lappy/config/sx/sxrc create mode 100644 lappy/configuration.nix create mode 100644 lappy/hardware-configuration.nix create mode 100644 lappy/paperless.nix diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..b2ea95d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lappy/builds/dwm"] + path = lappy/builds/dwm + url = https://git.beepboop.systems/stupidcomputer/dwm diff --git a/lappy/README.md b/lappy/README.md new file mode 100644 index 0000000..5072990 --- /dev/null +++ b/lappy/README.md @@ -0,0 +1,4 @@ +# lappy + +within this directory are some experimental configurations for a laptop. +that is all. diff --git a/lappy/builds/default.nix b/lappy/builds/default.nix new file mode 100644 index 0000000..9646d2c --- /dev/null +++ b/lappy/builds/default.nix @@ -0,0 +1,8 @@ +{ config, pkgs, ... }: + +{ + environment.systemPackages = with pkgs; [ + (callPackage ./utils.nix {}) + (callPackage ./dwm.nix {}) + ]; +} diff --git a/lappy/builds/dmenu b/lappy/builds/dmenu new file mode 160000 index 0000000..86f0b51 --- /dev/null +++ b/lappy/builds/dmenu @@ -0,0 +1 @@ +Subproject commit 86f0b5119eaa39943013d009967432ffd9d18365 diff --git a/lappy/builds/dwm b/lappy/builds/dwm new file mode 160000 index 0000000..f972a39 --- /dev/null +++ b/lappy/builds/dwm @@ -0,0 +1 @@ +Subproject commit f972a39b880bc2a631c3804b6c9b41faeb9a3898 diff --git a/lappy/builds/dwm.nix b/lappy/builds/dwm.nix new file mode 100644 index 0000000..0777905 --- /dev/null +++ b/lappy/builds/dwm.nix @@ -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 + ''; +} diff --git a/lappy/builds/st b/lappy/builds/st new file mode 160000 index 0000000..a0274bc --- /dev/null +++ b/lappy/builds/st @@ -0,0 +1 @@ +Subproject commit a0274bc20e11d8672bb2953fdd1d3010c0e708c5 diff --git a/lappy/builds/utils.nix b/lappy/builds/utils.nix new file mode 100644 index 0000000..44ca554 --- /dev/null +++ b/lappy/builds/utils.nix @@ -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 + ''; +} diff --git a/lappy/builds/utils/cmus-status-update b/lappy/builds/utils/cmus-status-update new file mode 100755 index 0000000..0730f88 --- /dev/null +++ b/lappy/builds/utils/cmus-status-update @@ -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 diff --git a/lappy/builds/utils/paperless b/lappy/builds/utils/paperless new file mode 100755 index 0000000..14d78a2 --- /dev/null +++ b/lappy/builds/utils/paperless @@ -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 <', ':') + +-- source init.vim +-- requires rebuilding the configuration first +nnoremap('rr', function() + cmd.source('~/.config/nvim/init.lua') +end) +-- edit init.vim +nnoremap('re', function() + cmd.edit('~/.config/nvim/init.lua') +end) +-- openup netrw +nnoremap('fs', function() + cmd.Lexplore() +end) + +inoremap('qp', 'u[s1z=`]au') +inoremap("", "mZ0i`ZlA") +inoremap('jk', '') +inoremap('zz', ':w!a') + +tnoremap('', '') +-- }}} + +-- 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 +-- }}} diff --git a/lappy/config/rbw/config.json b/lappy/config/rbw/config.json new file mode 100644 index 0000000..8f18c83 --- /dev/null +++ b/lappy/config/rbw/config.json @@ -0,0 +1,6 @@ +{ + "base_url": "https://bitwarden.beepboop.systems", + "email": "bit@beepboop.systems", + "identity_url": null, + "lock_timeout": 3600 +} diff --git a/lappy/config/sx/default.nix b/lappy/config/sx/default.nix new file mode 100644 index 0000000..55dbcbe --- /dev/null +++ b/lappy/config/sx/default.nix @@ -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 + ]; +} diff --git a/lappy/config/sx/sxrc b/lappy/config/sx/sxrc new file mode 100755 index 0000000..6c80c80 --- /dev/null +++ b/lappy/config/sx/sxrc @@ -0,0 +1,8 @@ +status & + +xset r rate 200 80 +setxkbmap -option caps:super +pkill xcape +xcape -e 'Super_L=Escape' + +dwm diff --git a/lappy/configuration.nix b/lappy/configuration.nix new file mode 100644 index 0000000..6a2364f --- /dev/null +++ b/lappy/configuration.nix @@ -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"; +} diff --git a/lappy/hardware-configuration.nix b/lappy/hardware-configuration.nix new file mode 100644 index 0000000..d5030dd --- /dev/null +++ b/lappy/hardware-configuration.nix @@ -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; +} diff --git a/lappy/paperless.nix b/lappy/paperless.nix new file mode 100644 index 0000000..a536bfa --- /dev/null +++ b/lappy/paperless.nix @@ -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 []; + }; +}