diff --git a/os/linux/nix/daniel.nix b/os/linux/nix/daniel.nix index 1914e86..9dc9973 100644 --- a/os/linux/nix/daniel.nix +++ b/os/linux/nix/daniel.nix @@ -267,152 +267,159 @@ has_command = "command --quiet --search $argv[1]"; }; interactiveShellInit = '' - # prompt - function get_hostname - if test (uname) = Linux || test (uname) = Darwin - has_command hostname && hostname | cut -d. -f1 || cat /etc/hostname - else - # assume bsd - hostname | head -n 1 | cut -d. -f1 - end - end - - function fish_greeting - _prompt_prefix - printf "%s\n" (date) - end - - function preprocess_pwd - test (pwd) = / && echo "/" && return 1 - test (pwd) = $NICE_HOME && echo "~" && return 0 - pwd \ - | cut -c2- \ - | gawk '{n=split($0,p,"/");for(i=1;i<=n;i++){if(i==n){printf "/%s",p[i]}else{printf "/%.3s",p[i]}}}' - end - - function _maybe_sudo_prefix - if set -q SUDO_USER - set_color -b yellow black - printf " SUDO " - set_color -b normal normal - printf " " - end - end - - function _maybe_aws_profile - if set -q AWS_PROFILE && test $AWS_PROFILE = prd - printf " " - set_color -b yellow black - printf " AWS_PROFILE=prd " - set_color -b normal normal - end - end - - function _user_and_host - if test $argv[1] -eq 0 - set_color -b normal blue - else - set_color -b normal red - end - printf "%s@%s" $USER (get_hostname) - end - - function _cur_work_dir - set_color -b normal magenta - printf " %s" (preprocess_pwd) - end - - function _last_cmd_duration - set_color -b normal green - set -q CMD_DURATION && printf " %dms" $CMD_DURATION - end - - function _maybe_jobs_summary - if jobs -q - set_color -b normal cyan - printf " &%d" (jobs -p | wc -l) - end - end - - function _user_prompt - printf "\n" - set_color brblack - if test (id -u) -eq 0 - printf '# ' - else - printf '$ ' - end - set_color -b normal normal - end - - function _maybe_git_summary - set_color -b normal yellow - set cur_sha (git rev-parse --short HEAD 2>/dev/null) - if test $status = 0 - set num_changes (git status --porcelain | wc -l | string trim) - if test $num_changes = 0 - set num_changes "✔" + # prompt + function get_hostname + if test (uname) = Linux || test (uname) = Darwin + has_command hostname && hostname | cut -d. -f1 || cat /etc/hostname else - set num_changes "+$num_changes" + # assume bsd + hostname | head -n 1 | cut -d. -f1 end - printf " %s %s %s" (git branch --show-current) $cur_sha $num_changes end - end - function _prompt_marker - printf "%b133;A%b" "\x1b\x5d" "\x1b\x5c" - end + function fish_greeting + _prompt_prefix + printf "%s\n" (date) + end - function _prompt_continuation_marker - printf "%b133;A;k=s%b" "\x1b\x5d" "\x1b\x5c" - end + function preprocess_pwd + test (pwd) = / && echo "/" && return 1 + test (pwd) = $NICE_HOME && echo "~" && return 0 + pwd \ + | cut -c2- \ + | gawk '{n=split($0,p,"/");for(i=1;i<=n;i++){if(i==n){printf "/%s",p[i]}else{printf "/%.3s",p[i]}}}' + end - function cmd_marker --on-variable _ - printf "%b133;C%b" "\x1b\x5d" "\x1b\x5c" - end + function _maybe_sudo_prefix + if set -q SUDO_USER + set_color -b yellow black + printf " SUDO " + set_color -b normal normal + printf " " + end + end - function _prompt_prefix - set_color -b normal brblack - printf "# " - end + function _maybe_aws_profile + if set -q AWS_PROFILE && test $AWS_PROFILE = prd + printf " " + set_color -b yellow black + printf " AWS_PROFILE=prd " + set_color -b normal normal + end + end - function fish_prompt - set last_cmd_status $status - _prompt_marker - _prompt_prefix - _maybe_sudo_prefix - _user_and_host $last_cmd_status - _cur_work_dir - _maybe_git_summary - _maybe_aws_profile - _last_cmd_duration - _maybe_jobs_summary - _user_prompt - end + function _user_and_host + if test $argv[1] -eq 0 + set_color -b normal blue + else + set_color -b normal red + end + printf "%s@%s" $USER (get_hostname) + end - function fish_mode_prompt; end - function fish_right_prompt; end + function _cur_work_dir + set_color -b normal magenta + printf " %s" (preprocess_pwd) + end - # key bindings - set normal_mode "if commandline -P; commandline -f cancel; else; set fish_bind_mode default; commandline -f backward-char force-repaint; end" + function _last_cmd_duration + set_color -b normal green + set -q CMD_DURATION && printf " %dms" $CMD_DURATION + end - bind -M insert \cg skim-cd-widget - bind -M insert jk $normal_mode - bind -M insert jK $normal_mode - bind -M insert Jk $normal_mode - bind -M insert JK $normal_mode - bind -M insert jj $normal_mode - bind -M insert jJ $normal_mode - bind -M insert Jj $normal_mode - bind -M insert JJ $normal_mode + function _maybe_jobs_summary + if jobs -q + set_color -b normal cyan + printf " &%d" (jobs -p | wc -l) + end + end - bind -M insert \cp up-or-search - bind -M insert \cn down-or-search - bind -M insert \ce end-of-line - bind -M insert \ca beginning-of-line + function _user_prompt + printf "\n" + set_color brblack + if test (id -u) -eq 0 + printf '# ' + else + printf '$ ' + end + set_color -b normal normal + end - bind -M insert \cv edit_command_buffer - bind -M default \cv edit_command_buffer + function _maybe_git_summary + set_color -b normal yellow + set cur_sha (git rev-parse --short HEAD 2>/dev/null) + if test $status = 0 + set num_changes (git status --porcelain | wc -l | string trim) + if test $num_changes = 0 + set num_changes "✔" + else + set num_changes "+$num_changes" + end + printf " %s %s %s" (git branch --show-current) $cur_sha $num_changes + end + end + + function _prompt_marker + printf "%b133;A%b" "\x1b\x5d" "\x1b\x5c" + end + + function _prompt_continuation_marker + printf "%b133;A;k=s%b" "\x1b\x5d" "\x1b\x5c" + end + + function cmd_marker --on-variable _ + printf "%b133;C%b" "\x1b\x5d" "\x1b\x5c" + end + + function _prompt_prefix + set_color -b normal brblack + printf "# " + end + + function fish_prompt + set last_cmd_status $status + _prompt_marker + _prompt_prefix + _maybe_sudo_prefix + _user_and_host $last_cmd_status + _cur_work_dir + _maybe_git_summary + _maybe_aws_profile + _last_cmd_duration + _maybe_jobs_summary + _user_prompt + end + + function fish_mode_prompt; end + function fish_right_prompt; end + + # key bindings + fish_vi_key_bindings + + set --universal fish_cursor_default block + set --universal fish_cursor_insert line + set --universal fish_cursor_block block + fish_vi_cursor + set --universal fish_vi_force_cursor 1 + + bind --mode insert --sets-mode default jk repaint + bind --mode insert --sets-mode default jK repaint + bind --mode insert --sets-mode default Jk repaint + bind --mode insert --sets-mode default JK repaint + bind --mode insert --sets-mode default jj repaint + bind --mode insert --sets-mode default jJ repaint + bind --mode insert --sets-mode default Jj repaint + bind --mode insert --sets-mode default JJ repaint + + bind -M insert \cg skim-cd-widget + + bind -M insert \cp up-or-search + bind -M insert \cn down-or-search + bind -M insert \ce end-of-line + bind -M insert \ca beginning-of-line + + bind -M insert \cv edit_command_buffer + bind -M default \cv edit_command_buffer ''; loginShellInit = '' ''; diff --git a/os/linux/nix/machines/beefcake.nix b/os/linux/nix/machines/beefcake.nix index f9e329a..c9b74b7 100644 --- a/os/linux/nix/machines/beefcake.nix +++ b/os/linux/nix/machines/beefcake.nix @@ -564,6 +564,8 @@ }; }; + # TODO: https://nixos.wiki/wiki/Binary_Cache + networking.firewall.allowedTCPPorts = [ 80 # http (caddy) 443 # https (caddy) diff --git a/os/linux/nix/machines/musicbox.nix b/os/linux/nix/machines/musicbox.nix new file mode 100644 index 0000000..01877ef --- /dev/null +++ b/os/linux/nix/machines/musicbox.nix @@ -0,0 +1,244 @@ +# 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`). + +{ pkgs, inputs, ... }: + +let + # this is unused because it's referenced by my sway config + dbus-sway-environment = pkgs.writeTextFile { + name = "dbus-sway-environment"; + destination = "/bin/dbus-sway-environment"; + executable = true; + + text = '' + dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway + systemctl --user stop wireplumber xdg-desktop-portal xdg-desktop-portal-wlr + systemctl --user start wireplumber xdg-desktop-portal xdg-desktop-portal-wlr + ''; + }; + + # this is unused because it's referenced by my sway config + configure-gtk = pkgs.writeTextFile { + name = "configure-gtk"; + destination = "/bin/configure-gtk"; + executable = true; + text = + let + schema = pkgs.gsettings-desktop-schemas; + datadir = "${schema}/share/gsettings-schemas/${schema.name}"; + in + '' + export XDG_DATA_DIRS="${datadir}:$XDG_DATA_DIRS + gnome_schema = org.gnome.desktop.interface + gsettings set $gnome_schema gtk-theme 'Catppuccin-Mocha' + ''; + }; +in +{ + # TODO: fonts? right now, I'm just installing to ~/.local/share/fonts + + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + # TODO: bootloader? grub since seemingly no uefi? + + nixpkgs.config = { + allowUnfree = true; + packageOverrides = pkgs: { + vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; }; + }; + }; + + hardware.bluetooth.enable = true; + hardware.opengl = { + enable = true; + driSupport32Bit = true; + driSupport = true; + + extraPackages = with pkgs; [ + intel-media-driver # LIBVA_DRIVER_NAME=iHD + vaapiIntel # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium) + vaapiVdpau + libvdpau-va-gl + ]; + }; + + xdg.portal = { + enable = true; + wlr.enable = true; + + extraPortals = with pkgs; [ + xdg-desktop-portal-wlr + xdg-desktop-portal-gtk + ]; + }; + + programs.sway = { + enable = true; + wrapperFeatures.gtk = true; + }; + + networking.hostName = "musicbox"; + networking.networkmanager.enable = true; + + security.polkit.enable = true; + security.rtkit.enable = true; + + programs.fish.enable = true; + users.defaultUserShell = pkgs.fish; + + services.pipewire = { + enable = true; + wireplumber.enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + jack.enable = true; + }; + + time.timeZone = "America/Chicago"; + + i18n.defaultLocale = "en_US.UTF-8"; + console = { + font = "Lat2-Terminus16"; + useXkbConfig = true; + }; + + services.xserver.layout = "us"; + services.xserver.xkbOptions = "ctrl:nocaps"; + + hardware.pulseaudio.support32Bit = true; + + users.users.daniel = { + isNormalUser = true; + home = "/home/daniel/.home"; + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAPLXOjupz3ScYjgrF+ehrbp9OvGAWQLI6fplX6w9Ijb daniel@lyte.dev" + ]; + extraGroups = [ "wheel" "video" ]; + packages = [ ]; + }; + + services.dbus.enable = true; + + environment.systemPackages = with pkgs; [ + age + bat + bind + bottom + brightnessctl + clang + curl + delta + dog + dtach + dua + exa + fd + feh + file + fwupd + gcc + gimp + git + git-lfs + grim + inputs.helix.packages."x86_64-linux".helix + hexyl + htop + inkscape + inotify-tools + iputils + killall + kitty + krita + libinput + libinput-gestures + libnotify + lutris + gnumake + mako + mosh + nmap + nnn + nil + nixpkgs-fmt + noto-fonts + openssl + pamixer + pavucontrol + pciutils + pgcli + playerctl + podman-compose + pulseaudio + pulsemixer + rclone + restic + ripgrep + rsync + sd + slurp + sops + steam + swaybg + swayidle + swaylock + tmux + traceroute + unzip + vlc + vulkan-tools + watchexec + waybar + wget + wireplumber + wine + wl-clipboard + wofi + xh + zathura + zellij + zstd + ]; + + services.pcscd.enable = true; + services.flatpak.enable = true; + services.gnome.gnome-keyring.enable = true; + programs.gnupg.agent = { + enable = true; + pinentryFlavor = "gnome3"; + enableSSHSupport = true; + }; + + programs.thunar.enable = true; + + services.tailscale = { + enable = true; + useRoutingFeatures = "client"; + }; + + environment.variables = { + EDITOR = "hx"; + }; + + services.openssh = { + enable = true; + settings = { + PasswordAuthentication = false; + }; + listenAddresses = [ + { addr = "0.0.0.0"; port = 22; } + ]; + }; + + networking.firewall = { + enable = true; + allowPing = true; + allowedTCPPorts = [ ]; + allowedUDPPorts = [ ]; + }; + + system.stateVersion = "23.05"; +} +