diff --git a/.gitignore b/.gitignore index 72a01664..773271ce 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ up hosts/up-* .direnv doc/index.html +tags diff --git a/flake.nix b/flake.nix index 27024b0a..036e3db9 100644 --- a/flake.nix +++ b/flake.nix @@ -21,9 +21,17 @@ pkgs.url = "path:./pkgs"; pkgs.inputs.nixpkgs.follows = "nixos"; + + # PubSolarOS additions + + nix-dram.url = "github:dramforever/nix-dram"; + + # This is a fix so that the neovim-flake dependency of neovim-nightly doesn't shit itself + nixpkgs.url = "nixpkgs"; + neovim-nightly.url = "github:nix-community/neovim-nightly-overlay"; }; - outputs = inputs@{ self, pkgs, digga, nixos, ci-agent, home, nixos-hardware, nur, ... }: + outputs = inputs@{ self, pkgs, digga, nixos, ci-agent, home, nixos-hardware, nix-dram, nur, neovim-nightly, ... }: digga.lib.mkFlake { inherit self inputs; @@ -36,6 +44,8 @@ ./pkgs/default.nix pkgs.overlay # for `srcs` nur.overlay + nix-dram.overlay + neovim-nightly.overlay ]; }; latest = { }; @@ -72,6 +82,8 @@ profiles = [ ./profiles ./users ]; suites = { profiles, users, ... }: with profiles; rec { base = [ core users.nixos users.root ]; + pubsolaros = [ core base-user users.root ]; + anonymous = [ pubsolaros users.nixos ]; }; }; diff --git a/modules/audio/.config/vimpc/vimpcrc b/modules/audio/.config/vimpc/vimpcrc new file mode 100644 index 00000000..c4b5fcc7 --- /dev/null +++ b/modules/audio/.config/vimpc/vimpcrc @@ -0,0 +1,53 @@ +echo Parsing config file + +" Set the default tab +set window playlist + +" Set the windows to show at startup +set windows playlist,library,browse,help + +" Stop playing music when we quit +"set stoponquit + +" A silly example of an alias +"alias smiths deleteall; findartist! The Smiths; play 1 + +" Example maps +" map the F key to change to the browse window, go to the first line and enter search mode +"map F :browsegg/ +" map @ to switch to add next, add a song, then change back +"map @ :set add nexta:set add end + +map i +map j +map k + +map h i + +map q ZQ +map Q ZQ + +map l :tabnext +map j :tabprevious + +" Turn consume on when we connect +"consume on + +" Ensure that the database is up to date each connect +update + +" A more complex example, When we start vimpc +" - clear the playlist +" - add all songs +" - shuffle +" - start playling +"deleteall +"addall +"shuffle +"play 1 + +" Color the statusline and tabs +" highlight status blackbg +" highlight tab blackbg + +echo Config File Complete diff --git a/modules/audio/default.nix b/modules/audio/default.nix new file mode 100644 index 00000000..ce8c2f34 --- /dev/null +++ b/modules/audio/default.nix @@ -0,0 +1,72 @@ +{ lib, config, pkgs, ... }: +with lib; +let + psCfg = config.pub-solar; + cfg = config.pub-solar.audio; + xdg = config.home-manager.users."${psCfg.user.name}".xdg; +in +{ + options.pub-solar.audio = { + enable = mkEnableOption "Life in highs and lows"; + }; + + config = mkIf cfg.enable { + home-manager = with pkgs; pkgs.lib.setAttrByPath [ "users" psCfg.user.name ] { + home.packages = [ + mu + pavucontrol + pa_applet + playerctl + # Needed for pactl cmd, until pw-cli is more mature (vol up/down hotkeys?) + pulseaudio + # pulseeffects for microphone noise filtering + pulseeffects-pw + vimpc + ]; + xdg.configFile."vimpc/vimpcrc".source = ./.config/vimpc/vimpcrc; + systemd.user.services.pulseeffects = import ./pulseeffects.service.nix pkgs; + }; + + # Enable sound using pipewire-pulse + services.pipewire = { + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + + config.pipewire-pulse = builtins.fromJSON (builtins.readFile ./pipewire-pulse.conf.json); + + # Bluetooth configuration for pipewire + media-session.config.bluez-monitor.rules = [ + { + # Matches all cards + matches = [{ "device.name" = "~bluez_card.*"; }]; + actions = { + "update-props" = { + "bluez5.reconnect-profiles" = [ "hfp_hf" "hsp_hs" "a2dp_sink" ]; + # mSBC is not expected to work on all headset + adapter combinations. + "bluez5.msbc-support" = true; + }; + }; + } + { + matches = [ + # Matches all sources + { "node.name" = "~bluez_input.*"; } + # Matches all outputs + { "node.name" = "~bluez_output.*"; } + ]; + actions = { + "node.pause-on-idle" = false; + }; + } + ]; + }; + + # Enable bluetooth + hardware.bluetooth.enable = true; + services.blueman.enable = true; + + # Enable audio server & client + services.mopidy = import ./mopidy.nix pkgs; + }; +} diff --git a/modules/audio/mopidy.nix b/modules/audio/mopidy.nix new file mode 100644 index 00000000..99552113 --- /dev/null +++ b/modules/audio/mopidy.nix @@ -0,0 +1,19 @@ +pkgs: { + enable = true; + extensionPackages = with pkgs; [ + mopidy-spotify + mopidy-mpd + mopidy-soundcloud + mopidy-youtube + mopidy-local + mopidy-jellyfin + ]; + + configuration = '' + [mpd] + hostname = :: + + [audio] + output = pulsesink server=127.0.0.1:4713 + ''; +} diff --git a/modules/audio/pipewire-pulse.conf.json b/modules/audio/pipewire-pulse.conf.json new file mode 100644 index 00000000..a37f6b75 --- /dev/null +++ b/modules/audio/pipewire-pulse.conf.json @@ -0,0 +1,42 @@ +{ + "context.properties": {}, + "context.spa-libs": { + "audio.convert.*": "audioconvert/libspa-audioconvert", + "support.*": "support/libspa-support" + }, + "context.modules": [ + { + "name": "libpipewire-module-rtkit", + "args": {}, + "flags": [ + "ifexists", + "nofail" + ] + }, + { + "name": "libpipewire-module-protocol-native" + }, + { + "name": "libpipewire-module-client-node" + }, + { + "name": "libpipewire-module-adapter" + }, + { + "name": "libpipewire-module-metadata" + }, + { + "name": "libpipewire-module-protocol-pulse", + "args": { + "server.address": [ + "unix:native", + "tcp:4713" + ], + "vm.overrides": { + "pulse.min.quantum": "1024/48000" + } + } + } + ], + "stream.properties": {} +} diff --git a/modules/audio/pulseeffects.service.nix b/modules/audio/pulseeffects.service.nix new file mode 100644 index 00000000..632fbb54 --- /dev/null +++ b/modules/audio/pulseeffects.service.nix @@ -0,0 +1,8 @@ +pkgs: +{ + Service = { + Type = "dbus"; + BusName = "com.github.wwmm.pulseeffects"; + ExecStart = "${pkgs.pulseeffects-pw}/bin/pulseeffects --gapplication-service"; + }; +} diff --git a/modules/compat/default.nix b/modules/compat/default.nix new file mode 100644 index 00000000..af39a951 --- /dev/null +++ b/modules/compat/default.nix @@ -0,0 +1,6 @@ +{ config, pkgs, lib, ... }: with lib; { + # Both things below are for + # https://github.com/NixOS/nixpkgs/issues/124215 + documentation.info.enable = lib.mkForce false; + nix.sandboxPaths = [ "/bin/sh=${pkgs.bash}/bin/sh" ]; +} diff --git a/modules/crypto/default.nix b/modules/crypto/default.nix new file mode 100644 index 00000000..5d14dcc2 --- /dev/null +++ b/modules/crypto/default.nix @@ -0,0 +1,42 @@ +{ lib, config, pkgs, ... }: +with lib; +let + psCfg = config.pub-solar; + cfg = config.pub-solar.crypto; +in +{ + options.pub-solar.crypto = { + enable = mkEnableOption "Life in private"; + }; + + config = mkIf cfg.enable { + services.udev.packages = [ pkgs.yubikey-personalization ]; + services.dbus.packages = [ pkgs.gcr ]; + services.pcscd.enable = true; + + services.gnome.gnome-keyring.enable = true; + security.pam.services.greetd.enableGnomeKeyring = true; + + home-manager = with pkgs; pkgs.lib.setAttrByPath [ "users" psCfg.user.name ] { + systemd.user.services.polkit-gnome-authentication-agent = import ./polkit-gnome-authentication-agent.service.nix pkgs; + + services.gpg-agent = { + enable = true; + pinentryFlavor = "gnome3"; + verbose = true; + }; + + programs.gpg = { + enable = true; + }; + + home.packages = [ + gnome3.seahorse + keepassxc + libsecret + qMasterPassword + restic + ]; + }; + }; +} diff --git a/modules/crypto/polkit-gnome-authentication-agent.service.nix b/modules/crypto/polkit-gnome-authentication-agent.service.nix new file mode 100644 index 00000000..1194c860 --- /dev/null +++ b/modules/crypto/polkit-gnome-authentication-agent.service.nix @@ -0,0 +1,16 @@ +pkgs: +{ + Unit = { + Description = "Legacy polkit authentication agent for GNOME"; + Documentation = [ "https://gitlab.freedesktop.org/polkit/polkit/" ]; + BindsTo = [ "sway-session.target" ]; + After = [ "sway-session.target" ]; + }; + Service = { + Type = "simple"; + ExecStart = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1"; + }; + Install = { + WantedBy = [ "sway-session.target" ]; + }; +} diff --git a/modules/devops/default.nix b/modules/devops/default.nix new file mode 100644 index 00000000..c862af61 --- /dev/null +++ b/modules/devops/default.nix @@ -0,0 +1,24 @@ +{ lib, config, pkgs, ... }: +with lib; +let + psCfg = config.pub-solar; + cfg = config.pub-solar.devops; +in +{ + options.pub-solar.devops = { + enable = mkEnableOption "Life automated"; + }; + + config = mkIf cfg.enable { + home-manager = with pkgs; pkgs.lib.setAttrByPath [ "users" psCfg.user.name ] { + home.packages = [ + drone-cli + nmap + python38Packages.ansible + restic + shellcheck + terraform_0_15 + ]; + }; + }; +} diff --git a/modules/docker/default.nix b/modules/docker/default.nix new file mode 100644 index 00000000..668c4005 --- /dev/null +++ b/modules/docker/default.nix @@ -0,0 +1,22 @@ +{ lib, config, pkgs, ... }: +with lib; +let + psCfg = config.pub-solar; + cfg = config.pub-solar.docker; +in +{ + options.pub-solar.docker = { + enable = mkEnableOption "Life in metal boxes"; + }; + + config = mkIf cfg.enable { + virtualisation.docker.enable = true; + users.users = with pkgs; pkgs.lib.setAttrByPath [ psCfg.user.name ] { + extraGroups = [ "docker" ]; + }; + + environment.systemPackages = with pkgs; [ + docker-compose + ]; + }; +} diff --git a/modules/email/default.nix b/modules/email/default.nix new file mode 100644 index 00000000..d61bf1bc --- /dev/null +++ b/modules/email/default.nix @@ -0,0 +1,29 @@ +{ lib, config, pkgs, ... }: +with lib; +let + psCfg = config.pub-solar; + cfg = config.pub-solar.email; +in +{ + options.pub-solar.email = { + enable = mkEnableOption "Life in headers"; + }; + + config = mkIf cfg.enable { + home-manager = with pkgs; pkgs.lib.setAttrByPath [ "users" psCfg.user.name ] { + home.packages = [ + w3m + urlscan + neomutt + offlineimap + msmtp + mailto-mutt + ]; + + programs.offlineimap = { + enable = true; + pythonFile = builtins.readFile ./offlineimap.py; + }; + }; + }; +} diff --git a/modules/email/offlineimap.nix b/modules/email/offlineimap.nix new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/modules/email/offlineimap.nix @@ -0,0 +1 @@ + diff --git a/modules/email/offlineimap.py b/modules/email/offlineimap.py new file mode 100644 index 00000000..110b9e4b --- /dev/null +++ b/modules/email/offlineimap.py @@ -0,0 +1,9 @@ +#! /usr/bin/env python2 +import os +import subprocess + +def get_env(key): + return os.getenv(key) + +def get_secret(*attributes): + return subprocess.check_output(["secret-tool", "lookup"] + list(attributes)) diff --git a/modules/gaming/default.nix b/modules/gaming/default.nix new file mode 100644 index 00000000..21c54bac --- /dev/null +++ b/modules/gaming/default.nix @@ -0,0 +1,25 @@ +{ lib, config, pkgs, ... }: +with lib; +let + psCfg = config.pub-solar; + cfg = config.pub-solar.gaming; +in +{ + options.pub-solar.gaming = { + enable = mkEnableOption "Life in shooters"; + }; + + config = mkIf cfg.enable { + programs.steam.enable = true; + nixpkgs.config.packageOverrides = pkgs: { + steam = pkgs.steam.override { }; + }; + + home-manager = with pkgs; pkgs.lib.setAttrByPath [ "users" psCfg.user.name ] { + home.packages = [ + playonlinux + godot + ]; + }; + }; +} diff --git a/modules/gaming/steam.nix b/modules/gaming/steam.nix new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/modules/gaming/steam.nix @@ -0,0 +1 @@ + diff --git a/modules/graphical/.Xdefaults b/modules/graphical/.Xdefaults new file mode 100644 index 00000000..fcfcb22a --- /dev/null +++ b/modules/graphical/.Xdefaults @@ -0,0 +1,62 @@ +Xft.dpi: 96 +Xft.antialias: true +Xft.hinting: true +Xft.rgba: rgb +Xft.autohint: false +Xft.hintstyle: hintslight +Xft.lcdfilter: lcddefault + +! Base16 Burn +! Scheme: Benjamin Bädorf + +#define base00 #1a181a +#define base01 #2d2a2e +#define base02 #303030 +#define base03 #949494 +#define base04 #d3d1d4 +#define base05 #e3e1e4 +#define base06 #303030 +#define base07 #ff5f5f +#define base08 #f85e84 +#define base09 #df5923 +#define base0A #e5c463 +#define base0B #9ecd6f +#define base0C #ef9062 +#define base0D #7accd7 +#define base0E #ab9df2 +#define base0F #d70000 + +*foreground: base05 +#ifdef background_opacity +*background: [background_opacity]base00 +#else +*background: base00 +#endif +*cursorColor: base05 + +*color0: base00 +*color1: base08 +*color2: base0B +*color3: base0A +*color4: base0D +*color5: base0E +*color6: base0C +*color7: base05 + +*color8: base03 +*color9: base08 +*color10: base0B +*color11: base0A +*color12: base0D +*color13: base0E +*color14: base0C +*color15: base07 + +! Note: colors beyond 15 might not be loaded (e.g., xterm, urxvt), +! use 'shell' template to set these if necessary +*color16: base09 +*color17: base0F +*color18: base01 +*color19: base02 +*color20: base04 +*color21: base06 diff --git a/modules/graphical/alacritty.nix b/modules/graphical/alacritty.nix new file mode 100644 index 00000000..ef6c6956 --- /dev/null +++ b/modules/graphical/alacritty.nix @@ -0,0 +1,142 @@ +{ + env = { + TERM = "xterm-256color"; + }; + + window = { + # Window dimensions in character columns and lines + # Falls back to size specified by window manager if set to 0x0. + # (changes require restart) + dimensions = { + columns = 80; + lines = 24; + }; + + padding = { + x = 0; + y = 0; + }; + + decorations = "full"; + }; + + scrolling = { + # How many lines of scrollback to keep, + # "0" will disable scrolling. + history = 100000; + + # Number of lines the viewport will move for every line + # scrolled when scrollback is enabled (history > 0). + multiplier = 3; + }; + + # When true, bold text is drawn using the bright variant of colors. + draw_bold_text_with_bright_colors = true; + + font = { + # The normal (roman) font face to use. + normal = { + family = "Hack"; # should be "Menlo" or something on macOS. + # Style can be specified to pick a specific face. + style = "Regular"; + }; + + # The bold font face + bold = { + family = "Hack"; # should be "Menlo" or something on macOS. + # Style can be specified to pick a specific face. + style = "Bold"; + }; + + # The italic font face + italic = { + family = "Hack"; # should be "Menlo" or something on macOS. + # Style can be specified to pick a specific face. + style = "Italic"; + }; + + size = 18.0; + + offset = { + x = 0; + y = 0; + }; + + glyph_offset = { + x = 0; + y = 0; + }; + + use_thin_strokes = true; + }; + + key_bindings = [ + { key = "V"; mods = "Control|Alt"; action = "Paste"; } + { key = "C"; mods = "Control|Alt"; action = "Copy"; } + { key = "Paste"; action = "Paste"; } + { key = "Copy"; action = "Copy"; } + { key = "Q"; mods = "Command"; action = "Quit"; } + { key = "W"; mods = "Command"; action = "Quit"; } + { key = "Insert"; mods = "Shift"; action = "PasteSelection"; } + { key = "Key0"; mods = "Control"; action = "ResetFontSize"; } + { key = "Equals"; mods = "Control"; action = "IncreaseFontSize"; } + { key = "PageUp"; mods = "Shift"; action = "ScrollPageUp"; } + { key = "PageDown"; mods = "Shift"; action = "ScrollPageDown"; } + { key = "Minus"; mods = "Control"; action = "DecreaseFontSize"; } + { key = "H"; mode = "Vi|~Search"; action = "ScrollToBottom"; } + { key = "H"; mode = "Vi|~Search"; action = "ToggleViMode"; } + { key = "I"; mode = "Vi|~Search"; action = "Up"; } + { key = "K"; mode = "Vi|~Search"; action = "Down"; } + { key = "J"; mode = "Vi|~Search"; action = "Left"; } + { key = "L"; mode = "Vi|~Search"; action = "Right"; } + ]; + + # Base16 Burn 256 - alacritty color config + # Benjamin Bädorf + colors = { + # Default colors + primary = { + background = "0x1a181a"; + foreground = "0xe3e1e4"; + }; + + # Colors the cursor will use if `custom_cursor_colors` is true + cursor = { + text = "0x1a181a"; + cursor = "0xe3e1e4"; + }; + + # Normal colors + normal = { + black = "0x1a181a"; + red = "0xf85e84"; + green = "0x9ecd6f"; + yellow = "0xe5c463"; + blue = "0x7accd7"; + magenta = "0xab9df2"; + cyan = "0xef9062"; + white = "0xe3e1e4"; + }; + + # Bright colors + bright = { + black = "0x949494"; + red = "0xf85e84"; + green = "0x9ecd6f"; + yellow = "0xe5c463"; + blue = "0x7accd7"; + magenta = "0xab9df2"; + cyan = "0xef9062"; + white = "0xff5f5f"; + }; + + indexed_colors = [ + { index = 16; color = "0xdf5923"; } + { index = 17; color = "0xd70000"; } + { index = 18; color = "0x2d2a2e"; } + { index = 19; color = "0x303030"; } + { index = 20; color = "0xd3d1d4"; } + { index = 21; color = "0x303030"; } + ]; + }; +} diff --git a/modules/graphical/default.nix b/modules/graphical/default.nix new file mode 100644 index 00000000..63e7a43e --- /dev/null +++ b/modules/graphical/default.nix @@ -0,0 +1,149 @@ +{ lib, config, pkgs, ... }: +with lib; +let + psCfg = config.pub-solar; + cfg = config.pub-solar.graphical; + yamlFormat = pkgs.formats.yaml { }; + recursiveMerge = attrList: + let f = attrPath: + zipAttrsWith (n: values: + if tail values == [ ] + then head values + else if all isList values + then unique (concatLists values) + else if all isAttrs values + then f (attrPath ++ [ n ]) values + else last values + ); + in f [ ] attrList; +in +{ + options.pub-solar.graphical = { + enable = mkEnableOption "Life in color"; + alacritty = { + settings = mkOption { + type = yamlFormat.type; + default = { }; + }; + }; + }; + + config = mkIf cfg.enable { + hardware.opengl.enable = true; + environment = { + systemPackages = with pkgs; [ + gtk-engine-murrine + gtk_engines + gsettings-desktop-schemas + + matcha-gtk-theme + papirus-maia-icon-theme + + glib + ]; + etc = { + "xdg/PubSolar.conf".text = '' + [Qt] + style=GTK+ + ''; + }; + }; + + services.greetd = { + enable = true; + restart = false; + settings = { + default_session = { + command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd ${pkgs.sway-service}/bin/sway-service"; + }; + }; + }; + + qt5 = { + enable = true; + platformTheme = "gtk2"; + style = "gtk2"; + }; + + # Required for running Gnome apps outside the Gnome DE, see https://nixos.wiki/wiki/GNOME#Running_GNOME_programs_outside_of_GNOME + programs.dconf.enable = true; + services.udev.packages = with pkgs; [ gnome3.gnome-settings-daemon ]; + # Enable Sushi, a quick previewer for nautilus + services.gnome.sushi.enable = true; + # Enable GVfs, a userspace virtual filesystem + services.gvfs.enable = true; + + fonts.enableDefaultFonts = true; + fonts.fonts = with pkgs; [ + corefonts + fira-code + fira-code-symbols + google-fonts + lato + montserrat + nerdfonts + noto-fonts + noto-fonts-cjk + open-sans + powerline-fonts + source-sans-pro + ]; + + home-manager = with pkgs; pkgs.lib.setAttrByPath [ "users" psCfg.user.name ] { + home.packages = [ + alacritty + chromium + firefox + + flameshot + libnotify + gnome3.adwaita-icon-theme + gnome3.nautilus + + wine + + toggle-kbd-layout + + wcwd + + vlc + + gimp + ]; + + xdg.configFile."alacritty/alacritty.yml" = { + source = yamlFormat.generate "alacritty.yml" (recursiveMerge [ (import ./alacritty.nix) cfg.alacritty.settings ]); + }; + + gtk = { + enable = true; + font.name = "Lato"; + iconTheme = { + package = pkgs.papirus-maia-icon-theme; + name = "Papirus-Adapta-Nokto-Maia"; + }; + theme = { + package = pkgs.matcha-gtk-theme; + name = "Matcha-dark-aliz"; + }; + + gtk3.extraConfig = { + gtk-xft-antialias = "1"; + gtk-xft-hinting = "1"; + gtk-xft-hintstyle = "hintfull"; + gtk-xft-rgba = "rgb"; + gtk-application-prefer-dark-theme = "true"; + }; + + }; + + # Fix KeepassXC rendering issue + # https://github.com/void-linux/void-packages/issues/23517 + systemd.user.sessionVariables.QT_AUTO_SCREEN_SCALE_FACTOR = "0"; + + xresources.extraConfig = builtins.readFile ./.Xdefaults; + + systemd.user.services.network-manager-applet = import ./network-manager-applet.service.nix pkgs; + }; + }; +} diff --git a/modules/graphical/network-manager-applet.service.nix b/modules/graphical/network-manager-applet.service.nix new file mode 100644 index 00000000..71480a62 --- /dev/null +++ b/modules/graphical/network-manager-applet.service.nix @@ -0,0 +1,16 @@ +pkgs: +{ + Unit = { + Description = "Lightweight Wayland notification daemon"; + BindsTo = [ "sway-session.target" ]; + After = [ "sway-session.target" ]; + # ConditionEnvironment requires systemd v247 to work correctly + ConditionEnvironment = [ "WAYLAND_DISPLAY" ]; + }; + Service = { + ExecStart = "${pkgs.networkmanagerapplet}/bin/nm-applet --sm-disable --indicator"; + }; + Install = { + WantedBy = [ "sway-session.target" ]; + }; +} diff --git a/modules/module-list.nix b/modules/module-list.nix index 1e3ec721..35cf4abe 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -1 +1,21 @@ -[ ] +[ + ./compat + ./user + ./x-os + ./sway + ./graphical + ./docker + ./audio + ./email + ./crypto + ./nextcloud + ./gaming + ./virtualisation + ./social + ./devops + ./terminal-life + ./server + ./printing + ./office + ./uhk +] diff --git a/modules/nextcloud/default.nix b/modules/nextcloud/default.nix new file mode 100644 index 00000000..e37fb8e1 --- /dev/null +++ b/modules/nextcloud/default.nix @@ -0,0 +1,17 @@ +{ lib, config, pkgs, ... }: +with lib; +let + psCfg = config.pub-solar; + cfg = config.pub-solar.nextcloud; +in +{ + options.pub-solar.nextcloud = { + enable = mkEnableOption "Life in sync"; + }; + + config = mkIf cfg.enable { + home-manager = with pkgs; pkgs.lib.setAttrByPath [ "users" psCfg.user.name ] { + systemd.user.services.nextcloud-client = import ./nextcloud.service.nix pkgs; + }; + }; +} diff --git a/modules/nextcloud/nextcloud.service.nix b/modules/nextcloud/nextcloud.service.nix new file mode 100644 index 00000000..29045f0f --- /dev/null +++ b/modules/nextcloud/nextcloud.service.nix @@ -0,0 +1,21 @@ +pkgs: +{ + Unit = { + Description = "Nextcloud Client"; + BindsTo = [ "sway-session.target" ]; + Wants = [ "graphical-session-pre.target" ]; + After = [ "graphical-session-pre.target" ]; + # ConditionEnvironment requires systemd v247 to work correctly + ConditionEnvironment = [ "WAYLAND_DISPLAY" ]; + }; + Service = { + Type = "simple"; + ExecStart = "${pkgs.nextcloud-client}/bin/nextcloud --background"; + ExecReload = "/run/current-system/sw/bin/kill -HUP $MAINPID"; + KillMode = "process"; + Restart = "on-failure"; + }; + Install = { + WantedBy = [ "sway-session.target" ]; + }; +} diff --git a/modules/office/default.nix b/modules/office/default.nix new file mode 100644 index 00000000..74a21d7a --- /dev/null +++ b/modules/office/default.nix @@ -0,0 +1,26 @@ +{ lib, config, pkgs, ... }: +with lib; +let + psCfg = config.pub-solar; + cfg = config.pub-solar.office; +in +{ + options.pub-solar.office = { + enable = mkEnableOption "Install office programs, also enables printing server"; + }; + + config = mkIf cfg.enable { + pub-solar.printing.enable = true; + + # Gnome PDF viewer + programs.evince.enable = true; + home-manager = with pkgs; pkgs.lib.setAttrByPath [ "users" psCfg.user.name ] { + home.packages = [ + libreoffice-fresh + gnome3.simple-scan + # Tools like pdfunite + poppler_utils + ]; + }; + }; +} diff --git a/modules/printing/default.nix b/modules/printing/default.nix new file mode 100644 index 00000000..ea9ce166 --- /dev/null +++ b/modules/printing/default.nix @@ -0,0 +1,34 @@ +{ lib, config, pkgs, ... }: +with lib; +let + psCfg = config.pub-solar; + cfg = config.pub-solar.printing; +in +{ + options.pub-solar.printing = { + enable = mkEnableOption "CUPSSSss"; + }; + + config = mkIf cfg.enable { + services.avahi.enable = true; + services.avahi.nssmdns = true; + services.avahi.publish.enable = true; + services.avahi.publish.userServices = true; + services.printing.enable = true; + services.printing.browsing = true; + services.printing.listenAddresses = [ "localhost:631" ]; + services.printing.allowFrom = [ "all" ]; + services.printing.defaultShared = false; + services.printing.drivers = [ + pkgs.gutenprint + pkgs.brgenml1lpr + pkgs.brgenml1cupswrapper + pkgs.brlaser + pkgs.cups-brother-hl3140cw + ]; + hardware.sane = { + enable = true; + brscan4.enable = true; + }; + }; +} diff --git a/modules/server/default.nix b/modules/server/default.nix new file mode 100644 index 00000000..3821421c --- /dev/null +++ b/modules/server/default.nix @@ -0,0 +1,19 @@ +{ lib, config, pkgs, ... }: +with lib; +let + psCfg = config.pub-solar; + cfg = config.pub-solar.server; +in +{ + options.pub-solar.server = { + enable = mkEnableOption "Enable server options like sshd"; + }; + + config = mkIf cfg.enable { + services.openssh = { + enable = true; + permitRootLogin = "no"; + passwordAuthentication = false; + }; + }; +} diff --git a/modules/social/default.nix b/modules/social/default.nix new file mode 100644 index 00000000..f3aa63b7 --- /dev/null +++ b/modules/social/default.nix @@ -0,0 +1,23 @@ +{ lib, config, pkgs, ... }: +with lib; +let + psCfg = config.pub-solar; + cfg = config.pub-solar.social; +in +{ + options.pub-solar.social = { + enable = mkEnableOption "Life with others"; + }; + + config = mkIf cfg.enable { + home-manager = with pkgs; pkgs.lib.setAttrByPath [ "users" psCfg.user.name ] { + home.packages = [ + #mySignalDesktop + signal-desktop + tdesktop + element-desktop + irssi + ]; + }; + }; +} diff --git a/modules/sway/config/config b/modules/sway/config/config new file mode 100644 index 00000000..2360c062 --- /dev/null +++ b/modules/sway/config/config @@ -0,0 +1,212 @@ +# Default config for sway +# +# Copy this to ~/.config/sway/config and edit it to your liking. +# +# Read `man 5 sway` for a complete reference. + +### Variables +# +# Logo key. Use Mod1 for Alt. +set $mod Mod4 +# Home row direction keys, like vim +set $left j +set $down k +set $up i +set $right l +# Your preferred terminal emulator +set $term alacritty +# Your preferred application launcher +# Note: pass the final command to swaymsg so that the resulting window can be opened +# on the original workspace that the command was run on. +#set $menu dmenu_path | dmenu | xargs swaymsg exec bemenu-run --no-overlap + +default_border pixel 1 + +### Output configuration +# +# Default wallpaper (more resolutions are available in @datadir@/backgrounds/sway/) +output * bg ~/.config/wallpaper.jpg fill + +### Key bindings +# +# Basics: +# + # Start a terminal + bindsym $mod+Return exec $term + + # Start a terminal + bindsym $mod+Shift+Return exec sh -c '$term --working-directory $(wcwd)' + + # Kill focused window + bindsym $mod+Shift+q kill + + # Drag floating windows by holding down $mod and left mouse button. + # Resize them with right mouse button + $mod. + # Despite the name, also works for non-floating windows. + # Change normal to inverse to use left mouse button for resizing and right + # mouse button for dragging. + floating_modifier $mod normal + + # Reload the configuration file + bindsym $mod+Ctrl+r reload + +# +# Moving around: +# + # Move your focus around + bindsym $mod+$left focus left + bindsym $mod+$down focus down + bindsym $mod+$up focus up + bindsym $mod+$right focus right + # Or use $mod+[up|down|left|right] + bindsym $mod+Left focus left + bindsym $mod+Down focus down + bindsym $mod+Up focus up + bindsym $mod+Right focus right + + # Move the focused window with the same, but add Shift + bindsym $mod+Shift+$left move left + bindsym $mod+Shift+$down move down + bindsym $mod+Shift+$up move up + bindsym $mod+Shift+$right move right + # Ditto, with arrow keys + bindsym $mod+Shift+Left move left + bindsym $mod+Shift+Down move down + bindsym $mod+Shift+Up move up + bindsym $mod+Shift+Right move right +# +# Workspaces: +# + + + # Workspace names + # to display names or symbols instead of plain workspace numbers you can use + # something like: set $ws1 1:mail + # set $ws2 2: + set $ws1 1 + set $ws2 2 + set $ws3 3 + set $ws4 4 + set $ws5 5 + set $ws6 6 + set $ws7 7 + set $ws8 8 + set $ws9 9 + + # Switch to workspace + bindsym $mod+1 workspace 1 + bindsym $mod+2 workspace 2 + bindsym $mod+3 workspace 3 + bindsym $mod+4 workspace 4 + bindsym $mod+5 workspace 5 + bindsym $mod+6 workspace 6 + bindsym $mod+7 workspace 7 + bindsym $mod+8 workspace 8 + bindsym $mod+9 workspace 9 + # Move focused container to workspace + bindsym $mod+Ctrl+1 move container to workspace $ws1 + bindsym $mod+Ctrl+2 move container to workspace $ws2 + bindsym $mod+Ctrl+3 move container to workspace $ws3 + bindsym $mod+Ctrl+4 move container to workspace $ws4 + bindsym $mod+Ctrl+5 move container to workspace $ws5 + bindsym $mod+Ctrl+6 move container to workspace $ws6 + bindsym $mod+Ctrl+7 move container to workspace $ws7 + bindsym $mod+Ctrl+8 move container to workspace $ws8 + bindsym $mod+Ctrl+9 move container to workspace $ws9 + # Move focused container to workspace and move focus with it + bindsym $mod+Shift+1 move container to workspace 1; workspace $ws1 + bindsym $mod+Shift+2 move container to workspace 2; workspace $ws2 + bindsym $mod+Shift+3 move container to workspace 3; workspace $ws3 + bindsym $mod+Shift+4 move container to workspace 4; workspace $ws4 + bindsym $mod+Shift+5 move container to workspace 5; workspace $ws5 + bindsym $mod+Shift+6 move container to workspace 6; workspace $ws6 + bindsym $mod+Shift+7 move container to workspace 7; workspace $ws7 + bindsym $mod+Shift+8 move container to workspace 8; workspace $ws8 + bindsym $mod+Shift+9 move container to workspace 9; workspace $ws9 + # Note: workspaces can have any name you want, not just numbers. + # We just use 1-10 as the default. + + #navigate workspaces next / previous + bindsym $mod+Ctrl+Right workspace next + bindsym $mod+Ctrl+Left workspace prev + + # workspace back and forth (with/without active container) + workspace_auto_back_and_forth yes + bindsym $mod+b workspace back_and_forth + bindsym $mod+Shift+b move container to workspace back_and_forth; workspace back_and_forth + +# +# Layout stuff: +# + # Configure border style + default_border pixel 1 + default_floating_border normal + + # Hide borders + hide_edge_borders none + + # Font for window titles. Will also be used by the bar unless a different font + # is used in the bar {} block below. + font xft:Hack 16 + + # You can "split" the current object of your focus with + # $mod+b or $mod+v, for horizontal and vertical splits + # respectively. + bindsym $mod+h splith; exec notify-send 'tile horizontally' + bindsym $mod+v splitv; exec notify-send 'tile vertically' + + # Switch the current container between different layout styles + bindsym $mod+s layout stacking + bindsym $mod+w layout tabbed + bindsym $mod+e layout toggle split + + # Make the current focus fullscreen + bindsym $mod+f fullscreen + + # Toggle the current focus between tiling and floating mode + bindsym $mod+Shift+space floating toggle + + # Swap focus between the tiling area and the floating area + bindsym $mod+t focus mode_toggle + + # Move focus to the parent container + bindsym $mod+a focus parent + bindsym $mod+d focus child +# +# Scratchpad: +# + # Sway has a "scratchpad", which is a bag of holding for windows. + # You can send windows there and get them back later. + + # Move the currently focused window to the scratchpad + bindsym $mod+Shift+minus move scratchpad + + # Show the next scratchpad window or hide the focused scratchpad window. + # If there are multiple scratchpad windows, this command cycles through them. + bindsym $mod+minus scratchpad show +# +# Resizing containers: +# +mode "resize" { + # left will shrink the containers width + # right will grow the containers width + # up will shrink the containers height + # down will grow the containers height + bindsym $left resize shrink width 10px + bindsym $down resize grow height 10px + bindsym $up resize shrink height 10px + bindsym $right resize grow width 10px + + # Ditto, with arrow keys + bindsym Left resize shrink width 10px + bindsym Down resize grow height 10px + bindsym Up resize shrink height 10px + bindsym Right resize grow width 10px + + # Return to default mode + bindsym Return mode "default" + bindsym Escape mode "default" +} +bindsym $mod+r mode "resize" + +include ~/.config/sway/config.d/* diff --git a/modules/sway/config/config.d/applications.conf b/modules/sway/config/config.d/applications.conf new file mode 100644 index 00000000..8691bc4f --- /dev/null +++ b/modules/sway/config/config.d/applications.conf @@ -0,0 +1,72 @@ +# switch to workspace with urgent window automatically +for_window [urgent=latest] focus + +for_window [app_id="keepassxc"] floating disable +assign [app_id="keepassxc"] $ws8 + +for_window [app_id="virt-manager"] floating disable +assign [app_id="virt-manager"] $ws9 + +assign [instance="element"] $ws4 +assign [app_id="Signal"] $ws4 +assign [app_id="telegramdesktop"] $ws4 + +# Launcher +for_window [app_id="launcher" title="Alacritty"] floating enable, border pixel 10, sticky enable + +# Floating menus +for_window [app_id="pavucontrol"] floating enable +for_window [app_id="blueman-manager"] floating enable + +# Open specific applications in floating mode +for_window [title="alsamixer"] floating enable border pixel 1 +for_window [class="Calamares"] floating enable border normal +for_window [class="Clipgrab"] floating enable +for_window [title="File Transfer*"] floating enable +for_window [class="Galculator"] floating enable border pixel 1 +for_window [class="GParted"] floating enable border normal +for_window [title="i3_help"] floating enable sticky enable border normal +for_window [class="Lightdm-gtk-greeter-settings"] floating enable +for_window [class="Lxappearance"] floating enable sticky enable border normal +for_window [class="Manjaro-hello"] floating enable +for_window [class="Manjaro Settings Manager"] floating enable border normal +for_window [title="MuseScore: Play Panel"] floating enable +for_window [class="Nitrogen"] floating enable sticky enable border normal +for_window [class="Oblogout"] fullscreen enable +for_window [class="octopi"] floating enable +for_window [title="About Pale Moon"] floating enable +for_window [class="Pamac-manager"] floating enable +for_window [class="Pavucontrol"] floating enable +for_window [class="qt5ct"] floating enable sticky enable border normal +for_window [class="Qtconfig-qt4"] floating enable sticky enable border normal +for_window [class="Simple-scan"] floating enable border normal +for_window [class="(?i)System-config-printer.py"] floating enable border normal +for_window [class="Skype"] floating enable border normal +for_window [class="Thus"] floating enable border normal +for_window [class="Timeset-gui"] floating enable border normal +for_window [class="(?i)virtualbox"] floating enable border normal +for_window [class="Xfburn"] floating enable +for_window [class="^VirtualBox Machine$" title="Running"] floating disable +for_window [class="^rdesktop" title="rdesktop"] floating disable + +# firefox floating menus +for_window [window_role="pop-up"] floating enable +for_window [window_role="task_dialog"] floating enable +for_window [window_role="pop-up"] floating enable +for_window [window_role="bubble"] floating enable +for_window [window_role="task_dialog"] floating enable +for_window [window_role="Preferences"] floating enable +for_window [window_type="dialog"] floating enable +for_window [window_type="menu"] floating enable +for_window [title="About Mozilla Firefox"] floating enabled +for_window [title="Password Required - Mozilla Firefox"] floating enabled +for_window [title="Firefox — Sharing Indicator"] floating enabled +for_window [title="Extension: (Open in Browser)*"] floating enabled + +# qMasterPassword floating menu +for_window [title="qMasterPassword"] focus +for_window [title="qMasterPassword"] floating enable + +# vimpc floating instance +for_window [app_id="mu_vimpc"] focus +for_window [app_id="mu_vimpc"] floating enable, border pixel 10, sticky enable diff --git a/modules/sway/config/config.d/colorscheme.conf b/modules/sway/config/config.d/colorscheme.conf new file mode 100644 index 00000000..3886c3d6 --- /dev/null +++ b/modules/sway/config/config.d/colorscheme.conf @@ -0,0 +1,19 @@ +## Base16 Burn +# Author: Benjamin Bädorf + +set $base00 #1a181a +set $base01 #2d2a2e +set $base02 #303030 +set $base03 #949494 +set $base04 #d3d1d4 +set $base05 #e3e1e4 +set $base06 #303030 +set $base07 #ff5f5f +set $base08 #f85e84 +set $base09 #df5923 +set $base0A #e5c463 +set $base0B #9ecd6f +set $base0C #ef9062 +set $base0D #7accd7 +set $base0E #ab9df2 +set $base0F #d70000 diff --git a/modules/sway/config/config.d/custom-keybindings.conf b/modules/sway/config/config.d/custom-keybindings.conf new file mode 100644 index 00000000..2b7ba20d --- /dev/null +++ b/modules/sway/config/config.d/custom-keybindings.conf @@ -0,0 +1,49 @@ +# launch categorized menu +bindsym $mod+z exec --no-startup-id morc_menu + +# switch keyboard input language +bindsym $mod+tab exec toggle-kbd-layout + +################################################################################################ +## sound-section - ## +################################################################################################ + +bindsym $mod+Ctrl+m exec pavucontrol + +################################################################################################ + +# Quickstart application shortcuts +bindsym $mod+F1 exec qMasterPassword +bindsym $mod+F2 exec firefox +bindsym $mod+F3 exec $term -e vifm +bindsym $mod+Shift+F3 exec gksu $term -e vifm +bindsym $mod+F4 exec nautilus -w +bindsym $mod+Shift+F4 exec signal-desktop --enable-features=UseOzonePlatform --ozone-platform=wayland +bindsym $mod+F5 exec $term -e 'mocp -C $XDG_CONFIG_DIR/mocp/config' +bindsym $mod+Shift+m exec mu +bindsym $mod+Shift+h exec xdg-open /usr/share/doc/manjaro/i3_help.pdf + +# Screenshofts +bindsym $mod+Ctrl+p exec grim -g "$(slurp -d -b \#ffffff11)" ~/Pictures/Screenshots/$(date +%Y%m%d_%Hh%Mm%Ss)_grim.png +bindsym $mod+Shift+p exec grim ~/Pictures/Screenshots/$(date +%Y%m%d_%Hh%Mm%Ss)_grim.png +bindsym $mod+Ctrl+f exec "( pkill flameshot || true && flameshot & ) && ( sleep 0.5s && flameshot gui )" + +# Launcher +set $menu exec alacritty --class launcher -e env TERMINAL_COMMAND="alacritty -e" sway-launcher +bindsym $mod+Space exec $menu + +# Set shut down, restart and locking features +set $mode_system (l)ock, (e)xit, (s)uspend, (h)ibernate, (r)eboot, (Shift+s)hutdown +bindsym $mod+0 mode "$mode_system" +mode "$mode_system" { + bindsym l exec swaylock-bg, mode "default" + bindsym e exec systemctl --user stop graphical-session.target, mode "default" + bindsym s exec systemctl suspend, mode "default" + bindsym h exec systemctl hibernate, mode "default" + bindsym r exec systemctl reboot, mode "default" + bindsym Shift+s exec systemctl poweroff, mode "default" + + # exit system mode: "Enter" or "Escape" + bindsym Return mode "default" + bindsym Escape mode "default" +} diff --git a/modules/sway/config/config.d/gaps.conf b/modules/sway/config/config.d/gaps.conf new file mode 100644 index 00000000..f0a17661 --- /dev/null +++ b/modules/sway/config/config.d/gaps.conf @@ -0,0 +1,53 @@ +# Set inner/outer gaps +gaps inner 10 +gaps outer -5 + +# Additionally, you can issue commands with the following syntax. This is useful to bind keys to changing the gap size. +# gaps inner|outer current|all set|plus|minus +# gaps inner all set 10 +# gaps outer all plus 5 + +# Smart gaps (gaps used if only more than one container on the workspace) +smart_gaps on + +# Smart borders (draw borders around container only if it is not the only container on this workspace) +# on|no_gaps (on=always activate and no_gaps=only activate if the gap size to the edge of the screen is 0) +smart_borders on + +# Press $mod+Shift+g to enter the gap mode. Choose o or i for modifying outer/inner gaps. Press one of + / - (in-/decrement for current workspace) or 0 (remove gaps for current workspace). If you also press Shift with these keys, the change will be global for all workspaces. +set $mode_gaps Gaps: (o) outer, (i) inner +set $mode_gaps_outer Outer Gaps: +|-|0 (local), Shift + +|-|0 (global) +set $mode_gaps_inner Inner Gaps: +|-|0 (local), Shift + +|-|0 (global) +bindsym $mod+Shift+g mode "$mode_gaps" + +mode "$mode_gaps" { + bindsym o mode "$mode_gaps_outer" + bindsym i mode "$mode_gaps_inner" + bindsym Return mode "default" + bindsym Escape mode "default" +} +mode "$mode_gaps_inner" { + bindsym plus gaps inner current plus 5 + bindsym minus gaps inner current minus 5 + bindsym 0 gaps inner current set 0 + + bindsym Shift+plus gaps inner all plus 5 + bindsym Shift+minus gaps inner all minus 5 + bindsym Shift+0 gaps inner all set 0 + + bindsym Return mode "default" + bindsym Escape mode "default" +} +mode "$mode_gaps_outer" { + bindsym plus gaps outer current plus 5 + bindsym minus gaps outer current minus 5 + bindsym 0 gaps outer current set 0 + + bindsym Shift+plus gaps outer all plus 5 + bindsym Shift+minus gaps outer all minus 5 + bindsym Shift+0 gaps outer all set 0 + + bindsym Return mode "default" + bindsym Escape mode "default" +} + diff --git a/modules/sway/config/config.d/systemd.conf b/modules/sway/config/config.d/systemd.conf new file mode 100644 index 00000000..ceb273f8 --- /dev/null +++ b/modules/sway/config/config.d/systemd.conf @@ -0,0 +1,6 @@ +# Note that the systemctl commands must be run synchronously and can't be split into +# three exec statements, since otherwise the session target may be started before +# systemctl import-environment is complete, and services that require certain variables +# will fail to run. +# https://github.com/swaywm/sway/wiki/Systemd-integration +exec "systemctl --user import-environment; systemctl --user start sway-session.target; dbus-update-activation-environment WAYLAND_DISPLAY" diff --git a/modules/sway/config/config.d/theme.conf b/modules/sway/config/config.d/theme.conf new file mode 100644 index 00000000..27ae794a --- /dev/null +++ b/modules/sway/config/config.d/theme.conf @@ -0,0 +1,13 @@ +# Border BG Text Ind Child Border +client.focused $base00 $base01 $base07 $base0D $base07 +client.focused_inactive $base00 $base01 $base07 $base03 $base00 +client.unfocused $base00 $base00 $base04 $base06 $base00 +client.urgent $base00 $base0F $base00 $base08 $base00 + +client.background $base00 + +# Read the gtk settings from gtk setting.ini and pass them to gsettings +exec_always import-gtk-settings \ + gtk-theme:gtk-theme-name \ + icon-theme:gtk-icon-theme-name \ + cursor-theme:gtk-cursor-theme-name diff --git a/modules/sway/default.nix b/modules/sway/default.nix new file mode 100644 index 00000000..21f017c0 --- /dev/null +++ b/modules/sway/default.nix @@ -0,0 +1,91 @@ +{ lib, config, pkgs, ... }: +with lib; +let + psCfg = config.pub-solar; + cfg = config.pub-solar.sway; +in +{ + options.pub-solar.sway = { + enable = mkEnableOption "Life in boxes"; + }; + options.pub-solar.sway.v4l2loopback.enable = mkOption { + type = types.bool; + default = true; + description = "WebCam streaming tool"; + }; + + config = mkIf cfg.enable (mkMerge [ + (mkIf (cfg.v4l2loopback.enable) { + boot.extraModulePackages = with config.boot.kernelPackages; [ v4l2loopback ]; + boot.kernelModules = [ "v4l2loopback" ]; + boot.extraModprobeConfig = '' + options v4l2loopback exclusive_caps=1 devices=3 + ''; + }) + + ({ + environment.systemPackages = with pkgs; [ + linuxPackages.v4l2loopback + ]; + + programs.sway.enable = true; + + xdg.portal = { + enable = true; + extraPortals = with pkgs; [ xdg-desktop-portal-gtk xdg-desktop-portal-wlr ]; + gtkUsePortal = true; + }; + + services.pipewire.enable = true; + + home-manager = with pkgs; pkgs.lib.setAttrByPath [ "users" psCfg.user.name ] { + home.packages = with pkgs; [ + sway + grim + kanshi + mako + slurp + swayidle + swaylock + swaybg + xwayland + + libappindicator-gtk3 + + wl-clipboard + wf-recorder + brightnessctl + gammastep + geoclue2 + xsettingsd + ydotool + + swaylock-bg + sway-launcher + sway-service + import-gtk-settings + s + wcwd + ]; + + programs.waybar.enable = true; + #programs.waybar.systemd.enable = true; + + systemd.user.services.mako = import ./mako.service.nix pkgs; + systemd.user.services.sway = import ./sway.service.nix pkgs; + systemd.user.services.swayidle = import ./swayidle.service.nix pkgs; + systemd.user.services.xsettingsd = import ./xsettingsd.service.nix pkgs; + systemd.user.services.waybar = import ./waybar.service.nix pkgs; + systemd.user.targets.sway-session = import ./sway-session.target.nix pkgs; + + xdg.configFile."sway/config".source = ./config/config; + xdg.configFile."sway/config.d/colorscheme.conf".source = ./config/config.d/colorscheme.conf; + xdg.configFile."sway/config.d/theme.conf".source = ./config/config.d/theme.conf; + xdg.configFile."sway/config.d/gaps.conf".source = ./config/config.d/gaps.conf; + xdg.configFile."sway/config.d/custom-keybindings.conf".source = ./config/config.d/custom-keybindings.conf; + xdg.configFile."sway/config.d/applications.conf".source = ./config/config.d/applications.conf; + xdg.configFile."sway/config.d/systemd.conf".source = ./config/config.d/systemd.conf; + }; + }) + ]); +} diff --git a/modules/sway/gammastep.service.nix b/modules/sway/gammastep.service.nix new file mode 100644 index 00000000..f59edf02 --- /dev/null +++ b/modules/sway/gammastep.service.nix @@ -0,0 +1,18 @@ +pkgs: +{ + Unit = { + Description = "set color temperature of display according to time of day"; + Documentation = [ "man:gammastep(1)" ]; + BindsTo = [ "sway-session.target" ]; + After = [ "sway-session.target" ]; + # ConditionEnvironment requires systemd v247 to work correctly + ConditionEnvironment = [ "WAYLAND_DISPLAY" ]; + }; + Service = { + Type = "simple"; + ExecStart = "${pkgs.gammastep}/bin/gammastep -l geoclue2 -m wayland -v"; + }; + Install = { + WantedBy = [ "sway-session.target" ]; + }; +} diff --git a/modules/sway/libinput-gestures.service.nix b/modules/sway/libinput-gestures.service.nix new file mode 100644 index 00000000..c4c860da --- /dev/null +++ b/modules/sway/libinput-gestures.service.nix @@ -0,0 +1,19 @@ +pkgs: +{ + Unit = { + Description = "Actions gestures on your touchpad using libinput"; + Documentation = [ "https://github.com/bulletmark/libinput-gestures" ]; + BindsTo = [ "sway-session.target" ]; + After = [ "sway-session.target" ]; + }; + Service = { + Type = "simple"; + ExecStart = "${pkgs.libinput-gestures}/bin/libinput-gestures"; + Restart = "on-failure"; + RestartSec = "1"; + TimeoutStopSec = "10"; + }; + Install = { + WantedBy = [ "sway-session.target" ]; + }; +} diff --git a/modules/sway/mako.service.nix b/modules/sway/mako.service.nix new file mode 100644 index 00000000..190b986d --- /dev/null +++ b/modules/sway/mako.service.nix @@ -0,0 +1,20 @@ +pkgs: +{ + Unit = { + Description = "Lightweight Wayland notification daemon"; + Documentation = [ "man:mako(1)" ]; + BindsTo = [ "sway-session.target" ]; + After = [ "sway-session.target" ]; + # ConditionEnvironment requires systemd v247 to work correctly + ConditionEnvironment = [ "WAYLAND_DISPLAY" ]; + }; + Service = { + Type = "dbus"; + BusName = "org.freedesktop.Notifications"; + ExecStart = "${pkgs.mako}/bin/mako"; + ExecReload = "${pkgs.mako}/bin/makoctl reload"; + }; + Install = { + WantedBy = [ "sway-session.target" ]; + }; +} diff --git a/modules/sway/sway-session.target.nix b/modules/sway/sway-session.target.nix new file mode 100644 index 00000000..3eb4d24c --- /dev/null +++ b/modules/sway/sway-session.target.nix @@ -0,0 +1,10 @@ +pkgs: +{ + Unit = { + Description = "sway compositor session"; + Documentation = [ "man:systemd.special(7)" ]; + BindsTo = [ "graphical-session.target" ]; + Wants = [ "graphical-session-pre.target" ]; + After = [ "graphical-session-pre.target" ]; + }; +} diff --git a/modules/sway/sway.service.nix b/modules/sway/sway.service.nix new file mode 100644 index 00000000..95efc3e6 --- /dev/null +++ b/modules/sway/sway.service.nix @@ -0,0 +1,18 @@ +pkgs: +{ + Unit = { + Description = "sway - SirCmpwn's Wayland window manager"; + Documentation = [ "man:sway(5)" ]; + BindsTo = [ "graphical-session.target" ]; + Wants = [ "graphical-session-pre.target" ]; + After = [ "graphical-session-pre.target" ]; + }; + Service = { + Type = "simple"; + ExecStart = "${pkgs.sway}/bin/sway"; + Restart = "on-failure"; + RestartSec = "1"; + TimeoutStopSec = "10"; + ExecStopPost = "${pkgs.systemd}/bin/systemctl --user unset-environment SWAYSOCK DISPLAY I3SOCK WAYLAND_DISPLAY"; + }; +} diff --git a/modules/sway/swayidle.service.nix b/modules/sway/swayidle.service.nix new file mode 100644 index 00000000..a750eacb --- /dev/null +++ b/modules/sway/swayidle.service.nix @@ -0,0 +1,22 @@ +pkgs: +{ + Unit = { + Description = "Idle manager for Wayland"; + Documentation = [ "man:swayidle(1)" ]; + BindsTo = [ "graphical-session.target" ]; + Wants = [ "graphical-session-pre.target" ]; + After = [ "graphical-session-pre.target" ]; + }; + Service = { + Type = "simple"; + ExecStart = ''${pkgs.swayidle}/bin/swayidle -w \ + timeout 600 'swaylock-bg' \ + timeout 900 'swaymsg "output * dpms off"' \ + resume 'swaymsg "output * dpms on"' \ + before-sleep 'swaylock-bg' + ''; + }; + Install = { + WantedBy = [ "sway-session.target" ]; + }; +} diff --git a/modules/sway/waybar.service.nix b/modules/sway/waybar.service.nix new file mode 100644 index 00000000..f508f144 --- /dev/null +++ b/modules/sway/waybar.service.nix @@ -0,0 +1,20 @@ +pkgs: +{ + Unit = { + Description = "Highly customizable Wayland bar for Sway and Wlroots based compositors."; + Documentation = "https://github.com/Alexays/Waybar/wiki/"; + BindsTo = [ "sway-session.target" ]; + After = [ "graphical-session-pre.target" "network-online.target" ]; + Wants = [ "graphical-session-pre.target" "network-online.target" "blueman-applet.service" ]; + }; + + Service = { + Type = "dbus"; + BusName = "fr.arouillard.waybar"; + ExecStart = "${pkgs.waybar}/bin/waybar"; + }; + + Install = { + WantedBy = [ "sway-session.target" ]; + }; +} diff --git a/modules/sway/xsettingsd.service.nix b/modules/sway/xsettingsd.service.nix new file mode 100644 index 00000000..0d729cb2 --- /dev/null +++ b/modules/sway/xsettingsd.service.nix @@ -0,0 +1,19 @@ +pkgs: +{ + Unit = { + Description = "X Settings Daemon"; + Documentation = [ "https://github.com/derat/xsettingsd/wiki/Installation" ]; + BindsTo = [ "sway-session.target" ]; + After = [ "sway-session.target" ]; + # ConditionEnvironment requires systemd v247 to work correctly + ConditionEnvironment = [ "WAYLAND_DISPLAY" ]; + }; + Service = { + Type = "simple"; + ExecStart = "${pkgs.xsettingsd}/bin/xsettingsd"; + ExecStop = "/run/current-system/sw/bin/env pkill xsettingsd"; + }; + Install = { + WantedBy = [ "sway-session.target" ]; + }; +} diff --git a/modules/sway/ydotool.service.nix b/modules/sway/ydotool.service.nix new file mode 100644 index 00000000..d53bfcd7 --- /dev/null +++ b/modules/sway/ydotool.service.nix @@ -0,0 +1,19 @@ +pkgs: +{ + Unit = { + Description = "ydotool - Generic command-line automation tool (no X!)"; + Documentation = [ "https://github.com/ReimuNotMoe/ydotool" ]; + BindsTo = [ "sway-session.target" ]; + After = [ "sway-session.target" ]; + }; + Service = { + Type = "simple"; + ExecStart = "${pkgs.ydotool}/bin/ydotoold"; + Restart = "on-failure"; + RestartSec = "1"; + TimeoutStopSec = "10"; + }; + Install = { + WantedBy = [ "sway-session.target" ]; + }; +} diff --git a/modules/terminal-life/default.nix b/modules/terminal-life/default.nix new file mode 100644 index 00000000..0e013185 --- /dev/null +++ b/modules/terminal-life/default.nix @@ -0,0 +1,44 @@ +{ lib, config, pkgs, ... }: +with lib; +let + psCfg = config.pub-solar; + cfg = config.pub-solar.terminal-life; +in +{ + options.pub-solar.terminal-life = { + enable = mkEnableOption "Life in black and white"; + }; + + config = mkIf cfg.enable { + programs.command-not-found.enable = false; + + # Needed to get zsh completion for system packages (e.g. systemd). + environment.pathsToLink = [ "/share/zsh" ]; + + services.lorri.enable = true; + + environment.systemPackages = with pkgs; [ + screen + ]; + + home-manager = with pkgs; pkgs.lib.setAttrByPath [ "users" psCfg.user.name ] { + home.packages = [ + ag + ack + bat + exa + gh + powerline + vifm + watson + nnn + fd + direnv + ]; + + programs.neovim = import ./nvim { inherit config; inherit pkgs; }; + programs.fzf = import ./fzf { inherit config; inherit pkgs; }; + programs.zsh = import ./zsh { inherit config; inherit pkgs; }; + }; + }; +} diff --git a/modules/terminal-life/fzf/default.nix b/modules/terminal-life/fzf/default.nix new file mode 100644 index 00000000..6d9e4a7c --- /dev/null +++ b/modules/terminal-life/fzf/default.nix @@ -0,0 +1,11 @@ +{ config, pkgs, ... }: +{ + enable = true; + defaultCommand = "fd --hidden --type f --exclude .git"; + defaultOptions = [ + "--color=bg+:#2d2a2e,bg:#1a181a,spinner:#ef9062,hl:#7accd7" + "--color=fg:#d3d1d4,header:#7accd7,info:#e5c463,pointer:#ef9062" + "--color=marker:#ef9062,fg+:#303030,prompt:#e5c463,hl+:#7accd7" + ]; + enableZshIntegration = true; +} diff --git a/modules/terminal-life/nvim/clipboard.vim b/modules/terminal-life/nvim/clipboard.vim new file mode 100644 index 00000000..7467dcc0 --- /dev/null +++ b/modules/terminal-life/nvim/clipboard.vim @@ -0,0 +1,20 @@ +" Wayland clipboard provider that strips carriage returns (GTK3 issue). +" This is needed because currently there's an issue where GTK3 applications on +" Wayland contain carriage returns at the end of the lines (this is a root +" issue that needs to be fixed). +let g:clipboard = { + \ 'name': 'wayland-strip-carriage', + \ 'copy': { + \ '+': 'wl-copy --foreground --type text/plain', + \ '*': 'wl-copy --foreground --type text/plain --primary', + \ }, + \ 'paste': { + \ '+': {-> systemlist('wl-paste --no-newline | tr -d "\r"')}, + \ '*': {-> systemlist('wl-paste --no-newline --primary | tr -d "\r"')}, + \ }, + \ 'cache_enabled': 1, + \ } + +" Copy filenames +nnor yfp :let @+=expand("%:p") " Mnemonic: Yank File path +nnor yfn :let @+=expand("%") " Mnemonic: Yank File name diff --git a/modules/terminal-life/nvim/default.nix b/modules/terminal-life/nvim/default.nix new file mode 100644 index 00000000..c4268a9f --- /dev/null +++ b/modules/terminal-life/nvim/default.nix @@ -0,0 +1,142 @@ +{ config, pkgs, ... }: +let + psCfg = config.pub-solar; + xdg = config.home-manager.users."${psCfg.user.name}".xdg; + + sonokai = pkgs.vimUtils.buildVimPlugin { + name = "sonokai"; + src = pkgs.fetchFromGitHub { + owner = "sainnhe"; + repo = "sonokai"; + rev = "51e7ee8b13f9c2e4eae33f8d745eaa1f320b0ae6"; + sha256 = "0svqr6dnpk2p5qhb6j0rllns8f0f4886wxpx69wgazjx84bx728i"; + }; + }; + suda = pkgs.vimUtils.buildVimPlugin { + name = "suda"; + src = pkgs.fetchFromGitHub { + owner = "lambdalisue"; + repo = "suda.vim"; + rev = "fbb138f5090c3db4dabeba15326397a09df6b73b"; + sha256 = "ztZ5UPd2y4Mkore/QLfMCwjM0Qy4eWCOw535NzDSfgY="; + }; + }; + workspace = pkgs.vimUtils.buildVimPlugin { + name = "vim-workspace"; + src = pkgs.fetchFromGitHub { + owner = "thaerkh"; + repo = "vim-workspace"; + rev = "faa835406990171bbbeff9254303dad49bad17cb"; + sha256 = "w6CcFcIplwUVcvx54rbTwThBxus1k7yHot2TpdNQ61M="; + }; + }; + beautify = pkgs.vimUtils.buildVimPlugin { + name = "vim-beautify"; + src = pkgs.fetchFromGitHub { + owner = "zeekay"; + repo = "vim-beautify"; + rev = "e0691483927dc5a0c051433602397419f9628623"; + sha256 = "QPTCl6KaGcAjTS5yVDov9yxmv0fDaFoPLMsrtVIG6GQ="; + }; + }; +in +{ + enable = true; + + package = pkgs.neovim-nightly; + + viAlias = true; + vimAlias = true; + vimdiffAlias = true; + + withNodeJs = true; + withRuby = true; + withPython3 = true; + + extraConfig = builtins.concatStringsSep "\n" [ + '' + " Persistent undo + set undofile + set undodir=${xdg.cacheHome}/nvim/undo + + set backupdir=${xdg.dataHome}/nvim/backup + set directory=${xdg.dataHome}/nvim/swap/ + '' + (builtins.readFile ./init.vim) + (builtins.readFile ./plugins.vim) + (builtins.readFile ./clipboard.vim) + (builtins.readFile ./ui.vim) + (builtins.readFile ./quickfixopenall.vim) + (builtins.readFile ./lsp.vim) + ]; + + extraPackages = with pkgs; [ + nodejs + code-minimap + nodePackages.bash-language-server + nodePackages.dockerfile-language-server-nodejs + nodePackages.svelte-language-server + nodePackages.typescript-language-server + nodePackages.typescript + nodePackages.vim-language-server + nodePackages.vue-language-server + nodePackages.yaml-language-server + nodePackages.vscode-json-languageserver-bin + nodePackages.vscode-html-languageserver-bin + nodePackages.vscode-css-languageserver-bin + python3Full + python-language-server + solargraph + rust-analyzer + ctags + ccls + rnix-lsp + terraform-ls + ]; + + plugins = with pkgs.vimPlugins; [ + nvim-lspconfig + lsp_extensions-nvim + completion-nvim + + suda + ack-vim + syntastic + airline + workspace + editorconfig-vim + vim-vinegar + vim-gutentags + minimap-vim + nnn-vim + + sonokai + + fugitive + vim-gitgutter + vimagit + + vim-highlightedyank + fzf-vim + fzfWrapper + + beautify + vim-surround + + vim-sensible + vim-bufkill + + ansible-vim + emmet-vim + rust-vim + vim-go + vim-vue + vim-javascript + vim-json + vim-markdown + yats-vim + vim-ruby + vim-toml + vim-nix + ]; +} diff --git a/modules/terminal-life/nvim/init.vim b/modules/terminal-life/nvim/init.vim new file mode 100644 index 00000000..b32a5022 --- /dev/null +++ b/modules/terminal-life/nvim/init.vim @@ -0,0 +1,143 @@ +set nocompatible " be iMproved, required +filetype indent plugin on " required + +set modeline +set modelines=1 +set nowrap + +set viminfo='100,<100,s20 " vim file history + +set hidden + +set expandtab +set shiftwidth=2 +set number +set relativenumber + +set undolevels=1000 +set undoreload=10000 + +set updatetime=300 + +let mapleader = " " + +nmap :w +imap :w +vmap gv + +noremap y "+y +noremap p "+p + +noremap i +noremap j +noremap k +noremap h i + +vnoremap K L +vnoremap I H +vnoremap H I + +nnoremap K L +nnoremap I H +nnoremap H I + +map i :wincmd k +map j :wincmd h +map k :wincmd j +map l :wincmd l + +map I :wincmd K +map J :wincmd H +map K :wincmd J +map L :wincmd L + +" replay macro for each line of a visual selection +xnoremap @q :normal @q +xnoremap @@ :normal @@ + +" reselect and re-yank any text that is pasted in visual mode +xnoremap p pgvy + +" Escape overwrite +inoremap jj + +" Open new buffer +nmap T :enew + +" Move to the next buffer +nmap l :bnext + +" Move to the previous buffer +nmap j :bprevious + +" Close the current buffer and move to the previous one +" This replicates the idea of closing a tab +nmap q :bp bd # + +" Show all open buffers and their status +nmap bl :ls + +" Mapping selecting mappings +nmap (fzf-maps-n) +xmap (fzf-maps-x) +omap (fzf-maps-o) + +nmap :Files +imap :Files + +" Insert mode completion +imap (fzf-complete-word) +imap (fzf-complete-path) +imap (fzf-complete-file) +imap (fzf-complete-line) + +" Clear quickfix shortcut +nmap c :ccl + +" netrw +let g:netrw_fastbrowse=0 + +" fzf with file preview +command! -bang -nargs=? -complete=dir Files + \ call fzf#vim#files(, fzf#vim#with_preview(), 0) +"command! -bang -nargs=? -complete=dir Files +" \ call fzf#vim#files(, fzf#vim#with_preview({'options': '--preview "' . "grep -Pzo '.*See docs/COPYRIGHT.rdoc for more details(.*\n)*' {}" . '"'}), 0) + +" Auto-FMT rust code on save +let g:rustfmt_autosave = 1 + +" Indenting in html template tags +let g:html_indent_style1 = "inc" + +" yank highlight duration +let g:highlightedyank_highlight_duration = 200 + +" Markdown options +let g:vim_markdown_folding_disabled = 1 + +" Haskell options +let g:haskell_enable_quantification = 1 " to enable highlighting of `forall` +let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec` +let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc` +let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern` +let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles +let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static` +let g:haskell_backpack = 1 " to enable highlighting of backpack keywords + +" Emmet +let g:user_emmet_leader_key='' + +" Minimap settings +let g:minimap_auto_start = 1 + +" Ack +if executable('ag') + let g:ackprg = 'ag --vimgrep' +endif + +" Remember cursor position +" Vim jumps to the last position when reopening a file +if has("autocmd") + au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif +endif + diff --git a/modules/terminal-life/nvim/lsp.vim b/modules/terminal-life/nvim/lsp.vim new file mode 100644 index 00000000..600131d7 --- /dev/null +++ b/modules/terminal-life/nvim/lsp.vim @@ -0,0 +1,116 @@ +" Set completeopt to have a better completion experience +" :help completeopt +" menuone: popup even when there's only one match +" noinsert: Do not insert text until a selection is made +" noselect: Do not select, force user to select one from the menu +set completeopt=menuone,noinsert,noselect + +" Avoid showing extra messages when using completion +set shortmess+=c + +" Configure neovim 5 experimental LSPs +" https://github.com/neovim/nvim-lspconfig +" https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md +" https://gitlab.com/Iron_E/dotfiles/-/blob/master/.config/nvim/lua/_config/plugin/nvim_lsp.lua +lua < g[ PrevDiagnosticCycle +" nnoremap g] NextDiagnosticCycle + +" have a fixed column for the diagnostics to appear in +" this removes the jitter when warnings/errors flow in +set signcolumn=yes + +" NeoVim 0.5 Code navigation shortcuts +nnoremap gd lua vim.lsp.buf.definition() +nnoremap K lua vim.lsp.buf.hover() +nnoremap gD lua vim.lsp.buf.implementation() +nnoremap lua vim.lsp.buf.signature_help() +nnoremap 1gD lua vim.lsp.buf.type_definition() +nnoremap gr lua vim.lsp.buf.references() +nnoremap g0 lua vim.lsp.buf.document_symbol() +nnoremap gW lua vim.lsp.buf.workspace_symbol() +nnoremap lua vim.lsp.buf.declaration() diff --git a/modules/terminal-life/nvim/plugins.vim b/modules/terminal-life/nvim/plugins.vim new file mode 100644 index 00000000..eb5a5c51 --- /dev/null +++ b/modules/terminal-life/nvim/plugins.vim @@ -0,0 +1,41 @@ +" Happy yaml configuration +au! BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml +autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab + +" Golang +" Go test shortcut +nmap got :GoTest + +" Go formatting +autocmd FileType go setlocal noexpandtab shiftwidth=4 tabstop=4 softtabstop=4 nolist + +" vim-go disable text-objects +let g:go_textobj_enabled = 0 + +" disable vim-go :GoDef short cut (gd) +" this is handled by LanguageClient [LC] +let g:go_def_mapping_enabled = 0 + +" GitGutter and vim Magit +" inspired by: https://jakobgm.com/posts/vim/git-integration/ +" Don't map gitgutter keys automatically, set them ourselves +let g:gitgutter_map_keys = 0 + +" Jump between hunks +nmap gn (GitGutterNextHunk) " git next +nmap gp (GitGutterPrevHunk) " git previous + +" Hunk-add and hunk-revert for chunk staging +nmap ga (GitGutterStageHunk) " git add (chunk) +nmap gu (GitGutterUndoHunk) " git undo (chunk) + +" Open vimagit pane +nnoremap gs :Magit " git status + +" Push to remote +nnoremap gP :! git push " git Push + +" Quick conflict resolution in git mergetool nvim +" http://vimcasts.org/episodes/fugitive-vim-resolving-merge-conflicts-with-vimdiff/ +nmap [ :diffget //2 +nmap ] :diffget //3 diff --git a/modules/terminal-life/nvim/quickfixopenall.vim b/modules/terminal-life/nvim/quickfixopenall.vim new file mode 100644 index 00000000..6b4d8445 --- /dev/null +++ b/modules/terminal-life/nvim/quickfixopenall.vim @@ -0,0 +1,20 @@ +"Usage: +" 1. Perform a vimgrep search +" :vimgrep /def/ *.rb +" 2. Issue QuickFixOpenAll command +" :QuickFixOpenAll +function! QuickFixOpenAll() + if empty(getqflist()) + return + endif + let s:prev_val = "" + for d in getqflist() + let s:curr_val = bufname(d.bufnr) + if (s:curr_val != s:prev_val) + exec "edit " . s:curr_val + endif + let s:prev_val = s:curr_val + endfor +endfunction + +command! QuickFixOpenAll call QuickFixOpenAll() diff --git a/modules/terminal-life/nvim/ui.vim b/modules/terminal-life/nvim/ui.vim new file mode 100644 index 00000000..0071792f --- /dev/null +++ b/modules/terminal-life/nvim/ui.vim @@ -0,0 +1,16 @@ +let g:base16_shell_path = $XDG_CONFIG_HOME . "/zsh/base16.sh" +let base16colorspace = 256 +set termguicolors +let g:sonokai_style = 'shusia' +let g:sonokai_enable_italic = 1 +let g:sonokai_disable_italic_comment = 1 +let g:sonokai_transparent_background = 1 +colorscheme sonokai +set background=dark + +let g:airline#extensions#tabline#enabled = 1 " Enable the list of buffers +let g:airline#extensions#tabline#fnamemod = ':t' " Show just the filename +let g:airline#extensions#tabline#formatter = 'unique_tail_improved' +let g:airline_powerline_fonts = 1 " Use powerline fonts +let g:airline_theme = 'sonokai' + diff --git a/modules/terminal-life/zsh/base16.zsh b/modules/terminal-life/zsh/base16.zsh new file mode 100644 index 00000000..3686b98d --- /dev/null +++ b/modules/terminal-life/zsh/base16.zsh @@ -0,0 +1,126 @@ +#!/bin/sh +# base16-shell (https://github.com/chriskempson/base16-shell) +# Base16 Shell template by Chris Kempson (http://chriskempson.com) +# Burn scheme by Benjamin Bädorf + +color00="1a/18/1a" # Base 00 - Black +color01="f8/5e/84" # Base 08 - Red +color02="9e/cd/6f" # Base 0B - Green +color03="e5/c4/63" # Base 0A - Yellow +color04="7a/cc/d7" # Base 0D - Blue +color05="ab/9d/f2" # Base 0E - Magenta +color06="ef/90/62" # Base 0C - Cyan +color07="e3/e1/e4" # Base 05 - White +color08="94/94/94" # Base 03 - Bright Black +color09=$color01 # Base 08 - Bright Red +color10=$color02 # Base 0B - Bright Green +color11=$color03 # Base 0A - Bright Yellow +color12=$color04 # Base 0D - Bright Blue +color13=$color05 # Base 0E - Bright Magenta +color14=$color06 # Base 0C - Bright Cyan +color15="ff/5f/5f" # Base 07 - Bright White +color16="df/59/23" # Base 09 +color17="d7/00/00" # Base 0F +color18="2d/2a/2e" # Base 01 +color19="30/30/30" # Base 02 +color20="d3/d1/d4" # Base 04 +color21="30/30/30" # Base 06 +color_foreground="e3/e1/e4" # Base 05 +color_background="1a/18/1a" # Base 00 + +if [ -n "$TMUX" ]; then + # Tell tmux to pass the escape sequences through + # (Source: http://permalink.gmane.org/gmane.comp.terminal-emulators.tmux.user/1324) + put_template() { printf '\033Ptmux;\033\033]4;%d;rgb:%s\033\033\\\033\\' $@; } + put_template_var() { printf '\033Ptmux;\033\033]%d;rgb:%s\033\033\\\033\\' $@; } + put_template_custom() { printf '\033Ptmux;\033\033]%s%s\033\033\\\033\\' $@; } +elif [ "${TERM%%[-.]*}" = "screen" ]; then + # GNU screen (screen, screen-256color, screen-256color-bce) + put_template() { printf '\033P\033]4;%d;rgb:%s\007\033\\' $@; } + put_template_var() { printf '\033P\033]%d;rgb:%s\007\033\\' $@; } + put_template_custom() { printf '\033P\033]%s%s\007\033\\' $@; } +elif [ "${TERM%%-*}" = "linux" ]; then + put_template() { [ $1 -lt 16 ] && printf "\e]P%x%s" $1 $(echo $2 | sed 's/\///g'); } + put_template_var() { true; } + put_template_custom() { true; } +else + put_template() { printf '\033]4;%d;rgb:%s\033\\' $@; } + put_template_var() { printf '\033]%d;rgb:%s\033\\' $@; } + put_template_custom() { printf '\033]%s%s\033\\' $@; } +fi + +# 16 color space +put_template 0 $color00 +put_template 1 $color01 +put_template 2 $color02 +put_template 3 $color03 +put_template 4 $color04 +put_template 5 $color05 +put_template 6 $color06 +put_template 7 $color07 +put_template 8 $color08 +put_template 9 $color09 +put_template 10 $color10 +put_template 11 $color11 +put_template 12 $color12 +put_template 13 $color13 +put_template 14 $color14 +put_template 15 $color15 + +# 256 color space +put_template 16 $color16 +put_template 17 $color17 +put_template 18 $color18 +put_template 19 $color19 +put_template 20 $color20 +put_template 21 $color21 + +# foreground / background / cursor color +if [ -n "$ITERM_SESSION_ID" ]; then + # iTerm2 proprietary escape codes + put_template_custom Pg e3e1e4 # foreground + put_template_custom Ph 1a181a # background + put_template_custom Pi e3e1e4 # bold color + put_template_custom Pj 303030 # selection color + put_template_custom Pk e3e1e4 # selected text color + put_template_custom Pl e3e1e4 # cursor + put_template_custom Pm 1a181a # cursor text +else + put_template_var 10 $color_foreground + if [ "$BASE16_SHELL_SET_BACKGROUND" != false ]; then + put_template_var 11 $color_background + if [ "${TERM%%-*}" = "rxvt" ]; then + put_template_var 708 $color_background # internal border (rxvt) + fi + fi + put_template_custom 12 ";7" # cursor (reverse video) +fi + +# clean up +unset -f put_template +unset -f put_template_var +unset -f put_template_custom +unset color00 +unset color01 +unset color02 +unset color03 +unset color04 +unset color05 +unset color06 +unset color07 +unset color08 +unset color09 +unset color10 +unset color11 +unset color12 +unset color13 +unset color14 +unset color15 +unset color16 +unset color17 +unset color18 +unset color19 +unset color20 +unset color21 +unset color_foreground +unset color_background diff --git a/modules/terminal-life/zsh/default.nix b/modules/terminal-life/zsh/default.nix new file mode 100644 index 00000000..0ff87812 --- /dev/null +++ b/modules/terminal-life/zsh/default.nix @@ -0,0 +1,94 @@ +{ config, pkgs, ... }: +let + psCfg = config.pub-solar; + xdg = config.home-manager.users."${psCfg.user.name}".xdg; +in +{ + enable = true; + enableAutosuggestions = true; + enableCompletion = true; + dotDir = ".config/zsh"; + + history = { + ignoreDups = true; + expireDuplicatesFirst = true; + ignoreSpace = true; + path = "$HOME/.local/share/zsh/zsh_history"; + save = 10000; + size = 10000; + }; + + shellAliases = { + nano = "nvim"; + vi = "nvim"; + vim = "nvim"; + mutt = "neomutt"; + ls = "exa"; + la = "exa --group-directories-first -lag"; + fm = "vifm ."; + vifm = "vifm ."; + wget = "wget --hsts-file=$XDG_CACHE_HOME/wget-hsts"; + irssi = "irssi --config=$XDG_CONFIG_HOME/irssi/config --home=$XDG_DATA_HOME/irssi"; + drone = "DRONE_TOKEN=$(secret-tool lookup drone token) drone"; + no = "manix \"\" | grep '^# ' | sed 's/^# \(.*\) (.*/\1/;s/ (.*//;s/^# //' | fzf --preview=\"manix '{}'\" | xargs manix"; + # fix nixos-option + nixos-option = "nixos-option -I nixpkgs=/etc/nixos/lib/compat"; + }; + zplug = { + enable = true; + plugins = [ + { + name = "plugins/z"; + tags = [ "from:oh-my-zsh" ]; + } + { + name = "romkatv/powerlevel10k"; + tags = [ "as:theme" "depth:1" ]; + } + { name = "zdharma/fast-syntax-highlighting"; } + { name = "chisui/zsh-nix-shell"; } + ]; + }; + + initExtra = '' + bindkey -v + bindkey -v 'jj' vi-cmd-mode + bindkey -a 'i' up-line + bindkey -a 'k' down-line + bindkey -a 'j' backward-char + bindkey -a 'h' vi-insert + bindkey '^[[H' beginning-of-line + bindkey '^[[F' end-of-line + bindkey '^R' history-incremental-pattern-search-backward + bindkey '^ ' autosuggest-accept + bindkey '^q' push-line-or-edit + + bindkey '^R' fzf-history-widget + + # ArrowUp/Down start searching history with current input + autoload -U history-search-end + zle -N history-beginning-search-backward-end history-search-end + zle -N history-beginning-search-forward-end history-search-end + bindkey "^[[A" history-beginning-search-backward-end + bindkey "^[[B" history-beginning-search-forward-end + bindkey "^P" history-beginning-search-backward-end + bindkey "^N" history-beginning-search-forward-end + + # MAKE CTRL+S WORK IN VIM + stty -ixon + stty erase '^?' + + # If a command is not found, show me where it is + source ${pkgs.nix-index}/etc/profile.d/command-not-found.sh + '' + + builtins.readFile ./base16.zsh + + builtins.readFile ./p10k.zsh + + + '' + source ${pkgs.fzf}/share/fzf/key-bindings.zsh + source ${pkgs.fzf}/share/fzf/completion.zsh + source ${pkgs.git-bug}/share/zsh/site-functions/git-bug + eval "$(direnv hook zsh)" + '' + + builtins.readFile ./fzf.zsh; +} diff --git a/modules/terminal-life/zsh/fzf.zsh b/modules/terminal-life/zsh/fzf.zsh new file mode 100644 index 00000000..78b0fb86 --- /dev/null +++ b/modules/terminal-life/zsh/fzf.zsh @@ -0,0 +1,58 @@ +# Use ~~ as the trigger sequence instead of the default ** +export FZF_COMPLETION_TRIGGER='~~' + +# Options to fzf command +export FZF_COMPLETION_OPTS='--border --info=inline' + +__fzfcmd() { + echo "fzf" +} + +# ctrl+r - Paste the selected command from history into the command line +fzf-history-widget() { + local selected num + setopt localoptions noglobsubst noposixbuiltins pipefail HIST_FIND_NO_DUPS 2> /dev/null + + selected=( $(fc -rl 1 | + FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS --query=${(qqq)LBUFFER} +m" $(__fzfcmd)) ) + local ret=$? + if [ -n "$selected" ]; then + num=$selected[1] + if [ -n "$num" ]; then + zle vi-fetch-history -n $num + fi + fi + zle redisplay + typeset -f zle-line-init >/dev/null && zle zle-line-init + return $ret +} +zle -N fzf-history-widget +bindkey '^R' fzf-history-widget + +# Use fd (https://github.com/sharkdp/fd) instead of the default find +# command for listing path candidates. +# - The first argument to the function ($1) is the base path to start traversal +# - See the source code (completion.{bash,zsh}) for the details. +_fzf_compgen_path() { + fd --hidden --follow --exclude ".git" . "$1" +} + +# Use fd to generate the list for directory completion +_fzf_compgen_dir() { + fd --type d --hidden --follow --exclude ".git" . "$1" +} + +# (EXPERIMENTAL) Advanced customization of fzf options via _fzf_comprun function +# - The first argument to the function is the name of the command. +# - You should make sure to pass the rest of the arguments to fzf. +_fzf_comprun() { + local command=$1 + shift + + case "$command" in + cd) fzf "$@" --preview 'tree -C {} | head -200' ;; + export|unset) fzf "$@" --preview "eval 'echo \$'{}" ;; + ssh) fzf "$@" --preview 'dig {}' ;; + *) fzf "$@" ;; + esac +} diff --git a/modules/terminal-life/zsh/p10k.zsh b/modules/terminal-life/zsh/p10k.zsh new file mode 100644 index 00000000..64503895 --- /dev/null +++ b/modules/terminal-life/zsh/p10k.zsh @@ -0,0 +1,934 @@ +# Generated by Powerlevel10k configuration wizard on 2020-04-18 at 01:15 CEST. +# Based on romkatv/powerlevel10k/config/p10k-classic.zsh, checksum 30399. +# Wizard options: powerline, classic, unicode, darkest, 24h time, angled separators, +# sharp heads, sharp tails, 1 line, compact, concise, transient_prompt, +# instant_prompt=verbose. +# Type `p10k configure` to generate another config. +# +# Config for Powerlevel10k with classic powerline prompt style. Type `p10k configure` to generate +# your own config based on it. +# +# Tip: Looking for a nice color? Here's a one-liner to print colormap. +# +# for i in {0..255}; do print -Pn "%K{$i} %k%F{$i}${(l:3::0:)i}%f " ${${(M)$((i%6)):#3}:+$'\n'}; done + +# Temporarily change options. +'builtin' 'local' '-a' 'p10k_config_opts' +[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') +[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') +[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') +'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' + +() { + emulate -L zsh -o extended_glob + + # Unset all configuration options. This allows you to apply configuration changes without + # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`. + unset -m 'POWERLEVEL9K_*' + + # Zsh >= 5.1 is required. + autoload -Uz is-at-least && is-at-least 5.1 || return + + # The list of segments shown on the left. Fill it with the most important segments. + typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( + ssh + context + dir # current directory + vcs # git status + # prompt_char # prompt symbol + ) + + # The list of segments shown on the right. Fill it with less important segments. + # Right prompt on the last prompt line (where you are typing your commands) gets + # automatically hidden when the input line reaches it. Right prompt above the + # last prompt line gets hidden if it would overlap with left prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=( + vi_mode # vi mode (you don't need this if you've enabled prompt_char) + status # exit code of the last command + command_execution_time # duration of the last command + background_jobs # presence of background jobs + direnv # direnv status (https://direnv.net/) + vim_shell # vim shell indicator (:sh) + triton # show the current triton profile + nix_shell # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) + watson + # kubecontext # current kubernetes context (https://kubernetes.io/) + # terraform # terraform workspace (https://www.terraform.io) + # aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) + # aws_eb_env # aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) + # azure # azure account name (https://docs.microsoft.com/en-us/cli/azure) + # gcloud # google cloud cli account and project (https://cloud.google.com/) + # google_app_cred # google application credentials (https://cloud.google.com/docs/authentication/production) + # context # user@hostname + # ranger # ranger shell (https://github.com/ranger/ranger) + # nnn # nnn shell (https://github.com/jarun/nnn) + # midnight_commander # midnight commander shell (https://midnight-commander.org/) + # vpn_ip # virtual private network indicator + # load # CPU load + # disk_usage # disk usage + # ram # free RAM + # swap # used swap + # todo # todo items (https://github.com/todotxt/todo.txt-cli) + # timewarrior # timewarrior tracking status (https://timewarrior.net/) + # taskwarrior # taskwarrior task count (https://taskwarrior.org/) + # time # current time + # ip # ip address and bandwidth usage for a specified network interface + # public_ip # public IP address + # proxy # system-wide http/https/ftp proxy + # battery # internal battery + # wifi # wifi speed + # example # example user-defined segment (see prompt_example function below) + ) + + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND="black" + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND="yellow" + typeset -g POWERLEVEL9K_VI_INSERT_MODE_STRING="" + typeset -g POWERLEVEL9K_VI_COMMAND_MODE_STRING="CMD" + + # Defines character set used by powerlevel10k. It's best to let `p10k configure` set it for you. + typeset -g POWERLEVEL9K_MODE=powerline + # When set to `moderate`, some icons will have an extra space after them. This is meant to avoid + # icon overlap when using non-monospace fonts. When set to `none`, spaces are not added. + typeset -g POWERLEVEL9K_ICON_PADDING=none + + # When set to true, icons appear before content on both sides of the prompt. When set + # to false, icons go after content. If empty or not set, icons go before content in the left + # prompt and after content in the right prompt. + # + # You can also override it for a specific segment: + # + # POWERLEVEL9K_STATUS_ICON_BEFORE_CONTENT=false + # + # Or for a specific segment in specific state: + # + # POWERLEVEL9K_DIR_NOT_WRITABLE_ICON_BEFORE_CONTENT=false + typeset -g POWERLEVEL9K_ICON_BEFORE_CONTENT= + + # Add an empty line before each prompt. + typeset -g POWERLEVEL9K_PROMPT_ON_NEWLINE=true + typeset -g POWERLEVEL9K_RPROMPT_ON_NEWLINE=false + + # Connect left prompt lines with these symbols. You'll probably want to use the same color + # as POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND below. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX='' + typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_PREFIX='%238F' + typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX='%238F❯ ' + # Connect right prompt lines with these symbols. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_SUFFIX='%238F' + typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_SUFFIX='%238F' + typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_SUFFIX='%238F' + + # Filler between left and right prompt on the first prompt line. You can set it to ' ', '·' or + # '─'. The last two make it easier to see the alignment between left and right prompt and to + # separate prompt from command output. You might want to set POWERLEVEL9K_PROMPT_ADD_NEWLINE=false + # for more compact prompt if using using this option. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_BACKGROUND= + if [[ $POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR != ' ' ]]; then + # The color of the filler. You'll probably want to match the color of POWERLEVEL9K_MULTILINE + # ornaments defined above. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND=238 + # Start filler from the edge of the screen if there are no left segments on the first line. + typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_FIRST_SEGMENT_END_SYMBOL='%{%}' + # End filler on the edge of the screen if there are no right segments on the first line. + typeset -g POWERLEVEL9K_EMPTY_LINE_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='%{%}' + fi + + # Default background color. + typeset -g POWERLEVEL9K_BACKGROUND=none + + # Separator between same-color segments on the left. + typeset -g POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR='%242F\uE0B1' + # Separator between same-color segments on the right. + typeset -g POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR='%242F\uE0B3' + # Separator between different-color segments on the left. + typeset -g POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='\uE0B0' + # Separator between different-color segments on the right. + typeset -g POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR='\uE0B2' + # The right end of left prompt. + typeset -g POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='\uE0B0' + # The left end of right prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='\uE0B2' + # The left end of left prompt. + typeset -g POWERLEVEL9K_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL='\uE0B2' + # The right end of right prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL='\uE0B0' + # Left prompt terminator for lines without any segments. + typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL= + + #################################[ os_icon: os identifier ]################################## + # OS identifier color. + typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND=255 + # Custom icon. + # typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='⭐' + + ################################[ prompt_char: prompt symbol ]################################ + # Transparent background. + typeset -g POWERLEVEL9K_PROMPT_CHAR_BACKGROUND= + # Green prompt symbol if the last command succeeded. + typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=1 + # Red prompt symbol if the last command failed. + typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=17 + # Default prompt symbol. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='❯' + # Prompt symbol in command vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='❮' + # Prompt symbol in visual vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='Ⅴ' + # Prompt symbol in overwrite vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='▶' + typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true + # No line terminator if prompt_char is the last segment. + typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL= + # No line introducer if prompt_char is the first segment. + typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= + # No surrounding whitespace. + typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_{LEFT,RIGHT}_WHITESPACE= + + ##################################[ dir: current directory ]################################## + typeset -g POWERLEVEL9K_{ETC,FOLDER,HOME,HOME_SUB}_ICON= + typeset -g POWERLEVEL9K_DIR_{ETC,HOME,HOME_SUBFOLDER,DEFAULT,NOT_WRITABLE}_BACKGROUND=1 + typeset -g POWERLEVEL9K_DIR_{ETC,HOME,HOME_SUBFOLDER,DEFAULT,NOT_WRITABLE}_FOREGROUND=0 + typeset -g POWERLEVEL9K_DIR_WRITABLE_FORBIDDEN_VISUAL_IDENTIFIER_COLOR=17 + + typeset -g POWERLEVEL9K_DIR_{ETC,DEFAULT}_BACKGROUND=15 + typeset -g POWERLEVEL9K_DIR_{HOME,HOME_SUBFOLDER}_BACKGROUND=1 + typeset -g POWERLEVEL9K_DIR_NOT_WRITABLE_BACKGROUND=1 + + typeset -g POWERLEVEL9K_DIR_ANCHOR_BOLD=true + # Don't shorten directories that contain any of these files. They are anchors. + local anchor_files=( + .bzr + .citc + .git + .hg + .node-version + .python-version + .go-version + .ruby-version + .lua-version + .java-version + .perl-version + .php-version + .tool-version + .shorten_folder_marker + .svn + .terraform + CVS + Cargo.toml + composer.json + go.mod + package.json + stack.yaml + ) + typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})" + # If set to true, remove everything before the last (deepest) subdirectory that contains files + # matching $POWERLEVEL9K_SHORTEN_FOLDER_MARKER. For example, when the current directory is + # /foo/bar/git_repo/baz, prompt will display git_repo/baz. This assumes that /foo/bar/git_repo + # contains a marker (.git) and other directories don't. + typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false + # Don't shorten this many last directory segments. They are anchors. + typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=100 + # Shorten directory if it's longer than this even if there is space for it. The value can + # be either absolute (e.g., '80') or a percentage of terminal width (e.g, '50%'). If empty, + # directory will be shortened only when prompt doesn't fit or when other parameters demand it + # (see POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS and POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT below). + # If set to `0`, directory will always be shortened to its minimum length. + typeset -g POWERLEVEL9K_DIR_MAX_LENGTH= + # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least this + # many columns for typing commands. + typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS=40 + # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least + # COLUMNS * POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT * 0.01 columns for typing commands. + typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT=50 + # If set to true, embed a hyperlink into the directory. Useful for quickly + # opening a directory in the file manager simply by clicking the link. + # Can also be handy when the directory is shortened, as it allows you to see + # the full directory that was used in previous commands. + typeset -g POWERLEVEL9K_DIR_HYPERLINK=false + + # Enable special styling for non-writable directories. + typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=true + # Show this icon when the current directory is not writable. POWERLEVEL9K_DIR_SHOW_WRITABLE + # above must be set to true for this parameter to have effect. + typeset -g POWERLEVEL9K_DIR_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='∅' + + #####################################[ vcs: git status ]###################################### + # Branch icon. Set this parameter to '\uF126 ' for the popular Powerline branch icon. + typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= + + # Untracked files icon. It's really a question mark, your font isn't broken. + # Change the value of this parameter to show a different icon. + typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' + + # Formatter for Git status. + # + # Example output: master ⇣42⇡42 *42 merge ~42 +42 !42 ?42. + # + # You can edit the function to customize how Git status looks. + # + # VCS_STATUS_* parameters are set by gitstatus plugin. See reference: + # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. + function my_git_formatter() { + emulate -L zsh + + if [[ -n $P9K_CONTENT ]]; then + # If P9K_CONTENT is not empty, use it. It's either "loading" or from vcs_info (not from + # gitstatus plugin). VCS_STATUS_* parameters are not available in this case. + typeset -g my_git_format=$P9K_CONTENT + return + fi + + if (( $1 )); then + # Styling for up-to-date Git status. + local meta='%0F' # grey foreground + local clean='%0F' # green foreground + local modified='%0F' # yellow foreground + local untracked='%0F' # blue foreground + local conflicted='%0F' # red foreground + else + # Styling for incomplete and stale Git status. + local meta='%0F' # grey foreground + local clean='%0F' # grey foreground + local modified='%0F' # grey foreground + local untracked='%0F' # grey foreground + local conflicted='%0F' # grey foreground + fi + + local res + local where # branch or tag + if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then + res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}" + where=${(V)VCS_STATUS_LOCAL_BRANCH} + elif [[ -n $VCS_STATUS_TAG ]]; then + res+="${meta}#" + where=${(V)VCS_STATUS_TAG} + fi + + # If local branch name or tag is at most 32 characters long, show it in full. + # Otherwise show the first 12 … the last 12. + # Tip: To always show local branch name in full without truncation, delete the next line. + (( $#where > 32 )) && where[13,-13]="…" + res+="${clean}${where//\%/%%}" # escape % + + # Display the current Git commit if there is no branch or tag. + # Tip: To always display the current Git commit, remove `[[ -z $where ]] &&` from the next line. + [[ -z $where ]] && res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" + + # Show tracking branch name if it differs from local branch. + if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then + res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape % + fi + + # ⇣42 if behind the remote. + (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}" + # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. + (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" " + (( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}⇡${VCS_STATUS_COMMITS_AHEAD}" + # ⇠42 if behind the push remote. + (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}" + (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" " + # ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42. + (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}⇢${VCS_STATUS_PUSH_COMMITS_AHEAD}" + # *42 if have stashes. + (( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}" + # 'merge' if the repo is in an unusual state. + [[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}" + # ~42 if have merge conflicts. + (( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}" + # +42 if have staged changes. + (( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}" + # !42 if have unstaged changes. + (( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}" + # ?42 if have untracked files. It's really a question mark, your font isn't broken. + # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon. + # Remove the next line if you don't want to see untracked files at all. + (( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}" + # "─" if the number of unstaged files is unknown. This can happen due to + # POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY (see below) being set to a non-negative number lower + # than the number of files in the Git index, or due to bash.showDirtyState being set to false + # in the repository config. The number of staged and untracked files may also be unknown + # in this case. + (( VCS_STATUS_HAS_UNSTAGED == -1 )) && res+=" ${modified}─" + + typeset -g my_git_format=$res + } + functions -M my_git_formatter 2>/dev/null + + # Don't count the number of unstaged, untracked and conflicted files in Git repositories with + # more than this many files in the index. Negative value means infinity. + # + # If you are working in Git repositories with tens of millions of files and seeing performance + # sagging, try setting POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY to a number lower than the output + # of `git ls-files | wc -l`. Alternatively, add `bash.showDirtyState = false` to the repository's + # config: `git config bash.showDirtyState false`. + typeset -g POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY=-1 + + # Don't show Git status in prompt for repositories whose workdir matches this pattern. + # For example, if set to '~', the Git repository at $HOME/.git will be ignored. + # Multiple patterns can be combined with '|': '~|~/some/dir'. + typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~' + + # Disable the default Git status formatting. + typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true + # Install our own Git status formatter. + typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter(1)))+${my_git_format}}' + typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION='${$((my_git_formatter(0)))+${my_git_format}}' + # Enable counters for staged, unstaged, etc. + typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 + + # Icon color. + typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=4 + typeset -g POWERLEVEL9K_VCS_LOADING_VISUAL_IDENTIFIER_COLOR=4 + # Custom icon. + typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION= + # Custom prefix. + # typeset -g POWERLEVEL9K_VCS_PREFIX='%244Fon ' + + # Show status of repositories of these types. You can add svn and/or hg if you are + # using them. If you do, your prompt may become slow even when your current directory + # isn't in an svn or hg reposotiry. + typeset -g POWERLEVEL9K_VCS_BACKENDS=(git) + + # These settings are used for respositories other than Git or when gitstatusd fails and + # Powerlevel10k has to fall back to using vcs_info. + typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=0 + typeset -g POWERLEVEL9K_VCS_CLEAN_BACKGROUND=2 + typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=0 + typeset -g POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND=3 + typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=0 + typeset -g POWERLEVEL9K_VCS_MODIFIED_BACKGROUND=3 + + ##########################[ status: exit code of the last command ]########################### + # Enable OK_PIPE, ERROR_PIPE and ERROR_SIGNAL status states to allow us to enable, disable and + # style them independently from the regular OK and ERROR state. + typeset -g POWERLEVEL9K_STATUS_EXTENDED_STATES=true + + # Status on success. No content, just an icon. No need to show it if prompt_char is enabled as + # it will signify success by turning green. + typeset -g POWERLEVEL9K_STATUS_OK=true + typeset -g POWERLEVEL9K_STATUS_OK_FOREGROUND=70 + typeset -g POWERLEVEL9K_STATUS_OK_VISUAL_IDENTIFIER_EXPANSION='✔' + + # Status when some part of a pipe command fails but the overall exit status is zero. It may look + # like this: 1|0. + typeset -g POWERLEVEL9K_STATUS_OK_PIPE=true + typeset -g POWERLEVEL9K_STATUS_OK_PIPE_FOREGROUND=70 + typeset -g POWERLEVEL9K_STATUS_OK_PIPE_VISUAL_IDENTIFIER_EXPANSION='✔' + + # Status when it's just an error code (e.g., '1'). No need to show it if prompt_char is enabled as + # it will signify error by turning red. + typeset -g POWERLEVEL9K_STATUS_ERROR=true + typeset -g POWERLEVEL9K_STATUS_ERROR_FOREGROUND=160 + typeset -g POWERLEVEL9K_STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION='✘' + + # Status when the last command was terminated by a signal. + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL=true + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_FOREGROUND=160 + # Use terse signal names: "INT" instead of "SIGINT(2)". + typeset -g POWERLEVEL9K_STATUS_VERBOSE_SIGNAME=false + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_VISUAL_IDENTIFIER_EXPANSION='✘' + + # Status when some part of a pipe command fails and the overall exit status is also non-zero. + # It may look like this: 1|0. + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE=true + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_FOREGROUND=160 + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION='✘' + + ###################[ command_execution_time: duration of the last command ]################### + # Show duration of the last command if takes longer than this many seconds. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3 + # Show this many fractional digits. Zero means round to seconds. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0 + # Execution time color. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=0 + # Duration format: 1d 2h 3m 4s. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s' + # Custom icon. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_VISUAL_IDENTIFIER_EXPANSION= + # Custom prefix. + # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PREFIX='%244Ftook ' + + #######################[ background_jobs: presence of background jobs ]####################### + # Don't show the number of background jobs. + typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=false + # Background jobs color. + typeset -g POWERLEVEL9K_BACKGROUND_JOBS_FOREGROUND=37 + # Custom icon. + typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION='≡' + + #######################[ direnv: direnv status (https://direnv.net/) ]######################## + # Direnv color. + typeset -g POWERLEVEL9K_DIRENV_FOREGROUND=178 + # Custom icon. + # typeset -g POWERLEVEL9K_DIRENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###############[ asdf: asdf version manager (https://github.com/asdf-vm/asdf) ]############### + # Default asdf color. Only used to display tools for which there is no color override (see below). + typeset -g POWERLEVEL9K_ASDF_FOREGROUND=66 + + # There are four parameters that can be used to hide asdf tools. Each parameter describes + # conditions under which a tool gets hidden. Parameters can hide tools but not unhide them. If at + # least one parameter decides to hide a tool, that tool gets hidden. If no parameter decides to + # hide a tool, it gets shown. + # + # Special note on the difference between POWERLEVEL9K_ASDF_SOURCES and + # POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW. Consider the effect of the following commands: + # + # asdf local python 3.8.1 + # asdf global python 3.8.1 + # + # After running both commands the current python version is 3.8.1 and its source is "local" as + # it takes precedence over "global". If POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW is set to false, + # it'll hide python version in this case because 3.8.1 is the same as the global version. + # POWERLEVEL9K_ASDF_SOURCES will hide python version only if the value of this parameter doesn't + # contain "local". + + # Hide tool versions that don't come from one of these sources. + # + # Available sources: + # + # - shell `asdf current` says "set by ASDF_${TOOL}_VERSION environment variable" + # - local `asdf current` says "set by /some/not/home/directory/file" + # - global `asdf current` says "set by /home/username/file" + # + # Note: If this parameter is set to (shell local global), it won't hide tools. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SOURCES. + typeset -g POWERLEVEL9K_ASDF_SOURCES=(shell local global) + + # If set to false, hide tool versions that are the same as global. + # + # Note: The name of this parameter doesn't reflect its meaning at all. + # Note: If this parameter is set to true, it won't hide tools. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_PROMPT_ALWAYS_SHOW. + typeset -g POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW=false + + # If set to false, hide tool versions that are equal to "system". + # + # Note: If this parameter is set to true, it won't hide tools. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_SYSTEM. + typeset -g POWERLEVEL9K_ASDF_SHOW_SYSTEM=true + + # If set to non-empty value, hide tools unless there is a file matching the specified file pattern + # in the current directory, or its parent diretory, or its grandparent directory, and so on. + # + # Note: If this parameter is set to empty value, it won't hide tools. + # Note: SHOW_ON_UPGLOB isn't specific to asdf. It works with all prompt segments. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_ON_UPGLOB. + # + # Example: Hide nodejs version when there is no package.json and no *.js files in the current + # directory, in `..`, in `../..` and so on. + # + # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.js|package.json' + typeset -g POWERLEVEL9K_ASDF_SHOW_ON_UPGLOB= + + # Ruby version from asdf. + typeset -g POWERLEVEL9K_ASDF_RUBY_FOREGROUND=168 + # typeset -g POWERLEVEL9K_ASDF_RUBY_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_RUBY_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Python version from asdf. + typeset -g POWERLEVEL9K_ASDF_PYTHON_FOREGROUND=37 + # typeset -g POWERLEVEL9K_ASDF_PYTHON_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PYTHON_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Go version from asdf. + typeset -g POWERLEVEL9K_ASDF_GOLANG_FOREGROUND=37 + # typeset -g POWERLEVEL9K_ASDF_GOLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_GOLANG_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Node.js version from asdf. + typeset -g POWERLEVEL9K_ASDF_NODEJS_FOREGROUND=70 + # typeset -g POWERLEVEL9K_ASDF_NODEJS_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Rust version from asdf. + typeset -g POWERLEVEL9K_ASDF_RUST_FOREGROUND=37 + # typeset -g POWERLEVEL9K_ASDF_RUST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_RUST_SHOW_ON_UPGLOB='*.foo|*.bar' + + # .NET Core version from asdf. + typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_FOREGROUND=134 + # typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Flutter version from asdf. + typeset -g POWERLEVEL9K_ASDF_FLUTTER_FOREGROUND=38 + # typeset -g POWERLEVEL9K_ASDF_FLUTTER_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_FLUTTER_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Lua version from asdf. + typeset -g POWERLEVEL9K_ASDF_LUA_FOREGROUND=32 + # typeset -g POWERLEVEL9K_ASDF_LUA_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_LUA_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Java version from asdf. + typeset -g POWERLEVEL9K_ASDF_JAVA_FOREGROUND=32 + # typeset -g POWERLEVEL9K_ASDF_JAVA_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_JAVA_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Perl version from asdf. + typeset -g POWERLEVEL9K_ASDF_PERL_FOREGROUND=67 + # typeset -g POWERLEVEL9K_ASDF_PERL_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PERL_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Erlang version from asdf. + typeset -g POWERLEVEL9K_ASDF_ERLANG_FOREGROUND=125 + # typeset -g POWERLEVEL9K_ASDF_ERLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_ERLANG_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Elixir version from asdf. + typeset -g POWERLEVEL9K_ASDF_ELIXIR_FOREGROUND=129 + # typeset -g POWERLEVEL9K_ASDF_ELIXIR_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_ELIXIR_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Postgres version from asdf. + typeset -g POWERLEVEL9K_ASDF_POSTGRES_FOREGROUND=31 + # typeset -g POWERLEVEL9K_ASDF_POSTGRES_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_POSTGRES_SHOW_ON_UPGLOB='*.foo|*.bar' + + # PHP version from asdf. + typeset -g POWERLEVEL9K_ASDF_PHP_FOREGROUND=99 + # typeset -g POWERLEVEL9K_ASDF_PHP_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PHP_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Haskell version from asdf. + typeset -g POWERLEVEL9K_ASDF_HASKELL_FOREGROUND=172 + # typeset -g POWERLEVEL9K_ASDF_HASKELL_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_HASKELL_SHOW_ON_UPGLOB='*.foo|*.bar' + + ###########[ nix_shell ]########### + # # Nix shell color. + typeset -g POWERLEVEL9K_NIX_SHELL_FOREGROUND=74 + + # Tip: If you want to see just the icon without "pure" and "impure", uncomment the next line. + typeset -g POWERLEVEL9K_NIX_SHELL_CONTENT_EXPANSION='' + + # Custom icon. + typeset -g POWERLEVEL9K_NIX_SHELL_VISUAL_IDENTIFIER_EXPANSION='nix' + + ###########[ vi_mode: vi mode (you don't need this if you've enabled prompt_char) ]########### + # Text and color for normal (a.k.a. command) vi mode. + typeset -g POWERLEVEL9K_VI_COMMAND_MODE_STRING=CMD + typeset -g POWERLEVEL9K_VI_MODE_NORMAL_FOREGROUND=4 + # Text and color for visual vi mode. + typeset -g POWERLEVEL9K_VI_VISUAL_MODE_STRING=VIS + typeset -g POWERLEVEL9K_VI_MODE_VISUAL_FOREGROUND=3 + # Text and color for overtype (a.k.a. overwrite and replace) vi mode. + typeset -g POWERLEVEL9K_VI_OVERWRITE_MODE_STRING=OVR + typeset -g POWERLEVEL9K_VI_MODE_OVERWRITE_FOREGROUND=2 + # Text and color for insert vi mode. + typeset -g POWERLEVEL9K_VI_INSERT_MODE_STRING= + typeset -g POWERLEVEL9K_VI_MODE_INSERT_FOREGROUND=7 + + ##################################[ context: user@hostname ]################################## + typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=17 + # Context color in SSH without privileges. + typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_FOREGROUND=7 + # Default context color (no privileges, no SSH). + typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=7 + + # Context format when running with privileges: bold user@hostname. + typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%B%n@%m' + # Context format when in SSH without privileges: user@hostname. + typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_TEMPLATE='%n@%m' + # Default context format (no privileges, no SSH): user@hostname. + typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%n@%m' + + ###[ virtualenv: python virtual environment (https://docs.python.org/3/library/venv.html) ]### + # Python virtual environment color. + typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=37 + # Don't show Python version next to the virtual environment name. + typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false + # Separate environment name from Python version only with a space. + typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER= + # Custom icon. + # typeset -g POWERLEVEL9K_VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #####################[ anaconda: conda environment (https://conda.io/) ]###################### + # Anaconda environment color. + typeset -g POWERLEVEL9K_ANACONDA_FOREGROUND=37 + # Don't show Python version next to the anaconda environment name. + typeset -g POWERLEVEL9K_ANACONDA_SHOW_PYTHON_VERSION=false + # Separate environment name from Python version only with a space. + typeset -g POWERLEVEL9K_ANACONDA_{LEFT,RIGHT}_DELIMITER= + # Custom icon. + # typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################[ pyenv: python environment (https://github.com/pyenv/pyenv) ]################ + # Pyenv color. + typeset -g POWERLEVEL9K_PYENV_FOREGROUND=37 + # Hide python version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PYENV_SOURCES=(shell local global) + # If set to false, hide python version if it's the same as global: + # $(pyenv version-name) == $(pyenv global). + typeset -g POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide python version if it's equal to "system". + typeset -g POWERLEVEL9K_PYENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################[ goenv: go environment (https://github.com/syndbg/goenv) ]################ + # Goenv color. + typeset -g POWERLEVEL9K_GOENV_FOREGROUND=37 + # Hide go version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_GOENV_SOURCES=(shell local global) + # If set to false, hide go version if it's the same as global: + # $(goenv version-name) == $(goenv global). + typeset -g POWERLEVEL9K_GOENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide go version if it's equal to "system". + typeset -g POWERLEVEL9K_GOENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_GOENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ nodenv: node.js version from nodenv (https://github.com/nodenv/nodenv) ]########## + # Nodenv color. + typeset -g POWERLEVEL9K_NODENV_FOREGROUND=70 + # Hide node version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_NODENV_SOURCES=(shell local global) + # If set to false, hide node version if it's the same as global: + # $(nodenv version-name) == $(nodenv global). + typeset -g POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide node version if it's equal to "system". + typeset -g POWERLEVEL9K_NODENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_NODENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##############[ nvm: node.js version from nvm (https://github.com/nvm-sh/nvm) ]############### + # Nvm color. + typeset -g POWERLEVEL9K_NVM_FOREGROUND=70 + # Custom icon. + # typeset -g POWERLEVEL9K_NVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ############[ nodeenv: node.js environment (https://github.com/ekalinin/nodeenv) ]############ + # Nodeenv color. + typeset -g POWERLEVEL9K_NODEENV_FOREGROUND=70 + # Don't show Node version next to the environment name. + typeset -g POWERLEVEL9K_NODEENV_SHOW_NODE_VERSION=false + # Separate environment name from Node version only with a space. + typeset -g POWERLEVEL9K_NODEENV_{LEFT,RIGHT}_DELIMITER= + # Custom icon. + # typeset -g POWERLEVEL9K_NODEENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##############################[ node_version: node.js version ]############################### + # Node version color. + typeset -g POWERLEVEL9K_NODE_VERSION_FOREGROUND=70 + # Show node version only when in a directory tree containing package.json. + typeset -g POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_NODE_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######################[ go_version: go version (https://golang.org) ]######################## + # Go version color. + typeset -g POWERLEVEL9K_GO_VERSION_FOREGROUND=37 + # Show go version only when in a go project subdirectory. + typeset -g POWERLEVEL9K_GO_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_GO_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #################[ rust_version: rustc version (https://www.rust-lang.org) ]################## + # Rust version color. + typeset -g POWERLEVEL9K_RUST_VERSION_FOREGROUND=37 + # Show rust version only when in a rust project subdirectory. + typeset -g POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###############[ dotnet_version: .NET version (https://dotnet.microsoft.com) ]################ + # .NET version color. + typeset -g POWERLEVEL9K_DOTNET_VERSION_FOREGROUND=134 + # Show .NET version only when in a .NET project subdirectory. + typeset -g POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #####################[ php_version: php version (https://www.php.net/) ]###################### + # PHP version color. + typeset -g POWERLEVEL9K_PHP_VERSION_FOREGROUND=99 + # Show PHP version only when in a PHP project subdirectory. + typeset -g POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_PHP_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ laravel_version: laravel php framework version (https://laravel.com/) ]########### + # Laravel version color. + typeset -g POWERLEVEL9K_LARAVEL_VERSION_FOREGROUND=161 + # Custom icon. + # typeset -g POWERLEVEL9K_LARAVEL_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ####################[ java_version: java version (https://www.java.com/) ]#################### + # Java version color. + typeset -g POWERLEVEL9K_JAVA_VERSION_FOREGROUND=32 + # Show java version only when in a java project subdirectory. + typeset -g POWERLEVEL9K_JAVA_VERSION_PROJECT_ONLY=true + # Show brief version. + typeset -g POWERLEVEL9K_JAVA_VERSION_FULL=false + # Custom icon. + # typeset -g POWERLEVEL9K_JAVA_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###[ package: name@version from package.json (https://docs.npmjs.com/files/package.json) ]#### + # Package color. + typeset -g POWERLEVEL9K_PACKAGE_FOREGROUND=117 + # Package format. The following parameters are available within the expansion. + # + # - P9K_PACKAGE_NAME The value of `name` field in package.json. + # - P9K_PACKAGE_VERSION The value of `version` field in package.json. + # + # typeset -g POWERLEVEL9K_PACKAGE_CONTENT_EXPANSION='${P9K_PACKAGE_NAME//\%/%%}@${P9K_PACKAGE_VERSION//\%/%%}' + # Custom icon. + # typeset -g POWERLEVEL9K_PACKAGE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## + # Rbenv color. + typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168 + # Hide ruby version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_RBENV_SOURCES=(shell local global) + # If set to false, hide ruby version if it's the same as global: + # $(rbenv version-name) == $(rbenv global). + typeset -g POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide ruby version if it's equal to "system". + typeset -g POWERLEVEL9K_RBENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_RBENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######################[ rvm: ruby version from rvm (https://rvm.io) ]######################## + # Rvm color. + typeset -g POWERLEVEL9K_RVM_FOREGROUND=168 + # Don't show @gemset at the end. + typeset -g POWERLEVEL9K_RVM_SHOW_GEMSET=false + # Don't show ruby- at the front. + typeset -g POWERLEVEL9K_RVM_SHOW_PREFIX=false + # Custom icon. + # typeset -g POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ fvm: flutter version management (https://github.com/leoafarias/fvm) ]############ + # Fvm color. + typeset -g POWERLEVEL9K_FVM_FOREGROUND=38 + # Custom icon. + # typeset -g POWERLEVEL9K_FVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ luaenv: lua version from luaenv (https://github.com/cehoffman/luaenv) ]########### + # Lua color. + typeset -g POWERLEVEL9K_LUAENV_FOREGROUND=32 + # Hide lua version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_LUAENV_SOURCES=(shell local global) + # If set to false, hide lua version if it's the same as global: + # $(luaenv version-name) == $(luaenv global). + typeset -g POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide lua version if it's equal to "system". + typeset -g POWERLEVEL9K_LUAENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_LUAENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###############[ jenv: java version from jenv (https://github.com/jenv/jenv) ]################ + # Java color. + typeset -g POWERLEVEL9K_JENV_FOREGROUND=32 + # Hide java version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_JENV_SOURCES=(shell local global) + # If set to false, hide java version if it's the same as global: + # $(jenv version-name) == $(jenv global). + typeset -g POWERLEVEL9K_JENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide java version if it's equal to "system". + typeset -g POWERLEVEL9K_JENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_JENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ plenv: perl version from plenv (https://github.com/tokuhirom/plenv) ]############ + # Perl color. + typeset -g POWERLEVEL9K_PLENV_FOREGROUND=67 + # Hide perl version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PLENV_SOURCES=(shell local global) + # If set to false, hide perl version if it's the same as global: + # $(plenv version-name) == $(plenv global). + typeset -g POWERLEVEL9K_PLENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide perl version if it's equal to "system". + typeset -g POWERLEVEL9K_PLENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ############[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############ + # PHP color. + typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=99 + # Hide php version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PHPENV_SOURCES=(shell local global) + # If set to false, hide php version if it's the same as global: + # $(phpenv version-name) == $(phpenv global). + typeset -g POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide php version if it's equal to "system". + typeset -g POWERLEVEL9K_PHPENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ haskell_stack: haskell version from stack (https://haskellstack.org/) ]########### + # Haskell color. + typeset -g POWERLEVEL9K_HASKELL_STACK_FOREGROUND=172 + # Hide haskell version if it doesn't come from one of these sources. + # + # shell: version is set by STACK_YAML + # local: version is set by stack.yaml up the directory tree + # global: version is set by the implicit global project (~/.stack/global-project/stack.yaml) + typeset -g POWERLEVEL9K_HASKELL_STACK_SOURCES=(shell local) + # If set to false, hide haskell version if it's the same as in the implicit global project. + typeset -g POWERLEVEL9K_HASKELL_STACK_ALWAYS_SHOW=true + # Custom icon. + # typeset -g POWERLEVEL9K_HASKELL_STACK_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Example of a user-defined prompt segment. Function prompt_example will be called on every + # prompt if `example` prompt segment is added to POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or + # POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. It displays an icon and orange text greeting the user. + # + # Type `p10k help segment` for documentation and a more sophisticated example. + function prompt_watson() { + local watson_status=$(watson status) + local noproject="No project started." + if [ "$watson_status" != "$noproject" ]; then + p10k segment -i "祥" -f yellow -t "$(echo $watson_status | awk '{print $2,$3}')" + else + p10k segment -i "⏾" -f red -t "" + fi + } + + function prompt_triton() { + local triton_profile=$(echo $TRITON_PROFILE) + if [ "$triton_profile" != "" ]; then + p10k segment -f yellow -t "$(echo "✚" "$triton_profile")" + fi + } + + # Transient prompt works similarly to the builtin transient_rprompt option. It trims down prompt + # when accepting a command line. Supported values: + # + # - off: Don't change prompt when accepting a command line. + # - always: Trim down prompt when accepting a command line. + # - same-dir: Trim down prompt when accepting a command line unless this is the first command + # typed after changing current working directory. + typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=always + + # Instant prompt mode. + # + # - off: Disable instant prompt. Choose this if you've tried instant prompt and found + # it incompatible with your zsh configuration files. + # - quiet: Enable instant prompt and don't print warnings when detecting console output + # during zsh initialization. Choose this if you've read and understood + # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. + # - verbose: Enable instant prompt and print a warning when detecting console output during + # zsh initialization. Choose this if you've never tried instant prompt, haven't + # seen the warning, or if you are unsure what this all means. + typeset -g POWERLEVEL9K_INSTANT_PROMPT=verbose + + # Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized. + # For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload + # can slow down prompt by 1-2 milliseconds, so it's better to keep it turned off unless you + # really need it. + typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=false + + # If p10k is already loaded, reload configuration. + # This works even with POWERLEVEL9K_DISABLE_HOT_RELOAD=true. + (( ! $+functions[p10k] )) || p10k reload +} + +# Tell `p10k configure` which file it should overwrite. +typeset -g POWERLEVEL9K_CONFIG_FILE=${${(%):-%x}:a} + +(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]} +'builtin' 'unset' 'p10k_config_opts' diff --git a/modules/uhk/default.nix b/modules/uhk/default.nix new file mode 100644 index 00000000..a1ac05b1 --- /dev/null +++ b/modules/uhk/default.nix @@ -0,0 +1,28 @@ +{ lib, config, pkgs, ... }: +with lib; +let + psCfg = config.pub-solar; + cfg = config.pub-solar.uhk; +in +{ + options.pub-solar.uhk = { + enable = mkEnableOption "Ultimate Hacking Keyboard"; + }; + + config = mkIf cfg.enable { + environment.systemPackages = with pkgs; [ + uhk-agent + ]; + + # Ultimate Hacking Keyboard rules + # These are the udev rules for accessing the USB interfaces of the UHK as non-root users. + services.udev.packages = with pkgs; [ + uhk-agent + ]; + services.udev.extraRules = '' + SUBSYSTEM=="input", ATTRS{idVendor}=="1d50", ATTRS{idProduct}=="612[0-7]", GROUP="input", MODE="0660" + SUBSYSTEMS=="usb", ATTRS{idVendor}=="1d50", ATTRS{idProduct}=="612[0-7]", TAG+="uaccess" + KERNEL=="hidraw*", ATTRS{idVendor}=="1d50", ATTRS{idProduct}=="612[0-7]", TAG+="uaccess" + ''; + }; +} diff --git a/modules/user/default.nix b/modules/user/default.nix new file mode 100644 index 00000000..d2edd476 --- /dev/null +++ b/modules/user/default.nix @@ -0,0 +1,36 @@ +{ lib, config, pkgs, ... }: +with lib; +let + cfg = config.pub-solar; +in +{ + options.pub-solar = { + user = { + name = mkOption { + description = "User login name"; + type = types.nullOr types.str; + default = "nixos"; + }; + password = mkOption { + description = "User password"; + type = types.nullOr types.str; + default = null; + }; + fullName = mkOption { + description = "User full name"; + type = types.nullOr types.str; + default = null; + }; + email = mkOption { + description = "User email address"; + type = types.nullOr types.str; + default = null; + }; + gpgKeyId = mkOption { + description = "GPG Key ID"; + type = types.nullOr types.str; + default = null; + }; + }; + }; +} diff --git a/modules/virtualisation/default.nix b/modules/virtualisation/default.nix new file mode 100644 index 00000000..c97db9d2 --- /dev/null +++ b/modules/virtualisation/default.nix @@ -0,0 +1,48 @@ +{ lib, config, pkgs, ... }: +with lib; +let + psCfg = config.pub-solar; + cfg = config.pub-solar.virtualisation; +in +{ + options.pub-solar.virtualisation = { + enable = mkEnableOption "Life in libvirt"; + }; + + config = mkIf cfg.enable { + boot.kernelParams = [ + "amd_iommu=on" + "iommu=pt" + ]; + + virtualisation.libvirtd = { + enable = true; + qemuOvmf = true; + }; + users.users = pkgs.lib.setAttrByPath [ psCfg.user.name ] { + extraGroups = [ "libvirtd" ]; + }; + + environment.systemPackages = with pkgs; [ + coreutils-full + usbutils + libvirt + libvirt-glib + qemu + virt-manager + python38Packages.libvirt + gvfs + scream + edk2 + OVMF + win-virtio + ]; + + home-manager = with pkgs; pkgs.lib.setAttrByPath [ "users" psCfg.user.name ] { + xdg.dataFile."libvirt/.keep".text = "# this file is here to generate the directory"; + }; + + systemd.tmpfiles.rules = [ "f /dev/shm/scream-ivshmem 0660 ${psCfg.user.name} kvm" ]; + systemd.user.services.scream-ivshmem-pulse = import ./scream-ivshmem-pulse.service.nix pkgs; + }; +} diff --git a/modules/virtualisation/scream-ivshmem-pulse.service.nix b/modules/virtualisation/scream-ivshmem-pulse.service.nix new file mode 100644 index 00000000..c4337fa0 --- /dev/null +++ b/modules/virtualisation/scream-ivshmem-pulse.service.nix @@ -0,0 +1,19 @@ +pkgs: +{ + enable = true; + wantedBy = [ "multi-user.target" ]; + unitConfig = { + Description = "Scream IVSHMEM pulse reciever"; + BindsTo = [ "pipewire-pulse.service" ]; + After = [ "pipewire-pulse.service" ]; + Wants = [ "pipewire-pulse.service" ]; + }; + serviceConfig = { + Type = "simple"; + ExecStartPre = [ + "${pkgs.coreutils-full}/bin/truncate -s 0 /dev/shm/scream-ivshmem" + "${pkgs.coreutils-full}/bin/dd if=/dev/zero of=/dev/shm/scream-ivshmem bs=1M count=2" + ]; + ExecStart = "${pkgs.scream}/bin/scream -m /dev/shm/scream-ivshmem"; + }; +} diff --git a/modules/x-os/boot.nix b/modules/x-os/boot.nix new file mode 100644 index 00000000..5068590e --- /dev/null +++ b/modules/x-os/boot.nix @@ -0,0 +1,42 @@ +{ config, pkgs, lib, ... }: + +let + cfg = config.pub-solar.x-os; +in +with lib; { + options = { + pub-solar.x-os.keyfile = mkOption { + type = types.str; + description = "Keyfile location"; + }; + }; + + config = { + # Enable plymouth for better experience of booting + boot.plymouth.enable = true; + + # Use Keyfile to unlock the root partition to avoid keying in twice. + # Allow fstrim to work on it. + boot.initrd = { + secrets = { "/keyfile.bin" = cfg.keyfile; }; + luks.devices."cryptroot" = { + keyFile = "/keyfile.bin"; + allowDiscards = true; + fallbackToPassword = true; + }; + }; + + # Use GRUB with encrypted /boot under EFI env. + boot.loader = { + efi.efiSysMountPoint = "/boot/efi"; + + grub = { + enable = true; + version = 2; + device = "nodev"; + efiSupport = true; + enableCryptodisk = true; + }; + }; + }; +} diff --git a/modules/x-os/default.nix b/modules/x-os/default.nix new file mode 100644 index 00000000..6276bf5f --- /dev/null +++ b/modules/x-os/default.nix @@ -0,0 +1,7 @@ +{ ... }: { + imports = [ + ./boot.nix + ./i18n.nix + ./networking.nix + ]; +} diff --git a/modules/x-os/i18n.nix b/modules/x-os/i18n.nix new file mode 100644 index 00000000..3219160d --- /dev/null +++ b/modules/x-os/i18n.nix @@ -0,0 +1,16 @@ +{ config, pkgs, lib, ... }: +with lib; +{ + config = { + # Set your time zone. + time.timeZone = "Europe/Berlin"; + + # Select internationalisation properties. + console = { + font = "Lat2-Terminus16"; + }; + i18n = { + defaultLocale = "en_US.UTF-8"; + }; + }; +} diff --git a/modules/x-os/networking.nix b/modules/x-os/networking.nix new file mode 100644 index 00000000..1e981290 --- /dev/null +++ b/modules/x-os/networking.nix @@ -0,0 +1,54 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let cfg = config.pub-solar.x-os; +in +{ + options.pub-solar.x-os = { + binaryCaches = mkOption { + type = types.listOf types.str; + default = [ ]; + description = "Binary caches to use."; + }; + publicKeys = mkOption { + type = types.listOf types.str; + default = [ ]; + description = "Public keys of binary caches."; + }; + iwdConfig = mkOption { + type = with types; nullOr (attrsOf (attrsOf (oneOf [ bool int str ]))); + default = null; + description = "Configuratoin of iNet Wireless Daemon."; + }; + }; + config = { + networking.networkmanager = { + # Enable networkmanager. REMEMBER to add yourself to group in order to use nm related stuff. + enable = true; + }; + + # Customized binary caches list (with fallback to official binary cache) + nix.binaryCaches = cfg.binaryCaches; + nix.binaryCachePublicKeys = cfg.publicKeys; + + # These entries get added to /etc/hosts + networking.hosts = { + "127.0.0.1" = [ "cups.local" ]; + }; + + # Caddy reverse proxy for local services like cups + services.caddy = { + enable = true; + config = '' + { + auto_https off + } + cups.local:80 + bind 127.0.0.1 + request_header Host localhost:631 + reverse_proxy unix//run/cups/cups.sock + ''; + }; + }; +} diff --git a/overlays/fonts.nix b/overlays/fonts.nix new file mode 100644 index 00000000..4f837020 --- /dev/null +++ b/overlays/fonts.nix @@ -0,0 +1 @@ +import ./fonts diff --git a/overlays/fonts/default.nix b/overlays/fonts/default.nix new file mode 100644 index 00000000..c5be3050 --- /dev/null +++ b/overlays/fonts/default.nix @@ -0,0 +1,4 @@ +final: prev: +with final; { + futura-otf = import ./futura.nix; +} diff --git a/overlays/fonts/futura.nix b/overlays/fonts/futura.nix new file mode 100644 index 00000000..3c2c3cc4 --- /dev/null +++ b/overlays/fonts/futura.nix @@ -0,0 +1,19 @@ +{ stdenv, fetchFromGitHub }: + +stdenv.mkDerivation rec { + pname = "futura"; + version = "1.0.0"; + + src = ../secrets/fonts/Futura Std; + + installPhase = '' + install -D -m 444 /* -t $out/share/fonts/otf + ''; + + meta = with stdenv.lib; { + description = ""; + longDescription = '' + ''; + homepage = ""; + }; +} diff --git a/overlays/pub-solar.nix b/overlays/pub-solar.nix new file mode 100644 index 00000000..e1215796 --- /dev/null +++ b/overlays/pub-solar.nix @@ -0,0 +1 @@ +import ./pub-solar diff --git a/overlays/pub-solar/default.nix b/overlays/pub-solar/default.nix new file mode 100644 index 00000000..88257773 --- /dev/null +++ b/overlays/pub-solar/default.nix @@ -0,0 +1,15 @@ +final: prev: +with final; { + import-gtk-settings = writeShellScriptBin "import-gtk-settings" (import ./import-gtk-settings.nix final); + mailto-mutt = writeShellScriptBin "mailto-mutt" (import ./mailto-mutt.nix final); + mu = writeShellScriptBin "mu" (import ./mu.nix final); + mopidy-jellyfin = import ./mopidy-jellyfin.nix final; + psos = writeShellScriptBin "psos" (import ./psos.nix final); + s = writeShellScriptBin "s" (import ./s.nix final); + swaylock-bg = writeScriptBin "swaylock-bg" (import ./swaylock-bg.nix final); + sway-launcher = writeScriptBin "sway-launcher" (import ./sway-launcher.nix final); + sway-service = writeShellScriptBin "sway-service" (import ./sway-service.nix final); + toggle-kbd-layout = writeShellScriptBin "toggle-kbd-layout" (import ./toggle-kbd-layout.nix final); + uhk-agent = import ./uhk-agent.nix final; + wcwd = writeShellScriptBin "wcwd" (import ./wcwd.nix final); +} diff --git a/overlays/pub-solar/image-gpu-rom.nix b/overlays/pub-solar/image-gpu-rom.nix new file mode 100644 index 00000000..a472ee52 --- /dev/null +++ b/overlays/pub-solar/image-gpu-rom.nix @@ -0,0 +1,7 @@ +GPU_VGA_PORT="0000:01:00.0" + +echo 1 > "/sys/bus/pci/devices/$GPU_VGA_PORT/rom" +cat "/sys/bus/pci/devices/$GPU_VGA_PORT/rom" > \ +"/usr/share/qemu/gpu-1060.rom" +echo 0 > "/sys/bus/pci/devices/$GPU_VGA_PORT/rom" + diff --git a/overlays/pub-solar/import-gtk-settings.nix b/overlays/pub-solar/import-gtk-settings.nix new file mode 100644 index 00000000..f4b12b92 --- /dev/null +++ b/overlays/pub-solar/import-gtk-settings.nix @@ -0,0 +1,11 @@ +self: with self; '' + # usage: import-gsettings : : ... + + expression="" + for pair in "$@"; do + IFS=:; set -- $pair + expressions="$expressions -e 's/^$2=(.*)$/gsettings set org.gnome.desktop.interface $1 \1/e'" + done + IFS= + eval exec sed -E $expressions "$XDG_CONFIG_HOME"/gtk-3.0/settings.ini >/dev/null +'' diff --git a/overlays/pub-solar/iommu-test.nix b/overlays/pub-solar/iommu-test.nix new file mode 100644 index 00000000..e2439bfa --- /dev/null +++ b/overlays/pub-solar/iommu-test.nix @@ -0,0 +1,9 @@ +shopt - s nullglob + for + g in /sys/kernel/iommu_groups/*; do +echo "IOMMU Group ${g##*/}:" +for d in $g/devices/*; do +echo -e "\t$(lspci -nns ${d##*/})" +done; +done; + diff --git a/overlays/pub-solar/mailto-mutt.nix b/overlays/pub-solar/mailto-mutt.nix new file mode 100644 index 00000000..a17d2409 --- /dev/null +++ b/overlays/pub-solar/mailto-mutt.nix @@ -0,0 +1,5 @@ +self: with self; '' + echo "$@" >> $XDG_CACHE_HOME/log/mailto.log + + exec ${alacritty}/bin/alacritty -e neomutt -- "$@" +'' diff --git a/overlays/pub-solar/mopidy-jellyfin.nix b/overlays/pub-solar/mopidy-jellyfin.nix new file mode 100644 index 00000000..8c99ac21 --- /dev/null +++ b/overlays/pub-solar/mopidy-jellyfin.nix @@ -0,0 +1,29 @@ +self: with self; +let + websocket-client = python38.pkgs.buildPythonPackage rec { + pname = "websocket-client"; + version = "1.0.0"; + doCheck = false; + src = python38.pkgs.fetchPypi { + inherit pname version; + sha256 = "sha256-UFGzii9MJ/vXygd+uyPsaWWmJt7VqVY382vhs1tsT4E="; + }; + }; +in +python38.pkgs.buildPythonPackage rec { + pname = "Mopidy-Jellyfin"; + version = "1.0.2"; + doCheck = false; + propagatedBuildInputs = with python38.pkgs; [ + unidecode + websocket-client + requests + setuptools + pykka + mopidy + ]; + src = python38.pkgs.fetchPypi { + inherit pname version; + sha256 = "sha256-5XimIIQSpvNyQbSOFtSTkA0jhA0V68BbyQEQNnov+0g="; + }; +} diff --git a/overlays/pub-solar/mu.nix b/overlays/pub-solar/mu.nix new file mode 100644 index 00000000..90afaa4a --- /dev/null +++ b/overlays/pub-solar/mu.nix @@ -0,0 +1,3 @@ +self: with self; '' + exec ${alacritty}/bin/alacritty --class mu_vimpc --option dimensions.columns=120 --option dimensions.lines=80 -e vimpc -- "$@" +'' diff --git a/overlays/pub-solar/overlay.nix b/overlays/pub-solar/overlay.nix new file mode 100644 index 00000000..5378b910 --- /dev/null +++ b/overlays/pub-solar/overlay.nix @@ -0,0 +1,5 @@ +# You can use this file as a nixpkgs overlay. This is useful in the +# case where you don't want to add the whole NUR namespace to your +# configuration. + +self: super: import ./default.nix { pkgs = super; } diff --git a/overlays/pub-solar/psos.nix b/overlays/pub-solar/psos.nix new file mode 100644 index 00000000..a60bad6d --- /dev/null +++ b/overlays/pub-solar/psos.nix @@ -0,0 +1,29 @@ +self: with self; '' + case $1 in + rebuild) + shift; + exec sudo nixos-rebuild switch --flake "/etc/nixos#installed-host" $@ + ;; + update) + shift; + cd /etc/nixos + git pull + exec nix flake update + ;; + option) + shift; + exec nixos-option -I nixpkgs=/etc/nixos/lib/compat $@ + ;; + *) + if [[ "$@" != "" ]]; then + echo "Unknown command: psos $@" + echo "" + fi + echo "Usage: psos [COMMAND]" + echo " rebuild Rebuild the configuration and switch to it" + echo " update Pull git and update flake.lock" + echo " option [path] See the current value for an option in the flake config. Example: psos option nix.nixPath" + exit 1 + ;; + esac +'' diff --git a/overlays/pub-solar/s.nix b/overlays/pub-solar/s.nix new file mode 100644 index 00000000..668d5553 --- /dev/null +++ b/overlays/pub-solar/s.nix @@ -0,0 +1,39 @@ +self: with self; '' + case $1 in + d) + shift; + URL="https://duckduckgo.com?q=$@" + ;; + no) + shift; + URL="https://search.nixos.org/options?query=$@" + ;; + np) + shift; + URL="https://search.nixos.org/packages?query=$@" + ;; + rs) + shift; + URL="https://doc.rust-lang.org/std/index.html?search=$@" + ;; + rsc) + shift; + URL="https://docs.rs/releases/search?query=$@" + ;; + mdn) + shift; + URL="https://developer.mozilla.org/en-US/search?q=$@" + ;; + w) + shift; + URL="https://en.wikipedia.org/w/index.php?search=$@" + ;; + *) + URL="https://search.b12f.io?q=$@" + ;; + esac + + + ${firefox-wayland}/bin/firefox --new-tab "$URL" + ${sway}/bin/swaymsg '[app_id="firefox"]' focus +'' diff --git a/overlays/pub-solar/sway-launcher.nix b/overlays/pub-solar/sway-launcher.nix new file mode 100644 index 00000000..afa09d07 --- /dev/null +++ b/overlays/pub-solar/sway-launcher.nix @@ -0,0 +1,64 @@ +self: with self; '' + #!/usr/bin/env zsh + # terminal application launcher for sway, using fzf + # original command: + # Based on: https://github.com/swaywm/sway/issues/1367 + # bindsym $altkey+space exec termite --name=launcher -e \ + # "bash -c 'compgen -c | sort -u | fzf --no-extended --print-query | \ + # tail -n1 | xargs -r swaymsg -t command exec'" + + HIST_FILE="''${XDG_CACHE_HOME:-$HOME/.cache}/sway-launcher-history.txt" + + # Get shell command list + # This may include the occasional non-executable file + command_list=$({ whence -wm '*' | sed 's/:[^:]*$//' }) + + # read existing command history + if [ -f "$HIST_FILE" ]; then + command_history=$(cat "$HIST_FILE") + else + command_history="" + fi + + # search command list + command_str=$(printf "%s\n" "''${command_history}" "''${command_list}" | \ + sed -E 's/^[0-9]+ (.+)$/\1/' | \ + fzf --exact --no-extended --print-query --no-sort | \ + tail -n1) || exit 1 + + if [ "$command_str" = "" ]; then + exit 1 + fi + # echo "Command: $command_str" + + # using \E flag from perl regex + test "''${command_str#*\\E}" != "$command_str" && echo "command can't contain '\E'" + test "''${command_str#*\\E}" != "$command_str" && exit 1 + + # get full line from history (with count number) + hist_line=$(echo "$command_history" | grep -Pe "^[0-9]+ \Q$command_str\E$") + # echo "Hist Line: $hist_line" + + if [ "$hist_line" = "" ]; then + hist_count=1 + else + # Increment usage count + hist_count=$(echo "$hist_line" | sed -E 's/^([0-9]+) .+$/\1/') + hist_count=$((hist_count + 1)) + # delete line, to add updated later + # echo "Hist Before: $command_history" + command_history=$(echo "$command_history" | \ + grep --invert-match -Pe "^[0-9]+ \Q$command_str\E$") + # echo "Hist After: $command_history" + fi + + # update history + update_line="''${hist_count} ''${command_str}" + printf "%s\n" "''${update_line}" "''${command_history}" | \ + sort --numeric-sort --reverse > "$HIST_FILE" + # echo "$update_line" + + # execute command + echo "$command_str" + ${sway}/bin/swaymsg -t command exec "$command_str" +'' diff --git a/overlays/pub-solar/sway-service.nix b/overlays/pub-solar/sway-service.nix new file mode 100644 index 00000000..f0b97ee7 --- /dev/null +++ b/overlays/pub-solar/sway-service.nix @@ -0,0 +1,6 @@ +self: with self; '' + # first import environment variables from the login manager + systemctl --user import-environment + # then start the service + exec systemctl --wait --user start sway.service +'' diff --git a/overlays/pub-solar/swaylock-bg.nix b/overlays/pub-solar/swaylock-bg.nix new file mode 100644 index 00000000..b55c32ae --- /dev/null +++ b/overlays/pub-solar/swaylock-bg.nix @@ -0,0 +1,20 @@ +self: with self; '' + # Dependencies: + # swaylock + + # Make sure we aren't running twice + RUNNING=$(ps -A | grep swaylock | wc -l) + if [ $RUNNING -ne 0 ]; then + exit 0 + fi + + IMAGE=$XDG_CONFIG_HOME/wallpaper.jpg + LOCKARGS="" + + for OUTPUT in `${sway}/bin/swaymsg -t get_outputs | jq -r '.[].name'` + do + LOCKARGS="''${LOCKARGS} --image ''${OUTPUT}:''${IMAGE}" + IMAGES="''${IMAGES} ''${IMAGE}" + done + exec ${swaylock}/bin/swaylock $LOCKARGS +'' diff --git a/overlays/pub-solar/toggle-kbd-layout.nix b/overlays/pub-solar/toggle-kbd-layout.nix new file mode 100644 index 00000000..0d837b0a --- /dev/null +++ b/overlays/pub-solar/toggle-kbd-layout.nix @@ -0,0 +1,14 @@ +self: with self; '' + set -e + + current_layout=$(${sway}/bin/swaymsg -t get_inputs | ${jq}/bin/jq -r '.[] | select(.type == "keyboard") | .xkb_active_layout_index' | head -1) + total_layouts=$(${sway}/bin/swaymsg -t get_inputs | ${jq}/bin/jq -r '.[] | select(.type == "keyboard") | .xkb_layout_names | length' | head -1) + + next_layout=$(expr $current_layout + 1); + + if [ $next_layout -ge $total_layouts ]; then + next_layout=0; + fi + + ${sway}/bin/swaymsg input '*' xkb_switch_layout "$next_layout" +'' diff --git a/overlays/pub-solar/uhk-agent.nix b/overlays/pub-solar/uhk-agent.nix new file mode 100644 index 00000000..3143b054 --- /dev/null +++ b/overlays/pub-solar/uhk-agent.nix @@ -0,0 +1,44 @@ +self: with self; +let + uhk-agent-bin = stdenv.mkDerivation rec { + pname = "uhk-agent-bin"; + version = "1.5.14"; + src = builtins.fetchurl { + url = "https://github.com/UltimateHackingKeyboard/agent/releases/download/v1.5.14/UHK.Agent-1.5.14-linux-x86_64.AppImage"; + sha256 = "sha256:1yzh4ixy0cqg02xf84vcqj3h67mkxyzs6jf1h935ay582n70nyqg"; + }; + phases = [ "installPhase" "patchPhase" ]; + installPhase = '' + mkdir -p $out/bin + cp $src $out/bin/uhk-agent + chmod +x $out/bin/uhk-agent + ''; + }; + + script = '' + #!${bash}/bin/bash + + ${appimage-run}/bin/appimage-run ${uhk-agent-bin}/bin/uhk-agent + ''; +in +stdenv.mkDerivation rec { + pname = "uhk-agent"; + version = "1.5.14"; + buildInputs = [ + bash + uhk-agent-bin + appimage-run + ]; + + phases = [ "buildPhase" "installPhase" "patchPhase" ]; + + buildPhase = '' + echo "${script}" >> uhk-agent + ''; + + installPhase = '' + mkdir -p $out/bin + cp uhk-agent $out/bin/uhk-agent + chmod +x $out/bin/uhk-agent + ''; +} diff --git a/overlays/pub-solar/wcwd.nix b/overlays/pub-solar/wcwd.nix new file mode 100644 index 00000000..e5ebcca8 --- /dev/null +++ b/overlays/pub-solar/wcwd.nix @@ -0,0 +1,5 @@ +self: with self; '' + pid=$(${sway}/bin/swaymsg -t get_tree | jq '.. | select(.type?) | select(.type=="con") | select(.focused==true).pid') + ppid=$(pgrep --newest --parent ''${pid}) + readlink /proc/''${ppid}/cwd || echo $HOME +'' diff --git a/profiles/base-user/.config/dircolors b/profiles/base-user/.config/dircolors new file mode 100644 index 00000000..89c085da --- /dev/null +++ b/profiles/base-user/.config/dircolors @@ -0,0 +1,243 @@ +# Configuration file for dircolors, a utility to help you set the +# LS_COLORS environment variable used by GNU ls with the --color option. + +# Copyright (C) 1996-2014 Free Software Foundation, Inc. +# Copying and distribution of this file, with or without modification, +# are permitted provided the copyright notice and this notice are preserved. + +# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the +# slackware version of dircolors) are recognized but ignored. + +# You can copy this file to .dir_colors in your $HOME directory to override +# the system defaults. + +# Below, there should be one TERM entry for each termtype that is colorizable +TERM Eterm +TERM ansi +TERM color-xterm +TERM con132x25 +TERM con132x30 +TERM con132x43 +TERM con132x60 +TERM con80x25 +TERM con80x28 +TERM con80x30 +TERM con80x43 +TERM con80x50 +TERM con80x60 +TERM cons25 +TERM console +TERM cygwin +TERM dtterm +TERM eterm-color +TERM gnome +TERM gnome-256color +TERM hurd +TERM jfbterm +TERM konsole +TERM kterm +TERM linux +TERM linux-c +TERM mach-color +TERM mach-gnu-color +TERM mlterm +TERM putty +TERM putty-256color +TERM rxvt +TERM rxvt-256color +TERM rxvt-cygwin +TERM rxvt-cygwin-native +TERM rxvt-unicode +TERM rxvt-unicode-256color +TERM rxvt-unicode256 +TERM screen +TERM screen-256color +TERM screen-256color-bce +TERM screen-bce +TERM screen-w +TERM screen.Eterm +TERM screen.rxvt +TERM screen.linux +TERM st +TERM st-256color +TERM terminator +TERM vt100 +TERM xterm +TERM xterm-16color +TERM xterm-256color +TERM xterm-88color +TERM xterm-color +TERM xterm-debian + +# Below are the color init strings for the basic file types. A color init +# string consists of one or more of the following numeric codes: +# Attribute codes: +# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed +# Text color codes: +# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white +# Background color codes: +# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white +#NORMAL 00 # no color code at all +#FILE 00 # regular file: use no color at all +RESET 0 # reset to "normal" color +DIR 01;34 # directory +LINK 01;36 # symbolic link. (If you set this to 'target' instead of a + # numerical value, the color is as for the file pointed to.) +MULTIHARDLINK 00 # regular file with more than one link +FIFO 40;33 # pipe +SOCK 01;35 # socket +DOOR 01;35 # door +BLK 40;33;01 # block device driver +CHR 40;33;01 # character device driver +ORPHAN 01;05;37;41 # orphaned syminks +MISSING 01;05;37;41 # ... and the files they point to +SETUID 37;41 # file that is setuid (u+s) +SETGID 30;43 # file that is setgid (g+s) +CAPABILITY 30;41 # file with capability +STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w) +OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky +STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable + +# This is for files with execute permission: +EXEC 01;32 + +# List any file extensions like '.gz' or '.tar' that you would like ls +# to colorize below. Put the extension, a space, and the color init string. +# (and any comments you want to add after a '#') + +# If you use DOS-style suffixes, you may want to uncomment the following: +#.cmd 01;32 # executables (bright green) +#.exe 01;32 +#.com 01;32 +#.btm 01;32 +#.bat 01;32 +# Or if you want to colorize scripts even if they do not have the +# executable bit actually set. +#.sh 01;32 +#.csh 01;32 + + # archives or compressed (bright red) +.tar 01;31 +.tgz 01;31 +.arc 01;31 +.arj 01;31 +.taz 01;31 +.lha 01;31 +.lz4 01;31 +.lzh 01;31 +.lzma 01;31 +.tlz 01;31 +.txz 01;31 +.tzo 01;31 +.t7z 01;31 +.zip 01;31 +.z 01;31 +.Z 01;31 +.dz 01;31 +.gz 01;31 +.lrz 01;31 +.lz 01;31 +.lzo 01;31 +.xz 01;31 +.bz2 01;31 +.bz 01;31 +.tbz 01;31 +.tbz2 01;31 +.tz 01;31 +.deb 01;31 +.rpm 01;31 +.jar 01;31 +.war 01;31 +.ear 01;31 +.sar 01;31 +.rar 01;31 +.alz 01;31 +.ace 01;31 +.zoo 01;31 +.cpio 01;31 +.7z 01;31 +.rz 01;31 +.cab 01;31 + +# image formats +.jpg 01;35 +.jpeg 01;35 +.gif 01;35 +.bmp 01;35 +.pbm 01;35 +.pgm 01;35 +.ppm 01;35 +.tga 01;35 +.xbm 01;35 +.xpm 01;35 +.tif 01;35 +.tiff 01;35 +.png 01;35 +.svg 01;35 +.svgz 01;35 +.mng 01;35 +.pcx 01;35 +.mov 01;35 +.mpg 01;35 +.mpeg 01;35 +.m2v 01;35 +.mkv 01;35 +.webm 01;35 +.ogm 01;35 +.mp4 01;35 +.m4v 01;35 +.mp4v 01;35 +.vob 01;35 +.qt 01;35 +.nuv 01;35 +.wmv 01;35 +.asf 01;35 +.rm 01;35 +.rmvb 01;35 +.flc 01;35 +.avi 01;35 +.fli 01;35 +.flv 01;35 +.gl 01;35 +.dl 01;35 +.xcf 01;35 +.xwd 01;35 +.yuv 01;35 +.cgm 01;35 +.emf 01;35 + +# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions +.axv 01;35 +.anx 01;35 +.ogv 01;35 +.ogx 01;35 + +# Document files +.pdf 00;32 +.ps 00;32 +.txt 00;32 +.patch 00;32 +.diff 00;32 +.log 00;32 +.tex 00;32 +.doc 00;32 + +# audio formats +.aac 00;36 +.au 00;36 +.flac 00;36 +.m4a 00;36 +.mid 00;36 +.midi 00;36 +.mka 00;36 +.mp3 00;36 +.mpc 00;36 +.ogg 00;36 +.ra 00;36 +.wav 00;36 + +# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions +.axa 00;36 +.oga 00;36 +.spx 00;36 +.xspf 00;36 diff --git a/profiles/base-user/.config/git/config.nix b/profiles/base-user/.config/git/config.nix new file mode 100644 index 00000000..6b099f87 --- /dev/null +++ b/profiles/base-user/.config/git/config.nix @@ -0,0 +1,31 @@ +{ config, pkgs, ... }: +let + user = config.pub-solar.user; + xdg = config.home-manager.users."${user.name}".xdg; +in +''[user] + ${if user.email != null then "email = ${user.email}" else ""} + ${if user.fullName != null then "name = ${user.fullName}" else ""} + ${if user.gpgKeyId != null then "signingkey = ${user.gpgKeyId}" else ""} +[core] + editor = /etc/profiles/per-user/${config.pub-solar.user.name}/bin/nvim +[alias] + pol = pull + ack = -c color.grep.linenumber=\"bold yellow\"\n -c color.grep.filename=\"bold green\"\n -c color.grep.match=\"reverse yellow\"\n grep --break --heading --line-number +# define command which will be used when "nvim"is set as a merge tool +[mergetool "nvim"] + cmd = /etc/profiles/per-user/${config.pub-solar.user.name}/bin/nvim -f -c \"Gdiffsplit!\" \"$MERGED\" +# set "nvim" as tool for merging +[merge] + tool = /etc/profiles/per-user/${config.pub-solar.user.name}/bin/nvim +# automatically launch merge tool without displaying a prompt +[mergetool] + prompt = false +[commit] + gpgsign = true +[tag] + gpgsign = true +[init] + defaultBranch = main +[pull] + rebase = false'' diff --git a/profiles/base-user/.config/libinput-gestures.conf b/profiles/base-user/.config/libinput-gestures.conf new file mode 100644 index 00000000..17b87774 --- /dev/null +++ b/profiles/base-user/.config/libinput-gestures.conf @@ -0,0 +1,198 @@ +# Configuration file for libinput-gestures. +# Mark Blakeney, Sep 2015 +# +# The default configuration file exists at /etc/libinput-gestures.conf +# but a user can create a personal custom configuration file at +# ~/.config/libinput-gestures.conf. +# +# Lines starting with '#' and blank lines are ignored. Currently +# "gesture" and "device" configuration keywords are supported as +# described below. The keyword can optionally be appended with a ":" (to +# maintain compatibility with original format configuration files). +# +# Each gesture line has 3 [or 4] arguments separated by whitespace: +# +# action motion [finger_count] command +# +# where action and motion is either: +# swipe up +# swipe down +# swipe left +# swipe right +# swipe left_up +# swipe left_down +# swipe right_up +# swipe right_down +# pinch in +# pinch out +# pinch clockwise +# pinch anticlockwise +# +# command is the remainder of the line and is any valid shell command + +# arguments. +# +# finger_count is a single numeric digit and is optional (and is +# typically 3 or 4). If specified then the command is executed when +# exactly that number of fingers is used in the gesture. If not +# specified then the command is executed when that gesture is executed +# with any number of fingers. Gesture lines specified with finger_count +# have priority over the same gesture specified without any +# finger_count. +# +# Typically command will be xdotool, or wmctrl. See "man xdotool" for +# the many things you can action with that tool. Note that unfortunately +# xdotool does not work with native Wayland clients. + +############################################################################### +# SWIPE GESTURES: +############################################################################### + +# Note the default is an "internal" command that uses wmctrl to switch +# workspaces and, unlike xdotool, works on both Xorg and Wayland (via +# XWayland). It also can be configured for vertical and horizontal +# switching over tabular workspaces, as per the example below. You can +# also add "-w" to the internal command to allow wrapping workspaces. + +# Move to next workspace (works for GNOME/KDE/etc on Wayland and Xorg) +#gesture swipe up _internal ws_up + +# NOTE ABOUT FINGER COUNT: +# The above command will configure this command for all fingers (i.e. 3 +# for 4) but to configure it for 3 fingers only, change it to: +# gesture swipe up 3 _internal ws_up +# Then you can configure something else for 4 fingers or leave 4 fingers +# unconfigured. You can configure an explicit finger count like this for +# all example commands in this configuration file. +# +gesture swipe up 3 ydotool key Super_L+Down +gesture swipe up 4 ydotool key Super_L+Ctrl+Right + +# Move to prev workspace (works for GNOME/KDE/etc on Wayland and Xorg) +#gesture swipe down _internal ws_down +gesture swipe down 3 ydotool key Super_L+Up +gesture swipe down 4 ydotool key Super_L+Ctrl+Left + +# Browser go forward (works only for Xorg, and Xwayland clients) +gesture swipe left 3 ydotool key ctrl+] + +# Browser go back (works only for Xorg, and Xwayland clients) +gesture swipe right 3 ydotool key ctrl+[ + +# NOTE: If you don't use "natural" scrolling direction for your touchpad +# then you may want to swap the above default left/right and up/down +# configurations. + +# Optional extended swipe gestures, e.g. for browser tab navigation: +# +# Jump to next open browser tab +#gesture swipe right_up xdotool key control+Tab +#gesture swipe right_up xdotool key control+Next +gesture swipe right_up ydotool key ctrl+PageDown +# +# Jump to previous open browser tab +#gesture swipe left_up xdotool key control+shift+Tab +gesture swipe left_up ydotool key ctrl+PageUp +# +# Close current browser tab +# gesture swipe left_down xdotool key control+w +# +# Reopen and jump to last closed browser tab +# gesture swipe right_down xdotool key control+shift+t + +# Example of 8 static workspaces, e.g. using KDE virtual-desktops, +# arranged in 2 rows of 4 columns across using swipe up/down/left/right +# to navigate in fixed planes. You can also add the "-w/--wrap" option +# to allow wrapping in any direction. You must configure your virtual +# desktops with the same column dimension. +# gesture swipe up _internal --cols 4 ws_up +# gesture swipe down _internal --cols 4 ws_down +# gesture swipe left _internal --cols 4 ws_left +# gesture swipe right _internal --cols 4 ws_right +# +# Example of 16 static workspaces, e.g. using KDE virtual-desktops, +# arranged in 4 rows of 4 columns across using swipe up/down/left/right +# to navigate in fixed planes, and also using swipe +# left_up/left_down/right_up/right_down to navigate diagonally. You can +# also add the "-w/--wrap" option to allow wrapping in any direction +# and/or diagonally. You must configure your virtual desktops with the +# same column dimension. +# gesture swipe up _internal --cols 4 ws_up +# gesture swipe down _internal --cols 4 ws_down +# gesture swipe left _internal --cols 4 ws_left +# gesture swipe right _internal --cols 4 ws_right +# gesture swipe left_up _internal --cols 4 ws_left_up +# gesture swipe left_down _internal --cols 4 ws_left_down +# gesture swipe right_up _internal --cols 4 ws_right_up +# gesture swipe right_down _internal --cols 4 ws_right_down + +# Example virtual desktop switching for Ubuntu Unity/Compiz. The +# _internal command does not work for Compiz but you can explicitly +# configure the swipe commands to work for a Compiz virtual 2 +# dimensional desktop as follows: +# gesture swipe up xdotool key ctrl+alt+Up +# gesture swipe down xdotool key ctrl+alt+Down +# gesture swipe left xdotool key ctrl+alt+Left +# gesture swipe right xdotool key ctrl+alt+Right + +# Example to change audio volume: +# Note this only works on an Xorg desktop (not Wayland). +# gesture swipe up xdotool key XF86AudioRaiseVolume +# gesture swipe down xdotool key XF86AudioLowerVolume + +############################################################################### +# PINCH GESTURES: +############################################################################### + +# GNOME SHELL open/close overview (works for GNOME on Xorg only) +gesture pinch in ydotool key ctrl+- +gesture pinch out ydotool key ctrl+shift+= + +# KDE Plasma open/close overview +# gesture pinch in xdotool key ctrl+F9 +# gesture pinch out xdotool key ctrl+F9 + +# GNOME SHELL open/close overview (works for GNOME on Wayland and Xorg) +# Note since GNOME 3.24 on Wayland this is implemented natively so no +# real point configuring for Wayland. +# gesture pinch in dbus-send --session --type=method_call --dest=org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval string:'Main.overview.toggle();' +# gesture pinch out dbus-send --session --type=method_call --dest=org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval string:'Main.overview.toggle();' + +# Optional extended pinch gestures: +# gesture pinch clockwise +# gesture pinch anticlockwise + +############################################################################### +# This application normally determines your touchpad device +# automatically. Some users may have multiple touchpads but by default +# we use only the first one found. However, you can choose to specify +# the explicit device name to use. Run "libinput list-devices" to work +# out the name of your device (from the "Device:" field). Then add a +# device line specifying that name, e.g: +# +# device DLL0665:01 06CB:76AD Touchpad +# +# If the device name starts with a '/' then it is instead considered as +# the explicit device path although since device paths can change +# through reboots this is best to be a symlink. E.g. instead of specifying +# /dev/input/event12, use the corresponding full path link under +# /dev/input/by-path/ or /dev/input/by-id/. +# +# You can choose to use ALL touchpad devices by setting the device name +# to "all". E.g. Do this if you have multiple touchpads which you want +# to use in parallel. This reduces performance slightly so only set this +# if you have to. +# +# device all + +############################################################################### +# You can set a minimum travel distance threshold before swipe gestures +# are actioned using the swipe_threshold configuration command. +# Specify this value in dots. The default is 0. +# E.g. set it to 100 dots with "swipe_threshold 100". +# swipe_threshold 0 + +############################################################################### +# You can set a timeout on gestures from start to end. The default is +# the value commented below. It can be any value in float secs >= 0. +# 0 = no timeout. E.g. set it to 2 secs with "timeout 2". +# timeout 1.5 diff --git a/profiles/base-user/.config/mako/config b/profiles/base-user/.config/mako/config new file mode 100644 index 00000000..73a16faf --- /dev/null +++ b/profiles/base-user/.config/mako/config @@ -0,0 +1,22 @@ +padding=10 +margin=5,5,0 +default-timeout=5000 + +## Base16 Burn +# Author: Benjamin Bädorf +# +# You can use these variables anywhere in the mako configuration file. + +background-color=#1a181a +text-color=#e3e1e4 +border-color=#ff5f5f + +[urgency=low] +background-color=#1a181a +text-color=#e3e1e4 +border-color=#ff5f5f + +[urgency=high] +background-color=#ff5f5f +text-color=#1a181a +border-color=#1a181a diff --git a/profiles/base-user/.config/mimeapps.list b/profiles/base-user/.config/mimeapps.list new file mode 100644 index 00000000..e69de29b diff --git a/profiles/base-user/.config/mutt/base16.muttrc b/profiles/base-user/.config/mutt/base16.muttrc new file mode 100644 index 00000000..ff30a476 --- /dev/null +++ b/profiles/base-user/.config/mutt/base16.muttrc @@ -0,0 +1,132 @@ +# base16-mutt: base16-shell support for mutt +# +# These depend on mutt compiled with s-lang, not ncurses. Check by running `mutt -v` +# Details this configuration may be found in the mutt manual: +# §3 Patterns +# §9 Using color and mono video attributes + +# https://www.neomutt.org/guide/configuration.html#color +# base00 : color00 - Default Background +# base01 : color18 - Lighter Background (Used for status bars) +# base02 : color19 - Selection Background +# base03 : color08 - Comments, Invisibles, Line Highlighting + +# base04 : color20 - Dark Foreground (Used for status bars) +# base05 : color07 - Default Foreground, Caret, Delimiters, Operators +# base06 : color21 - Light Foreground (Not often used) +# base07 : color15 - Light Background (Not often used) + +# base08 : color01 - Index Item: Deleted. +# base09 : color16 - Message: URL. +# base0A : color03 - Search Text Background. Message: Bold. +# base0B : color02 - Message: Code. Index Item: Tagged. +# base0C : color06 - Message: Subject, Quotes. Index Item: Trusted. +# base0D : color04 - Message: Headings. +# base0E : color05 - Message: Italic, Underline. Index Item: Flagged. +# base0F : color17 - Deprecated, Opening/Closing Embedded Language Tags e.g. + +## Base +color normal color07 color00 # softer, bold + +## Weak +color tilde color08 color00 # `~` padding at the end of pager +color attachment color08 color00 +color tree color08 color00 # arrow in threads +color signature color08 color00 +color markers color08 color00 # `+` wrap indicator in pager + +## Strong +color bold color21 color00 +color underline color21 color00 + +## Highlight +color error color01 color00 +color message color02 color00 # informational messages +color search color00 color01 +color status color01 color18 +color indicator color03 color19 # inverse, brighter + + +# Message Index ---------------------------------------------------------------- + +## Weak +color index color08 color00 "~R" # read messages +color index color08 color00 "~d >45d" # older than 45 days +color index color08 color00 "~v~(!~N)" # collapsed thread with no unread +color index color08 color00 "~Q" # messages that have been replied to + +## Strong +color index color01 color00 "(~U|~N|~O)" # unread, new, old messages +color index color01 color00 "~v~(~U|~N|~O)" # collapsed thread with unread + +## Highlight +### Trusted +color index color06 color00 "~g" # PGP signed messages +color index color06 color00 "~G" # PGP encrypted messages +### Odd +color index color01 color00 "~E" # past Expires: header date +color index color01 color00 "~=" # duplicated +color index color01 color00 "~S" # marked by Supersedes: header +### Flagged +color index color05 color00 "~F" # flagged messages +color index color02 color00 "~v~(~F)" # collapsed thread with flagged inside + +# Selection +color index color02 color18 "~T" # tagged messages +color index color01 color18 "~D" # deleted messages + +### Message Headers ---------------------------------------------------- + +# Base +color hdrdefault color07 color00 +color header color07 color00 "^" +# Strong +color header color21 color00 "^(From)" +# Highlight +color header color04 color00 "^(Subject)" + +### Message Body ------------------------------------------------------- +# When possible, these regular expressions attempt to match http://spec.commonmark.org/ +## Weak +# ~~~ Horizontal rules ~~~ +color body color08 color00 "([[:space:]]*[-+=#*~_]){3,}[[:space:]]*" +## Strong +# *Bold* span +color body color03 color00 "(^|[[:space:][:punct:]])\\*[^*]+\\*([[:space:][:punct:]]|$)" +# _Underline_ span +color body color05 color00 "(^|[[:space:][:punct:]])_[^_]+_([[:space:][:punct:]]|$)" +# /Italic/ span (Sometimes gets directory names) +color body color05 color00 "(^|[[:space:][:punct:]])/[^/]+/([[:space:][:punct:]]|$)" +# ATX headers +color body color04 color00 "^[[:space:]]{0,3}#+[[:space:]].*$" +## Highlight +# `Code` span +color body color02 color00 "(^|[[:space:][:punct:]])\`[^\`]+\`([[:space:][:punct:]]|$)" +# Indented code block +color body color02 color00 "^[[:space:]]{4,}.*$" +# URLs +color body color16 color00 "([a-z][a-z0-9+-]*://(((([a-z0-9_.!~*'();:&=+$,-]|%[0-9a-f][0-9a-f])*@)?((([a-z0-9]([a-z0-9-]*[a-z0-9])?)\\.)*([a-z]([a-z0-9-]*[a-z0-9])?)\\.?|[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+)(:[0-9]+)?)|([a-z0-9_.!~*'()$,;:@&=+-]|%[0-9a-f][0-9a-f])+)(/([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*(;([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*)*(/([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*(;([a-z0-9_.!~*'():@&=+$,-]|%[0-9a-f][0-9a-f])*)*)*)?(\\?([a-z0-9_.!~*'();/?:@&=+$,-]|%[0-9a-f][0-9a-f])*)?(#([a-z0-9_.!~*'();/?:@&=+$,-]|%[0-9a-f][0-9a-f])*)?|(www|ftp)\\.(([a-z0-9]([a-z0-9-]*[a-z0-9])?)\\.)*([a-z]([a-z0-9-]*[a-z0-9])?)\\.?(:[0-9]+)?(/([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*(;([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*)*(/([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*(;([-a-z0-9_.!~*'():@&=+$,]|%[0-9a-f][0-9a-f])*)*)*)?(\\?([-a-z0-9_.!~*'();/?:@&=+$,]|%[0-9a-f][0-9a-f])*)?(#([-a-z0-9_.!~*'();/?:@&=+$,]|%[0-9a-f][0-9a-f])*)?)[^].,:;!)? \t\r\n<>\"]" +# Email addresses +color body color16 color00 "((@(([0-9a-z-]+\\.)*[0-9a-z-]+\\.?|#[0-9]+|\\[[0-9]?[0-9]?[0-9]\\.[0-9]?[0-9]?[0-9]\\.[0-9]?[0-9]?[0-9]\\.[0-9]?[0-9]?[0-9]\\]),)*@(([0-9a-z-]+\\.)*[0-9a-z-]+\\.?|#[0-9]+|\\[[0-9]?[0-9]?[0-9]\\.[0-9]?[0-9]?[0-9]\\.[0-9]?[0-9]?[0-9]\\.[0-9]?[0-9]?[0-9]\\]):)?[0-9a-z_.+%$-]+@(([0-9a-z-]+\\.)*[0-9a-z-]+\\.?|#[0-9]+|\\[[0-2]?[0-9]?[0-9]\\.[0-2]?[0-9]?[0-9]\\.[0-2]?[0-9]?[0-9]\\.[0-2]?[0-9]?[0-9]\\])" +# Emoticons ;-P +color body black yellow "[;:][-o]?[})>{(<|P]" + +# PGP +color body color21 color01 "(BAD signature)" +color body color21 color01 "^gpg: BAD signature from.*" +color body color21 color04 "(Good signature)" +color body color21 color04 "^gpg: Good signature .*" +color body color04 color00 "^gpg: " + + +## Quotation blocks +color quoted color06 color00 +color quoted1 color02 color00 +color quoted2 color03 color00 +color quoted3 color16 color00 +color quoted4 color01 color00 +color quoted5 color17 color00 +color quoted6 color05 color00 +color quoted7 color04 color00 + +# vi: ft=muttrc diff --git a/profiles/base-user/.config/mutt/mailcap b/profiles/base-user/.config/mutt/mailcap new file mode 100644 index 00000000..f6cb96a1 --- /dev/null +++ b/profiles/base-user/.config/mutt/mailcap @@ -0,0 +1 @@ +text/html; w3m -I %{charset} -T text/html; copiousoutput; diff --git a/profiles/base-user/.config/mutt/muttrc b/profiles/base-user/.config/mutt/muttrc new file mode 100644 index 00000000..37a78c70 --- /dev/null +++ b/profiles/base-user/.config/mutt/muttrc @@ -0,0 +1,104 @@ +# vim: filetype=muttrc + +source $XDG_CONFIG_HOME/mutt/base16.muttrc +source $XDG_CONFIG_HOME/mutt/accounts.muttrc + +set editor = `echo \$EDITOR` + +set sidebar_visible = yes +set sidebar_width = 50 +set sidebar_format = "%B%?F? [%F]?%* %?N?%N/?%S" + +set sendmail_wait = 0 + +set mail_check_stats + +set crypt_use_gpgme=yes +set crypt_autosign=yes +set crypt_verify_sig=yes +set crypt_replysign=yes +set crypt_replyencrypt=yes +set crypt_replysignencrypted=yes +set crypt_autoencrypt=yes + +set pgp_check_gpg_decrypt_status_fd +set pgp_use_gpg_agent=yes +set pgp_self_encrypt=yes + +# Store message headers locally to speed things up. +# If hcache is a folder, Mutt will create sub cache folders for each account which may speeds things up even more. +set header_cache = $XDG_CACHE_HOME/mutt + +# Store messages locally to speed things up, like searching message bodies. +# Can be the same folder as header_cache. +# This will cost important disk usage according to your e-mail amount. +set message_cachedir = $XDG_CACHE_HOME/mutt +set imap_check_subscribed + +# Allow Mutt to open a new IMAP connection automatically. +unset imap_passive + +# Keep the IMAP connection alive by polling intermittently (time in seconds). +set imap_keepalive = 300 + +# How often to check for new mail (time in seconds). +set mail_check = 120 + +set askcc +set askbcc + +set date_format="!%d.%m.%Y %H:%M" +set index_format="%4C %Z %D %4c %20.20L %s" + +#------------------------------------------------------------ +# Vi Key Bindings +#------------------------------------------------------------ + +# Moving around +bind generic g noop +bind generic gg first-entry +bind generic,index G last-entry +bind generic,index i previous-entry +bind generic,index k next-entry + +bind pager,index d noop +bind pager,index dd delete-message + +bind pager i previous-line +bind pager k next-line +bind pager I previous-entry +bind pager K next-entry + +bind pager r noop +bind pager rr reply +bind pager ra group-reply +bind pager rn group-chat-reply +bind pager rl list-reply + +# Threads +bind browser,pager,index N search-opposite +bind pager,index dT delete-thread +bind pager,index dt delete-subthread +bind pager,index g noop +bind pager,index gt next-thread +bind pager,index gT previous-thread +bind index za collapse-thread +bind index zA collapse-all # Missing :folddisable/foldenable + +# Enable URL opening +macro index,pager \cb " urlscan" "call urlscan to extract URLs out of a message" +macro attach,compose \cb " urlscan" "call urlscan to extract URLs out of a message" + +# Translate markdown to html +macro compose \e5 "F pandoc -s -f markdown -t html \ny^T^Utext/html; charset=utf-8\n" +set wait_key=no + +# Save to ~/Downloads by default +macro attach D "~/Downloads/" "Save to Downloads" + +set mailcap_path = $XDG_CONFIG_HOME/mutt/mailcap + +# HTML emails +auto_view text/html # view html automatically +alternative_order text/plain text/enriched text/html # save html for last + diff --git a/profiles/base-user/.config/offlineimap/functions.py b/profiles/base-user/.config/offlineimap/functions.py new file mode 100644 index 00000000..110b9e4b --- /dev/null +++ b/profiles/base-user/.config/offlineimap/functions.py @@ -0,0 +1,9 @@ +#! /usr/bin/env python2 +import os +import subprocess + +def get_env(key): + return os.getenv(key) + +def get_secret(*attributes): + return subprocess.check_output(["secret-tool", "lookup"] + list(attributes)) diff --git a/profiles/base-user/.config/user-dirs.dirs b/profiles/base-user/.config/user-dirs.dirs new file mode 100644 index 00000000..5a833b8f --- /dev/null +++ b/profiles/base-user/.config/user-dirs.dirs @@ -0,0 +1,15 @@ +# This file is written by xdg-user-dirs-update +# If you want to change or add directories, just edit the line you're +# interested in. All local changes will be retained on the next run. +# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped +# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an +# absolute path. No other format is supported. +# +XDG_DESKTOP_DIR="$HOME/" +XDG_DOWNLOAD_DIR="$HOME/Downloads" +XDG_TEMPLATES_DIR="$HOME/Templates" +XDG_PUBLICSHARE_DIR="$HOME/Public" +XDG_DOCUMENTS_DIR="$HOME/" +XDG_MUSIC_DIR="$HOME/" +XDG_PICTURES_DIR="$HOME/" +XDG_VIDEOS_DIR="$HOME/" diff --git a/profiles/base-user/.config/user-dirs.locale b/profiles/base-user/.config/user-dirs.locale new file mode 100644 index 00000000..3e0b4191 --- /dev/null +++ b/profiles/base-user/.config/user-dirs.locale @@ -0,0 +1 @@ +en_US \ No newline at end of file diff --git a/profiles/base-user/.config/vifm/colors/base16.vifm b/profiles/base-user/.config/vifm/colors/base16.vifm new file mode 100644 index 00000000..70ae0ee9 --- /dev/null +++ b/profiles/base-user/.config/vifm/colors/base16.vifm @@ -0,0 +1,26 @@ +" Reset all styles first +highlight clear + +highlight Border cterm=none ctermfg=235 ctermbg=0 + +highlight TopLine cterm=none ctermfg=20 ctermbg=18 +highlight TopLineSel cterm=none ctermfg=1 ctermbg=18 + +highlight Win cterm=none ctermfg=188 ctermbg=0 +highlight Directory cterm=bold ctermfg=4 ctermbg=0 +highlight CurrLine cterm=none ctermfg=3 ctermbg=19 +highlight OtherLine cterm=none ctermfg=3 ctermbg=19 +highlight Selected cterm=none ctermfg=5 ctermbg=19 + +highlight JobLine cterm=bold ctermfg=0 ctermbg=18 +highlight StatusLine cterm=bold ctermfg=0 ctermbg=18 +highlight ErrorMsg cterm=bold ctermfg=0 ctermbg=18 +highlight WildMenu cterm=bold ctermfg=0 ctermbg=18 +highlight CmdLine cterm=none ctermfg=20 ctermbg=0 + +highlight Executable cterm=bold ctermfg=2 ctermbg=0 +highlight Link cterm=none ctermfg=9 ctermbg=0 +highlight BrokenLink cterm=none ctermfg=1 ctermbg=0 +highlight Device cterm=none ctermfg=228 ctermbg=0 +highlight Fifo cterm=none ctermfg=109 ctermbg=0 +highlight Socket cterm=none ctermfg=110 ctermbg=0 diff --git a/profiles/base-user/.config/vifm/vifmrc b/profiles/base-user/.config/vifm/vifmrc new file mode 100644 index 00000000..3a10e173 --- /dev/null +++ b/profiles/base-user/.config/vifm/vifmrc @@ -0,0 +1,495 @@ +" vim: filetype=vifm : +" Sample configuration file for vifm (last updated: 2 June, 2019) +" You can edit this file by hand. +" The " character at the beginning of a line comments out the line. +" Blank lines are ignored. +" The basic format for each item is shown with an example. + +" ------------------------------------------------------------------------------ + +" Command used to edit files in various contexts. The default is vim. +" If you would like to use another vi clone such as Elvis or Vile +" you will need to change this setting. + +set vicmd=nvim +" set vicmd=elvis\ -G\ termcap +" set vicmd=vile + +" This makes vifm perform file operations on its own instead of relying on +" standard utilities like `cp`. While using `cp` and alike is a more universal +" solution, it's also much slower when processing large amounts of files and +" doesn't support progress measuring. + +set syscalls + +" Trash Directory +" The default is to move files that are deleted with dd or :d to +" the trash directory. If you change this you will not be able to move +" files by deleting them and then using p to put the file in the new location. +" I recommend not changing this until you are familiar with vifm. +" This probably shouldn't be an option. + +set trash + +" This is how many directories to store in the directory history. + +set history=100 + +" Automatically resolve symbolic links on l or Enter. + +set nofollowlinks + +" With this option turned on you can run partially entered commands with +" unambiguous beginning using :! (e.g. :!Te instead of :!Terminal or :!Te). + +" set fastrun + +" Natural sort of (version) numbers within text. + +set sortnumbers + +" Maximum number of changes that can be undone. + +set undolevels=100 + +" Use Vim's format of help file (has highlighting and "hyperlinks"). +" If you would rather use a plain text help file set novimhelp. + +set vimhelp + +" If you would like to run an executable file when you +" press return on the file name set this. + +set norunexec + +" Selected color scheme + +colorscheme base16 + +" Format for displaying time in file list. For example: +" TIME_STAMP_FORMAT=%m/%d-%H:%M +" See man date or man strftime for details. + +set timefmt=%m/%d\ %H:%M + +" Show list of matches on tab completion in command-line mode + +set wildmenu + +" Display completions in a form of popup with descriptions of the matches + +set wildstyle=popup + +" Display suggestions in normal, visual and view modes for keys, marks and +" registers (at most 5 files). In other view, when available. + +set suggestoptions=normal,visual,view,otherpane,keys,marks,registers + +" Ignore case in search patterns unless it contains at least one uppercase +" letter + +set ignorecase +set smartcase + +" Don't highlight search results automatically + +set nohlsearch + +" Use increment searching (search while typing) +set incsearch + +" Try to leave some space from cursor to upper/lower border in lists + +set scrolloff=4 + +" Don't do too many requests to slow file systems + +if !has('win') + set slowfs=curlftpfs +endif + +" Set custom status line look + +set statusline=" Hint: %z%= %A %10u:%-7g %15s %20d " + +" ------------------------------------------------------------------------------ + +" :mark mark /full/directory/path [filename] + +mark b ~/bin/ +mark h ~/ + +" ------------------------------------------------------------------------------ + +" :com[mand][!] command_name action +" The following macros can be used in a command +" %a is replaced with the user arguments. +" %c the current file under the cursor. +" %C the current file under the cursor in the other directory. +" %f the current selected file, or files. +" %F the current selected file, or files in the other directory. +" %b same as %f %F. +" %d the current directory name. +" %D the other window directory name. +" %m run the command in a menu window + +command! df df -h %m 2> /dev/null +command! diff vim -d %f %F +command! zip zip -r %f.zip %f +command! unzip unzip %c %c.extracted +command! run !! ./%f +command! make !!make %a +command! mkcd :mkdir %a | cd %a +command! vgrep vim "+grep %a" +command! reload :write | restart + +" ------------------------------------------------------------------------------ + +" The file type is for the default programs to be used with +" a file extension. +" :filetype pattern1,pattern2 defaultprogram,program2 +" :fileviewer pattern1,pattern2 consoleviewer +" The other programs for the file type can be accessed with the :file command +" The command macros %f, %F, %d, %F may be used in the commands. +" The %a macro is ignored. To use a % you must put %%. + +" For automated FUSE mounts, you must register an extension with :file[x]type +" in one of following formats: +" +" :filetype extensions FUSE_MOUNT|some_mount_command using %SOURCE_FILE and %DESTINATION_DIR variables +" %SOURCE_FILE and %DESTINATION_DIR are filled in by vifm at runtime. +" A sample line might look like this: +" :filetype *.zip,*.jar,*.war,*.ear FUSE_MOUNT|fuse-zip %SOURCE_FILE %DESTINATION_DIR +" +" :filetype extensions FUSE_MOUNT2|some_mount_command using %PARAM and %DESTINATION_DIR variables +" %PARAM and %DESTINATION_DIR are filled in by vifm at runtime. +" A sample line might look like this: +" :filetype *.ssh FUSE_MOUNT2|sshfs %PARAM %DESTINATION_DIR +" %PARAM value is filled from the first line of file (whole line). +" Example first line for SshMount filetype: root@127.0.0.1:/ +" +" You can also add %CLEAR if you want to clear screen before running FUSE +" program. + +" Pdf +filextype *.pdf epdfview %c %i &, apvlv %c, xpdf %c +fileviewer *.pdf + \ vifmimg pdfpreview %px %py %pw %ph %c + \ %pc + \ vifmimg clear + " \ pdftotext -nopgbrk %c - + +" PostScript +filextype *.ps,*.eps,*.ps.gz + \ {View in zathura} + \ zathura %f, + \ {View in gv} + \ gv %c %i &, + +" Djvu +filextype *.djvu + \ {View in zathura} + \ zathura %f, + \ {View in apvlv} + \ apvlv %f, + +" Audio +filetype *.wav,*.mp3,*.flac,*.m4a,*.wma,*.ape,*.ac3,*.og[agx],*.spx,*.opus + \ {Play using vlc} + \ vlc %c, + \ {Play using ffplay} + \ ffplay -nodisp -autoexit %c, +fileviewer *.mp3 mp3info +fileviewer *.flac soxi + +" Video +filextype *.avi,*.mp4,*.wmv,*.dat,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob, + \*.fl[icv],*.m2v,*.mov,*.webm,*.ts,*.mts,*.m4v,*.r[am],*.qt,*.divx, + \*.as[fx] + \ {View using vlc} + \ vlc %f, + \ {View using ffplay} + \ ffplay -fs -autoexit %f, +fileviewer *.avi,*.mp4,*.wmv,*.dat,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob, + \*.fl[icv],*.m2v,*.mov,*.webm,*.ts,*.mts,*.m4v,*.r[am],*.qt,*.divx, + \*.as[fx] + \ vifmimg videopreview %px %py %pw %ph %c + \ %pc + \ vifmimg clear + " \ ffprobe -pretty %c 2>&1 + +" Web +filextype *.html,*.htm + \ {Open with vim} + \ nvim %f, + \ {Open with firefox} + \ firefox-developer-edition %f &, +filetype *.html,*.htm links, lynx + +" Object +filetype *.o nm %f | less + +" Man page +filetype *.[1-8] man ./%c +fileviewer *.[1-8] man ./%c | col -b + +" Images +filextype *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm + \ {View in viewnior} + \ viewnior %f, +fileviewer *.bmp,*.jpg,*.jpeg,*.png,*.xpm + \ vifmimg draw %px %py %pw %ph %c + \ %pc + \ vifmimg clear + " Get w3m image previews inside vifm + " \ imgt %px %py %pw %ph %c + " \ %pc + " \ imgc %px %py %pw %ph NOT NEEDED IN XTERM +fileviewer *.gif + \ vifmimg gifpreview %px %py %pw %ph %c + \ %pc + \ vifmimg clear + +" OpenRaster +filextype *.ora + \ {Edit in MyPaint} + \ mypaint %f, + +" Mindmap +filextype *.vym + \ {Open with VYM} + \ vym %f &, + +" MD5 +filetype *.md5 + \ {Check MD5 hash sum} + \ md5sum -c %f %S, + +" SHA1 +filetype *.sha1 + \ {Check SHA1 hash sum} + \ sha1sum -c %f %S, + +" SHA256 +filetype *.sha256 + \ {Check SHA256 hash sum} + \ sha256sum -c %f %S, + +" SHA512 +filetype *.sha512 + \ {Check SHA512 hash sum} + \ sha512sum -c %f %S, + +" GPG signature +filetype *.asc + \ {Check signature} + \ !!gpg --verify %c, + +" Torrent +filetype *.torrent ktorrent %f & +fileviewer *.torrent dumptorrent -v %c + +" FuseZipMount +filetype *.zip,*.jar,*.war,*.ear,*.oxt,*.apkg + \ {Mount with fuse-zip} + \ FUSE_MOUNT|fuse-zip %SOURCE_FILE %DESTINATION_DIR, + \ {View contents} + \ zip -sf %c | less, + \ {Extract here} + \ tar -xf %c, +fileviewer *.zip,*.jar,*.war,*.ear,*.oxt zip -sf %c + +" ArchiveMount +filetype *.tar,*.tar.bz2,*.tbz2,*.tgz,*.tar.gz,*.tar.xz,*.txz + \ {Mount with archivemount} + \ FUSE_MOUNT|archivemount %SOURCE_FILE %DESTINATION_DIR, +fileviewer *.tgz,*.tar.gz tar -tzf %c +fileviewer *.tar.bz2,*.tbz2 tar -tjf %c +fileviewer *.tar.txz,*.txz xz --list %c +fileviewer *.tar tar -tf %c + +" Rar2FsMount and rar archives +filetype *.rar + \ {Mount with rar2fs} + \ FUSE_MOUNT|rar2fs %SOURCE_FILE %DESTINATION_DIR, +fileviewer *.rar unrar v %c + +" IsoMount +filetype *.iso + \ {Mount with fuseiso} + \ FUSE_MOUNT|fuseiso %SOURCE_FILE %DESTINATION_DIR, + +" SshMount +filetype *.ssh + \ {Mount with sshfs} + \ FUSE_MOUNT2|sshfs %PARAM %DESTINATION_DIR %FOREGROUND, + +" FtpMount +filetype *.ftp + \ {Mount with curlftpfs} + \ FUSE_MOUNT2|curlftpfs -o ftp_port=-,,disable_eprt %PARAM %DESTINATION_DIR %FOREGROUND, + +" Fuse7z and 7z archives +filetype *.7z + \ {Mount with fuse-7z} + \ FUSE_MOUNT|fuse-7z %SOURCE_FILE %DESTINATION_DIR, +fileviewer *.7z 7z l %c + +" Office files +filextype *.odt,*.doc,*.docx,*.xls,*.xlsx,*.odp,*.pptx libreoffice %f & +fileviewer *.doc catdoc %c +fileviewer *.docx docx2txt.pl %f - + +" TuDu files +filetype *.tudu tudu -f %c + +" Qt projects +filextype *.pro qtcreator %f & + +" All others +filetype *.ts,*.js,*.css,*.sass,*.scss,*.go,*.rs,*.py,*.html,*.xhtml,*.json,*.jsx,*.tsx,*.vue,*.svelte,*.sql + \ {Open in editor} + \ nvim %c, +fileviewer *.ts,*.js,*.css,*.sass,*.scss,*.go,*.rs,*.py,*.html,*.xhtml,*.json,*.jsx,*.tsx,*.vue,*.svelte,*.sql bat %c + +" Directories +filextype */ + \ {View in thunar} + \ Thunar %f &, + +" Syntax highlighting in preview +" +" Explicitly set highlight type for some extensions +" +" 256-color terminal +" fileviewer *.[ch],*.[ch]pp highlight -O xterm256 -s dante --syntax c %c +" fileviewer Makefile,Makefile.* highlight -O xterm256 -s dante --syntax make %c +" +" 16-color terminal +" fileviewer *.c,*.h highlight -O ansi -s dante %c +" +" Or leave it for automatic detection +" +" fileviewer *[^/] pygmentize -O style=monokai -f console256 -g + +" Displaying pictures in terminal +" +" fileviewer *.jpg,*.png shellpic %c + +" Open all other files with default system programs (you can also remove all +" :file[x]type commands above to ensure they don't interfere with system-wide +" settings). By default all unknown files are opened with 'vi[x]cmd' +" uncommenting one of lines below will result in ignoring 'vi[x]cmd' option +" for unknown file types. +" For *nix: +" filetype * xdg-open +" For OS X: +" filetype * open +" For Windows: +" filetype * start, explorer + +" ------------------------------------------------------------------------------ + +" What should be saved automatically between vifm sessions. Drop "savedirs" +" value if you don't want vifm to remember last visited directories for you. +set vifminfo=dhistory,savedirs,chistory,state,tui,shistory, + \phistory,fhistory,dirstack,registers,bookmarks,bmarks + +" ------------------------------------------------------------------------------ + +" Examples of configuring both panels + +" Customize view columns a bit (enable ellipsis for truncated file names) +" +" set viewcolumns=-{name}..,6{}. + +" Filter-out build and temporary files +" +" filter! /^.*\.(lo|o|d|class|py[co])$|.*~$/ + +" ------------------------------------------------------------------------------ + +" Sample mappings + +" Start shell in current directory +nnoremap s :shell + +" Display sorting dialog +nnoremap S :sort + +" Toggle visibility of preview window +nnoremap w :view +vnoremap w :viewgv + +" Open file in existing instance of nvim +nnoremap o :!vim %f +" Open file in new instance of vim +nnoremap O :!vim %f + +" Open file in the background using its default program +nnoremap gb :file &l + +" Interaction with system clipboard +if has('win') + " Yank current directory path to Windows clipboard with forward slashes + nnoremap yp :!echo %"d:gs!\!/! %i | clip + " Yank path to current file to Windows clipboard with forward slashes + nnoremap yf :!echo %"c:gs!\!/! %i | clip +elseif executable('xclip') + " Yank current directory path into the clipboard + nnoremap yd :!echo %d | xclip %i + " Yank current file path into the clipboard + nnoremap yf :!echo %c:p | xclip %i +elseif executable('xsel') + " Yank current directory path into primary and selection clipboards + nnoremap yd :!echo -n %d | xsel --input --primary %i && + \ echo -n %d | xsel --clipboard --input %i + " Yank current file path into into primary and selection clipboards + nnoremap yf :!echo -n %c:p | xsel --input --primary %i && + \ echo -n %c:p | xsel --clipboard --input %i +endif + +" Mappings for faster renaming +nnoremap I cw +nnoremap cc cw +nnoremap A cw + +" Open console in current directory +nnoremap ,t :!xterm & + +" Open editor to edit vifmrc and apply settings after returning to vifm +nnoremap ,c :write | edit $MYVIFMRC | restart +" Open gvim to edit vifmrc +nnoremap ,C :!gvim --remote-tab-silent $MYVIFMRC & + +" Toggle wrap setting on ,w key +nnoremap ,w :set wrap! + +" Example of standard two-panel file managers mappings +nnoremap :!less %f +nnoremap :edit +nnoremap :copy +nnoremap :move +nnoremap :mkdir +nnoremap :delete + +" Arrow remapping +map i +map j +map k +noremap h i + +vnoremap K L +vnoremap I H +vnoremap H I + +nnoremap K L +nnoremap I H +nnoremap H I + +" Escape overwrite +cmap jj + +" fzf +command! FZFfind :set noquickview | :execute 'goto "'.system('fd --hidden --exclude .git --exclude node_modules | fzf --preview "ls -lhA --group-directories-first --color=always {}" --preview-window wrap 2>/dev/tty ').'"%IU' | redraw +nnoremap :FZFfind diff --git a/profiles/base-user/.config/waybar/colorscheme.css b/profiles/base-user/.config/waybar/colorscheme.css new file mode 100644 index 00000000..9cb06b31 --- /dev/null +++ b/profiles/base-user/.config/waybar/colorscheme.css @@ -0,0 +1,23 @@ +/* +* +* Base16 Burn +* Author: Benjamin Bädorf +* +*/ + +@define-color base00 #1a181a; +@define-color base01 #2d2a2e; +@define-color base02 #303030; +@define-color base03 #949494; +@define-color base04 #d3d1d4; +@define-color base05 #e3e1e4; +@define-color base06 #303030; +@define-color base07 #ff5f5f; +@define-color base08 #f85e84; +@define-color base09 #df5923; +@define-color base0A #e5c463; +@define-color base0B #9ecd6f; +@define-color base0C #ef9062; +@define-color base0D #7accd7; +@define-color base0E #ab9df2; +@define-color base0F #d70000; diff --git a/profiles/base-user/.config/waybar/config b/profiles/base-user/.config/waybar/config new file mode 100644 index 00000000..b2231671 --- /dev/null +++ b/profiles/base-user/.config/waybar/config @@ -0,0 +1,102 @@ +{ + "layer": "top", // Waybar at top layer + // "position": "bottom", // Waybar position (top|bottom|left|right) + + "height": 26, // Waybar height + "modules-left": ["sway/workspaces", "sway/mode"], + "modules-center": ["mpd"], + "modules-right": ["sway/language", "pulseaudio", "network", "idle_inhibitor", "battery", "clock", "tray"], + "sway/workspaces": { + "disable-scroll": true + }, + "sway/mode": { + "tooltip": false, + "format": "{}" + }, + "sway/window": { + "tooltip": false, + "max-length": 96 + }, + "sway/language": { + "format": "{}", + "max-length": 50 + }, + "tray": { + "icon-size": 21, + "spacing": 10 + }, + "clock": { + "tooltip-format": "{:%Y %B}\n{calendar}", + "format-alt": "{:%a %d. %h %H:%M}" + }, + "backlight": { + // "device": "acpi_video1", + "tooltip": true, + "tooltip-format": "Brightness: {percent}%", + "format": "{icon}", + "format-icons": ["", ""] + }, + "cpu": { + "format": "{}% " + }, + "memory": { + "format": "{}% " + }, + "idle_inhibitor": { + "format": "{icon} ", + "format-icons": { + "activated": "", + "deactivated": "" + } + }, + "battery": { + "tooltip": false, + "states": { + "critical": 25 + }, + "full-at": 84, + "format": "{icon} {capacity}%", + "format-full": "{icon}", + "format-icons": ["", "", "", "", ""], + }, + "network": { + "interval": 3, + "tooltip": true, + //"interface": "wlp4s0", // (Optional) To force the use of this interface   \uF2E7, + "format-wifi": " \uf062 {bandwidthUpBits} | \uf063 {bandwidthDownBits}", + "format-ethernet": " \uf062 {bandwidthUpBits} | \uf063 {bandwidthDownBits}", + "format-disconnected": "", + "tooltip-format-wifi": "{essid} ({signalStrength}%)  {ipaddr}", + "tooltip-format-ethernet": "{ifname}  {ipaddr}" + }, + //\ue04f{volume}% + "pulseaudio": { + "tooltip": false, + "format": "{volume}% {icon}", + "format-bluetooth": "{volume}% {icon}", + "format-muted": "", + "on-click": "pavucontrol", + "format-alt": "{volume}% {icon}", + "format-icons": { + "headphones": "", + "handsfree": "", + "headset": "", + "phone": "", + "portable": "", + "car": "", + "default": ["","", ""] + } + }, + "mpd": { + "format": "{artist} - {title} [{elapsedTime:%M:%S} / {totalTime:%M:%S}]", + "format-disconnected": "", + "format-stopped": "", + "interval": 1, + "state-icons": { + "paused": "", + "playing": "" + }, + "tooltip-format": "MPD (connected)", + "tooltip-format-disconnected": "MPD (disconnected)" + } +} diff --git a/profiles/base-user/.config/waybar/style.css b/profiles/base-user/.config/waybar/style.css new file mode 100644 index 00000000..f4e07cce --- /dev/null +++ b/profiles/base-user/.config/waybar/style.css @@ -0,0 +1,78 @@ +@import "./colorscheme.css"; + +* { + min-height: 0; + border: none; +} + +window#waybar { + font-family: Hack; + font-weight: 500; + font-size: 14px; + background: rgba(11, 12, 13, 0.90); + border-bottom: 1px solid rgba(0, 0, 2, 0.53); + color: @base04; +} + + +#workspaces button { + font-size: 14px; + box-shadow: none; + text-shadow: none; + padding: 0px 3px 0px 3px; + color: @base04; +} + + +#workspaces button.focused { + color: #f85e84; + color: @base07; + /* margin: 2px 0px 2px 0px; */ +} + +#workspaces button:hover { + background: rgba(255, 255, 255, 0.00); + /* margin: 2px 0px 2px 0px; */ +} + +#clock, #backlight, #battery, #cpu, #memory, #network, #pulseaudio, #custom-spotify, #tray, #mode { + font-size: 14px; + margin: 0px 10px 0px 5px; +} + +#pulseaudio { + /* border-top: 1px solid transparent; */ + font-size: 12px; + margin-left: 15px; +} + +#battery { + font-size: 12px; +} + +#battery.critical { + color: @base07; +} +#battery.charging { + color: @base0B; +} +#battery.full { + margin: 0px 0px 0px 0px; +} + + +#network { + border-top: 1px solid transparent; +} +#network.disconnected { + margin: 0px 0px 0px 0px; + color: rgba(75, 81, 98, 0); +} + + +#pulseaudio.muted { + margin: 0px 0px 0px 0px; + color: rgba(75, 81, 98, 0); +} + + diff --git a/profiles/base-user/.config/xmodmap b/profiles/base-user/.config/xmodmap new file mode 100644 index 00000000..3eb325a3 --- /dev/null +++ b/profiles/base-user/.config/xmodmap @@ -0,0 +1,8 @@ +! Swap Caps_Lock and Control_L +! +remove Lock = Caps_Lock +remove Control = Control_L +!keysym Control_L = Caps_Lock +keysym Caps_Lock = Control_L +add Lock = Caps_Lock +add Control = Control_L diff --git a/profiles/base-user/.config/xsettingsd/xsettingsd.conf b/profiles/base-user/.config/xsettingsd/xsettingsd.conf new file mode 100644 index 00000000..8ea990f1 --- /dev/null +++ b/profiles/base-user/.config/xsettingsd/xsettingsd.conf @@ -0,0 +1,18 @@ +Gtk/ButtonImages 1 +Gtk/CanChangeAccels 1 +Gtk/CursorThemeName "default" +Gtk/CursorThemeSize 0 +Gtk/EnableEventSounds 0 +Gtk/EnableInputFeedbackSounds 0 +Gtk/FontName "Lato" +Gtk/ThemeName "Matcha-dark-aliz" +Gtk/IconThemeName "Papirus-Adapta-Nokto-Maia" +Gtk/MenuBarAccel "F10" +Gtk/MenuImages 1 +Gtk/ToolbarIconSize 3 +Gtk/ToolbarStyle "icons" +Xft/Antialias 1 +Xft/DPI 102400 +Xft/Hinting 1 +Xft/HintStyle "hintslight" +Xft/RGBA "rgb" diff --git a/profiles/base-user/.gitignore b/profiles/base-user/.gitignore new file mode 100644 index 00000000..cd8e2eed --- /dev/null +++ b/profiles/base-user/.gitignore @@ -0,0 +1,111 @@ +* + +!*.nix +!/.gitignore + +!/.zshrc +!/.Xdefaults +!/.Xresources +!/.xinitrc +!/.config + +!/assets +!/assets/wallpaper.jpg + +!/.config/dircolors + +!/.config/xmodmap + +!/.config/environment.d +!/.config/environment.d/profile.conf +!/.config/environment.d/drone.conf +!/.config/environment.d/restic.conf + +!/.config/user-dirs.dirs +!/.config/user-dirs.locale + +!/.config/gtk-2.0 +!/.config/gtk-2.0/gtkrc + +!/.config/gtk-3.0 +!/.config/gtk-3.0/settings.ini + +!/.config/xsettingsd +!/.config/xsettingsd/xsettingsd.conf + +!/.config/mako +!/.config/mako/config + +!/.config/alacritty +!/.config/alacritty/alacritty.yml + +!/.config/git +!/.config/git/config + +!/.config/vifm +!/.config/vifm/vifmrc +!/.config/vifm/scripts +!/.config/vifm/colors +!/.config/vifm/colors/base16.vifm + +!/.config/nvim +!/.config/nvim/init.vim +!/.config/nvim/clipboard.vim +!/.config/nvim/lsp.vim +!/.config/nvim/quickfixopenall.vim +!/.config/nvim/ui.vim + +!/.config/mimeapps.list + +!/.config/libinput-gestures.conf + +!/.config/sway +!/.config/sway/config +!/.config/sway/config.d +!/.config/sway/config.d/applications.conf +!/.config/sway/config.d/autostart.conf +!/.config/sway/config.d/colorscheme.conf +!/.config/sway/config.d/custom-keybindings.conf +!/.config/sway/config.d/gaps.conf +!/.config/sway/config.d/input-defaults.conf +!/.config/sway/config.d/systemd.conf +!/.config/sway/config.d/theme.conf +!/.config/sway/config.d/biolimo +!/.config/sway/config.d/biolimo/screens.conf +!/.config/sway/config.d/biolimo/inputs.conf +!/.config/sway/config.d/chocolatebar +!/.config/sway/config.d/chocolatebar/screens.conf + +!/.config/waybar +!/.config/waybar/colorscheme.css +!/.config/waybar/config +!/.config/waybar/style.css + +!/.config/mutt +!/.config/mutt/muttrc +!/.config/mutt/base16.muttrc +!/.config/mutt/mailcap + +!/.config/offlineimap +!/.config/offlineimap/functions.py + +!/.local +!/.local/bin +!/.local/bin/install-base +!/.local/bin/swaylock-bg +!/.local/bin/sway-launcher +!/.local/bin/sway-service +!/.local/bin/toggle-kbd-layout +!/.local/bin/wcwd +!/.local/bin/vifmrun +!/.local/bin/vifmimg +!/.local/bin/s +!/.local/bin/windows +!/.local/bin/import-gtk-settings +!/.local/bin/mailto-mutt +!/.local/bin/setup-host-conf +!/.local/bin/steam-xdg + +!/.local/share +!/.local/share/applications +!/.local/share/applications/userapp-Firefox.desktop diff --git a/profiles/base-user/.xinitrc b/profiles/base-user/.xinitrc new file mode 100644 index 00000000..3c317bfb --- /dev/null +++ b/profiles/base-user/.xinitrc @@ -0,0 +1,75 @@ +#!/bin/sh +# +# ~/.xinitrc +# +# Executed by startx (run your window manager from here) + +userresources=$HOME/.Xresources +usermodmap=$HOME/.config/xmodmap +sysresources=/etc/X11/xinit/.Xresources +sysmodmap=/etc/X11/xinit/.Xmodmap + +DEFAULT_SESSION='i3 --shmlog-size 0' + +xset -b + +if [ -d $HOME/.fonts ]; then + xset +fp $HOME/.fonts + xset fp rehash +fi + +# merge in defaults and keymaps + +if [ -f $sysresources ]; then + xrdb -merge $sysresources +fi + +if [ -f $sysmodmap ]; then + xmodmap $sysmodmap +fi + +if [ -f "$userresources" ]; then + xrdb -merge "$userresources" +fi + +if [ -f "$usermodmap" ]; then + xmodmap "$usermodmap" +fi + +# start some nice programs + +if [ -d /etc/X11/xinit/xinitrc.d ] ; then + for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do + [ -x "$f" ] && . "$f" + done + unset f +fi + +get_session(){ + local dbus_args=(--sh-syntax --exit-with-session) + case $1 in + awesome) dbus_args+=(awesome) ;; + bspwm) dbus_args+=(bspwm-session) ;; + budgie) dbus_args+=(budgie-desktop) ;; + cinnamon) dbus_args+=(cinnamon-session) ;; + deepin) dbus_args+=(startdde) ;; + enlightenment) dbus_args+=(enlightenment_start) ;; + fluxbox) dbus_args+=(startfluxbox) ;; + gnome) dbus_args+=(gnome-session) ;; + i3|i3wm) dbus_args+=(i3 --shmlog-size 0) ;; + jwm) dbus_args+=(jwm) ;; + kde) dbus_args+=(startkde) ;; + lxde) dbus_args+=(startlxde) ;; + lxqt) dbus_args+=(lxqt-session) ;; + mate) dbus_args+=(mate-session) ;; + xfce) dbus_args+=(xfce4-session) ;; + openbox) dbus_args+=(openbox-session) ;; + *) dbus_args+=($DEFAULT_SESSION) ;; + esac + + echo "dbus-launch ${dbus_args[*]}" +} + +exec $(get_session) +xset r rate 660 25 + diff --git a/profiles/base-user/assets/wallpaper.jpg b/profiles/base-user/assets/wallpaper.jpg new file mode 100644 index 00000000..ec0624dc Binary files /dev/null and b/profiles/base-user/assets/wallpaper.jpg differ diff --git a/profiles/base-user/default.nix b/profiles/base-user/default.nix new file mode 100644 index 00000000..e327a736 --- /dev/null +++ b/profiles/base-user/default.nix @@ -0,0 +1,24 @@ +{ config, pkgs, lib, ... }: +let + psCfg = config.pub-solar; +in +{ + imports = [ + ./home.nix + ]; + + users = { + mutableUsers = false; + + users = with pkgs; pkgs.lib.setAttrByPath [ psCfg.user.name ] { + # Indicates whether this is an account for a “real” user. + # This automatically sets group to users, createHome to true, + # home to /home/username, useDefaultShell to true, and isSystemUser to false. + isNormalUser = true; + description = ""; + extraGroups = [ "wheel" "docker" "input" "audio" "networkmanager" "lp" "scanner" ]; + initialHashedPassword = if psCfg.user.password != null then psCfg.user.password else ""; + shell = pkgs.zsh; + }; + }; +} diff --git a/profiles/base-user/home.nix b/profiles/base-user/home.nix new file mode 100644 index 00000000..6d7c87d2 --- /dev/null +++ b/profiles/base-user/home.nix @@ -0,0 +1,70 @@ +{ config, pkgs, lib, ... }: +with lib; +let + psCfg = config.pub-solar; + xdg = config.home-manager.users."${psCfg.user.name}".xdg; +in +{ + imports = [ + ./session-variables.nix + ]; + + home-manager = pkgs.lib.setAttrByPath [ "users" psCfg.user.name ] { + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; + + # Home Manager needs a bit of information about you and the + # paths it should manage. + home.username = psCfg.user.name; + home.homeDirectory = "/home/${psCfg.user.name}"; + + home.packages = with pkgs; [ ]; + + fonts.fontconfig.enable = true; + + programs.dircolors.enable = true; + programs.dircolors.enableZshIntegration = true; + + home.file."xinitrc".source = ./.xinitrc; + + xdg.enable = true; + xdg.mime.enable = true; + xdg.mimeApps = import ./mimeapps.nix; + + xdg.configFile."git/config".text = import ./.config/git/config.nix { inherit config; inherit pkgs; }; + xdg.configFile."dircolors".source = ./.config/dircolors; + xdg.configFile."xmodmap".source = ./.config/xmodmap; + xdg.configFile."user-dirs.dirs".source = ./.config/user-dirs.dirs; + xdg.configFile."user-dirs.locale".source = ./.config/user-dirs.locale; + xdg.configFile."xsettingsd/xsettingsd.conf".source = ./.config/xsettingsd/xsettingsd.conf; + xdg.configFile."mako/config".source = ./.config/mako/config; + xdg.configFile."vifm/vifmrc".source = ./.config/vifm/vifmrc; + xdg.configFile."vifm/colors/base16.vifm".source = ./.config/vifm/colors/base16.vifm; + xdg.configFile."libinput-gestures.conf".source = ./.config/libinput-gestures.conf; + xdg.configFile."waybar/config".source = ./.config/waybar/config; + xdg.configFile."waybar/style.css".source = ./.config/waybar/style.css; + xdg.configFile."waybar/colorscheme.css".source = ./.config/waybar/colorscheme.css; + xdg.configFile."mutt/muttrc".source = ./.config/mutt/muttrc; + xdg.configFile."mutt/base16.muttrc".source = ./.config/mutt/base16.muttrc; + xdg.configFile."mutt/mailcap".source = ./.config/mutt/mailcap; + xdg.configFile."offlineimap/functions.py".source = ./.config/offlineimap/functions.py; + xdg.configFile."wallpaper.jpg".source = ./assets/wallpaper.jpg; + + # Ensure nvim backup directory gets created + # Workaround for E510: Can't make backup file (add ! to override) + xdg.dataFile."nvim/backup/.keep".text = ""; + + # Allow unfree packages only on a user basis, not on a system-wide basis + xdg.configFile."nixpkgs/config.nix".text = " { allowUnfree = true; } "; + + # This value determines the Home Manager release that your + # configuration is compatible with. This helps avoid breakage + # when a new Home Manager release introduces backwards + # incompatible changes. + # + # You can update Home Manager without changing this value. See + # the Home Manager release notes for a list of state version + # changes in each release. + home.stateVersion = "21.03"; + }; +} diff --git a/profiles/base-user/mimeapps.nix b/profiles/base-user/mimeapps.nix new file mode 100644 index 00000000..f6b4d2d5 --- /dev/null +++ b/profiles/base-user/mimeapps.nix @@ -0,0 +1,25 @@ +{ + enable = true; + defaultApplications = { + "x-scheme-handler/http" = [ "firefox.desktop" ]; + "x-scheme-handler/https" = [ "firefox.desktop" ]; + "x-scheme-handler/ftp" = [ "firefox.desktop" ]; + "x-scheme-handler/chrome" = [ "firefox.desktop" ]; + "text/html" = [ "firefox.desktop" ]; + "application/x-extension-htm" = [ "firefox.desktop" ]; + "application/x-extension-html" = [ "firefox.desktop" ]; + "application/x-extension-shtml" = [ "firefox.desktop" ]; + "application/xhtml+xml" = [ "firefox.desktop" ]; + "application/x-extension-xhtml" = [ "firefox.desktop" ]; + "application/x-extension-xht" = [ "firefox.desktop" ]; + "image/jpeg" = [ "viewnior.desktop" "gpicview.desktop" ]; + "image/png" = [ "viewnior.desktop" "gpicview.desktop" ]; + "text/plain" = [ "mousepad.desktop" ]; + "x-scheme-handler/mailto" = [ "userapp-Thunderbird.desktop" ]; + "message/rfc822" = [ "userapp-Thunderbird.desktop" ]; + "application/pdf" = [ "org.gnome.Evince.desktop" ]; + "application/x-bittorrent" = [ "deluge.desktop" ]; + "x-scheme-handler/msteams" = [ "teams.desktop" ]; + "x-scheme-handler/tg" = [ "userapp-Telegram Desktop-JBKFU0.desktop" ]; + }; +} diff --git a/profiles/base-user/session-variables.nix b/profiles/base-user/session-variables.nix new file mode 100644 index 00000000..4e745bba --- /dev/null +++ b/profiles/base-user/session-variables.nix @@ -0,0 +1,81 @@ +{ config, pkgs, ... }: +let + psCfg = config.pub-solar; + xdg = config.home-manager.users."${psCfg.user.name}".xdg; + variables = { + XDG_CONFIG_HOME = xdg.configHome; + XDG_CACHE_HOME = xdg.cacheHome; + XDG_DATA_HOME = xdg.dataHome; + + XDG_CURRENT_DESKTOP = "sway"; + + QT_QPA_PLATFORM = "wayland"; + + # Wayland fixes + ECORE_EVAS_ENGINE = "wayland_egl"; + ELM_ENGINE = "wayland_egl"; + SDL_VIDEODRIVER = "wayland"; + + EDITOR = "/etc/profiles/per-user/${psCfg.user.name}/bin/nvim"; + VISUAL = "/etc/profiles/per-user/${psCfg.user.name}/bin/nvim"; + + # fix "xdg-open fork-bomb" your preferred browser from here + BROWSER = "${pkgs.firefox-wayland}/bin/firefox"; + + # node + NODE_REPL_HISTORY = "${xdg.dataHome}/node_repl_history"; + NVM_DIR = "${xdg.dataHome}/nvm"; + PKG_CACHE_PATH = "${xdg.cacheHome}/pkg-cache"; + + # npm + NPM_CONFIG_USERCONFIG = "${xdg.configHome}/npm/config"; + NPM_CONFIG_CACHE = "${xdg.configHome}/npm"; + # TODO: used to be XDG_RUNTIME_DIR NPM_CONFIG_TMP = "/tmp/npm"; + + # Make sure virsh runs without root + LIBVIRT_DEFAULT_URI = "qemu:///system"; + + # wine + WINEPREFIX = "${xdg.dataHome}/wineprefixes/default"; + + # z + _Z_DATA = "${xdg.dataHome}/z"; + + # wget + WGETRC = "${xdg.configHome}/wgetrc"; + + # rust + RUSTUP_HOME = "${xdg.dataHome}/rustup"; + CARGO_HOME = "${xdg.dataHome}/cargo"; + + # Java + _JAVA_OPTIONS = "-Djava.util.prefs.userRoot = '${xdg.configHome}/java'"; + _JAVA_AWT_WM_NONREPARENTING = "1"; + + # docker + DOCKER_CONFIG = "${xdg.configHome}/docker"; + + # experimental wayland in firefox/thunderbird + MOZ_ENABLE_WAYLAND = "1"; + + # Vagrant + VAGRANT_HOME = "${xdg.dataHome}/vagrant"; + VAGRANT_DEFAULT_PROVIDER = "libvirt"; + + # Android + ANDROID_SDK_ROOT = "${xdg.configHome}/android"; + + ANDROID_AVD_HOME = "${xdg.dataHome}/android"; + ANDROID_EMULATOR_HOME = "${xdg.dataHome}/android"; + ADB_VENDOR_KEY = "${xdg.configHome}/android"; + + # TELEMETRY BS + VUEDX_TELEMETRY = "off"; + }; +in +{ + home-manager = pkgs.lib.setAttrByPath [ "users" psCfg.user.name ] { + home.sessionVariables = variables; + systemd.user.sessionVariables = variables; + }; +} diff --git a/profiles/core/default.nix b/profiles/core/default.nix index 41b5136e..99f9bb11 100644 --- a/profiles/core/default.nix +++ b/profiles/core/default.nix @@ -4,145 +4,132 @@ in { imports = [ ../cachix ]; - nix.systemFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ]; + config = { + pub-solar.terminal-life.enable = true; + pub-solar.audio.enable = true; + pub-solar.crypto.enable = true; + pub-solar.devops.enable = true; + pub-solar.docker.enable = true; + pub-solar.nextcloud.enable = true; + pub-solar.office.enable = true; + # pub-solar.printing.enable = true; # this is enabled automatically if office is enabled + pub-solar.server.enable = true; + pub-solar.printing.enable = true; - environment = { + nix.systemFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ]; - systemPackages = with pkgs; [ - binutils - coreutils - curl - direnv - dnsutils - dosfstools - fd - git - gotop - gptfdisk - iputils - jq - manix - moreutils - nix-index - nmap - ripgrep - skim - tealdeer - usbutils - utillinux - whois - ]; + environment = { - shellInit = '' - export STARSHIP_CONFIG=${ - pkgs.writeText "starship.toml" - (fileContents ./starship.toml) - } - ''; + systemPackages = with pkgs; [ + # Core unix utility packages + coreutils-full + progress + dnsutils + inetutils + pciutils + usbutils + git + git-lfs + git-bug + git-crypt + wget + openssl + openssh + curl + htop + lsof + psmisc + xdg-utils + sysfsutils + renameutils + nfs-utils + moreutils + mailutils + keyutils + input-utils + elfutils + binutils + dateutils + diffutils + findutils + exfat-utils - shellAliases = - let ifSudo = lib.mkIf config.security.sudo.enable; - in - { - # quick cd - ".." = "cd .."; - "..." = "cd ../.."; - "...." = "cd ../../.."; - "....." = "cd ../../../.."; + # zippit + zip + unzip - # git - g = "git"; + # Modern modern utilities + p7zip + croc + jq - # grep - grep = "rg"; - gi = "grep -i"; + # Nix specific utilities + niv + manix + nix-index + # Build broken, python2.7-PyJWT-2.0.1.drv' failed + #nixops + psos - # internet ip - myip = "dig +short myip.opendns.com @208.67.222.222 2>&1"; + # Fun + neofetch + ]; + }; - # nix - n = "nix"; - np = "n profile"; - ni = "np install"; - nr = "np remove"; - ns = "n search --no-update-lock-file"; - nf = "n flake"; - nepl = "n repl ''"; - srch = "ns nixos"; - orch = "ns override"; - nrb = ifSudo "sudo nixos-rebuild"; - mn = '' - manix "" | grep '^# ' | sed 's/^# \(.*\) (.*/\1/;s/ (.*//;s/^# //' | sk --preview="manix '{}'" | xargs manix - ''; + fonts = { + fonts = with pkgs; [ powerline-fonts dejavu_fonts ]; - # fix nixos-option - nixos-option = "nixos-option -I nixpkgs=${self}/lib/compat"; + fontconfig.defaultFonts = { - # sudo - s = ifSudo "sudo -E "; - si = ifSudo "sudo -i"; - se = ifSudo "sudoedit"; + monospace = [ "DejaVu Sans Mono for Powerline" ]; - # top - top = "gotop"; - - # systemd - ctl = "systemctl"; - stl = ifSudo "s systemctl"; - utl = "systemctl --user"; - ut = "systemctl --user start"; - un = "systemctl --user stop"; - up = ifSudo "s systemctl start"; - dn = ifSudo "s systemctl stop"; - jtl = "journalctl"; + sansSerif = [ "DejaVu Sans" ]; }; - }; - - fonts = { - fonts = with pkgs; [ powerline-fonts dejavu_fonts ]; - - fontconfig.defaultFonts = { - - monospace = [ "DejaVu Sans Mono for Powerline" ]; - - sansSerif = [ "DejaVu Sans" ]; - }; + + nix = { + package = pkgs.nix-dram; + + autoOptimiseStore = true; + + gc.automatic = true; + + optimise.automatic = true; + + useSandbox = true; + + allowedUsers = [ "@wheel" ]; + + trustedUsers = [ "root" "@wheel" ]; + + extraOptions = '' + min-free = 536870912 + keep-outputs = true + keep-derivations = true + fallback = true + experimental-features = nix-command flakes + ''; + + registry.default = { + to = { + type = "github"; + owner = "NixOS"; + repo = "nixpkgs"; + ref = "nixos-unstable"; + }; + from = { + type = "indirect"; + id = "default"; + }; + }; + }; + + system.autoUpgrade.enable = true; + + services.earlyoom.enable = true; + + boot.kernelPackages = pkgs.linuxPackages_latest; + boot.supportedFilesystems = [ "ntfs" ]; }; - - nix = { - - autoOptimiseStore = true; - - gc.automatic = true; - - optimise.automatic = true; - - useSandbox = true; - - allowedUsers = [ "@wheel" ]; - - trustedUsers = [ "root" "@wheel" ]; - - extraOptions = '' - min-free = 536870912 - keep-outputs = true - keep-derivations = true - fallback = true - ''; - - }; - - programs.bash = { - promptInit = '' - eval "$(${pkgs.starship}/bin/starship init bash)" - ''; - interactiveShellInit = '' - eval "$(${pkgs.direnv}/bin/direnv hook bash)" - ''; - }; - - services.earlyoom.enable = true; - } diff --git a/profiles/gaming/default.nix b/profiles/gaming/default.nix new file mode 100644 index 00000000..a833f192 --- /dev/null +++ b/profiles/gaming/default.nix @@ -0,0 +1,9 @@ +{ self, config, lib, pkgs, ... }: +let inherit (lib) fileContents; +in +{ + pub-solar.gaming.enable = true; + pub-solar.docker.enable = true; + pub-solar.docker.enable = true; + pub-solar.docker.enable = true; +}; diff --git a/profiles/graphical/default.nix b/profiles/graphical/default.nix new file mode 100644 index 00000000..62acad2f --- /dev/null +++ b/profiles/graphical/default.nix @@ -0,0 +1,8 @@ +{ self, config, lib, pkgs, ... }: +let inherit (lib) fileContents; +in +{ + pub-solar.graphical.enable = true; + pub-solar.sway.enable = true; + pub-solar.social.enable = true; +}