From e6c98453e744af831961662e094726b20eece702 Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Fri, 5 Feb 2021 12:38:31 +0100 Subject: machines/sternenseemann/wolfgang: init --- machines/default.nix | 3 + machines/sternenseemann/base-laptop.nix | 50 +++++ machines/sternenseemann/base.nix | 37 ++++ machines/sternenseemann/desktop-sway.nix | 327 +++++++++++++++++++++++++++++++ machines/sternenseemann/fonts.nix | 41 ++++ machines/sternenseemann/wolfgang.nix | 138 +++++++++++++ 6 files changed, 596 insertions(+) create mode 100644 machines/sternenseemann/base-laptop.nix create mode 100644 machines/sternenseemann/base.nix create mode 100644 machines/sternenseemann/desktop-sway.nix create mode 100644 machines/sternenseemann/fonts.nix create mode 100644 machines/sternenseemann/wolfgang.nix diff --git a/machines/default.nix b/machines/default.nix index 75b5d5fd..2a7394e9 100644 --- a/machines/default.nix +++ b/machines/default.nix @@ -24,6 +24,9 @@ with import ../lib; legosi = callMachine ./profpatsch/legosi.nix {}; # mikiya = callMachine ./profpatsch/mikiya.nix {}; }; + sternenseemann = { + wolfgang = callMachine ./sternenseemann/wolfgang.nix {}; + }; misc = { mailserver = callMachine ./misc/mailserver.nix {}; }; diff --git a/machines/sternenseemann/base-laptop.nix b/machines/sternenseemann/base-laptop.nix new file mode 100644 index 00000000..8ef216d5 --- /dev/null +++ b/machines/sternenseemann/base-laptop.nix @@ -0,0 +1,50 @@ +# TODO split out common stuff for personal computers +# when I have a non-laptop one +{ config, lib, pkgs, ... }: + +{ + imports = [ + ./base.nix + ./fonts.nix + ]; + + config = { + console.keyMap = "neo"; + + hardware.enableRedistributableFirmware = lib.mkDefault true; + + hardware.bluetooth.enable = lib.mkDefault true; + services.blueman.enable = true; + + hardware.pulseaudio = { + daemon.config.flat-volumes = "yes"; + enable = true; + }; + + hardware.cpu.intel.updateMicrocode = true; + + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + + services.tlp.enable = lib.mkDefault true; + + hardware.trackpoint = lib.mkDefault { + enable = true; + emulateWheel = true; + }; + + environment.systemPackages = with pkgs; [ + tree + lowdown + lynx sacc + acpi + zip unzip + stow + neovim silver-searcher + mosh + nmap + ffmpeg graphicsmagick + kitty pavucontrol + xsel + ] ++ pkgs.vuizvui.sternenseemann.scripts.default; + }; +} diff --git a/machines/sternenseemann/base.nix b/machines/sternenseemann/base.nix new file mode 100644 index 00000000..d39a982d --- /dev/null +++ b/machines/sternenseemann/base.nix @@ -0,0 +1,37 @@ +{ config, lib, pkgs, ... }: + +{ + config = { + boot.cleanTmpDir = true; + + nix.useSandbox = true; + nix.extraOptions = "gc-keep-derivations = false"; + nixpkgs.config.allowUnfree = true; + + services.journald.extraConfig = lib.mkDefault "SystemMaxUse=500M"; + + console.keyMap = lib.mkDefault "de-latin1"; + + time.timeZone = lib.mkDefault "Europe/Berlin"; + + i18n = { + defaultLocale = "en_US.UTF-8"; + }; + + programs.fish.enable = true; + programs.fish.vendor.completions.enable = true; + + documentation = { + enable = true; + dev.enable = true; + man.enable = true; + }; + + environment.systemPackages = with pkgs; [ + curl wget + mandoc man-pages + git + file htop psmisc tmux + ]; + }; +} diff --git a/machines/sternenseemann/desktop-sway.nix b/machines/sternenseemann/desktop-sway.nix new file mode 100644 index 00000000..e118e33e --- /dev/null +++ b/machines/sternenseemann/desktop-sway.nix @@ -0,0 +1,327 @@ +# TODO(sterni) icons, GTK +# TODO(sterni) X11 cursor +{ config, pkgs, lib, ... }: + +let + inherit (pkgs.vuizvui.profpatsch) + getBins + ; + + inherit (pkgs.writers) + writeDashBin + ; + + bins = (getBins pkgs.systemd [ "systemctl" ]) + // (getBins pkgs.xurls [ "xurls" ]) + // (getBins pkgs.bemenu [ "bemenu" ]) + // (getBins pkgs.dbus [ "dbus-run-session" ]) + // (getBins pkgs.sway [ "sway" "swaymsg" ]) + ; + + # manual start script + startSway = writeDashBin "start-sway" '' + ${bins.systemctl} --user import-environment + ${bins.systemctl} --user start sway.service + ''; + + # sway scripts for systemd + swayService = writeDashBin "sway-service" '' + ${bins.dbus-run-session} -- "${pkgs.sway}/bin/sway" + ''; + + exitSway = writeDashBin "exit-sway" '' + ${bins.swaymsg} exit + ${bins.systemctl} --user unset-environment WAYLAND_DISPLAY + ${bins.systemctl} --user unset-environment DISPLAY + ''; + + # reduce repition in sway config by generating workspace switches + wsConfig = lib.concatMapStringsSep "\n" (n: '' + bindsym $mod+${toString n} workspace number ${toString n} + bindsym $mod+Shift+${toString n} move container to workspace number ${toString n} + '') [1 2 3 4 5 6 7 8 9]; + + # .Xresources file to fix DPI issues in Xwayland + xResources = pkgs.writeText "Xresources" '' + Xft.dpi: 96 + ''; +in + +{ + imports = [ + ./fonts.nix + ]; + + config = { + programs.sway = { + enable = true; + extraPackages = with pkgs; [ + vuizvui.sternenseemann.tep # emoji picker + bemenu # better dmenu + xwayland qt5.qtwayland + wl-clipboard # instead of xsel + grim slurp # screenshots + mako # notifications + ]; + wrapperFeatures = { + gtk = true; + base = true; + }; + }; + + environment.sessionVariables = { + # TODO get screen capture working in firefox + XDG_SESSION_TYPE = "wayland"; + XDG_CURRENT_DESKTOP = "sway"; + MOZ_ENABLE_WAYLAND = "1"; + # SDL + SDL_VIDEODRIVER = "wayland"; + # QT + QT_QPA_PLATFORM = "wayland"; + QT_WAYLAND_DISABLE_WINDOWDECORATION = "1"; + }; + + services.dbus.packages = [ pkgs.mako ]; + + services.pipewire.enable = true; + xdg.portal = { + enable = true; + extraPortals = with pkgs; [ + xdg-desktop-portal-wlr + xdg-desktop-portal-gtk + ]; + gtkUsePortal = true; + }; + + environment.etc = { + "sway/config".text = '' + # correct DPI after hotplugging + exec ${pkgs.xorg.xrdb}/bin/xrdb -load ${xResources} + + set $mod Mod4 + #set $term ${pkgs.kitty}/bin/kitty + set $term ${pkgs.foot}/bin/foot + set $menu ${pkgs.bemenu}/bin/bemenu-run -l 5 -i + set $makoctl ${pkgs.mako}/bin/makoctl + + # neo arrow keys + set $left i + set $right e + set $up l + set $down a + + bindsym $mod+Shift+c reload + + bindsym $mod+Return exec $term + bindsym $mod+d exec $menu + + bindsym $mod+c exec $makoctl dismiss -a + + bindsym $mod+g exec ${pkgs.vuizvui.sternenseemann.tep}/bin/tep copy -l 25 -p 'tep>' -i + + bindsym $mod+Shift+q kill + + bindsym $mod+h splith + bindsym $mod+v splitv + + bindsym $mod+s layout stacking + bindsym $mod+t layout tabbed + bindsym $mod+n layout toggle split + + bindsym $mod+f fullscreen + + bindsym $mod+Shift+space floating toggle + bindsym $mod+space focus mode_toggle + floating_modifier $mod normal + + bindsym $mod+$left focus left + bindsym $mod+$down focus down + bindsym $mod+$up focus up + bindsym $mod+$right focus right + + bindsym $mod+p focus parent + + bindsym $mod+Shift+$left move left + bindsym $mod+Shift+$down move down + bindsym $mod+Shift+$up move up + bindsym $mod+Shift+$right move right + + mode "resize" { + bindsym $left resize shrink width 10px + bindsym $down resize grow height 10px + bindsym $up resize shrink height 10px + bindsym $right resize grow width 10px + + bindsym Return mode "default" + bindsym Escape mode "default" + } + bindsym $mod+r mode "resize" + + # workspace shortcuts + ${wsConfig} + + set $pactl ${config.hardware.pulseaudio.package}/bin/pactl + bindsym XF86AudioRaiseVolume exec $pactl set-sink-volume @DEFAULT_SINK@ +5% + bindsym XF86AudioLowerVolume exec $pactl set-sink-volume @DEFAULT_SINK@ -5% + bindsym XF86AudioMute exec $pactl set-sink-mute @DEFAULT_SINK@ toggle + bindsym XF86AudioMicMute exec $pactl set-source-mute @DEFAULT_SOURCE@ toggle + + set $brightnessctl ${pkgs.brightnessctl}/bin/brightnessctl + bindsym XF86MonBrightnessDown exec $brightnessctl set 5%- + bindsym XF86MonBrightnessUp exec $brightnessctl set +5% + + bindsym $mod+0 exec ${pkgs.swaylock}/bin/swaylock -c FFC0CB -k -l + + font "DejaVu Sans Mono normal 10" + + gaps inner 10 + + output * bg #000000 solid_color + + # class border backgr. text indicator + client.focused #ffffff #ffffff #000000 #d0d0d0 + client.focused_inactive #000000 #000000 #ffffff #000000 + client.unfocused #000000 #000000 #ffffff #000000 + client.urgent #900000 #900000 #ffffff #900000 + + bar { + status_command ${pkgs.i3status}/bin/i3status + position top + colors { + font "DejaVu Sans Mono normal 10" + statusline #ffffff + background #000000 + focused_workspace #ffffff #ffffff #000000 + active_workspace #ffffff #ffffff #c4c4c4 + inactive_workspace #000000 #000000 #ffffff + urgent_workspace #900000 #900000 #ffffff + } + } + ''; + "xdg/i3status/config".text = '' + # TODO replace i3status? + general { + output_format = "i3bar" + colors = true + interval = 1 + } + + order += "volume master" + order += "battery all" + order += "tztime dotdate" + order += "tztime dottime" + order += "tztime offset" + + volume master { + format = "๐Ÿ”Š: %volume" + format_muted = "๐Ÿ”ˆ: %volume" + device = "pulse" + } + + battery all { + format = "%status: %percentage" + status_chr = "โšก" + status_bat = "๐Ÿ”‹" + status_unk = "โ“" + status_full = "๐Ÿ’ฏ" + low_threshold = 10 + } + + tztime dotdate { + timezone = "UTC" + format = "%Y-%m-%d" + } + + tztime dottime { + timezone = "UTC" + format = "%Hยท%M" + } + + tztime offset { + format = "%z" + } + ''; + }; + + vuizvui.programs.foot = { + enable = true; + settings = { + font = [ + "Bitstream Vera Sans Mono" + { + font = "Noto Color Emoji"; + options = { size = 8; }; + } + ]; + + key-bindings = { + scrollback-up-page = "Control+Shift+Page_Up"; + scrollback-down-page = "Control+Shift+Page_Down"; + search-start = "Control+Shift+F"; + font-increase = "Control+Shift+plus"; + font-decrease = "Control+Shift+minus"; + font-reset = "Control+Shift+0"; + pipe-visible = { + bind = "Control+Shift+e"; + cmd = ''sh -c "${lib.concatStringsSep " | " [ + bins.xurls + "tac" + "${bins.bemenu} -l 10" + "xargs -r $BROWSER" + ]}"''; + }; + }; + + mouse-bindings = { + primary-paste = "none"; + }; + + mouse = { + alternate-scroll-mode = "no"; + }; + + scrollback = { + lines = 10000; + indicator-position = "none"; + }; + }; + }; + + environment.variables = { + XKB_DEFAULT_LAYOUT = "de"; + XKB_DEFAULT_VARIANT = "neo"; + # TODO user env? + SWAYSOCK = "/run/user/${toString config.users.users.lukas.uid}/sway.sock"; + }; + + environment.systemPackages = with pkgs; [ + startSway + xdg_utils + networkmanagerapplet # for nm-connection-ediotr + imv zathura + foot + gnome3.nautilus + ]; + + # allow ydotool to use /dev/uinput + # services.udev.extraRules = '' + # KERNEL=="uinput", GROUP:="uinput", MODE:="0660" + # ''; + # users.groups.uinput = {}; + # users.users.lukas.extraGroups = [ "uinput" ]; + + # based on https://nixos.wiki/Sway + systemd.user = { + services.sway = { + bindsTo = [ "graphical-session.target" ]; + wants = [ "graphical-session-pre.target" ]; + after = [ "graphical-session-pre.target" ]; + serviceConfig = { + Type = "simple"; + ExecStart = "${swayService}/bin/sway-service"; + ExecStop = "${exitSway}/bin/exit-sway"; + }; + }; + }; + }; +} diff --git a/machines/sternenseemann/fonts.nix b/machines/sternenseemann/fonts.nix new file mode 100644 index 00000000..f74b6593 --- /dev/null +++ b/machines/sternenseemann/fonts.nix @@ -0,0 +1,41 @@ +{ config, pkgs, ... }: + +{ + config = { + fonts = { + fonts = with pkgs; [ + corefonts # microsoft fonts + dejavu_fonts + ttf_bitstream_vera # dejavu without b&w emojis + libertine + liberation_ttf # free replacements for times โ€ฆ + google-fonts # vollkorn, source * pro, inconsolata + freefont_ttf + noto-fonts # noto fonts: great for fallbacks + noto-fonts-extra + noto-fonts-cjk + noto-fonts-emoji # emoji primary + twemoji-color-font # emoji fallback + unifont # bitmap font, good fallback + unifont_upper # upper unicode ranges of unifont + spleen # bitmap monospace font + ]; + + fontDir.enable = true; + enableGhostscriptFonts = true; + enableDefaultFonts = true; + + fontconfig = { + enable = true; + antialias = true; + hinting.enable = true; + defaultFonts = { + monospace = [ "Bitstream Vera Sans Mono" "Noto Mono" ]; + serif = [ "Vollkorn" "Noto Serif" ]; + sansSerif = [ "Open Sans" "Noto Sans" ]; + emoji = [ "Noto Color Emoji" "Twitter Color Emoji" "Unifont" "Unifont Upper" ]; + }; + }; + }; + }; +} diff --git a/machines/sternenseemann/wolfgang.nix b/machines/sternenseemann/wolfgang.nix new file mode 100644 index 00000000..1e583fa4 --- /dev/null +++ b/machines/sternenseemann/wolfgang.nix @@ -0,0 +1,138 @@ +{ config, pkgs, lib, ... }: + +let + i686Games = false; + avahi = false; +in { + imports = [ + ./base-laptop.nix + ./desktop-sway.nix + ]; + + boot.initrd.availableKernelModules = [ + "xhci_pci" + "nvme" + "usb_storage" + "sd_mod" + "rtsx_pci_sdmmc" + ]; + boot.kernelModules = [ + "kvm-intel" + "snd-seq" + "snd-rawmidi" ]; + + hardware.opengl.driSupport32Bit = i686Games; + hardware.pulseaudio = { + enable = true; + support32Bit = i686Games; + zeroconf.discovery.enable = avahi; + }; + + # 100% CPU in university + services.avahi.enable = avahi; + + fileSystems."/" = { + device = "/dev/mapper/main"; + fsType = "btrfs"; + }; + + fileSystems."/boot" = { + device = "/dev/nvme0n1p1"; + fsType = "vfat"; + }; + + swapDevices = [ + { device = "/dev/disk/by-uuid/198329ed-5038-4ad8-b8a6-e52921f2673d"; } + ]; + + nix.maxJobs = 4; + nix.useSandbox = true; + nix.trustedUsers = [ "lukas" ]; + + boot.initrd.luks.devices = { + "main".device = "/dev/nvme0n1p2"; + "swap".device = "/dev/nvme0n1p3"; + }; + + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + networking = { + hostName = "wolfgang"; + firewall = { + enable = true; + allowedTCPPortRanges = [ + { from = 9990; to = 9999; } + ]; + }; + # nat networking for virtual machines / containers + # TODO: remove when I don't have to deal with such + # stuff @ work anymore + nat = { + enable = true; + internalInterfaces = [ "ve-+" ]; + externalInterface = "wlp3s0"; + }; + networkmanager = { + enable = true; + unmanaged = [ "interface-name:ve-*" ]; + }; + }; + + + virtualisation.docker.enable = true; + + time.timeZone = "Europe/Berlin"; + + environment.systemPackages = with pkgs; [ + vuizvui.sternenseemann.pass + exfat borgbackup + gnupg pinentry-gtk2 signing-party gpgme + thunderbird + jackline + vuizvui.sternenseemann.texlive jabref + youtube-dl mpv spotify + newsboat + ghc cabal-install cabal2nix + sbcl rlwrap + valgrind gdb + scribus gimp inkscape libreoffice + audacity + signal-desktop tdesktop discord + multimc + vuizvui.sternenseemann.t + hunspell + vuizvui.profpatsch.nman + firefox-wayland + # TODO(sterni) depot.users.sterni.clhs-lookup + ] ++ (with hunspellDicts; [ de-de en-gb-large en-us ]); + + services.tor = { + enable = true; + + torsocks = { + enable = true; + }; + + client = { + enable = true; + }; + }; + + services.printing.enable = true; + + services.xserver = { + videoDrivers = [ "intel" ]; + }; + + users.users.lukas = { + isNormalUser = true; + uid = 1000; + home = "/home/lukas"; + group = "users"; + extraGroups = [ "wheel" "networkmanager" "audio" "docker" ]; + shell = "${pkgs.fish}/bin/fish"; + }; + + system.stateVersion = "unstable"; +} -- cgit 1.4.1