├── dotfiles ├── Xresources ├── ssh-config ├── share │ └── icons │ │ └── default │ │ └── index.theme ├── bin │ ├── is-wayland │ ├── nmgui │ ├── clip │ ├── sysnformat │ ├── bench │ ├── battery-watchdog │ ├── gitree │ ├── check-deps-size │ ├── wifi-ap │ ├── cpu-usage │ ├── sysinfo │ ├── shot │ ├── compiler │ ├── howoldis │ ├── bestafk │ ├── git-change-author │ ├── toggle-audio-output │ ├── bspwmrc │ ├── record │ ├── system │ └── backup-sync ├── rofi-config ├── mimeapps.list ├── ros-container │ ├── tmux.conf │ ├── Webots-R2020a.conf │ ├── startup.sh │ ├── bashrc.sh │ └── Dockerfile ├── cava-config ├── esp-idf-shell.nix ├── alacritty-config.yml ├── vscodium-settings.json ├── kitty-config ├── evd-shell.nix ├── i3blocks-config ├── vis-config ├── sxhkdrc ├── sway-config ├── init.vim ├── polybar-config └── dunst-config ├── .gitignore ├── pkgs ├── nur-packages.nix ├── overlays │ ├── default.nix │ ├── overrides.nix │ ├── custom.nix │ └── dotfiles.nix ├── overrides │ ├── the-powder-toy.nix │ ├── urn.nix │ ├── emacs.nix │ ├── update-resolv-conf.nix │ └── neovim.nix └── custom │ ├── bobthefish.nix │ ├── kristvanity.nix │ ├── kernel-gcc-patch.nix │ ├── sway-session.nix │ ├── chip8.nix │ ├── ls_extended.nix │ ├── dotfiles-bin.nix │ ├── inter-font.nix │ ├── bitpocket.nix │ ├── technic-launcher.nix │ ├── esp32-toolchain.nix │ ├── dotfiles-background.nix │ ├── riko4.nix │ ├── luakit.nix │ ├── compton-latest.nix │ └── thelounge.nix ├── modules ├── hosts │ ├── nixos-qemu.nix │ ├── xenon.nix │ ├── helium.nix │ └── neon.nix ├── home │ ├── backup.nix │ ├── users.nix │ ├── default.nix │ ├── wayland.nix │ ├── cloud.nix │ ├── xserver.nix │ ├── shell.nix │ ├── hardware.nix │ └── packages.nix └── overrides │ └── thinkfan.nix ├── README.md └── LICENSE-MIT /dotfiles/Xresources: -------------------------------------------------------------------------------- 1 | Xcursor.theme: Paper 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | result 2 | nixos-qemu.qcow2 3 | TODO.md 4 | -------------------------------------------------------------------------------- /dotfiles/ssh-config: -------------------------------------------------------------------------------- 1 | host radon 2 | HostName radon 3 | Port 18903 4 | -------------------------------------------------------------------------------- /dotfiles/share/icons/default/index.theme: -------------------------------------------------------------------------------- 1 | [Icon Theme] 2 | Inherits=Paper 3 | -------------------------------------------------------------------------------- /dotfiles/bin/is-wayland: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | [ "$XDG_SESSION_TYPE" = wayland ] 4 | -------------------------------------------------------------------------------- /pkgs/nur-packages.nix: -------------------------------------------------------------------------------- 1 | { pkgs }: 2 | 3 | (import ./overlays/custom.nix) pkgs pkgs 4 | -------------------------------------------------------------------------------- /dotfiles/bin/nmgui: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | nm-applet > /dev/null 2>&1 & 4 | stalonetray > /dev/null 2>&1 5 | killall nm-applet 6 | -------------------------------------------------------------------------------- /pkgs/overlays/default.nix: -------------------------------------------------------------------------------- 1 | [ 2 | (import ./overrides.nix) 3 | (import ./custom.nix) 4 | (import ./dotfiles.nix) 5 | ] 6 | -------------------------------------------------------------------------------- /dotfiles/bin/clip: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if is-wayland; then 4 | wl-copy "$@" 5 | else 6 | xclip -selection clipboard "$@" 7 | fi 8 | -------------------------------------------------------------------------------- /dotfiles/bin/sysnformat: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | VALUE=$(awk "BEGIN { a=$1 / 1000000; print a }") 4 | 5 | printf "%.2f" "$VALUE" 6 | -------------------------------------------------------------------------------- /dotfiles/rofi-config: -------------------------------------------------------------------------------- 1 | configuration { 2 | run-shell-command: "{terminal} {cmd}"; 3 | modi: "combi"; 4 | show-icons: true; 5 | combi-modi: "drun,run"; 6 | } 7 | @theme "glue_pro_blue" 8 | -------------------------------------------------------------------------------- /dotfiles/bin/bench: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | threads="$(nproc)" 4 | 5 | sysbench cpu --cpu-max-prime=20000 --threads="$threads" run | grep "events per second" 6 | sysbench memory --threads="$threads" run | grep "transferred" 7 | -------------------------------------------------------------------------------- /dotfiles/mimeapps.list: -------------------------------------------------------------------------------- 1 | [Default Applications] 2 | inode/directory=thunar.desktop 3 | application/pdf=org.pwmt.zathura.desktop 4 | text/html=firefox.desktop 5 | image/svg+xml=firefox.desktop 6 | image/png=viewnior.desktop 7 | image/jpeg=viewnior.desktop 8 | image/gif=viewnior.desktop 9 | -------------------------------------------------------------------------------- /dotfiles/ros-container/tmux.conf: -------------------------------------------------------------------------------- 1 | # remap prefix to Control + a 2 | set -g prefix C-a 3 | # bind 'C-a C-a' to type 'C-a' 4 | bind C-a send-prefix 5 | unbind C-b 6 | 7 | bind-key G run-shell "pkill -9 gzserver; pkill -9 gzclient; pkill -9 -f sonar_interpreter_node" \; send-keys "q" 8 | -------------------------------------------------------------------------------- /dotfiles/cava-config: -------------------------------------------------------------------------------- 1 | [general] 2 | framerate = 60 3 | 4 | [output] 5 | channels = mono 6 | 7 | [color] 8 | gradient = 1 9 | gradient_color_1 = '#E05606' 10 | gradient_color_2 = '#B21E0A' 11 | 12 | [smoothing] 13 | integral = 40 14 | gravity = 600 15 | monstercat = 0 16 | waves = 1 17 | -------------------------------------------------------------------------------- /pkgs/overrides/the-powder-toy.nix: -------------------------------------------------------------------------------- 1 | { the-powder-toy, fetchFromGitHub, ...}: 2 | 3 | the-powder-toy.overrideAttrs (old: rec { 4 | postPatch = 5 | let oldPostPatch = if builtins.hasAttr "postPatch" old then old.postPatch else ""; in 6 | "${oldPostPatch}\nsed -i 's,powder.pref,.powder.pref,g' src/client/Client.cpp"; 7 | }) 8 | -------------------------------------------------------------------------------- /dotfiles/bin/battery-watchdog: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | battery_percentage=$(cat /sys/class/power_supply/BAT0/capacity) 4 | charging=$(cat /sys/class/power_supply/AC/online) 5 | 6 | if [ "$battery_percentage" -lt 10 ] && [ "$charging" -eq 0 ]; then 7 | echo "Battery low. Suspending to prevent battery damage." 8 | systemctl suspend 9 | fi 10 | -------------------------------------------------------------------------------- /dotfiles/ros-container/Webots-R2020a.conf: -------------------------------------------------------------------------------- 1 | [%General] 2 | checkWebotsUpdateOnStartup=false 3 | disableSaveWarning=false 4 | startupMode=Pause 5 | telemetry=false 6 | theme=webots_night.qss 7 | 8 | [Internal] 9 | firstLaunch=false 10 | 11 | [OpenGL] 12 | GTAO=4 13 | disableAntiAliasing=false 14 | disableShadows=false 15 | textureQuality=2 16 | -------------------------------------------------------------------------------- /dotfiles/ros-container/startup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | export USER=$(whoami) 4 | 5 | source /opt/ros/melodic/setup.bash 6 | if [ ! -f /tmp/.roslaunched ]; then 7 | touch /tmp/.roslaunched 8 | roscore > /dev/null & 9 | else 10 | echo "Warning: ROS daemon already launched." 11 | read 12 | fi 13 | 14 | export MAKEFLAGS=-j$(nproc) 15 | 16 | tmux 17 | -------------------------------------------------------------------------------- /modules/hosts/nixos-qemu.nix: -------------------------------------------------------------------------------- 1 | { config, lib, pkgs, ... }: 2 | 3 | { 4 | imports = [ 5 | ../home 6 | ]; 7 | 8 | networking.hostName = "nixos-qemu"; 9 | 10 | # programs.sway-beta.enable = true; 11 | # services.xserver.windowManager.session = [{ 12 | # name = "sway-beta"; 13 | # start = '' 14 | # sway & 15 | # waitPID=$! 16 | # ''; 17 | # }]; 18 | } 19 | -------------------------------------------------------------------------------- /pkgs/overrides/urn.nix: -------------------------------------------------------------------------------- 1 | { stdenv, fetchFromGitLab, urn, ... }: 2 | 3 | urn.overrideDerivation (old: rec { 4 | version = "0.7.2-pre"; 5 | name = "urn-${version}"; 6 | src = fetchFromGitLab { 7 | owner = "urn"; 8 | repo = "urn"; 9 | rev = "ff1049713dcc7ded5968a813627543281e5f299f"; 10 | sha256 = "1kcrrdk3b6kljh0jk4s916l3f3ixfx2mdazr6mr9l2jsdcki7zxz"; 11 | }; 12 | }) 13 | -------------------------------------------------------------------------------- /dotfiles/bin/gitree: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Runs `tree`, ignoring files from .gitignore. 3 | # Copied and modified from https://gist.github.com/jpwilliams/dabff82b0ceb95dd57a7552ea7f2d675 4 | 5 | tree -C -I "$( (cat .gitignore 2> /dev/null || cat "$(git rev-parse --show-toplevel 2> /dev/null)"/.gitignore 2> /dev/null || echo "node_modules") | grep -Ev "^#.*$|^[[:space:]]*$" | tr "\\n" "|" | rev | cut -c 2- | rev)" 6 | -------------------------------------------------------------------------------- /dotfiles/ros-container/bashrc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | source /opt/ros/melodic/setup.bash 4 | [ -f ./devel/setup.bash ] && source ./devel/setup.bash 5 | alias catkut="catkin_make -DFranka_DIR:PATH=/opt/libfranka/build -Dfreenect2_DIR=/opt/freenect2/lib/cmake/freenect2" 6 | alias runsim="roslaunch lidarps lidarps.launch" 7 | alias dslam="roslaunch lidarps_ui debug_slam.launch" 8 | alias webots="/opt/webots/webots" 9 | -------------------------------------------------------------------------------- /dotfiles/bin/check-deps-size: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | output_path=/tmp/deps.svg 4 | 5 | case "$1" in 6 | /nix/store/*) 7 | store_path="$1" 8 | ;; 9 | *) 10 | store_path="$(dirname "$(dirname "$(readlink "$(command -v "$1")")")")" 11 | ;; 12 | esac 13 | 14 | echo "$store_path" 15 | if [ "$store_path" != "." ]; then 16 | nix-du -r "$store_path" | tred | dot -Tsvg > "$output_path" 17 | xdg-open "$output_path" 18 | fi 19 | -------------------------------------------------------------------------------- /dotfiles/bin/wifi-ap: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [[ $1 == "on" ]]; then 4 | echo "Starting Wifi AP" 5 | sudo rfkill unblock wlan 6 | sleep 1 7 | nmcli con down EthernetHost 8 | nmcli con up EthernetClient 9 | nmcli con up Hotspot 10 | elif [[ $1 == "off" ]]; then 11 | echo "Stopping Wifi AP" 12 | nmcli con down Hotspot 13 | nmcli con down EthernetClient 14 | nmcli con up EthernetHost 15 | else 16 | echo "Expected on/off" 17 | fi 18 | -------------------------------------------------------------------------------- /dotfiles/bin/cpu-usage: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | all_usage=$(mpstat -P ALL 1 1 | awk '/Average:/ && $2 ~ /[0-9]/ {print 100 - $12}' | sort -n) 4 | 5 | max_usage=$(echo "$all_usage" | tr " " "\n" | tail -n 1) 6 | 7 | sum_usage=0 8 | 9 | for usage in $all_usage; do 10 | sum_usage=$(echo "$sum_usage" + "$usage" | bc -l) 11 | done 12 | 13 | avg_usage=$(echo "$sum_usage / $(nproc)" | bc -l) 14 | 15 | 16 | printf "%.2f%% / %.2f%%" "$avg_usage" "$max_usage" 17 | -------------------------------------------------------------------------------- /pkgs/overrides/emacs.nix: -------------------------------------------------------------------------------- 1 | { emacsWithPackages, notmuch, ... }: 2 | 3 | emacsWithPackages 4 | (epkgs: (with epkgs.melpaStablePackages; [ 5 | magit 6 | evil 7 | linum-relative 8 | auto-complete 9 | fiplr 10 | rainbow-delimiters 11 | free-keys 12 | base16-theme 13 | 14 | nix-mode 15 | rust-mode 16 | markdown-mode 17 | haskell-mode 18 | lua-mode 19 | ]) ++ (with epkgs.elpaPackages; [ 20 | ])) 21 | -------------------------------------------------------------------------------- /dotfiles/bin/sysinfo: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | case $1 in 4 | battery_usage) 5 | if [ -f /sys/class/power_supply/BAT0/power_now ]; then 6 | echo "$(sysnformat "$(cat /sys/class/power_supply/BAT0/power_now)")" W 7 | else 8 | echo "- W" 9 | fi 10 | ;; 11 | cpufreq) 12 | echo "$(sysnformat "$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)")" GHz 13 | ;; 14 | *) 15 | echo "sysinfo " 16 | exit 1 17 | ;; 18 | esac 19 | -------------------------------------------------------------------------------- /pkgs/overrides/update-resolv-conf.nix: -------------------------------------------------------------------------------- 1 | { update-resolv-conf, lib, coreutils, openresolv, systemd, ... }: 2 | 3 | # nix-collect-garbage -d kept removing the script, so I made this workaround. 4 | 5 | let binPath = lib.makeBinPath [ coreutils openresolv systemd ]; 6 | 7 | in update-resolv-conf.overrideAttrs (old: { 8 | installPhase = '' 9 | install -Dm555 update-resolv-conf.sh $out/bin/update-resolv-conf 10 | wrapProgram $out/bin/update-resolv-conf --prefix PATH : ${binPath} 11 | ''; 12 | }) 13 | -------------------------------------------------------------------------------- /pkgs/overlays/overrides.nix: -------------------------------------------------------------------------------- 1 | self: super: 2 | 3 | { 4 | # Be able to use unstable packages in NixOS config 5 | pkgsUnstable = (import { config = super.config; }); 6 | 7 | # Package overrides 8 | the-powder-toy = import ../overrides/the-powder-toy.nix super; 9 | update-resolv-conf = import ../overrides/update-resolv-conf.nix super; 10 | neovim = import ../overrides/neovim.nix super; 11 | emacs = import ../overrides/emacs.nix super; 12 | urn = import ../overrides/urn.nix super; 13 | } 14 | -------------------------------------------------------------------------------- /pkgs/custom/bobthefish.nix: -------------------------------------------------------------------------------- 1 | { nixpkgs ? import {}, 2 | stdenv ? nixpkgs.stdenv, 3 | fetchFromGitHub ? nixpkgs.fetchFromGitHub }: 4 | 5 | stdenv.mkDerivation rec { 6 | pname = "bobthefish"; 7 | version = "2020-10-16"; 8 | 9 | src = fetchFromGitHub { 10 | owner = "oh-my-fish"; 11 | repo = "theme-bobthefish"; 12 | rev = "dfec8fa044a937b7a84f54dc2d7cf39495770580"; 13 | sha256 = "0v1qgf11xln0lzkh3yar7kd81vqwyy57l3c5x3qawddxjz8mnwpc"; 14 | }; 15 | 16 | installPhase = '' 17 | mkdir -p $out/lib 18 | cp -r . $out/lib/bobthefish 19 | ''; 20 | } 21 | -------------------------------------------------------------------------------- /dotfiles/bin/shot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | path=$HOME/Pictures/Screenshots/$(date +"%Y%m%d-%H%M%S").png 4 | 5 | if is-wayland; then 6 | case $1 in 7 | "s") grim -g "$(slurp)" "$path" ;; 8 | "u") echo "Window selection unsupported."; exit 1 ;; 9 | "m") grim "$path" ;; 10 | *) exit 1 ;; 11 | esac 12 | else 13 | case $1 in 14 | "s") args=(--noopengl -s -u) ;; 15 | "u") args=(-u -i "$(xdotool getactivewindow)") ;; 16 | "m") args=() ;; 17 | *) exit 1 ;; 18 | esac 19 | 20 | maim "${args[@]}" "$path" 21 | fi 22 | 23 | xclip -selection clipboard -t image/png -i "$path" 24 | -------------------------------------------------------------------------------- /dotfiles/esp-idf-shell.nix: -------------------------------------------------------------------------------- 1 | { nixpkgs ? import {} }: 2 | 3 | let 4 | inherit (nixpkgs) pkgs; 5 | in 6 | 7 | pkgs.stdenv.mkDerivation { 8 | name = "esp-idf-env"; 9 | buildInputs = with pkgs; [ 10 | gawk gperf gettext automake bison flex texinfo help2man libtool autoconf ncurses5 11 | (python2.withPackages (ppkgs: with ppkgs; [ pyserial future ])) 12 | (pkgs.callPackage /home/casper/Projects/nix/pkgs/custom/esp32-toolchain.nix {}) 13 | ]; 14 | shellHook = '' 15 | export NIX_CFLAGS_LINK=-lncurses 16 | export IDF_PATH=$HOME/esp/esp-idf 17 | ''; 18 | } 19 | -------------------------------------------------------------------------------- /pkgs/custom/kristvanity.nix: -------------------------------------------------------------------------------- 1 | { stdenv, fetchFromGitHub, cmake, openssl_1_1, tclap, pkgconfig }: 2 | 3 | stdenv.mkDerivation rec { 4 | pname = "kristvanity"; 5 | version = "2018-07-11"; 6 | 7 | src = fetchFromGitHub { 8 | owner = "Lignum"; 9 | repo = "KristVanity"; 10 | rev = "b381cb803db0cf599991087a138420a574d526c0"; 11 | sha256 = "0s1i753c6794y780lnflclyj8j885j20yvfnikf8drygr6bfqywp"; 12 | }; 13 | 14 | buildInputs = [ cmake openssl_1_1 tclap pkgconfig ]; 15 | 16 | meta = with stdenv; { 17 | homepage = https://github.com/Lignum/KristVanity; 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /dotfiles/bin/compiler: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ -z "$1" ]; then 4 | echo "usage: compiler [--open]" 5 | exit 1 6 | fi 7 | 8 | file=$(readlink -f "$1") 9 | base="${file%.*}" 10 | 11 | case "$file" in 12 | *\.md) pandoc -f markdown -s --number-sections -V geometry:margin=2cm "$file" -o "$base".pdf ;; 13 | *\.plantuml) plantuml -Smonochrome=true "$file" ;; 14 | *) echo "Invalid input file."; exit 1 ;; 15 | esac 16 | 17 | if [ "$2" ]; then 18 | case "$file" in 19 | *\.md) xdg-open "$base".pdf ;; 20 | *\.plantuml) xdg-open "$base".png ;; 21 | esac 22 | fi 23 | -------------------------------------------------------------------------------- /dotfiles/alacritty-config.yml: -------------------------------------------------------------------------------- 1 | font: 2 | normal: 3 | family: "Fira Code" 4 | bold: 5 | family: "Fira Code" 6 | style: "Bold" 7 | italic: 8 | family: "Fira Code" 9 | style: "Oblique" 10 | size: 9.0 11 | offset: 12 | y: 1 13 | 14 | colors: 15 | primary: 16 | foreground: "0xABB2BF" 17 | background: "0x101010" 18 | cursor: 19 | cursor: "0x93A1A1" 20 | selection: 21 | text: "0x161616" 22 | background: "0x91A1A1" 23 | 24 | 25 | background_opacity: 0.85 26 | 27 | live_config_reload: false 28 | 29 | draw_bold_text_with_bright_colors: false 30 | 31 | -------------------------------------------------------------------------------- /dotfiles/bin/howoldis: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | howoldis_url=https://howoldis.herokuapp.com/api/channels 4 | howoldis_path=/tmp/howoldis.json 5 | 6 | curl -s $howoldis_url > $howoldis_path 7 | 8 | declare -a channels=("nixos-19.03" "nixos-unstable") 9 | 10 | echo "Nixpkgs channels:" 11 | 12 | for channel in "${channels[@]}" 13 | do 14 | channel_secs=$(jq -r "to_entries[] | .value | select(.name == \"${channel}\").time" < $howoldis_path) 15 | channel_hours=$(bc <<< "scale=2; $channel_secs/60/60") 16 | echo "Channel $channel updated $channel_hours hours ago" 17 | done 18 | 19 | rm $howoldis_path 20 | -------------------------------------------------------------------------------- /pkgs/custom/kernel-gcc-patch.nix: -------------------------------------------------------------------------------- 1 | { fetchFromGitHub, stdenv }: 2 | 3 | let kernel_gcc_patch = stdenv.mkDerivation { 4 | name = "kernel_gcc_patch"; 5 | src = fetchFromGitHub { 6 | owner = "graysky2"; 7 | repo = "kernel_gcc_patch"; 8 | rev = "547932b1146cdd7b25eca8fb3449f6af2ea81726"; 9 | sha256 = "0b6yxm8di64ps4c87j3kj90wf05834w49ad57bq35lrpzxf54gr4"; 10 | }; 11 | installPhase = '' 12 | mkdir -p $out/lib 13 | mv ./* $out/lib 14 | ''; 15 | }; in 16 | 17 | { name = "gcc_patch"; 18 | patch = builtins.toPath "${kernel_gcc_patch}/lib/enable_additional_cpu_optimizations_for_gcc_v9.1+_kernel_v4.13+.patch"; 19 | } 20 | -------------------------------------------------------------------------------- /pkgs/custom/sway-session.nix: -------------------------------------------------------------------------------- 1 | { lib, stdenv, writeText, configFile ? null }: 2 | 3 | let 4 | sessionStr = '' 5 | [Desktop Entry] 6 | Name=sway 7 | Comment=Sway Wayland session 8 | Exec=sway ${lib.optionalString (configFile != null) "--config ${configFile}"} 9 | X-LightDM-Session-Type=wayland 10 | ''; 11 | sessionFile = writeText "sway.desktop" sessionStr; 12 | in 13 | 14 | stdenv.mkDerivation { 15 | name = "sway-session"; 16 | phases = [ "installPhase" ]; 17 | installPhase = '' 18 | mkdir -p $out/share/xsessions 19 | cp ${sessionFile} $out/share/xsessions/sway.desktop 20 | ''; 21 | passthru.providedSessions = [ "sway" ]; 22 | } 23 | -------------------------------------------------------------------------------- /modules/home/backup.nix: -------------------------------------------------------------------------------- 1 | { config, lib, pkgs, ... }: 2 | 3 | { 4 | systemd.tmpfiles.rules = [ "d /var/lib/backup 0700 casper users -" ]; 5 | 6 | systemd.timers.backup-sync = { 7 | description = "Timer to periodically run the backup-sync script"; 8 | wantedBy = [ "timers.target" ]; 9 | timerConfig.OnCalendar = "17:00"; 10 | }; 11 | 12 | systemd.services.backup-sync = { 13 | description = "Create, encrypt and send a backup"; 14 | path = with pkgs; [ rsync hostname gnutar lz4 ccrypt openssh ]; 15 | 16 | serviceConfig = { 17 | Type = "simple"; 18 | User = "casper"; 19 | ExecStart = "${pkgs.dotfiles-bin}/bin/backup-sync"; 20 | }; 21 | }; 22 | } 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nix 2 | 3 | My NixOS configuration files. 4 | 5 | # Structure 6 | 7 | `dotfiles/` contains dotfiles and scripts such as `init.vim` and 8 | `bin/gitree`. 9 | 10 | `modules/` contains NixOS configuration modules. Each machine has its 11 | "entry point" in `modules/hosts/.nix`. `/etc/nixos/configuration.nix` 12 | is empty and only contains an import of the corresponding entry point. 13 | 14 | `pkgs/` contains overlays, custom packages and overrides. 15 | 16 | # Building 17 | 18 | In order to build this configuration, you need to use these channels: 19 | 20 | ``` 21 | nixos https://nixos.org/channels/nixos-24.11 22 | nixos-unstable https://nixos.org/channels/nixos-unstable 23 | ``` 24 | -------------------------------------------------------------------------------- /pkgs/custom/chip8.nix: -------------------------------------------------------------------------------- 1 | { stdenv, fetchFromGitHub, SDL2 }: 2 | 3 | stdenv.mkDerivation rec { 4 | pname = "chip8"; 5 | version = "2018-06-23"; 6 | 7 | src = fetchFromGitHub { 8 | owner = "wernsey"; 9 | repo = "chip8"; 10 | rev = "4af7ee733bc57415e4bbe302d2b83da2b2b35e67"; 11 | sha256 = "0jkwvj4dfhvjd53hd5ywm2cdv1dzmd0m3cbfa0099dfbccf0pi7y"; 12 | }; 13 | 14 | installPhase = '' 15 | mkdir -p $out/bin 16 | install -m 755 c8asm $out/bin 17 | install -m 755 c8dasm $out/bin 18 | # Do not install the chip8 interpreter. It is broken on Astrododge. 19 | #install -m 755 chip8 $out/bin 20 | ''; 21 | 22 | buildInputs = [ SDL2 ]; 23 | enableParallelBuilding = true; 24 | } 25 | -------------------------------------------------------------------------------- /pkgs/custom/ls_extended.nix: -------------------------------------------------------------------------------- 1 | { lib, stdenv, fetchFromGitHub, makeWrapper }: 2 | 3 | stdenv.mkDerivation rec { 4 | pname = "ls-extended"; 5 | version = "1.1.0"; 6 | 7 | src = fetchFromGitHub { 8 | owner = "Electrux"; 9 | repo = "ls_extended"; 10 | rev = "v${version}"; 11 | sha256 = "1nv7vvy7sqnvy30cbxmrvckd2932v5iixpn48qf5pvlxnwwgi6m2"; 12 | }; 13 | 14 | buildPhase = "bash ./build.sh"; 15 | installPhase = '' 16 | mkdir -p $out/bin 17 | install -m 755 bin/ls_extended $out/bin/ls_extended 18 | ''; 19 | 20 | meta = { 21 | description = "ls with coloring and icons "; 22 | home = https://github.com/Electrux/ls_extended; 23 | license = lib.licenses.bsd3; 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /dotfiles/bin/bestafk: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | function reconnect { 4 | xdotool mousemove 1271 625 5 | sleep 0.5 6 | xdotool click 1 7 | sleep 1.5 8 | xdotool mousemove 784 449 9 | sleep 0.5 10 | xdotool click 1 11 | sleep 1.5 12 | xdotool mousemove 458 236 13 | sleep 0.5 14 | xdotool click 1 15 | sleep 20 16 | xdotool type t 17 | } 18 | 19 | function launch { 20 | pkill -f java 21 | MultiMC >/dev/null 2>&1 & 22 | sleep 1 23 | xdotool mousemove 149 139 click 1 24 | sleep 0.05 25 | xdotool click 1 26 | sleep 5 27 | xdotool search --name "MultiMC" windowkill 28 | xdotool mousemove 784 449 29 | sleep 60 30 | reconnect 31 | } 32 | 33 | launch 34 | while true; do 35 | reconnect 36 | 37 | sleep 600 38 | done 39 | -------------------------------------------------------------------------------- /modules/home/users.nix: -------------------------------------------------------------------------------- 1 | { config, pkgs, ... }: 2 | 3 | { 4 | # Disable mutable users. 5 | users.mutableUsers = false; 6 | 7 | # Allow passwordless sudo for wheel users. 8 | security.sudo.wheelNeedsPassword = false; 9 | 10 | # User accounts. 11 | users.extraUsers.casper = { 12 | isNormalUser = true; 13 | uid = 1000; 14 | extraGroups = [ 15 | "wheel" "networkmanager" "wireshark" "dialout" "docker" "libvirtd" "kvm" 16 | ]; 17 | hashedPassword = "$6$ubbEPgKNVlt$OuKWoA.IqJyxxebEdCO8iDIX045XhtxWuhRvZwrFAp5eizycgMOt8rvdVuwwyAsKKtuXjjwOtYGsBJ6zV53SP/"; 18 | home = "/home/casper"; 19 | shell = pkgs.fish; 20 | }; 21 | 22 | # SSH config. 23 | programs.ssh.extraConfig = builtins.readFile ../../dotfiles/ssh-config; 24 | } 25 | -------------------------------------------------------------------------------- /dotfiles/bin/git-change-author: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export old_email="$1" 4 | export correct_name="$2" 5 | export correct_email="$3" 6 | 7 | if [ "$#" -lt 3 ]; then 8 | echo "usage: $0 " 9 | exit 1 10 | fi 11 | 12 | git filter-branch --env-filter ' 13 | 14 | OLD_EMAIL="${old_email}" 15 | CORRECT_NAME="${correct_name}" 16 | CORRECT_EMAIL="${correct_email}" 17 | 18 | if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ] 19 | then 20 | export GIT_COMMITTER_NAME="$CORRECT_NAME" 21 | export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL" 22 | fi 23 | if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ] 24 | then 25 | export GIT_AUTHOR_NAME="$CORRECT_NAME" 26 | export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL" 27 | fi 28 | ' --tag-name-filter cat -- --branches --tags 29 | -------------------------------------------------------------------------------- /modules/home/default.nix: -------------------------------------------------------------------------------- 1 | { config, pkgs, ... }: 2 | 3 | { 4 | imports = [ 5 | ./hardware.nix 6 | ./packages.nix 7 | ./shell.nix 8 | ./users.nix 9 | ./xserver.nix 10 | ./wayland.nix 11 | # ./cloud.nix 12 | ]; 13 | 14 | nixpkgs.overlays = import ../../pkgs/overlays; 15 | 16 | nix = { 17 | settings.sandbox = true; 18 | daemonIOSchedPriority = 7; 19 | daemonCPUSchedPolicy = "batch"; 20 | extraOptions = '' 21 | fallback = true 22 | ''; 23 | }; 24 | 25 | # Internationalisation properties. 26 | console.keyMap = "us"; 27 | i18n.defaultLocale = "en_US.UTF-8"; 28 | 29 | # Time zone. 30 | time.timeZone = "Europe/Amsterdam"; 31 | 32 | # The NixOS release version. 33 | system.stateVersion = "18.03"; 34 | } 35 | -------------------------------------------------------------------------------- /pkgs/custom/dotfiles-bin.nix: -------------------------------------------------------------------------------- 1 | { stdenv, dash, shellcheck }: 2 | 3 | stdenv.mkDerivation { 4 | name = "dotfiles-bin"; 5 | src = ../../dotfiles; 6 | buildInputs = [ dash ]; 7 | 8 | configurePhase = '' 9 | # Use dash as /bin/sh 10 | find ./bin -type f -exec sed -i -e 's/bin\/sh/usr\/bin\/env dash/g' {} \; 11 | ''; 12 | installPhase = '' 13 | mkdir -p $out/lib/dotfiles 14 | cp -r ./* $out/lib/dotfiles 15 | cp -r ./share $out/share 16 | mv $out/lib/dotfiles/bin $out/bin 17 | cat < $out/bin/dotfiles 18 | #!/usr/bin/env bash 19 | 20 | echo $out/lib/dotfiles 21 | EOF 22 | chmod +x $out/bin/dotfiles 23 | ''; 24 | 25 | doCheck = true; 26 | checkInputs = [ shellcheck ]; 27 | checkPhase = '' 28 | shellcheck ./bin/* 29 | ''; 30 | } 31 | -------------------------------------------------------------------------------- /dotfiles/bin/toggle-audio-output: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$(hostname)" != "xenon" ]; then 4 | # This script is useless for other hosts than xenon. 5 | exit 1 6 | fi 7 | 8 | alsa_card_nr="$(arecord -l | grep "HD-Audio Generic" | head -n 1 | cut -c6-6)" 9 | pa_card_name=alsa_output.pci-0000_1e_00.3.analog-stereo 10 | lineout_port=analog-output-lineout 11 | headphone_port=analog-output-headphones 12 | 13 | current_port="$(pactl list sinks | grep "analog-output-" | grep "Active Port" | grep -oE "[^ ]+\$")" 14 | 15 | if [ "${current_port}" = "${headphone_port}" ]; then 16 | amixer -c "${alsa_card_nr}" cset iface=MIXER,name="Auto-Mute Mode" Disabled > /dev/null 17 | pactl set-sink-port "${pa_card_name}" "${lineout_port}" 18 | else 19 | pactl set-sink-port "${pa_card_name}" "${headphone_port}" 20 | fi 21 | -------------------------------------------------------------------------------- /pkgs/custom/inter-font.nix: -------------------------------------------------------------------------------- 1 | { lib, stdenv, fetchurl, unzip }: 2 | 3 | stdenv.mkDerivation rec { 4 | pname = "inter-font"; 5 | version = "3.19"; 6 | 7 | src = fetchurl { 8 | url = "https://github.com/rsms/inter/releases/download/v3.19/Inter-3.19.zip"; 9 | sha256 = "0ch0rk6nwd80y7vqbmrii9cr3zq6sq2gqpgkxdxsaqhp1livc2hm"; 10 | }; 11 | 12 | buildInputs = [ unzip ]; 13 | 14 | sourceRoot = "Inter Desktop"; 15 | 16 | installPhase = '' 17 | mkdir -p $out/data/fonts 18 | cp -v ./* $out/data/fonts 19 | ''; 20 | 21 | meta = { 22 | description = "A typeface specially designed for user interfaces with focus on high legibility of small-to-medium sized text on computer screens"; 23 | home = https://github.com/rsms/inter; 24 | license = lib.licenses.ofl; 25 | }; 26 | } 27 | -------------------------------------------------------------------------------- /pkgs/custom/bitpocket.nix: -------------------------------------------------------------------------------- 1 | { lib, stdenv, fetchFromGitHub, makeWrapper, locale, hostname, mount, openssh, rsync }: 2 | 3 | stdenv.mkDerivation rec { 4 | pname = "bitpocket"; 5 | version = "latest-2021-02-23"; 6 | 7 | src = fetchFromGitHub { 8 | owner = "sickill"; 9 | repo = "bitpocket"; 10 | rev = "a868b35f9830be6afce2c9a887236652e843793b"; 11 | sha256 = "084jwk6rka7q4406gzvlyrg9cspf4gj5djz9l0rs06d79v4mn7ry"; 12 | }; 13 | 14 | buildInputs = [ makeWrapper ]; 15 | 16 | installPhase = '' 17 | mkdir -p $out/bin 18 | install -m755 ./bin/bitpocket $out/bin/bitpocket 19 | ''; 20 | 21 | postFixup = '' 22 | wrapProgram $out/bin/bitpocket --prefix PATH : \ 23 | ${lib.makeBinPath [ locale hostname mount openssh rsync ]} 24 | ''; 25 | 26 | meta = { 27 | description = "Small but smart script that does 2-way directory synchronization"; 28 | home = https://github.com/sickill/bitpocket; 29 | license = lib.licenses.mit; 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /pkgs/custom/technic-launcher.nix: -------------------------------------------------------------------------------- 1 | { stdenv, fetchurl, makeWrapper, jre, openal }: 2 | 3 | let version = "4.355"; in 4 | 5 | stdenv.mkDerivation { 6 | pname = "technic-launcher"; 7 | version = version; 8 | 9 | jar = fetchurl { 10 | url = "http://launcher.technicpack.net/launcher${lib.replaceStrings ["."] ["/"] version}/TechnicLauncher.jar"; 11 | sha256 = "0f6f094d7m7bhg7h4fwpv1iillp5fsmk3rwy06lmg9pfp9gq9ixc"; 12 | }; 13 | 14 | nativeBuildInputs = [ makeWrapper ]; 15 | buildInputs = [ openal ]; 16 | 17 | phases = "installPhase"; 18 | 19 | installPhase = '' 20 | mkdir -p $out/share/java 21 | ln -s $jar $out/share/java/technic.jar 22 | makeWrapper ${jre}/bin/java $out/bin/technic --add-flags "-jar $out/share/java/technic.jar" --prefix LD_LIBRARY_PATH : ${openal}/lib 23 | ''; 24 | 25 | meta = with lib; { 26 | description = "Minecraft Mod Launcher"; 27 | homepage = https://www.technicpack.net/; 28 | license = licenses.unfree; 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /dotfiles/bin/bspwmrc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$1" != "-r" ]; then 4 | xrdb "$(dotfiles)/Xresources" 5 | system launch & 6 | system reload & 7 | fi 8 | 9 | if [ "$(hostname)" = "xenon" ]; then 10 | bspc monitor DVI-D-0 -d SI SII 11 | bspc monitor DisplayPort-0 -d I II III IV V VI VII VIII 12 | elif [ "$(hostname)" = "neon" ] && xrandr -q | grep "DP-1 connected"; then 13 | bspc monitor LVDS-1 -d SI SII 14 | bspc monitor DP-1 -d I II III IV V VI VII VIII 15 | else 16 | bspc monitor -d I II III IV V VI VII VIII IX X 17 | fi 18 | 19 | bspc config border_width 1 20 | bspc config window_gap 8 21 | 22 | bspc config split_ratio 0.52 23 | bspc config borderless_monocle true 24 | bspc config gapless_monocle true 25 | bspc config focus_follows_pointer true 26 | bspc config pointer_follows_focus true 27 | bspc config pointer_follows_monitor true 28 | 29 | bspc rule -a "Zathura" state=tiled 30 | 31 | xsetroot -cursor_name left_ptr 32 | -------------------------------------------------------------------------------- /pkgs/overlays/custom.nix: -------------------------------------------------------------------------------- 1 | self: super: 2 | 3 | { 4 | # Custom packages 5 | bobthefish = super.callPackage ../custom/bobthefish.nix {}; 6 | riko4 = super.callPackage ../custom/riko4.nix {}; 7 | luakit = super.callPackage ../custom/luakit.nix {}; 8 | technic-launcher = super.callPackage ../custom/technic-launcher.nix {}; 9 | thelounge = super.callPackage ../custom/thelounge.nix {}; 10 | ls_extended = super.callPackage ../custom/ls_extended.nix {}; 11 | kristvanity = super.callPackage ../custom/kristvanity.nix {}; 12 | chip8 = super.callPackage ../custom/chip8.nix {}; 13 | esp32-toolchain = super.callPackage ../custom/esp32-toolchain.nix {}; 14 | compton-latest = super.callPackage ../custom/compton-latest.nix {}; 15 | sway-session = super.callPackage ../custom/sway-session.nix {}; 16 | kernel-gcc-patch = super.callPackage ../custom/kernel-gcc-patch.nix {}; 17 | bitpocket = super.callPackage ../custom/bitpocket.nix {}; 18 | inter-font = super.callPackage ../custom/inter-font.nix {}; 19 | } 20 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 CrazedProgrammer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | 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 FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /modules/home/wayland.nix: -------------------------------------------------------------------------------- 1 | { config, pkgs, ... }: 2 | 3 | let 4 | swayExtraConfig = '' 5 | # No mouse accelleration 6 | input 1133:49283:Logitech_G403_Prodigy_Gaming_Mouse accel_profile flat 7 | 8 | input * xkb_layout "${config.services.xserver.xkb.layout}" 9 | input * xkb_options "${config.services.xserver.xkb.options}" 10 | input * repeat_delay "${builtins.toString config.services.xserver.autoRepeatDelay}" 11 | input * repeat_rate "${builtins.toString (1000 / config.services.xserver.autoRepeatInterval)}" 12 | 13 | output * background /home/casper/Pictures/Background.png tile 14 | output DVI-D-1 mode 1920x1080@60.000000Hz scale 1 pos 0 0 15 | output DP-1 mode 1920x1080@144.001007Hz scale 1 pos 1920 0 16 | ''; 17 | swayConfigFile = pkgs.writeText "sway-config" 18 | '' 19 | ${builtins.readFile ../../dotfiles/sway-config} 20 | ${swayExtraConfig} 21 | ''; 22 | in 23 | 24 | { 25 | # Enable sway window manager. 26 | programs.sway = { 27 | enable = true; 28 | }; 29 | services.displayManager.sessionPackages = [ 30 | (pkgs.sway-session.override { configFile = swayConfigFile; }) 31 | ]; 32 | } 33 | -------------------------------------------------------------------------------- /modules/home/cloud.nix: -------------------------------------------------------------------------------- 1 | { config, lib, pkgs, ... }: 2 | 3 | { 4 | systemd.timers.cloud-sync = { 5 | description = "Timer to periodically sync up with a directory in the cloud"; 6 | wantedBy = [ "timers.target" ]; 7 | timerConfig.OnCalendar = "*-*-* *:*:00"; 8 | }; 9 | 10 | systemd.services.cloud-sync = { 11 | description = "Sync with cloud directory"; 12 | 13 | serviceConfig = { 14 | Type = "oneshot"; 15 | User = "casper"; 16 | WorkingDirectory = "/home/casper/Cloud"; 17 | ExecStart = "${pkgs.bitpocket}/bin/bitpocket sync --force"; 18 | # Send notification in case sync fails. 19 | ExecStopPost = "${pkgs.bash}/bin/sh -c '[ \"$EXIT_STATUS\" = 0 ] || ${pkgs.libnotify}/bin/notify-send \"Failed to sync cloud directory. Check the cloud-sync.service logs for more info.\"'"; 20 | # Wait for the process to exit instead of sending a SIGTERM signal 21 | # on systemctl stop (the default). SIGCHLD is ignored by default. 22 | KillSignal = "SIGCHLD"; 23 | }; 24 | # Required for notify-send to work. 25 | environment.DBUS_SESSION_BUS_ADDRESS = "unix:path=/run/user/1000/bus"; 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /dotfiles/vscodium-settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "workbench.colorTheme": "Default Dark+", 3 | "window.zoomLevel": -2, 4 | "omnisharp.useGlobalMono": "always", 5 | "csharp.referencesCodeLens.enabled": false, 6 | "plantuml.jar": "/home/casper/Downloads/plantuml-1.2021.14.jar", 7 | "plantuml.lintDiagramNoName": false, 8 | "update.mode": "none", 9 | "omnisharp.useEditorFormattingSettings": false, 10 | "omnisharp.enableRoslynAnalyzers": true, 11 | "[javascript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, 12 | "[typescript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, 13 | "[json]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, 14 | "[html]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, 15 | "[css]": { 16 | "editor.defaultFormatter": "esbenp.prettier-vscode" 17 | }, 18 | "editor.formatOnSave": true, 19 | "csharp.testsCodeLens.enabled": false, 20 | "javascript.updateImportsOnFileMove.enabled": "always", 21 | "typescript.updateImportsOnFileMove.enabled": "always", 22 | "razor.devmode": true, 23 | "razor.disableBlazorDebugPrompt": true, 24 | "razor.languageServer.debug": true 25 | } 26 | -------------------------------------------------------------------------------- /dotfiles/kitty-config: -------------------------------------------------------------------------------- 1 | font_family Fira Code 2 | italic_font auto 3 | bold_font auto 4 | bold_italic_font auto 5 | 6 | font_size 9 7 | map ctrl+shift+equal change_font_size all +1.0 8 | map ctrl+shift+minus change_font_size all -1.0 9 | 10 | adjust_line_height 110% 11 | 12 | scrollback_lines 10000 13 | 14 | confirm_os_window_close 0 15 | 16 | # bell 17 | enable_audio_bell no 18 | 19 | # cursor colour 20 | cursor #93A1A1 21 | selection_background #91A1A1 22 | selection_foreground #161616 23 | # foreground colour 24 | foreground #ABB2BF 25 | # background colour 26 | background #101010 27 | dynamic_background_opacity yes 28 | background_opacity 0.85 29 | 30 | # black 31 | color0 #000000 32 | color8 #5C6370 33 | 34 | # red 35 | color1 #E06C75 36 | color9 #E06C75 37 | 38 | # green 39 | color2 #98C379 40 | color10 #98C379 41 | 42 | # yellow 43 | color3 #D19A66 44 | color11 #D19A66 45 | 46 | # blue 47 | color4 #61AFEF 48 | color12 #61AFEF 49 | 50 | # magenta 51 | color5 #C678DD 52 | color13 #C678DD 53 | 54 | # cyan 55 | color6 #56B6C2 56 | color14 #56B6C2 57 | 58 | # white 59 | color7 #ABB2BF 60 | color15 #FFFEFE 61 | 62 | # disable update checking 63 | update_check_interval 0 64 | -------------------------------------------------------------------------------- /pkgs/custom/esp32-toolchain.nix: -------------------------------------------------------------------------------- 1 | { stdenv, fetchurl, makeWrapper, buildFHSUserEnv }: 2 | 3 | let 4 | fhsEnv = buildFHSUserEnv { 5 | name = "esp32-toolchain-env"; 6 | targetPkgs = pkgs: with pkgs; [ zlib ]; 7 | runScript = ""; 8 | }; 9 | in 10 | 11 | stdenv.mkDerivation rec { 12 | pname = "esp32-toolchain"; 13 | version = "1.22.0"; 14 | 15 | src = fetchurl { 16 | url = "https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz"; 17 | sha256 = "0mji8jq1dg198z8bl50i0hs3drdqa446kvf6xpjx9ha63lanrs9z"; 18 | }; 19 | 20 | buildInputs = [ makeWrapper ]; 21 | 22 | phases = [ "unpackPhase" "installPhase" ]; 23 | 24 | installPhase = '' 25 | cp -r . $out 26 | for FILE in $(ls $out/bin); do 27 | FILE_PATH="$out/bin/$FILE" 28 | if [[ -x $FILE_PATH ]]; then 29 | mv $FILE_PATH $FILE_PATH-unwrapped 30 | makeWrapper ${fhsEnv}/bin/esp32-toolchain-env $FILE_PATH --add-flags "$FILE_PATH-unwrapped" 31 | fi 32 | done 33 | ''; 34 | 35 | meta = with lib; { 36 | description = "ESP32 toolchain"; 37 | homepage = https://docs.espressif.com/projects/esp-idf/en/stable/get-started/linux-setup.html; 38 | license = licenses.gpl3; 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /dotfiles/evd-shell.nix: -------------------------------------------------------------------------------- 1 | # Environment for the EVD course. 2 | 3 | { pkgs ? import {}, mkShell ? true }: 4 | 5 | let 6 | mPythonPackages = pkgs.python3Packages; 7 | buildInputs = with pkgs; 8 | [ 9 | clang 10 | cmake 11 | pkg-config 12 | llvm 13 | clang-analyzer 14 | clang-tools 15 | valgrind 16 | gdb 17 | ddd 18 | 19 | doxygen 20 | graphviz 21 | gtest 22 | 23 | gtkmm3 24 | pcre 25 | (opencv4.override { 26 | enableGtk2 = true; 27 | enablePython = true; 28 | pythonPackages = mPythonPackages; 29 | }) 30 | mPythonPackages.python 31 | mPythonPackages.autopep8 32 | 33 | qtcreator 34 | qt5.full 35 | qt5.qtquickcontrols2 36 | qt5.qtquickcontrols 37 | qt5.qtdoc 38 | ]; 39 | buildScript = '' 40 | export CC=clang 41 | export CXX=clang++ 42 | export XDG_DATA_DIRS=$XDG_DATA_DIRS:$GSETTINGS_SCHEMAS_PATH 43 | ''; 44 | in 45 | 46 | if mkShell then 47 | pkgs.mkShell { 48 | buildInputs = buildInputs; 49 | shellHook = buildScript; 50 | } 51 | else 52 | pkgs.stdenv.mkDerivation { 53 | name = "evd-shell"; 54 | phases = [ "buildPhase" ]; 55 | buildInputs = buildInputs; 56 | buildPhase = "echo $PATH > $out"; 57 | } 58 | -------------------------------------------------------------------------------- /dotfiles/bin/record: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # list of upload destinations 4 | REC_PATH=/tmp/rec-$(date +"%Y%m%d-%H%M%S").mp4 5 | OUT_PATH=/tmp/rec-out-$(date +"%Y%m%d-%H%M%S").mp4 6 | FRAMERATE=60 7 | 8 | if is-wayland; then 9 | cd /tmp || exit 1 10 | wf-recorder -g "$(slurp)" 11 | cd - || exit 1 12 | mv /tmp/recording.mp4 "$REC_PATH" 13 | else 14 | DISPLAY=$(ps -u "$(id -u)" -o pid= | \ 15 | while read -r pid; do 16 | tr '\0' '\n' 2>/dev/null < /proc/"$pid"/environ | grep '^DISPLAY=:' 17 | done | grep -o ':[0-9]*' | sort -u) 18 | 19 | # region select & record the video 20 | read -r X Y W H _ _ < <(slop --noopengl -f "%x %y %w %h %g %i") 21 | W2=$(echo "($W / 2) * 2" | bc) 22 | H2=$(echo "($H / 2) * 2" | bc) 23 | ffmpeg -f x11grab -show_region 1 -framerate $FRAMERATE -video_size "${W2}x${H2}" -i "$DISPLAY.0+$X,$Y" -c:v libx264 -pix_fmt yuv420p -preset ultrafast -tune zerolatency "$REC_PATH" 24 | fi 25 | 26 | if [[ -f $REC_PATH ]]; then 27 | if [[ $(hostname) = "xenon" ]]; then 28 | ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i "$REC_PATH" -c:v h264_vaapi -b:v 4M -profile 578 -bf 0 "$OUT_PATH" 29 | else 30 | ffmpeg -i "$REC_PATH" -c:v libx264 -b:v 4M -bufsize 4M -an "$OUT_PATH" 31 | fi 32 | rm "$REC_PATH" 33 | notify-send "Saved video to $OUT_PATH" 34 | fi 35 | 36 | -------------------------------------------------------------------------------- /pkgs/custom/dotfiles-background.nix: -------------------------------------------------------------------------------- 1 | { stdenv, imagemagick, fetchurl }: 2 | 3 | let 4 | source = fetchurl { 5 | url = "https://www.pixelstalk.net/wp-content/uploads/2016/10/Blank-Wallpaper-Full-HD.png"; 6 | sha256 = "1z2xg8ffqyg9lp9xhm70asnpiw952waq2l5irj1fydkp5hbbgaxx"; 7 | name = "background-original.jpg"; 8 | }; 9 | in 10 | 11 | stdenv.mkDerivation rec { 12 | name = "dotfiles-background"; 13 | src = source; 14 | buildInputs = [ imagemagick ]; 15 | phases = [ "buildPhase" "installPhase" ]; 16 | buildPhase = '' 17 | convert $src -resize 3840x2160^ shrink-h.png 18 | convert shrink-h.png -gravity South -crop 3840x2160+0+0 shrink.png 19 | convert shrink.png -crop 3840x1080+0+990 result-wide.png 20 | convert shrink.png -resize 1920x1080 result.png 21 | ''; 22 | installPhase = '' 23 | mkdir -p $out/bin 24 | mkdir -p $out/lib/${name} 25 | # Make sure the source does not get garbage collected. 26 | ln -s $src $out/lib/${name}/${source.name} 27 | 28 | cp result-wide.png $out/lib/${name}/background-wide.png 29 | cp result.png $out/lib/${name}/background.png 30 | 31 | cat < $out/bin/${name} 32 | #!/bin/sh 33 | 34 | echo $out/lib/${name}/background.png 35 | EOF 36 | cat < $out/bin/${name}-wide 37 | #!/bin/sh 38 | 39 | echo $out/lib/${name}/background-wide.png 40 | EOF 41 | 42 | chmod +x $out/bin/${name} 43 | chmod +x $out/bin/${name}-wide 44 | ''; 45 | } 46 | -------------------------------------------------------------------------------- /modules/overrides/thinkfan.nix: -------------------------------------------------------------------------------- 1 | { config, lib, pkgs, ... }: 2 | 3 | with lib; 4 | 5 | let 6 | 7 | cfg = config.services.thinkfan-override; 8 | configFile = pkgs.writeText "thinkfan.conf" '' 9 | ${cfg.fan} 10 | ${cfg.sensors} 11 | ${cfg.levels} 12 | ''; 13 | 14 | in { 15 | 16 | options = { 17 | 18 | services.thinkfan-override = { 19 | 20 | enable = mkOption { 21 | type = types.bool; 22 | default = false; 23 | }; 24 | 25 | sensors = mkOption { 26 | type = types.lines; 27 | default = '' 28 | tp_thermal /proc/acpi/ibm/thermal (0,0,10) 29 | ''; 30 | }; 31 | 32 | fan = mkOption { 33 | type = types.str; 34 | default = "tp_fan /proc/acpi/ibm/fan"; 35 | }; 36 | 37 | levels = mkOption { 38 | type = types.lines; 39 | default = '' 40 | (0, 0, 55) 41 | (1, 48, 60) 42 | (2, 50, 61) 43 | (3, 52, 63) 44 | (6, 56, 65) 45 | (7, 60, 85) 46 | (127, 80, 32767) 47 | ''; 48 | }; 49 | 50 | extraArgs = mkOption { 51 | type = types.listOf types.str; 52 | default = []; 53 | }; 54 | 55 | }; 56 | 57 | }; 58 | 59 | config = mkIf cfg.enable { 60 | 61 | environment.systemPackages = [ pkgs.thinkfan ]; 62 | 63 | systemd.services.thinkfan = { 64 | description = "Thinkfan"; 65 | after = [ "basic.target" ]; 66 | wantedBy = [ "multi-user.target" ]; 67 | path = [ pkgs.thinkfan ]; 68 | serviceConfig.ExecStart = "${pkgs.thinkfan}/bin/thinkfan -n ${toString cfg.extraArgs} -c ${configFile}"; 69 | }; 70 | 71 | boot.extraModprobeConfig = "options thinkpad_acpi fan_control=1"; 72 | 73 | }; 74 | 75 | } 76 | 77 | -------------------------------------------------------------------------------- /pkgs/overlays/dotfiles.nix: -------------------------------------------------------------------------------- 1 | self: super: 2 | 3 | let 4 | makeWrapped = { name, cmd ? name, pkg ? super.lib.getAttr name super, arg, extraWrapArgs ? ""}: 5 | super.stdenv.mkDerivation { 6 | name = name + "-wrapped-" + (pkg.version or ""); 7 | buildInputs = [ super.makeWrapper ]; 8 | buildCommand = '' 9 | mkdir -p $out/bin 10 | for BINARY in $(ls ${pkg}/bin); do 11 | ln -s ${pkg}/bin/$BINARY $out/bin/$BINARY 12 | done 13 | wrapProgram $out/bin/${cmd} --add-flags "${arg}" ${extraWrapArgs} 14 | ''; 15 | }; 16 | in 17 | 18 | { 19 | dotfiles-bin = super.callPackage ../custom/dotfiles-bin.nix { }; 20 | dotfiles-background = super.callPackage ../custom/dotfiles-background.nix { }; 21 | 22 | emacs-wrapped = makeWrapped { 23 | name = "emacs"; 24 | arg = "-Q -l \\$(dotfiles)/init.el"; 25 | }; 26 | rofi-wrapped = makeWrapped { 27 | name = "rofi"; 28 | pkg = super.rofi; 29 | arg = "-config \\$(dotfiles)/rofi-config"; 30 | }; 31 | cli-visualizer-wrapped = makeWrapped { 32 | name = "cli-visualizer"; 33 | cmd = "vis"; 34 | arg = "-c \\$(dotfiles)/vis-config"; 35 | }; 36 | dunst-wrapped = makeWrapped { 37 | name = "dunst"; 38 | arg = "-config \\$(dotfiles)/dunst-config"; 39 | }; 40 | alacritty-wrapped = makeWrapped { 41 | pkg = super.pkgsUnstable.alacritty; 42 | name = "alacritty"; 43 | arg = "--config-file=\\$(dotfiles)/alacritty-config.yml"; 44 | }; 45 | # NOTE: Kitty adds itself to the PATH for unknown reasons, 46 | # so it is not possible to spawn Kitty with the correct config recursively. 47 | kitty-wrapped = makeWrapped { 48 | name = "kitty"; 49 | arg = "--config=\\$(dotfiles)/kitty-config"; 50 | }; 51 | cava-wrapped = makeWrapped { 52 | name = "cava"; 53 | arg = "-p ~/Projects/nix/dotfiles/cava-config"; # FIX THIS 54 | }; 55 | i3blocks-wrapped = makeWrapped { 56 | name = "i3blocks"; 57 | arg = "-c \\$(dotfiles)/i3blocks-config"; 58 | extraWrapArgs = "--set SCRIPT_DIR ${super.i3blocks}/libexec/i3blocks"; 59 | }; 60 | } 61 | -------------------------------------------------------------------------------- /pkgs/custom/riko4.nix: -------------------------------------------------------------------------------- 1 | { lib, stdenv, fetchFromGitHub, SDL2, libGL, libGLU, luajit, cmake, curl }: 2 | 3 | let 4 | sdl_gpu = stdenv.mkDerivation rec { 5 | pname = "sdl_gpu"; 6 | version = "2018-07-26"; 7 | src = fetchFromGitHub { 8 | owner = "grimfang4"; 9 | repo = "sdl-gpu"; 10 | rev = "dd982b9c7af9f9f7c8806d20cf29ff348f8ab937"; 11 | sha256 = "0xs72r26r4z8k2fxmk0na75zqr5z7a3mx1hsaz0qw81fpq3ad70j"; 12 | }; 13 | buildInputs = [ SDL2 libGL cmake libGLU ]; 14 | enableParallelBuilding = true; 15 | }; 16 | libcurlpp = stdenv.mkDerivation rec { 17 | name = "libcurlpp-${version}"; 18 | version = "2018-06-15"; 19 | src = fetchFromGitHub { 20 | owner = "jpbarrette"; 21 | repo = "curlpp"; 22 | rev = "8810334c830faa3b38bcd94f5b1ab695a4f05eb9"; 23 | sha256 = "11yrsjcxdcana5pwx5sqc9k2gwr3v1li9bapc940cj83mg8fw0iy"; 24 | }; 25 | buildInputs = [ curl cmake ]; 26 | enableParallelBuilding = true; 27 | }; 28 | in 29 | 30 | stdenv.mkDerivation rec { 31 | name = "riko4-${version}"; 32 | version = "2018-08-05"; 33 | src = fetchFromGitHub { 34 | owner = "incinirate"; 35 | repo = "Riko4"; 36 | rev = "c93f018b8342120b24a6d94e7ea9dfc97f7c7356"; 37 | sha256 = "09nfdvgrvdbr1139hi6s0ra4ffa5xgikrzrh7hlm2nilncws4xia"; 38 | }; 39 | 40 | buildInputs = [ SDL2 luajit cmake curl sdl_gpu libcurlpp ]; 41 | hardeningDisable = [ "fortify" ]; 42 | 43 | cmakeFlags = [ "-DSDL2_gpu_INCLUDE_DIR=\"${sdl_gpu}/include\"" ]; 44 | makeFlags = [ "CXX_FLAGS+=-g" ]; 45 | dontStrip = true; 46 | 47 | installPhase = '' 48 | install -Dm0755 riko4 $out/bin/.riko4-unwrapped 49 | mkdir -p $out/lib/riko4 50 | cp -r ../data $out/lib/riko4 51 | cp -r ../scripts $out/lib/riko4 52 | cat > $out/bin/riko4 < /dev/null 55 | ../../bin/.riko4-unwrapped 56 | popd > /dev/null 57 | EOF 58 | chmod +x $out/bin/riko4 59 | ''; 60 | enableParallelBuilding = true; 61 | 62 | meta = with lib; { 63 | description = "Fantasy console for pixel art game development"; 64 | license = licenses.mit; 65 | }; 66 | } 67 | -------------------------------------------------------------------------------- /modules/home/xserver.nix: -------------------------------------------------------------------------------- 1 | { config, pkgs, ... }: 2 | 3 | { 4 | services.xserver = { 5 | # Enable the X11 windowing system. 6 | enable = true; 7 | 8 | # Keyboard options 9 | xkb.layout = "us"; 10 | xkb.options = "caps:escape,compose:ralt"; 11 | autoRepeatDelay = 300; 12 | autoRepeatInterval = 30; 13 | 14 | # Enable the SDDM login manager. 15 | displayManager.lightdm = { 16 | enable = true; 17 | }; 18 | 19 | # bspwm window manager. 20 | windowManager = { 21 | # default = "bspwm"; 22 | bspwm = { 23 | enable = true; 24 | configFile = ../../dotfiles/bin/bspwmrc; 25 | sxhkd.configFile = ../../dotfiles/sxhkdrc; 26 | }; 27 | }; 28 | }; 29 | 30 | environment.variables = { 31 | GTK_THEME = "Nordic"; 32 | GTK_ICON_THEME = "Paper"; 33 | }; 34 | 35 | environment.etc = { 36 | "xdg/gtk-2.0/gtkrc" = { 37 | mode = "444"; 38 | text = '' 39 | gtk-theme-name = "${config.environment.variables.GTK_THEME}" 40 | gtk-icon-theme-name = "${config.environment.variables.GTK_ICON_THEME}" 41 | ''; 42 | }; 43 | "xdg/gtk-3.0/settings.ini" = { 44 | mode = "444"; 45 | text = '' 46 | [Settings] 47 | gtk-theme-name = ${config.environment.variables.GTK_THEME} 48 | gtk-icon-theme-name = ${config.environment.variables.GTK_ICON_THEME} 49 | ''; 50 | }; 51 | "xdg/mimeapps.list" = { 52 | mode = "444"; 53 | text = builtins.readFile ../../dotfiles/mimeapps.list; 54 | }; 55 | }; 56 | 57 | environment.extraInit = '' 58 | export XDG_CONFIG_DIRS="/etc/xdg:$XDG_CONFIG_DIRS" 59 | export RUST_BACKTRACE=1 60 | export XDG_DATA_DIRS=$XDG_DATA_DIRS:${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/gsettings-desktop-schemas-${pkgs.gsettings-desktop-schemas.version} 61 | ''; 62 | 63 | fonts = { 64 | packages = with pkgs; [ 65 | dejavu_fonts 66 | ubuntu_font_family 67 | noto-fonts-cjk-sans fira-code 68 | # Broken: EULA url returns 503. 69 | # corefonts 70 | ]; 71 | fontconfig = { 72 | subpixel.rgba = "none"; 73 | subpixel.lcdfilter = "none"; 74 | }; 75 | }; 76 | } 77 | -------------------------------------------------------------------------------- /modules/hosts/xenon.nix: -------------------------------------------------------------------------------- 1 | { config, lib, pkgs, ... }: 2 | 3 | { 4 | imports = [ 5 | ../home 6 | ../home/backup.nix 7 | ]; 8 | 9 | boot = { 10 | loader = { 11 | # Use the systemd-boot EFI boot loader. 12 | systemd-boot.enable = true; 13 | efi.canTouchEfiVariables = false; 14 | 15 | # Skip the boot selection menu. In order to open it again, repeatedly press the space key on boot. 16 | timeout = 0; 17 | }; 18 | 19 | initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ]; 20 | kernelParams = [ "amdgpu.dc=1" ]; 21 | kernelModules = [ "kvm-amd" ]; 22 | blacklistedKernelModules = [ "snd_hda_codec_hdmi" ]; # Disable HDMI audio 23 | }; 24 | 25 | networking.hostName = "xenon"; 26 | 27 | fileSystems."/" = 28 | { device = "/dev/disk/by-uuid/b9f43929-9b6e-4a05-82fc-f2820a3b2249"; 29 | fsType = "ext4"; 30 | }; 31 | 32 | fileSystems."/boot" = 33 | { device = "/dev/disk/by-uuid/0432-52B8"; 34 | fsType = "vfat"; 35 | }; 36 | 37 | swapDevices = 38 | [ { device = "/dev/disk/by-uuid/2854a56b-660f-4add-8bfa-9efb36a1cc01"; } 39 | ]; 40 | 41 | nix.maxJobs = 24; 42 | nix.buildCores = 24; 43 | 44 | # AMD polaris firmware 45 | hardware.enableRedistributableFirmware = true; 46 | 47 | environment.systemPackages = with pkgs; [ steam ]; 48 | 49 | services.xserver = { 50 | videoDrivers = [ "amdgpu" "modesetting" "vesa" ]; 51 | config = '' 52 | Section "Monitor" 53 | Identifier "DisplayPort-0" 54 | VertRefresh 144.0 - 144.0 55 | EndSection 56 | Section "Monitor" 57 | Identifier "DVI-D-0" 58 | Option "LeftOf" "DisplayPort-0" 59 | EndSection 60 | Section "Device" 61 | Identifier "AMD" 62 | Driver "amdgpu" 63 | Option "TearFree" "true" 64 | EndSection 65 | Section "InputClass" 66 | Identifier "Logitech G403 Prodigy Gaming Mouse" 67 | MatchIsPointer "yes" 68 | Option "AccelerationProfile" "-1" 69 | Option "AccelerationScheme" "none" 70 | Option "AccelSpeed" "-1" 71 | Option "Resolution" "3500" 72 | EndSection 73 | ''; 74 | }; 75 | } 76 | -------------------------------------------------------------------------------- /pkgs/overrides/neovim.nix: -------------------------------------------------------------------------------- 1 | { neovim, vimPlugins, vimUtils, fetchFromGitHub, lib, ... }: 2 | 3 | let 4 | customPluginData = [ 5 | ["ntpeters/vim-better-whitespace" "2020-03-24" 6 | "8cf4b2175dd61416c2fe7d3234324a6c59d678de" "1iga1xdzygnr9rhv0kw01nr3vahl2d486p06slmri2vy8ngzym0q"] 7 | ["rhysd/vim-clang-format" "2018-02-01" 8 | "8ff1660a1e9f856479fffe693743521f4f3068cb" "1g9vs6cg7irmwqa1lz6i7xbq50svykhvax12vx7cpf2bxs8jfp3n"] 9 | ["drmikehenry/vim-headerguard" "2015-04-28" 10 | "e53b37fa0772ffe2f30209f6109f5f2ae0fbf48f" "0aq6405p6m4wlgak0zzb7rz6fs5f4gbd2fq4fzy683wspg1k5lq0"] 11 | ]; 12 | 13 | buildCustomPlugins = plugins: with lib; listToAttrs (map (plugin: 14 | let 15 | fullname = splitString "/" (elemAt plugin 0); 16 | owner = elemAt fullname 0; 17 | name = elemAt fullname 1; 18 | version = elemAt plugin 1; 19 | rev = elemAt plugin 2; 20 | sha256 = elemAt plugin 3; 21 | in 22 | { name = name; 23 | value = vimUtils.buildVimPlugin { 24 | name = "${name}-${version}"; 25 | version = version; 26 | src = fetchFromGitHub { 27 | owner = owner; 28 | repo = name; 29 | rev = rev; 30 | sha256 = sha256; 31 | }; 32 | }; 33 | }) plugins); 34 | 35 | customPlugins = buildCustomPlugins customPluginData; 36 | customRC = builtins.readFile ../../dotfiles/init.vim; 37 | 38 | retrievePluginName = line: 39 | let fullName = lib.elemAt (lib.strings.splitString "'" line) 1; 40 | rawName = lib.elemAt (lib.strings.splitString "/" fullName) 1; 41 | name = builtins.replaceStrings ["."] ["-"] rawName; in 42 | name; 43 | isPluginLine = line: 44 | lib.strings.hasPrefix "\tPlug '" line; 45 | 46 | pluginNameList = (builtins.map retrievePluginName (builtins.filter isPluginLine (lib.strings.splitString "\n" customRC))) 47 | ++ [ "deoplete-nvim" ]; # Deoplete doesn't work with other neovim installations for some reason. 48 | in 49 | 50 | neovim.override { 51 | vimAlias = true; 52 | configure = { 53 | customRC = customRC; 54 | 55 | packages.plugins.start = builtins.map (name: lib.getAttr name (vimPlugins // customPlugins)) pluginNameList; 56 | }; 57 | } 58 | -------------------------------------------------------------------------------- /modules/hosts/helium.nix: -------------------------------------------------------------------------------- 1 | { config, lib, pkgs, ... }: 2 | 3 | { 4 | imports = [ 5 | ../home 6 | ../home/backup.nix 7 | ]; 8 | 9 | boot = { 10 | loader = { 11 | # Use the systemd-boot EFI boot loader. 12 | systemd-boot.enable = true; 13 | efi.canTouchEfiVariables = false; 14 | 15 | # Skip the boot selection menu. In order to open it again, repeatedly press the space key on boot. 16 | timeout = 0; 17 | }; 18 | 19 | initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ]; 20 | 21 | # Pin kernel version for displaylink support. 22 | kernelPackages = pkgs.linuxPackages_5_15; 23 | }; 24 | 25 | services.xserver = { 26 | videoDrivers = [ 27 | #"displaylink" # USB external monitor support 28 | "amdgpu" "radeon" "modesetting" "fbdev" 29 | ]; 30 | 31 | config = '' 32 | Section "Monitor" 33 | Identifier "HDMI-A-0" 34 | Option "LeftOf" "eDP" 35 | Option "TearFree" "true" 36 | EndSection 37 | Section "Monitor" 38 | Identifier "eDP" 39 | Option "TearFree" "true" 40 | EndSection 41 | Section "Device" 42 | Identifier "AMD" 43 | Driver "amdgpu" 44 | EndSection 45 | ''; 46 | }; 47 | 48 | # Realtek wifi firmware 49 | hardware.enableRedistributableFirmware = true; 50 | 51 | networking.hostName = "helium"; 52 | 53 | fileSystems."/" = 54 | { device = "/dev/disk/by-uuid/b9f43929-9b6e-4a05-82fc-f2820a3b2249"; 55 | fsType = "ext4"; 56 | }; 57 | 58 | fileSystems."/boot" = 59 | { device = "/dev/disk/by-uuid/0432-52B8"; 60 | fsType = "vfat"; 61 | }; 62 | 63 | swapDevices = 64 | [ { device = "/dev/disk/by-uuid/2854a56b-660f-4add-8bfa-9efb36a1cc01"; } 65 | ]; 66 | 67 | nix.settings.max-jobs = 12; 68 | nix.settings.cores = 12; 69 | 70 | systemd.services = { 71 | battery-watchdog = { 72 | description = "Battery watchdog"; 73 | path = with pkgs; [ systemd ]; 74 | script = '' 75 | ${../../dotfiles/bin/battery-watchdog} 76 | ''; 77 | startAt = "*-*-* *:*:00"; 78 | }; 79 | }; 80 | 81 | environment.systemPackages = with pkgs; [ steam light ]; 82 | } 83 | -------------------------------------------------------------------------------- /dotfiles/bin/system: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Program for general startup/lock commands. 4 | # This is done to avoid duplicates in i3 config. 5 | 6 | function kill { 7 | pkill -f polybar 8 | pkill -f dunst 9 | pkill -f batsignal 10 | pkill -f compton 11 | } 12 | 13 | function launch { 14 | gsettings set org.gnome.desktop.interface gtk-theme "$GTK_THEME" 15 | gsettings set org.gnome.desktop.interface icon-theme "$GTK_ICON_THEME" 16 | gsettings set org.gnome.desktop.interface cursor-theme "$GTK_ICON_THEME" 17 | 18 | if [ "$(hostname)" = "xenon" ]; then 19 | # Unmute speakers. 20 | amixer -c 1 sset "Auto-Mute Mode" Disabled 21 | fi 22 | if [ "$(hostname)" = "helium" ]; then 23 | # Remove tearing on display. 24 | xrandr --output eDP --set TearFree on 25 | fi 26 | } 27 | 28 | function reload { 29 | if is-wayland; then 30 | dunst & 31 | else 32 | if [ "$(hostname)" = "xenon" ]; then 33 | feh --bg-tile "$(dotfiles-background-wide)" & 34 | else 35 | feh --bg-scale "$(dotfiles-background)" & 36 | fi 37 | sh -c "polybar --config=$(dotfiles)/polybar-config \$(hostname) || polybar --config=$(dotfiles)/polybar-config generic" & 38 | dunst & 39 | if [ "$(hostname)" == "neon" ]; then 40 | batsignal -w 20 -c 15 & 41 | if glxinfo | grep "OpenGL vendor string: nouveau"; then 42 | compton --vsync=opengl 43 | else 44 | compton --backend=glx --vsync=drm 45 | fi 46 | else 47 | compton 48 | fi 49 | fi 50 | } 51 | 52 | function lock { 53 | if is-wayland; then 54 | swaylock -n -c 000000 55 | else 56 | i3lock -n -c 000000 57 | fi 58 | } 59 | 60 | function tlock { 61 | bash -c 'sleep 0.1; xtrlock-pam -b none' & 62 | } 63 | 64 | function suspend { 65 | if [[ "$(hostname)" == "xenon" && 6700000 -gt $(vmstat -s | grep used\ memory | cut -d " " -f7) ]] ; then 66 | # Prevent "double suspending". 67 | if [ ! -f /tmp/.suspend ]; then 68 | touch /tmp/.suspend 69 | systemctl hibernate 70 | sh -c "sleep 1; rm /tmp/.suspend" & 71 | disown 72 | fi 73 | else 74 | systemctl suspend 75 | fi 76 | } 77 | 78 | function reboot { 79 | sudo systemctl kexec || sudo systemctl reboot 80 | } 81 | 82 | function brightness-inc { 83 | sudo light -A 10 84 | } 85 | 86 | function brightness-dec { 87 | sudo light -U 10 88 | } 89 | 90 | for var in "$@" 91 | do 92 | "$var" 93 | done 94 | -------------------------------------------------------------------------------- /pkgs/custom/luakit.nix: -------------------------------------------------------------------------------- 1 | { stdenv, gtk3, luajit, lua51Packages, webkitgtk, pkgconfig, sqlite, fetchFromGitHub, glib_networking, gsettings_desktop_schemas, makeWrapper }: 2 | 3 | let 4 | lualibs = with lua51Packages; [ luafilesystem luasqlite3 ]; 5 | getPath = lib : type : "${lib}/lib/lua/${luajit.luaversion}/?.${type};${lib}/share/lua/${luajit.luaversion}/?.${type}"; 6 | getLuaPath = lib : getPath lib "lua"; 7 | getLuaCPath = lib : getPath lib "so"; 8 | luaPath = lib.concatStringsSep ";" (map getLuaPath lualibs); 9 | luaCPath = lib.concatStringsSep ";" (map getLuaCPath lualibs); 10 | in 11 | 12 | stdenv.mkDerivation { 13 | 14 | name = "luakit"; 15 | pname = "2018.01.05"; 16 | 17 | src = fetchFromGitHub { 18 | owner = "luakit"; 19 | repo = "luakit"; 20 | rev = "5f3555244a56526cb36dd31d25bffefc8589294d"; 21 | sha256 = "1z66s18jzlw2gp8ih3mijr76fwa3wlk8sfg1xsmj6v4fbzqnr1z3"; 22 | }; 23 | 24 | buildInputs = [ gtk3 luajit webkitgtk pkgconfig sqlite makeWrapper ]; 25 | 26 | postPatch = '' 27 | sed -i -e "s|/etc/xdg/luakit/|$out/etc/xdg/luakit/|" lib/lousy/util.lua 28 | patchShebangs ./build-utils 29 | ''; 30 | 31 | buildPhase = '' 32 | make DEVELOPMENT_PATHS=0 USE_LUAJIT=1 INSTALLDIR=$out DESTDIR=$out PREFIX=$out MANPREFIX=$out/share/man DOCDIR=$out/share/luakit/doc PIXMAPDIR=$out/share/pixmaps APPDIR=$out/share/applications LIBDIR=$out/lib/luakit USE_GTK3=1 LUA_PATH='?/init.lua;?.lua;${luaPath}' LUA_CPATH='${luaCPath}' 33 | cat buildopts.h 34 | ''; 35 | 36 | installPhase = let luaKitPath = "$out/share/luakit/lib/?/init.lua;$out/share/luakit/lib/?.lua"; in 37 | '' 38 | make DEVELOPMENT_PATHS=0 INSTALLDIR=$out DESTDIR=$out PREFIX=$out USE_GTK3=1 install 39 | wrapProgram $out/bin/luakit \ 40 | --prefix GIO_EXTRA_MODULES : "${glib_networking.out}/lib/gio/modules" \ 41 | --prefix XDG_DATA_DIRS : "${gsettings_desktop_schemas}/share:$out/usr/share/:$out/share/:$GSETTINGS_SCHEMAS_PATH" \ 42 | --prefix XDG_CONFIG_DIRS : "$out/etc/xdg" \ 43 | --set LUA_PATH '${luaKitPath};${luaPath};' \ 44 | --set LUA_CPATH '${luaCPath};' 45 | ''; 46 | 47 | meta = with lib; { 48 | description = "Fast, small, webkit based browser framework extensible in Lua"; 49 | homepage = http://luakit.org; 50 | license = licenses.gpl3; 51 | }; 52 | } 53 | -------------------------------------------------------------------------------- /dotfiles/bin/backup-sync: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DIRS_LOCATION="$HOME/.private/backup-list" 4 | PASSWD_LOCATION="$HOME/.private/backup-passwd" 5 | 6 | BACKUP_PATH="/var/lib/backup" 7 | BACKUP_ROOT_PATH="$BACKUP_PATH/root" 8 | BACKUP_ARCHIVE_PATH="$BACKUP_PATH/archive" 9 | REMOTE_BACKUP_ARCHIVE_PATH="/home/casper/backup/$(hostname)" 10 | 11 | ZIP_METHOD="lz4" 12 | ARCHIVE_NAME="$(date --iso-8601=date)-backup-$(hostname)" 13 | ARCHIVE_PATH="${BACKUP_ARCHIVE_PATH}/${ARCHIVE_NAME}.tar.${ZIP_METHOD}" 14 | 15 | # Number of files to keep after pruning. 16 | MIN_FILES_TO_KEEP=2 17 | MAX_FILES_TO_KEEP=8 18 | MIN_DISK_GB_FREE_TO_KEEP=30 19 | 20 | sync_dirs() 21 | ( 22 | echo "Syncing directories..." 23 | while read -r dir; do 24 | mkdir -p "${BACKUP_ROOT_PATH}${dir}" 25 | rsync -a "$dir/" "${BACKUP_ROOT_PATH}${dir}" 26 | done < "$DIRS_LOCATION" 27 | ) 28 | 29 | create_archive() 30 | ( 31 | mkdir -p "$BACKUP_ARCHIVE_PATH" 32 | 33 | echo "Creating archive $ARCHIVE_NAME..." 34 | cd "$BACKUP_ROOT_PATH" || exit 1 35 | rm -f "$ARCHIVE_PATH" 36 | tar -I "${ZIP_METHOD}" -cf "$ARCHIVE_PATH" . 37 | ) 38 | 39 | encrypt_archive() 40 | ( 41 | echo "Encrypting archive..." 42 | ccrypt --encrypt -f -k "$PASSWD_LOCATION" "$ARCHIVE_PATH" 43 | ) 44 | 45 | calculate_checksum() 46 | ( 47 | echo "Calculating checksum..." 48 | sha256sum -b "$ARCHIVE_PATH.cpt" | cut -d " " -f1 > "$ARCHIVE_PATH.cpt.sha256sum" 49 | ) 50 | 51 | upload_archive() 52 | ( 53 | echo "Uploading archive to VPS..." 54 | scp -q "$ARCHIVE_PATH.cpt" "$ARCHIVE_PATH.cpt.sha256sum" "casper@radon:$REMOTE_BACKUP_ARCHIVE_PATH" 55 | ) 56 | 57 | prune_archives() 58 | ( 59 | cd "$BACKUP_ARCHIVE_PATH" || exit 1 60 | 61 | echo "Pruning archives..." 62 | while [ "$(find . -maxdepth 1 -type f | wc -l)" -gt "$MAX_FILES_TO_KEEP" ] || [ "$(df . -B 1G | tail -n1 | tr -s " " | cut -d " " -f 4)" -lt "$MIN_DISK_GB_FREE_TO_KEEP" ]; do 63 | if [ "$(find . -maxdepth 1 -type f | wc -l)" -le "$MIN_FILES_TO_KEEP" ]; then 64 | break; 65 | fi 66 | rm "$(find . -maxdepth 1 -type f | sort | head -n1)" 67 | done 68 | ) 69 | 70 | if [ ! -f "$DIRS_LOCATION" ]; then 71 | echo "Backup directory list missing from $DIRS_LOCATION" 72 | exit 1 73 | elif [ ! -f "$PASSWD_LOCATION" ]; then 74 | echo "Backup password missing from $PASSWD_LOCATION" 75 | exit 1 76 | fi 77 | 78 | sync_dirs 79 | #create_archive 80 | 81 | # Uncomment to generate encrypted archives 82 | # encrypt_archive 83 | # calculate_checksum 84 | 85 | #prune_archives 86 | 87 | # Uncomment to enable uploading back-ups to VPS 88 | #upload_archive 89 | 90 | echo "Done." 91 | -------------------------------------------------------------------------------- /dotfiles/i3blocks-config: -------------------------------------------------------------------------------- 1 | # i3blocks config file 2 | # 3 | # Please see man i3blocks for a complete reference! 4 | # The man page is also hosted at http://vivien.github.io/i3blocks 5 | # 6 | # List of valid properties: 7 | # 8 | # align 9 | # color 10 | # command 11 | # full_text 12 | # instance 13 | # interval 14 | # label 15 | # min_width 16 | # name 17 | # separator 18 | # separator_block_width 19 | # short_text 20 | # signal 21 | # urgent 22 | 23 | # Global properties 24 | # 25 | # The top properties below are applied to every block, but can be overridden. 26 | # Each block command defaults to the script name to avoid boilerplate. 27 | # Change $SCRIPT_DIR to the location of your scripts! 28 | command=$SCRIPT_DIR/$BLOCK_NAME 29 | separator_block_width=15 30 | markup=none 31 | 32 | # Volume indicator 33 | # 34 | # The first parameter sets the step (and units to display) 35 | # The second parameter overrides the mixer selection 36 | # See the script for details. 37 | 38 | [volume] 39 | # label=♪ 40 | label=VOL 41 | interval=1 42 | signal=10 43 | # STEP=5 44 | 45 | [backlight] 46 | label=BAC 47 | command=printf "%.0f%%" $(light -G) 48 | interval=1 49 | 50 | # Network interface monitoring 51 | # 52 | # If the instance is not specified, use the interface used for default route. 53 | # The address can be forced to IPv4 or IPv6 with -4 or -6 switches. 54 | [iface] 55 | #IFACE=wlan0 56 | color=#00FF00 57 | interval=10 58 | separator=false 59 | 60 | # Wifi signal strength 61 | [wifi] 62 | instance=wlp3s0 63 | label=SIGN 64 | interval=10 65 | separator=false 66 | 67 | [bandwidth] 68 | # Specifying a label doesn't work for some reason 69 | # command=$SCRIPT_DIR/bandwidth --inlabel "I" --outlabel "O" 70 | interval=1 71 | 72 | # CPU usage 73 | # 74 | # The script may be called with -w and -c switches to specify thresholds, 75 | # see the script for details. 76 | # [cpu_usage] 77 | # label=CPU 78 | # interval=1 79 | # min_width=CPU 100.00% 80 | # separator=false 81 | 82 | [custom_cpu_max_usage] 83 | label=CPU 84 | min_width=100.00% / 100.00% 85 | command=cpu-usage 86 | interval=1 87 | 88 | # [load_average] 89 | # label=LOAD 90 | # interval=10 91 | 92 | # Battery indicator 93 | # 94 | # The battery instance defaults to 0. 95 | [battery] 96 | label=BAT 97 | #label=⚡ 98 | interval=30 99 | 100 | # OpenVPN support 101 | # 102 | # Support multiple VPN, with colors. 103 | #[openvpn] 104 | #interval=20 105 | 106 | # Temperature 107 | # 108 | # Support multiple chips, though lm-sensors. 109 | # The script may be called with -w and -c switches to specify thresholds, 110 | # see the script for details. 111 | [temperature] 112 | label=TEMP 113 | interval=1 114 | 115 | # Date Time 116 | # 117 | [time] 118 | command=date '+%B %e %H:%M:%S' 119 | interval=1 120 | 121 | -------------------------------------------------------------------------------- /pkgs/custom/compton-latest.nix: -------------------------------------------------------------------------------- 1 | # This derivation will be removed when NixOS 19.03 releases. 2 | { stdenv, lib, fetchFromGitHub, pkg-config, asciidoc, docbook_xml_dtd_45 3 | , docbook_xsl, libxslt, libxml2, makeWrapper, meson, ninja 4 | , xorg, libxcb ,xcbutilrenderutil, xcbutilimage, pixman, libev 5 | , dbus, libconfig, libdrm, libGL, pcre, libX11, libXcomposite, libXdamage 6 | , libXinerama, libXrandr, libXrender, libXext, xwininfo, libxdg_basedir 7 | , xorgproto ? xorg.xproto }: 8 | 9 | let 10 | common = source: stdenv.mkDerivation (source // rec { 11 | name = "${source.pname}-${source.version}"; 12 | 13 | nativeBuildInputs = (source.nativeBuildInputs or []) ++ [ 14 | pkg-config 15 | asciidoc 16 | docbook_xml_dtd_45 17 | docbook_xsl 18 | makeWrapper 19 | ]; 20 | 21 | installFlags = [ "PREFIX=$(out)" ]; 22 | 23 | postInstall = '' 24 | wrapProgram $out/bin/compton-trans \ 25 | --prefix PATH : ${lib.makeBinPath [ xwininfo ]} 26 | ''; 27 | 28 | meta = with lib; { 29 | description = "A fork of XCompMgr, a sample compositing manager for X servers"; 30 | longDescription = '' 31 | A fork of XCompMgr, which is a sample compositing manager for X 32 | servers supporting the XFIXES, DAMAGE, RENDER, and COMPOSITE 33 | extensions. It enables basic eye-candy effects. This fork adds 34 | additional features, such as additional effects, and a fork at a 35 | well-defined and proper place. 36 | ''; 37 | license = licenses.mit; 38 | maintainers = with maintainers; [ ertes enzime twey ]; 39 | platforms = platforms.linux; 40 | }; 41 | }); 42 | 43 | gitSource = rec { 44 | pname = "compton-git"; 45 | version = "5.1"; 46 | 47 | COMPTON_VERSION = "v${version}"; 48 | 49 | nativeBuildInputs = [ meson ninja ]; 50 | 51 | src = fetchFromGitHub { 52 | owner = "yshui"; 53 | repo = "compton"; 54 | rev = COMPTON_VERSION; 55 | sha256 = "1qpy76kkhz8gfby842ry7lanvxkjxh4ckclkcjk4xi2wsmbhyp08"; 56 | }; 57 | 58 | buildInputs = [ 59 | dbus libX11 libXext 60 | xorgproto 61 | libXinerama libdrm pcre libxml2 libxslt libconfig libGL 62 | # Removed: 63 | # libXcomposite libXdamage libXrender libXrandr 64 | 65 | # New: 66 | libxcb xcbutilrenderutil xcbutilimage 67 | pixman libev 68 | libxdg_basedir 69 | ]; 70 | 71 | preBuild = '' 72 | git() { echo "v${version}"; } 73 | export -f git 74 | ''; 75 | 76 | NIX_CFLAGS_COMPILE = [ "-fno-strict-aliasing" ]; 77 | 78 | mesonFlags = [ 79 | "-Dvsync_drm=true" 80 | "-Dnew_backends=true" 81 | "-Dbuild_docs=true" 82 | ]; 83 | 84 | meta = { 85 | homepage = https://github.com/yshui/compton/; 86 | }; 87 | }; 88 | in common gitSource 89 | -------------------------------------------------------------------------------- /modules/home/shell.nix: -------------------------------------------------------------------------------- 1 | { config, pkgs, lib, ... }: 2 | 3 | { 4 | # Use vim for all the things. 5 | environment.variables = { 6 | EDITOR = lib.mkOverride 900 "vim"; 7 | TERMINAL = "kitty"; 8 | }; 9 | 10 | # Use the fish shell. 11 | programs.fish = { 12 | enable = true; 13 | 14 | shellAliases = { 15 | ls = "ls_extended"; 16 | l = "ls -lah"; 17 | vim = "vim -p"; 18 | iotop = "sudo iotop"; 19 | bmon = "sudo bmon"; 20 | potp = "pass otp uuotp | clip"; 21 | cargo = "env LIBRARY_PATH=/run/current-system/sw/lib cargo"; 22 | radonssh = "ssh casper@radon -t tmux"; 23 | ovpn = "sudo openvpn --config ~/.openvpn-(hostname)"; 24 | maps = "nix-shell -p chromium --run \"chromium https://maps.google.com\""; 25 | lgit = "git add -A; and git commit; and git push"; 26 | lgitf = "git add -A; and git commit; and git pull; and git push"; 27 | qemu = "qemu-system-x86_64 -m 8192 --enable-kvm -cpu host -smp (nproc --all) -vga virtio"; 28 | sysa = "sudo nixos-rebuild switch"; 29 | sysu = "sudo nix-channel --update; sysa"; 30 | sysuf = "cd $HOME/Projects/nixpkgs; git pull upstream master; cd -; sysa -I nixpkgs=$HOME/Projects/nixpkgs"; 31 | sysclean = "sudo nix-collect-garbage -d; and sudo nix-store --optimise"; 32 | nix-shell-unstable = "nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz"; 33 | 34 | # TODO: try to find a way to persist the disk image without chown errors during VM boot. 35 | vm-build = "sudo nixos-rebuild build-vm -p test -I nixos-config=./modules/hosts/nixos-qemu.nix"; 36 | vm-run = "./result/bin/run-nixos-qemu-vm -m 4096 --enable-kvm --smp (nproc --all); and rm ./nixos-qemu.qcow2"; 37 | 38 | # Deprecated 39 | cdcc = "cd ~/.local/share/ccemux/computer/0"; 40 | aubuild = "nix-shell -p automake autoconf libtool --run \"sh autogen.sh\"; and nix-build ."; 41 | 42 | esp-shell = "nix-shell (dotfiles)/esp-idf-shell.nix"; 43 | evd-shell = "nix-shell (dotfiles)/evd-shell.nix"; 44 | evd-vm = "qemu $HOME/VMs/debian.qcow2 -fsdev local,security_model=none,id=fsdev0,path=$HOME/Documents/EVD-1/evdk_share -device virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=hostshare"; 45 | 46 | ros = "xhost +; docker run $argv --mount source=cargo-cache,target=/home/casper/.cargo/registry --cap-add=SYS_PTRACE -e DISPLAY=$DISPLAY --device /dev/dri -v /tmp/.X11-unix:/tmp/.X11-unix -v $HOME/.Xauthority:/home/casper/.Xauthority -v $PWD:/pwd --rm -it ros:melodic-custom; echo > /dev/null"; 47 | ros-join = "docker exec -it (docker ps | grep melodic-custom | cut -f 1 -d \" \") tmux"; 48 | ros-install = "docker build -t ros:melodic-custom (dotfiles)/ros-container; and docker volume create cargo-cache"; 49 | }; 50 | 51 | shellInit = '' 52 | set -g theme_date_format "+%H:%M:%S " 53 | for file in ${pkgs.bobthefish}/lib/bobthefish/{functions/,}*.fish; . $file; end 54 | ''; 55 | }; 56 | } 57 | -------------------------------------------------------------------------------- /modules/home/hardware.nix: -------------------------------------------------------------------------------- 1 | { config, pkgs, lib, ... }: 2 | 3 | { 4 | boot = { 5 | # Quiet console at startup. 6 | kernelParams = [ "quiet" "vga=current" ]; 7 | }; 8 | 9 | # /tmp on tmpfs. 10 | fileSystems."/tmp" = { 11 | fsType = "tmpfs"; 12 | device = "tmpfs"; 13 | options = [ "mode=1777" "strictatime" "nosuid" "nodev" "size=12g" ]; 14 | }; 15 | 16 | networking = { 17 | # Use NetworkManager for networking. 18 | networkmanager = { 19 | enable = true; 20 | insertNameservers = [ "1.1.1.1" "1.0.0.1" ]; 21 | dns = "none"; 22 | }; 23 | dhcpcd.enable = false; 24 | 25 | # Extra hosts. 26 | extraHosts = '' 27 | 167.86.113.178 radon 28 | ''; 29 | }; 30 | 31 | hardware = { 32 | # Enable PulseAudio with Bluetooth support. 33 | pulseaudio = { 34 | enable = true; 35 | package = pkgs.pulseaudioFull; 36 | }; 37 | 38 | # 32 bit compatibility for Steam. 39 | graphics.enable32Bit = true; 40 | pulseaudio.support32Bit = true; 41 | }; 42 | 43 | services.pipewire.enable = lib.mkForce false; 44 | 45 | # Enable Bluetooth support. 46 | hardware.bluetooth = { 47 | enable = true; 48 | package = pkgs.pkgsUnstable.bluez; # Use latest BlueZ, contains needed fixes. 49 | }; 50 | 51 | # Allow VM to access ST-Link and Google Nexus devices. 52 | services.udev.extraRules = '' 53 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", MODE="0777" 54 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", MODE="0777" 55 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3752", MODE="0777" 56 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="18d1", MODE="0777" 57 | ''; 58 | services.udev.packages = [ 59 | pkgs.android-udev-rules 60 | ]; 61 | 62 | # Ignore lid switch on laptop. 63 | services.logind.extraConfig = '' 64 | HandleSuspendKey=ignore 65 | HandleHibernateKey=ignore 66 | HandleLidSwitch=ignore 67 | HandleLidSwitchExternalPower=ignore 68 | HandleLidSwitchDocked=ignore 69 | ''; 70 | 71 | programs.wireshark = { 72 | enable = true; 73 | package = pkgs.wireshark; 74 | }; 75 | virtualisation.docker = { 76 | enable = true; 77 | enableOnBoot = false; 78 | }; 79 | virtualisation.libvirtd = { 80 | enable = true; 81 | }; 82 | services.earlyoom.enable = true; 83 | 84 | # Improve boot time by not waiting for the network and time sync to come up. 85 | systemd.services."NetworkManager-wait-online" = { 86 | wantedBy = lib.mkForce [ ]; 87 | }; 88 | systemd.services."systemd-timesyncd" = { 89 | wantedBy = lib.mkForce [ ]; 90 | }; 91 | # Yes, this is a hack. 92 | services.xserver.displayManager.setupCommands = "${pkgs.systemd}/bin/systemctl start systemd-timesyncd tlp || true"; 93 | 94 | # Systemd stop job timeout. 95 | # Increase max file descriptors to 1M. 96 | systemd.extraConfig = '' 97 | DefaultLimitNOFILE=1048576 98 | DefaultTimeoutStartSec=10s 99 | DefaultTimeoutStopSec=10s 100 | ''; 101 | security.pam.loginLimits = [{ 102 | domain = "*"; 103 | type = "hard"; 104 | item = "nofile"; 105 | value = "1048576"; 106 | }]; 107 | } 108 | -------------------------------------------------------------------------------- /modules/home/packages.nix: -------------------------------------------------------------------------------- 1 | { config, lib, pkgs, ... }: 2 | 3 | { 4 | # Allow only these unfree packages. 5 | nixpkgs.config.allowUnfreePredicate = pkg: 6 | pkgs.lib.elem (if (builtins.hasAttr "name" pkg) then (builtins.parseDrvName pkg.name).name else pkg.pname) 7 | [ "steam" "steam-unwrapped" "steam-runtime" "factorio-alpha" "virtualbox" 8 | "pycharm-professional" "clion" "corefonts" "font-bh-lucidatypewriter" 9 | "displaylink" ]; 10 | 11 | # Fix glava not finding config files. 12 | environment.etc."xdg/glava".source = "${pkgs.glava}/etc/xdg/glava"; 13 | 14 | # Disable telemetry on the .NET CLI. 15 | environment.variables.DOTNET_CLI_TELEMETRY_OPTOUT = "1"; 16 | 17 | environment.systemPackages = with pkgs; [ 18 | # Basic tools 19 | wget curl jq bc loc p7zip fdupes binutils-unwrapped ls_extended file parallel lz4 ccrypt tree 20 | (pass.withExtensions (exts: [ exts.pass-otp ])) gnupg pinentry-gtk2 21 | 22 | # Version control 23 | git subversion 24 | 25 | # Utilities 26 | qemu stress sysbench 27 | clang-tools rustfmt rust-analyzer clippy 28 | pandoc plantuml doxygen graphviz flamegraph 29 | (texlive.combine { 30 | inherit (texlive) scheme-small enumitem sectsty; 31 | }) 32 | 33 | # X utilities 34 | xclip maim slop lxrandr xdotool hhpc xorg.xhost glxinfo redshift 35 | # Wayland utilities 36 | grim slurp wf-recorder wl-clipboard 37 | 38 | # Nix utilities 39 | nix-du 40 | 41 | # Build systems 42 | gnumake cmake #gradle 43 | 44 | # Libraries 45 | SDL2 SDL2_image libv4l 46 | 47 | # Languages 48 | gcc stdenv.cc.cc.lib 49 | lua5_3 luajit elixir nim 50 | cargo nodejs #jre 51 | dotnet-sdk mono 52 | (urn.override { useLuaJit = true; }) 53 | 54 | # Games 55 | #polymc chip8 riko4 56 | gnome-mines ccemux the-powder-toy 57 | 58 | # Terminals 59 | kitty-wrapped alacritty-wrapped 60 | 61 | # Editors 62 | neovim vscodium 63 | 64 | # Browsers 65 | firefox 66 | # Mail client 67 | thunderbird 68 | 69 | # GTK+ and icon theme (settings) 70 | arc-theme paper-icon-theme nordic shades-of-gray-theme 71 | glib gsettings-desktop-schemas 72 | 73 | # Office suite 74 | gnome-calculator libreoffice-fresh 75 | 76 | # Visual editors 77 | gimp audacity xfce.mousepad 78 | #tiled pencil sweethome3d.application 79 | #fritzing arduino 80 | 81 | # CLI A/V editors 82 | ffmpeg imagemagick 83 | 84 | # Multimedia 85 | (xfce.thunar.override { thunarPlugins = [ xfce.thunar-archive-plugin ]; }) 86 | (mpv.override { scripts = [ mpvScripts.mpris ]; }) 87 | viewnior zathura guvcview file-roller #cli-visualizer-wrapped cava-wrapped glava 88 | 89 | # Networking 90 | openssh bitpocket networkmanagerapplet nmap socat openvpn update-resolv-conf #tigervnc youtube-dl 91 | 92 | # WM utilities 93 | (polybar.override { pulseSupport = true; }) rofi-wrapped feh dunst-wrapped libnotify xtrlock-pam compton-latest i3lock i3blocks-wrapped 94 | 95 | # Scripts 96 | dotfiles-bin dotfiles-background 97 | 98 | # System utilities 99 | pavucontrol playerctl blueberry polkit_gnome exfat ntfs3g rdfind iotop bmon linuxPackages.perf picocom gotop htop sysstat ncdu usbutils 100 | # Virtualization 101 | #docker-compose libguestfs-with-appliance virt-manager 102 | # Vagrant libvirtd support 103 | #bridge-utils ebtables libxslt libxml2 libvirt zlib 104 | ] ++ (if builtins.pathExists /home/casper/.factorio.nix 105 | then lib.singleton (factorio.override (import /home/casper/.factorio.nix)) 106 | else [ ]); 107 | } 108 | -------------------------------------------------------------------------------- /modules/hosts/neon.nix: -------------------------------------------------------------------------------- 1 | { config, lib, pkgs, ... }: 2 | 3 | { 4 | imports = [ 5 | ../home 6 | ../overrides/thinkfan.nix 7 | ]; 8 | 9 | boot = { 10 | loader = { 11 | # Use the systemd-boot EFI boot loader. 12 | systemd-boot.enable = true; 13 | efi.canTouchEfiVariables = true; 14 | 15 | # Skip the boot selection menu. In order to open it again, repeatedly press the space key on boot. 16 | timeout = 0; 17 | }; 18 | 19 | initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "firewire_ohci" "usb_storage" "sd_mod" "sr_mod" "sdhci_pci" ]; 20 | kernelModules = [ "kvm-intel" ]; 21 | kernelParams = [ "i915.enable_psr=1" "i915.enable_fbc=1" "i915.fastboot=1" ]; 22 | extraModulePackages = [ config.boot.kernelPackages.acpi_call ]; 23 | }; 24 | 25 | networking.hostName = "neon"; # Define your hostname. 26 | 27 | fileSystems."/" = 28 | { device = "/dev/disk/by-uuid/37796d43-4ff7-4037-b3b4-6b7df7c5b78b"; 29 | fsType = "ext4"; 30 | }; 31 | 32 | fileSystems."/boot" = 33 | { device = "/dev/disk/by-uuid/B829-AF71"; 34 | fsType = "vfat"; 35 | }; 36 | 37 | swapDevices = 38 | [ { device = "/dev/disk/by-uuid/9b01e592-1c2e-429d-8dbd-552c6b5788c1"; } 39 | ]; 40 | 41 | nix.maxJobs = 8; 42 | nix.buildCores = 8; 43 | 44 | # Intel wifi firmware 45 | hardware.enableRedistributableFirmware = true; 46 | 47 | services.logind.lidSwitch = "ignore"; 48 | 49 | environment.systemPackages = with pkgs; [ 50 | light tpacpi-bat config.boot.kernelPackages.cpupower batsignal 51 | ]; 52 | 53 | # Using TLP because Powertop doesn't work. The cause of this is that the 54 | # kernel module cpufreq_stats does not exist for some reason, even with CONFIG_CPU_FREQ_STATS=y. 55 | services.tlp = { 56 | enable = true; 57 | settings = { 58 | CPU_SCALING_GOVERNOR_ON_AC = "performance"; 59 | CPU_SCALING_GOVERNOR_ON_BAT = "powersave"; 60 | START_CHARGE_THRESH_BAT0 = 75; 61 | STOP_CHARGE_THRESH_BAT0 = 90; 62 | }; 63 | }; 64 | systemd.services = { 65 | tlp = { 66 | wantedBy = lib.mkForce [ ]; 67 | }; 68 | # This option makes Firefox stop working for some strange reason, unfortunately. 69 | # I'll have to find another way to improve boot time. 70 | # systemd-udev-settle.serviceConfig.ExecStart = ["" "${pkgs.coreutils}/bin/true"]; 71 | 72 | battery-watchdog = { 73 | description = "Battery watchdog"; 74 | path = with pkgs; [ systemd ]; 75 | script = '' 76 | ${../../dotfiles/bin/battery-watchdog} 77 | ''; 78 | startAt = "*-*-* *:*:00"; 79 | }; 80 | }; 81 | 82 | services.thinkfan-override = { 83 | enable = true; 84 | sensors = '' 85 | hwmon /sys/class/thermal/thermal_zone0/temp 86 | ''; 87 | levels = '' 88 | (0, 0, 58) 89 | (1, 42, 62) 90 | (2, 57, 68) 91 | (3, 63, 73) 92 | (6, 68, 75) 93 | (7, 70, 84) 94 | (127, 80, 32767) 95 | ''; 96 | extraArgs = [ "-s 1" "-b 0" ]; 97 | }; 98 | 99 | services.xserver = { 100 | # Note: displaylink can be added for external USB-C monitor support 101 | videoDrivers = [ "nouveau" "modesetting" "vesa" ]; 102 | libinput = { 103 | enable = true; 104 | touchpad.naturalScrolling = false; 105 | }; 106 | config = '' 107 | Section "Device" 108 | Identifier "nvidia card" 109 | Driver "nouveau" 110 | Option "GLXVBlank" "on" 111 | EndSection 112 | ''; 113 | }; 114 | 115 | # Enable printing to Canon Pixma MG5750. 116 | services.printing.enable = true; 117 | services.printing.drivers = [ pkgs.gutenprint ]; 118 | # Enable Avahi for printer discovery via mDNS. 119 | services.avahi.enable = true; 120 | services.avahi.nssmdns = true; 121 | } 122 | -------------------------------------------------------------------------------- /dotfiles/vis-config: -------------------------------------------------------------------------------- 1 | ##Refresh rate of the visualizers. A really high refresh rate may cause screen tearing. Default is 20. 2 | visualizer.fps=60 3 | 4 | ##Sets the audio sources to use. Currently available ones are "mpd" and "alsa"Sets the audio sources to use. 5 | ##Currently available ones are "mpd", "pulse" and "alsa". Defaults to "mpd". 6 | audio.sources=pulse 7 | 8 | ##vis tries to find the correct pulseaudio sink, however this will not work on all systems. 9 | ##If pulse audio is not working with vis try switching the audio source. A list can be found by running the 10 | ##command pacmd list-sinks | grep -e 'name:' -e 'index' 11 | #audio.pulse.source=0 12 | 13 | ##Defaults to "/tmp/mpd.fifo" 14 | #mpd.fifo.path=/tmp/mpd.fifo 15 | 16 | ##If set to false the visualizers will use mono mode instead of stereo. Some visualizers will 17 | ##behave differently when mono is enabled. For example, spectrum show two sets of bars. 18 | #audio.stereo.enabled=false 19 | 20 | ##Specifies how often the visualizer will change in seconds. 0 means do not rotate. Default is 0. 21 | visualizer.rotation.secs=10 22 | 23 | ##Configures the samples rate and the cutoff frequencies. 24 | audio.sampling.frequency=48000 25 | audio.low.cutoff.frequency=50 26 | audio.high.cutoff.frequency=5000 27 | 28 | ##Applies scaling factor to both lorenz and ellipse visualizers. This is useful when the system audio is set 29 | #to a low volume. 30 | #visualizer.scaling.multiplier=1.0 31 | 32 | ##Configures the visualizers and the order they are in. Available visualizers are spectrum,lorenz,ellipse. 33 | ##Defaults to spectrum,ellipse,lorenz 34 | visualizers=ellipse,lorenz 35 | 36 | 37 | ##Configures what character the spectrum visualizer will use. Specifying a space (e.g " ") means the 38 | ##background will be colored instead of the character. Defaults to " ". 39 | #visualizer.spectrum.character=# 40 | 41 | ##Spectrum bar width. Defaults to 2. 42 | visualizer.spectrum.bar.width=2 43 | 44 | ##The amount of space between each bar in the spectrum visualizer. Defaults to 1. It's possible to set this to 45 | ##zero to have no space between bars 46 | visualizer.spectrum.bar.spacing=0 47 | 48 | ##Available smoothing options are monstercat, sgs, none. 49 | #visualizer.spectrum.smoothing.mode=sgs 50 | 51 | ##This configures the falloff effect on the spectrum visualizer. Available falloff options are fill,top,none. 52 | ##Defaults to "fill" 53 | visualizer.spectrum.falloff.mode=fill 54 | 55 | ##Configures how fast the falloff character falls. This is an exponential falloff so values usually look 56 | ##best 0.9+ and small changes in this value can have a large effect. Defaults to 0.95 57 | visualizer.spectrum.falloff.weight=0.93 58 | 59 | ##Margins in percent of total screen for spectrum visualizer. All margins default to 0 60 | #visualizer.spectrum.top.margin=0.30 61 | #visualizer.spectrum.bottom.margin=0.10 62 | #visualizer.spectrum.right.margin=0.10 63 | #visualizer.spectrum.left.margin=0.10 64 | 65 | ##Reverses the direction of the spectrum so that high freqs are first and low freqs last. Defaults to false. 66 | #visualizer.spectrum.reversed=false 67 | 68 | ##This configures the sgs smoothing effect on the spectrum visualizer. More points spreads out the smoothing 69 | ##effect and increasing passes runs the smoother multiple times on reach run. Defaults are points=3 and passes=1 70 | #visualizer.sgs.smoothing.points=3 71 | #visualizer.sgs.smoothing.passes=1 72 | 73 | 74 | ##Configures what character the ellipse visualizer will use. Specifying a space (e.g " ") means the 75 | ##background will be colored instead of the character. Defaults to "█". 76 | #visualizer.ellipse.character=# 77 | 78 | ##The radius of each color ring in the ellipse visualizer. Defaults to 2. 79 | #visualizer.ellipse.radius=2 80 | 81 | 82 | ##Configures what character the lorenz visualizer will use. Specifying a space (e.g " ") means the 83 | ##background will be colored instead of the character. Defaults to "█". 84 | #visualizer.lorenz.character=# 85 | 86 | ##Specifies the color scheme. The color scheme must be in ~/.config/vis/colors/ directory. The default scheme is "colors". 87 | #colors.scheme=rainbow 88 | -------------------------------------------------------------------------------- /dotfiles/sxhkdrc: -------------------------------------------------------------------------------- 1 | # 2 | # wm independent hotkeys 3 | # 4 | 5 | # terminal emulator 6 | super + Return 7 | rofi-sensible-terminal 8 | 9 | # program launcher 10 | super + p 11 | rofi -show combi 12 | 13 | # browser 14 | super + b 15 | firefox 16 | 17 | # mail client 18 | super + m 19 | thunderbird 20 | 21 | # toggle mouse cursor 22 | super + shift + g 23 | sh -c 'if ! pkill hhpc; then hhpc -i 0; fi &' 24 | 25 | # toggle redshift 26 | super + shift + z 27 | sh -c 'if ! pkill -9 -f redshift; then redshift -l 52:5; fi &' 28 | 29 | # power management 30 | super + shift + u 31 | poweroff 32 | 33 | super + shift + i 34 | system reboot 35 | 36 | super + shift + o 37 | system tlock 38 | 39 | {super + shift + Delete,XF86ScreenSaver} 40 | system lock 41 | 42 | super + ctrl + Delete 43 | system suspend lock 44 | 45 | # apply system config 46 | super + shift + a 47 | sudo nixos-rebuild switch --no-build-nix 48 | 49 | # reload 50 | super + shift + r 51 | system kill reload 52 | 53 | # multimedia keys 54 | {XF86AudioRaiseVolume,XF86AudioLowerVolume} 55 | pactl set-sink-volume @DEFAULT_SINK@ {+,-}3% 56 | XF86AudioMute 57 | pactl set-sink-mute @DEFAULT_SINK@ toggle 58 | {XF86AudioPlay,XF86AudioStop,XF86AudioNext,XF86AudioPrev} 59 | playerctl {play-pause,stop,next,previous} 60 | 61 | # toggle between audio outputs 62 | super + a 63 | toggle-audio-output 64 | 65 | # brightness keys 66 | {XF86MonBrightnessUp,XF86MonBrightnessDown} 67 | system brightness-{inc,dec} 10 68 | 69 | # screen recording keys 70 | {_,ctrl,shift} + Print 71 | shot {m,s,u} 72 | 73 | {_,ctrl} + super + Print 74 | {record,pkill -f ffmpeg} 75 | 76 | 77 | # 78 | # bspwm hotkeys 79 | # 80 | 81 | # exit bspwm 82 | super + shift + y 83 | bspc quit 84 | 85 | # close and kill 86 | super + {_,shift + }q 87 | bspc node -{c,k} 88 | 89 | # alternate between the tiled and monocle layout 90 | super + n 91 | bspc desktop -l next 92 | 93 | # send the newest marked node to the newest preselected node 94 | super + y 95 | bspc node newest.marked.local -n newest.!automatic.local 96 | 97 | # swap the current node and the biggest node 98 | super + g 99 | bspc node -s biggest 100 | 101 | # 102 | # state/flags 103 | # 104 | 105 | # set the window state 106 | super + {t,shift + t,s,f} 107 | bspc node -t {tiled,pseudo_tiled,floating,~fullscreen} 108 | 109 | # set the node flags 110 | super + ctrl + {m,x,y,z} 111 | bspc node -g {marked,locked,sticky,private} 112 | 113 | # 114 | # focus/swap 115 | # 116 | 117 | # focus the node in the given direction 118 | super + {_,shift + }{h,j,k,l} 119 | bspc node -{f,s} {west,south,north,east} 120 | 121 | # focus the node for the given path jump 122 | super + {p,b,comma,period} 123 | bspc node -f @{parent,brother,first,second} 124 | 125 | # focus the next/previous node in the current desktop 126 | super + {_,shift + }c 127 | bspc node -f {next,prev}.local 128 | 129 | # focus the next/previous desktop in the current monitor 130 | super + bracket{left,right} 131 | bspc desktop -f {prev,next}.local 132 | 133 | # focus the last node/desktop 134 | super + {grave,Tab} 135 | bspc {node,desktop} -f last 136 | 137 | # focus the older or newer node in the focus history 138 | super + {o,i} 139 | bspc wm -h off; \ 140 | bspc node {older,newer} -f; \ 141 | bspc wm -h on 142 | 143 | # focus or send to the given desktop 144 | super + {_,shift + }{1-9,0} 145 | bspc {desktop -f,node -d} '^{1-9,10}' 146 | 147 | # rename the current desktop 148 | super + shift + p 149 | sh -c 'NAME=$(echo | rofi -dmenu -p "Enter new desktop name"); [ -n "$NAME" ] && bspc desktop -n "$NAME"' 150 | 151 | # 152 | # preselect 153 | # 154 | 155 | # preselect the direction 156 | super + ctrl + {h,j,k,l} 157 | bspc node -p {west,south,north,east} 158 | 159 | # preselect the ratio 160 | super + ctrl + {1-9} 161 | bspc node -o 0.{1-9} 162 | 163 | # cancel the preselection for the focused node 164 | super + ctrl + space 165 | bspc node -p cancel 166 | 167 | # cancel the preselection for the focused desktop 168 | super + ctrl + shift + space 169 | bspc query -N -d | xargs -I id -n 1 bspc node id -p cancel 170 | 171 | # 172 | # move/resize 173 | # 174 | 175 | # expand a window by moving one of its side outward 176 | super + alt + {h,j,k,l} 177 | bspc node -z {left -20 0,bottom 0 20,top 0 -20,right 20 0} 178 | 179 | # contract a window by moving one of its side inward 180 | super + alt + shift + {h,j,k,l} 181 | bspc node -z {right -20 0,top 0 20,bottom 0 -20,left 20 0} 182 | 183 | # move a floating window 184 | super + {Left,Down,Up,Right} 185 | bspc node -v {-20 0,0 20,0 -20,20 0} 186 | -------------------------------------------------------------------------------- /dotfiles/ros-container/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:bionic 2 | 3 | # Update timezone data 4 | RUN apt-get update \ 5 | && DEBIAN_FRONTEND=noninteractive TZ=Europe/Amsterdam apt-get install -y tzdata 6 | 7 | # Add ROS package repo 8 | RUN apt-get install -y gnupg2 lsb-release \ 9 | && sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' \ 10 | && apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 11 | 12 | # Install all required packages 13 | RUN [ "$(getent group users | cut -d: -f3)" = "100" ] \ 14 | && apt-get update && apt-get -y install vim tmux htop mpv cppcheck valgrind doxygen usbutils sudo git ffmpeg wget \ 15 | ttf-ubuntu-font-family qt5-default morse-simulator \ 16 | libzbar-dev libpcl-dev libjpeg-turbo8-dev libturbojpeg0-dev libturbojpeg libglfw3-dev \ 17 | libusb-1.0-0-dev libopenni2-dev opencl-headers openni2-utils \ 18 | libjson-perl libperlio-gzip-perl \ 19 | swig libusb-dev libreadline-dev libzzip-0-13 libavcodec-extra libssh-gcrypt-dev libzip-dev pbzip2 libpci-dev \ 20 | ros-melodic-desktop-full ros-melodic-tf2-tools ros-melodic-webots-ros python-rospkg python-rospkg-modules 21 | 22 | ARG INSTALL_WEBOTS=true 23 | ARG WEBOTS_TAG=R2020a-rev1 24 | RUN if [ "$INSTALL_WEBOTS" = true ]; then \ 25 | cd /opt \ 26 | && git clone --single-branch --branch "$WEBOTS_TAG" --recurse-submodules https://github.com/cyberbotics/webots.git \ 27 | && cd /opt/webots \ 28 | && rm -rf ./.git \ 29 | && env HOME=/opt bash -c "source src/install_scripts/bashrc.linux && make release -j$(nproc)" \ 30 | ; else true; fi 31 | ENV WEBOTS_HOME=/opt/webots 32 | 33 | ARG INSTALL_FREENECT2=false 34 | ARG FREENECT2_TAG=master 35 | RUN if [ "$INSTALL_FREENECT2" = true ]; then \ 36 | cd /opt \ 37 | && git clone --single-branch --branch "$FREENECT2_TAG" https://github.com/OpenKinect/libfreenect2.git \ 38 | && cd libfreenect2 \ 39 | && rm -rf ./.git \ 40 | && mkdir build && cd build \ 41 | && cmake .. -DBUILD_OPENNI2_DRIVER=ON -DBUILD_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX=/opt/freenect2 \ 42 | && make -j$(nproc) \ 43 | && make install \ 44 | && cp /opt/libfreenect2/platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/ \ 45 | && ldconfig /opt/freenect2 \ 46 | && ln -s /opt/libfreenect2/build/bin/Protonect /usr/local/bin/kinect_test \ 47 | ; else true; fi 48 | 49 | ARG INSTALL_LIBFRANKA=false 50 | RUN if [ "$INSTALL_LIBFRANKA" = true ]; then \ 51 | cd /opt \ 52 | && git clone --recursive https://github.com/frankaemika/libfranka \ 53 | && cd libfranka \ 54 | && rm -rf ./.git \ 55 | && mkdir build \ 56 | && cd build \ 57 | && cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF -DBUILD_EXAMPLES=OFF .. \ 58 | && cmake --build . \ 59 | ; else true; fi 60 | 61 | ARG INSTALL_LCOV=false 62 | RUN if [ "$INSTALL_LCOV" = true ]; then \ 63 | cd /tmp \ 64 | && git clone https://github.com/linux-test-project/lcov.git \ 65 | && cd lcov \ 66 | && make install \ 67 | ; else true; fi 68 | 69 | # Install additional ROS SLAM packages 70 | RUN sudo apt-get update && sudo apt-get install -y python-rosdep ros-melodic-hector-slam ros-melodic-gmapping ros-melodic-cartographer ros-melodic-slam-toolbox ros-melodic-slam-karto ros-melodic-amcl ros-melodic-mrpt-rbpf-slam ros-melodic-mrpt-ekf-slam-2d ros-melodic-mrpt-icp-slam-2d ros-melodic-rplidar-ros ros-melodic-cartographer-ros ros-melodic-laser-filters 71 | 72 | # Remove temporary files 73 | RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 74 | 75 | # Add normal user 76 | RUN useradd -m -u 1000 -g users -G dialout,sudo,tape -s /bin/bash casper; echo casper:casper | chpasswd 77 | RUN echo "source /opt/bashrc.sh" >> /etc/bash.bashrc 78 | 79 | # Install rust 80 | RUN su casper -c "mkdir -p /home/casper/.cargo/registry" 81 | VOLUME /home/casper/.cargo/registry 82 | RUN su casper -c "export HOME=/home/casper; curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y" 83 | 84 | # Initialize rosdep 85 | RUN rosdep init 86 | RUN su casper -c "export HOME=/home/casper; rosdep update" 87 | 88 | # Copy configuration files 89 | COPY startup.sh /opt/startup.sh 90 | COPY bashrc.sh /opt/bashrc.sh 91 | COPY tmux.conf /etc/tmux.conf 92 | RUN su casper -c "mkdir -p /home/casper/.config/Cyberbotics" 93 | COPY --chown=casper:users Webots-R2020a.conf /home/casper/.config/Cyberbotics/Webots-R2020a.conf 94 | RUN chmod 644 /home/casper/.config/Cyberbotics/Webots-R2020a.conf 95 | 96 | ENTRYPOINT [ "/usr/bin/env", "bash", "/opt/startup.sh" ] 97 | 98 | USER casper 99 | WORKDIR /pwd 100 | -------------------------------------------------------------------------------- /pkgs/custom/thelounge.nix: -------------------------------------------------------------------------------- 1 | # I'll fix this sometime, but not today. 2 | 3 | { stdenv, fetchFromGitHub, callPackage, nodejs }: 4 | 5 | stdenv.mkDerivation { 6 | pname = "thelounge"; 7 | version = "2.5.0-rc.5"; 8 | 9 | src = fetchFromGitHub { 10 | owner = "thelounge"; 11 | repo = "lounge"; 12 | rev = "69ef6831b9bf59e842cf4c3c17578260d9b83c34"; 13 | sha256 = "19scp431lx3s6qncvgcb0c2mzlbd7dlgpk3dgxm21kgsrxxdb4bi"; 14 | }; 15 | 16 | buildInputs = [ nodejs ]; 17 | buildPhase = '' 18 | HOME=/tmp npm i 19 | HOME=/tmp NODE_ENV=production npm run build 20 | ''; 21 | 22 | installPhase = '' 23 | mkdir -p $out/lib 24 | mkdir -p $out/bin 25 | cp -r . $out/lib/lounge 26 | chmod +x $out/lib/lounge/index.js 27 | ln -s $out/lib/lounge/index.js $out/bin/lounge 28 | ''; 29 | 30 | # Cannot be built inside a sandbox because npm requires networking. 31 | __noChroot = true; 32 | } 33 | 34 | 35 | 36 | # with lib; 37 | 38 | # let 39 | # nodePackages = callPackage (import ) { 40 | # self = nodePackages; 41 | # generated = package/thelounge.nix; 42 | # }; 43 | # in 44 | # 45 | # nodePackages.buildNodePackage rec { 46 | # name = "thelounge"; 47 | # version = "2.5.0-rc.2"; 48 | # 49 | # src = fetchFromGitHub { 50 | # owner = "thelounge"; 51 | # repo = "lounge"; 52 | # rev = "fc0af518c6dd5251123d71f54d702453ab08f6eb"; 53 | # sha256 = "042kslxbwnsfcd3wchasxwfxyx1p7jssyyxjbw3413nla24ixdcn"; 54 | # }; 55 | # 56 | # postBuild = '' 57 | # NODE_ENV=production ${nodejs}/bin/npm run build 58 | # ''; 59 | # 60 | # deps = [ 61 | # nodePackages.by-version."bcryptjs"."2.4.3" 62 | # nodePackages.by-version."cheerio"."0.22.0" 63 | # nodePackages.by-version."colors"."1.1.2" 64 | # nodePackages.by-version."commander"."2.11.0" 65 | # nodePackages.by-version."express"."4.16.0" 66 | # nodePackages.by-version."express-handlebars"."3.0.0" 67 | # nodePackages.by-version."fs-extra"."4.0.2" 68 | # nodePackages.by-version."irc-framework"."2.9.1" 69 | # nodePackages.by-version."ldapjs"."1.0.1" 70 | # nodePackages.by-version."lodash"."4.17.4" 71 | # nodePackages.by-version."moment"."2.18.1" 72 | # nodePackages.by-version."package-json"."4.0.1" 73 | # nodePackages.by-version."read"."1.0.7" 74 | # nodePackages.by-version."request"."2.83.0" 75 | # nodePackages.by-version."semver"."5.4.1" 76 | # nodePackages.by-version."socket.io"."1.7.4" 77 | # nodePackages.by-version."spdy"."3.4.7" 78 | # nodePackages.by-version."ua-parser-js"."0.7.14" 79 | # nodePackages.by-version."urijs"."1.18.12" 80 | # nodePackages.by-version."web-push"."3.2.3" 81 | # nodePackages.by-version."npm-run-all"."4.1.1" 82 | # nodePackages.by-version."babel-core"."6.26.0" 83 | # nodePackages.by-version."babel-loader"."7.1.2" 84 | # nodePackages.by-version."babel-preset-env"."1.6.0" 85 | # nodePackages.by-version."chai"."4.1.2" 86 | # nodePackages.by-version."css.escape"."1.5.1" 87 | # nodePackages.by-version."emoji-regex"."6.5.1" 88 | # nodePackages.by-version."eslint"."4.8.0" 89 | # nodePackages.by-version."font-awesome"."4.7.0" 90 | # nodePackages.by-version."fuzzy"."0.1.3" 91 | # nodePackages.by-version."handlebars"."4.0.10" 92 | # nodePackages.by-version."handlebars-loader"."1.6.0" 93 | # nodePackages.by-version."intersection-observer"."0.4.2" 94 | # nodePackages.by-version."jquery"."3.2.1" 95 | # nodePackages.by-version."jquery-textcomplete"."1.8.4" 96 | # nodePackages.by-version."jquery-ui"."1.12.1" 97 | # nodePackages.by-version."mocha"."3.5.3" 98 | # nodePackages.by-version."mousetrap"."1.6.1" 99 | # nodePackages.by-version."nyc"."11.2.1" 100 | # nodePackages.by-version."socket.io-client"."1.7.4" 101 | # nodePackages.by-version."stylelint"."8.1.1" 102 | # nodePackages.by-version."stylelint-config-standard"."17.0.0" 103 | # (callPackage (import ) {}).webpack # nodePackages.by-version."webpack"."3.6.0" 104 | # ]; 105 | 106 | # peerDependencies = []; 107 | #}; 108 | 109 | 110 | 111 | # { stdenv, fetchFromGitHub, callPackage, python, utillinux }: 112 | # 113 | # with lib; 114 | # 115 | # let 116 | # nodePackages = callPackage (import ../../../../top-level/node-packages.nix) { 117 | # neededNatives = [ python ] ++ optional (stdenv.isLinux) utillinux; 118 | # self = nodePackages; 119 | # generated = ./package.nix; 120 | # }; 121 | # 122 | # in nodePackages.buildNodePackage rec { 123 | # name = "shout-${version}"; 124 | # version = "0.53.0"; 125 | # 126 | # src = fetchFromGitHub { 127 | # owner = "erming"; 128 | # repo = "shout"; 129 | # rev = "2cee0ea6ef5ee51de0190332f976934b55bbc8e4"; 130 | # sha256 = "1kci1qha1csb9sqb4ig487q612hgdn5lycbcpad7m9r6chn835qg"; 131 | # }; 132 | # 133 | # buildInputs = nodePackages.nativeDeps."shout" or []; 134 | # 135 | # deps = [ 136 | # nodePackages.by-version."bcrypt-nodejs"."0.0.3" 137 | # nodePackages.by-version."cheerio"."^0.17.0" 138 | # nodePackages.by-version."commander"."^2.3.0" 139 | # nodePackages.by-version."event-stream"."^3.1.7" 140 | # nodePackages.by-version."express"."^4.9.5" 141 | # nodePackages.by-version."lodash"."~2.4.1" 142 | # nodePackages.by-version."mkdirp"."^0.5.0" 143 | # nodePackages.by-version."moment"."~2.7.0" 144 | # nodePackages.by-version."read"."^1.0.5" 145 | # nodePackages.by-version."request"."^2.51.0" 146 | # nodePackages.by-version."slate-irc"."~0.7.3" 147 | # nodePackages.by-version."socket.io"."~1.0.6" 148 | # ]; 149 | # 150 | # peerDependencies = []; 151 | # 152 | # meta = { 153 | # description = "Web IRC client that you host on your own server"; 154 | # license = licenses.mit; 155 | # homepage = http://shout-irc.com/; 156 | # maintainers = with maintainers; [ benley ]; 157 | # platforms = platforms.unix; 158 | # }; 159 | # } 160 | # 161 | -------------------------------------------------------------------------------- /dotfiles/sway-config: -------------------------------------------------------------------------------- 1 | # sway config file 2 | # 3 | # Please see http://i3wm.org/docs/userguide.html and man 5 sway for a complete reference! 4 | 5 | set $mod Mod4 6 | 7 | # Font for window titles. Will also be used by the bar unless a different font 8 | # is used in the bar {} block below. 9 | font pango:FiraCode 9 10 | 11 | # No window titles 12 | default_border pixel 1 13 | default_floating_border pixel 1 14 | 15 | # Border colors 16 | client.focused #555555 #444444 #dddddd #444444 #666666 17 | client.focused_inactive #444444 #333333 #dddddd #333333 #555555 18 | client.unfocused #444444 #333333 #dddddd #333333 #555555 19 | 20 | # Use Mouse+$mod to drag floating windows to their wanted position 21 | floating_modifier $mod 22 | 23 | # start a terminal 24 | bindsym $mod+Return exec "rofi-sensible-terminal" 25 | 26 | # start the application launcher 27 | bindsym $mod+p exec "rofi -show combi" 28 | 29 | # start the browser 30 | bindsym $mod+b exec "env GDK_BACKEND=wayland firefox" 31 | 32 | # install gentoo 33 | bindsym XF86Launch1 exec "mpv https://i.crzd.me/install-gentoo.mp4 --fullscreen" 34 | 35 | # toggle mouse cursor 36 | bindsym $mod+Shift+g exec "sh -c 'if ! pkill hhpc; then hhpc -i 0; fi &'" 37 | 38 | # kill focused window 39 | bindsym $mod+q kill 40 | 41 | # disable focus wrapping 42 | focus_wrapping no 43 | 44 | # scratchpad 45 | bindsym $mod+Shift+c move scratchpad 46 | bindsym $mod+c scratchpad show 47 | 48 | # change focus 49 | bindsym $mod+h focus left 50 | bindsym $mod+j focus down 51 | bindsym $mod+k focus up 52 | bindsym $mod+l focus right 53 | 54 | # move focused window 55 | bindsym $mod+Shift+h move left 56 | bindsym $mod+Shift+j move down 57 | bindsym $mod+Shift+k move up 58 | bindsym $mod+Shift+l move right 59 | 60 | # split in horizontal orientation 61 | bindsym $mod+g split h 62 | 63 | # split in vertical orientation 64 | bindsym $mod+v split v 65 | 66 | # enter fullscreen mode for the focused container 67 | bindsym $mod+f fullscreen toggle 68 | 69 | # change container layout (stacked, tabbed, toggle split) 70 | bindsym $mod+s layout stacking 71 | bindsym $mod+w layout tabbed 72 | bindsym $mod+e layout toggle split 73 | 74 | # toggle tiling / floating 75 | bindsym $mod+Shift+space floating toggle 76 | 77 | # change focus between tiling / floating windows 78 | bindsym $mod+space focus mode_toggle 79 | 80 | # focus the parent container 81 | bindsym $mod+a focus parent 82 | 83 | # focus the child container 84 | bindsym $mod+d focus child 85 | 86 | # gaps 87 | gaps inner 6 88 | bindsym $mod+equal gaps inner all plus 3 89 | bindsym $mod+minus gaps inner all minus 3 90 | 91 | # switch to workspace 92 | bindsym $mod+1 workspace 1 93 | bindsym $mod+2 workspace 2 94 | bindsym $mod+3 workspace 3 95 | bindsym $mod+4 workspace 4 96 | bindsym $mod+5 workspace 5 97 | bindsym $mod+6 workspace 6 98 | bindsym $mod+7 workspace 7 99 | bindsym $mod+8 workspace 8 100 | bindsym $mod+9 workspace 9 101 | bindsym $mod+0 workspace 10 102 | 103 | # move focused container to workspace 104 | bindsym $mod+Shift+1 move container to workspace 1 105 | bindsym $mod+Shift+2 move container to workspace 2 106 | bindsym $mod+Shift+3 move container to workspace 3 107 | bindsym $mod+Shift+4 move container to workspace 4 108 | bindsym $mod+Shift+5 move container to workspace 5 109 | bindsym $mod+Shift+6 move container to workspace 6 110 | bindsym $mod+Shift+7 move container to workspace 7 111 | bindsym $mod+Shift+8 move container to workspace 8 112 | bindsym $mod+Shift+9 move container to workspace 9 113 | bindsym $mod+Shift+0 move container to workspace 10 114 | 115 | # exit sway (logs you out of your session) 116 | bindsym $mod+Shift+y exec "swaymsg exit" 117 | # kill all windows 118 | bindsym $mod+Shift+t [class=".+"] kill 119 | # shutdown 120 | bindsym $mod+Shift+u exec "poweroff" 121 | # reboot 122 | bindsym $mod+Shift+i exec "system reboot" 123 | # lock screen and suspend 124 | # bindsym $mod+Shift+o exec "system tlock" 125 | bindsym $mod+Shift+o exec "sudo systemctl restart display-manager" 126 | bindsym $mod+Shift+Delete exec "system kill lock reload" 127 | bindsym $mod+Ctrl+Delete exec "system suspend lock" 128 | # apply system config 129 | bindsym $mod+Shift+a exec "sudo nixos-rebuild switch --no-build-nix" 130 | 131 | # resize window (you can also use the mouse for that) 132 | mode "resize" { 133 | # These bindings trigger as soon as you enter the resize mode 134 | 135 | # Pressing left will shrink the window’s width. 136 | # Pressing right will grow the window’s width. 137 | # Pressing up will shrink the window’s height. 138 | # Pressing down will grow the window’s height. 139 | bindsym h resize shrink width 10 px or 10 ppt 140 | bindsym j resize grow height 10 px or 10 ppt 141 | bindsym k resize shrink height 10 px or 10 ppt 142 | bindsym l resize grow width 10 px or 10 ppt 143 | 144 | # back to normal: Escape 145 | bindsym Escape mode "default" 146 | } 147 | 148 | bindsym $mod+r mode "resize" 149 | 150 | # screenshot and record shortcuts 151 | bindsym Print exec "shot m" 152 | bindsym Ctrl+Print exec "shot s" 153 | bindsym Shift+Print exec "shot u" 154 | bindsym $mod+Print exec "record" 155 | bindsym $mod+Ctrl+Print exec "pkill -2 -f wf-recorder || pkill -f ffmpeg" 156 | 157 | # volume keys 158 | bindsym XF86AudioRaiseVolume exec "pactl set-sink-volume @DEFAULT_SINK@ +3%" 159 | bindsym XF86AudioLowerVolume exec "pactl set-sink-volume @DEFAULT_SINK@ -3%" 160 | bindsym XF86AudioMute exec "pactl set-sink-mute @DEFAULT_SINK@ toggle" 161 | 162 | # brightness keys 163 | bindsym XF86MonBrightnessUp exec "system brightness-inc" 164 | bindsym XF86MonBrightnessDown exec "system brightness-dec" 165 | 166 | # fix intrusive wl-paste window 167 | for_window [title="wl-clipboard"] floating enable 168 | 169 | # startup file 170 | exec --no-startup-id "system launch" 171 | exec_always --no-startup-id "system kill reload" 172 | 173 | bar { 174 | position top 175 | 176 | output DP-1 177 | output LVDS-1 178 | 179 | # When the status_command prints a new line to stdout, swaybar updates. 180 | # The default just shows the current date and time. 181 | status_command i3blocks 182 | 183 | colors { 184 | statusline #ffffff 185 | background #32323288 186 | inactive_workspace #32323200 #32323200 #5c5c5c 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /dotfiles/init.vim: -------------------------------------------------------------------------------- 1 | set nocompatible 2 | 3 | " Prevent nesting 4 | 5 | if $NEOVIM == 'true' 6 | echo 'Nesting is disabled.' 7 | q! 8 | endif 9 | let $NEOVIM = 'true' 10 | 11 | " Plugin polyglot (nix-plugin-manager and vim-plug) 12 | 13 | if !empty(glob('~/.vim/autoload/plug.vim')) || !empty(glob('~/.local/share/nvim/site/autoload/plug.vim')) 14 | call plug#begin('~/.vim-plug') 15 | " Deoplete doesn't work in other installations I've tested, 16 | " unfortunately. 17 | " Plug 'Shougo/deoplete.nvim' 18 | Plug 'tpope/vim-vinegar' 19 | Plug 'tpope/vim-surround' 20 | Plug 'ctrlpvim/ctrlp.vim' 21 | Plug 'sheerun/vim-polyglot' 22 | Plug 'itchyny/lightline.vim' 23 | Plug 'easymotion/vim-easymotion' 24 | Plug 'ntpeters/vim-better-whitespace' 25 | Plug 'tpope/vim-commentary' 26 | Plug 'luochen1990/rainbow' 27 | Plug 'vim-pandoc/vim-pandoc-syntax' 28 | Plug 'rhysd/vim-clang-format' 29 | Plug 'drmikehenry/vim-headerguard' 30 | Plug 'rhysd/git-messenger.vim' 31 | call plug#end() 32 | endif 33 | 34 | " Swap and backup file directory 35 | 36 | if !has('nvim') 37 | set directory=$HOME/.vim/swap// 38 | set backupdir=$HOME/.vim/backup// 39 | execute 'silent :!mkdir -p' shellescape(&directory) 40 | execute 'silent :!mkdir -p' shellescape(&backupdir) 41 | endif 42 | 43 | " File type extension registry 44 | 45 | au BufNewFile,BufRead *.inc setlocal ft=cpp 46 | 47 | " File type presets 48 | 49 | autocmd FileType css :setlocal ts=4 sw=4 50 | autocmd FileType c,cpp,cs,php,python,julia,Dockerfile :setlocal et ts=4 sw=4 51 | autocmd FileType lisp,arduino,haskell,cabal,lua,typescript,javascript,json,html,xml,cmake :setlocal et ts=2 sw=2 52 | autocmd FileType markdown,text,plaintex :setlocal foldcolumn=4 colorcolumn=79 textwidth=79 et ts=2 sw=2 53 | autocmd FileType nix,plantuml :setlocal indentexpr= 54 | 55 | " GUI and colors 56 | 57 | set mouse=a guicursor= nu rnu noshowmode background=dark tabpagemax=999 58 | hi Statement ctermfg=yellow 59 | hi LineNr ctermfg=darkgrey 60 | hi CursorLineNr ctermfg=grey 61 | hi ColorColumn ctermbg=black 62 | hi FoldColumn ctermbg=none 63 | hi Pmenu ctermbg=darkgrey 64 | hi MatchParen cterm=bold ctermbg=darkgrey ctermfg=none 65 | hi gitmessengerPopupNormal term=None ctermfg=255 ctermbg=234 66 | 67 | " Keyboard mappings 68 | 69 | nmap :w 70 | nmap :q 71 | nmap :CF 72 | imap :wi 73 | imap :q 74 | imap diwi 75 | tnoremap 76 | vnoremap p "_dP 77 | 78 | for dirkey in ['h', 'j', 'k', 'l'] 79 | execute 'nnoremap ' . dirkey 80 | execute 'inoremap ' . dirkey . 'i' 81 | execute 'tnoremap ' . dirkey . 'i' 82 | endfor 83 | 84 | " Searching 85 | 86 | set ignorecase smartcase 87 | 88 | " CtrlP 89 | 90 | let g:ctrlp_regexp = 1 91 | set wildignore+=*/venv/* 92 | 93 | " EasyMotion 94 | 95 | let g:EasyMotion_do_mapping = 0 " Disable default mappings 96 | nmap W (easymotion-w) 97 | nmap B (easymotion-b) 98 | 99 | " Autocomplete 100 | 101 | let g:deoplete#enable_at_startup = 1 102 | let g:deoplete#on_insert_enter = 0 103 | autocmd VimEnter * call deoplete#custom#option('max_list', 7) 104 | 105 | " Enable markdown section folding without the line characters. 106 | let g:markdown_folding = 1 107 | autocmd FileType markdown :setlocal foldcolumn=0 numberwidth=7 108 | 109 | " Clang-Format 110 | 111 | let g:clang_format#code_style = 'llvm' 112 | 113 | " Rainbow parentheses 114 | 115 | let g:rainbow_conf = { 116 | \ 'separately': { 117 | \ '*': 0, 118 | \ 'lisp': { 119 | \ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'], 120 | \ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'], 121 | \ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'], 122 | \ } 123 | \ } 124 | \} 125 | let g:rainbow_active = 1 126 | 127 | " Status bar 128 | 129 | let g:lightline = { 130 | \ 'active': { 131 | \ 'left': [ [ 'mode', 'paste' ], 132 | \ [ 'readonly', 'buffername', 'modified' ] ], 133 | \ 'right': [ [ 'lineinfo' ], [ 'percent' ], 134 | \ [ 'fileformat', 'fileencoding', 'filetype', 'totallines' ] ], 135 | \ }, 136 | \ 'inactive':{ 137 | \ 'left': [ [ 'buffername' ] ], 138 | \ 'right': [ [ 'lineinfo' ], [ 'percent' ] ] 139 | \ }, 140 | \ 'component': { 141 | \ 'totallines': '%{line("$")}L', 142 | \ }, 143 | \ 'component_function': { 144 | \ 'buffername': 'BufName', 145 | \ }, 146 | \} 147 | 148 | let g:bufname_cache = {} 149 | function BufName() 150 | let name = expand('%:p') 151 | if !has_key(g:bufname_cache, name) 152 | if name == '' 153 | let g:bufname_cache[name] = '[new]' 154 | elseif name =~ 'term:\/\/' 155 | let g:bufname_cache[name] = expand('%:t') 156 | else 157 | let parts = split(name, '/') 158 | let homeparts = split($HOME, '/') 159 | let nhparts = len(homeparts) 160 | 161 | let ishome = parts[:nhparts - 1] == homeparts 162 | 163 | if ishome 164 | call remove(parts, 0, nhparts - 1) 165 | call insert(parts, '~') 166 | endif 167 | 168 | let nparts = len(parts) 169 | let shortparts = [] 170 | 171 | for part in parts 172 | if strpart(part, 0, 1) == '.' 173 | call add(shortparts, strpart(part, 0, 2)) 174 | else 175 | call add(shortparts, strpart(part, 0, 1)) 176 | endif 177 | endfor 178 | 179 | let shortparts[nparts - 1] = parts[nparts - 1] 180 | 181 | let g:bufname_cache[name] = (ishome ? '' : '/') . join(shortparts, '/') 182 | endif 183 | endif 184 | return g:bufname_cache[name] 185 | endfunction 186 | 187 | " Auto-load changes from disk 188 | 189 | if !exists('g:CheckUpdateStarted') 190 | let g:CheckUpdateStarted = 1 191 | call timer_start(1, 'CheckUpdate') 192 | endif 193 | function! CheckUpdate(timer) 194 | silent! checktime 195 | call timer_start(1000, 'CheckUpdate') 196 | endfunction 197 | 198 | " Commands 199 | 200 | command Term :belowright new | :terminal 201 | command CF :ClangFormat 202 | command CFA :bufdo execute ':CF' | w 203 | command CH :HeaderguardAdd 204 | command QE :%bd|e# 205 | command C :w | :execute 'silent :!compiler' shellescape(bufname('%')) '&' 206 | command CO :w | :execute 'silent :!compiler' shellescape(bufname('%')) '--open' '&' 207 | 208 | " Misc functions 209 | 210 | function Chomp(str) 211 | return substitute(a:str, '\n\+$', '', '') 212 | endfunction 213 | 214 | function TempPath(...) 215 | let ext = (a:0 >= 1) ? a:1 : fnamemodify(bufname('%'), ':e') 216 | let random = Chomp(system('bash -c "echo \$RANDOM"')) 217 | return '/tmp/' . random . '.' . ext 218 | endfunction 219 | 220 | " Workaround: Disable clipboard support until wl-clipboard 221 | " doesn't create new windows with wlroots compositors. 222 | 223 | if !empty($WAYLAND_DISPLAY) 224 | let g:clipboard = { 225 | \ 'name': 'myClipboard', 226 | \ 'copy': { 227 | \ '+': ':', 228 | \ '*': ':', 229 | \ }, 230 | \ 'paste': { 231 | \ '+': ':', 232 | \ '*': ':', 233 | \ }, 234 | \ 'cache_enabled': 1, 235 | \ } 236 | endif 237 | -------------------------------------------------------------------------------- /dotfiles/polybar-config: -------------------------------------------------------------------------------- 1 | ;===================================================== 2 | ; 3 | ; To learn more about how to configure Polybar 4 | ; go to https://github.com/jaagr/polybar 5 | ; 6 | ; The README contains alot of information 7 | ; 8 | ;===================================================== 9 | 10 | [colors] 11 | background = #aa222222 12 | background-alt = #aa444444 13 | foreground = #dfdfdf 14 | foreground-alt = #999999 15 | primary = #bbffb52a 16 | secondary = #bbf94444 17 | ternary = #bbf97444 18 | alert = #ccbd2c40 19 | border = #dd111111 20 | 21 | [bar/xenon] 22 | modules-left = bspwm volume 23 | modules-center = title 24 | modules-right = cpuload temperature_xenon wired date 25 | 26 | monitor = ${env:MONITOR:DisplayPort-0} 27 | width = 100% 28 | height = 20 29 | radius = 0 30 | fixed-center = true 31 | 32 | background = ${colors.background} 33 | foreground = ${colors.foreground} 34 | 35 | underline-size = 2 36 | underline-color = #F00 37 | 38 | border-size = 0 39 | border-color = ${colors.border} 40 | 41 | padding-left = 0 42 | padding-right = 0 43 | 44 | module-margin-left = 1 45 | module-margin-right = 1 46 | 47 | font-0 = FiraCode:size=9;3 48 | 49 | [bar/neon] 50 | modules-left = bspwm volume backlight 51 | modules-center = title 52 | modules-right = cpuload temperature wireless battery battery_usage date 53 | 54 | monitor = 55 | width = ${bar/xenon.width} 56 | height = ${bar/xenon.height} 57 | 58 | radius = ${bar/xenon.radius} 59 | fixed-center = ${bar/xenon.fixed-center} 60 | 61 | background = ${bar/xenon.background} 62 | foreground = ${bar/xenon.foreground} 63 | 64 | underline-size = ${bar/xenon.underline-size} 65 | underline-color = ${bar/xenon.underline-color} 66 | 67 | border-size = ${bar/xenon.border-size} 68 | border-color = ${bar/xenon.border-color} 69 | 70 | padding-left = ${bar/xenon.padding-left} 71 | padding-right = ${bar/xenon.padding-right} 72 | 73 | module-margin-left = ${bar/xenon.module-margin-left} 74 | module-margin-right = ${bar/xenon.module-margin-right} 75 | 76 | font-0 = ${bar/xenon.font-0} 77 | 78 | [bar/helium] 79 | modules-left = bspwm volume backlight 80 | modules-center = title 81 | modules-right = cpuload temperature wireless battery battery_usage date 82 | 83 | monitor = 84 | width = ${bar/xenon.width} 85 | height = ${bar/xenon.height} 86 | 87 | radius = ${bar/xenon.radius} 88 | fixed-center = ${bar/xenon.fixed-center} 89 | 90 | background = ${bar/xenon.background} 91 | foreground = ${bar/xenon.foreground} 92 | 93 | underline-size = ${bar/xenon.underline-size} 94 | underline-color = ${bar/xenon.underline-color} 95 | 96 | border-size = ${bar/xenon.border-size} 97 | border-color = ${bar/xenon.border-color} 98 | 99 | padding-left = ${bar/xenon.padding-left} 100 | padding-right = ${bar/xenon.padding-right} 101 | 102 | module-margin-left = ${bar/xenon.module-margin-left} 103 | module-margin-right = ${bar/xenon.module-margin-right} 104 | 105 | font-0 = ${bar/xenon.font-0} 106 | 107 | [bar/generic] 108 | modules-left = bspwm volume 109 | modules-center = title 110 | modules-right = cpuload date 111 | 112 | monitor = ${env:MONITOR:Virtual-1} 113 | monitor-fallback = ${env:MONITOR:eDP1} 114 | width = ${bar/xenon.width} 115 | height = ${bar/xenon.height} 116 | 117 | radius = ${bar/xenon.radius} 118 | fixed-center = ${bar/xenon.fixed-center} 119 | 120 | background = ${bar/xenon.background} 121 | foreground = ${bar/xenon.foreground} 122 | 123 | underline-size = ${bar/xenon.underline-size} 124 | underline-color = ${bar/xenon.underline-color} 125 | 126 | border-size = ${bar/xenon.border-size} 127 | border-color = ${bar/xenon.border-color} 128 | 129 | padding-left = ${bar/xenon.padding-left} 130 | padding-right = ${bar/xenon.padding-right} 131 | 132 | module-margin-left = ${bar/xenon.module-margin-left} 133 | module-margin-right = ${bar/xenon.module-margin-right} 134 | 135 | font-0 = ${bar/xenon.font-0} 136 | 137 | 138 | [module/bspwm] 139 | type = internal/bspwm 140 | 141 | pin-workspaces = false 142 | 143 | label-focused-background = ${colors.background-alt} 144 | label-focused-underline= ${colors.primary} 145 | label-focused-padding = 2 146 | 147 | label-occupied-padding = 1 148 | 149 | label-urgent-background = ${colors.alert} 150 | label-urgent-padding = 1 151 | 152 | label-empty-foreground = ${colors.foreground-alt} 153 | label-empty-padding = 1 154 | 155 | [module/cpugraph] 156 | type = internal/cpu 157 | interval = 1 158 | format = 159 | format-prefix = 160 | format-prefix-foreground = ${colors.foreground-alt} 161 | format-underline = ${colors.secondary} 162 | label = CPU %percentage-cores%% 163 | 164 | ramp-coreload-0 = ▁ 165 | ramp-coreload-1 = ▂ 166 | ramp-coreload-2 = ▃ 167 | ramp-coreload-3 = ▄ 168 | ramp-coreload-4 = ▅ 169 | ramp-coreload-5 = ▆ 170 | ramp-coreload-6 = ▇ 171 | ramp-coreload-7 = █ 172 | 173 | [module/cpuload] 174 | type = custom/script 175 | exec = cpu-usage 176 | format-prefix = "CPU " 177 | format-underline = ${colors.secondary} 178 | interval = 1 179 | 180 | [module/cpufreq] 181 | type = custom/script 182 | exec = sysinfo cpufreq 183 | format-underline = ${colors.secondary} 184 | interval = 1 185 | 186 | [module/memory] 187 | type = internal/memory 188 | interval = 1 189 | format-prefix = 190 | format-prefix-foreground = ${colors.foreground-alt} 191 | format-underline = ${colors.ternary} 192 | label = RAM %gb_used% 193 | 194 | [module/wireless] 195 | type = internal/network 196 | interface = wlp3s0 197 | interval = 1 198 | label-connected = NET %downspeed% %upspeed% 199 | format-connected-underline = ${colors.secondary} 200 | 201 | [module/wired] 202 | type = internal/network 203 | interface = enp4s0 204 | interval = 1 205 | label-connected = NET %downspeed% %upspeed% 206 | format-connected-underline = ${colors.secondary} 207 | 208 | [module/date] 209 | type = internal/date 210 | interval = 10 211 | 212 | time = %H:%M 213 | 214 | label = %time% 215 | 216 | [module/volume] 217 | type = internal/pulseaudio 218 | 219 | format-volume = 220 | format-volume-underline = ${colors.primary} 221 | label-volume = VOL %percentage%% 222 | label-volume-foreground = ${root.foreground} 223 | 224 | format-muted-prefix = 225 | format-muted-foreground = ${colors.foreground-alt} 226 | label-muted = MUTED 227 | 228 | [module/backlight] 229 | type = internal/backlight 230 | 231 | card = intel_backlight 232 | format =