Move Nix files into a nix directory

Move everything from `config` to the root level.
This commit is contained in:
Oliver Davies 2024-11-20 21:37:15 +00:00
parent 9f47df62b5
commit 69a397e624
124 changed files with 14 additions and 14 deletions

View file

@ -0,0 +1,91 @@
{
config,
desktop,
inputs,
pkgs,
self,
username,
...
}:
let
inherit (pkgs) lib;
desktop-config = import ./desktop.nix {
inherit
config
inputs
pkgs
username
;
};
shared-config = import "${self}/nix/lib/shared/home-manager.nix" {
inherit
inputs
pkgs
self
username
;
};
shared-packages = import "${self}/nix/lib/shared/home-manager-packages.nix" {
inherit
desktop
inputs
pkgs
username
;
};
in
{
imports =
if desktop then
[
desktop-config
shared-config
]
else
[ shared-config ];
home.packages =
shared-packages
++ pkgs.lib.optionals desktop (
with pkgs;
[
brave
discord
gimp
gscan2pdf
handbrake
kdenlive
meslo-lg
obs-studio
okular
pamixer
pass
pavucontrol
pinentry
via
pocket-casts
xcape
xsel
pkgs.nixpkgs-2405.zoom-us
]
);
home.sessionVariables = {
DIRENV_LOG_FORMAT = "";
EDITOR = "nvim";
LANG = "en_GB.UTF-8";
LC_ALL = "en_GB.UTF-8";
LC_CTYPE = "en_GB.UTF-8";
PATH = lib.concatStringsSep ":" [
"$PATH"
"$HOME/go/bin"
"./vendor/bin"
"./node_modules/.bin"
];
PULUMI_SKIP_UPDATE_CHECK = "true";
REPOS = "$HOME/Code";
RIPGREP_CONFIG_PATH = "$HOME/.config/ripgrep/config";
};
}

View file

@ -0,0 +1,18 @@
{
config,
inputs,
pkgs,
username,
}:
{
imports = [
../../modules/home-manager/alacritty.nix
../../modules/home-manager/copyq.nix
../../modules/home-manager/bluetuith.nix
../../modules/home-manager/espanso.nix
../../modules/home-manager/gtk.nix
../../modules/home-manager/flameshot.nix
../../modules/home-manager/gtk.nix
../../modules/home-manager/mpv.nix
];
}

View file

@ -0,0 +1,139 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, ... }:
{
imports = [
# Include the results of the hardware scan.
./hardware-configuration.nix
];
# Bootloader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.loader.efi.efiSysMountPoint = "/boot/efi";
boot.kernelPackages = pkgs.linuxPackages_latest;
networking.hostName = "lemp11"; # Define your hostname.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Enable networking
networking.networkmanager.enable = true;
# Set your time zone.
time.timeZone = "Europe/London";
# Select internationalisation properties.
i18n.defaultLocale = "en_GB.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "en_GB.UTF-8";
LC_IDENTIFICATION = "en_GB.UTF-8";
LC_MEASUREMENT = "en_GB.UTF-8";
LC_MONETARY = "en_GB.UTF-8";
LC_NAME = "en_GB.UTF-8";
LC_NUMERIC = "en_GB.UTF-8";
LC_PAPER = "en_GB.UTF-8";
LC_TELEPHONE = "en_GB.UTF-8";
LC_TIME = "en_GB.UTF-8";
};
# Enable the X11 windowing system.
services.xserver.enable = true;
# Enable the KDE Plasma Desktop Environment.
services.xserver.displayManager.sddm.enable = true;
services.xserver.desktopManager.plasma5.enable = true;
# Configure keymap in X11
services.xserver = {
layout = "gb";
xkbVariant = "";
};
# Configure console keymap
console.keyMap = "uk";
# Enable CUPS to print documents.
services.printing.enable = true;
# Enable sound with pipewire.
hardware.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
# If you want to use JACK applications, uncomment this
#jack.enable = true;
# use the example session manager (no others are packaged yet so this is enabled by default,
# no need to redefine it in your config for now)
#media-session.enable = true;
};
# Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true;
# Define a user account. Don't forget to set a password with passwd.
users.users.opdavies = {
isNormalUser = true;
description = "Oliver Davies";
extraGroups = [
"jellyfin"
"networkmanager"
"wheel"
];
packages = with pkgs; [
firefox
kate
# thunderbird
];
};
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
# vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
# wget
];
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
# programs.gnupg.agent = {
# enable = true;
# enableSSHSupport = true;
# };
# List services that you want to enable:
# Enable the OpenSSH daemon.
# services.openssh.enable = true;
# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "22.11"; # Did you read the comment?
}

View file

@ -0,0 +1,51 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{
config,
lib,
pkgs,
modulesPath,
...
}:
{
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot.initrd.availableKernelModules = [
"xhci_pci"
"thunderbolt"
"nvme"
"usb_storage"
"usbhid"
"sd_mod"
"sdhci_pci"
];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/" = {
device = "/dev/disk/by-uuid/e577c869-18a1-4830-9e00-124fcabdab89";
fsType = "ext4";
};
fileSystems."/boot/efi" = {
device = "/dev/disk/by-uuid/48FE-D346";
fsType = "vfat";
};
swapDevices = [ { device = "/dev/disk/by-uuid/2dce327b-f18d-4727-a9a2-e79d2b5161f9"; } ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp0s13f0u1u2u4.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp0s20f3.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View file

@ -0,0 +1,294 @@
{
inputs,
outputs,
desktop ? false,
hostname,
self,
}:
{ pkgs, ... }:
let
username = "opdavies";
in
{
imports = [ ../../modules/nixos/desktop ];
nixpkgs = {
config = {
allowUnfree = true;
permittedInsecurePackages = [ "electron-27.3.11" ];
};
overlays = [
outputs.overlays.additions
outputs.overlays.modifications
outputs.overlays.stable-packages
outputs.overlays.unstable-packages
];
};
nix.nixPath = [ "nixpkgs=${inputs.nixpkgs}" ];
# Bootloader.
boot = {
loader = {
systemd-boot = {
enable = true;
configurationLimit = 10;
};
efi = {
canTouchEfiVariables = true;
efiSysMountPoint = "/boot/efi";
};
};
};
services.thermald.enable = true;
services.power-profiles-daemon.enable = false;
systemd.extraConfig = ''
DefaultTimeoutStopSec=10s
'';
networking.hostName = hostname;
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Enable networking
networking.networkmanager.enable = true;
# Set your time zone.
time.timeZone = "Europe/London";
# Select internationalisation properties.
i18n.defaultLocale = "en_GB.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "en_GB.UTF-8";
LC_IDENTIFICATION = "en_GB.UTF-8";
LC_MEASUREMENT = "en_GB.UTF-8";
LC_MONETARY = "en_GB.UTF-8";
LC_NAME = "en_GB.UTF-8";
LC_NUMERIC = "en_GB.UTF-8";
LC_PAPER = "en_GB.UTF-8";
LC_TELEPHONE = "en_GB.UTF-8";
LC_TIME = "en_GB.UTF-8";
};
# Enable the X11 windowing system.
services.xserver.enable = true;
services.xserver = {
xkb = {
layout = "gb";
variant = "";
};
};
# Configure console keymap
console.keyMap = "uk";
services.avahi.enable = true;
services.avahi.nssmdns4 = true;
services.avahi.openFirewall = true;
services.printing.enable = true;
# Enable sound with pipewire.
hardware.pulseaudio.enable = false;
security = {
polkit.enable = true;
rtkit.enable = true;
};
services.pipewire = {
enable = true;
alsa = {
enable = true;
support32Bit = true;
};
pulse.enable = true;
};
# Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true;
users.users.${username} = {
isNormalUser = true;
description = "Oliver Davies";
extraGroups = [
"docker"
"networkmanager"
"wheel"
];
packages = with pkgs; [ ];
};
security.sudo.wheelNeedsPassword = false;
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages =
with pkgs;
[
caffeine-ng
gtypist
fastfetch
mermaid-cli
mkcert
taskopen
taskwarrior3
taskwarrior-tui
ttyper
yt-dlp
ytfzf
]
++ pkgs.lib.optionals desktop [
acpi
arandr
backintime
bluetuith
brightnessctl
cpufrequtils
libnotify
pmutils
ffmpegthumbnailer
libreoffice
logseq
rclone
rclone-browser
shotwell
slack
vscode
xfce.thunar
xfce.thunar-volman
xfce.tumbler
# Games.
zeroad
];
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
# programs.gnupg.agent = {
# enable = true;
# enableSSHSupport = true;
# };
# List services that you want to enable:
# Enable the OpenSSH daemon.
services.openssh.enable = true;
# Open ports in the firewall.
networking.firewall.allowedTCPPorts = [
9003 # xdebug
];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "22.11"; # Did you read the comment?
programs.dconf.enable = true;
programs.zsh.enable = true;
programs.zsh.histSize = 5000;
users.defaultUserShell = "/etc/profiles/per-user/${username}/bin/zsh";
zramSwap.enable = true;
nix = {
extraOptions = ''
trusted-users = root ${username}
'';
gc = {
automatic = true;
dates = "daily";
options = "--delete-older-than 7d";
};
optimise.automatic = true;
settings = {
auto-optimise-store = true;
experimental-features = [
"nix-command"
"flakes"
];
warn-dirty = false;
};
};
# Make Caps lock work as an Escape key on press and Ctrl on hold.
services.interception-tools =
let
dfkConfig = pkgs.writeText "dual-function-keys.yaml" ''
MAPPINGS:
- KEY: KEY_CAPSLOCK
TAP: KEY_ESC
HOLD: KEY_LEFTCTRL
'';
in
{
enable = true;
plugins = pkgs.lib.mkForce [ pkgs.interception-tools-plugins.dual-function-keys ];
udevmonConfig = ''
- JOB: "${pkgs.interception-tools}/bin/intercept -g $DEVNODE | ${pkgs.interception-tools-plugins.dual-function-keys}/bin/dual-function-keys -c ${dfkConfig} | ${pkgs.interception-tools}/bin/uinput -d $DEVNODE"
DEVICE:
NAME: "AT Translated Set 2 keyboard"
EVENTS:
EV_KEY: [[KEY_CAPSLOCK, KEY_ESC, KEY_LEFTCTRL]]
'';
};
services.gvfs.enable = true;
programs.gnupg.agent = {
enable = true;
enableSSHSupport = true;
pinentryPackage = pkgs.pinentry-qt;
};
programs.firefox = {
enable = true;
languagePacks = [ "en-GB" ];
preferences = {
"intl.accept_languages" = "en-GB, en";
"intl.regional_prefs.use_os_locales" = true;
};
};
services.blueman.enable = true;
services.cron = {
enable = true;
systemCronJobs = [ "* * * * * opdavies /home/${username}/.local/bin/notify-battery" ];
};
services.auto-cpufreq.enable = true;
services.udev = {
enable = true;
extraRules = ''
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0660", GROUP="users", TAG+="uaccess", TAG+="udev-acl"
'';
};
}

64
nix/lib/nixos/default.nix Normal file
View file

@ -0,0 +1,64 @@
{
inputs,
outputs,
nixos-hardware,
pkgs,
self,
username,
}:
{
desktop ? false,
hostname,
}:
let
configuration = import ./configuration.nix {
inherit
outputs
desktop
hostname
inputs
self
;
};
hardwareConfiguration = import ./hardware-configuration.nix;
in
inputs.nixpkgs.lib.nixosSystem {
modules = [
inputs.home-manager.nixosModules.home-manager
{
home-manager = {
extraSpecialArgs = {
inherit
inputs
desktop
self
username
;
};
useGlobalPkgs = true;
useUserPackages = true;
users."${username}" = import "${self}/nix/home/${username}";
};
}
(import ../../modules/nixos/autorandr.nix)
(import ../../modules/nixos/i3.nix {
inherit
inputs
pkgs
self
username
;
})
configuration
hardwareConfiguration
# TODO: only for "lemp11".
nixos-hardware.nixosModules.common-cpu-intel
nixos-hardware.nixosModules.common-gpu-intel
nixos-hardware.nixosModules.common-pc-laptop
nixos-hardware.nixosModules.common-pc-laptop-hdd
nixos-hardware.nixosModules.system76
];
}

View file

@ -0,0 +1,59 @@
{
config,
lib,
pkgs,
modulesPath,
...
}:
{
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot.initrd.availableKernelModules = [
"xhci_pci"
"thunderbolt"
"nvme"
"usb_storage"
"sd_mod"
];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.kernelParams = [
"i915.modeset=1"
"i915.fastboot=1"
"i915.enable_guc=2"
"i915.enable_psr=1"
"i915.enable_fbc=1"
"i915.enable_dc=2"
];
boot.extraModulePackages = [ ];
boot.kernelPackages = pkgs.linuxPackages_zen;
hardware.enableAllFirmware = true;
hardware.system76.enableAll = true;
fileSystems."/" = {
device = "/dev/disk/by-label/nixos";
fsType = "ext4";
};
fileSystems."/boot/efi" = {
device = "/dev/disk/by-label/boot";
fsType = "vfat";
};
swapDevices = [ { device = "/dev/disk/by-label/swap"; } ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp0s13f0u1.useDHCP = lib.mkDefault true;
# networking.interfaces.wlo1.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
hardware.bluetooth.enable = true;
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View file

@ -0,0 +1,83 @@
{
desktop,
inputs,
pkgs,
username,
...
}:
let
php = pkgs.php82;
phpPackages = pkgs.php82Packages;
inherit (pkgs) writeShellApplication;
_timer = writeShellApplication (import ./scripts/_timer.nix);
create-zellij-session = writeShellApplication (
import ./scripts/create-zellij-session.nix { inherit pkgs; }
);
deliver = writeShellApplication (import ./scripts/deliver.nix { inherit pkgs; });
export-video-list = writeShellApplication (
import ./scripts/export-video-list.nix { inherit pkgs username; }
);
run = writeShellApplication (import ./scripts/run.nix { inherit pkgs; });
t = writeShellApplication (import ./scripts/t.nix { inherit pkgs; });
timer = writeShellApplication (import ./scripts/timer.nix);
in
with pkgs;
[
age
awscli2
bitwarden-cli
bottom
cachix
ctop
delta
devenv
dog
doppler
entr
fd
file
gcc
gh
git
git-crypt
gnupg
go
inotify-tools
jq
killall
lua
mariadb
mob
php
phpPackages.composer
pv
rustywind
simple-http-server
sshs
tldr
tree
tree-sitter
unzip
virtualenv
watchexec
wget
xclip
xcp
xdg-utils
xh
yarn
# Scripts.
create-zellij-session
deliver
run
t
]
++ pkgs.lib.optionals desktop [
# Scripts.
_timer
export-video-list
timer
]

View file

@ -0,0 +1,47 @@
{
inputs,
pkgs,
username,
self,
}:
{
home.username = "${username}";
home.homeDirectory = "/home/${username}";
# Nicely reload system units when changing configs.
systemd.user.startServices = "sd-switch";
# See https://github.com/nix-community/home-manager/issues/2064#issuecomment-2259307514.
# This is a workaround for the following errors that appeared when switching back to unstable:
# - 1: Failed to start unit flameshot.service
# - 2: org.freedesktop.systemd1.NoSuchUnit: Unit tray.target not found.
systemd.user.targets.tray = {
Unit = {
Description = "Home Manager System Tray";
Requires = [ "graphical-session-pre.target" ];
};
};
home.stateVersion = "22.05";
programs.home-manager.enable = true;
imports = [
(import ../../modules/home-manager/git.nix { inherit inputs pkgs; })
(import ../../modules/home-manager/neovim.nix { inherit inputs pkgs; })
../../modules/home-manager/bat.nix
../../modules/home-manager/bin.nix
../../modules/home-manager/direnv.nix
../../modules/home-manager/fzf.nix
../../modules/home-manager/htop.nix
../../modules/home-manager/lsd.nix
../../modules/home-manager/pet.nix
../../modules/home-manager/phpactor.nix
../../modules/home-manager/ripgrep.nix
../../modules/home-manager/starship.nix
../../modules/home-manager/syncthing.nix
../../modules/home-manager/tmux.nix
../../modules/home-manager/zellij.nix
../../modules/home-manager/zsh.nix
];
}

View file

@ -0,0 +1,13 @@
{
name = "_timer";
runtimeInputs = [ ];
text = ''
mins=$1
message=''${2:-Time out!}
sleep -- "$mins" * 60
notify-send -t 0 "''${message}" "Your timer of $mins min is over" -u normal
'';
}

View file

@ -0,0 +1,65 @@
{ pkgs }:
{
name = "create-zellij-session";
runtimeInputs = with pkgs; [
openssl
zellij
];
text = ''
function _execute_zellij_layout {
local session_name="$1"
local layout_file="$2"
DIGEST="$(openssl sha512 "$layout_file")"
# Prompt the first time we see a given layout file before running it.
if ! grep -q "$DIGEST" ~/..zellij.digests 2> /dev/null; then
cat "$layout_file"
read -r -n 1 -p "Trust (and run) this Zellij file? (t = trust, otherwise = skip) "
if [[ $REPLY =~ ^[Tt]$ ]]; then
echo "$DIGEST" >> ~/..zellij.digests
_attach_to_or_create_zellij_session --layout "$layout_file"
fi
else
_attach_to_or_create_zellij_session --layout "$layout_file"
fi
}
function _attach_to_or_create_zellij_session {
zellij attach "$session_name" 2>/dev/null || zellij --session "$session_name" "$@"
}
function main {
if [[ $# -eq 1 ]]; then
selected_path=$1
else
selected_path=$(find "$REPOS" "$REPOS/tfw" "$HOME/Documents" -maxdepth 1 -mindepth 1 -type d \
! -name "*-old" \
! -name "*.bak" \
! -name "*.old" \
! -name "_archive" \
| sort \
| fzf --reverse)
fi
session_name=$(basename "$selected_path")
cd "$selected_path"
if [[ -f ".ignored/dev.kdl" ]]; then
_execute_zellij_layout "$session_name" ".ignored/dev.kdl"
elif [[ -f "dev.kdl" ]]; then
_execute_zellij_layout "$session_name" "dev.kdl"
fi
_attach_to_or_create_zellij_session
}
main "$@"
'';
}

View file

@ -0,0 +1,25 @@
{ pkgs }:
{
name = "deliver";
runtimeInputs = with pkgs; [ docker ];
text = ''
set +o pipefail
# Based on https://github.com/jessarcher/dotfiles/blob/ef692c35d64db2c13674dfc850a23b6acf9e8f91/scripts/deliver.
docker_compose_service_name=$(docker compose ps --services 2>/dev/null | grep '^app\|php$' | head -n1)
if [[ "$docker_compose_service_name" != "" ]]; then
if [ -t 1 ]; then
"${pkgs.docker}/bin/docker" compose exec "$docker_compose_service_name" "$@"
else
# The command is not being run in a TTY
"${pkgs.docker}/bin/docker" compose exec -T "$docker_compose_service_name" "$@"
fi
else
"$@"
fi
'';
}

View file

@ -0,0 +1,33 @@
{ pkgs, username, ... }:
{
name = "export-video-list";
runtimeInputs = with pkgs; [
jq
tree
udisks
];
text = ''
device_name="/dev/sda2"
device_label="UNTITLED"
source_path="/run/media/${username}/$device_label"
# If the source path doesn't exist, try mounting the device.
if [[ ! -d "$source_path" ]]; then
${pkgs.udisks}/bin/udisksctl mount -b "$device_name"
fi
# Exit early if the source path still doesn't exist.
if [[ ! -d "$source_path" ]]; then
echo "Error: $source_path not found."
exit 1
fi
output_file="$HOME/Documents/videos.json"
${pkgs.tree}/bin/tree -J "$source_path/Videos" | ${pkgs.jq}/bin/jq . > "$output_file"
${pkgs.jq}/bin/jq . < "$output_file"
'';
}

View file

@ -0,0 +1,16 @@
{ pkgs }:
{
name = "run";
runtimeInputs = with pkgs; [ bashInteractive ];
text = ''
if [[ -e .ignored/run ]]; then
.ignored/run "$@"
exit $?
fi
./run "$@"
'';
}

View file

@ -0,0 +1,38 @@
{ pkgs }:
{
name = "t";
runtimeInputs = with pkgs; [
openssl
tmux
];
text = ''
# Based on similar scripts by ThePrimeagen and Jess Archer.
if [[ $# -eq 1 ]]; then
selected_path=$1
else
# Get the session name from fuzzy-finding list of directories and generating a
# tmux-safe version.
items=$(find "$REPOS" ~/Documents \
-maxdepth 1 -mindepth 1 -type d \
! -name "_archive" \
! -name "*-old" \
! -name "*.old"
)
selected_path=$(echo "''${items}" | sort | fzf --reverse)
fi
session_name=$(basename "$selected_path" | sed 's/\./_/g')
if tmux switch-client -t="$session_name" 2>/dev/null; then
exit 0
fi
( (tmux new-session -c "$selected_path" -d -s "$session_name" && tmux switch-client -t "$session_name") 2>/dev/null ) ||
tmux new-session -c "$selected_path" -A -s "$session_name"
'';
}

View file

@ -0,0 +1,20 @@
{
name = "timer";
runtimeInputs = [ ];
text = ''
if [[ "$1" == "" ]]; then
echo "Usage: ''${0##*/} <mins> [message]"
exit 1
fi
mins=$1
message=$2
nohup _timer "$mins" "$message" &> /dev/null &
echo "timer started for $mins min"
echo "timer started for $mins min, message: '$message'" | systemd-cat -t timer
'';
}

12
nix/lib/theme/default.nix Normal file
View file

@ -0,0 +1,12 @@
{ pkgs, ... }:
{
fonts = {
monospace = {
name = "MesloLGSDZ Nerd Font Mono";
# fc-list : family | sort | grep "Nerd Font"
package = pkgs.nerdfonts.override { fonts = [ "Meslo" ]; };
size = "10";
};
};
}

62
nix/lib/wsl2/default.nix Normal file
View file

@ -0,0 +1,62 @@
{
inputs,
outputs,
self,
username,
}:
{ system }:
let
inherit (pkgs) lib;
pkgs = import inputs.nixpkgs {
overlays = [
outputs.overlays.additions
outputs.overlays.modifications
outputs.overlays.unstable-packages
];
};
shared-config = import "${self}/nix/lib/shared/home-manager.nix" {
inherit
inputs
pkgs
self
username
;
};
shared-packages = import "${self}/nix/lib/shared/home-manager-packages.nix" {
inherit inputs pkgs username;
desktop = false;
};
in
inputs.home-manager.lib.homeManagerConfiguration {
inherit pkgs;
extraSpecialArgs = {
inherit self;
};
modules = [
{
imports = [ shared-config ];
home.packages = shared-packages ++ [ pkgs.wsl-open ];
home.sessionVariables = {
DIRENV_LOG_FORMAT = "";
EDITOR = "nvim";
PATH = lib.concatStringsSep ":" [
"$PATH"
"$HOME/go/bin"
"./vendor/bin"
"./node_modules/.bin"
];
PULUMI_SKIP_UPDATE_CHECK = "true";
REPOS = "$HOME/Code";
RIPGREP_CONFIG_PATH = "$HOME/.config/ripgrep/config";
};
}
];
}

View file

@ -0,0 +1,42 @@
{
lib,
pkgs,
self,
...
}:
let
inherit (lib) strings;
inherit (strings) toInt;
theme = import "${self}/nix/lib/theme" { inherit pkgs; };
in
{
programs.alacritty = {
enable = true;
settings = {
env = {
TERM = "screen-256color";
};
window.padding = {
x = 15;
y = 15;
};
font = {
size = toInt "${theme.fonts.monospace.size}";
bold.style = "Regular";
normal.family = "${theme.fonts.monospace.name}";
offset.y = 6;
glyph_offset.y = 3;
};
terminal.shell = {
program = "zsh";
};
};
};
}

View file

@ -0,0 +1 @@
{ programs.bat.enable = true; }

View file

@ -0,0 +1,9 @@
{ self, ... }:
{
home.sessionPath = [ "$HOME/.local/bin" ];
home.file.".local/bin" = {
source = "${self}/nix/bin";
recursive = true;
};
}

View file

@ -0,0 +1,19 @@
{
xdg.configFile."bluetuith/bluetuith.conf" = {
text = ''
{
adapter: ""
adapter-states: ""
connect-bdaddr: ""
gsm-apn: ""
gsm-number: ""
keybindings: {
NavigateDown: j
NavigateUp: k
}
receive-dir: ""
theme: {}
}
'';
};
}

View file

@ -0,0 +1 @@
{ services.copyq.enable = true; }

View file

@ -0,0 +1,7 @@
{
programs.direnv = {
enable = true;
enableZshIntegration = true;
nix-direnv.enable = true;
};
}

View file

@ -0,0 +1,16 @@
{
services.espanso = {
enable = true;
configs = {
default = {
show_notifications = false;
toggle_key = "LEFT_ALT";
};
};
matches = {
base = import ./espanso/matches/base.nix;
};
};
}

View file

@ -0,0 +1,81 @@
let
websiteUrl = "https://www.oliverdavies.uk";
dailyUrl = "https://dailydrupaler.com";
podcastUrl = "https://beyondblockspodcast.com";
in
{
matches = [
{
trigger = ":archive";
replace = "${websiteUrl}/archive";
}
{
trigger = ":atdc";
replace = "${websiteUrl}/atdc";
}
{
trigger = ":call";
replace = "${websiteUrl}/call";
}
{
trigger = ":coaching";
replace = "${websiteUrl}/team-coaching";
}
{
trigger = ":daily";
replace = "${dailyUrl}";
}
{
trigger = ":dotfiles";
replace = "https://github.com/opdavies/dotfiles.nix";
}
{
trigger = ":dc";
replace = "Drupal Commerce";
}
{
trigger = ":dr";
replace = "Drupal";
}
{
trigger = ":gt";
replace = "Great, thanks!";
}
{
trigger = ":guest";
replace = "If you'd like to be a guest on ${podcastUrl} and talk about ..., I'd love to have you on the show.";
}
{
trigger = ":lh";
replace = "http://localhost";
}
{
trigger = ":podcast";
replace = "${podcastUrl}";
}
{
trigger = ":pricing";
replace = "${websiteUrl}/pricing";
}
{
trigger = ":record";
replace = "https://savvycal.com/opdavies/beyond-blocks";
}
{
trigger = ":talks";
replace = "${websiteUrl}/presentations";
}
{
trigger = ":website";
replace = "${websiteUrl}";
}
{
trigger = ":zet";
replace = "https://zet.oliverdavies.uk";
}
{
trigger = ":zoom";
replace = "https://savvycal.com/opdavies/zoom";
}
];
}

View file

@ -0,0 +1,16 @@
{ username, ... }:
{
services.flameshot = {
enable = true;
settings = {
General = {
disabledTrayIcon = false;
saveAfterCopy = true;
savePath = "/home/${username}/Pictures/Screenshots";
showHelp = false;
uiColor = "#60a5fa";
};
};
};
}

View file

@ -0,0 +1,6 @@
{
programs.fzf = {
enable = true;
enableZshIntegration = true;
};
}

View file

@ -0,0 +1,154 @@
{ pkgs, ... }:
{
home.file.".gitmessage".text = ''
# Description
#
# - Why is this change necessary?
# - How does it address the issue?
# - What side effects does this change have?
#
# For breaking changes, uncomment the following line and describe the change:
#
# BREAKING CHANGE:
#
#
# Add any issue IDs or commit SHAs that this commit references:
#
# Refs:
'';
programs = {
git = {
enable = true;
userName = "Oliver Davies";
userEmail = "oliver@oliverdavies.dev";
includes = [
{
condition = "gitdir:~/Code/tfw";
contents.user.email = "oliver.davies@tfw.wales";
}
];
aliases = {
aa = "add --all";
assume = "update-index --assume-unchanged";
assumed = "!git ls-files -v | grep '^[hsmrck?]' | cut -c 3-";
b = "branch";
blame = "blame -w -C -C -C";
browse = "!gh repo view --web";
ca = "commit --amend --verbose";
car = "commit --amend --no-edit";
cl = "!hub clone";
co = "checkout";
compare = "!hub compare";
current-branch = "rev-parse --abbrev-ref HEAD";
dc = "diff --color --word-diff --cached";
df = "diff --color --word-diff";
dup = "!git checkout develop && git fetch origin && echo && git sl develop..origin/develop && echo && git pull --quiet && git checkout -";
fixup = "commit --fixup";
issues = "!gh issue list --web";
mup = "!git master-to-main-wrapper checkout %BRANCH% && git fetch origin && echo && git sl %BRANCH%..origin/%BRANCH% && echo && git pull --quiet && git checkout -";
no-ff = "merge --no-ff";
pl = "pull";
prune = "remote prune origin";
ps = "push";
pulls = "!gh pr list --web";
rbc = "rebase --continue";
rdup = "!git dup && git rebase develop";
remotes = "remote -v";
repush = "!git pull --rebase && git push";
ri = "rebase --interactive";
rid = "!git rebase -i $(git merge-base develop HEAD)";
rim = "!git rebase -i $(git master-to-main-wrapper merge-base %BRANCH% HEAD)";
rip = "!git rebase -i $(git merge-base production HEAD)";
ris = "!git rebase -i $(git merge-base staging HEAD)";
riu = "!git rebase -i $(git rev-parse --abbrev-ref --symbolic-full-name @{u})";
rmup = "!git mup && git master-to-main-wrapper rebase %BRANCH%";
sl = "log --oneline --decorate -20";
sla = "log --oneline --decorate --graph --all -20";
slap = "log --oneline --decorate --graph --all";
slp = "log --oneline --decorate";
stash = "stash --included-untracked";
unassume = "update-index --no-assume-unchanged";
uncommit = "reset --soft HEAD^";
unstage = "reset";
update = "!git fetch --all --jobs=4 --prune --progress && git rebase --autostash --stat";
upstream = "rev-parse --abbrev-ref --symbolic-full-name @{u}";
ureset = "!git reset --hard $(git upstream)";
worktrees = "worktree list";
};
ignores = [
"/.ddev/providers/"
"/.direnv/"
"/.ignored/"
"/.issue-id"
"/.phpactor.json"
"/notes"
"/todo"
];
extraConfig = {
branch = {
autosetupmerge = true;
autosetuprebase = "always";
sort = "-committerdate";
};
checkout.defaultRemote = "origin";
color.ui = true;
column.ui = "auto";
commit.template = "~/.gitmessage";
core = {
editor = "nvim";
excludesFile = "~/.config/git/ignore";
pager = "delta";
};
delta.line-numbers = true;
diff.tool = "vimdiff";
fetch.prune = true;
gpg.format = "ssh";
grep.lineNumber = true;
help.autocorrect = "1";
init.defaultBranch = "main";
maintenance = {
auto = false;
strategy = "incremental";
};
merge.ff = "only";
push = {
autoSetupRemote = true;
default = "upstream";
};
pull = {
ff = "only";
rebase = true;
};
rebase = {
autosquash = true;
autostash = true;
};
user.signingkey = "~/.ssh/id_rsa.pub";
};
};
};
home.packages = with pkgs.unstable; [ git-instafix ];
home.sessionVariables = {
GIT_INSTAFIX_UPSTREAM = "origin/main";
};
}

View file

@ -0,0 +1,11 @@
{ pkgs, ... }:
{
gtk = {
enable = true;
theme.package = pkgs.arc-theme;
theme.name = "Arc-Dark";
iconTheme.package = pkgs.arc-icon-theme;
iconTheme.name = "Arc";
};
}

View file

@ -0,0 +1,9 @@
{
programs.htop = {
enable = true;
settings = {
show_cpu_temperature = true;
};
};
}

View file

@ -0,0 +1,10 @@
{
programs.lsd = {
enable = true;
enableAliases = false;
settings = {
icons.when = "never";
};
};
}

View file

@ -0,0 +1,11 @@
{
programs.mpv = {
enable = true;
# https://github.com/mpv-player/mpv/blob/master/etc/input.conf
bindings = {
"DOWN" = "add volume -5";
"UP" = "add volume 5";
};
};
}

View file

@ -0,0 +1,202 @@
{ inputs, pkgs, ... }:
{
programs.neovim = {
enable = true;
plugins = with pkgs.vimPlugins; [
comment-nvim
dial-nvim
fidget-nvim
gitsigns-nvim
harpoon
impatient-nvim
mini-nvim
neodev-nvim
nvim-spectre
nvim-web-devicons
oil-nvim
refactoring-nvim
sort-nvim
treesj
undotree
vim-abolish
vim-eunuch
vim-highlightedyank
vim-just
vim-nix
vim-obsession
vim-pasta
vim-repeat
vim-sleuth
vim-sort-motion
vim-terraform
vim-textobj-user
vim-unimpaired
conf-vim
edit-alternate-vim
nvim-tmux-navigation
standard-vim
vim-autoread
vim-textobj-indent
vim-textobj-xmlattr
vim-zoom
# Testing
vim-test
# Git
committia-vim
diffview-nvim
vim-fugitive
# Debugging
nvim-dap
nvim-dap-ui
nvim-dap-virtual-text
# Treesitter
(pkgs.vimPlugins.nvim-treesitter.withPlugins (
plugins: with plugins; [
bash
comment
css
csv
dockerfile
gitattributes
gitignore
go
html
javascript
json
kdl
lua
luadoc
make
markdown
markdown_inline
nix
php
phpdoc
query
rst
scss
sql
terraform
twig
typescript
vim
vimdoc
vue
xml
yaml
]
))
nvim-treesitter-context
nvim-treesitter-textobjects
# LSP, linting and formatting
conform-nvim
lsp-status-nvim
nvim-lint
nvim-lspconfig
# Completion
cmp-buffer
cmp-calc
cmp-cmdline
cmp-nvim-lsp
cmp-path
cmp-treesitter
cmp_luasnip
lspkind-nvim
nvim-cmp
# Snippets
friendly-snippets
luasnip
# Telescope
plenary-nvim
popup-nvim
telescope-frecency-nvim
telescope-fzf-native-nvim
telescope-live-grep-args-nvim
telescope-nvim
telescope-ui-select-nvim
# Databases
vim-dadbod
vim-dadbod-ui
vim-dadbod-completion
# Themes
catppuccin-nvim
# Configuration.
inputs.self.packages.${pkgs.system}.opdavies-nvim
];
extraLuaConfig = ''
if vim.loader then
vim.loader.enable()
end
require "opdavies"
'';
extraPackages = with pkgs; [
# Languages
nodePackages.typescript
nodejs-slim
php81
# Language servers
gopls
lua-language-server
lua54Packages.luacheck
marksman
nixd
nodePackages."@tailwindcss/language-server"
nodePackages.bash-language-server
nodePackages.dockerfile-language-server-nodejs
nodePackages.intelephense
nodePackages.typescript-language-server
nodePackages.vls
nodePackages.vscode-langservers-extracted
nodePackages.vue-language-server
nodePackages.yaml-language-server
phpactor
terraform-ls
# Formatters
black
eslint_d
nixfmt-rfc-style
nodePackages.prettier
stylua
yamlfmt
# Tools
hadolint
html-tidy
nodePackages.jsonlint
nodePackages.markdownlint-cli
php82Packages.php-codesniffer
php82Packages.phpstan
proselint
shellcheck
yamllint
];
};
home.file.".markdownlint.yaml".text = ''
default: true
line-length: false
no-duplicate-heading:
siblings_only: true
'';
}

View file

@ -0,0 +1,24 @@
{
programs.pet = {
enable = true;
snippets = [
{
command = "nix flake lock --update-input <input-name>";
description = "Display a log of a Git repository, showing each commit on its own line.";
output = "";
tag = [ "git" ];
}
{
command = "nix flake lock --update-input opdavies-nvim";
description = "Update a single input within a Nix flake.";
output = "";
tag = [
"nix"
"nix-flake"
];
}
];
};
}

View file

@ -0,0 +1,7 @@
{ self, ... }:
{
xdg.configFile.phpactor = {
source = "${self}/phpactor";
recursive = true;
};
}

View file

@ -0,0 +1,9 @@
{ pkgs, ... }:
{
home.packages = with pkgs; [ ripgrep ];
xdg.configFile."ripgrep/config".text = ''
--follow
--smart-case
'';
}

View file

@ -0,0 +1,175 @@
let
inherit (builtins) concatStringsSep;
in
{
programs.starship = {
enable = true;
enableZshIntegration = true;
settings = {
add_newline = false;
# https://starship.rs/config/#prompt
format = concatStringsSep "" [
"\n"
"$username"
"$hostname"
"$directory"
"$vcsh"
"$git_branch"
"$git_status"
"$git_metrics"
"$docker_context"
"$nodejs"
"$php"
"$terraform"
"$nix_shell"
"$direnv"
"\${custom.mob}"
"$memory_usage"
"$cmd_duration"
"$lua"
"$status"
"$character"
];
cmd_duration.disabled = true;
direnv.disabled = false;
directory.format = "[$path]($style) ";
git_status.disabled = true;
nix_shell.disabled = true;
nodejs.disabled = true;
php.disabled = true;
username.disabled = true;
custom = {
mob = {
command = "echo $MOB_TIMER_ROOM";
format = "[($output)]($style) ";
when = "[[ -v MOB_TIMER_ROOM ]]";
};
};
# https://starship.rs/presets/plain-text
aws.symbol = "aws ";
azure.symbol = "az ";
bun.symbol = "bun ";
c.symbol = "C ";
character = {
success_symbol = "[>](bold green)";
error_symbol = "[x](bold red)";
vimcmd_symbol = "[<](bold green)";
};
cobol.symbol = "cobol ";
conda.symbol = "conda ";
crystal.symbol = "cr ";
cmake.symbol = "cmake ";
daml.symbol = "daml ";
dart.symbol = "dart ";
deno.symbol = "deno ";
dotnet.symbol = ".NET ";
directory.read_only = " ro";
docker_context.symbol = "docker ";
elixir.symbol = "exs ";
elm.symbol = "elm ";
fennel.symbol = "fnl ";
fossil_branch.symbol = "fossil ";
gcloud.symbol = "gcp ";
git_branch.symbol = "git ";
git_commit.tag_symbol = " tag ";
git_status = {
ahead = ">";
behind = "<";
diverged = "<>";
renamed = "r";
deleted = "x";
};
gleam.symbol = "gleam ";
golang.symbol = "go ";
gradle.symbol = "gradle ";
guix_shell.symbol = "guix ";
hg_branch.symbol = "hg ";
java.symbol = "java ";
julia.symbol = "jl ";
kotlin.symbol = "kt ";
lua.symbol = "lua ";
nodejs.symbol = "nodejs ";
memory_usage.symbol = "memory ";
meson.symbol = "meson ";
nats.symbol = "nats ";
nim.symbol = "nim ";
nix_shell.symbol = "nix ";
ocaml.symbol = "ml ";
opa.symbol = "opa ";
os.symbols = {
AIX = "aix ";
Alpaquita = "alq ";
AlmaLinux = "alma ";
Alpine = "alp ";
Amazon = "amz ";
Android = "andr ";
Arch = "rch ";
Artix = "atx ";
CentOS = "cent ";
Debian = "deb ";
DragonFly = "dfbsd ";
Emscripten = "emsc ";
EndeavourOS = "ndev ";
Fedora = "fed ";
FreeBSD = "fbsd ";
Garuda = "garu ";
Gentoo = "gent ";
HardenedBSD = "hbsd ";
Illumos = "lum ";
Kali = "kali ";
Linux = "lnx ";
Mabox = "mbox ";
Macos = "mac ";
Manjaro = "mjo ";
Mariner = "mrn ";
MidnightBSD = "mid ";
Mint = "mint ";
NetBSD = "nbsd ";
NixOS = "nix ";
OpenBSD = "obsd ";
OpenCloudOS = "ocos ";
openEuler = "oeul ";
openSUSE = "osuse ";
OracleLinux = "orac ";
Pop = "pop ";
Raspbian = "rasp ";
Redhat = "rhl ";
RedHatEnterprise = "rhel ";
RockyLinux = "rky ";
Redox = "redox ";
Solus = "sol ";
SUSE = "suse ";
Ubuntu = "ubnt ";
Ultramarine = "ultm ";
Unknown = "unk ";
Void = "void ";
Windows = "win ";
};
package.symbol = "pkg ";
perl.symbol = "pl ";
php.symbol = "php ";
pijul_channel.symbol = "pijul ";
pulumi.symbol = "pulumi ";
purescript.symbol = "purs ";
python.symbol = "py ";
quarto.symbol = "quarto ";
raku.symbol = "raku ";
ruby.symbol = "rb ";
rust.symbol = "rs ";
scala.symbol = "scala ";
spack.symbol = "spack ";
solidity.symbol = "solidity ";
status.symbol = "[x](bold red) ";
sudo.symbol = "sudo ";
swift.symbol = "swift ";
typst.symbol = "typst ";
terraform.symbol = "terraform ";
zig.symbol = "zig ";
};
};
}

View file

@ -0,0 +1 @@
{ services.syncthing.enable = true; }

View file

@ -0,0 +1,77 @@
{ pkgs, ... }:
let
inherit (pkgs) tmuxPlugins;
in
{
programs.tmux = {
enable = true;
terminal = "tmux-256color";
extraConfig = ''
set-option -g status-keys "vi"
set-option -sa terminal-features "''${TERM}:RGB"
bind -n S-Left resize-pane -L 2
bind -n S-Right resize-pane -R 2
bind -n S-Down resize-pane -D 1
bind -n S-Up resize-pane -U 1
bind -n C-Left resize-pane -L 10
bind -n C-Right resize-pane -R 10
bind -n C-Down resize-pane -D 5
bind -n C-Up resize-pane -U 5
# Status line customisation
set-option -g status-left ""
set-option -g status-right " #{session_name}"
set-option -g status-right-length 100
set-option -g status-style "fg=#7C7D83 bg=default"
set-option -g window-status-activity-style none
set-option -g window-status-current-style "fg=#E9E9EA"
bind c new-window -c "#{pane_current_path}"
set -g base-index 1
set -g pane-base-index 1
set -g renumber-windows on
# Break a pane into a new window.
bind-key b break-pane -d
bind-key J command-prompt -p "join pane from: " "join-pane -h -s '%%'"
bind-key C-j choose-tree
set-window-option -g mode-keys vi
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
bind C-j split-window -v "tmux list-sessions | sed -E 's/:.*$//' | grep -v \"^$(tmux display-message -p '#S')\$\" | fzf --reverse | xargs tmux switch-client -t"
bind-key K run-shell 'tmux switch-client -n \; kill-session -t "$(tmux display-message -p "#S")" || tmux kill-session'
# Allow clearing screen with ctrl-l by using <prefix> C-l
bind C-l send-keys "C-l"
bind C-k send-keys "C-k"
# Enable mouse support.
setw -g mouse on
# Remove delay when switching Vim modes.
set -sg escape-time 0
set-option -g pane-active-border-style "fg=#1f2335"
set-option -g pane-border-style "fg=#1f2335"
bind-key -r f run-shell "tmux new-window t"
if-shell "[ -f ~/.tmux.conf.local ]" 'source ~/.tmux.conf.local'
'';
plugins = [
tmuxPlugins.vim-tmux-navigator
tmuxPlugins.yank
];
};
}

View file

@ -0,0 +1,11 @@
{ self, ... }:
{
programs.zellij = {
enable = true;
};
xdg.configFile."zellij" = {
source = "${self}/zellij";
recursive = true;
};
}

View file

@ -0,0 +1,124 @@
{ pkgs, ... }:
{
programs.zsh = {
dotDir = ".config/zsh";
enable = true;
enableCompletion = true;
cdpath = [ "~/Code" ];
shellAliases = (import ./zsh/aliases.nix);
localVariables = {
ABBR_SET_EXPANSION_CURSOR = 1;
};
initExtra = ''
# suffix
alias -s gz="tar -tf"
alias -s {html,HTML}="background firefox"
alias -s {jpg,JPG,png,PNG}="background okular"
alias -s {pdf,PDF}="background okular"
alias -s {zip,ZIP}="unzip -l"
background() {
for ((i=2;i<=$#;i++)); do
''${@[1]} ''${@[$i]} &> /dev/null &
done
}
git() {
if [[ "''${1}" == "root" ]]; then
shift
local ROOT="$(${pkgs.git}/bin/git rev-parse --show-toplevel 2> /dev/null || echo -n .)"
if [[ $# == 0 ]]; then
cd "''${ROOT}"
else
(cd "''${ROOT}" && eval "''${@}")
fi
else
${pkgs.git}/bin/git "''${@}"
fi
}
ttyper() {
command ${pkgs.ttyper}/bin/ttyper --language english1000 --words 50 "''${@}"
}
yt-dlp() {
command yt-dlp --paths ~/Videos "$@"
}
# Case insensitive autocompletion.
zstyle ":completion:*" matcher-list "" "m:{a-zA-Z}={A-Za-z}" "r:|=*" "l:|=* r:|=*"
autoload -Uz compinit && compinit
bindkey -s ^f "t\n"
bindkey -s ^v "nvim\n"
clear-ls-all() {
clear
ls -al
zle reset-prompt
}
zle -N clear-ls-all
clear-git-status() {
clear
git status
zle reset-prompt
}
zle -N clear-git-status
clear-tree-2() {
clear
tree -L 2
zle reset-prompt
}
zle -N clear-tree-2
clear-tree-3() {
clear
tree -L 3
zle reset-prompt
}
zle -N clear-tree-3
bindkey '^G' clear-git-status
# bindkey '^H' clear-tree-3
# bindkey '^J' clear-tree-2
# bindkey '^K' clear-ls-all
setopt auto_cd
setopt auto_pushd
setopt pushd_ignore_dups
setopt pushdminus
'';
zplug = {
enable = true;
plugins = [
{
name = "plugin/git";
tags = [ "from:oh-my-zsh" ];
}
{
name = "plugin/vi-mode";
tags = [ "from:oh-my-zsh" ];
}
{ name = "olets/zsh-abbr"; }
{ name = "zsh-users/zsh-completions"; }
{ name = "zsh-users/zsh-syntax-highlighting"; }
];
};
};
home.file.".config/zsh-abbr/user-abbreviations".text = builtins.readFile ./zsh/abbreviations.zsh;
}

View file

@ -0,0 +1,153 @@
abbr c="clear"
abbr cs="create-script"
abbr daily="run create-daily next"
abbr rst="rst2pdf"
abbr st="source .tmux"
abbr sz="source ~/.config/zsh/.zshrc"
abbr ti="timer"
abbr uagr="update-all-git-repos"
abbr v="nvim"
abbr yt="yt-dlp"
abbr evl="export-video-list"
abbr vv="cat ~/Documents/videos.json"
abbr g="git"
abbr ga="git add"
abbr gan="git add -N"
abbr gap="git add -p"
abbr gb="git branch"
abbr gbl="git blame"
abbr gc="git commit"
abbr gca="git commit --amend"
abbr gcan="git commit --amend --no-edit"
abbr gcl="git clone"
abbr gcm="git commit -m"
abbr gco="git checkout"
abbr gcob="git checkout -b"
abbr gd="git diff"
abbr gds="git diff --staged"
abbr gf="git fetch"
abbr gfa="git fetch --all"
abbr gl="git log"
abbr glo="git log --oneline"
abbr gls="git log --stat"
abbr gm="git merge"
abbr gmf="git merge --ff"
abbr gmnf="git merge --no-ff"
abbr gpl="git pull"
abbr gplr="git pull --rebase"
abbr gps="git push"
abbr gpsa="git push acquia"
abbr gpsam="git push acquia main"
abbr gpsap="git push acquia HEAD:production"
abbr gpso="git push origin"
abbr gpsom="git push origin main"
abbr gr="git rebase"
abbr gra="git rebase --abort"
abbr grc="git rebase --continue"
abbr gri="git rebase -i"
abbr gs="git status"
abbr gsh="git show"
abbr gst="git stash"
abbr gstp="git stash pop"
# tmux
abbr ta="tmux attach"
abbr tl="tmux list-sessions"
abbr tk="tmux kill-session"
# zellij
abbr czs="create-zellij-session"
abbr z="zellij"
abbr za="zellij attach"
abbr zd="zellij delete-session"
abbr zda="zellij delete-all-sessions"
abbr ze="zellij edit"
abbr zei="zellij edit --in-place"
abbr zk="zellij kill-session"
abbr zka="zellij kill-all-sessions | sort"
abbr zl="zellij list-sessions | grep -v EXITED"
abbr zla="zellij list-sessions"
abbr znt="zellij action new-tab"
abbr zr="zellij run --"
abbr zri="zellij run --in-place --"
abbr zrf="zellij run --floating --"
abbr multitask="zellij action start-or-reload-plugin file:$HOME/zellij-plugins/multitask.wasm --configuration "shell=$SHELL,cwd=`pwd`""
# Docker and Docker Compose.
abbr dk="docker"
abbr dkp="docker ps"
abbr dkpa="docker ps -a"
abbr dkpaq="docker ps -a -q"
abbr dkb="docker build -t"
abbr dks="docker start"
abbr dkt="docker stop"
abbr dkrm="docker rm"
abbr dkri="docker rmi"
abbr dke="docker exec -ti"
abbr dkl="docker logs -f"
abbr dki="docker images"
abbr dkpu="docker pull"
abbr dkph="docker push"
abbr dkbnc="docker build --no-cache -t"
abbr dkr="docker run --rm"
abbr dkrti="docker run --rm -ti"
abbr dkc="docker compose"
abbr dkcb="docker compose build"
abbr dkcu="docker compose up"
abbr dkclean="docker ps -q -a -f status=exited | xargs -r docker rm && docker images -q -f dangling=true | xargs -r docker rmi"
# Nix and direnv.
abbr dea="direnv allow"
abbr dee="direnv edit"
abbr nxf="nix flake"
abbr nxfc="nix flake check"
abbr nxfs="nix flake show"
abbr nxfu="nix flake update"
abbr nxr="nix run nixpkgs#%"
abbr nxs="nix shell nixpkgs#%"
# run scripts.
abbr r="run"
abbr rc="run composer"
abbr rcda="run composer dump-autoload"
abbr rci="run composer install"
abbr rcr="run composer require"
abbr rcu="run composer update"
abbr rd="run drush"
abbr rdce="run drush config:export -y"
abbr rdci="run drush config:import -y"
abbr rdcr="run drush cache:rebuild"
abbr rdscr="run drush php:script"
abbr rduli="run drush uli"
abbr rdup="run drush updatedb -y"
abbr rpub="run publish"
abbr rt="run test"
abbr -g A1="| awk '{print $1}'"
abbr -g C="| xclip -sel clip"
abbr -g Fj="| jq ."
abbr -g Fy="| yq ."
abbr -g G="| grep"
abbr -g GH="| grep HTTP"
abbr -g Gi="| grep -i"
abbr -g H2="| head -n 20"
abbr -g H="| head"
abbr -g L="| less"
abbr -g V="| nvim -"
abbr -g X="| xargs -I1"
abbr today="task +TODAY"
abbr tomorrow="task +TOMORROW"
abbr overdue="task +OVERDUE"
abbr nah="git reset --hard; git clean -fd"
abbr wip="git commit -m wip"
abbr dv="devenv"
abbr dvi="devenv info"
abbr dvp="devenv processes"
abbr dvs="devenv shell"
abbr dvt="devenv tasks"
abbr dvu="devenv up"

View file

@ -0,0 +1,14 @@
{
"$" = "";
"-" = "cd -";
".." = "cd ..";
"..." = "cd ../..";
"...." = "cd ../../..";
"....." = "cd ../../../..";
cat = "bat";
s = "secrets";
secrets = ''doppler --project "$(whoami)" run'';
tag = "tag-release";
vss = "LC_ALL=C sort --unique $REPOS/dotfiles.nix/config/neovim/spell/en.utf-8.add --output $REPOS/dotfiles.nix/config/neovim/spell/en.utf-8.add";
wt = "git worktree";
}

View file

@ -0,0 +1,43 @@
{
services.autorandr = {
enable = true;
profiles =
let
fingerprint = "00ffffffffffff000dae081400000000251d0104a51f117802ee95a3544c99260f505400000001010101010101010101010101010101363680a0703820403020350035ad1000001a000000fe004e3134304843472d4551310a20000000fe00434d4e0a202020202020202020000000fe004e3134304843472d4551310a200084";
name = "eDP-1";
in
{
default = {
fingerprint = {
"${name}" = fingerprint;
};
config = {
"${name}" = {
enable = true;
mode = "1920x1080";
};
};
};
desktop = {
config = {
"${name}".enable = false;
"HDMI-1" = {
enable = true;
mode = "2560x1440";
primary = true;
rate = "59.95";
};
};
fingerprint = {
"${name}" = fingerprint;
"HDMI-1" = "00ffffffffffff004c2d1710424e58432b1f0103803f24782ac8b5ad50449e250f5054bfef80714f810081c081809500a9c0b300010108e80030f2705a80b0588a0078682100001e000000fd00324b1e873c000a202020202020000000fc004c5532385235350a2020202020000000ff0048345a524130303132380a20200183020335f04961120313041f10605f2309070783010000e305c0006b030c002000b83c2000200167d85dc401788003e20f81e3060501023a801871382d40582c450078682100001e023a80d072382d40102c458078682100001e04740030f2705a80b0588a0078682100001e565e00a0a0a029503020350078682100001a000049";
};
};
};
};
}

View file

@ -0,0 +1,6 @@
{
imports = [
./docker.nix
./kanata.nix
];
}

View file

@ -0,0 +1,9 @@
{
imports = [
../.
./fonts.nix
./gitea.nix
./jellyfin.nix
./immich.nix
];
}

View file

@ -0,0 +1,36 @@
{ pkgs, ... }:
let
theme = import ../../../lib/theme { inherit pkgs; };
in
{
environment.systemPackages = with pkgs; [
terminus_font
terminus_font_ttf
];
fonts = {
fontconfig = {
enable = true;
defaultFonts = {
monospace = [ theme.fonts.monospace.name ];
};
};
packages =
with pkgs;
[
(nerdfonts.override {
fonts = [
"AnonymousPro"
"FiraCode"
"GeistMono"
"IntelOneMono"
"Iosevka"
"JetBrainsMono"
];
})
]
++ [ theme.fonts.monospace.package ];
};
}

View file

@ -0,0 +1,17 @@
{ pkgs, ... }:
{
services.gitea = {
enable = true;
settings = {
server = {
HTTP_PORT = 2222;
};
service = {
DISABLE_REGISTRATION = true;
};
};
};
}

View file

@ -0,0 +1,7 @@
{ pkgs, ... }:
{
services.immich.enable = true;
environment.systemPackages = [ pkgs.immich-cli ];
}

View file

@ -0,0 +1,6 @@
{
services.jellyfin = {
enable = true;
openFirewall = true;
};
}

View file

@ -0,0 +1,10 @@
{
virtualisation.docker = {
enable = true;
autoPrune = {
enable = true;
dates = "weekly";
};
};
}

142
nix/modules/nixos/i3.nix Normal file
View file

@ -0,0 +1,142 @@
{
inputs,
pkgs,
self,
username,
...
}:
let
theme = import "${self}/nix/lib/theme" { inherit pkgs; };
modifier = "Mod4";
in
{
services = {
displayManager.defaultSession = "none+i3";
xserver = {
displayManager.lightdm.enable = true;
windowManager.i3 = {
enable = true;
extraPackages = with pkgs; [
i3status
i3lock
i3blocks
];
};
};
};
environment.systemPackages = [ pkgs.nitrogen ];
home-manager.users.${username} = {
xsession.windowManager.i3 = {
enable = true;
config = {
assigns = {
"7" = [ { class = "vlc"; } ];
"8" = [ { class = "0ad"; } ];
"9" = [
{ class = "Slack"; }
{ class = "discord"; }
];
};
defaultWorkspace = "workspace number 1";
focus.followMouse = false;
modifier = modifier;
keybindings = inputs.nixpkgs.lib.mkOptionDefault {
"${modifier}+d" = "exec ${pkgs.rofi}/bin/rofi -show drun";
"${modifier}+Shift+b" = "exec ${pkgs.firefox}/bin/firefox";
"${modifier}+Shift+f" = "exec ${pkgs.xfce.thunar}/bin/thunar";
# Change focus.
"${modifier}+h" = "focus left";
"${modifier}+j" = "focus down";
"${modifier}+k" = "focus up";
"${modifier}+l" = "focus right";
# Move focused window.
"${modifier}+Shift+h" = "move left";
"${modifier}+Shift+j" = "move down";
"${modifier}+Shift+k" = "move up";
"${modifier}+Shift+l" = "move right";
"${modifier}+Shift+s" = "exec ${pkgs.flameshot}/bin/flameshot gui";
"${modifier}+Shift+p" = "exec ${pkgs.autorandr}/bin/autorandr --change";
"${modifier}+Shift+y" = "exec ${pkgs.copyq}/bin/copyq toggle";
"XF86AudioRaiseVolume" = "exec pamixer -ui 2 && pamixer --get-volume";
"XF86AudioLowerVolume" = "exec pamixer -ud 2 && pamixer --get-volume";
"XF86AudioMute" = ''exec pamixer --toggle-mute && ( [ "$(pamixer --get-mute)" = "true" ] && echo 0'';
"XF86MonBrightnessDown" = "exec brightnessctl set 5%- | sed -En 's/.*(([0-9]+)%).*/1/p'";
"XF86MonBrightnessUp" = "exec brightnessctl set +5% | sed -En 's/.*(([0-9]+)%).*/1/p'";
};
terminal = "alacritty";
window = {
border = 0;
hideEdgeBorders = "none";
};
};
extraConfig = ''
set $laptop eDP-1
bindswitch --reload --locked lid:on output $laptop disable
bindswitch --reload --locked lid:off output $laptop enable
exec_always --no-startup-id ${pkgs.nitrogen}/bin/nitrogen --restore &
exec_always --no-startup-id caffeine
default_border none
default_floating_border none
smart_borders on
smart_gaps on
for_window [class="zoom"] floating enable
# xprop | grep -i class
'';
config = {
bars = [
{
position = "bottom";
statusCommand = "${pkgs.i3status}/bin/i3status";
trayOutput = "none";
}
];
fonts.names = [ "${theme.fonts.monospace.name}" ];
gaps = {
smartBorders = "on";
smartGaps = true;
};
};
};
programs.i3status = {
enable = true;
general.colors = false;
modules = {
"battery all".settings.last_full_capacity = true;
"tztime local".settings.format = "%d-%m-%Y %H:%M:%S";
cpu_temperature.enable = false;
ipv6.enable = false;
load.enable = false;
};
};
};
}

View file

@ -0,0 +1,42 @@
{
services.kanata = {
enable = true;
keyboards = {
internalKeyboard = {
devices = [
"/dev/input/event18" # lemp11
];
extraDefCfg = "process-unmapped-keys yes";
config = ''
(defsrc
caps a s d f j k l ;
)
(defvar
tap-time 150
hold-time 200
)
(defalias
escctrl (tap-hold 100 100 esc lctl)
a (tap-hold $tap-time $hold-time a lmet)
s (tap-hold $tap-time $hold-time s lalt)
d (tap-hold $tap-time $hold-time d lsft)
f (tap-hold $tap-time $hold-time f lctl)
j (tap-hold $tap-time $hold-time j rctl)
k (tap-hold $tap-time $hold-time k rsft)
l (tap-hold $tap-time $hold-time l ralt)
; (tap-hold $tap-time $hold-time ; rmet)
)
(deflayer base
@escctrl @a @s @d @f @j @k @l @;
)
'';
};
};
};
}

27
nix/overlays/default.nix Normal file
View file

@ -0,0 +1,27 @@
{ inputs, ... }:
{
additions =
final: prev:
import ../pkgs {
inherit prev;
pkgs = final;
};
modifications = final: prev: { };
stable-packages = final: _prev: {
nixpkgs-2405 = import inputs.nixpkgs-2405 {
config.allowUnfree = true;
system = final.system;
};
};
unstable-packages = final: _prev: {
unstable = import inputs.nixpkgs-unstable {
config.allowUnfree = true;
system = final.system;
};
};
}

19
nix/pkgs/default.nix Normal file
View file

@ -0,0 +1,19 @@
{ pkgs, prev, ... }:
let
inherit (pkgs) callPackage;
in
{
vimPlugins = prev.vimPlugins // {
conf-vim = callPackage ./vim-plugins/conf-vim.nix { };
edit-alternate-vim = callPackage ./vim-plugins/edit-alternate-vim.nix { };
nvim-tmux-navigation = callPackage ./vim-plugins/nvim-tmux-navigation.nix { };
standard-vim = callPackage ./vim-plugins/standard-vim.nix { };
vim-autoread = callPackage ./vim-plugins/vim-autoread.nix { };
vim-caser = callPackage ./vim-plugins/vim-caser.nix { };
vim-heritage = callPackage ./vim-plugins/vim-heritage.nix { };
vim-textobj-indent = callPackage ./vim-plugins/vim-textobj-indent.nix { };
vim-textobj-xmlattr = callPackage ./vim-plugins/vim-textobj-xmlattr.nix { };
vim-zoom = callPackage ./vim-plugins/vim-zoom.nix { };
};
}

View file

@ -0,0 +1,11 @@
{ pkgs, ... }:
pkgs.vimUtils.buildVimPlugin {
name = "conf-vim";
src = pkgs.fetchFromGitHub {
owner = "tjdevries";
repo = "conf.vim";
rev = "master";
sha256 = "AjiTJsoim0BAnyfqk1IQzNsa6jhFM2+A66E7q9sJqz0=";
};
}

View file

@ -0,0 +1,11 @@
{ pkgs, ... }:
pkgs.vimUtils.buildVimPlugin {
name = "edit-alternate-vim";
src = pkgs.fetchFromGitHub {
owner = "tjdevries";
repo = "edit_alternate.vim";
rev = "master";
sha256 = "mEKnqYAhgrdxPRoKf4S4yYecdFIHGg8bDxpqPuC1+S4=";
};
}

View file

@ -0,0 +1,11 @@
{ pkgs, ... }:
pkgs.vimUtils.buildVimPlugin {
name = "nvim-tmux-navigation";
src = pkgs.fetchFromGitHub {
owner = "alexghergh";
repo = "nvim-tmux-navigation";
rev = "4898c98702954439233fdaf764c39636681e2861";
sha256 = "sha256-CxAgQSbOrg/SsQXupwCv8cyZXIB7tkWO+Y6FDtoR8xk=";
};
}

View file

@ -0,0 +1,11 @@
{ pkgs, ... }:
pkgs.vimUtils.buildVimPlugin {
name = "standard-vim";
src = pkgs.fetchFromGitHub {
owner = "tjdevries";
repo = "standard.vim";
rev = "master";
sha256 = "9VwkvV1Dv6cE4uDkPp36DozjWJOclDR883yDMYw000E=";
};
}

View file

@ -0,0 +1,11 @@
{ pkgs, ... }:
pkgs.vimUtils.buildVimPlugin {
name = "vim-autoread";
src = pkgs.fetchFromGitHub {
owner = "djoshea";
repo = "vim-autoread";
rev = "24061f84652d768bfb85d222c88580b3af138dab";
sha256 = "fSADjNt1V9jgAPjxggbh7Nogcxyisi18KaVve8j+c3w=";
};
}

View file

@ -0,0 +1,11 @@
{ pkgs, ... }:
pkgs.vimUtils.buildVimPlugin {
name = "vim-caser";
src = pkgs.fetchFromGitHub {
owner = "arthurxavierx";
repo = "vim-caser";
rev = "6bc9f41d170711c58e0157d882a5fe8c30f34bf6";
sha256 = "PXAY01O/cHvAdWx3V/pyWFeiV5qJGvLcAKhl5DQc0Ps=";
};
}

View file

@ -0,0 +1,11 @@
{ pkgs, ... }:
pkgs.vimUtils.buildVimPlugin {
name = "vim-heritage";
src = pkgs.fetchFromGitHub {
owner = "jessarcher";
repo = "vim-heritage";
rev = "cffa05c78c0991c998adc4504d761b3068547db6";
sha256 = "Lebe5V1XFxn4kSZ+ImZ69Vst9Nbc0N7eA9IzOCijFS0=";
};
}

View file

@ -0,0 +1,11 @@
{ pkgs, ... }:
pkgs.vimUtils.buildVimPlugin {
name = "vim-textobj-indent";
src = pkgs.fetchFromGitHub {
owner = "kana";
repo = "vim-textobj-indent";
rev = "deb76867c302f933c8f21753806cbf2d8461b548";
sha256 = "oFzUPG+IOkbKZ2gU/kduQ3G/LsLDlEjFhRP0BHBE+1Q=";
};
}

View file

@ -0,0 +1,11 @@
{ pkgs, ... }:
pkgs.vimUtils.buildVimPlugin {
name = "vim-textobj-xmlattr";
src = pkgs.fetchFromGitHub {
owner = "whatyouhide";
repo = "vim-textobj-xmlattr";
rev = "694a297f1d75fd527e87da9769f3c6519a87ebb1";
sha256 = "+91FVP95oh00flINdltqx6qJuijYo56tHIh3J098G2Q=";
};
}

View file

@ -0,0 +1,11 @@
{ pkgs, ... }:
pkgs.vimUtils.buildVimPlugin {
name = "vim-zoom";
src = pkgs.fetchFromGitHub {
owner = "dhruvasagar";
repo = "vim-zoom";
rev = "01c737005312c09e0449d6518decf8cedfee32c7";
sha256 = "/ADzScsG0u6RJbEtfO23Gup2NYdhPkExqqOPVcQa7aQ=";
};
}