├── python ├── lib │ ├── __init__.py │ └── sha256.py ├── .gitignore ├── scripts │ ├── bin │ │ ├── kmake │ │ ├── tz_chg │ │ ├── b4_branch │ │ ├── cbl_vmm │ │ ├── korg_gcc │ │ ├── korg_llvm │ │ ├── nas_sync │ │ ├── print_cmd │ │ ├── sd_nspawn │ │ ├── cbl_ptchmn │ │ ├── cbl_report │ │ ├── cbl_gen_line │ │ ├── gen_patch_cc │ │ ├── cbl_bld_krnl_pkg │ │ ├── cbl_bld_krnl_vm │ │ ├── tuxmake_bld_all │ │ └── cbl_gen_build_report │ ├── korg_gcc.py │ ├── korg_llvm.py │ ├── print_cmd.py │ ├── gen_patch_cc.py │ ├── upd_distro.py │ └── tmxrun.py ├── .style.yapf ├── pgo-llvm-builder │ ├── .gitignore │ ├── mkosi.postinst.d │ │ ├── 01-dynamic-deps.fish.chroot │ │ ├── 01-create-builder.fish.chroot │ │ ├── 01-modern-llvm.fish.chroot │ │ ├── 03-modern-binutils.fish.chroot │ │ ├── 00-modern-cmake.sh.chroot │ │ ├── 02-modern-zstd.fish.chroot │ │ ├── 02-modern-python.fish.chroot │ │ ├── 02-modern-ninja.fish.chroot │ │ └── 03-modern-perf.fish.chroot │ ├── mkosi.conf │ └── dep-vers.fish ├── .pylintrc └── ruff.toml ├── configs ├── kernel │ └── .gitignore ├── tmux │ ├── .tmux.conf.nspawn │ ├── .tmux.conf.vm │ ├── generic.yml │ ├── primary.yml │ ├── .tmux.conf.regular │ ├── qemu.yml │ ├── .tmux.conf.container │ ├── test.yml │ ├── next.yml │ └── .tmux.conf.common ├── common │ ├── vim │ │ ├── skeletons │ │ │ ├── bash │ │ │ ├── fish │ │ │ └── python │ │ └── indent │ │ │ └── make.vim │ ├── muttrc.gpg │ ├── netrc.gpg │ ├── botinfo.gpg │ ├── server_ip.gpg │ ├── config.ini.gpg │ ├── del_dog_api_key.gpg │ ├── muttrc.notifier.gpg │ ├── tar-excludes │ └── colors.sh ├── tuxmake │ └── storage.conf ├── systemd │ ├── mnt-nas.automount │ ├── nas-bundles.timer │ ├── nas-bundles.service │ └── mnt-nas.mount ├── local │ ├── tio.config │ ├── snazzy.js │ ├── Nathan.profile │ ├── snazzy.theme │ ├── Nathan.dconf │ └── snazzy.colorscheme ├── b4 │ └── kbuild-am.template └── archinstall │ └── vm_config.json ├── requirements.txt ├── mkosi ├── dev-arch │ ├── mkosi.extra │ │ └── etc │ │ │ └── use-cbl │ └── mkosi.postinst.d │ │ ├── 00-locale-gen.fish.chroot │ │ ├── 00-add-grep-wrappers.fish.chroot │ │ ├── 00-symlink-home.fish.chroot │ │ ├── 02-add-hetzner-mirror.py.chroot │ │ ├── 00-conf.fish.chroot │ │ └── 01-install-packages.fish.chroot ├── dev-debian │ ├── mkosi.postinst.d │ │ ├── 01-symlink-home.fish.chroot │ │ ├── 00-modern-fish.sh.chroot │ │ ├── 01-passwordless-sudo.fish.chroot │ │ ├── 01-fix-sharkdp-symlinks.fish.chroot │ │ ├── 01-setup-locales.fish.chroot │ │ ├── 01-etc-use-cbl.fish.chroot │ │ └── 01-install-packages.fish.chroot │ └── mkosi.conf.d │ │ └── 00-cross-compilers.conf └── dev-fedora │ ├── mkosi.postinst.d │ ├── 00-symlink-home.fish.chroot │ ├── 00-add-grep-wrappers.fish.chroot │ ├── 00-etc-use-cbl.fish.chroot │ ├── 01-install-packages.fish.chroot │ ├── 00-swap-doas-for-sudo.fish.chroot │ ├── 00-fedora40-crypto-policy.fish.chroot │ ├── 00-install-edk2-arm.fish.chroot │ └── 00-fix-nsswitch.conf.fish.chroot │ └── mkosi.conf.d │ ├── 00-arm64-cross-compilers.conf │ └── 00-x86_64-cross-compilers.conf ├── pkgbuilds ├── python-msgspec │ ├── .gitignore │ └── PKGBUILD ├── .gitignore ├── tio │ └── PKGBUILD ├── python-pebble │ └── PKGBUILD ├── cvise │ └── PKGBUILD └── gdb-multiarch │ └── PKGBUILD ├── .shellcheckrc ├── fish ├── completions │ ├── vwfunc.fish │ ├── tbf.fish │ ├── get_ip.fish │ ├── cbl_gcmt.fish │ ├── cbl_cl_software.fish │ ├── cbl_clone_repo.fish │ ├── rmbx.fish │ ├── edfunc.fish │ ├── msh.fish │ ├── upd.fish │ ├── cbl_upd_krnl.fish │ ├── cbl_bld_llvm_korg.fish │ ├── edcomp.fish │ ├── cbl_bld_krnl_pkg.fish │ ├── cbl_bld_krnl_rpm.fish │ ├── cbl_bld_krnl_vm.fish │ └── build-llvm.py.fish ├── functions │ ├── fish_greeting.fish │ ├── bell.fish │ ├── cde.fish │ ├── crl.fish │ ├── cdr.fish │ ├── __in_orb.fish │ ├── gh_llvm.fish │ ├── __is_github_actions.fish │ ├── fzf.fish │ ├── virsh_ips.fish │ ├── __user_exists.fish │ ├── __print_error.fish │ ├── fish_format.fish │ ├── restart_ssh_agent.fish │ ├── __in_deb_chroot.fish │ ├── __print_red.fish │ ├── __print_warning.fish │ ├── rld.fish │ ├── __print_green.fish │ ├── transfer_mod_db.fish │ ├── __print_yellow.fish │ ├── hwvulns.fish │ ├── print_no_werror_cfgs.fish │ ├── __in_venv.fish │ ├── __has_detached_head.fish │ ├── __wezterm_title.fish │ ├── yapf.fish │ ├── __is_location_primary.fish │ ├── __stable_folder_to_branch.fish │ ├── __gen_boot_utils_json.fish │ ├── __git_cpi.fish │ ├── duf.fish │ ├── have_dev_kvm_access.fish │ ├── fisher_update.fish │ ├── gpg_key_usable.fish │ ├── __get_my_funcs.fish │ ├── ls.fish │ ├── b4.fish │ ├── lei.fish │ ├── remkdir.fish │ ├── __in_nspawn.fish │ ├── __stripall.fish │ ├── __is_tree_dirty.fish │ ├── remkdircd.fish │ ├── cbl_upd_qemu.fish │ ├── kgtm.fish │ ├── header.fish │ ├── __get_systemd_version.fish │ ├── cbl_check_sysfs_cfi.fish │ ├── kgmbx.fish │ ├── __git_rn.fish │ ├── cbl_ci_gen_series.fish │ ├── cdf.fish │ ├── __get_glibc_version.fish │ ├── __git_dmb.fish │ ├── get_host_llvm_target.fish │ ├── yapff.fish │ ├── fix_wrktrs_for_nspawn.fish │ ├── cbl_install_vm.fish │ ├── tuxmake.fish │ ├── tmuxp.fish │ ├── __is_shallow_clone.fish │ ├── glr.fish │ ├── reset_ssh_agent.fish │ ├── __git_rf.fish │ ├── encrypt_gpg_file.fish │ ├── __git_sync.fish │ ├── vwfunc.fish │ ├── setup_registries_conf.fish │ ├── vw.fish │ ├── fix_fish_history.fish │ ├── kchp.fish │ ├── decrypt_gpg_file.fish │ ├── cbl_lkt_for_all_llvm.fish │ ├── b4_prep.fish │ ├── tbf.fish │ ├── __gen_func_completions.fish │ ├── virsh_delete_vm.fish │ ├── cbl_bld_all.fish │ ├── gpg_key_cache.fish │ ├── cbl_qualify_next.fish │ ├── clone_aur_repos.fish │ ├── updfull.fish │ ├── newfunc.fish │ ├── __is_installed.fish │ ├── upd_repo_pkg.fish │ ├── __is_system_binary.fish │ ├── clean_old_kernels.fish │ ├── __in_container.fish │ ├── __in_tree.fish │ ├── b4_from_next.fish │ ├── __tg_msg.fish │ ├── vim_setup.fish │ ├── newpylink.fish │ ├── rmbx.fish │ ├── tmxrun.fish │ ├── git_py_files.fish │ ├── b4_patch.fish │ ├── prep_config.fish │ ├── cbl_create_tc_tar.fish │ ├── cbl_rb_fd.fish │ ├── updall.fish │ ├── cbl_install_tc_tar.fish │ ├── klog.fish │ ├── prep_vm_archinstall.fish │ ├── create_folder_tar.fish │ ├── __get_distro.fish │ ├── __git_bf.fish │ ├── __in_container_msg.fish │ ├── create_repo_tar.fish │ ├── tmxa.fish │ ├── edcomp.fish │ ├── lsfuncs.fish │ ├── hugo_serve.fish │ ├── cbl_gen_vm_boot_files.fish │ ├── gh_run.fish │ ├── mchsh.fish │ ├── __adjust_fisher_paths.fish │ ├── __start_tmux.fish │ ├── get_ip.fish │ ├── __mail_msg.fish │ ├── __git_sw.fish │ ├── cbl_cl_software.fish │ ├── cbl_test_llvm_linux.fish │ ├── mvfunc.fish │ ├── __git_ua.fish │ ├── nspawn_path.fish │ ├── kpch.fish │ ├── cbl_bld_llvm_fast.fish │ ├── cbl_bld_llvm_sbs.fish │ ├── updweb.fish │ ├── edfunc.fish │ ├── __tmux_ssh_fixup.fish │ ├── setup_sd_nspawn.fish │ ├── cbl_bld_krnl_deb.fish │ ├── cbl_patch_llvm.fish │ ├── setup_libvirt.fish │ ├── prep_pkg_for_vm.fish │ ├── kboot.fish │ ├── msh.fish │ ├── setup_systemd_files.fish │ ├── _hydro_addon_nathan.fish │ ├── __gen_slim_initrd.fish │ ├── sd_boot_kernel.fish │ ├── cbl_test_kvm.fish │ ├── cbl_prep_bisect.fish │ ├── cbl_gen_korg_llvm_announce.fish │ ├── install_arch_kernel.fish │ ├── __clone_repo_from_bundle.fish │ ├── lei_setup.fish │ ├── cbl_bld_tot_gcc.fish │ └── cbl_upd_stbl_wrktrs.fish └── conf.d │ └── colors.fish ├── bin ├── aarch64 │ └── read_all ├── armv7l │ └── read_all ├── x86_64 │ └── read_all └── packages │ ├── opendoas_6.8.2-1_arm64.deb │ ├── opendoas_6.8.2-1_armhf.deb │ ├── opendoas_6.8.2-1+b1_amd64.deb │ └── modprobed-db-2.48-1.fc42.noarch.rpm ├── .github └── workflows │ └── main.yml ├── README.md ├── LICENSE ├── bash └── bootstrap.sh └── specs └── modprobed-db └── modprobed-db.spec /python/lib/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /configs/kernel/.gitignore: -------------------------------------------------------------------------------- 1 | *.old 2 | -------------------------------------------------------------------------------- /python/.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__/ 2 | -------------------------------------------------------------------------------- /python/scripts/bin/kmake: -------------------------------------------------------------------------------- 1 | ../kmake.py -------------------------------------------------------------------------------- /python/scripts/bin/tz_chg: -------------------------------------------------------------------------------- 1 | ../tz_chg.py -------------------------------------------------------------------------------- /python/scripts/korg_gcc.py: -------------------------------------------------------------------------------- 1 | korg_tc.py -------------------------------------------------------------------------------- /python/scripts/korg_llvm.py: -------------------------------------------------------------------------------- 1 | korg_tc.py -------------------------------------------------------------------------------- /python/scripts/bin/b4_branch: -------------------------------------------------------------------------------- 1 | ../b4_branch.py -------------------------------------------------------------------------------- /python/scripts/bin/cbl_vmm: -------------------------------------------------------------------------------- 1 | ../cbl_vmm.py -------------------------------------------------------------------------------- /python/scripts/bin/korg_gcc: -------------------------------------------------------------------------------- 1 | ../korg_tc.py -------------------------------------------------------------------------------- /python/scripts/bin/korg_llvm: -------------------------------------------------------------------------------- 1 | ../korg_tc.py -------------------------------------------------------------------------------- /python/scripts/bin/nas_sync: -------------------------------------------------------------------------------- 1 | ../nas_sync.py -------------------------------------------------------------------------------- /python/scripts/bin/print_cmd: -------------------------------------------------------------------------------- 1 | ../print_cmd.py -------------------------------------------------------------------------------- /python/scripts/bin/sd_nspawn: -------------------------------------------------------------------------------- 1 | ../sd_nspawn.py -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | requests 2 | tuxmake 3 | -------------------------------------------------------------------------------- /mkosi/dev-arch/mkosi.extra/etc/use-cbl: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /pkgbuilds/python-msgspec/.gitignore: -------------------------------------------------------------------------------- 1 | msgspec/ 2 | -------------------------------------------------------------------------------- /python/scripts/bin/cbl_ptchmn: -------------------------------------------------------------------------------- 1 | ../cbl_ptchmn.py -------------------------------------------------------------------------------- /python/scripts/bin/cbl_report: -------------------------------------------------------------------------------- 1 | ../cbl_report.py -------------------------------------------------------------------------------- /configs/tmux/.tmux.conf.nspawn: -------------------------------------------------------------------------------- 1 | .tmux.conf.container -------------------------------------------------------------------------------- /python/scripts/bin/cbl_gen_line: -------------------------------------------------------------------------------- 1 | ../cbl_gen_line.py -------------------------------------------------------------------------------- /python/scripts/bin/gen_patch_cc: -------------------------------------------------------------------------------- 1 | ../gen_patch_cc.py -------------------------------------------------------------------------------- /python/scripts/bin/cbl_bld_krnl_pkg: -------------------------------------------------------------------------------- 1 | ../cbl_bld_krnl_pkg.py -------------------------------------------------------------------------------- /python/scripts/bin/cbl_bld_krnl_vm: -------------------------------------------------------------------------------- 1 | ../cbl_bld_krnl_vm.py -------------------------------------------------------------------------------- /python/scripts/bin/tuxmake_bld_all: -------------------------------------------------------------------------------- 1 | ../tuxmake_bld_all.py -------------------------------------------------------------------------------- /configs/common/vim/skeletons/bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | -------------------------------------------------------------------------------- /configs/common/vim/skeletons/fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | 3 | -------------------------------------------------------------------------------- /pkgbuilds/.gitignore: -------------------------------------------------------------------------------- 1 | *.patch 2 | *.tar.* 3 | pkg/ 4 | src/ 5 | -------------------------------------------------------------------------------- /python/scripts/bin/cbl_gen_build_report: -------------------------------------------------------------------------------- 1 | ../cbl_gen_build_report.py -------------------------------------------------------------------------------- /.shellcheckrc: -------------------------------------------------------------------------------- 1 | disable=SC1090 2 | disable=SC2030 3 | disable=SC2031 4 | -------------------------------------------------------------------------------- /python/.style.yapf: -------------------------------------------------------------------------------- 1 | [style] 2 | based_on_style = pep8 3 | column_limit = 100 4 | -------------------------------------------------------------------------------- /fish/completions/vwfunc.fish: -------------------------------------------------------------------------------- 1 | complete -c vwfunc -x -a "(__gen_func_completions)" 2 | -------------------------------------------------------------------------------- /python/pgo-llvm-builder/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | git/ 3 | install/ 4 | rust/ 5 | src/ 6 | -------------------------------------------------------------------------------- /bin/aarch64/read_all: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanchance/env/HEAD/bin/aarch64/read_all -------------------------------------------------------------------------------- /bin/armv7l/read_all: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanchance/env/HEAD/bin/armv7l/read_all -------------------------------------------------------------------------------- /bin/x86_64/read_all: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanchance/env/HEAD/bin/x86_64/read_all -------------------------------------------------------------------------------- /configs/common/muttrc.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanchance/env/HEAD/configs/common/muttrc.gpg -------------------------------------------------------------------------------- /configs/common/netrc.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanchance/env/HEAD/configs/common/netrc.gpg -------------------------------------------------------------------------------- /configs/common/botinfo.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanchance/env/HEAD/configs/common/botinfo.gpg -------------------------------------------------------------------------------- /configs/common/server_ip.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanchance/env/HEAD/configs/common/server_ip.gpg -------------------------------------------------------------------------------- /configs/common/config.ini.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanchance/env/HEAD/configs/common/config.ini.gpg -------------------------------------------------------------------------------- /configs/common/vim/skeletons/python: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | if __name__ == '__main__': 4 | pass 5 | -------------------------------------------------------------------------------- /fish/completions/tbf.fish: -------------------------------------------------------------------------------- 1 | complete -c tbf -x -a "(path filter -t dir $TMP_BUILD_FOLDER/* | path basename)" 2 | -------------------------------------------------------------------------------- /configs/common/del_dog_api_key.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanchance/env/HEAD/configs/common/del_dog_api_key.gpg -------------------------------------------------------------------------------- /configs/common/muttrc.notifier.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanchance/env/HEAD/configs/common/muttrc.notifier.gpg -------------------------------------------------------------------------------- /mkosi/dev-debian/mkosi.postinst.d/01-symlink-home.fish.chroot: -------------------------------------------------------------------------------- 1 | ../../dev-arch/mkosi.postinst.d/00-symlink-home.fish.chroot -------------------------------------------------------------------------------- /mkosi/dev-fedora/mkosi.postinst.d/00-symlink-home.fish.chroot: -------------------------------------------------------------------------------- 1 | ../../dev-arch/mkosi.postinst.d/00-symlink-home.fish.chroot -------------------------------------------------------------------------------- /bin/packages/opendoas_6.8.2-1_arm64.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanchance/env/HEAD/bin/packages/opendoas_6.8.2-1_arm64.deb -------------------------------------------------------------------------------- /bin/packages/opendoas_6.8.2-1_armhf.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanchance/env/HEAD/bin/packages/opendoas_6.8.2-1_armhf.deb -------------------------------------------------------------------------------- /configs/tuxmake/storage.conf: -------------------------------------------------------------------------------- 1 | [storage] 2 | driver = "overlay" 3 | rootless_storage_path = "$HOME/.local/share/containers/storage" 4 | -------------------------------------------------------------------------------- /mkosi/dev-debian/mkosi.postinst.d/00-modern-fish.sh.chroot: -------------------------------------------------------------------------------- 1 | ../../../python/pgo-llvm-builder/mkosi.postinst.d/00-modern-fish.sh.chroot -------------------------------------------------------------------------------- /mkosi/dev-fedora/mkosi.postinst.d/00-add-grep-wrappers.fish.chroot: -------------------------------------------------------------------------------- 1 | ../../dev-arch/mkosi.postinst.d/00-add-grep-wrappers.fish.chroot -------------------------------------------------------------------------------- /bin/packages/opendoas_6.8.2-1+b1_amd64.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanchance/env/HEAD/bin/packages/opendoas_6.8.2-1+b1_amd64.deb -------------------------------------------------------------------------------- /configs/common/vim/indent/make.vim: -------------------------------------------------------------------------------- 1 | setlocal noexpandtab 2 | setlocal tabstop=8 3 | setlocal softtabstop=8 4 | setlocal shiftwidth=8 5 | -------------------------------------------------------------------------------- /bin/packages/modprobed-db-2.48-1.fc42.noarch.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanchance/env/HEAD/bin/packages/modprobed-db-2.48-1.fc42.noarch.rpm -------------------------------------------------------------------------------- /python/.pylintrc: -------------------------------------------------------------------------------- 1 | [MASTER] 2 | init-hook="from pylint.config import find_pylintrc; import os, sys; sys.path.append(os.path.dirname(find_pylintrc()))" 3 | -------------------------------------------------------------------------------- /fish/completions/get_ip.fish: -------------------------------------------------------------------------------- 1 | complete -c get_ip -f -d "Special host" -a '(type get_ip | string match -gr "^ case ([a-zA-Z0-9\- ]+)" | string split " ")' 2 | -------------------------------------------------------------------------------- /mkosi/dev-debian/mkosi.postinst.d/01-passwordless-sudo.fish.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | 3 | echo 'nathan ALL=(ALL) NOPASSWD: ALL' >/etc/sudoers.d/00_nathan 4 | -------------------------------------------------------------------------------- /fish/completions/cbl_gcmt.fish: -------------------------------------------------------------------------------- 1 | complete -c cbl_gcmt -x -d "Type of commit" -a '(type cbl_gcmt | string match -gr "^ case ([^\']+)\$" | string split " ")' 2 | -------------------------------------------------------------------------------- /configs/tmux/.tmux.conf.vm: -------------------------------------------------------------------------------- 1 | set-window-option -g window-status-current-style fg=red,bg=default,bold 2 | 3 | source ~/.tmux.conf.common 4 | source ~/.tmux.conf.container 5 | -------------------------------------------------------------------------------- /mkosi/dev-arch/mkosi.postinst.d/00-locale-gen.fish.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | 3 | sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen 4 | locale-gen 5 | -------------------------------------------------------------------------------- /fish/functions/fish_greeting.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function fish_greeting 6 | end 7 | -------------------------------------------------------------------------------- /mkosi/dev-fedora/mkosi.conf.d/00-arm64-cross-compilers.conf: -------------------------------------------------------------------------------- 1 | [Content] 2 | Packages=binutils-x86_64-linux-gnu 3 | gcc-x86_64-linux-gnu 4 | [Match] 5 | Architecture=arm64 6 | -------------------------------------------------------------------------------- /configs/systemd/mnt-nas.automount: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Automount Synology NAS folder at boot 3 | 4 | [Automount] 5 | Where=/mnt/nas 6 | 7 | [Install] 8 | WantedBy=multi-user.target 9 | -------------------------------------------------------------------------------- /fish/completions/cbl_cl_software.fish: -------------------------------------------------------------------------------- 1 | complete -c cbl_cl_software.fish -x -d "Software to clean" -a '(type cbl_cl_software.fish | string match -gr "^ case ([\w|\-|\s]+)")' 2 | -------------------------------------------------------------------------------- /fish/completions/cbl_clone_repo.fish: -------------------------------------------------------------------------------- 1 | complete -c cbl_clone_repo -x -d "Repo to clone" -a '(type cbl_clone_repo | string match -gr "^ case ([\w|\-|\s]+)" | string split " ")' 2 | -------------------------------------------------------------------------------- /mkosi/dev-fedora/mkosi.conf.d/00-x86_64-cross-compilers.conf: -------------------------------------------------------------------------------- 1 | [Content] 2 | Packages=binutils-aarch64-linux-gnu 3 | gcc-aarch64-linux-gnu 4 | [Match] 5 | Architecture=x86-64 6 | -------------------------------------------------------------------------------- /fish/completions/rmbx.fish: -------------------------------------------------------------------------------- 1 | complete -c rmbx -f -s u -l update -d "Update mailbox file before reading" 2 | complete -c rmbx -x -d Mailbox -a "(path filter -d $MAIL_FOLDER/* | path basename)" 3 | -------------------------------------------------------------------------------- /mkosi/dev-debian/mkosi.postinst.d/01-fix-sharkdp-symlinks.fish.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | 3 | ln -fsv /usr/bin/batcat /usr/local/bin/bat 4 | ln -fsv /usr/bin/fdfind /usr/local/bin/fd 5 | -------------------------------------------------------------------------------- /fish/functions/bell.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | function bell -d "printf '\a'" 6 | printf '\a' 7 | end 8 | -------------------------------------------------------------------------------- /configs/common/tar-excludes: -------------------------------------------------------------------------------- 1 | linux-mainline-llvm/linux-mainline-llvm 2 | linux-next-llvm/linux-next-llvm 3 | pkgbuilds/linux-*/config.old 4 | pkgbuilds/*/pkg 5 | pkgbuilds/*/src 6 | pkgbuilds/*/*.tar.* 7 | -------------------------------------------------------------------------------- /configs/systemd/nas-bundles.timer: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Generate git bundles on NAS weekly 3 | 4 | [Timer] 5 | OnCalendar=weekly 6 | Persistent=true 7 | 8 | [Install] 9 | WantedBy=timers.target 10 | -------------------------------------------------------------------------------- /fish/functions/cde.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function cde -d "Change to env folder" 6 | cd $ENV_FOLDER 7 | end 8 | -------------------------------------------------------------------------------- /fish/functions/crl.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function crl -d "Shorthand for 'curl -LSs'" -w curl 6 | curl -LSs $argv 7 | end 8 | -------------------------------------------------------------------------------- /fish/functions/cdr.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function cdr -d "Change to root directory of git repo" 6 | cd (git root) 7 | end 8 | -------------------------------------------------------------------------------- /configs/systemd/nas-bundles.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Generate git bundles on NAS 3 | 4 | [Service] 5 | ExecStart=:/bin/sh -c '$PYTHON_SCRIPTS_FOLDER/nas_sync.py -t bundles' 6 | 7 | [Install] 8 | WantedBy=default.target 9 | -------------------------------------------------------------------------------- /configs/local/tio.config: -------------------------------------------------------------------------------- 1 | [aadp] 2 | device = /dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_BGA=b11A920-if00-port0 3 | 4 | [honeycomb] 5 | device = /dev/serial/by-id/usb-FTDI_FT230X_Basic_UART_DK0D1901-if00-port0 6 | -------------------------------------------------------------------------------- /fish/completions/edfunc.fish: -------------------------------------------------------------------------------- 1 | complete -c edfunc -x -a "(__gen_func_completions)" 2 | complete -c edfunc -f -s r -l reload -d "Reload fish files after editing function" 3 | complete -c edfunc -f -s f -l fzf -d "Select functions to edit using fzf" 4 | -------------------------------------------------------------------------------- /fish/functions/__in_orb.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2023 Nathan Chancellor 4 | 5 | function __in_orb -d "Check if running within an OrbStack machine on macOS" 6 | set -q MAC_FOLDER 7 | end 8 | -------------------------------------------------------------------------------- /fish/functions/gh_llvm.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | function gh_llvm -d "Shorthand for 'gh -R llvm/llvm-project'" -w gh 6 | gh -R llvm/llvm-project $argv 7 | end 8 | -------------------------------------------------------------------------------- /fish/completions/msh.fish: -------------------------------------------------------------------------------- 1 | complete -c msh -f -d "Special host" -a '(type msh | string match -gr "^ case ([a-zA-Z0-9][a-zA-Z0-9\- ]+)" | string split " " | path sort)' 2 | complete -c msh -f -s t -l tailscale -d "Connect to device using Tailscale" 3 | -------------------------------------------------------------------------------- /fish/functions/__is_github_actions.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function __is_github_actions -d "Tests if running on GitHub Actions" 6 | set -q GITHUB_ACTIONS 7 | end 8 | -------------------------------------------------------------------------------- /fish/functions/fzf.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function fzf -d "Call fzf with custom environment" 6 | set -fx TMPDIR /var/tmp/fzf 7 | command fzf $argv 8 | end 9 | -------------------------------------------------------------------------------- /fish/functions/virsh_ips.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function virsh_ips -d "Shorthand for 'virsh net-dhcp-leases default'" 6 | virsh net-dhcp-leases default 7 | end 8 | -------------------------------------------------------------------------------- /fish/functions/__user_exists.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function __user_exists -d "Checks if a user exists on the machine" 6 | getent passwd $argv &>/dev/null 7 | end 8 | -------------------------------------------------------------------------------- /fish/functions/__print_error.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function __print_error -d "Print a message with an ERROR tag in bold red" 6 | __print_red "\nERROR: $argv\n" 7 | end 8 | -------------------------------------------------------------------------------- /fish/functions/fish_format.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function fish_format -d "Format all fish files in directory with fish_indent" 6 | fd -e fish -x fish_indent -w 7 | end 8 | -------------------------------------------------------------------------------- /fish/functions/restart_ssh_agent.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function restart_ssh_agent -d "Reset then start the ssh-agent" 6 | reset_ssh_agent 7 | start_ssh_agent 8 | end 9 | -------------------------------------------------------------------------------- /mkosi/dev-arch/mkosi.postinst.d/00-add-grep-wrappers.fish.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | 3 | for char in e f 4 | echo '#!/bin/sh 5 | 6 | exec grep -'(string upper $char)' "$@"' >/usr/local/bin/"$char"grep 7 | end 8 | 9 | chmod 755 /usr/local/bin/*grep 10 | -------------------------------------------------------------------------------- /configs/systemd/mnt-nas.mount: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Mount Synology NAS folder at boot 3 | 4 | [Mount] 5 | What=10.0.1.30:/volume1/Storage 6 | Where=/mnt/nas 7 | Options=vers=4 8 | Type=nfs 9 | TimeoutSec=30 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /fish/functions/__in_deb_chroot.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | function __in_deb_chroot -d "Check if we are in a Debian chroot (usually via schroot)" 6 | test -r /etc/debian_chroot 7 | end 8 | -------------------------------------------------------------------------------- /fish/functions/__print_red.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function __print_red -d "Print input in bold, red text" 6 | printf '%b%b%b\n' (set_color -o red) "$argv" (set_color normal) 7 | end 8 | -------------------------------------------------------------------------------- /fish/functions/__print_warning.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function __print_warning -d "Print a message with a WARNING tag in bold yellow" 6 | __print_yellow "\nWARNING: $argv\n" 7 | end 8 | -------------------------------------------------------------------------------- /configs/tmux/generic.yml: -------------------------------------------------------------------------------- 1 | session_name: main 2 | windows: 3 | - window_name: btop and host 4 | layout: 0d09,269x53,0,0[269x36,0,0,15,269x16,0,37,17] 5 | panes: 6 | - btop 7 | - 8 | - window_name: machinectl shell 9 | focus: true 10 | panes: 11 | - shell: mchsh 12 | -------------------------------------------------------------------------------- /fish/functions/rld.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function rld -d "Reload fish configuration" 6 | fisher_update $ENV_FOLDER/fish 1>/dev/null 7 | source $__fish_config_dir/config.fish 8 | end 9 | -------------------------------------------------------------------------------- /configs/tmux/primary.yml: -------------------------------------------------------------------------------- 1 | session_name: main 2 | windows: 3 | - window_name: btop and host shell 4 | layout: 0d09,269x53,0,0[269x36,0,0,15,269x16,0,37,17] 5 | panes: 6 | - shell: btop 7 | - 8 | - window_name: nspawn 9 | focus: true 10 | panes: 11 | - shell: mchsh 12 | -------------------------------------------------------------------------------- /fish/functions/__print_green.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function __print_green -d "Print input in bold, green text" 6 | printf '%b%b%b\n' (set_color -o green) "$argv" (set_color normal) 7 | end 8 | -------------------------------------------------------------------------------- /fish/functions/transfer_mod_db.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | function transfer_mod_db -d "Transfer modprobed.db to $MAIN_REMOTE_IP" 6 | scp $HOME/.config/modprobed.db nathan@$MAIN_REMOTE_IP:/tmp 7 | end 8 | -------------------------------------------------------------------------------- /fish/functions/__print_yellow.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function __print_yellow -d "Print input in bold, yellow text" 6 | printf '%b%b%b\n' (set_color -o yellow) "$argv" (set_color normal) 7 | end 8 | -------------------------------------------------------------------------------- /fish/functions/hwvulns.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function hwvulns -d "Displays the hardware vulnerability sysfs values" 6 | grep --color=always . /sys/devices/system/cpu/vulnerabilities/* 7 | end 8 | -------------------------------------------------------------------------------- /fish/functions/print_no_werror_cfgs.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | function print_no_werror_cfgs -d "Print disabled -Werror Kconfig values for KCONFIG_ALLCONFIG" 6 | printf 'CONFIG_%s=n\n' {DRM_,}WERROR 7 | end 8 | -------------------------------------------------------------------------------- /fish/functions/__in_venv.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function __in_venv -d "Returns true if in a Python virtual environment" 6 | # This isn't foolproof but it is good enough 7 | set -q VIRTUAL_ENV 8 | end 9 | -------------------------------------------------------------------------------- /fish/functions/__has_detached_head.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function __has_detached_head -d "Returns true if supplied git repo in detached HEAD state" 6 | test -z "$(git -C $argv branch --show-current)" 7 | end 8 | -------------------------------------------------------------------------------- /fish/functions/__wezterm_title.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function __wezterm_title -d "Sets the title for a tab in WezTerm" 6 | printf "\x1b]1337;SetUserVar=panetitle=%s\x07" "$(echo -n "$argv" | base64)" 7 | end 8 | -------------------------------------------------------------------------------- /fish/functions/yapf.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function yapf -d "Call yapf with additional default arguments" 6 | command yapf \ 7 | --in-place \ 8 | --parallel \ 9 | $argv 10 | end 11 | -------------------------------------------------------------------------------- /fish/functions/__is_location_primary.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function __is_location_primary -d "Checks if current machine is a primary machine (workstation, server)" 6 | contains $LOCATION $PRIMARY_LOCATIONS 7 | end 8 | -------------------------------------------------------------------------------- /fish/functions/__stable_folder_to_branch.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | function __stable_folder_to_branch -d "Convert 'linux-stable-.' into 'linux-..y'" 6 | string replace stable- '' (path basename $argv).y 7 | end 8 | -------------------------------------------------------------------------------- /python/pgo-llvm-builder/mkosi.postinst.d/01-dynamic-deps.fish.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # Description: Install dependencies that are only needed under certain conditions 3 | 4 | if test "$DISTRIBUTION_ARCHITECTURE" = amd64 5 | apt update 6 | 7 | and apt install -y --no-install-recommends libc6-dev-i386 8 | end 9 | -------------------------------------------------------------------------------- /fish/functions/__gen_boot_utils_json.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | function __gen_boot_utils_json -d "Generate /tmp/boot-utils.json" 6 | crl -o /tmp/boot-utils.json https://api.github.com/repos/ClangBuiltLinux/boot-utils/releases/latest 7 | end 8 | -------------------------------------------------------------------------------- /configs/tmux/.tmux.conf.regular: -------------------------------------------------------------------------------- 1 | # Bind prefix to Ctrl-Space instead of Ctrl-Space on the host 2 | unbind C-b 3 | set-option -g prefix C-Space 4 | bind-key C-Space send-prefix 5 | 6 | set-window-option -g window-status-current-style fg=blue,bg=default,bold 7 | 8 | source ~/.tmux.conf.common 9 | source ~/.tmux.conf.container 10 | -------------------------------------------------------------------------------- /fish/functions/__git_cpi.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function __git_cpi -d "Interactive git cherry-pick with forgit" 6 | set branch (git bf) 7 | if test -n "$branch" 8 | git-forgit cherry_pick $branch 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /fish/functions/duf.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function duf -d "Call duf with default arguments when available" 6 | if command -q duf 7 | command duf -style ascii $argv 8 | else 9 | df -hT $argv 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /fish/functions/have_dev_kvm_access.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function have_dev_kvm_access -d "Checks if /dev/kvm is usable by the current user" 6 | python3 -c "import os, sys; sys.exit(0 if os.access('/dev/kvm', os.R_OK | os.W_OK) else 1)" 7 | end 8 | -------------------------------------------------------------------------------- /fish/functions/fisher_update.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2025 Nathan Chancellor 4 | 5 | function fisher_update -d "Run 'fisher update' after setting up _fisher_plugins for environment" 6 | __adjust_fisher_paths -c 7 | fisher update $argv 8 | __adjust_fisher_paths -H 9 | end 10 | -------------------------------------------------------------------------------- /fish/functions/gpg_key_usable.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function gpg_key_usable -d "Checks if GPG is installed and key is in keyring" 6 | command -q gpg; or return 7 | gpg --list-secret-keys --keyid-format LONG &| string match -qr 1D6B269171C01A96 8 | end 9 | -------------------------------------------------------------------------------- /fish/functions/__get_my_funcs.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2025 Nathan Chancellor 4 | 5 | function __get_my_funcs -d "Get a list of functions defined in $ENV_FOLDER/fish/functions" 6 | path basename $ENV_FOLDER/fish/functions/*.fish $PYTHON_BIN_FOLDER/* | path change-extension '' | path sort 7 | end 8 | -------------------------------------------------------------------------------- /fish/functions/ls.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function ls -d "Use eza instead of ls if it is available" -w eza 6 | if status is-interactive; and command -q eza 7 | eza $argv 8 | else 9 | command ls --color=auto $argv 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /configs/local/snazzy.js: -------------------------------------------------------------------------------- 1 | t.prefs_.set('background-color', "#282a36"); 2 | t.prefs_.set('foreground-color', "#eff0eb"); 3 | t.prefs_.set('cursor-color', "#eff0eb"); 4 | t.prefs_.set('color-palette-overrides', ["#282a36","#ff5c57","#5af78e","#f3f99d","#57c7ff","#ff6ac1","#9aedfe","#f1f1f0","#686868","#ff5c57","#5af78e","#f3f99d","#57c7ff","#ff6ac1","#9aedfe","#eff0eb"]); -------------------------------------------------------------------------------- /fish/functions/b4.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function b4 -d "Call b4 with custom environment" 6 | set -fx XDG_CACHE_HOME $XDG_FOLDER/cache 7 | set -fx XDG_CONFIG_HOME $XDG_FOLDER/config 8 | set -fx XDG_DATA_HOME $XDG_FOLDER/share 9 | command b4 $argv 10 | end 11 | -------------------------------------------------------------------------------- /fish/functions/lei.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function lei -d "Call lei with custom environment" 6 | set -fx XDG_CACHE_HOME $XDG_FOLDER/cache 7 | set -fx XDG_CONFIG_HOME $XDG_FOLDER/config 8 | set -fx XDG_DATA_HOME $XDG_FOLDER/share 9 | command lei $argv 10 | end 11 | -------------------------------------------------------------------------------- /fish/functions/remkdir.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2023 Nathan Chancellor 4 | 5 | function remkdir -d "Recreate a folder" 6 | if test (count $argv) -ne 1 7 | __print_error "remkdir only takes one argument!" 8 | return 1 9 | end 10 | 11 | rm -fr $argv 12 | and mkdir -p $argv 13 | end 14 | -------------------------------------------------------------------------------- /fish/functions/__in_nspawn.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | function __in_nspawn -d "Test if currently in a systemd-nspawn container" 6 | if command -q systemd-detect-virt 7 | test (systemd-detect-virt -c) = systemd-nspawn 8 | return 9 | end 10 | return 1 11 | end 12 | -------------------------------------------------------------------------------- /fish/functions/__stripall.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function __stripall -d "Strips all files that are not already stripped" 6 | fd -t file . $argv -x file | string match -er 'not stripped' | string split -f 1 : | while read -l file 7 | strip $file 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /mkosi/dev-debian/mkosi.postinst.d/01-setup-locales.fish.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | 3 | echo "locales locales/default_environment_locale select en_US.UTF-8" | debconf-set-selections 4 | echo "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8" | debconf-set-selections 5 | 6 | rm -f /etc/locale.gen 7 | 8 | dpkg-reconfigure --frontend noninteractive locales 9 | -------------------------------------------------------------------------------- /configs/local/Nathan.profile: -------------------------------------------------------------------------------- 1 | [Appearance] 2 | ColorScheme=snazzy 3 | Font=Iosevka Fixed SS08,9,-1,5,50,0,0,0,0,0 4 | 5 | [General] 6 | Command=/bin/fish 7 | Name=Nathan 8 | Parent=FALLBACK/ 9 | 10 | [Interaction Options] 11 | AutoCopySelectedText=true 12 | MiddleClickPasteMode=1 13 | 14 | [Scrolling] 15 | HistoryMode=2 16 | 17 | [Terminal Features] 18 | UrlHintsModifier=67108864 -------------------------------------------------------------------------------- /configs/local/snazzy.theme: -------------------------------------------------------------------------------- 1 | [Scheme] 2 | Name=Snazzy 3 | ColorCursor=#efeff0f0ebeb 4 | ColorForeground=#efeff0f0ebeb 5 | ColorBackground=#28282a2a3636 6 | ColorPalette=#28282a2a3636;#ffff5c5c5757;#5a5af7f78e8e;#f3f3f9f99d9d;#5757c7c7ffff;#ffff6a6ac1c1;#9a9aededfefe;#f1f1f1f1f0f0;#686868686868;#ffff5c5c5757;#5a5af7f78e8e;#f3f3f9f99d9d;#5757c7c7ffff;#ffff6a6ac1c1;#9a9aededfefe;#f1f1f1f1f0f0 7 | -------------------------------------------------------------------------------- /configs/b4/kbuild-am.template: -------------------------------------------------------------------------------- 1 | On ${sentdate}, ${fromname} wrote: 2 | ${quote} 3 | 4 | Applied to 5 | 6 | ${treename} ${branch} 7 | 8 | Thanks! 9 | 10 | ${summary} 11 | 12 | Please look out for regression or issue reports or other follow up 13 | comments, as they may result in the patch/series getting dropped or 14 | reverted. 15 | 16 | Best regards, 17 | -- 18 | ${signature} 19 | -------------------------------------------------------------------------------- /fish/functions/__is_tree_dirty.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | function __is_tree_dirty -d "Checks if a git tree is dirty" 6 | if test (count $argv) -gt 0 7 | set git_args -C $argv[1] 8 | end 9 | count (command git $git_args --no-optional-locks status -u --porcelain) >/dev/null 10 | end 11 | -------------------------------------------------------------------------------- /fish/functions/remkdircd.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2023 Nathan Chancellor 4 | 5 | function remkdircd -d "Recreate a folder and cd into it" 6 | if test (count $argv) -ne 1 7 | __print_error "remkdircd only takes one argument!" 8 | return 1 9 | end 10 | 11 | remkdir $argv 12 | and cd $argv 13 | end 14 | -------------------------------------------------------------------------------- /fish/completions/upd.fish: -------------------------------------------------------------------------------- 1 | complete -c upd -f -d "Update target" -a '(type upd | string match -gr "^\s+case ([a-zA-Z0-9][a-zA-Z0-9\- ]+)" | string match -rv "^(arm|aarch|x86)" | string split " " | path sort -u)' 2 | complete -c upd -f -s f -l force -d "Install package locally even if already installed via distro" 3 | complete -c upd -f -s y -l yes -d "Answer package manager prompts non-interactively" 4 | -------------------------------------------------------------------------------- /fish/functions/cbl_upd_qemu.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function cbl_upd_qemu -d "Update QEMU and boot kernels with it" 6 | cbl_bld_qemu -i -u 7 | or return 8 | 9 | cbl_lkt \ 10 | --linux-folder $CBL_SRC_P/linux \ 11 | --only-test-boot \ 12 | --targets def 13 | end 14 | -------------------------------------------------------------------------------- /fish/functions/kgtm.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function kgtm -d "Shorthand for scripts/get_maintainer.pl" 6 | if not test -x scripts/get_maintainer.pl 7 | __print_error "get_maintainer.pl does not exist" 8 | return 1 9 | end 10 | scripts/get_maintainer.pl --scm $argv 11 | end 12 | -------------------------------------------------------------------------------- /fish/functions/header.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function header -d "Prints a formatter header to signal what is being done to the user" 6 | set border "===="(for i in (seq 1 (string length $argv)); printf "="; end)"====" 7 | printf '\n\033[01;34m%s\n%s\n%s\033[0m\n\n' $border "== $argv ==" $border 8 | end 9 | -------------------------------------------------------------------------------- /python/pgo-llvm-builder/mkosi.postinst.d/01-create-builder.fish.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # Description: Create a builder account with the same UID as the user on the host for idmapping 3 | 4 | useradd -m -u $PYTHON_PGO_BUILDER_UID -U builder 5 | # ensure that git works in container at /llvm for git information in LLVM version string 6 | su builder -c 'git config --global --add safe.directory /llvm' 7 | -------------------------------------------------------------------------------- /python/pgo-llvm-builder/mkosi.postinst.d/01-modern-llvm.fish.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # Description: Download and install the latest version of LLVM from apt.llvm.org 3 | 4 | set llvm_version 20 5 | 6 | mkdir /etc/apt/trusted.gpg.d 7 | 8 | wget -O - -q https://apt.llvm.org/llvm.sh | bash -s -- $llvm_version 9 | or return 10 | 11 | ln -fsv /usr/lib/llvm-$llvm_version/bin/* /usr/local/bin 12 | -------------------------------------------------------------------------------- /fish/functions/__get_systemd_version.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2025 Nathan Chancellor 4 | 5 | function __get_systemd_version -d "Get current systemd version" 6 | if not command -q systemctl 7 | echo 0 8 | return 1 9 | end 10 | systemctl --version | string match "systemd*" | string replace -r "\D*(\d+)\D.*" '$1' 11 | end 12 | -------------------------------------------------------------------------------- /fish/functions/cbl_check_sysfs_cfi.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function cbl_check_sysfs_cfi -d "Run LTP's read_all testcase and check for CFI failures" 6 | set read_all $ENV_FOLDER/bin/(uname -m)/read_all 7 | 8 | sudo sh -c "dmesg -C && $read_all -d /proc && $read_all -d /sys && dmesg -l warn" 9 | end 10 | -------------------------------------------------------------------------------- /fish/functions/kgmbx.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function kgmbx -d "Fetch an mbox file from lore.kernel.org using b4 and open it in mutt" 6 | set msg_id $argv[1] 7 | set mbox (mktemp --suffix=.mbox) 8 | 9 | if b4 mbox -n $mbox $msg_id 10 | mutt -f $mbox 11 | rm $mbox 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /mkosi/dev-debian/mkosi.postinst.d/01-etc-use-cbl.fish.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | 3 | # This image is the default development image on arm systems but it is not on 4 | # other systems so avoid using the toolchains by default there. They can still 5 | # be accessed via absolute paths if necessary. 6 | if test $ARCHITECTURE = arm 7 | echo 1 >/etc/use-cbl 8 | else 9 | echo 0 >/etc/use-cbl 10 | end 11 | -------------------------------------------------------------------------------- /fish/functions/__git_rn.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function __git_rn -d "Get remote name from local branch" 6 | if test (count $argv) -eq 0 7 | set branch (git bn) 8 | else 9 | set branch $argv 10 | end 11 | 12 | git for-each-ref --format='%(upstream:remotename)' refs/heads/$branch 13 | end 14 | -------------------------------------------------------------------------------- /fish/functions/cbl_ci_gen_series.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2025 Nathan Chancellor 4 | 5 | function cbl_ci_gen_series -d "Regenerate series files in CBL CI repo" 6 | for dir in $CBL_GIT/continuous-integration2/patches/* 7 | pushd $dir 8 | or return 9 | 10 | path sort *.patch >series 11 | 12 | popd 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /mkosi/dev-fedora/mkosi.postinst.d/00-etc-use-cbl.fish.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | 3 | # This image is the default development image on arm64 systems but it is not on 4 | # x86_64 systems so avoid using the toolchains by default there. They can still 5 | # be accessed via absolute paths if necessary. 6 | if test $ARCHITECTURE = arm64 7 | echo 1 >/etc/use-cbl 8 | else 9 | echo 0 >/etc/use-cbl 10 | end 11 | -------------------------------------------------------------------------------- /fish/functions/cdf.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function cdf -d "cd + fzf" 6 | if command -q eza 7 | set ls_cmd eza 8 | else 9 | set ls_cmd ls 10 | end 11 | 12 | set dest (fd -t d --color=always | fzf --preview "$ls_cmd {}") 13 | 14 | if test -n "$dest" 15 | cd $dest 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /mkosi/dev-arch/mkosi.postinst.d/00-symlink-home.fish.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | 3 | # While it would be nice if everything worked fine without this symlink, there 4 | # is unfortunately some software that only uses and relies on absolute paths, 5 | # such as git worktrees. This environment will only be used with '--bind-user', 6 | # so there is no harm in unconditionally doing this. 7 | ln -fnrsv /run/host/home/nathan /home/nathan 8 | -------------------------------------------------------------------------------- /fish/functions/__get_glibc_version.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function __get_glibc_version -d "Get glibc version as a five or six digit number" 6 | PYTHONPATH=$PYTHON_LIB_FOLDER python3 -c 'import setup 7 | glibc_version = setup.get_glibc_version() 8 | print(f"{glibc_version[0]:d}{glibc_version[1]:02d}{glibc_version[2]:02d}")' 9 | end 10 | -------------------------------------------------------------------------------- /fish/functions/__git_dmb.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function __git_dmb -d "Delete merged git branches" 6 | for branch in (__git_bf) 7 | set remotename (git rn $branch) 8 | git bd $branch 9 | if test -n "$remotename" 10 | git push $remotename :$branch; or return 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /fish/functions/get_host_llvm_target.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2023 Nathan Chancellor 4 | 5 | function get_host_llvm_target -d "Get the current host architecture as an LLVM target" 6 | switch (uname -m) 7 | case aarch64 8 | echo AArch64 9 | case x86_64 10 | echo X86 11 | case '*' 12 | echo Unknown 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /fish/functions/yapff.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function yapff -d "yapf + fzf" 6 | if test (count $argv) -gt 0 7 | set files $argv 8 | else 9 | set files (fd -e py | fzf --header "Files to format" --multi --preview 'fish -c "bat {}"') 10 | test -z "$files"; and return 0 11 | end 12 | 13 | yapf $files 14 | end 15 | -------------------------------------------------------------------------------- /python/scripts/print_cmd.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | from pathlib import Path 6 | import sys 7 | 8 | sys.path.append(str(Path(__file__).resolve().parents[1])) 9 | # pylint: disable=wrong-import-position 10 | import lib.utils 11 | # pylint: enable=wrong-import-position 12 | 13 | if __name__ == '__main__': 14 | lib.utils.print_cmd(sys.argv[1:]) 15 | -------------------------------------------------------------------------------- /fish/functions/fix_wrktrs_for_nspawn.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | function fix_wrktrs_for_nspawn -d 'Fix worktree paths in gitdir files created within systemd-nspawn' 6 | PYTHONPATH=$PYTHON_FOLDER python3 -c 'import lib.utils, sys 7 | from pathlib import Path 8 | 9 | for arg in sys.argv[1:]: 10 | lib.utils.'(status function)'(Path(arg))' $argv 11 | end 12 | -------------------------------------------------------------------------------- /fish/functions/cbl_install_vm.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function cbl_install_vm -d "Wrapper for install-vm.py" 6 | __in_container_msg -h; or return 7 | 8 | set install_vm_py $CBL_GIT/containers/ci/install-vm.py 9 | 10 | if not test -f $install_vm_py 11 | cbl_clone_repo containers 12 | end 13 | 14 | $install_vm_py $argv 15 | end 16 | -------------------------------------------------------------------------------- /fish/completions/cbl_upd_krnl.fish: -------------------------------------------------------------------------------- 1 | complete -c cbl_upd_krnl -f 2 | complete -c cbl_upd_krnl -f -s r -l reboot -d "Reboot system after updating kernel" 3 | if test (__get_distro) = arch 4 | complete -c cbl_upd_krnl -f -s k -l kexec -d "Kexec system after updating kernel" 5 | 6 | set -l valid_arch_krnls {linux-,}{debug,{mainline,next}-llvm} 7 | complete -c cbl_upd_krnl -x -n "not __fish_seen_argument $valid_arch_krnls" -d Kernel -a "$valid_arch_krnls" 8 | end 9 | -------------------------------------------------------------------------------- /fish/functions/tuxmake.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function tuxmake -d "Call tuxmake with custom environment" 6 | set -fx CONTAINERS_STORAGE_CONF $ENV_FOLDER/configs/tuxmake/storage.conf 7 | set -fx XDG_CACHE_HOME $XDG_FOLDER/cache 8 | set -fx XDG_CONFIG_HOME $XDG_FOLDER/config 9 | set -fx XDG_DATA_HOME $XDG_FOLDER/share 10 | command tuxmake $argv 11 | end 12 | -------------------------------------------------------------------------------- /fish/functions/tmuxp.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function tmuxp -d "Calls tmuxp based on how it is available" 6 | if __is_system_binary tmuxp 7 | # installed via distro, just call directly 8 | command tmuxp $argv 9 | else 10 | # installed in $BIN_FOLDER, need to point PYTHONPATH to it 11 | env PYTHONPATH=$BIN_FOLDER/tmuxp tmuxp $argv 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /python/pgo-llvm-builder/mkosi.postinst.d/03-modern-binutils.fish.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | 3 | git clone https://github.com/ClangBuiltLinux/tc-build /tc-build 4 | or return 5 | 6 | set targets \ 7 | arm \ 8 | powerpc \ 9 | powerpc64 \ 10 | powerpc64le \ 11 | riscv64 \ 12 | s390x 13 | 14 | PATH=/usr/local/bin:$PATH /tc-build/build-binutils.py \ 15 | --install-folder /usr/local \ 16 | --targets $targets 17 | or return 18 | 19 | rm -fr /tc-build 20 | -------------------------------------------------------------------------------- /fish/functions/__is_shallow_clone.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function __is_shallow_clone -d "Tests if the supplied git repository is shallow" 6 | set repo $argv[1] 7 | if not test -d $repo 8 | __print_error "Repository ('$repo') cannot be found!" 9 | return 1 10 | end 11 | set git_dir (git -C $repo rev-parse --absolute-git-dir) 12 | test -e $git_dir/shallow 13 | end 14 | -------------------------------------------------------------------------------- /fish/functions/glr.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function glr -d "Get latest release of software from GitHub" 6 | if set -q GITHUB_TOKEN 7 | set -a crl_args \ 8 | -H "Accept: application/vnd.github+json" \ 9 | -H "Authorization: Bearer $GITHUB_TOKEN" 10 | end 11 | crl $crl_args "https://api.github.com/repos/$argv[1]/releases/latest" | jq -r .tag_name 12 | end 13 | -------------------------------------------------------------------------------- /fish/functions/reset_ssh_agent.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function reset_ssh_agent -d "Reset the ssh-agent" 6 | if __in_nspawn; and not test -L $HOME/.ssh/.container-ssh-agent.fish 7 | rm -frv $HOME/.ssh/.container-ssh-agent.{fish,sock} 8 | else 9 | rm -frv $HOME/.ssh/.host-ssh-agent.{fish,sock} 10 | end 11 | set -e SSH_AUTH_SOCK 12 | killall -v ssh-agent 13 | end 14 | -------------------------------------------------------------------------------- /fish/functions/__git_rf.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function __git_rf -d "git reset file" 6 | for arg in $argv 7 | switch $arg 8 | case -q --quiet 9 | set -a git_ch_args $arg 10 | case '*' 11 | set -a files $arg 12 | end 13 | end 14 | 15 | git reset -- $files &>/dev/null 16 | and git checkout $git_ch_args -- $files 17 | end 18 | -------------------------------------------------------------------------------- /fish/functions/encrypt_gpg_file.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function encrypt_gpg_file -d "Encrypts a GPG file into a location" 6 | gpg_key_cache 7 | if test (count $argv) -gt 1 8 | set input $argv[2] 9 | else 10 | set input $HOME/.$argv[1] 11 | end 12 | gpg --batch --yes --output $ENV_FOLDER/configs/common/$argv[1].gpg --encrypt --recipient natechancellor@gmail.com $input 13 | end 14 | -------------------------------------------------------------------------------- /configs/local/Nathan.dconf: -------------------------------------------------------------------------------- 1 | [/] 2 | background-color='#282a36' 3 | bold-color='#eff0eb' 4 | bold-color-same-as-fg=true 5 | font='Iosevka Fixed SS08 11' 6 | foreground-color='#eff0eb' 7 | palette=['#282a36', '#ff5c57', '#5af78e', '#f3f99d', '#57c7ff', '#ff6ac1', '#9aedfe', '#f1f1f0', '#686868', '#ff5c57', '#5af78e', '#f3f99d', '#57c7ff', '#ff6ac1', '#9aedfe', '#eff0eb'] 8 | scrollback-lines=1000000 9 | use-system-font=false 10 | use-theme-background=false 11 | use-theme-colors=false 12 | visible-name='Nathan' 13 | -------------------------------------------------------------------------------- /fish/functions/__git_sync.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function __git_sync -d "Deletes merged branches and syncs fork with upstream" 6 | if test (count $argv) -eq 0 7 | set repo (path basename $PWD) 8 | else 9 | set repo $argv[1] 10 | end 11 | 12 | git sw main; or return 13 | git pull; or return 14 | git dmb 15 | gh repo sync --force nathanchance/$repo 16 | git ru 17 | end 18 | -------------------------------------------------------------------------------- /fish/functions/vwfunc.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function vwfunc -d "View function defintion in fish with a pager" 6 | set func_file $PYTHON_SCRIPTS_FOLDER/$argv.py 7 | if test -f "$func_file" 8 | vw -c $func_file 9 | else 10 | type $argv &| bat \ 11 | --color always \ 12 | --language fish \ 13 | $BAT_PAGER_OPTS \ 14 | --style plain 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /fish/functions/setup_registries_conf.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function setup_registries_conf -d "Set up registries.conf for pull through ghcr.io cache" 6 | set registries_conf $HOME/.config/containers/registries.conf 7 | mkdir -p (path dirname $registries_conf); or return 8 | echo '[[registry]] 9 | location="ghcr.io" 10 | [[registry.mirror]] 11 | location="10.0.1.193:5002" 12 | insecure=true' >$registries_conf 13 | end 14 | -------------------------------------------------------------------------------- /configs/tmux/qemu.yml: -------------------------------------------------------------------------------- 1 | session_name: qemu 2 | windows: 3 | - window_name: nspawn and cbl_vmm 4 | focus: true 5 | layout: 61d8,269x53,0,0[269x41,0,0,57,269x11,0,42{134x11,0,42,58,134x11,135,42,59}] 6 | start_directory: '~' 7 | panes: 8 | - shell: mchsh 9 | shell_command: 10 | - cmd: ssh_vm 11 | enter: false 12 | sleep_before: 1 13 | - shell: mchsh 14 | shell_command: 15 | - cmd: cbl_vmm run -P build 16 | enter: false 17 | sleep_before: 1 18 | focus: true 19 | - shell: mchsh 20 | -------------------------------------------------------------------------------- /fish/functions/vw.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function vw -d "View file with bat" 6 | for arg in $argv 7 | switch $arg 8 | case -c --copy 9 | set -a bat_args --style plain 10 | case '*' 11 | set -a files $arg 12 | end 13 | end 14 | 15 | bat \ 16 | --color always \ 17 | $BAT_PAGER_OPTS \ 18 | $bat_args \ 19 | $files 20 | end 21 | -------------------------------------------------------------------------------- /configs/tmux/.tmux.conf.container: -------------------------------------------------------------------------------- 1 | # new window using c 2 | unbind c 3 | bind-key c new-window mchsh 4 | 5 | # open ephemeral container using E 6 | bind-key E new-window 'sd_nspawn -e' 7 | 8 | # run commands in systemd-nspawn using r 9 | bind-key r { 10 | command-prompt -p "run command (systemd-nspawn):" { 11 | new-window "sd_nspawn -r '%1'; or exec fish -l" 12 | } 13 | } 14 | 15 | # split panes into systemd-nspawn container using | and - 16 | bind-key | split-window -h mchsh 17 | bind-key - split-window -v mchsh 18 | -------------------------------------------------------------------------------- /fish/functions/fix_fish_history.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | function fix_fish_history -d "Remove NUL bytes to workaround https://github.com/fish-shell/fish-shell/issues/10300" 6 | python3 -c "from pathlib import Path 7 | fish_history = Path.home() / '.local/share/fish/fish_history' 8 | history_bytes = fish_history.read_bytes() 9 | if (nul := b'\x00') in history_bytes: 10 | fish_history.write_bytes(history_bytes.replace(nul, b''))" 11 | end 12 | -------------------------------------------------------------------------------- /fish/functions/kchp.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function kchp -d "Shorthand for scripts/checkpatch.pl" 6 | if test -n "$CHECKPATCH" 7 | set checkpatch $CHECKPATCH 8 | else 9 | set checkpatch scripts/checkpatch.pl 10 | end 11 | 12 | if not test -x $checkpatch 13 | __print_error "$checkpatch does not exist or is not executable?" 14 | return 1 15 | end 16 | 17 | $checkpatch $argv 18 | end 19 | -------------------------------------------------------------------------------- /fish/functions/decrypt_gpg_file.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function decrypt_gpg_file -d "Decrypts a GPG file into a location" 6 | gpg_key_cache 7 | if test (count $argv) -gt 1 8 | set output $argv[2] 9 | else 10 | set output $HOME/.$argv[1] 11 | end 12 | mkdir -p (path dirname $output) 13 | gpg --batch --yes --pinentry-mode loopback --output $output --decrypt $ENV_FOLDER/configs/common/$argv[1].gpg 14 | end 15 | -------------------------------------------------------------------------------- /mkosi/dev-fedora/mkosi.postinst.d/01-install-packages.fish.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | 3 | # Setup external repos 4 | curl -LSso /etc/yum.repos.d/gh-cli.repo https://cli.github.com/packages/rpm/gh-cli.repo 5 | or return 6 | 7 | echo '[tuxmake] 8 | name=tuxmake 9 | type=rpm-md 10 | baseurl=https://tuxmake.org/packages/ 11 | gpgcheck=1 12 | gpgkey=https://tuxmake.org/packages/repodata/repomd.xml.key 13 | enabled=1' >/etc/yum.repos.d/tuxmake.repo 14 | 15 | dnf update -y 16 | or return 17 | 18 | dnf install -y \ 19 | gh \ 20 | tuxmake 21 | -------------------------------------------------------------------------------- /fish/functions/cbl_lkt_for_all_llvm.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2023 Nathan Chancellor 4 | 5 | function cbl_lkt_for_all_llvm -d "Run cbl_lkt for all supported LLVM versions" 6 | for idx in (seq 1 (count $LLVM_VERSIONS_KERNEL)) 7 | set -l cbl_lkt_args $argv 8 | if test $idx -ne 1 9 | set -a cbl_lkt_args \ 10 | --llvm-prefix (korg_llvm folder -p $LLVM_VERSIONS_KERNEL[$idx]) 11 | end 12 | cbl_lkt $cbl_lkt_args; or return 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /fish/functions/b4_prep.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2023 Nathan Chancellor 4 | 5 | function b4_prep -d "Wrapper around 'b4 prep'" 6 | if test (count $argv) -ne 3 7 | __print_error "b4_prep " 8 | return 1 9 | end 10 | 11 | set repo $argv[1] 12 | set remote_branch $argv[2] 13 | set local_branch $argv[3] 14 | 15 | __in_tree kernel; or return 16 | 17 | git f $repo $remote_branch 18 | and b4 prep -f FETCH_HEAD -n $local_branch 19 | end 20 | -------------------------------------------------------------------------------- /fish/functions/tbf.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2023 Nathan Chancellor 4 | 5 | function tbf -d "Prints a build folder specific to the current directory" 6 | if test (count $argv) -eq 0 7 | set src $PWD 8 | else 9 | set src $argv 10 | end 11 | 12 | if string match -qr ^$CBL_SRC_W $src 13 | set base (string split -f 2,3 -m 2 -r / $src | string join -) 14 | else 15 | set base (path basename $src) 16 | end 17 | 18 | echo $TMP_BUILD_FOLDER/$base 19 | end 20 | -------------------------------------------------------------------------------- /fish/functions/__gen_func_completions.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2025 Nathan Chancellor 4 | 5 | function __gen_func_completions -d "Generate completions for self-created functions" 6 | __get_my_funcs | string match -er (commandline -ct) | while read -l func 7 | if test -e $PYTHON_BIN_FOLDER/$func 8 | set desc ($func -h | string match -er '^[A-Z].*$') 9 | else 10 | set desc (functions -D -v $func | tail -1) 11 | end 12 | echo $func\t$desc 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /python/pgo-llvm-builder/mkosi.postinst.d/00-modern-cmake.sh.chroot: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Description: Download and install a more modern version of cmake, which is required for newer LLVM releases 3 | 4 | set -eux 5 | 6 | cmake_version=4.2.1 7 | 8 | case "$ARCHITECTURE" in 9 | "arm64") 10 | arch=aarch64 11 | ;; 12 | "x86-64") 13 | arch=x86_64 14 | ;; 15 | esac 16 | wget -O - -q https://github.com/Kitware/CMake/releases/download/v"$cmake_version"/cmake-"$cmake_version"-linux-"$arch".tar.gz | tar -C /usr/local --strip-components=1 -xzvf - 17 | -------------------------------------------------------------------------------- /python/pgo-llvm-builder/mkosi.postinst.d/02-modern-zstd.fish.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # Description: Build and install a modern version of zstd, as Buster has 1.3.8, which has features LLVM requires behind an experimental flag. 3 | 4 | set zstd_version 1.5.7 5 | set workdir (mktemp -d) 6 | 7 | wget -O - -q https://github.com/facebook/zstd/releases/download/v$zstd_version/zstd-$zstd_version.tar.gz | tar -C $workdir --strip-components=1 -xzvf - 8 | or return 9 | 10 | for subdir in lib programs 11 | make -C $workdir/$subdir -j(nproc) install 12 | or return 13 | end 14 | 15 | rm -fr $workdir 16 | -------------------------------------------------------------------------------- /fish/functions/virsh_delete_vm.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function virsh_delete_vm -d "Remove virtual machine using virsh" 6 | set name $argv[1] 7 | 8 | if set virsh_dominfo (virsh dominfo $name 2>/dev/null) 9 | if string match -qr "State:\s+running" $virsh_dominfo 10 | virsh destroy $name 11 | end 12 | 13 | virsh undefine --nvram $name 14 | or virsh undefine $name 15 | or return 16 | 17 | virsh vol-delete --pool default $name.qcow2 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /fish/functions/cbl_bld_all.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function cbl_bld_all -d "Build latest LLVM and test it against several Linux kernels" 6 | __in_container_msg -c; or return 7 | 8 | for arg in $argv 9 | switch $arg 10 | case -l --lts -s --short 11 | set -a cbl_bld_all_krnl_args $arg 12 | end 13 | end 14 | 15 | # Build new LLVM and binutils 16 | cbl_bld_tot_tcs; or return 17 | 18 | # Build and boot kernels 19 | cbl_bld_all_krnl $cbl_bld_all_krnl_args 20 | end 21 | -------------------------------------------------------------------------------- /fish/functions/gpg_key_cache.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function gpg_key_cache -d "Prompt for GPG password so that it is cached by the agent" 6 | gpg_key_usable; or return 0 7 | status is-interactive; or return 0 8 | set num (gpg-connect-agent 'keyinfo --list' /bye 2>/dev/null | awk 'BEGIN{CACHED=0} /^S/ {if($7==1){CACHED=1}} END{if($0!=""){print CACHED} else {print "none"}}') 9 | if test "$num" = none || test "$num" = 0 10 | echo | gpg --pinentry-mode loopback --clearsign --output /dev/null 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /fish/functions/cbl_qualify_next.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function cbl_qualify_next -d "Run a series of checks to qualify new linux-next revisions" 6 | __in_container_msg -h; or return 7 | sudo true; or return 8 | 9 | set fish_trace 1 10 | 11 | uname -r 12 | 13 | systemctl --failed 14 | 15 | sudo dmesg -l warn+ 16 | 17 | sleep 5 18 | 19 | cbl_check_sysfs_cfi &>/dev/null 20 | if test $status -eq 0 21 | sudo dmesg -l warn,err 22 | else 23 | cbl_check_sysfs_cfi 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /configs/tmux/test.yml: -------------------------------------------------------------------------------- 1 | session_name: main 2 | windows: 3 | - window_name: btop and machinectl shell 4 | panes: 5 | - btop 6 | - shell: mchsh 7 | shell_command: 8 | - cmd: cbl_bld_all 9 | enter: false 10 | sleep_before: 1 11 | - window_name: host and machinectl shell 12 | layout: 775f,269x53,0,0[269x41,0,0,3,269x11,0,42,4] 13 | focus: true 14 | panes: 15 | - shell_command: 16 | - cmd: cbl_qualify_next 17 | enter: false 18 | focus: true 19 | - shell: have_dev_kvm_access; and mchsh 20 | shell_command: 21 | - cmd: cbl_test_kvm vmm 22 | enter: false 23 | sleep_before: 1 24 | -------------------------------------------------------------------------------- /fish/functions/clone_aur_repos.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function clone_aur_repos -d "Clone repos from AUR to build packages locally" 6 | set packages \ 7 | debhelper \ 8 | modprobed-db \ 9 | opendoas-sudo \ 10 | shellcheck-bin 11 | 12 | for package in $packages 13 | set repo $SRC_FOLDER/packaging/pkg/$package 14 | if not test -d $repo 15 | mkdir -p (path dirname $repo) 16 | git clone https://aur.archlinux.org/$package.git $repo 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /mkosi/dev-fedora/mkosi.postinst.d/00-swap-doas-for-sudo.fish.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | 3 | rm -f /etc/dnf/protected.d/sudo.conf 4 | 5 | if dnf list --installed sudo &>/dev/null 6 | dnf remove -y sudo 7 | or return 8 | end 9 | 10 | ln -frsv /usr/{bin/doas,local/bin/sudo} 11 | 12 | set doas_conf /etc/doas.conf 13 | echo 'permit nopass nathan as root' >$doas_conf 14 | chmod 600 $doas_conf 15 | git diff --no-index /dev/null $doas_conf 16 | 17 | set doas_pam /etc/pam.d/doas 18 | cp $doas_pam{,.new} 19 | echo 'session optional pam_umask.so' >>$doas_pam.new 20 | git diff --no-index $doas_pam{,.new} 21 | mv $doas_pam{.new,} 22 | -------------------------------------------------------------------------------- /fish/functions/updfull.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function updfull -d "Update host machine, shell environment, and main development container" 6 | __in_container_msg -h 7 | or return 8 | 9 | for arg in $argv 10 | switch $arg 11 | case -s --skip-container 12 | set os_target os-no-container 13 | end 14 | end 15 | if not set -q os_target 16 | set os_target os 17 | end 18 | 19 | upd -y \ 20 | env \ 21 | fisher \ 22 | $os_target \ 23 | vim 24 | end 25 | -------------------------------------------------------------------------------- /mkosi/dev-debian/mkosi.conf.d/00-cross-compilers.conf: -------------------------------------------------------------------------------- 1 | [Content] 2 | Packages=binutils-aarch64-linux-gnu 3 | binutils-arm-linux-gnueabi 4 | binutils-arm-linux-gnueabihf 5 | binutils-mips-linux-gnu 6 | binutils-mipsel-linux-gnu 7 | binutils-riscv64-linux-gnu 8 | binutils-s390x-linux-gnu 9 | gcc-aarch64-linux-gnu 10 | gcc-mips-linux-gnu 11 | gcc-mipsel-linux-gnu 12 | gcc-riscv64-linux-gnu 13 | gcc-s390x-linux-gnu 14 | gcc-arm-linux-gnueabi 15 | gcc-arm-linux-gnueabihf 16 | [Match] 17 | Architecture=|arm64 18 | Architecture=|x86-64 19 | -------------------------------------------------------------------------------- /mkosi/dev-fedora/mkosi.postinst.d/00-fedora40-crypto-policy.fish.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | 3 | set src /usr/share/crypto-policies/policies/DEFAULT.pol 4 | set dst /etc/crypto-policies/policies/MYDEFAULT.pol 5 | 6 | # FEDORA40 contains this change but it has been removed upstream 7 | # so append it to the default policy and use it. 8 | cp -v $src $dst 9 | echo ' 10 | # Allow SHA1 for kernels that default to it for module signing 11 | # __openssl_block_sha1_signatures = 0' >>$dst 12 | git diff --no-index $src $dst 13 | 14 | # See comment in mkosi.conf as to why this is necessary 15 | update-crypto-policies --set (path basename $dst | path change-extension '') 16 | -------------------------------------------------------------------------------- /fish/functions/newfunc.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function newfunc -d "Generate and edit new function fish" 6 | for func_name in $argv 7 | set func_file $ENV_FOLDER/fish/functions/$func_name.fish 8 | 9 | if test -f $func_file 10 | __print_error "$func_name already exists!" 11 | return 1 12 | end 13 | 14 | echo "#!/usr/bin/env fish 15 | # SPDX-License-Identifier: MIT 16 | # Copyright (C) "(date +%Y)" Nathan Chancellor 17 | 18 | function $func_name 19 | end" >$func_file 20 | edfunc $func_file 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /fish/functions/__is_installed.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function __is_installed -d "Checks if a package is installed depending on the package manager" 6 | if command -q pacman 7 | pacman -Q $argv &>/dev/null 8 | else if command -q dnf 9 | dnf list --installed $argv &>/dev/null 10 | else if command -q dpkg 11 | dpkg -s $argv &>/dev/null 12 | else if command -q apk 13 | apk info -e $argv &>/dev/null 14 | else 15 | __print_error "__is_installed() does not handle this package manager" 16 | return 1 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /fish/functions/upd_repo_pkg.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function upd_repo_pkg -d "Update package in personal Arch Linux repo" 6 | set database nathan.db.tar.gz 7 | if not test -f $database 8 | __print_error "Working directory should have $database!" 9 | return 1 10 | end 11 | 12 | repo-add $database $argv 13 | 14 | if test -L nathan.db 15 | rm -v nathan.db 16 | cp -v nathan.db{.tar.gz,} 17 | end 18 | 19 | if test -L nathan.files 20 | rm -v nathan.files 21 | cp -v nathan.files{.tar.gz,} 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /fish/functions/__is_system_binary.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2025 Nathan Chancellor 4 | 5 | function __is_system_binary -d "Checks if command is a system binary (installed from a package manager)" 6 | set binary $argv[1] 7 | if not command -q $binary 8 | # cannot be a system binary if it is not installed 9 | return 1 10 | end 11 | 12 | # This is not foolproof but it will cover a good number of cases 13 | if test $LOCATION = mac 14 | set regex /opt/homebrew/bin/ 15 | else 16 | set regex /usr/s?bin/ 17 | end 18 | command -v $binary | string match -qr ^$regex 19 | end 20 | -------------------------------------------------------------------------------- /pkgbuilds/tio/PKGBUILD: -------------------------------------------------------------------------------- 1 | # Maintainer: Nathan Chancellor 2 | 3 | pkgname=tio 4 | pkgver=3.9 5 | pkgrel=1 6 | pkgdesc="A simple serial device I/O tool" 7 | arch=(x86_64) 8 | url="https://tio.github.io/" 9 | license=(GPL-2.0-or-later) 10 | depends=(glib2 glibc lua) 11 | makedepends=(meson) 12 | optdepends=(bash-completion) 13 | source=("https://github.com/$pkgname/$pkgname/releases/download/v$pkgver/$pkgname-$pkgver.tar.xz") 14 | sha256sums=('06fe0c22e3e75274643c017928fbc85e86589bc1acd515d92f98eecd4bbab11b') 15 | 16 | build() { 17 | arch-meson "$pkgname-$pkgver" build 18 | meson compile -C build 19 | } 20 | 21 | package() { 22 | meson install -C build --destdir "$pkgdir" 23 | } 24 | -------------------------------------------------------------------------------- /fish/functions/clean_old_kernels.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function clean_old_kernels -d "Clean up old installed kernels" 6 | set distro (__get_distro) 7 | switch $distro 8 | case almalinux fedora rocky 9 | set -l kernels (rpm -q kernel{,-{core,modules}} | string match -rv (uname -r | string replace -a - _) | string replace -a .(uname -m) "" | fzf -m) 10 | if test -n "$kernels" 11 | sudo dnf remove -y $kernels 12 | end 13 | case '*' 14 | __print_error "No support for '$distro'!" 15 | return 1 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /fish/functions/__in_container.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function __in_container -d "Checks if command is being run in a container" 6 | if command -q systemd-detect-virt 7 | set virt (systemd-detect-virt -c) 8 | switch $virt 9 | case none 10 | return 1 11 | case '*' 12 | if test $virt = lxc; and __in_orb 13 | return 1 14 | end 15 | return 0 16 | end 17 | else 18 | set -q container 19 | or test -f /run/.containerenv 20 | or test -f /.dockerenv 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /fish/functions/__in_tree.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function __in_tree -d "Checks if we are in a particular source tree" 6 | set type $argv[1] 7 | if test -z "$type" 8 | __print_error "No type provided?" 9 | return 128 10 | end 11 | 12 | switch $type 13 | case kernel 14 | set file Makefile 15 | set msg "a $type" 16 | case llvm 17 | set file llvm/CMakeLists.txt 18 | set msg "an "(string upper $type) 19 | end 20 | 21 | if not test -f $file 22 | __print_error "You do not appear to be in $msg tree!" 23 | return 1 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /fish/functions/b4_from_next.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | function b4_from_next -d "Run b4_prep after interactively selecting a base from Next/Trees" 6 | if not test -e Next/Trees 7 | __print_error "Not in a -next tree?" 8 | return 1 9 | end 10 | 11 | set parts (fzf series 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /fish/completions/edcomp.fish: -------------------------------------------------------------------------------- 1 | function __edcomp_gen_args 2 | path filter -f $ENV_FOLDER/fish/completions/* | path basename | path change-extension "" | string match -er (commandline -ct) | while read -l item 3 | if test -e $ENV_FOLDER/fish/functions/$item.fish 4 | set desc (functions -Dv $item | tail -n1) 5 | else if test -e $PYTHON_BIN_FOLDER/$item 6 | set desc ($item -h | string match -er '^[A-Z]') 7 | else 8 | set desc 'external command' 9 | end 10 | echo $item\t$desc 11 | end 12 | end 13 | 14 | complete -c edcomp -x -a "(__edcomp_gen_args)" 15 | complete -c edcomp -f -s r -l reload -d "Reload fish files after editing function" 16 | complete -c edcomp -f -s f -l fzf -d "Select functions to edit using fzf" 17 | -------------------------------------------------------------------------------- /fish/functions/prep_config.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2023 Nathan Chancellor 4 | 5 | function prep_config -d "Prepare kernel configuration in build folder" 6 | set src_cfg $argv[1] 7 | 8 | set bld $argv[2] 9 | if test -z "$bld" 10 | set bld (tbf) 11 | end 12 | set dst_cfg $bld/.config 13 | 14 | if string match -qr 'http(s?)://' $src_cfg 15 | set url true 16 | else if test -e $src_cfg 17 | set local true 18 | else 19 | __print_error "Could not handle $src_cfg?" 20 | return 1 21 | end 22 | 23 | remkdir $bld 24 | if set -q local 25 | cp -v $src_cfg $dst_cfg 26 | end 27 | if set -q url 28 | crl -o $dst_cfg $src_cfg 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /python/pgo-llvm-builder/mkosi.postinst.d/02-modern-ninja.fish.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # Description: Build and install a more modern version of ninja, which is required for newer LLVM and cmake releases 3 | 4 | set ninja_version 1.13.2 5 | set workdir (mktemp -d) 6 | 7 | begin 8 | # Download source code 9 | wget -O - -q https://github.com/ninja-build/ninja/archive/refs/tags/v$ninja_version.tar.gz | tar -C $workdir --strip-components=1 -xzvf - 10 | 11 | # Download build dependencies 12 | and apt update -y 13 | and apt build-dep -y ninja-build 14 | 15 | # Configure and build 16 | and pushd $workdir 17 | and ./configure.py --bootstrap 18 | and install -Dvm755 ninja /usr/local/bin/ninja 19 | and popd 20 | end 21 | or return 22 | 23 | rm -fr $workdir 24 | -------------------------------------------------------------------------------- /configs/tmux/next.yml: -------------------------------------------------------------------------------- 1 | session_name: linux-next updates 2 | windows: 3 | - window_name: main 4 | focus: true 5 | layout: tiled 6 | panes: 7 | - shell: mchsh 8 | shell_command: 9 | - cmd: cbl_upd_krnl next-llvm 10 | sleep_before: 1 11 | start_directory: $CBL_SRC_P/linux-next-llvm 12 | enter: false 13 | focus: true 14 | - shell: mchsh 15 | shell_command: 16 | - cmd: cbl_rb_fd 17 | sleep_before: 1 18 | start_directory: $CBL_SRC_P/fedora 19 | enter: false 20 | - shell: mchsh 21 | shell_command: 22 | - cmd: vim $PY_L/kernel.py 23 | sleep_before: 1 24 | enter: false 25 | - shell: mchsh 26 | shell_command: 27 | - cmd: cbl_upd_src p n 28 | sleep_before: 1 29 | start_directory: $CBL_SRC_P/linux-next 30 | enter: false 31 | -------------------------------------------------------------------------------- /fish/functions/cbl_create_tc_tar.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2023 Nathan Chancellor 4 | 5 | function cbl_create_tc_tar -d "Create tarball with latest toolchains in $CBL_TC" 6 | if test -L (path dirname $CBL_TC_BNTL); and test -L (path dirname $CBL_TC_LLVM) 7 | set tar_dst $CBL_TC/latest-cbl-tc.tar.zst 8 | tar \ 9 | --create \ 10 | --directory $CBL_TC \ 11 | --file $tar_dst \ 12 | --zstd \ 13 | (realpath {$CBL_TC_BNTL_STORE,$CBL_TC_LLVM_STORE}-latest | string replace $CBL_TC/ '') 14 | printf '\nTarball is available at: %s\n' $tar_dst 15 | else 16 | __print_error "Either binutils or LLVM is not built in $CBL_TC?" 17 | return 1 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /fish/functions/cbl_rb_fd.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function cbl_rb_fd -d "Rebase generic Fedora kernel on latest linux-next" 6 | __in_container_msg -c 7 | or return 8 | 9 | # Prepare kernel source 10 | PYTHONPATH=$PYTHON_FOLDER/lib python3 -c "import kernel; kernel.prepare_source('fedora')" 11 | or return 12 | 13 | # Build kernel 14 | set lnx_src $CBL_SRC_P/fedora 15 | set lnx_bld (tbf $lnx_src) 16 | fish -c "cd $lnx_src; and cbl_bld_krnl_rpm --cfi --lto --slim-arm64-platforms arm64" 17 | or return 18 | 19 | # Copy kernel configuration to easily see changes from Fedora or Linux upstream 20 | cp -v $lnx_bld/.config $ENV_FOLDER/configs/kernel/fedora-arm64.config 21 | end 22 | -------------------------------------------------------------------------------- /fish/functions/updall.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function updall -d "Update binaries in $BIN_FOLDER" 6 | for arg in $argv 7 | switch $arg 8 | case -n --no-os 9 | set os false 10 | end 11 | end 12 | 13 | if test "$os" != false 14 | set targets os 15 | end 16 | 17 | set -a targets \ 18 | bat \ 19 | btop \ 20 | diskus \ 21 | duf \ 22 | eza \ 23 | fd \ 24 | fisher \ 25 | fzf \ 26 | repo \ 27 | rg \ 28 | tmuxp \ 29 | vim \ 30 | zoxide 31 | 32 | if __is_location_primary 33 | set -a targets forks 34 | end 35 | 36 | upd $targets 37 | end 38 | -------------------------------------------------------------------------------- /fish/completions/cbl_bld_krnl_pkg.fish: -------------------------------------------------------------------------------- 1 | complete -c cbl_bld_krnl_pkg -f -l cfi -d "Enable CONFIG_CFI" 2 | complete -c cbl_bld_krnl_pkg -f -l cfi-permissive -d "Enable CONFIG_CFI_PERMISSIVE" 3 | complete -c cbl_bld_krnl_pkg -f -l lto -d "Enable CONFIG_LTO_CLANG_THIN" 4 | complete -c cbl_bld_krnl_pkg -f -s g -l gcc -d "Build with GCC instead of LLVM" 5 | complete -c cbl_bld_krnl_pkg -f -s l -l localmodconfig -d "Call localmodconfig during configuration" 6 | complete -c cbl_bld_krnl_pkg -f -s m -l menuconfig -d "Call menuconfig during configuration" 7 | complete -c cbl_bld_krnl_pkg -f -l no-werror -d "Disable CONFIG_WERROR" 8 | complete -c cbl_bld_krnl_pkg -x -s R -l ref -d "Reference to base kernel tree on" 9 | complete -c cbl_bld_krnl_pkg -f -d "Positional arguments" -a '(string join \n -- $VALID_ARCH_KRNLS\t"Kernel package")' 10 | -------------------------------------------------------------------------------- /fish/functions/cbl_install_tc_tar.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2023 Nathan Chancellor 4 | 5 | function cbl_install_tc_tar -d "Install a toolchain tarball generated with create_cbl_tc_tar" 6 | if test (count $argv) -lt 1 7 | __print_error "Provide toolchain tarball as argument!" 8 | return 1 9 | end 10 | set tar $argv[1] 11 | 12 | set tcs (tar -tf $tar | python3 -c "import re, sys 13 | print('\n'.join({ 14 | m[0] 15 | for m 16 | in re.findall('^((binutils|llvm)/[0-9A-Za-z-_]+)/', 17 | sys.stdin.read(), 18 | flags=re.M) 19 | }))") 20 | mkdir -p $CBL_TC 21 | tar -C $CBL_TC -axf $tar 22 | for tc in $tcs 23 | cbl_upd_software_symlinks (path dirname $tc) $CBL_TC/$tc 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /fish/functions/klog.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | function klog -d "View kernel log with bat" -w dmesg 6 | __in_container_msg -h 7 | or return 8 | 9 | for arg in $argv 10 | set -a dmesg_args $arg 11 | switch $arg 12 | case -w --follow -W --follow-new 13 | set provides_pager true 14 | end 15 | end 16 | 17 | set dmesg_cmd \ 18 | sudo dmesg \ 19 | --human \ 20 | --color=always \ 21 | $dmesg_args 22 | 23 | if set -q provides_pager 24 | $dmesg_cmd 25 | else 26 | # Ask for password first to avoid messing up bat 27 | sudo true 28 | or return 29 | 30 | $dmesg_cmd &| bat --style plain 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /fish/functions/prep_vm_archinstall.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | function prep_vm_archinstall -d "Prepare archinstall files for virtual machine installation" 6 | read -P 'Password for virtual machine user: ' -s user_pass 7 | 8 | ssh_vm root copy-id 9 | or return 10 | 11 | set creds /tmp/creds.json 12 | echo '{ 13 | "!root-password": null, 14 | "!users": [ 15 | { 16 | "!password": "'$user_pass'", 17 | "sudo": true, 18 | "username": "nathan" 19 | } 20 | ] 21 | }' >$creds 22 | 23 | ssh_vm root transfer $ENV_FOLDER/configs/archinstall/vm_config.json :/root/config.json 24 | ssh_vm root transfer $creds :/root/(path basename $creds) 25 | 26 | rm -f $creds 27 | end 28 | -------------------------------------------------------------------------------- /fish/functions/create_folder_tar.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function create_folder_tar -d "Create zstd compressed tarball of a folder" 6 | set folder $argv[1] 7 | if not test -d $folder 8 | __print_error "$folder could not be found or is not a folder!" 9 | return 1 10 | end 11 | 12 | set output $TMP_FOLDER/(path basename $folder)-(date +%Y-%m-%d-%H-%M).tar.zst 13 | 14 | tar \ 15 | --create \ 16 | --exclude-from $ENV_FOLDER/configs/common/tar-excludes \ 17 | --directory (path dirname $folder) \ 18 | --file $output \ 19 | --zstd \ 20 | (path basename $folder) 21 | 22 | echo 23 | echo "File is now available at: "(string replace $TMP_FOLDER '$TMP_FOLDER' $output) 24 | end 25 | -------------------------------------------------------------------------------- /fish/functions/__get_distro.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function __get_distro -d "Prints a short name for the currently running distro" 6 | if test "$LOCATION" = mac 7 | echo macos 8 | else 9 | for file in /etc/os-release /usr/lib/os-release 10 | test -e $file; and break 11 | end 12 | set os_release_id (string match -gr '^ID="?([^"]+)"?$' 6 | 7 | function __git_bf -d "Use fzf on git branch output" 8 | set preview "git log {1} --graph --pretty=format:'-%C(auto)%h%d %s %C(black)%C(bold)%cr%Creset' --color=always --abbrev-commit --date=relative" 9 | set fzf_opts \ 10 | --ansi \ 11 | --header-lines=1 \ 12 | --multi \ 13 | --no-mouse \ 14 | --no-sort \ 15 | --preview \"$preview\" \ 16 | --tiebreak=index 17 | 18 | git branch --all --color=always | \ 19 | LC_ALL=C sort -k1.1,1.1 -rs | \ 20 | FZF_DEFAULT_OPTS="$fzf_opts" fzf | awk '{print $1}' 21 | end 22 | -------------------------------------------------------------------------------- /fish/functions/__in_container_msg.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function __in_container_msg -d "Reports an error based on where command is attempting to be run" 6 | for arg in $argv 7 | switch $arg 8 | case -c --container 9 | if __in_container 10 | return 0 11 | else 12 | __print_error "Command needs to be run in a container!" 13 | return 1 14 | end 15 | case -h --host 16 | if __in_container 17 | __print_error "Command needs to be run in the host OS!" 18 | return 1 19 | else 20 | return 0 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | # Run a bunch of lint checks to keep me honest 2 | name: Linting 3 | on: 4 | push: 5 | paths: 6 | - '**.fish' 7 | - '**.py' 8 | - '**.sh' 9 | pull_request: 10 | paths: 11 | - '**.fish' 12 | - '**.py' 13 | - '**.sh' 14 | jobs: 15 | fish: 16 | uses: nathanchance/actions-workflows/.github/workflows/fish_format.yml@main 17 | python: 18 | strategy: 19 | fail-fast: false 20 | matrix: 21 | version: ['3.14', '3.13', '3.12', '3.11', '3.10'] 22 | uses: nathanchance/actions-workflows/.github/workflows/python_lint.yml@main 23 | with: 24 | python_version: ${{ matrix.version }} 25 | shellcheck: 26 | uses: ClangBuiltLinux/actions-workflows/.github/workflows/shellcheck.yml@main 27 | shfmt: 28 | uses: ClangBuiltLinux/actions-workflows/.github/workflows/shfmt.yml@main 29 | -------------------------------------------------------------------------------- /fish/functions/create_repo_tar.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function create_repo_tar -d "Create a tarball of a git repo from just the tracked files" 6 | if test (count $argv) -gt 0 7 | set repo $argv[1] 8 | if not test -d $repo 9 | __print_error "$repo does not exist?" 10 | return 1 11 | end 12 | else 13 | set repo (git root) 14 | end 15 | 16 | set output $repo/dist/(path basename $repo)-(date +%Y-%m-%d-%H-%M).tar.zst 17 | 18 | mkdir -p (path dirname $output) 19 | tar \ 20 | --create \ 21 | --directory $repo \ 22 | --file $output \ 23 | --zstd \ 24 | (git -C $repo ls-files) 25 | echo '*' >(path dirname $output)/.gitignore 26 | 27 | echo "File is now available at: $output" 28 | end 29 | -------------------------------------------------------------------------------- /fish/functions/tmxa.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function tmxa -d "Attach to a tmux session if it exists, start a new one if not" 6 | if test -z "$TMUX" 7 | switch $LOCATION 8 | case aadp chromebox framework-desktop honeycomb test-{desktop-intel-{11700,n100},desktop-amd-8745HS,laptop-intel} 9 | set tmuxp_cfg test 10 | case generic 11 | if __in_orb 12 | set tmuxp_cfg primary 13 | else 14 | set tmuxp_cfg generic 15 | end 16 | case hetzner workstation 17 | set tmuxp_cfg primary 18 | end 19 | if set -q tmuxp_cfg 20 | tmuxp load --yes $tmuxp_cfg 21 | else 22 | tmux new-session -AD -s main 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /fish/functions/edcomp.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2025 Nathan Chancellor 4 | 5 | function edcomp -d "Edit completions in $ENV_FOLDER" 6 | for arg in $argv 7 | switch $arg 8 | case -f --fzf 9 | set fzf true 10 | case -r --reload 11 | set reload true 12 | case '*' 13 | set -a comps_to_edit $arg 14 | end 15 | end 16 | 17 | set comp_dir $ENV_FOLDER/fish/completions 18 | if test "$fzf" = true 19 | set -a comps_to_edit (path filter -f $comp_dir/* | path basename | path change-extension '' | fzf -m --preview "cat $comp_dir/{}.fish") 20 | end 21 | 22 | set files_to_edit $comp_dir/$comps_to_edit.fish 23 | if test -n "$files_to_edit" 24 | vim -p $files_to_edit 25 | if test "$reload" = true 26 | rld 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /fish/functions/lsfuncs.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | function lsfuncs -d "List function names and descriptions from $ENV_FOLDER/fish/functions" 6 | begin 7 | set column_width 30 8 | 9 | set border (string repeat -n $column_width -N -) 10 | 11 | printf '| %s | %s |\n' $border $border 12 | printf '| %-'$column_width's | %-'$column_width's |\n' Function Description 13 | printf '| %s | %s |\n' $border $border 14 | 15 | for func in (__get_my_funcs) 16 | if test -e $PYTHON_BIN_FOLDER/$func 17 | set desc ($func -h | string match -er '^[A-Z].*$') 18 | else 19 | set desc (functions -D -v $func | tail -1) 20 | end 21 | printf '| %-'$column_width's | %s\n' $func $desc 22 | end 23 | end &| bat $BAT_PAGER_OPTS --style plain 24 | end 25 | -------------------------------------------------------------------------------- /mkosi/dev-fedora/mkosi.postinst.d/00-install-edk2-arm.fish.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # Description: Download and install edk2-arm from Debian, as the Fedora package was sunset: 3 | # https://src.fedoraproject.org/rpms/edk2/c/53fa21dafcef14a7d264a89c2977cdbef58df770 4 | 5 | if test "$ARCHITECTURE" != arm64 6 | return 0 7 | end 8 | 9 | set edk2_ver (curl -fLSs 'https://salsa.debian.org/qemu-team/edk2/-/raw/debian/latest/debian/changelog?ref_type=heads' | string match -gr '^edk2 \((.*)\) unstable;' | head -1) 10 | or return 11 | set edk2_deb qemu-efi-arm_"$edk2_ver"_all.deb 12 | 13 | set workdir (mktemp -d) 14 | and curl -fLSso $workdir/$edk2_deb http://http.us.debian.org/debian/pool/main/e/edk2/$edk2_deb 15 | and ar x --output $workdir $workdir/$edk2_deb 16 | and tar -C $workdir -xJf $workdir/data.tar.xz 17 | and install -Dvm644 $workdir/usr/share/AAVMF/AAVMF32_CODE.fd /usr/share/edk2/arm/QEMU_EFI.fd 18 | and rm -fr $workdir 19 | -------------------------------------------------------------------------------- /python/ruff.toml: -------------------------------------------------------------------------------- 1 | target-version = 'py39' 2 | 3 | [lint] 4 | select = [ 5 | 'A', # flake8-builtins 6 | 'ARG', # flake8-unused-arguments 7 | 'B', # flake8-bugbear 8 | 'C4', # flake8-comprehensions 9 | 'COM', # flake8-commas 10 | 'E', # pycodestyle 11 | 'F', # pyflakes 12 | 'PIE', # flake8-pie 13 | 'PL', # pylint 14 | 'PTH', # flake8-use-pathlib 15 | 'RET', # flake8-return 16 | 'RUF', # ruff 17 | 'S', # flake8-bandit 18 | 'SIM', # flake8-simplify 19 | 'SLF', # flake8-self 20 | 'UP', # pyupgrade 21 | 'W', # pycodestyle 22 | ] 23 | ignore = [ 24 | 'E501', # line-too-long 25 | 'PLR0911', # too-many-return-statments 26 | 'PLR0912', # too-many-branches 27 | 'PLR0913', # too-many-arguments 28 | 'PLR0915', # too-many-statements 29 | 'PLR2004', # magic-value-comparison 30 | 'S603', # subprocess-without-shell-equals-true 31 | 'S607', # start-process-with-partial-path 32 | ] 33 | -------------------------------------------------------------------------------- /fish/functions/hugo_serve.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function hugo_serve -d "Runs 'hugo server' based on WSL's IP address" -w hugo 6 | if not command -q ip 7 | __print_error "ip could not be found, please install it!" 8 | return 1 9 | end 10 | 11 | for arg in $argv 12 | switch $arg 13 | case -t --tailscale 14 | set intf tailscale 15 | case '*' 16 | set -a hugo_args $arg 17 | end 18 | end 19 | set -q intf 20 | or set intf en 21 | 22 | set ip (ip addr | string match -er $intf | string match -er inet | string match -r '\d+\.\d+.\d+\.\d+') 23 | if test -z "$ip" 24 | __print_error "ip not found?" 25 | return 1 26 | end 27 | 28 | set -a hugo_args \ 29 | --baseURL=$ip \ 30 | --bind=0.0.0.0 31 | 32 | hugo server $hugo_args 33 | end 34 | -------------------------------------------------------------------------------- /fish/functions/cbl_gen_vm_boot_files.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function cbl_gen_vm_boot_files -d "Generate files needed to boot local compiled kernels with cbl_vmm.py" 6 | # Make sure we are not running our own kernel, which might not have modules enabled 7 | if string match -qr '\(nathan@' (cat /proc/version) 8 | __print_error "It seems like a non-stock kernel is booted?" 9 | return 1 10 | end 11 | 12 | # Make sure all modules the virtual machine might need are loaded (virtiofs, etc) 13 | ls $HOST_FOLDER 1>/dev/null; or return 14 | 15 | # Create kernel_files folder 16 | set kernel_folder $HOST_FOLDER/kernel_files 17 | mkdir -p $kernel_folder 18 | 19 | # Get cmdline and lsmod 20 | cat /proc/cmdline >$kernel_folder/cmdline 21 | lsmod >$kernel_folder/lsmod 22 | 23 | # Generate initrd 24 | __gen_slim_initrd $kernel_folder 25 | end 26 | -------------------------------------------------------------------------------- /fish/functions/gh_run.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function gh_run -d "Run GitHub Actions Workflow" 6 | if test (count $argv) -lt 3 7 | __print_error "Expected repo, branch name, and workflow as arguments, in that order!" 8 | return 1 9 | end 10 | 11 | set repo $argv[1] 12 | set branch $argv[2] 13 | set workflow $argv[3] 14 | set run_args $argv[4..-1] 15 | 16 | gh workflow run \ 17 | --ref $branch \ 18 | --repo $repo \ 19 | $run_args \ 20 | $workflow 21 | 22 | # Make sure that 'gh run list' call succeeds 23 | sleep 3 24 | 25 | set json_key databaseId 26 | set workflow_id (gh run list \ 27 | --json $json_key \ 28 | --jq .[].$json_key \ 29 | --limit 1 \ 30 | --repo $repo \ 31 | --workflow $workflow) 32 | 33 | gh run view \ 34 | --repo $repo \ 35 | $workflow_id 36 | end 37 | -------------------------------------------------------------------------------- /fish/functions/mchsh.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | # 'machinectl shell' does not return the error code of the called process, so this should only be used interactively. 6 | function mchsh -d "Wrapper around 'machinectl shell'" 7 | __in_container_msg -h 8 | or return 9 | 10 | for arg in $argv 11 | switch $arg 12 | case '*@*' 13 | set user_host $arg 14 | case '*' 15 | set -a mchsh_args $arg 16 | end 17 | end 18 | if not set -q user_host 19 | set user_host $USER@$DEV_IMG 20 | end 21 | if not set -q mchsh_args 22 | set mchsh_args -l 23 | end 24 | 25 | # Use fish's --init-commands to drop into the current working directory, 26 | # instead of $HOME, which is not really useful if working on the host and 27 | # wanting to drop into the guest to work. 28 | machinectl shell -q $user_host $SHELL -C 'cd '(nspawn_path -c $PWD) $mchsh_args 29 | end 30 | -------------------------------------------------------------------------------- /pkgbuilds/python-pebble/PKGBUILD: -------------------------------------------------------------------------------- 1 | # Maintainer: Nathan Chancellor 2 | pkgname=python-pebble 3 | _name=${pkgname#python-} 4 | pkgver=5.1.3 5 | pkgrel=1 6 | pkgdesc="A neat API to manage threads and processes within an application" 7 | arch=('any') 8 | url="https://github.com/noxdafox/pebble" 9 | license=(LGPL-3.0-or-later) 10 | depends=(python) 11 | makedepends=( 12 | python-build 13 | python-installer 14 | python-setuptools 15 | python-wheel 16 | ) 17 | checkdepends=(python-pytest) 18 | source=("$pkgname-$pkgver.tar.gz::https://github.com/noxdafox/${_name}/archive/refs/tags/$pkgver.tar.gz") 19 | sha256sums=('8304af95d4d43d73c4f648403114be8cefcb9527d27488bb9e974ea6cde2661a') 20 | 21 | build() { 22 | cd "${_name}-$pkgver" 23 | 24 | python -m build --wheel --no-isolation 25 | } 26 | 27 | check() { 28 | cd "${_name}-$pkgver" 29 | 30 | PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=. pytest 31 | } 32 | 33 | package() { 34 | cd "${_name}-$pkgver" 35 | 36 | python -m installer --destdir="$pkgdir" dist/*.whl 37 | } 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # env 2 | 3 | This repository contains my shell environment scripts and configurations. The layout is as follows: 4 | 5 | * `bash/`: Files written for `bash`, mostly aimed at bootstrapping environments from the `root` user. 6 | * `configs/`: Configuration files, such as for terminal programs, editors, and `tmux`. 7 | * `fish/`: Files written for `fish`, my primary shell program. 8 | * `mkosi/`: Files for use with `mkosi` to generate chroots for development, intended to be run with `systemd-nspawn`. 9 | * `pkgbuilds/`: My collection of PKGBUILD files for Arch Linux. 10 | * `python/`: My collection of Python scripts and projects. 11 | 12 | ## Support 13 | 14 | You can take and use anything in this repo freely, as it is licensed under the MIT License. However, if you have any issues with using them, I do not provide any type of support, as I tailor everything in this repo entirely for my own set up and use cases. I have done my best to comment everything so it can easily be understood. I will accept pull requests if you feel something could be better! 15 | -------------------------------------------------------------------------------- /fish/functions/__adjust_fisher_paths.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | function __adjust_fisher_paths -d "Translate paths in _fisher_plugins to and from systemd-nspawn paths" 6 | if not __in_nspawn 7 | return 8 | end 9 | 10 | set mode $argv[1] 11 | 12 | # Constants 13 | set run_host /run/host 14 | set host_home /home/$USER 15 | set guest_home $run_host$host_home 16 | 17 | for idx in (seq 1 (count $_fisher_plugins)) 18 | set val $_fisher_plugins[$idx] 19 | switch $mode 20 | case -c --container 21 | if string match -qr ^$host_home $val 22 | set _fisher_plugins[$idx] (string replace $host_home $guest_home $val) 23 | end 24 | 25 | case -H --host 26 | if string match -qr ^$run_host $val 27 | set _fisher_plugins[$idx] (string replace $guest_home $host_home $val) 28 | end 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /mkosi/dev-fedora/mkosi.postinst.d/00-fix-nsswitch.conf.fish.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # This script enables the nss-systemd plugin for the shadow and gshadow 3 | # databases, which allows systemd-nspawn's '--bind-user' to passthrough 4 | # the host user's login information to the container. This really should 5 | # be done in authselect upstream but there were some regressions that 6 | # should not really apply to my usage. 7 | # https://github.com/authselect/authselect/pull/380 8 | # https://github.com/authselect/authselect/issues/385 9 | 10 | set profile local-systemd 11 | authselect create-profile \ 12 | -b local \ 13 | --symlink-{dconf,meta,pam} \ 14 | $profile 15 | or return 16 | 17 | set nsswitch_conf /etc/authselect/custom/$profile/nsswitch.conf 18 | sed -i 's;^shadow: files$;shadow: files systemd;' $nsswitch_conf 19 | sed -i 's;^gshadow: files$;gshadow: files systemd;' $nsswitch_conf 20 | 21 | git diff --no-index /etc/authselect/nsswitch.conf $nsswitch_conf 22 | 23 | authselect select custom/$profile 24 | or return 25 | 26 | authselect apply-changes 27 | -------------------------------------------------------------------------------- /fish/functions/__start_tmux.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function __start_tmux -d "Start tmux under certain conditions (for use in config.fish)" 6 | # If we are in a login shell... 7 | status is-login 8 | # and we are not in a graphical environment (implies a terminal application with tabs)... 9 | and not set -q DISPLAY 10 | # and we are not in WSL (implies Windows Terminal, which has tabs)... 11 | and not set -q WSLENV 12 | # and we are not already in a tmux environment... 13 | and not set -q TMUX 14 | # and we are not in a chroot (which may imply a tmux environment)... 15 | and not __in_deb_chroot 16 | # and we are not in a systemd-nspawn environment (which will only interact with the host's environment) 17 | and not __in_nspawn 18 | # and we have it installed, 19 | and command -q tmux 20 | # attempt to attach to a session named "main" while detaching everyone 21 | # else or create a new session if one does not already exist 22 | and tmxa 23 | end 24 | -------------------------------------------------------------------------------- /fish/functions/get_ip.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2025 Nathan Chancellor 4 | 5 | function get_ip -d "Get a particular machine's IP address via short name or hostname" 6 | set device $argv[1] 7 | switch $device 8 | case aadp 9 | echo 10.0.1.2 10 | case amd-desktop-8745HS beelink-amd-ryzen-8745hs 11 | echo 10.0.1.8 12 | case chromebox chromebox3 13 | echo 10.0.1.14 14 | case framework framework-desktop framework-amd-ryzen-maxplus-395 15 | echo 10.0.1.23 16 | case hetzner main 17 | echo $HETZNER_IP 18 | case honeycomb 19 | echo 10.0.1.17 20 | case intel-desktop-11700 asus-intel-core-11700 21 | echo 10.0.1.5 22 | case intel-desktop-n100 beelink-intel-n100 23 | echo 10.0.1.11 24 | case intel-laptop msi-intel-core-10210U 25 | echo 10.0.1.20 26 | case '*' 27 | __print_error "Unrecognized device name: $device" 28 | return 1 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /fish/functions/__mail_msg.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function __mail_msg -d "Send myself an email" 6 | if __is_github_actions 7 | set muttrc $GITHUB_WORKSPACE/muttrc.notifier 8 | else 9 | set muttrc $HOME/.muttrc.notifier 10 | end 11 | 12 | if not test -f $muttrc 13 | __print_error "$muttrc does not exist!" 14 | return 1 15 | end 16 | 17 | if test (count $argv) -gt 0 18 | for file in $argv 19 | if test -f $file 20 | set -a inputs $file 21 | else 22 | __print_error "Input file '$file' does not exist!" 23 | return 1 24 | end 25 | end 26 | else 27 | set tmp_file (mktemp) 28 | cat /dev/stdin >$tmp_file 29 | set inputs $tmp_file 30 | end 31 | 32 | set -l date (date +%F-%T) 33 | 34 | mutt -F $muttrc -s "$hostname: $date" -a $inputs -- nathan@kernel.org <$inputs[1] 35 | if set -q tmp_file 36 | rm -f $tmp_file 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /configs/local/snazzy.colorscheme: -------------------------------------------------------------------------------- 1 | # --- special colors --- 2 | 3 | [Background] 4 | Color=40,42,56 5 | 6 | [BackgroundIntense] 7 | Color=40,42,56 8 | Bold=true 9 | 10 | [Foreground] 11 | Color=239,240,235 12 | 13 | [ForegroundIntense] 14 | Color=239,240,235 15 | Bold=true 16 | 17 | # --- standard colors --- 18 | 19 | [Color0] 20 | Color=40,42,56 21 | 22 | [Color0Intense] 23 | Color=104,104,104 24 | 25 | [Color1] 26 | Color=255,92,87 27 | 28 | [Color1Intense] 29 | Color=255,92,87 30 | 31 | [Color2] 32 | Color=90,247,142 33 | 34 | [Color2Intense] 35 | Color=90,247,142 36 | 37 | [Color3] 38 | Color=243,249,157 39 | 40 | [Color3Intense] 41 | Color=243,249,157 42 | 43 | [Color4] 44 | Color=87,199,255 45 | 46 | [Color4Intense] 47 | Color=87,199,255 48 | 49 | [Color5] 50 | Color=255,106,193 51 | 52 | [Color5Intense] 53 | Color=255,106,193 54 | 55 | [Color6] 56 | Color=154,237,254 57 | 58 | [Color6Intense] 59 | Color=154,237,254 60 | 61 | [Color7] 62 | Color=241,241,240 63 | 64 | [Color7Intense] 65 | Color=239,240,235 66 | 67 | # --- general options --- 68 | 69 | [General] 70 | Description=snazzy 71 | Opacity=1 72 | Wallpaper= 73 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016-2023 Nathan Chancellor 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a 6 | copy of this software and associated documentation files (the "Software"), 7 | to deal in the Software without restriction, including without limitation 8 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | and/or sell copies of the Software, and to permit persons to whom the 10 | Software is furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /fish/functions/__git_sw.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function __git_sw -d "git switch with fzf" 6 | if test (count $argv) -gt 0 7 | for arg in $argv 8 | switch $arg 9 | case -d --detach 10 | set -a git_switch_args $arg 11 | case '*' 12 | set ref $arg 13 | end 14 | end 15 | if not set -q ref 16 | __print_error "No ref supplied?" 17 | return 1 18 | end 19 | else 20 | set ref (git bf) 21 | end 22 | 23 | if test -n "$ref" 24 | if string match -qr "^remotes/" $ref 25 | for remote in (git remote) 26 | set replace_string "^remotes/$remote/" 27 | if string match -qr "$replace_string" $ref 28 | set -f git_switch_args \ 29 | -c (string replace -r "$replace_string" "" $ref) 30 | break 31 | end 32 | end 33 | end 34 | 35 | git switch $git_switch_args $ref 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /configs/archinstall/vm_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "additional-repositories": [], 3 | "archinstall-language": "English", 4 | "audio_config": null, 5 | "bootloader": "Systemd-boot", 6 | "config_version": "3.0.1", 7 | "disk_config": {}, 8 | "disk_encryption": null, 9 | "hostname": "qemu", 10 | "kernels": [ 11 | "linux" 12 | ], 13 | "locale_config": { 14 | "kb_layout": "us", 15 | "sys_enc": "UTF-8", 16 | "sys_lang": "en_US" 17 | }, 18 | "mirror_config": null, 19 | "network_config": { 20 | "type": "iso" 21 | }, 22 | "ntp": true, 23 | "packages": [ 24 | "python" 25 | ], 26 | "parallel downloads": 0, 27 | "profile_config": { 28 | "gfx_driver": null, 29 | "greeter": null, 30 | "profile": { 31 | "custom_settings": { 32 | "sshd": {} 33 | }, 34 | "details": [ 35 | "sshd" 36 | ], 37 | "main": "Server" 38 | } 39 | }, 40 | "save_config": null, 41 | "swap": true, 42 | "timezone": "America/Phoenix", 43 | "uki": false, 44 | "version": "3.0.1" 45 | } 46 | -------------------------------------------------------------------------------- /fish/functions/cbl_cl_software.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function cbl_cl_software -d "Clean up old versions of managed software" 6 | __in_container_msg -c; or return 7 | 8 | for arg in $argv 9 | switch $arg 10 | case binutils 11 | set folder $CBL_TC_BNTL_STORE 12 | set binary as 13 | case gcc 14 | set folder $CBL_TC_GCC_STORE 15 | set binary aarch64-linux-gcc 16 | case llvm 17 | set folder $CBL_TC_LLVM_STORE 18 | set binary clang 19 | case qemu 20 | set folder $CBL_QEMU_INSTALL 21 | set binary qemu-system-x86_64 22 | end 23 | 24 | set folders_to_remove (path filter -d $folder/* | path basename | path sort | command fzf -m --preview="$folder/{}/bin/$binary --version") 25 | if test -n "$folders_to_remove" 26 | set rm_cmd \ 27 | sudo rm -fr $folder/$folders_to_remove 28 | print_cmd $rm_cmd 29 | $rm_cmd 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /fish/conf.d/colors.fish: -------------------------------------------------------------------------------- 1 | # fish colors 2 | set -U fish_color_normal normal 3 | set -U fish_color_command blue 4 | set -U fish_color_quote yellow 5 | set -U fish_color_redirection green 6 | set -U fish_color_end green 7 | set -U fish_color_error red 8 | set -U fish_color_param cyan 9 | set -U fish_color_comment brblack 10 | set -U fish_color_match normal 11 | set -U fish_color_selection 97979b 12 | set -U fish_color_search_match yellow 13 | set -U fish_color_history_current normal 14 | set -U fish_color_operator magenta 15 | set -U fish_color_escape magenta 16 | set -U fish_color_cwd blue 17 | set -U fish_color_cwd_root blue 18 | set -U fish_color_valid_path normal 19 | set -U fish_color_autosuggestion 97979b 20 | set -U fish_color_user yellow 21 | set -U fish_color_host green 22 | set -U fish_color_cancel normal 23 | set -U fish_pager_color_completion normal 24 | set -U fish_pager_color_description B3A06D yellow 25 | set -U fish_pager_color_prefix white --bold --underline 26 | set -U fish_pager_color_progress brwhite --background=cyan 27 | 28 | # hydro colors 29 | set -U hydro_color_pwd blue 30 | set -U hydro_color_git magenta 31 | set -U hydro_color_duration yellow 32 | set -U hydro_color_prompt green 33 | -------------------------------------------------------------------------------- /mkosi/dev-arch/mkosi.postinst.d/02-add-hetzner-mirror.py.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from os import environ as env 4 | from pathlib import Path 5 | import sys 6 | 7 | EXPECTED_MOUNTS = ( 8 | ((PYTHON_FOLDER := Path(env['SRCDIR'], 'python')), 'PYTHON_FOLDER'), 9 | ((ETC := Path(env['SRCDIR'], 'etc')), '/etc'), 10 | ) 11 | for expected_path, host_value in EXPECTED_MOUNTS: 12 | if not expected_path.exists(): 13 | raise RuntimeError(f"{host_value} not passed into build environment?") 14 | 15 | sys.path.append(str(PYTHON_FOLDER)) 16 | # pylint: disable-next=wrong-import-position 17 | from setup.arch import HETZNER_MIRROR, add_hetzner_mirror_to_repos # noqa: E402 18 | 19 | if not (host_pacman_conf := Path(ETC, 'pacman.conf')).exists(): 20 | sys.exit(0) # host is not Arch, cannot be Hetzner 21 | 22 | if HETZNER_MIRROR not in host_pacman_conf.read_text(encoding='utf-8'): 23 | sys.exit(0) # host is Arch but still not Hetzner 24 | 25 | guest_pacman_conf = Path('/etc/pacman.conf') 26 | guest_pacman_conf_txt = add_hetzner_mirror_to_repos( 27 | guest_pacman_conf.read_text(encoding='utf-8')) 28 | guest_pacman_conf.write_text(guest_pacman_conf_txt, encoding='utf-8') 29 | -------------------------------------------------------------------------------- /fish/functions/cbl_test_llvm_linux.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function cbl_test_llvm_linux -d "Test stable and mainline Linux with all supported versions of LLVM" 6 | __in_container_msg -c; or return 7 | 8 | if not test -f $HOME/.muttrc.notifier 9 | __print_error "This function runs cbl_lkt, which requires the notifier!" 10 | return 1 11 | end 12 | 13 | set targets $argv 14 | if test -z "$targets" 15 | set targets mainline stable 16 | end 17 | 18 | cbl_upd_src c $targets 19 | korg_llvm install 20 | 21 | if contains mainline $targets 22 | set -a linux_folders $CBL_SRC_C/linux 23 | end 24 | if contains stable $targets 25 | set -a linux_folder $CBL_SRC_C/linux-stable-$CBL_STABLE_VERSIONS 26 | end 27 | 28 | for linux_folder in $linux_folders 29 | for ver in $LLVM_VERSIONS_KERNEL_STABLE 30 | cbl_lkt \ 31 | --build-folder (tbf cbl_test_llvm_linux) \ 32 | --linux-folder $linux_folder \ 33 | --llvm-prefix (korg_llvm folder -p $ver); or return 34 | end 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /bash/bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eux 4 | 5 | tmp_dir=$(mktemp -d) 6 | 7 | is_available() { 8 | command -v "$1" >/dev/null 2>&1 9 | } 10 | 11 | for file in /etc/os-release /usr/lib/os-release; do 12 | # We don't care if this fails, we will fail on the next command 13 | if . $file >/dev/null 2>&1; then 14 | break 15 | fi 16 | done 17 | 18 | if ! is_available python3; then 19 | if is_available apk; then 20 | apk add python3 21 | elif is_available dnf; then 22 | dnf install -y python3 23 | else 24 | echo "[-] No suitable command could be found to install python3" >&2 25 | fi 26 | fi 27 | 28 | if is_available curl; then 29 | dwnld_cmd="curl -LSs" 30 | elif is_available wget; then 31 | dwnld_cmd="wget -q -O-" 32 | else 33 | echo "[-] No suitable download command could be found!" >&2 34 | exit 1 35 | fi 36 | 37 | $dwnld_cmd https://github.com/nathanchance/env/tarball/main | tar -C "$tmp_dir" -xvzf - --strip-components=1 38 | 39 | python_setup=$tmp_dir/python/setup 40 | if [ ! -d "$python_setup" ]; then 41 | echo "[-] $python_setup could not be found, did download command fail?" >&2 42 | exit 1 43 | fi 44 | 45 | "$python_setup"/"${ID_LIKE-$ID}".py "$@" 46 | -------------------------------------------------------------------------------- /fish/functions/mvfunc.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function mvfunc -d "Move function file in $ENV_FOLDER" 6 | if test (count $argv) -ne 2 7 | __print_error "mvfunc expects only two arguments!" 8 | return 1 9 | end 10 | 11 | set src_name $argv[1] 12 | set fish_src $ENV_FOLDER/fish/functions/$src_name.fish 13 | if not test -f $fish_src 14 | __print_error "$fish_src could not be found!" 15 | return 1 16 | end 17 | set py_src $PYTHON_SCRIPTS_FOLDER/$src_name.py 18 | 19 | set dst_name $argv[2] 20 | set fish_dst $ENV_FOLDER/fish/functions/$dst_name.fish 21 | if test -f $fish_dst 22 | __print_error "$fish_dst exists, remove it manually to proceed!" 23 | return 1 24 | end 25 | set py_dst $PYTHON_SCRIPTS_FOLDER/$dst_name.py 26 | 27 | mv -v $fish_src $fish_dst 28 | sed -i "s/$src_name/$dst_name/g" $fish_dst 29 | 30 | if test -f $py_src 31 | if test -f $py_dst 32 | __print_error "$py_dst already exists, manually move $py_src to it if that is expected!" 33 | return 1 34 | end 35 | 36 | mv -v $py_src $py_dst 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /fish/functions/__git_ua.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function __git_ua -d "git remote update + action" 6 | set action $argv[1] 7 | 8 | switch $action 9 | case rh rbi 10 | case '*' 11 | __print_error "Action needs to be the first argument!" 12 | return 1 13 | end 14 | 15 | switch (count $argv) 16 | case 1 17 | set remote (git rn) 18 | set branch (git bn) 19 | 20 | case 2 21 | set rmb $argv[2] 22 | if string match -qr '[a-zA-Z0-9-_]+/.*' $rmb 23 | set remote (string split -f 1 / $rmb) 24 | set branch (string replace "$remote/" "" $rmb) 25 | else 26 | __print_error "Expected /!" 27 | return 1 28 | end 29 | 30 | case 3 31 | set remote $argv[2] 32 | set branch $argv[3] 33 | 34 | case '*' 35 | __print_error "Too many arguments! Use either / or ." 36 | return 1 37 | end 38 | 39 | git ru --prune $remote; or return 40 | git $action $remote/$branch 41 | end 42 | -------------------------------------------------------------------------------- /fish/completions/cbl_bld_krnl_rpm.fish: -------------------------------------------------------------------------------- 1 | complete -c cbl_bld_krnl_rpm -f -l cfi -d "Enable CONFIG_CFI" 2 | complete -c cbl_bld_krnl_rpm -f -l cfi-permissive -d "Enable CONFIG_CFI_PERMISSIVE" 3 | complete -c cbl_bld_krnl_rpm -f -l debug -d "Force enable debug info" 4 | complete -c cbl_bld_krnl_rpm -f -l lto -d "Enable CONFIG_LTO_CLANG_THIN" 5 | complete -c cbl_bld_krnl_rpm -f -l no-debug -d "Force disable debug info" 6 | complete -c cbl_bld_krnl_rpm -f -l no-werror -d "Disable CONFIG_WERROR" 7 | complete -c cbl_bld_krnl_rpm -f -l slim-arm64-platforms -d "Disable unnecessary arm64 platforms for slimmer build" 8 | complete -c cbl_bld_krnl_rpm -f -s g -l gcc -d "Build with GCC instead of LLVM" 9 | complete -c cbl_bld_krnl_rpm -f -s l -l localmodconfig -d "Call localmodconfig during configuration" 10 | complete -c cbl_bld_krnl_rpm -f -s m -l menuconfig -d "Call menuconfig during configuration" 11 | complete -c cbl_bld_krnl_rpm -f -s n -l no-config -d "Do not automatically create configuration" 12 | 13 | function __cbl_bld_krnl_rpm_pos_args 14 | set -l valid_architectures aarch64 arm64 amd64 x86_64 15 | string join \n -- $valid_architectures\t"Kernel architecture" 16 | end 17 | complete -c cbl_bld_krnl_rpm -f -d "Positional arguments" -a '(__cbl_bld_krnl_rpm_pos_args)' 18 | -------------------------------------------------------------------------------- /fish/functions/nspawn_path.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | function nspawn_path -d "Translate /home paths into systemd-nspawn or host" 6 | set mode $argv[1] 7 | set path $argv[2] 8 | 9 | # Constants 10 | set run_host /run/host 11 | set host_home /home/$USER 12 | set guest_home $run_host$host_home 13 | 14 | # The path only needs to be adjusted if it starts with one of the two possible home paths 15 | if string match -qr '^('$host_home'|'$guest_home')' $path 16 | switch $mode 17 | # In container mode, the /home path should be prefixed with /run/host 18 | case -c --container 19 | if not string match -qr ^$run_host $path 20 | set prefix $run_host 21 | end 22 | printf '%s%s\n' $prefix $path 23 | 24 | # In host mode, /run/host should be stripped from /home 25 | case -H --host 26 | if string match -qr ^/home $path 27 | echo $path 28 | else 29 | string replace $run_host '' $path 30 | end 31 | end 32 | else 33 | echo $path 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /fish/functions/kpch.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function kpch -d "Run checkpatch.pl and get_maintainer.pl on a patch" 6 | __in_tree kernel; or return 7 | if string match -qr b4/ (git bn) 8 | set b4_branch true 9 | end 10 | 11 | if test (count $argv) -eq 0 12 | if set -q b4_branch 13 | if b4 prep --help &| string match -qr -- '--show-info \[PARAM\]' 14 | set range (b4 prep --show-info series-range) 15 | else 16 | set range (b4 prep --show-info | string match -gr '(?:start|end)-commit:\s+([a-z0-9]{40})' | string join ..) 17 | end 18 | kchp -g $range 19 | else 20 | set rev HEAD~1..HEAD 21 | end 22 | else 23 | set rev $argv[1] 24 | end 25 | 26 | if not set -q b4_branch 27 | for sha in (git log --format=%H --no-merges --reverse $rev) 28 | set title Commit (git cite $sha) 29 | set header (for i in (seq 1 (string length "$title")); printf "-"; end) 30 | printf "\n%s\n%s\n%s\n\n" $header "$title" $header 31 | 32 | kchp -g $sha 33 | git fp -1 --stdout $sha | kgtm 34 | end 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /fish/functions/cbl_bld_llvm_fast.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | function cbl_bld_llvm_fast -d "Quickly build a version of LLVM" -w build-llvm.py 6 | set bld_llvm_args $argv 7 | if contains -- -l $bld_llvm_args 8 | set llvm_flag -l 9 | end 10 | if contains -- --llvm-folder $bld_llvm_args 11 | set llvm_flag --llvm-folder 12 | end 13 | if set -q llvm_flag 14 | set llvm_folder $bld_llvm_args[(math (contains -i -- $llvm_flag $bld_llvm_args) + 1)] 15 | set bld_folder (tbf $llvm_folder) 16 | end 17 | if not set -q llvm_folder 18 | __in_tree llvm 19 | or return 128 20 | 21 | set llvm_folder . 22 | set bld_folder (tbf) 23 | end 24 | 25 | if not set -q tc_bld 26 | cbl_clone_repo tc-build 27 | or return 28 | 29 | set tc_bld $CBL_GIT/tc-build 30 | end 31 | 32 | $tc_bld/build-llvm.py \ 33 | --assertions \ 34 | --build-folder $bld_folder \ 35 | --build-stage1-only \ 36 | --build-targets distribution \ 37 | --llvm-folder $llvm_folder \ 38 | --projects clang lld \ 39 | --quiet-cmake \ 40 | --show-build-commands \ 41 | $bld_llvm_args 42 | end 43 | -------------------------------------------------------------------------------- /fish/functions/cbl_bld_llvm_sbs.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | function cbl_bld_llvm_sbs -d "Build identical copies of LLVM side by side from various revisions" 6 | __in_tree llvm 7 | or return 128 8 | 9 | set prefix $argv[1] 10 | 11 | for arg in $argv[2..] 12 | # either short or full SHA 13 | if string match -qr -- '[0-9a-f]{12}' $arg; or string match -qr -- '[0-9a-f]{40}' $arg 14 | set -a shas $arg 15 | else 16 | set -a bld_llvm_args $arg 17 | end 18 | end 19 | 20 | cbl_clone_repo $CBL_TC_BLD 21 | or return 22 | 23 | for sha in $shas 24 | git worktree prune 25 | git worktree add -d $prefix/src $sha 26 | or return 27 | cbl_patch_llvm $prefix/src 28 | 29 | $CBL_TC_BLD/build-llvm.py \ 30 | --assertions \ 31 | --build-folder $prefix/build/llvm-$sha \ 32 | --build-stage1-only \ 33 | --install-folder $prefix/install/llvm-$sha \ 34 | --llvm-folder $prefix/src \ 35 | --projects clang lld \ 36 | --quiet-cmake \ 37 | $bld_llvm_args 38 | or return 39 | 40 | rm -fr $prefix/src 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /fish/functions/updweb.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function updweb -d "Update my website with hugo" 6 | set website $GITHUB_FOLDER/nathanchance.github.io 7 | if not test -d $website 8 | mkdir -p (path dirname $website) 9 | gh repo clone (path basename $website) $website 10 | end 11 | 12 | set hugo_files $GITHUB_FOLDER/hugo-files 13 | if not test -d $hugo_files 14 | mkdir -p (path dirname $hugo_files) 15 | gh repo clone (path basename $hugo_files) $hugo_files 16 | end 17 | 18 | for arg in $argv 19 | switch $arg 20 | case -p --push 21 | set push true 22 | case '*' 23 | set -a hugo_args $arg 24 | end 25 | end 26 | 27 | fd -E CNAME . $website -x rm -rfv 28 | hugo -d $website -s $hugo_files $hugo_args 29 | 30 | set url (git -C $hugo_files remote get-url origin | sed -e 's/git@github.com:/https:\/\/github.com\//' -e 's/.git$//') 31 | set hash (git -C $hugo_files show -s --format=%H) 32 | 33 | git -C $website aa 34 | git -C $website ac -m "website: Update to $url/commit/$hash" 35 | if test "$push" = true 36 | git -C $website push 37 | end 38 | return 0 39 | end 40 | -------------------------------------------------------------------------------- /fish/functions/edfunc.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function edfunc -d "Edit function or script file in $ENV_FOLDER" 6 | for arg in $argv 7 | switch $arg 8 | case -f --fzf 9 | set fzf true 10 | case -r --reload 11 | set reload true 12 | case '*' 13 | set -a funcs_to_edit $arg 14 | end 15 | end 16 | 17 | if test "$fzf" = true 18 | set -a funcs_to_edit (__get_my_funcs | fzf -m) 19 | end 20 | 21 | for func_to_edit in $funcs_to_edit 22 | if test -f $func_to_edit 23 | set func_file $func_to_edit 24 | else 25 | set func_file $PYTHON_SCRIPTS_FOLDER/$func_to_edit.py 26 | if not test -f "$func_file" 27 | set func_file $ENV_FOLDER/fish/functions/$func_to_edit.fish 28 | end 29 | if not test -f "$func_file" 30 | __print_error "$func_file does not exist!" 31 | return 1 32 | end 33 | end 34 | set -a files_to_edit $func_file 35 | end 36 | 37 | if test -n "$files_to_edit" 38 | vim -p $files_to_edit 39 | if test "$reload" = true 40 | rld 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /fish/functions/__tmux_ssh_fixup.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function __tmux_ssh_fixup -d "Fix up SSH_CONNECTION value in tmux" 6 | # For whatever reason, there are times where SSH_CONNECTION exists in the 7 | # original shell environment and the tmux environment (as visible with 8 | # tmux show-env) but not in the shell environment within tmux. It usually 9 | # happens with tmux is automatically started at boot: 10 | # 11 | # $ env | grep SSH_CONNECTION 12 | # 13 | # $ tmux show-env | grep SSH_CONNECTION 14 | # SSH_CONNECTION=192.168.4.54 63192 192.168.4.104 22 15 | # 16 | # $ exit 17 | # 18 | # $ env | grep SSH_CONNECTION 19 | # SSH_CONNECTION=192.168.4.54 63192 192.168.4.104 22 20 | # 21 | # $ tmux new-session -AD -s main 22 | # 23 | # $ env | grep SSH_CONNECTION 24 | # SSH_CONNECTION=192.168.4.54 63192 192.168.4.104 22 25 | # 26 | # So we set it manually here 27 | 28 | if set -q TMUX 29 | set tmux_ssh_con (tmux show-env &| string match -er SSH_CONNECTION=) 30 | set fish_ssh_con $SSH_CONNECTION 31 | 32 | if test "$tmux_ssh_con" != "$fish_ssh_con" 33 | set -gx SSH_CONNECTION (string split -f 2 = $tmux_ssh_con) 34 | end 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /specs/modprobed-db/modprobed-db.spec: -------------------------------------------------------------------------------- 1 | Name: modprobed-db 2 | Version: 2.48 3 | Release: %autorelease 4 | Summary: Keeps track of EVERY kernel module ever used - useful for make localmodconfig 5 | BuildArch: noarch 6 | 7 | License: MIT 8 | URL: https://wiki.archlinux.org/index.php/Modprobed-db 9 | Source: https://github.com/graysky2/%{name}/archive/v%{version}.tar.gz 10 | 11 | BuildRequires: make 12 | BuildRequires: systemd-rpm-macros 13 | 14 | Requires: coreutils 15 | Requires: gawk 16 | Requires: grep 17 | Requires: kmod 18 | Requires: sed 19 | 20 | %description 21 | modprobed-db is a utility that populates a list of all the kernel modules that 22 | have been loaded on a system while running. This list can then be used to 23 | disable all the unused modules when building your own kernel and significantly 24 | reduce the compilation time. 25 | 26 | %prep 27 | %autosetup 28 | 29 | %build 30 | %make_build 31 | 32 | %install 33 | %make_install 34 | 35 | %files 36 | %{bash_completions_dir}/modprobed-db 37 | %{_bindir}/modprobed-db 38 | %{_datadir}/modprobed-db/modprobed-db.skel 39 | %{_mandir}/man8/modprobed-db.8.* 40 | %{_userunitdir}/modprobed-db.service 41 | %{_userunitdir}/modprobed-db.timer 42 | %{zsh_completions_dir}/_modprobed-db 43 | %license MIT 44 | 45 | %changelog 46 | %autochangelog 47 | -------------------------------------------------------------------------------- /fish/functions/setup_sd_nspawn.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2025 Nathan Chancellor 4 | 5 | function setup_sd_nspawn -d "Perform initial systemd-nspawn setup" 6 | # These platforms will more than likely use tmux so ensure the tmux 7 | # directory exists with the expected permissions so that sd_nspawn 8 | # will find it and mount it into the container properly. Even if they 9 | # do not use tmux, creating the directory and passing it through to 10 | # the container is not the end of the world, as no socket will exist. 11 | set tmux_tmp /var/tmp/tmux-(id -u) 12 | mkdir -p $tmux_tmp 13 | # tmux checks that the permissions are restrictive 14 | chmod 700 $tmux_tmp 15 | 16 | sudo true 17 | or return 18 | 19 | # Set up files first because that process is quicker than the build 20 | # process and doas/sudo authorization lasts at least five minutes 21 | $PYTHON_BIN_FOLDER/sd_nspawn -i 22 | or return 23 | 24 | mkosi_bld 25 | or return 26 | 27 | # '--now' is only supported with systemd 253 or newer but AlmaLinux 9 ships 252 28 | if test (machinectl --version | string match -gr '^systemd (\d+) ') -ge 253 29 | sudo machinectl enable --now $DEV_IMG 30 | else 31 | sudo machinectl enable $DEV_IMG 32 | and sudo machinectl start $DEV_IMG 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /mkosi/dev-arch/mkosi.postinst.d/00-conf.fish.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | 3 | for conf in makepkg pacman 4 | set old /etc/$conf.conf 5 | set pacnew /etc/$conf.conf.pacnew 6 | set new /etc/$conf.conf.new 7 | 8 | if test -f $pacnew 9 | mv -v $pacnew $new 10 | else 11 | cp -v $old $new 12 | end 13 | 14 | switch $conf 15 | case makepkg 16 | sed -i 's/^#MAKEFLAGS="-j2"/MAKEFLAGS="-j$(nproc)"/g' $new 17 | sed -i 's/^!ccache/ccache/g' $new 18 | 19 | case pacman 20 | sed -i 's/^CheckSpace/#CheckSpace/g' $new 21 | sed -i 's/^#VerbosePkgLists/VerbosePkgLists/g' $new 22 | sed -i 's/^#Color/Color/g' $new 23 | sed -i 's/^NoProgressBar/#NoProgressBar/g' $new 24 | sed -i 's/^#ParallelDownloads = 5/ParallelDownloads = 7/g' $new 25 | sed -i "/\[core-testing\]/,/Include/"'s/^#//' $new 26 | sed -i "/\[extra-testing\]/,/Include/"'s/^#//' $new 27 | 28 | echo ' 29 | [nathan] 30 | SigLevel = Optional TrustAll 31 | Server = https://raw.githubusercontent.com/nathanchance/arch-repo/main/$arch' >>$new 32 | end 33 | 34 | if command -q git 35 | git diff --no-index $old $new 36 | else 37 | diff -Naur $old $new 38 | end 39 | 40 | mv -v $new $old 41 | end 42 | 43 | echo 'permit nopass nathan as root' >/etc/doas.conf 44 | chmod 600 /etc/doas.conf 45 | -------------------------------------------------------------------------------- /mkosi/dev-arch/mkosi.postinst.d/01-install-packages.fish.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | 3 | function downgrade_pkg 4 | set pkg $argv[1] 5 | set ver $argv[2] 6 | 7 | set tarball /tmp/$pkg-$ver-x86_64.pkg.tar.zst 8 | set url https://archive.archlinux.org/packages/(string split -f 1 '' $pkg)/$pkg/(basename $tarball) 9 | 10 | curl -LSso $tarball $url 11 | and pacman -U --noconfirm $tarball 12 | and rm -fr $tarball 13 | end 14 | 15 | 16 | reflector \ 17 | --country "United States" \ 18 | --latest 15 \ 19 | --protocol https \ 20 | --save /etc/pacman.d/mirrorlist \ 21 | --sort rate 22 | 23 | and cat /etc/pacman.d/mirrorlist 24 | 25 | and pacman-key --init 26 | and pacman-key --populate 27 | 28 | # Temporarily disable the pacman sandbox 29 | and sed -i 's/^DownloadUser/#DownloadUser/g' /etc/pacman.conf 30 | 31 | and pacman -Syyuu --noconfirm 32 | 33 | # Switch to doas from sudo non-interatively 34 | and pacman -S --ask 4 --noconfirm opendoas-sudo 35 | and echo 'session optional pam_umask.so' | tee -a /etc/pam.d/doas 36 | 37 | and pacman -S --noconfirm \ 38 | arm-linux-gnueabi-binutils \ 39 | cvise \ 40 | debhelper \ 41 | mips-linux-gnu-binutils \ 42 | powerpc64-linux-gnu-binutils \ 43 | s390x-linux-gnu-binutils \ 44 | shellcheck-bin 45 | 46 | # Turn the pacman sandbox back on 47 | and sed -i 's/^#DownloadUser/DownloadUser/g' /etc/pacman.conf 48 | -------------------------------------------------------------------------------- /python/lib/sha256.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | import hashlib 6 | from pathlib import Path 7 | import re 8 | 9 | import requests 10 | 11 | from . import utils 12 | 13 | 14 | def calculate(file_path): 15 | file_hash = hashlib.sha256() 16 | with Path(file_path).open('rb') as file: 17 | # 1MB at a time 18 | while (chunk := file.read(1048576)): # 1MB at a time 19 | file_hash.update(chunk) 20 | return file_hash.hexdigest() 21 | 22 | 23 | def get_from_url(url, basename): 24 | response = requests.get(url, timeout=3600) 25 | response.raise_for_status() 26 | for line in response.content.decode('utf-8').splitlines(): 27 | if 'clone.bundle' in basename: 28 | basename = basename.split('-')[0] 29 | if basename in line and (sha256_match := re.search('[A-Fa-f0-9]{64}', line)): 30 | return sha256_match.group(0) 31 | return None 32 | 33 | 34 | def validate_from_url(file, url): 35 | computed_sha256 = calculate(file) 36 | expected_sha256 = get_from_url(url, file.name) 37 | 38 | if computed_sha256 == expected_sha256: 39 | utils.print_green(f"SUCCESS: {file.name} sha256 passed!") 40 | else: 41 | raise RuntimeError( 42 | f"{file.name} computed checksum ('{computed_sha256}') did not match expected checksum ('{expected_sha256}')!", 43 | ) 44 | -------------------------------------------------------------------------------- /fish/functions/cbl_bld_krnl_deb.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function cbl_bld_krnl_deb -d "Build a .deb kernel package" 6 | __in_container_msg -c; or return 7 | __in_tree kernel; or return 8 | 9 | # Effectively 'distclean' 10 | git cl -q 11 | 12 | # Allow cross compiling 13 | for arg in $argv 14 | switch $arg 15 | case aarch64 arm64 16 | set arch arm64 17 | case amd64 x86_64 18 | set arch x86_64 19 | case --cfi --cfi-permissive --lto --no-werror 20 | set -a config_args $arg 21 | end 22 | end 23 | 24 | # If no arch value specified, use host architecture 25 | if not set -q arch 26 | set arch (uname -m) 27 | switch $arch 28 | case aarch64 29 | set arch arm64 30 | end 31 | end 32 | 33 | cbl_gen_ubuntuconfig $config_args $arch 34 | 35 | kmake \ 36 | ARCH=$arch \ 37 | HOSTCFLAGS=-Wno-deprecated-declarations \ 38 | KBUILD_BUILD_HOST=$hostname \ 39 | LLVM=1 \ 40 | $KMAKE_DEB_ARGS \ 41 | O=(tbf)/$arch \ 42 | olddefconfig bindeb-pkg; or return 43 | 44 | echo Run 45 | printf '\n\t$ sudo fish -c "dpkg -i %s; and reboot"\n\n' (realpath -- (tbf)/linux-image-*.deb | string replace $TMP_BUILD_FOLDER \$TMP_BUILD_FOLDER) 46 | echo "to install and use new kernel." 47 | end 48 | -------------------------------------------------------------------------------- /fish/completions/cbl_bld_krnl_vm.fish: -------------------------------------------------------------------------------- 1 | function __cbl_bld_krnl_vm_get_arch 2 | # Check if '-a' / '--arch' was found on the command line 3 | set tokens (commandline -xpc) 4 | if set index (contains -i -- -a $tokens); or set index (contains -i -- --arch $tokens) 5 | set arch $tokens[(math $index + 1)] 6 | else 7 | set arch (uname -m) 8 | end 9 | switch $arch 10 | case arm64 11 | echo aarch64 12 | case armv7l 13 | echo arm 14 | case '*' 15 | echo $arch 16 | end 17 | end 18 | 19 | function __cbl_bld_krnl_vm_get_tc_args 20 | string join \n -- gcc-$GCC_VERSIONS_KERNEL llvm-$LLVM_VERSIONS_KERNEL 21 | end 22 | 23 | complete -c cbl_bld_krnl_vm -f -s h -l help -d "Show help message and exit" 24 | complete -c cbl_bld_krnl_vm -x -s a -l arch -d "Architecture to build and boot" -a "arm armv7l aarch64 arm64 x86_64" 25 | complete -c cbl_bld_krnl_vm -x -s c -l config -d "Use custom configuration target" 26 | complete -c cbl_bld_krnl_vm -x -s C -l directory -d "Path to kernel source" -a '(__fish_complete_directories)' 27 | complete -c cbl_bld_krnl_vm -f -s m -l menuconfig -d "Run menuconfig after localyesconfig" 28 | complete -c cbl_bld_krnl_vm -x -s n -l vm-name -d "Name of virtual machine" -a '(path basename $VM_FOLDER/(__cbl_bld_krnl_vm_get_arch)/*)' 29 | complete -c cbl_bld_krnl_vm -x -s t -l toolchain -d Toolchain -a '(__cbl_bld_krnl_vm_get_tc_args)' 30 | complete -c cbl_bld_krnl_vm -x -l additional-targets -d "Call target before 'all' target" 31 | -------------------------------------------------------------------------------- /python/pgo-llvm-builder/mkosi.conf: -------------------------------------------------------------------------------- 1 | [Build] 2 | WithNetwork=true 3 | 4 | [Content] 5 | Bootable=false 6 | # base packages 7 | Packages=build-essential 8 | passwd 9 | 10 | # for downloading and extracting various sources 11 | Packages=ca-certificates 12 | gzip 13 | wget 14 | xz-utils 15 | 16 | # for https://apt.llvm.org/llvm.sh 17 | Packages=apt 18 | gnupg 19 | lsb-release 20 | software-properties-common 21 | 22 | # for building and running fish shell 23 | Packages=groff-base 24 | man-db 25 | ncurses-base 26 | procps 27 | # build deps 28 | libpcre2-dev 29 | mount 30 | tar 31 | 32 | # for building perf 33 | Packages=libcapstone-dev 34 | libdw-dev 35 | libperl-dev 36 | libpfm4-dev 37 | libslang2-dev 38 | 39 | # for building Python 40 | Packages=libbz2-dev 41 | libffi-dev 42 | libreadline-dev 43 | libssl-dev 44 | pkg-config 45 | uuid-dev 46 | zlib1g-dev 47 | 48 | # for building kernels and LLVM 49 | Packages=bc 50 | binutils-dev 51 | bison 52 | cpio 53 | curl 54 | file 55 | flex 56 | git 57 | libelf-dev 58 | make 59 | texinfo 60 | u-boot-tools 61 | 62 | [Distribution] 63 | Distribution=debian 64 | Mirror=http://archive.debian.org 65 | Release=buster 66 | 67 | [Output] 68 | Format=directory 69 | ImageId=pgo-llvm-builder 70 | OutputDirectory=/var/lib/machines 71 | -------------------------------------------------------------------------------- /python/scripts/gen_patch_cc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2023 Nathan Chancellor 4 | 5 | from argparse import ArgumentParser 6 | from pathlib import Path 7 | import sys 8 | 9 | sys.path.append(str(Path(__file__).resolve().parents[1])) 10 | # pylint: disable=wrong-import-position 11 | import lib.utils 12 | # pylint: enable=wrong-import-position 13 | 14 | parser = ArgumentParser(description='Generate Cc: lines for patch') 15 | parser.add_argument( 16 | '-C', 17 | '--directory', 18 | default='.', 19 | help='Change into directory for operations (default: current working directory)') 20 | parser.add_argument('path', help='Path to generate Cc: list for') 21 | args = parser.parse_args() 22 | 23 | if not (repo := Path(args.directory).resolve()).exists(): 24 | raise RuntimeError(f"Provided repo ('{repo}') could not be found?") 25 | 26 | if not (get_maint := Path(repo, 'scripts/get_maintainer.pl')).exists(): 27 | raise RuntimeError(f"Provided repo ('{repo}') does not appear to be a kernel tree?") 28 | 29 | if not (path := Path(repo, args.path)).exists(): 30 | raise RuntimeError(f"Provided path ('{path}') could not be found in provided repo ('{repo}')?") 31 | 32 | # Show raw scripts/get_maintainer.pl output, which can help with trimming up or 33 | # modifying the list of addresses to send the patch to. 34 | lib.utils.run([get_maint, path], cwd=repo) 35 | print() 36 | 37 | for addr in lib.utils.chronic([get_maint, '--no-n', '--no-rolestats', path], 38 | cwd=repo).stdout.splitlines(): 39 | print(f"Cc: {addr}") 40 | -------------------------------------------------------------------------------- /fish/functions/cbl_patch_llvm.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2025 Nathan Chancellor 4 | 5 | function cbl_patch_llvm -d "Apply fixes for known problems from newer environments to LLVM" 6 | if test (count $argv) -eq 0 7 | __in_tree llvm 8 | or return 128 9 | 10 | set llvm_src $PWD 11 | else 12 | set llvm_src $argv[1] 13 | end 14 | # ensure git commands are always in LLVM repository, not current directory 15 | set git git -C $llvm_src 16 | 17 | if not set sha ($git sha) 18 | __print_error "$llvm_src not a git repository??" 19 | return 128 20 | end 21 | 22 | # Avoid build issues with newer versions of libstdc++ 23 | if not $git merge-base --is-ancestor 7e44305041d96b064c197216b931ae3917a34ac1 $sha 24 | $git cherry-pick -n 7e44305041d96b064c197216b931ae3917a34ac1 25 | or return 128 26 | end 27 | # the above patch will implicitly resolve the issue if 2222fddfc0a2 is present 28 | if not $git merge-base --is-ancestor 2222fddfc0a2ff02036542511597839856289094 $sha 29 | sed -i '/#include /i #include ' $llvm_src/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h 30 | end 31 | 32 | # https://github.com/llvm/llvm-project/issues/100296 33 | if $git merge-base --is-ancestor d38c8a7a51227fecdb1f84160f5da4f89c3e25be $sha 34 | and not $git merge-base --is-ancestor 40b4fd7a3e81d32b29364a1b15337bcf817659c0 $sha 35 | $git cherry-pick -n 40b4fd7a3e81d32b29364a1b15337bcf817659c0 36 | or return 128 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /fish/functions/setup_libvirt.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function setup_libvirt -d "Setup libvirt for current user" 6 | __in_container_msg -h; or return 7 | 8 | # Cache sudo permissions 9 | sudo true; or return 10 | 11 | if not command -q virsh 12 | upd -y; or return 13 | 14 | set distro (__get_distro) 15 | switch $distro 16 | case arch 17 | sudo pacman \ 18 | -S \ 19 | --noconfirm \ 20 | dmidecode \ 21 | dnsmasq \ 22 | libvirt \ 23 | qemu-desktop \ 24 | virt-install; or return 25 | 26 | sudo pacman \ 27 | -S \ 28 | --noconfirm \ 29 | --ask 4 \ 30 | iptables-nft; or return 31 | 32 | case fedora 33 | sudo dnf install -y @virtualization; or return 34 | 35 | case '*' 36 | __print_error "$distro is not supported by setup_libvirt!" 37 | return 1 38 | end 39 | end 40 | 41 | # Ensure that the rest of this function says in sync with setup_libvirt_common() in 'bash/common' 42 | set user (id -un) 43 | sudo fish -c "usermod -aG libvirt $user 44 | and systemctl enable --now libvirtd.service 45 | and virsh net-autostart default 46 | and if virsh net-info default | string match -qr 'Active:\s+no' 47 | virsh net-start default 48 | end" 49 | end 50 | -------------------------------------------------------------------------------- /mkosi/dev-debian/mkosi.postinst.d/01-install-packages.fish.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | 3 | # Setup gh repo 4 | set gh_gpg_key /etc/apt/keyrings/githubcli-archive-keyring.gpg 5 | and curl -fLSs https://cli.github.com/packages/(basename $gh_gpg_key) | dd of=$gh_gpg_key 6 | and echo "Types: deb 7 | URIs: https://cli.github.com/packages 8 | Suites: stable 9 | Components: main 10 | Signed-By: $gh_gpg_key" >/etc/apt/sources.list.d/github-cli.sources 11 | 12 | # Setup LLVM repo 13 | and set llvm_main_version (curl -fLSs https://raw.githubusercontent.com/llvm/llvm-project/main/cmake/Modules/LLVMVersion.cmake | string match -gr 'set\(LLVM_VERSION_MAJOR (\d+)\)'; or echo 20) 14 | and set llvm_stable_version (math $llvm_main_version - 1) 15 | and switch $ARCHITECTURE 16 | case arm64 x86-64 17 | set llvm_gpg_key /etc/apt/keyrings/apt-llvm-org.gpg 18 | curl -fLSs https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o $llvm_gpg_key 19 | and echo "Types: deb 20 | URIs: https://apt.llvm.org/$RELEASE/ 21 | Suites: llvm-toolchain 22 | Components: main 23 | Signed-By: $llvm_gpg_key" >/etc/apt/sources.list.d/llvm-main.sources 24 | and echo "Types: deb 25 | URIs: https://apt.llvm.org/$RELEASE/ 26 | Suites: llvm-toolchain-$llvm_stable_version 27 | Components: main 28 | Signed-By: $llvm_gpg_key" >/etc/apt/sources.list.d/llvm-stable.sources 29 | and set tc_packages {clang,lld,llvm}-$llvm_stable_version 30 | 31 | case '*' 32 | set tc_packages clang ll{d,vm} 33 | end 34 | 35 | # Download packages from repos 36 | and apt update 37 | and apt install -y \ 38 | $tc_packages \ 39 | gh 40 | -------------------------------------------------------------------------------- /pkgbuilds/cvise/PKGBUILD: -------------------------------------------------------------------------------- 1 | # Maintainer: Nathan Chancellor 2 | pkgname=cvise 3 | pkgver=2.11.0 4 | pkgrel=1 5 | pkgdesc="Super-parallel Python port of the C-Reduce" 6 | arch=(x86_64) 7 | url="https://github.com/marxin/cvise" 8 | license=('NCSA') 9 | depends=( 10 | clang 11 | llvm-libs 12 | python 13 | python-chardet 14 | python-msgspec 15 | python-pebble 16 | python-psutil 17 | python-zstandard 18 | unifdef 19 | ) 20 | makedepends=( 21 | cmake 22 | git 23 | flex 24 | llvm 25 | ) 26 | checkdepends=( 27 | python-jsonschema 28 | python-pytest 29 | python-pytest-mock 30 | python-pytest-subprocess 31 | ) 32 | optdepends=('colordiff: Show diffs in color') 33 | # source=("$pkgname-$pkgver.tar.gz::https://github.com/marxin/$pkgname/archive/refs/tags/v$pkgver.tar.gz") 34 | source=("git+$url.git") 35 | sha256sums=('SKIP') 36 | 37 | pkgver() { 38 | cd "$pkgname" 39 | git describe --long --abbrev=7 | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' 40 | } 41 | 42 | build() { 43 | # cd "$pkgname-$pkgver" 44 | cd "$pkgname" 45 | 46 | cmake \ 47 | -B build \ 48 | -DCMAKE_BUILD_TYPE=None \ 49 | -DCMAKE_INSTALL_PREFIX=/usr \ 50 | -DCMAKE_INSTALL_LIBEXECDIR=/usr/lib/$pkgname \ 51 | -DCMAKE_PREFIX_PATH=/usr \ 52 | -Wno-dev 53 | 54 | make -C build 55 | } 56 | 57 | check() { 58 | # cd "$pkgname-$pkgver" 59 | cd "$pkgname" 60 | 61 | make -C build test 62 | } 63 | 64 | package() { 65 | # cd "$pkgname-$pkgver" 66 | cd "$pkgname" 67 | 68 | make -C build DESTDIR="$pkgdir/" install 69 | install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE" 70 | } 71 | -------------------------------------------------------------------------------- /fish/functions/prep_pkg_for_vm.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | function prep_pkg_for_vm -d "Prepare package building files for virtual machine build" 6 | set package $argv[1] 7 | if test -z "$package" 8 | read -P 'Package to build: ' package 9 | end 10 | 11 | set arch (uname -m) 12 | set vm $argv[2] 13 | if test -z "$vm" 14 | __print_warning "No virtual machine, assuming default for $arch..." 15 | switch $arch 16 | case aarch64 17 | set vm fedora 18 | case x86_64 19 | set vm arch 20 | end 21 | end 22 | 23 | if string match -qr arch $vm 24 | set package_dirs $ENV_FOLDER/pkgbuilds/$package $SRC_FOLDER/packaging/pkg/$package 25 | end 26 | if string match -qr fedora $vm 27 | set package_dirs $ENV_FOLDER/specs/$package $SRC_FOLDER/packaging/rpm/$package 28 | end 29 | for item in $package_dirs 30 | if test -d $item 31 | set src_dir $item 32 | end 33 | end 34 | if not set -q src_dir 35 | __print_error "Could not find source for package '$package' in possible locations '$package_dirs'!" 36 | return 1 37 | end 38 | 39 | set dst_dir $VM_FOLDER/$arch/$vm/shared/$package 40 | 41 | if test -e $src_dir/.git 42 | remkdir $dst_dir 43 | echo "Copying $src_dir to $dst_dir via 'git archive'..." 44 | git -C $src_dir archive --format=tar HEAD | tar -C $dst_dir -vxf - 45 | else 46 | rm -fr $dst_dir 47 | mkdir -p (path dirname $dst_dir) 48 | cp -rv $src_dir (path dirname $dst_dir) 49 | end 50 | end 51 | -------------------------------------------------------------------------------- /fish/functions/kboot.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function kboot -d "Boot a kernel in QEMU" 6 | if not __in_container; and test -z "$OC" 7 | __print_error "This needs to be run in a container! Override this check with 'OC=1'." 8 | return 1 9 | end 10 | 11 | # Ensure that all PATH modifications are local to this function (like a subshell) 12 | set -lx PATH $PATH 13 | 14 | for arg in $argv 15 | switch $arg 16 | case -k --kbuild-folder 17 | set kernel true 18 | set -a boot_qemu_args $arg 19 | 20 | case '*' 21 | set -a boot_qemu_args $arg 22 | end 23 | end 24 | 25 | if not set -q kernel 26 | set -a boot_qemu_args -k (tbf) 27 | end 28 | if not string match -qr -- --gh-json-file $boot_qemu_args 29 | set boot_utils_json /tmp/boot-utils.json 30 | if not test -e $boot_utils_json 31 | __gen_boot_utils_json 32 | or return 33 | end 34 | set -a boot_qemu_args --gh-json-file $boot_utils_json 35 | end 36 | 37 | if test -z "$BU" 38 | set BU $CBL_SRC_C/boot-utils 39 | end 40 | if not test -d "$BU" 41 | mkdir -p (path dirname $BU) 42 | git clone https://github.com/ClangBuiltLinux/boot-utils $BU; or return 43 | end 44 | if test "$U" != 0 45 | git -C $BU pull -q -r; or return 46 | end 47 | 48 | if set -q PO 49 | set -p PATH $PO 50 | end 51 | 52 | set boot_qemu_cmd \ 53 | $BU/boot-qemu.py $boot_qemu_args 54 | print_cmd $boot_qemu_cmd 55 | $boot_qemu_cmd 56 | end 57 | -------------------------------------------------------------------------------- /configs/tmux/.tmux.conf.common: -------------------------------------------------------------------------------- 1 | # New window on host using C 2 | bind-key C new-window 3 | 4 | # Run comand on the host using R 5 | bind-key R { 6 | command-prompt -p "run command (host):" { 7 | new-window 'begin; %1; end; or exec fish -l' 8 | } 9 | } 10 | 11 | # Split panes on the host using H and V 12 | bind-key V split-window -h 13 | bind-key H split-window -v 14 | unbind '"' 15 | unbind % 16 | 17 | # Base index is 1 instead of 0 18 | set -g base-index 1 19 | 20 | # Quick af escape time yo 21 | set -s escape-time 0 22 | 23 | # Aggressive resize 24 | setw -g aggressive-resize on 25 | 26 | ## set the default TERM 27 | set -g default-terminal "screen-256color" 28 | 29 | ## update the TERM variable of terminal emulator when creating a new session or attaching a existing session 30 | set -ag update-environment ' TERM' 31 | 32 | set-window-option -g mode-keys vi 33 | bind-key -T copy-mode-vi 'v' send -X begin-selection 34 | bind-key -T copy-mode-vi 'y' send -X copy-selection 35 | bind-key -T copy-mode-vi 'Space' send -X halfpage-down 36 | bind-key -T copy-mode-vi 'Bspace' send -X halfpage-up 37 | 38 | # Hella scrollback 39 | set-option -g history-limit 1000000 40 | 41 | set-option -g status-style "fg=#FFFFFF,bg=default,default" 42 | set-window-option -g window-status-style "fg=#FFFFFF,bg=default,default" 43 | 44 | set-option -g message-style "fg=#FFFFFF,bg=default,bright" 45 | set -g status-left " " 46 | set -g status-justify left 47 | setw -g window-status-format ' #I:#{pane_current_command} ' 48 | setw -g window-status-current-format ' #I:#{pane_current_command}* ' 49 | set -g status-right " " 50 | 51 | # Quick configuration reload with prefix + Ctrl + r 52 | bind C-r source-file ~/.tmux.conf \; display "Reloaded!" 53 | -------------------------------------------------------------------------------- /fish/functions/msh.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function msh -d "Shorthand for mosh -o" -w mosh 6 | for arg in $argv 7 | switch $arg 8 | case -t --tailscale 9 | set tailscale true 10 | case '*' 11 | set target $arg 12 | end 13 | end 14 | 15 | if test "$tailscale" = true 16 | switch $target 17 | case aadp honeycomb 18 | set host $target 19 | case amd-desktop-8745HS 20 | set host beelink-amd-ryzen-8745hs 21 | case chromebox 22 | set host chromebox3 23 | case framework-desktop 24 | set host framework-amd-ryzen-maxplus-395 25 | case intel-desktop-11700 26 | set host asus-intel-core-11700 27 | case intel-desktop-n100 28 | set host beelink-intel-n100 29 | case intel-laptop 30 | set host msi-intel-core-10210U 31 | case '*' 32 | __print_error "Unsupported target device for Tailscale: $target" 33 | return 1 34 | end 35 | set user_host nathan@$host 36 | else 37 | switch $target 38 | case aadp amd-desktop-8745HS chromebox framework-desktop hetzner honeycomb intel-desktop-11700 intel-desktop-n100 intel-laptop main 39 | set user_host nathan@(get_ip $target) 40 | 41 | case '*@*' 42 | set user_host $target 43 | 44 | case '*' 45 | __print_error "Please specify a valid shorthand or user@host combination!" 46 | return 1 47 | end 48 | end 49 | 50 | mosh $user_host 51 | end 52 | -------------------------------------------------------------------------------- /fish/functions/setup_systemd_files.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2025 Nathan Chancellor 4 | 5 | function setup_systemd_files -d "Set up various systemd files" 6 | set targets $argv 7 | # user implicitly depends on env 8 | if contains user $targets; and not contains env $targets 9 | set -a targets env 10 | end 11 | # nas must be run on the host and have mount.nfs installed 12 | if contains nas $targets 13 | __in_container_msg -h 14 | or return 15 | 16 | if not command -q mount.nfs 17 | __print_error "mount.nfs could not be found, install it!" 18 | return 1 19 | end 20 | end 21 | set systemd_configs $ENV_FOLDER/configs/systemd 22 | 23 | for target in $targets 24 | switch $target 25 | case env 26 | set env_file $HOME/.config/environment.d/50-personal-env.conf 27 | mkdir -p (path dirname $env_file) 28 | 29 | for var in CBL_SRC_M NAS_FOLDER PYTHON_SCRIPTS_FOLDER 30 | printf "%s=%s\n" $var (nspawn_path -H $$var) 31 | end >$env_file 32 | 33 | case nas 34 | sudo fish -c "cp -v $systemd_configs/mnt-nas.{auto,}mount /etc/systemd/system 35 | and chmod 644 /etc/systemd/system/mnt-nas.{auto,}mount 36 | and systemctl enable --now mnt-nas.automount" 37 | 38 | case user 39 | set user_cfg_dir $HOME/.config/systemd/user 40 | set user_files \ 41 | nas-bundles.{service,timer} 42 | 43 | mkdir -p $user_cfg_dir 44 | for user_file in $systemd_configs/$user_files 45 | ln -fnrsv $user_file $user_cfg_dir 46 | or return 47 | end 48 | end 49 | end 50 | end 51 | -------------------------------------------------------------------------------- /pkgbuilds/python-msgspec/PKGBUILD: -------------------------------------------------------------------------------- 1 | # Maintainer: Nathan Chancellor 2 | pkgname=python-msgspec 3 | _name=${pkgname#python-} 4 | pkgver=0.19.0 5 | pkgrel=1 6 | pkgdesc="A fast serialization and validation library, with builtin support for JSON, MessagePack, YAML, and TOML" 7 | arch=(x86_64) 8 | url="https://github.com/jcrist/msgspec" 9 | license=(BSD-3-Clause) 10 | depends=( 11 | glibc 12 | python 13 | python-attrs 14 | python-typing_extensions 15 | ) 16 | makedepends=( 17 | git 18 | python-build 19 | python-installer 20 | python-setuptools 21 | python-setuptools-scm 22 | python-wheel 23 | ) 24 | checkdepends=( 25 | mypy 26 | python-msgpack 27 | python-pytest 28 | ) 29 | optdepends=( 30 | 'python-tomli-w: for TOML support' 31 | 'python-tomli: for TOML support' 32 | 'python-yaml: for YAML support' 33 | ) 34 | #source=("$pkgname-$pkgver.tar.gz::$url/archive/refs/tags/$pkgver.tar.gz") 35 | source=("git+$url.git") 36 | sha256sums=('SKIP') 37 | 38 | pkgver() { 39 | cd "${_name}" 40 | 41 | git describe --abbrev=7 --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g' 42 | } 43 | 44 | build() { 45 | cd "${_name}" 46 | # cd "${_name}-$pkgver" 47 | 48 | python -m build --wheel --no-isolation 49 | } 50 | 51 | check() { 52 | cd "${_name}" 53 | # cd "${_name}-$pkgver" 54 | local python_version=$(python -c 'import sys; print("".join(map(str, sys.version_info[:2])))') 55 | 56 | # Error on 'import pyright' even with pyright in checkdepends 57 | rm tests/typing/test_pyright.py 58 | 59 | PYTHONDONTWRITEBYTECODE=1 PYTHONPATH="$PWD/build/lib.linux-$CARCH-cpython-$python_version" pytest 60 | } 61 | 62 | package() { 63 | cd "${_name}" 64 | # cd "${_name}-$pkgver" 65 | 66 | python -m installer --destdir="$pkgdir" dist/*.whl 67 | 68 | install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE" 69 | } 70 | -------------------------------------------------------------------------------- /python/pgo-llvm-builder/dep-vers.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | 3 | function get_current_release 4 | set -l binary $argv[1] 5 | set -l file $PYTHON_FOLDER/pgo-llvm-builder/mkosi.postinst.d/*-modern-$binary.*.chroot 6 | if test -z "$file" 7 | __print_error "Could not find $binary file in $PYTHON_FOLDER/pgo-llvm-builder" 8 | exit 128 9 | end 10 | 11 | if not set -l current_ver (string match -gr 'version(?: |=)([0-9|.]+)$' <$file) 12 | __print_error "Could not find version in $file" 13 | exit 128 14 | end 15 | 16 | printf '%8s%8s | ' $binary: $current_ver 17 | end 18 | 19 | function get_latest_release 20 | set -l url 21 | set -l refspec 22 | 23 | for arg in $argv 24 | switch $arg 25 | case https://'*' 26 | set url $arg 27 | case refs/tags/'*' 28 | set refspec $arg 29 | end 30 | end 31 | if test -z "$url" 32 | __print_error "No URL provided?" 33 | exit 128 34 | end 35 | if test -z "$refspec" 36 | set refspec refs/tags/v'*' 37 | end 38 | 39 | set -l latest_ver 0 40 | git ls-remote --refs $url $refspec | string match -gr 'refs/tags/v?([0-9|.]+)$' | while read -l current_ver 41 | if test (vercmp $current_ver $latest_ver) -gt 0 42 | set latest_ver $current_ver 43 | end 44 | end 45 | printf '%s\n' $latest_ver 46 | end 47 | 48 | printf '%16s | latest\n' current 49 | 50 | get_current_release cmake 51 | get_latest_release https://github.com/Kitware/CMake 52 | 53 | get_current_release fish 54 | get_latest_release https://github.com/fish-shell/fish-shell refs/tags/'*' 55 | 56 | get_current_release ninja 57 | get_latest_release https://github.com/ninja-build/ninja 58 | 59 | get_current_release python 60 | get_latest_release https://github.com/python/cpython 61 | 62 | get_current_release zstd 63 | get_latest_release https://github.com/facebook/zstd 64 | -------------------------------------------------------------------------------- /configs/common/colors.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # SPDX-License-Identifier: MIT 3 | # 4 | # Copyright (C) 2021 Nathan Chancellor 5 | 6 | RESET="\033[0m" 7 | BRIGHT_FOREGROUND="\033[1m" 8 | 9 | BLACK="\033[30m" 10 | BRIGHT_BLACK="\033[01;30m" 11 | 12 | RED="\033[31m" 13 | BRIGHT_RED="\033[01;31m" 14 | 15 | GREEN="\033[32m" 16 | BRIGHT_GREEN="\033[01;32m" 17 | 18 | YELLOW="\033[33m" 19 | BRIGHT_YELLOW="\033[01;33m" 20 | 21 | BLUE="\033[34m" 22 | BRIGHT_BLUE="\033[01;34m" 23 | 24 | MAGENTA="\033[35m" 25 | BRIGHT_MAGENTA="\033[01;35m" 26 | 27 | CYAN="\033[36m" 28 | BRIGHT_CYAN="\033[01;36m" 29 | 30 | GRAY="\033[37m" 31 | WHITE="\033[01;37m" 32 | 33 | printf '\nThis is a test of FOREGROUND\n' 34 | printf '%bThis is a test of BRIGHT_FOREGROUND%b\n\n' "${BRIGHT_FOREGROUND}" "${RESET}" 35 | 36 | printf '%bThis is a test of BLACK%b\n' "${BLACK}" "${RESET}" 37 | printf '%bThis is a test of BRIGHT_BLACK%b\n\n' "${BRIGHT_BLACK}" "${RESET}" 38 | 39 | printf '%bThis is a test of RED%b\n' "${RED}" "${RESET}" 40 | printf '%bThis is a test of BRIGHT_RED%b\n\n' "${BRIGHT_RED}" "${RESET}" 41 | 42 | printf '%bThis is a test of GREEN%b\n' "${GREEN}" "${RESET}" 43 | printf '%bThis is a test of BRIGHT_GREEN%b\n\n' "${BRIGHT_GREEN}" "${RESET}" 44 | 45 | printf '%bThis is a test of YELLOW%b\n' "${YELLOW}" "${RESET}" 46 | printf '%bThis is a test of BRIGHT_YELLOW%b\n\n' "${BRIGHT_YELLOW}" "${RESET}" 47 | 48 | printf '%bThis is a test of BLUE%b\n' "${BLUE}" "${RESET}" 49 | printf '%bThis is a test of BRIGHT_BLUE%b\n\n' "${BRIGHT_BLUE}" "${RESET}" 50 | 51 | printf '%bThis is a test of MAGENTA%b\n' "${MAGENTA}" "${RESET}" 52 | printf '%bThis is a test of BRIGHT_MAGENTA%b\n\n' "${BRIGHT_MAGENTA}" "${RESET}" 53 | 54 | printf '%bThis is a test of CYAN%b\n' "${CYAN}" "${RESET}" 55 | printf '%bThis is a test of BRIGHT_CYAN%b\n\n' "${BRIGHT_CYAN}" "${RESET}" 56 | 57 | printf '%bThis is a test of GRAY%b\n' "${GRAY}" "${RESET}" 58 | printf '%bThis is a test of WHIE%b\n\n' "${WHITE}" "${RESET}" 59 | -------------------------------------------------------------------------------- /fish/functions/_hydro_addon_nathan.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2022-2023 Nathan Chancellor 4 | 5 | function _hydro_addon_nathan -d "Hydro prompt customizations" 6 | # New line to make prompt a little more spacious 7 | printf '\\\\n' 8 | 9 | # Signal if we are in a Python virtual environment 10 | if __in_venv 11 | printf '%b(%s) ' (set_color 4B8BBE) (path basename $VIRTUAL_ENV) 12 | end 13 | 14 | if __in_deb_chroot 15 | printf '%b(chroot:%s) ' (set_color yellow) (cat /etc/debian_chroot) 16 | end 17 | 18 | # Print symbol if we are in a container (like default toolbox prompt) 19 | if __in_nspawn 20 | if set incoming (findmnt -n -o FSROOT /run/host/incoming | path sort -u) 21 | set container_str '('(string split -f 2 -m 1 -r / $incoming)')' 22 | else if set image_id (string match -gr 'IMAGE_ID="?([^"]+)' $dst 45 | and rm -fr $PWD 46 | and popd 47 | end; or return 48 | else 49 | __print_error "No suitable way to generate initrd found?" 50 | return 1 51 | end 52 | end 53 | 54 | echo "Initial ramdisk is available at: $dst" 55 | end 56 | -------------------------------------------------------------------------------- /pkgbuilds/gdb-multiarch/PKGBUILD: -------------------------------------------------------------------------------- 1 | # Maintainer: Nathan Chancellor 2 | # Contributor: Levente Polyak 3 | # Contributor: Anatol Pomozov 4 | # Contributor: Allan McRae 5 | # Contributor: Jan de Groot 6 | 7 | pkgname=gdb-multiarch 8 | pkgver=16.2 9 | pkgrel=1 10 | pkgdesc='The GNU Debugger' 11 | arch=(x86_64) 12 | url='https://www.gnu.org/software/gdb/' 13 | license=(GPL-3.0-or-later) 14 | depends=(glibc ncurses libncursesw.so gcc-libs expat xz mpfr source-highlight 15 | readline libreadline.so guile python libelf) 16 | makedepends=(texinfo boost) 17 | backup=(etc/gdb/gdbinit) 18 | options=(!lto) # too many errors at the moment 19 | source=(https://ftp.gnu.org/gnu/gdb/gdb-${pkgver}.tar.xz{,.sig}) 20 | sha1sums=('ddc8916d192286ff41e58c108e0f6cf55cb0e2f5' 21 | 'SKIP') 22 | b2sums=('480cc5c116e418d7eb13a68bee8a2ced8e7a40bd38826dde3590a8d5b690c3dd46be6fa3790518b39ac7255698a1ecf35a2bb51d7e38d849f7b9277c15fe38fc' 23 | 'SKIP') 24 | validpgpkeys=('F40ADB902B24264AA42E50BF92EDB04BFF325CF3') # Joel Brobecker 25 | 26 | build() { 27 | cd gdb-$pkgver 28 | 29 | mkdir -p build && cd build 30 | ../configure \ 31 | --prefix=/usr \ 32 | --disable-nls \ 33 | --enable-languages=all \ 34 | --enable-source-highlight \ 35 | --enable-targets=all \ 36 | --enable-tui \ 37 | --with-system-readline \ 38 | --with-python=/usr/bin/python \ 39 | --with-system-gdbinit=/etc/gdb/gdbinit 40 | make 41 | } 42 | 43 | package() { 44 | 45 | cd gdb-$pkgver/build 46 | make -C gdb DESTDIR="$pkgdir" install 47 | make -C gdbserver DESTDIR="$pkgdir" install 48 | make -C gdb/data-directory DESTDIR="$pkgdir" install 49 | 50 | # install "custom" system gdbinit 51 | install -dm 755 "$pkgdir/etc/gdb" 52 | touch "$pkgdir/etc/gdb/gdbinit" 53 | 54 | # Symlink 'gdb' binary to 'gdb-multiarch' for interoperability purposes 55 | ln -s gdb "$pkgdir/usr/bin/$pkgname" 56 | } 57 | 58 | # vim: ts=2 sw=2 et: 59 | -------------------------------------------------------------------------------- /fish/functions/sd_boot_kernel.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | function sd_boot_kernel -d "Boot a kernel via full reboot or kexec using systemd" 6 | for arg in $argv 7 | switch $arg 8 | case -k --kexec 9 | set reboot kexec 10 | case -r --reboot 11 | set reboot reboot 12 | case --when='*' 13 | set -a systemctl_args $arg 14 | case '*' 15 | if test $arg = linux 16 | set krnl linux 17 | else 18 | set krnl linux-(string replace 'linux-' '' $arg) 19 | end 20 | end 21 | end 22 | 23 | if not set -q krnl 24 | __print_error "Kernel is required!" 25 | return 1 26 | end 27 | 28 | sudo true 29 | or return 30 | 31 | switch $reboot 32 | case kexec 33 | if not command -q kexec 34 | __print_error "Cannot kexec without kexec-tools" 35 | return 1 36 | end 37 | 38 | sudo kexec \ 39 | --load \ 40 | /boot/vmlinuz-$krnl \ 41 | --initrd=/boot/initramfs-$krnl.img \ 42 | --reuse-cmdline 43 | or return 44 | 45 | case reboot 46 | if not test -d /sys/firmware/efi 47 | __print_error "Not booted under UEFI?" 48 | return 1 49 | end 50 | 51 | set entries /boot/loader/entries 52 | if not test -d $entries 53 | __print_error "$entries not found, not using systemd-boot?" 54 | return 1 55 | end 56 | 57 | set conf $krnl.conf 58 | if not test -f $entries/$conf 59 | __print_error "$entries/$conf does not exist!" 60 | return 1 61 | end 62 | 63 | set -a systemctl_args --boot-loader-entry=$conf 64 | end 65 | 66 | sudo systemctl $reboot $systemctl_args 67 | end 68 | -------------------------------------------------------------------------------- /fish/functions/cbl_test_kvm.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function cbl_test_kvm -d "Test KVM against a Clang built kernel with QEMU" 6 | have_dev_kvm_access; or return 7 | 8 | switch $argv[1] 9 | case build 10 | __in_container_msg -c; or return 11 | 12 | set arch (uname -m) 13 | switch $arch 14 | case aarch64 15 | set arch arm64 16 | case x86_64 17 | : 18 | case '*' 19 | __print_error "cbl_test_kvm does not support $arch!" 20 | return 1 21 | end 22 | 23 | set src $CBL_SRC_C/linux 24 | set out (tbf $src) 25 | 26 | cbl_upd_src c m 27 | 28 | if test -e $CBL_TC_LLVM/clang 29 | set tc_arg LLVM=1 30 | else 31 | korg_llvm install \ 32 | --clean-up-old-versions \ 33 | --versions $LLVM_VERSION_STABLE 34 | set tc_arg (korg_llvm var) 35 | end 36 | 37 | kmake -C $src $tc_arg O=$out distclean defconfig all 38 | or return 39 | 40 | kboot -a $arch -k $out -t 45s 41 | 42 | case nested 43 | __in_container_msg -h; or return 44 | 45 | switch $LOCATION 46 | case vm 47 | updfull 48 | mkdir -p $TMP_FOLDER 49 | cp -v /boot/vmlinuz-linux $TMP_FOLDER/bzImage 50 | sd_nspawn -r 'kboot -a x86_64 -k '(nspawn_path -c $TMP_FOLDER)'/bzImage -t 30s' 51 | end 52 | 53 | case vmm 54 | cbl_vmm run; or return 55 | if test (uname -m) = aarch64 56 | cbl_clone_repo boot-utils; or return 57 | if $CBL_GIT/boot-utils/utils/aarch64_32_bit_el1_supported 58 | cbl_vmm run -a arm; or return 59 | end 60 | end 61 | exit 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /fish/functions/cbl_prep_bisect.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2025 Nathan Chancellor 4 | 5 | function cbl_prep_bisect -d "Prepare for an automated bisect" 6 | if test (count $argv) -ne 1 7 | __print_error (status function)" " 8 | return 1 9 | end 10 | 11 | cbl_clone_repo repro-scripts 12 | 13 | if not set -g bisect_script (mktemp --suffix=.fish -p $CBL_MISC/repro-scripts) 14 | print_error "Unable to create bisect script?" 15 | return 1 16 | end 17 | chmod +x $bisect_script 18 | 19 | switch $argv[1] 20 | case config 21 | echo '#!/usr/bin/env fish 22 | 23 | __in_tree kernel 24 | or return 128 25 | 26 | set lnx_bld (tbf)-testing 27 | 28 | set common_make_flags 29 | 30 | set j_flag -j(nproc) 31 | 32 | set fish_trace 1 33 | 34 | MAKEFLAGS="$j_flag $common_make_flags" tools/testing/ktest/config-bisect.pl -b $lnx_bld /config-{good,bad} $argv[1] 35 | or return 128 36 | 37 | kmake $common_make_flags O=$lnx_bld' >$bisect_script 38 | 39 | case kernel 40 | echo '#!/usr/bin/env fish 41 | 42 | __in_tree kernel 43 | or return 128 44 | 45 | set lnx_bld (tbf)-testing 46 | 47 | kmake \ 48 | (korg_llvm var) \ 49 | O=$lnx_bld \ 50 | mrproper &| string match -er \'\' 51 | switch "$pipestatus" 52 | case \'0 1\' 53 | return 0 54 | case \'1 0\' 55 | return 1 56 | end 57 | return 125' >$bisect_script 58 | 59 | case llvm 60 | echo '#!/usr/bin/env fish 61 | 62 | __in_tree llvm 63 | or return 128 64 | 65 | set llvm_bld (tbf)-testing 66 | 67 | cbl_bld_llvm_fast \ 68 | --build-folder $llvm_bld 69 | or return 125 70 | 71 | set lnx_src $CBL_SRC_C/linux 72 | set lnx_bld (tbf $lnx_src)-testing 73 | 74 | kmake \ 75 | -C $lnx_src \ 76 | LLVM=$llvm_bld/final/bin/ \ 77 | O=$lnx_bld \ 78 | mrproper &| string match -er \'\' 79 | switch "$pipestatus" 80 | case \'0 1\' 81 | return 0 82 | case \'1 0\' 83 | return 1 84 | end 85 | return 125' >$bisect_script 86 | end 87 | 88 | vim $bisect_script 89 | end 90 | -------------------------------------------------------------------------------- /fish/completions/build-llvm.py.fish: -------------------------------------------------------------------------------- 1 | complete -c build-llvm.py -f -l assertions -d "Force enable assertions" 2 | complete -c build-llvm.py -f -l bolt -d "Perform BOLT on final clang" 3 | complete -c build-llvm.py -x -s b -l build-folder -d "Build folder" -a "(__fish_complete_directories)" 4 | complete -c build-llvm.py -x -l build-targets -d "Targets to build" 5 | complete -c build-llvm.py -f -l build-stage1-only -d "Build LLVM in one stage" 6 | complete -c build-llvm.py -x -l build-type -d "Build type" -a "Debug Release RelWithDebInfo" 7 | complete -c build-llvm.py -x -l check-targets -d "Targets to check" 8 | complete -c build-llvm.py -x -s D -l defines -d "cmake defines" 9 | complete -c build-llvm.py -f -s f -l full-toolchain -d "Don't slim down LLVM build" 10 | complete -c build-llvm.py -x -s i -l install-folder -d "Install folder for toolchain" -a "(__fish_complete_directories)" 11 | complete -c build-llvm.py -x -l install-targets -d "Targets to install" 12 | complete -c build-llvm.py -x -s l -l llvm-folder -d "LLVM source folder" -a "(__fish_complete_directories)" 13 | complete -c build-llvm.py -x -s L -l linux-folder -d "Linux source folder" -a "(__fish_complete_directories)" 14 | complete -c build-llvm.py -x -l lto -d "Enable LTO" -a "full thin" 15 | complete -c build-llvm.py -f -s n -l no-update -d "Do not update LLVM" 16 | complete -c build-llvm.py -f -l no-ccache -d "Disable ccache" 17 | complete -c build-llvm.py -x -s p -l projects -d "Projects to build" 18 | set -l pgo_args kernel-{def,all{mod,yes}}config{,-slim} llvm 19 | complete -c build-llvm.py -x -l pgo -d "Build final clang with PGO" -a "$pgo_args" 20 | complete -c build-llvm.py -f -l quiet-cmake -d "Make cmake quieter" 21 | complete -c build-llvm.py -x -s r -l ref -d "git reference to build from" 22 | complete -c build-llvm.py -f -s s -l shallow-clone -d "Shallow clone LLVM repo" 23 | complete -c build-llvm.py -f -l show-build-commands -d "Print build commands" 24 | complete -c build-llvm.py -f -s t -l targets -d "Backends to enable" 25 | complete -c build-llvm.py -f -l use-good-revision -d "Use known good revision of LLVM" 26 | complete -c build-llvm.py -x -l vendor-string -d "Vendor string" 27 | -------------------------------------------------------------------------------- /fish/functions/cbl_gen_korg_llvm_announce.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2025 Nathan Chancellor 4 | 5 | function cbl_gen_korg_llvm_announce -d "Generate kernel.org LLVM release announcement" 6 | if test $PWD != $TMP_FOLDER/pgo-llvm-builder-staging 7 | __print_error "Not in $TMP_FOLDER/pgo-llvm-builder-staging?" 8 | return 1 9 | end 10 | 11 | if not test (count $argv) -eq 1 12 | __print_error (status function)' ' 13 | return 1 14 | end 15 | 16 | set llvm_ver $argv[1] 17 | set llvm_maj (string split -f 1 . $llvm_ver) 18 | 19 | for korg_user in ojeda 20 | set -a mutt_args -c $korg_user@kernel.org 21 | end 22 | 23 | echo "Hi all, 24 | 25 | I have built and uploaded LLVM $llvm_ver to 26 | https://mirrors.edge.kernel.org/pub/tools/llvm/. 27 | 28 | If there are any issues found, please let us know via email or 29 | https://github.com/ClangBuiltLinux/linux/issues/new, so that we have an 30 | opportunity to get them fixed in main and backported before the $llvm_maj.x 31 | series is no longer supported. 32 | 33 | Cheers, 34 | Nathan" >msg 35 | 36 | echo "#!/usr/bin/env fish 37 | 38 | echo 'Contents of msg for mailing list announcement:' 39 | echo 40 | cat msg 41 | echo 42 | 43 | read -P 'Would you like to edit the mailing list announcement before sending? [Y/N] ' req 44 | if test (string lower \$req) = y 45 | \$EDITOR msg 46 | end 47 | 48 | read -P 'Send mailing list announcement? [Y/N] ' req 49 | if test (string lower \$req) = y 50 | mutt $mutt_args -s 'Prebuilt LLVM $llvm_ver uploaded' -- llvm@lists.linux.dev linux-kernel@vger.kernel.org announce 62 | chmod +x announce 63 | end 64 | -------------------------------------------------------------------------------- /python/scripts/upd_distro.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | from argparse import ArgumentParser 6 | from pathlib import Path 7 | import sys 8 | 9 | sys.path.append(str(Path(__file__).resolve().parents[1])) 10 | # pylint: disable=wrong-import-position 11 | import lib.setup 12 | import lib.utils 13 | 14 | yes_arg = '-y' 15 | 16 | 17 | def brew(brew_args): 18 | lib.utils.run(['/opt/homebrew/bin/brew', *brew_args], show_cmd=True) 19 | 20 | 21 | parser = ArgumentParser(description='Update distribution') 22 | parser.add_argument(yes_arg, '--yes', action='store_true', help='Run noninteratively') 23 | args = parser.parse_args() 24 | 25 | if sys.platform == 'darwin': 26 | cmd_func = brew 27 | cmds = [ 28 | ['update'], 29 | ['upgrade'], 30 | ['upgrade', '--cask', 'wezterm@nightly', '--no-quarantine', '--greedy-latest'], 31 | ] 32 | yes_arg = None 33 | else: 34 | os_rel = lib.setup.get_os_rel() 35 | 36 | if os_rel['ID'] == 'arch': 37 | if not lib.utils.run_check_rc_zero(['checkupdates']): 38 | sys.exit(0) 39 | 40 | cmd_func = lib.setup.pacman 41 | cmds = [['-Syyu']] 42 | yes_arg = '--noconfirm' 43 | 44 | elif os_rel['ID'] in ('almalinux', 'fedora', 'rocky'): 45 | cmd_func = lib.setup.dnf 46 | cmds = [['update']] 47 | 48 | elif os_rel['ID'] == 'alpine': 49 | cmd_func = lib.setup.apk 50 | cmds = [ 51 | ['update'], 52 | ['upgrade'], 53 | ] 54 | yes_arg = None 55 | 56 | elif os_rel['ID'] in ('debian', 'raspbian', 'ubuntu'): 57 | cmd_func = lib.setup.apt 58 | cmds = [ 59 | ['update'], 60 | ['full-upgrade'], 61 | ['autoremove', '-y'], 62 | ] 63 | 64 | elif 'opensuse' in os_rel['ID']: 65 | cmd_func = lib.setup.zypper 66 | cmds = [['dup']] 67 | 68 | else: 69 | raise RuntimeError(f"Don't know how to handle '{os_rel['ID']}'?") 70 | 71 | for cmd in cmds: 72 | if args.yes and yes_arg and yes_arg not in cmd: 73 | cmd.append(yes_arg) 74 | cmd_func(cmd) 75 | -------------------------------------------------------------------------------- /fish/functions/install_arch_kernel.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | function install_arch_kernel -d "Install kernel for Arch Linux and reboot fully or via kexec" 6 | for arg in $argv 7 | switch $arg 8 | case -k --kexec -r --reboot 9 | set sd_boot_arg $arg 10 | case '*'.tar.zst 11 | set krnl_pkg $arg 12 | case '*' 13 | set krnl linux-(string replace 'linux-' '' $arg) 14 | end 15 | end 16 | 17 | if not set -q krnl 18 | if set -q sd_boot_arg 19 | __print_error "Kernel is required when performing reboot action!" 20 | return 1 21 | end 22 | if not set -q krnl_pkg 23 | __print_error "Kernel is required when locating kernel package!" 24 | return 1 25 | end 26 | end 27 | 28 | if not set -q krnl_pkg 29 | # Attempt to look for kernel. If there is one in /tmp, use that, as it means 30 | # it has been downloaded from another machine. Otherwise, look if there is a 31 | # package in the build folder or pkgbuild folder within the build folder. 32 | for search in /tmp (tbf $krnl){,/pkgbuild} 33 | if test -d $search 34 | # Ignore packages for headers, we do not build out of tree kernel 35 | # modules, so they are not needed. 36 | fd -e tar.zst -u $krnl $search | string match -rv headers | read -a krnl_pkg 37 | if test -n "$krnl_pkg" 38 | if test (count $krnl_pkg) = 1 39 | break 40 | else 41 | __print_error "Ambiguous kernels found: $krnl_pkg" 42 | return 1 43 | end 44 | end 45 | end 46 | end 47 | if test -z "$krnl_pkg" 48 | __print_error "Could not find kernel package for $krnl!" 49 | return 1 50 | end 51 | end 52 | 53 | sudo true 54 | or return 55 | 56 | sudo pacman -U --noconfirm $krnl_pkg 57 | or return 58 | 59 | if set -q sd_boot_arg 60 | sd_boot_kernel $sd_boot_arg $krnl 61 | end 62 | end 63 | -------------------------------------------------------------------------------- /python/scripts/tmxrun.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from argparse import ArgumentParser 4 | from pathlib import Path 5 | import sys 6 | 7 | sys.path.append(str(Path(__file__).resolve().parents[1])) 8 | # pylint: disable=wrong-import-position 9 | import lib.utils 10 | # pylint: enable=wrong-import-position 11 | 12 | parser = ArgumentParser( 13 | description='Run command in tmux with proper quoting to run in either host or container') 14 | parser.add_argument('-c', 15 | '--container', 16 | action='store_const', 17 | const='container', 18 | dest='mode', 19 | help='Run command in default development container') 20 | parser.add_argument('-H', 21 | '--host', 22 | action='store_const', 23 | const='host', 24 | dest='mode', 25 | help='Run command on the host') 26 | parser.add_argument('-d', '--detach', action='store_true', help='Do not switch to created window') 27 | parser.add_argument('-s', 28 | '--split-horizontal', 29 | action='store_const', 30 | const=['split-window', '-v'], 31 | dest='tmux_cmd', 32 | help='Split command in a horizontal pane') 33 | parser.add_argument('-v', 34 | '--split-vertical', 35 | action='store_const', 36 | const=['split-window', '-H'], 37 | dest='tmux_cmd', 38 | help='Split command in a vertical pane') 39 | parser.add_argument('cmd', help='Command and any arguments to run') 40 | args = parser.parse_args() 41 | 42 | if "'" in args.cmd: 43 | raise ValueError("Command cannot have ' in it!") 44 | 45 | mode = args.mode if args.mode else 'container' if lib.utils.in_container() else 'host' 46 | 47 | tmx_cmd = ['tmux'] 48 | if args.tmux_cmd: 49 | tmx_cmd += args.tmux_cmd 50 | else: 51 | tmx_cmd.append('new-window') 52 | if args.detach: 53 | tmx_cmd.append('-d') 54 | 55 | if mode == 'container': 56 | CMD_STR = f"sd_nspawn -r '{args.cmd}'; or exec fish -l" 57 | else: 58 | CMD_STR = f"begin; {args.cmd}; end; or exec fish -l" 59 | tmx_cmd.append(CMD_STR) 60 | 61 | lib.utils.run(tmx_cmd) 62 | -------------------------------------------------------------------------------- /python/pgo-llvm-builder/mkosi.postinst.d/03-modern-perf.fish.chroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # Description: Build and install a version of perf that matches the host machine's kernel version 3 | 4 | set workdir (mktemp -d) 5 | 6 | # Get host's kernel version 7 | if not set kernel_version (uname -r) 8 | echo "Failed to get host's kernel version!" 9 | return 1 10 | end 11 | 12 | if not string match -qr '^(?\d+)\.(?\d+)\.(?\d+)(?-rc\d+)?' $kernel_version 13 | echo "Did not find a kernel version match for host's kernel version: $kernel_version" 14 | return 1 15 | end 16 | 17 | if test -n "$rc" 18 | set url https://git.kernel.org/torvalds/t/linux-$maj.$min$rc.tar.gz 19 | else 20 | set ver $maj.$min 21 | if test $patch -gt 0 22 | set ver $ver.$patch 23 | end 24 | set url https://cdn.kernel.org/pub/linux/kernel/v$maj.x/linux-$ver.tar.xz 25 | end 26 | switch (string match -gr '\.(\w+)$' $url) 27 | case gz 28 | set tar_comp_arg -z 29 | case xz 30 | set tar_comp_arg -J 31 | case '*' 32 | echo "Unhandled compression algorithm: $comp" 33 | return 1 34 | end 35 | 36 | curl -LSs $url | tar -C $workdir --strip-components=1 -xf - $tar_comp_arg 37 | or return 38 | 39 | if test -e $workdir/tools/bpf/bpftool/sign.c 40 | echo 'diff --git a/tools/bpf/bpftool/sign.c b/tools/bpf/bpftool/sign.c 41 | index b34f74d210e9..9be9f1190d15 100644 42 | --- a/tools/bpf/bpftool/sign.c 43 | +++ b/tools/bpf/bpftool/sign.c 44 | @@ -30,6 +30,7 @@ 45 | 46 | static void display_openssl_errors(int l) 47 | { 48 | +#if 0 49 | char buf[OPEN_SSL_ERR_BUF_LEN]; 50 | const char *file; 51 | const char *data; 52 | @@ -45,6 +46,7 @@ static void display_openssl_errors(int l) 53 | p_err("OpenSSL %s: %s:%d", buf, file, line); 54 | } 55 | } 56 | +#endif 57 | } 58 | 59 | #define DISPLAY_OSSL_ERR(cond) \ 60 | ' | patch -d $workdir -p1 61 | or return 62 | end 63 | 64 | pushd $workdir/tools/perf 65 | or return 66 | 67 | fish_add_path -P /usr/local/bin 68 | 69 | make \ 70 | -f Makefile.perf \ 71 | -j(nproc) \ 72 | prefix=/usr/local \ 73 | LIBPFM4=1 \ 74 | NO_LIBLLVM=1 \ 75 | NO_LIBTRACEEVENT=1 \ 76 | NO_SDT=1 \ 77 | PYTHON=(command -v python3) \ 78 | PYTHON_CONFIG=(command -v python3-config) \ 79 | VF=0 \ 80 | install 81 | or return 82 | 83 | popd 84 | rm -fr $workdir 85 | -------------------------------------------------------------------------------- /fish/functions/__clone_repo_from_bundle.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2024 Nathan Chancellor 4 | 5 | function __clone_repo_from_bundle -d "Clone repo using a clone bundle if possible" 6 | set num_args (count $argv) 7 | if test $num_args -lt 2; or test $num_args -gt 3 8 | __print_error "$(status function) ()" 9 | return 1 10 | end 11 | 12 | set repo $argv[1] 13 | switch $repo 14 | case binutils 15 | set url https://sourceware.org/git/binutils-gdb.git 16 | case linux 17 | set user_repo torvalds/linux 18 | case linux-next 19 | set user_repo next/linux-next 20 | case linux-stable 21 | set user_repo stable/linux 22 | case llvm-project 23 | set branch main 24 | set url https://github.com/llvm/llvm-project.git 25 | case '*' 26 | __print_error "Unsupported repo ('$repo') provided!" 27 | return 1 28 | end 29 | 30 | set dest $argv[2] 31 | if test -e $dest 32 | __print_warning "Destination ('$dest') already exists, skipping..." 33 | return 0 34 | end 35 | 36 | set nas_bundle $NAS_FOLDER/bundles/$repo.bundle 37 | if test -e $nas_bundle 38 | set bundle $nas_bundle 39 | end 40 | if not set -q bundle 41 | if test $num_args -eq 3 42 | set bundle $argv[3] 43 | if not test -e $bundle 44 | __print_warning "Provided bundle ('$bundle') does not existing, cloning via $url..." 45 | set -e bundle 46 | end 47 | end 48 | end 49 | 50 | if not set -q url 51 | set url https://git.kernel.org/pub/scm/linux/kernel/git/$user_repo.git/ 52 | end 53 | 54 | if not set -q branch 55 | set branch master 56 | end 57 | 58 | mkdir -p (path dirname $dest) 59 | 60 | if set -q bundle 61 | git clone $bundle $dest 62 | and git -C $dest remote remove origin 63 | and git -C $dest remote add origin $url 64 | and git -C $dest remote update --prune origin 65 | and git -C $dest checkout $branch 66 | and git -C $dest branch --set-upstream-to origin/$branch 67 | and git -C $dest reset --hard origin/$branch 68 | else 69 | git clone $url $dest 70 | end 71 | end 72 | -------------------------------------------------------------------------------- /fish/functions/lei_setup.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function lei_setup -d "Sets up local email interface for Linux kernel mailing lists" 6 | # Make sure that folders exists that will hold configuration files 7 | mkdir -p $XDG_FOLDER/{cache,config,share}/lei $MAIL_FOLDER 8 | 9 | # Setup query for certain lists that are interesting 10 | set -a lists_query l:kernel-janitors.vger.kernel.org 11 | set -a lists_query OR 12 | set -a lists_query l:linux-arm-kernel.lists.infradead.org 13 | set -a lists_query OR 14 | set -a lists_query l:linux-kbuild.vger.kernel.org 15 | set -a lists_query OR 16 | set -a lists_query l:linux-kernel.vger.kernel.org 17 | set -a lists_query OR 18 | set -a lists_query l:linux-m68k.vger.kernel.org 19 | set -a lists_query OR 20 | set -a lists_query l:linux-next.vger.kernel.org 21 | set -a lists_query OR 22 | set -a lists_query l:linuxppc-dev.lists.ozlabs.org 23 | set -a lists_query OR 24 | set -a lists_query l:linux-riscv.lists.infradead.org 25 | set -a lists_query OR 26 | set -a lists_query l:linux-s390.vger.kernel.org 27 | set -a lists_query OR 28 | set -a lists_query l:stable.vger.kernel.org 29 | set -a lists_query OR 30 | set -a lists_query l:tools.linux.kernel.org 31 | set -a lists_query OR 32 | set -a lists_query l:workflows.vger.kernel.org 33 | 34 | lei q -I https://lore.kernel.org/all/ -o $MAIL_FOLDER/lists --dedupe=mid "($lists_query) AND rt:1.week.ago.." 35 | or return 36 | 37 | # Setup query for LLVM mail that might not be CC'd to llvm@lists.linux.dev or me 38 | set -a lists_query OR l:netdev.vger.kernel.org 39 | set llvm_exclusions {t, OR c}:llvm@lists.linux.dev "OR "{f,t,c}:nathan@kernel.org 40 | set llvm_inclusions {nq:c, OR nq:C}lang "OR nq:"{LLVM,llvm} 41 | 42 | lei q -I https://lore.kernel.org/all/ -o $MAIL_FOLDER/llvm --dedupe=mid "($lists_query) AND NOT ($llvm_exclusions) AND ($llvm_inclusions) AND rt:1.week.ago.." 43 | or return 44 | 45 | lei q -I https://lore.kernel.org/all/ -o $MAIL_FOLDER/kvmarm --dedupe=mid "(l:kvmarm@lists.cs.columbia.edu OR l:kvmarm@lists.linux.dev) AND rt:1.week.ago.." 46 | or return 47 | 48 | lei q -I https://lore.kernel.org/all/ -o $MAIL_FOLDER/kbuild --dedupe=mid "l:linux-kbuild.vger.kernel.org AND rt:2.week.ago.." 49 | end 50 | -------------------------------------------------------------------------------- /fish/functions/cbl_bld_tot_gcc.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2025 Nathan Chancellor 4 | 5 | function cbl_bld_tot_gcc -d "Build tip of tree GCC (often for comparison against clang)" 6 | if not set -q gcc_src 7 | set gcc_src $CBL_SRC_C/gcc 8 | end 9 | if not test -d $gcc_src 10 | git clone https://gcc.gnu.org/git/gcc.git $gcc_src 11 | or return 12 | end 13 | 14 | set binutils_src $CBL_SRC_C/binutils 15 | if not test -d $binutils_src 16 | __clone_repo_from_bundle (path basename $binutils_src) $binutils_src 17 | or return 18 | end 19 | begin 20 | python3 -c (string match -er '^LATEST_BINUTILS_RELEASE =' <$CBL_GIT/tc-build/build-binutils.py)"; print('binutils-' + '_'.join(str(x) for x in LATEST_BINUTILS_RELEASE if x))" | read binutils_tag 21 | and git -C $binutils_src remote update -p 22 | and git -C $binutils_src switch -d $binutils_tag 23 | end 24 | or return 25 | 26 | set date_time (date +%F_%H-%M-%S) 27 | set gcc_base_ver (cat $gcc_src/gcc/BASE-VER) 28 | set gcc_hash (git -C $gcc_src sha) 29 | set prefix $CBL_TC_GCC_STORE/$gcc_base_ver-$date_time-$gcc_hash 30 | 31 | set make_flags -j(nproc) 32 | 33 | set buildall $GITHUB_FOLDER/buildall 34 | if not test -d $buildall 35 | git clone https://github.com/nathanchance/buildall $buildall 36 | or return 37 | end 38 | 39 | pushd $buildall 40 | or return 41 | 42 | git cl 43 | 44 | make $make_flags 45 | or return 46 | 47 | for target in (PYTHONPATH=$PY_S python3 -c "from korg_tc import GCCManager; print('\n'.join(item for item in sorted(target for target in GCCManager.TARGETS if target not in ('arm64', 'loongarch', 'riscv'))))") 48 | set -l extra_conf 49 | switch $target 50 | case x86_64 51 | set extra_conf EXTRA_GCC_CONF=--disable-multilib 52 | end 53 | 54 | begin 55 | echo "BINUTILS_SRC=$binutils_src 56 | CHECKING=release 57 | ECHO=/bin/echo 58 | EXTRA_BINUTILS_CONF=--disable-gprofng" 59 | if test -n "$extra_conf" 60 | echo $extra_conf 61 | end 62 | echo "GCC_SRC=$gcc_src 63 | MAKEOPTS=$make_flags 64 | PREFIX=$prefix" 65 | end >config 66 | cat config 67 | 68 | ./build --toolchain $target 69 | or return 70 | end 71 | end 72 | -------------------------------------------------------------------------------- /fish/functions/cbl_upd_stbl_wrktrs.fish: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fish 2 | # SPDX-License-Identifier: MIT 3 | # Copyright (C) 2021-2023 Nathan Chancellor 4 | 5 | function cbl_upd_stbl_wrktrs -d "Update the worktrees for linux-stable" 6 | for folder in $argv 7 | if not test -d "$folder" 8 | header "Cloning $folder" 9 | __clone_repo_from_bundle linux-stable $folder 10 | else 11 | header "Updating $folder" 12 | git -C $folder remote update origin 13 | end 14 | 15 | set dirname (path dirname $folder) 16 | if test $dirname = $CBL_SRC_D 17 | set stable_versions $SUPPORTED_STABLE_VERSIONS 18 | else 19 | set stable_versions $CBL_STABLE_VERSIONS 20 | end 21 | 22 | for worktree in $folder-* 23 | set basename (path basename $worktree) 24 | set stable_version (string split -f 3 '-' $basename) 25 | if not contains $stable_version $stable_versions 26 | header "Removing $worktree" 27 | # Non-temporal git worktrees need to use the host path, as the 28 | # have been converted to the host path below. 29 | git -C $folder worktree remove --force (nspawn_path -H $worktree) 30 | git -C $folder bd linux-$stable_version.y 31 | 32 | if test $dirname = $CBL_SRC_P 33 | set patches_repo $GITHUB_FOLDER/patches 34 | set patches_folder $patches_repo/$basename 35 | 36 | if test -d $patches_folder 37 | rm -r $patches_folder 38 | and git -C $patches_repo add $patches_folder 39 | and git -C $patches_repo c -m "patches: Remove $basename due to EOL" 40 | end 41 | or return 42 | end 43 | end 44 | end 45 | 46 | for worktree in $folder-$stable_versions 47 | if not test -d $worktree 48 | header "Creating $worktree" 49 | set -l branch (__stable_folder_to_branch $worktree) 50 | git -C $folder worktree add --track -b $branch $worktree origin/$branch 51 | end 52 | end 53 | 54 | # We need to ensure the git worktree links are valid for both 55 | # host and systemd-nspawn 56 | fix_wrktrs_for_nspawn $folder 57 | end 58 | end 59 | --------------------------------------------------------------------------------