diff --git a/flake.nix b/flake.nix index 56adeba..4e85afa 100644 --- a/flake.nix +++ b/flake.nix @@ -111,6 +111,29 @@ ]; }; + zw = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + inherit pkgs; + specialArgs = {inherit inputs;}; + modules = [ + { environment.systemPackages = [ agenix.packages.x86_64-linux.default beeperApp ]; } + nur.nixosModules.nur + agenix.nixosModules.default + ./systems/z1/configuration.nix + home-manager.nixosModules.home-manager + { + home-manager.backupFileExtension = "backup"; + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.adriano = import ./systems/z1/home/adriano.nix; + home-manager.users.root = import ./systems/z1/home/root.nix; + home-manager.extraSpecialArgs = { + inherit kitty-grab agenix homeage helix-master; + }; + } + ]; + }; + roampi = nixpkgs-pi.lib.nixosSystem { system = "aarch64-linux"; specialArgs = {inherit inputs;}; diff --git a/images/flake.lock b/images/flake.lock index 7a9b0ec..2a6a6e7 100644 --- a/images/flake.lock +++ b/images/flake.lock @@ -73,11 +73,11 @@ ] }, "locked": { - "lastModified": 1703527373, - "narHash": "sha256-AjypRssRtS6F3xkf7rE3/bXkIF2WJOZLbTIspjcE1zM=", + "lastModified": 1705169127, + "narHash": "sha256-j9OEtNxOIPWZWjbECVMkI1TO17SzlpHMm0LnVWKOR/g=", "owner": "nix-community", "repo": "home-manager", - "rev": "80679ea5074ab7190c4cce478c600057cfb5edae", + "rev": "f2942f3385f1b35cc8a1abb03a45e29c9cb4d3c8", "type": "github" }, "original": { @@ -125,11 +125,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1703255338, - "narHash": "sha256-Z6wfYJQKmDN9xciTwU3cOiOk+NElxdZwy/FiHctCzjU=", + "lastModified": 1704722960, + "narHash": "sha256-mKGJ3sPsT6//s+Knglai5YflJUF2DGj7Ai6Ynopz0kI=", "owner": "nixos", "repo": "nixpkgs", - "rev": "6df37dc6a77654682fe9f071c62b4242b5342e04", + "rev": "317484b1ead87b9c1b8ac5261a8d2dd748a0492d", "type": "github" }, "original": { diff --git a/images/flake.nix b/images/flake.nix index 727599d..10f3f7b 100644 --- a/images/flake.nix +++ b/images/flake.nix @@ -16,7 +16,6 @@ }; inputs.nixos-hardware.url = "github:nixos/nixos-hardware?rev=34f96de8c9ad390d8717e3ca6260afd5f500de04"; - outputs = { self, agenix, homeage, home-manager, nixos-hardware, nixpkgs }@inputs: rec { nixosConfigurations.rpi4 = nixpkgs.lib.nixosSystem { @@ -37,7 +36,16 @@ ]; }; - # Enable reating an sd card image of this rpi4 + + nixosConfigurations.zw = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix" + "${nixpkgs}/nixos/modules/installer/cd-dvd/channel.nix" + ]; + }; + images.rpi4 = nixosConfigurations.rpi4.config.system.build.sdImage; + images.zw = nixosConfigurations.zw.config.system.build.isoImage; }; } diff --git a/systems/zw/configuration.nix b/systems/zw/configuration.nix new file mode 100644 index 0000000..43849a0 --- /dev/null +++ b/systems/zw/configuration.nix @@ -0,0 +1,492 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running `nixos-help`). +{ config, pkgs, inputs, ...}: { + + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ./zfs.nix + ]; + + nix = { + package = pkgs.nixFlakes; + extraOptions = '' + experimental-features = nix-command flakes + ''; + gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 7d"; + }; + }; + + # Configure secrets + age = { + identityPaths = [ "/root/.ssh/id_rsa" ]; + secrets = { + wireless_networks = { + file = ./secrets/wireless_networks.age; + }; + + tailscale_key = { + file = ./secrets/tailscale_key.age; + }; + }; + }; + + virtualisation.docker = { + enable = true; + rootless = { + enable = true; + setSocketVariable = true; + }; + }; + + # Yubikey + services.udev.packages = [ pkgs.yubikey-personalization ]; + + # Login and sudo with + security.pam = { + u2f = { + cue = true; # Show prompt when u2f is being requested, e.g. for sudo + control = "sufficient"; # Yubikey is sufficient for authentication, no second factor required + }; + + services = { + login.u2fAuth = true; + sudo.u2fAuth = true; + i3lock.u2fAuth = true; + }; + }; + + programs.i3lock.u2fSupport = true; + + # Only allow authentication with my serial id + security.pam.yubico = { + enable = true; + debug = false; + mode = "challenge-response"; + id = [ "24654932" ]; + }; + + # lock screen un unplug + services.udev.extraRules = '' + ACTION=="remove",\ + ENV{ID_BUS}=="usb",\ + ENV{ID_MODEL_ID}=="0407",\ + ENV{ID_VENDOR_ID}=="1050",\ + ENV{ID_VENDOR}=="Yubico",\ + RUN+="${pkgs.systemd}/bin/loginctl lock-sessions" + ''; + + # Smartcard support + services.pcscd.enable = true; + hardware.gpgSmartcards.enable = true; + + # /Yubikey + + environment.pathsToLink = [ "/libexec" ]; + programs.dconf.enable = true; + + networking.hostName = "zw"; # Define your hostname. + networking.wireless = { + enable = true; + userControlled.enable = true; + }; + networking.wireless.environmentFile = config.age.secrets.wireless_networks.path; + networking.wireless.networks = { + # "MTShadows" = { + # psk = "WinterChills"; + # priority = 100; + # }; + "labarbacoffee" = { + psk = "labarbadraper"; + priority = 100; + }; + "roam" = { + psk = "@ROAM_PSK@"; + priority = 2; + }; + Miniroam = { + psk = "@MINIROAM_PSK@"; + priority = 99; + }; + "DeltaSkyClub" = { + priority = 3; + }; + "TheCenturionLounge" = { + priority = 4; + }; + "Bonjour Bakery Cafe_5G" = { + psk = "bakedgoods"; + }; + "Home5536" = { + psk = "@HOME5536_PSK@"; + }; + "CatskillHouse" = { + psk = "@CATSKIPP_HOUSE@"; + }; + hhonors = { + priority = 100; + }; + }; + + # networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + console = { + font = "Isoveke"; + useXkbConfig = true; # use xkbOptions in tty. + }; + + # Set your time zone. + time.timeZone = "America/Denver"; + + # Enable bluetooth and sound + hardware.pulseaudio.enable = true; + hardware.bluetooth.enable = true; + sound.enable = true; + services.dbus.enable = true; + services.blueman.enable = true; + + # Enable touchpad support (enabled default in most desktopManager). + # Define a user account. Don't forget to set a password with ‘passwd’. + users = { + mutableUsers = true; + users.adriano = { + isNormalUser = true; + extraGroups = [ "wheel" "networkmanager" "docker" ]; # Enable ‘sudo’ for the user. + password = "Iliketochangeitchangeit"; + shell = pkgs.zsh; + openssh.authorizedKeys.keys = [ + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD1LwyUmY8yaaIfPKn9aUIsbm8NkcLvx8MOILtKubMxOvnJ+ZkOQnqve/KE+VNdvOzlZgnnLA24ZAeM5fD8n/WFVjDRsKqXVAfZOIygm2/P1RzEK5+AoVOeIC25DhizNGJ0pE8F4aSVTmTtOq5kOf1bTSuVhv3p/k6ZusrzBI2HOEOUg/sfs3Q1L7wHDHTA5qxqYACLebGocq0KqWPW4GTJ67XEMiNIENBh4EEEDTaeQZjRomeeR0ssDlrNAabf+vp+dxEtyHXS9dPznCFUIh7KyCx1oKLBl/O3B2NuVycXdo2yGpPGF6iKC6HW6lBHkYWfmgunQ4NOZWpbFFF0nT7K/kbFjmQKn3h7xuH3wXqs+iGXlDCQ1c/7YKarrD/JOsyWN/qHj9nto5QE40GZZRqhO1i16jCgMTyk0VLwZ5Eq6+zAKBKBQ2t/aFov4i05LuM3geg3LO4BoyQnP/ikuDb4ENRb1+wlJp9kCk2YKZeLwcgBXYg9xkXpX5ZnQl9E26s= adriano@zenity" ]; + packages = with pkgs; with inputs; [ + abook + appimagekit + clipmenu + ctags + dante + dict + di-tui.packages.${system}.default + direnv + dmenu + ess.packages.${system}.default + fzf + gcc8 + gimp + glow + gnumake + gopass + gopass-jsonapi + hugo + inetutils + kitty + language-servers.packages.${system}.vscode-langservers-extracted # For vscode-html-language-server, vscode-css-language-server, vscode-json-language-server in Helix + lazygit + libreoffice + ltex-ls + chatgpt-cli + git + go_1_21 + gopls + gscreenshot + ivpn + jq + logseq + nix-index + nodejs + nodePackages.typescript-language-server + nomad_1_4 + nil # nix lsp + playerctl + python310Packages.python-lsp-server + ripgrep + rofi + stripe-cli + spotify-player + tailscale + terraform + terraform-lsp + texlive.combined.scheme-tetex + tmux + ungoogled-chromium + usbutils + pandoc + python3 + simplescreenrecorder + speedtest-cli + tree + vlc + weechat + w3m + wpa_supplicant_gui + xclip + unzip + yubikey-manager + zoom-us + ]; + }; + }; + + environment.etc."dict.conf".text = "server dict.org"; + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + neovim + wget + ]; + + # Some programs need SUID wrappers, can be configured further or are + # started in user sessions. + # programs.mtr.enable = true; + programs.gnupg.agent = { + enable = true; + enableSSHSupport = true; + }; + + programs.zsh = { + enable = true; + }; + + # List services that you want to enable: + services.tailscale.enable = true; + services.ivpn.enable = true; + services.openntpd.enable = true; + services.openssh = { + enable = true; + settings.PasswordAuthentication = true; + }; + services.redis.servers."zw".enable=true; + services.redis.servers."zw".port=6379; + + services.xserver = { + enable = true; + layout = "us"; + xkbOptions = "caps:ctrl_modifier"; + windowManager.i3.enable = true; + desktopManager = { + xterm.enable = false; + }; + + displayManager = { + defaultSession = "none+i3"; + }; + libinput = { + enable = true; + touchpad = { + naturalScrolling = true; + accelSpeed = "0.5"; + disableWhileTyping = true; + additionalOptions = '' + Option "PalmDetection" "on" + ''; + }; + }; + + # Can't figure out how to enable natural scrolling. Ideally what I want is natural scrolling AND palm detection, + # but for now, it seems like I can't have both without getting my hands more dirty. Switching back to libinput + synaptics = { + enable = false; + palmDetect = true; + maxSpeed = "2.0"; + accelFactor = "0.01"; + twoFingerScroll = true; + }; + }; + + # Backlight/brightness control + programs.light.enable = true; + services.actkbd = { + enable = true; + bindings = [ + { keys = [ 225 ]; events = [ "key" ]; command = "/run/current-system/sw/bin/light -A 10"; } + { keys = [ 224 ]; events = [ "key" ]; command = "/run/current-system/sw/bin/light -U 10"; } + { keys = [ 114 ]; events = [ "key" ]; command = "/run/current-system/sw/bin/runuser -l adriano -c 'amixer -q set Master 5%- unmute'"; } + { keys = [ 115 ]; events = [ "key" ]; command = "/run/current-system/sw/bin/runuser -l adriano -c 'amixer -q set Master 5%+ unmute'"; } + ]; + }; + + # create a oneshot job to authenticate to Tailscale + systemd.services.tailscale-autoconnect = { + description = "Automatic connection to Tailscale"; + enable = true; + + # make sure tailscale is running before trying to connect to tailscale + after = [ "network-pre.target" "tailscale.service" ]; + wants = [ "network-pre.target" "tailscale.service" ]; + wantedBy = [ "multi-user.target" ]; + + # set this service as a oneshot job + serviceConfig.Type = "oneshot"; + + # have the job run this shell script + script = with pkgs; '' + # wait for tailscaled to settle + sleep 2 + + # # check if we are already authenticated to tailscale + # status="$(${tailscale}/bin/tailscale status -json | ${jq}/bin/jq -r .BackendState)" + # if [ $status = "Running" ]; then # if so, then do nothing + # exit 0 + # fi + + # otherwise authenticate with tailscale + ${tailscale}/bin/tailscale up -authkey $(cat ${config.age.secrets.tailscale_key.path}) --accept-routes --reset + ''; + }; + + systemd.services.address-book-sync = { + description = "Syncs the Fastmail address book"; + enable = true; + serviceConfig.User = "adriano"; + serviceConfig.Type = "oneshot"; + script = with pkgs; '' + tmpfile=$(mktemp) + destfile=$(mktemp) + + ${wget}/bin/wget -q https://carddav.fastmail.com/dav/addressbooks/user/me@adriano.fyi/Default \ + --user me@adriano.fyi \ + --password $(${gopass}/bin/gopass show fastmail.com/me-aerc | head -n 1) \ + -O $tmpfile + + ${abook}/bin/abook --convert \ + --informat vcard \ + --infile $tmpfile \ + --outformat abook \ + --outfile $destfile + + rm $tmpfile + chmod 600 $destfile + mv $destfile ~/.abook/addressbook + ''; + }; + + systemd.timers.address-book-sync = { + wantedBy = [ "timers.target" ]; + partOf = [ "address-book-sync.service" ]; + timerConfig = { + OnCalendar = "*-*-* 00:00:00"; + + }; + }; + + networking.firewall = { + # enable the firewall + enable = true; + + # always allow traffic from your Tailscale network + trustedInterfaces = [ "tailscale0" ]; + + # allow the Tailscale UDP port through the firewall + allowedUDPPorts = [ config.services.tailscale.port ]; + + # allow you to SSH in over the public internet + allowedTCPPorts = [ 22 ]; + }; + + + services.postgresql = { + enable = true; + ensureDatabases = [ "neoq" ]; + enableTCPIP = true; + # port = 5432; + authentication = pkgs.lib.mkOverride 10 '' + local all all trust + # ipv4 + host all all 127.0.0.1/32 trust + # ipv6 + host all all ::1/128 trust + ''; + + initialScript = pkgs.writeText "backend-initScript" '' + CREATE ROLE postgres WITH LOGIN PASSWORD 'postres' CREATEDB; + CREATE DATABASE neoq; + GRANT ALL PRIVILEGES ON DATABASE neoq TO postgres; + LOAD 'auto_explain'; + ''; + + settings = { + log_statement = "all"; + "auto_explain.log_analyze" = "true"; + "auto_explain.log_nested_statements" = "on"; + "auto_explain.log_min_duration" = 0; + "auto_explain.log_triggers" = "true"; + max_connections = 2000; + log_connections = "yes"; + logging_collector = "on"; + log_directory = "/tmp/"; + log_filename = "postgresql-%Y-%m-%d_%H%M%S.log"; + log_truncate_on_rotation = "true"; + log_rotation_age = 1440; + client_min_messages = "LOG"; + log_min_messages = "INFO"; + log_min_error_statement = "DEBUG5"; + log_min_duration_statement = 0; + }; + }; + + services = { + syncthing = { + enable = true; + user = "adriano"; + dataDir = "/home/adriano/.config/syncthing"; + configDir = "/home/adriano/.config/syncthing/config"; + guiAddress = "100.98.115.99:8384"; + overrideDevices = true; # overrides any devices added or deleted through the WebUI + overrideFolders = true; # overrides any folders added or deleted through the WebUI + settings = { + devices = { + "roampi" = { id = "PD2KG67-FKNO6QS-UTY24Q7-L6QQM6B-KL5NYMZ-A5HKAEH-4VYLSZR-WCCBPQT"; }; + "Miniroam" = { id = "F7UWLCE-JPZXXU2-4SHXZ3X-BM3T3U7-DTSVPVA-TXFYB67-5TCR574-MSYRJQR"; }; + "homepi" = { id = "CGBRCYB-2USPMPW-VKMVC4N-7SF2QLX-W5WWKHX-YD22FCO-XFNTJPC-RCKW5AY"; }; + }; + folders = { + "Documents" = { # Name of folder in Syncthing, also the folder ID + path = "/home/adriano/Documents"; # Which folder to add to Syncthing + devices = [ "roampi" "Miniroam" "homepi" ]; # Which devices to share the folder with + }; + "KB" = { # Name of folder in Syncthing, also the folder ID + path = "/home/adriano/KB"; # Which folder to add to Syncthing + devices = [ "roampi" "Miniroam" "homepi" ]; # Which devices to share the folder with + }; + + }; + }; + }; + }; + + fonts = { + packages = with pkgs; [ + (nerdfonts.override { fonts = [ "FiraCode" ]; }) + roboto + font-awesome_5 + ubuntu_font_family + noto-fonts + noto-fonts-color-emoji + iosevka + ]; + fontconfig = { + defaultFonts = { + sansSerif = [ "Iosevka" "Noto Color Emoji" ]; + serif = [ "Iosevka" "Noto Color Emoji" ]; + emoji = [ "Noto Color Emoji" ]; + }; + }; + }; + + # Copy the NixOS configuration file and link it from the resulting system + # (/run/current-system/configuration.nix). This is useful in case you + # accidentally delete configuration.nix. + # system.copySystemConfiguration = true; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It's perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "23.05"; # Did you read the comment? + +} diff --git a/systems/zw/hardware-configuration.nix b/systems/zw/hardware-configuration.nix new file mode 100644 index 0000000..b7ce904 --- /dev/null +++ b/systems/zw/hardware-configuration.nix @@ -0,0 +1,81 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "data/nixos"; + fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ]; + neededForBoot = true; + }; + + fileSystems."/home" = + { device = "data/nixos/home"; + fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ]; + neededForBoot = true; + }; + + fileSystems."/nix" = + { device = "data/nixos/nix"; + fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ]; + }; + + fileSystems."/root" = + { device = "data/nixos/root"; + fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ]; + neededForBoot = true; + }; + + fileSystems."/usr" = + { device = "data/nixos/usr"; + fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ]; + }; + + fileSystems."/var" = + { device = "data/nixos/var"; + fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ]; + }; + + fileSystems."/boot" = + { device = "boot/nixos/boot"; + fsType = "zfs"; options = [ "zfsutil" "X-mount.mkdir" ]; + neededForBoot = true; + }; + + fileSystems."/boot/efis/efi-boot0" = + { device = "/dev/disk/by-partlabel/z-efi-boot0"; + fsType = "vfat"; + }; + + fileSystems."/boot/efi" = + { device = "/boot/efis/zw-efi-boot0"; + fsType = "none"; + options = [ "bind" ]; + }; + + swapDevices = + [ { device = "/dev/disk/by-partlabel/zwswap0"; } + ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + networking.interfaces.enp38s0f1.useDHCP = lib.mkDefault true; + networking.interfaces.wlp0s20f3.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/systems/zw/home/Xresources b/systems/zw/home/Xresources new file mode 100644 index 0000000..99b5ada --- /dev/null +++ b/systems/zw/home/Xresources @@ -0,0 +1,60 @@ +# xterm fonts +xterm*faceName: Monospace +xterm*faceSize: 12 + +# THEME + +! Base16 Atelier Lakeside +! Scheme: Bram de Haan (http://atelierbramdehaan.nl) + +#define base00 #161b1d +#define base01 #1f292e +#define base02 #516d7b +#define base03 #5a7b8c +#define base04 #7195a8 +#define base05 #7ea2b4 +#define base06 #c1e4f6 +#define base07 #ebf8ff +#define base08 #d22d72 +#define base09 #935c25 +#define base0A #8a8a0f +#define base0B #568c3b +#define base0C #2d8f6f +#define base0D #257fad +#define base0E #6b6bb8 +#define base0F #b72dd2 + +*.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/systems/zw/home/adriano.nix b/systems/zw/home/adriano.nix new file mode 100644 index 0000000..02a885e --- /dev/null +++ b/systems/zw/home/adriano.nix @@ -0,0 +1,565 @@ +{ config, pkgs, lib, kitty-grab, homeage, helix-master, ... }: +{ + imports = [ + homeage.homeManagerModules.homeage + ]; + + homeage = { + identityPaths = [ "/home/adriano/.ssh/id_rsa_agenix" ]; + installationType = "systemd"; + + file."spotify-player-config" = { + source = ../secrets/spotify-player-config.age; + symlinks = [ "${config.xdg.configHome}/spotify_player/config_file.conf" ]; + }; + }; + + programs.home-manager.enable = true; + home = { + stateVersion = "23.05"; + sessionVariables = { + "GO111MODULE" = "on"; + "PGHOST" = "localhost"; + "PGUSER" = "postgres"; + "PGPASSWORD" = "postgres"; + "NOMAD_ADDR" = "http://cluster-0:4646"; + "PATH" = "$PATH:/home/adriano/go/bin"; + }; + + file = { + ".mozilla/native-messaging-hosts/com.justwatch.gopass.json".source = ./gopass/gopass-api-manifest.json; + ".config/gopass" = { + source = ./gopass; + recursive = true; + }; + ".config/helix" = { + source = ./helix; + recursive = true; + }; + ".config/nix" = { + source = ./nix; + recursive = true; + }; + "${config.xdg.configHome}/kitty/kitty_grab" = { + source = kitty-grab; + recursive = true; + }; + "${config.xdg.configHome}/kitty/grab.conf".source = ./kitty/kitty_grab.conf; + "${config.xdg.configHome}/notmuch/querymap-personal".source = ./notmuch/querymap-personal; + "${config.xdg.configHome}/notmuch/querymap-zenity".source = ./notmuch/querymap-zenity; + "${config.xdg.configHome}/aerc/binds.conf".source = ./aerc/binds.conf; + "${config.xdg.configHome}/mbsync/postExec" = { + text = '' + #!${pkgs.stdenv.shell} + ${pkgs.notmuch}/bin/notmuch new + ''; + executable = true; + }; + }; + }; + + services.dunst.enable = true; + services.spotifyd = { + enable = true; + settings = + { + global = { + username = "acaloiaro"; + password_cmd = "cat ${config.xdg.configHome}/spotifyd/password"; + backend = "pulseaudio"; + }; + }; + }; + + services.screen-locker = { + enable = true; + inactiveInterval = 30; + lockCmd = "${pkgs.i3lock}/bin/i3lock -n -c 000000"; + xautolock = { + enable = true; + detectSleep = true; + }; + }; + + xsession.windowManager.i3 = { + enable = true; + package = pkgs.i3-gaps; + + config = rec { + modifier = "Mod4"; + bars = [ + { + position = "bottom"; + statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs ~/.config/i3status-rust/config-bottom.toml"; + fonts = { + names = [ "DejaVu Sans Mono" "FontAwesome5Free" ]; + style = "Bold Semi-Condensed"; + size = 14.0; + }; + } + ]; + + window.border = 0; + + gaps = { + inner = 3; + outer = 1; + }; + + keybindings = lib.mkOptionDefault { + "XF86AudioPlay" = "exec playerctl play-pause"; + "XF86AudioPause" = "exec playerctl play-pause"; + "XF86AudioMute" = "exec amixer set Master toggle"; + "XF86AudioLowerVolume" = "exec amixer set Master 4%-"; + "XF86AudioRaiseVolume" = "exec amixer set Master 4%+"; + "XF86MonBrightnessDown" = "exec brightnessctl set 4%-"; + "XF86MonBrightnessUp" = "exec brightnessctl set 4%+"; + "${modifier}+Return" = "exec ${pkgs.kitty}/bin/kitty"; + "${modifier}+d" = "exec ${pkgs.rofi}/bin/rofi -modi drun -show drun"; + "${modifier}+Shift+d" = "exec ${pkgs.rofi}/bin/rofi -show window"; + "${modifier}+Shift+x" = "exec systemctl suspend"; + # Move + "${modifier}+Shift+h" = "move left"; + "${modifier}+Shift+l" = "move right"; + "${modifier}+Shift+k" = "move up"; + "${modifier}+Shift+j" = "move down"; + # Focus + "${modifier}+h" = "focus left"; + "${modifier}+l" = "focus right"; + "${modifier}+j" = "focus down"; + "${modifier}+k" = "focus up"; + }; + + startup = [ + { + command = "exec i3-msg workspace 1"; + always = true; + notification = false; + } + ]; + }; + }; + + programs.i3status-rust = { + enable = true; + bars = { + bottom = { + blocks = [ + { + block = "custom"; + command = "sed 's/ //' <(curl 'https://wttr.in/Draper,UT?format=4&u' -s)"; + interval = 1200; + } + { + block = "net"; + format = " {$signal_strength $ssid $frequency|} $device $icon ^icon_net_down $speed_down.eng(prefix:K) ^icon_net_up $speed_up.eng(prefix:K)"; + } + { + block = "memory"; + } + { + block = "cpu"; + interval = 1; + } + { + block = "sound"; + } + { + block = "battery"; + } + { + block = "time"; + interval = 60; + format = " $timestamp.datetime(f:'%a %d/%m %R') "; + } + ]; + settings = { + theme = { + theme = "solarized-dark"; + }; + }; + icons = "awesome5"; + theme = "gruvbox-dark"; + }; + }; + }; + + + programs.helix = { + enable = true; + package = helix-master.packages."x86_64-linux".default; + defaultEditor = true; + settings = (builtins.fromTOML (builtins.readFile ./helix/config.toml)); + languages = { + langauge = (builtins.fromTOML (builtins.readFile ./helix/languages.toml)); + }; + }; + + programs.git = { + enable = true; + userName = "Adriano Caloiaro"; + userEmail = "code@adriano.fyi"; + + signing = { + key = "C2BC56DE73CE3F75!"; + signByDefault = true; + }; + + extraConfig = { + push = { + autoSetupRemote = true; + }; + init = { + defaultBranch = "main"; + }; + pull = { + rebase = true; + }; + }; + }; + + programs.gh = { + enable = true; + + gitCredentialHelper = { + enable = true; + }; + + settings = { + version = 1; # Workaround for https://github.com/nix-community/home-manager/issues/4744 + editor = "hx"; + git_protocol = "ssh"; + }; + }; + + programs.kitty = { + enable = true; + theme = "GitHub Dark Dimmed"; # For normal/lower light environments + #theme = "GitHub Light"; # For higher light environments + extraConfig = '' +enabled_layouts fat,tall,stack +map Alt+g kitten kitty_grab/grab.py +map Ctrl+Shift+h previous_tab +map Ctrl+Shift+l next_tab +map Ctrl+Shift+b show_scrollback +map Ctrl+Shift+p goto_layout fat +draw_minimal_borders yes +window_padding_width 2 +window_border_width 0 +hide_window_decorations yes +titlebar-only yes +active_border_color none +font_size 12.0 + ''; + }; + + programs.zsh = { + enable = true; + dotDir = ".config/zsh"; + shellAliases = { + ll = "ls -l"; + vi = "hx $*"; + vim = "hx $*"; + rebuild = "sudo nixos-rebuild --flake .#zw switch"; + nomad = "NOMAD_TOKEN=$(${pkgs.gopass}/bin/gopass show hetzner-cluster| grep admin_token | awk '{print $2}') nomad $*"; + chatgpt = "OPENAI_API_KEY=$(${pkgs.gopass}/bin/gopass show openai.com/openai.com@adriano.fyi| grep api | awk '{print $2}') chatgpt $*"; + }; + + oh-my-zsh = { + enable = true; + theme = "eastwood"; + plugins = [ + "sudo" + "git" + "dotenv" + "fzf" + ]; + }; + + initExtra = '' + bindkey -v + export KEYTIMEOUT=1 + autoload edit-command-line + zle -N edit-command-line + + # Change cursor shape for different vi modes. + function zle-keymap-select { + if [[ ''${KEYMAP} == vicmd ]] || + [[ $1 = 'block' ]]; then + echo -ne '\e[1 q' + + elif [[ ''${KEYMAP} == main ]] || + [[ ''${KEYMAP} == viins ]] || + [[ ''${KEYMAP} = "" ]] || + [[ $1 = 'beam' ]]; then + echo -ne '\e[5 q' + fi + } + zle -N zle-keymap-select + + # Use beam shape cursor on startup. + echo -ne '\e[5 q' + + # Use beam shape cursor for each new prompt. + preexec() { + echo -ne '\e[5 q' + } + + + alias addresses="hx ~/KB/pages/Important\ Addresses.md" + alias ideas="hx ~/KB/pages/Notes/ideas/" + alias people="vim ~/KB/pages/People.md" + alias notes="hx ~/KB" + alias open="xdg-open $*" + alias quickqr='a() { qrencode -o qr.png $1 && ((open qr.png; sleep 15; rm qr.png ) &)}; a &>/dev/null' + alias xclip="xclip -selection clipboard $*" + alias speedtest='echo "$(curl -skLO https://git.io/speedtest.sh && chmod +x speedtest.sh && ./speedtest.sh && rm speedtest.sh)"' + alias colorlight="tmux set window-style 'fg=#171421,bg=#FFFDD0'" + alias nix='nix --extra-experimental-features "nix-command flakes" $*' + function gpgen { gopass generate "$1/$1@''${2=adriano.fyi}" } + ''; + }; + + services.nextcloud-client = { + enable = true; + startInBackground = true; + }; + + services.gpg-agent = { + enable = true; + enableSshSupport = true; + enableZshIntegration = true; + enableScDaemon = true; + + maxCacheTtl = 60 * 60 * 24; + defaultCacheTtl = 60 * 60 * 24; + defaultCacheTtlSsh = 60 * 60 * 24; + }; + + programs.firefox = { + enable = true; + package = pkgs.wrapFirefox pkgs.firefox-unwrapped { + extraPolicies = { + CaptivePortal = false; + DisableFirefoxStudies = true; + DisablePocket = true; + DisableTelemetry = true; + DisableFirefoxAccounts = false; + NoDefaultBookmarks = true; + OfferToSaveLogins = false; + OfferToSaveLoginsDefault = false; + PasswordManagerEnabled = false; + FirefoxHome = { + Search = true; + Pocket = false; + Snippets = false; + TopSites = false; + Highlights = false; + }; + UserMessaging = { + ExtensionRecommendations = false; + SkipOnboarding = true; + }; + }; + }; + + profiles = { + adriano = { + id = 0; + name = "adriano"; + extensions = with pkgs.nur.repos.rycee.firefox-addons; [ + floccus + ublock-origin + gopass-bridge + tridactyl + noscript + ]; + }; + }; + }; + + programs.qutebrowser = { + enable = true; + searchEngines = { + DEFAULT = "https://kagi.com/search?q={}"; + ddg = "https://duckduckgo.com/?q={}"; + hm = "https://mipmip.github.io/home-manager-option-search/?query={}"; + nixpkgs = "https://search.nixos.org/packages?query={}"; + nixos = "https://search.nixos.org/options?query={}"; + nixman = "https://nixos.org/manual/nix/unstable/?search={}"; + }; + keyBindings = let + pass_cmd = "spawn --userscript qute-pass --dmenu-invocation dmenu --mode gopass --password-store ~/.password-store"; + in { + normal = { + ",p" = pass_cmd; + ",Pu" = "${pass_cmd} --username-only"; + ",Pp" = "${pass_cmd} --password-only"; + ",Po" = "${pass_cmd} --otp-only"; + ",," = "config-cycle tabs.show never always"; + ",qc" = "spawn --userscript ~/.local/bin/qute-logseq"; + }; + }; + quickmarks = { + nixpkgs = "https://github.com/NixOS/nixpkgs"; + home-manager = "https://github.com/nix-community/home-manager"; + }; + settings = { + spellcheck.languages = ["en-US"]; + tabs = { + position = "left"; + show = "always"; + title = { + format = "{audio}{current_title}"; + format_pinned = "{audio}📌 {current_title}"; + }; + }; + fonts = { + default_size = "16px"; + }; + + zoom.default = "120%"; + }; + }; + + programs.aerc = { + enable = true; + extraConfig = { + general = { + file-picker-cmd = ''${pkgs.fzf}/bin/fzf --multi --query=%s''; + unsafe-accounts-conf = true; + log-level = "trace"; + log-file = "/tmp/aerc.log"; + }; + + compose = { + address-book-cmd = ''${pkgs.abook}/bin/abook --mutt-query "%s"''; + }; + + ui = { + this-day-time-format =''" 15:04"''; + this-year-time-format = "Mon Jan 02 15:04"; + timestamp-format = "2006-01-02 15:04"; + spinner = "[ ⡿ ],[ ⣟ ],[ ⣯ ],[ ⣷ ],[ ⣾ ],[ ⣽ ],[ ⣻ ],[ ⢿ ]"; + sidebar-width = 25; + }; + + filters = { + "text/plain" = "colorize"; + "text/html" = "w3m -T text/html -o display_link_number=1"; + "text/calendar" = "calendar"; + "message/delivery-status" = "colorize"; + "message/rfc822" = "colorize"; + }; + + hooks = { + mail-received = ''dunstify "New email from $AERC_FROM_NAME" "$AERC_SUBJECT"''; + }; + }; + }; + programs.mbsync.enable = true; + programs.msmtp.enable = true; + programs.notmuch = { + enable = true; + new.tags = [ "new" "inbox" ]; + hooks.postNew = '' + ${pkgs.notmuch}/bin/notmuch tag +personal -- tag:new and folder:/Personal/ + ${pkgs.notmuch}/bin/notmuch tag +zenity -- tag:new and folder:/Zenity/ + ''; + }; + + accounts.email.maildirBasePath = "/home/adriano/.mail"; + accounts.email.accounts = { + Personal = { + primary = true; + aerc = { + enable = true; + # extraAccounts = { + # source = "notmuch:///home/adriano/.mail"; + # maildir-store = "/home/adriano/.mail/Personal"; + # query-map = "/home/adriano/.config/notmuch/querymap-personal"; + # }; + }; + realName = "Adriano Caloiaro"; + address = "me@adriano.fyi"; + imap.host = "imap.fastmail.com"; + smtp.host = "smtp.fastmail.com"; + userName = "me@adriano.fyi"; + passwordCommand = "${pkgs.gopass}/bin/gopass show -o fastmail.com/me-aerc"; + + mbsync = { + enable = true; + create = "both"; + expunge = "both"; + remove = "both"; + }; + msmtp.enable = true; + notmuch.enable = true; + + gpg = { + encryptByDefault = true; + signByDefault = true; + key = "C2BC56DE73CE3F75!"; + }; + }; + + Zenity = { + primary = false; + aerc = { + enable = true; + # extraAccounts = { + # source = "notmuch:///home/adriano/.mail"; + # maildir-store = "/home/adriano/.mail/Zenity"; + # query-map = "/home/adriano/.config/notmuch/querymap-zenity"; + # }; + }; + realName = "Adriano Caloiaro"; + address = "adriano@zenitylabs.com"; + imap.host = "imap.fastmail.com"; + smtp.host = "smtp.fastmail.com"; + userName = "adriano@zenitylabs.com"; + passwordCommand = "${pkgs.gopass}/bin/gopass show -o fastmail.com/zenity-aerc"; + mbsync = { + enable = true; + create = "both"; + expunge = "both"; + remove = "both"; + }; + msmtp.enable = true; + notmuch.enable = true; + }; + }; + + services.mbsync = { + enable = true; + postExec = "${config.xdg.configHome}/mbsync/postExec"; + }; + + xdg = { + enable = true; + mime.enable = true; + mimeApps = { + enable = true; + defaultApplications = let + browser = "org.qutebrowser.qutebrowser.desktop"; + in { + "text/html" = browser; + "x-scheme-handler/http" = browser; + "x-scheme-handler/https" = browser; + "x-scheme-handler/about" = browser; + "x-scheme-handler/unknown" = browser; + + "x-scheme-handler/logseq" = "Logseq.desktop"; + }; + }; + desktopEntries = { + beeper-desktop = { + name = "Beeper"; + type = "Application"; + exec = "beeper %U"; + icon = "beeper"; + }; + }; + }; +} + diff --git a/systems/zw/home/aerc/binds.conf b/systems/zw/home/aerc/binds.conf new file mode 100644 index 0000000..39cb6d8 --- /dev/null +++ b/systems/zw/home/aerc/binds.conf @@ -0,0 +1,124 @@ +# Binds are of the form = +# To use '=' in a key sequence, substitute it with "Eq": "" +# If you wish to bind #, you can wrap the key sequence in quotes: "#" = quit + = :prev-tab + = :next-tab + = :term +? = :help keys +# FOOBAR +[messages] +q = :quit + +j = :next + = :next + = :next 50% + = :next 100% + = :next 100% + +k = :prev + = :prev + = :prev 50% + = :prev 100% + = :prev 100% +g = :select 0 +G = :select -1 + +J = :next-folder +K = :prev-folder +H = :collapse-folder +L = :expand-folder + +v = :mark -t +V = :mark -v + +T = :toggle-threads + + = :view +d = :prompt 'Really delete this message?' 'delete-message' +D = :delete +A = :archive flat + +C = :compose + +rr = :reply -a +rq = :reply -aq +Rr = :reply +Rq = :reply -q + +c = :cf +$ = :term +! = :term +| = :pipe + +/ = :search +\ = :filter +n = :next-result +N = :prev-result + = :clear + +[messages:folder=Drafts] + = :recall + +[view] +/ = :toggle-key-passthrough/ +q = :close +O = :open +S = :save +| = :pipe +D = :delete +A = :archive flat + + = :open-link + +f = :forward +rr = :reply -a +rq = :reply -aq +Rr = :reply +Rq = :reply -q + +H = :toggle-headers + = :prev-part + = :next-part +J = :next +K = :prev + +[view::passthrough] +$noinherit = true +$ex = + = :toggle-key-passthrough + +[compose] +# Keybindings used when the embedded terminal is not selected in the compose +# view +$ex = + = :prev-field + = :next-field + = :switch-account -p + = :switch-account -n + +[compose::editor] +# Keybindings used when the embedded terminal is selected in the compose view +$noinherit = true +$ex = + = :prev-field + = :next-field + = :prev-tab + = :next-tab + +[compose::review] +# Keybindings used when reviewing a message to be sent +y = :send +n = :abort +v = :preview +p = :postpone +q = :choose -o d discard abort -o p postpone postpone +e = :edit +a = :attach +d = :detach + +[terminal] +$noinherit = true +$ex = + + = :prev-tab + = :next-tab diff --git a/systems/zw/home/gopass/config.yml b/systems/zw/home/gopass/config.yml new file mode 100644 index 0000000..a0ab6c0 --- /dev/null +++ b/systems/zw/home/gopass/config.yml @@ -0,0 +1,11 @@ +autoclip: true +autoimport: true +cliptimeout: 45 +exportkeys: true +nopager: false +notifications: true +parsing: false +path: /home/adriano/.password-store +safecontent: false +mounts: + zenitylabs: /home/adriano/git/zenity-gopass-store diff --git a/systems/zw/home/gopass/gopass-api-manifest.json b/systems/zw/home/gopass/gopass-api-manifest.json new file mode 100644 index 0000000..cdc323b --- /dev/null +++ b/systems/zw/home/gopass/gopass-api-manifest.json @@ -0,0 +1,9 @@ +{ + "name": "com.justwatch.gopass", + "description": "Gopass wrapper to search and return passwords", + "path": "/home/adriano/.config/gopass/gopass_wrapper.sh", + "type": "stdio", + "allowed_extensions": [ + "{eec37db0-22ad-4bf1-9068-5ae08df8c7e9}" + ] +} diff --git a/systems/zw/home/gopass/gopass_wrapper.sh b/systems/zw/home/gopass/gopass_wrapper.sh new file mode 100755 index 0000000..8a1a71c --- /dev/null +++ b/systems/zw/home/gopass/gopass_wrapper.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +export PATH="$PATH:$HOME/.nix-profile/bin" # required for Nix +export PATH="$PATH:/usr/local/bin" # required on MacOS/brew +export PATH="$PATH:/usr/local/MacGPG2/bin" # required on MacOS/GPGTools GPGSuite +export GPG_TTY="$(tty)" + +# Uncomment to debug gopass-jsonapi +# export GOPASS_DEBUG_LOG=/tmp/gopass-jsonapi.log + +if [ -f ~/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then + source ~/.gpg-agent-info + export GPG_AGENT_INFO +else + eval $(gpg-agent --daemon) +fi + +export PATH="$PATH:/usr/local/bin" + +/etc/profiles/per-user/adriano/bin/gopass-jsonapi listen + +exit $? diff --git a/systems/zw/home/helix/config.toml b/systems/zw/home/helix/config.toml new file mode 100644 index 0000000..9f5498a --- /dev/null +++ b/systems/zw/home/helix/config.toml @@ -0,0 +1,123 @@ +theme = "nord" # For normal/darker settings +# theme = "nord-light" +# theme = "base16_terminal" + +[editor] +auto-save = true +color-modes = true +true-color = true +rulers = [120] +completion-replace = true +bufferline = "always" + +# cursorline = true +# cursorcolumn = true + +[editor.statusline] +left = ["mode", "spinner", "file-name", "file-modification-indicator"] +center = [ "version-control" ] + right = [ + "diagnostics", + "workspace-diagnostics", + "primary-selection-length", + "selections", + "position-percentage", + "total-line-numbers", + "file-type" + ] +separator = "│" + +[editor.lsp] +display-messages = true +auto-signature-help = false # this is covering completions +display-inlay-hints = true +goto-reference-include-declaration = false + +[editor.cursor-shape] +insert = "bar" +select = "underline" + +[editor.file-picker] +hidden = false + +[editor.soft-wrap] +enable = true + +[editor.search] +wrap-around = false + +[editor.whitespace] +# render = "all" + +[editor.indent-guides] +render = true +character = "┋" +skip-levels = 1 + +[keys.normal] +C-h = "jump_view_left" +C-j = "jump_view_down" +C-k = "jump_view_up" +C-l = "jump_view_right" +"minus" = "file_picker_in_current_buffer_directory" + +# from reddit +V = ["goto_first_nonwhitespace", "extend_to_line_end"] +D = ["ensure_selections_forward", "extend_to_line_end"] +# D = ["goto_first_nonwhitespace", "extend_line", "delete_selection"] +# x = "extend_line" +a = ["append_mode", "collapse_selection"] +i = ["insert_mode", "collapse_selection"] +C-space = "signature_help" +c = ["trim_selections", "change_selection"] + +# vim goodness +G = "goto_last_line" +"^" = "goto_first_nonwhitespace" +"$" = "goto_line_end" +C-w = { C-c = "wclose", c = "wclose" } +C-r = "redo" +#C-y = "scroll_up" +#C-e = "scroll_down" +# d = "kill_to_line_end" + + +[keys.normal.";"] +w = ":write" +";" = ":w" +a = "code_action" +o = [":hsplit ~/.config/helix/config.toml"] +l = [":hsplit ~/.config/helix/languages.toml"] +r = [":config-reload"] +# remove wayward white space +space = [ + "save_selection", + "select_all", + ":pipe trim-whitespace", + "collapse_selection", + "jump_backward", + "commit_undo_checkpoint", + ":write", +] +c = [":character-info"] +t = ":run-shell-command make test" + +[keys.normal.g] +a = "code_action" + +[keys.normal."space"] +B = "file_picker_in_current_buffer_directory" + +[keys.normal.Z] +Z = ":write-quit-all" +Q = ":quit-all" + +[keys.select] +x = "extend_line" +";" = ["collapse_selection", "normal_mode"] +V = "extend_to_line_end" + + +[keys.insert] +C-q = "collapse_selection" +C-space = "signature_help" diff --git a/systems/zw/home/helix/languages.toml b/systems/zw/home/helix/languages.toml new file mode 100644 index 0000000..5f80281 --- /dev/null +++ b/systems/zw/home/helix/languages.toml @@ -0,0 +1,71 @@ +[[language]] +name = "hcl" +scope = "source.tf" +roots = ["main.tf", ".terraform.d"] +file-types = ["hcl", "tf"] +auto-format = true +language-servers = [ "terraform-lsp" ] + +[[language]] +name = "go" +formatter = { command = "goimports" } +# config = { goimports = true, gofumpt = true, staticcheck = true, analyses = { unusedparams = true, unreachable = true } } + +[[language]] +name = "nix" +scope = "source.nix" +injection-regex = "nix" +file-types = ["nix"] +shebangs = [] +roots = [] +comment-token = "#" +language-servers = [ "nil" ] +indent = { tab-width = 2, unit = " " } +auto-format = true + +[[language]] +name = "markdown" +file-types = ["md", "eml"] +language-servers = [ "ltex-ls "] + +[[language]] +name = "html" +file-types = ["html"] +auto-format = false +language-servers = ["vscode-html-language-server"] + +[[language]] +name = "css" +file-types = ["css", "scss"] +language-servers = ["vscode-css-language-server"] + +[[language]] +name = "javascript" +file-types = ["js"] +language-servers = ["typescript-language-server"] + +[[grammar]] +name = "nix" +source = { git = "https://github.com/nix-community/tree-sitter-nix", rev = "1b69cf1fa92366eefbe6863c184e5d2ece5f187d" } + +[language-server."terraform-lsp"] +command = "terraform-lsp" + +[language-server.nil] +command = "nil" + +[language-server."ltex-ls"] +command = "ltex-ls" + +[language-server."vscode-html-language-server"] +command = "vscode-html-language-server" +args = ["--add-flags", "--stdio"] + +[language-server."vscode-css-language-server"] +command = "vscode-css-language-server" +args = ["--add-flags", "--stdio"] + +[language-server."typescript-language-server"] +command = "typescript-language-server" +args = ["--stdio"] + diff --git a/systems/zw/home/kitty/kitty_grab.conf b/systems/zw/home/kitty/kitty_grab.conf new file mode 100644 index 0000000..2e4e1a7 --- /dev/null +++ b/systems/zw/home/kitty/kitty_grab.conf @@ -0,0 +1,55 @@ +# vim:fileencoding=utf-8:ft=conf:foldmethod=marker + +#: Colors {{{ + +# selection_foreground #FFFFFF +# selection_background #5294E2 + +#: Colors for selected text while grabbing. + +#: }}} + +#: Key shortcuts {{{ + +# map q quit + +#: Exit the grabber without copying anything. + +# map Enter confirm +map y confirm + +#: Copy the selected region to clipboard and exit. + +map h move left +map l move right +map k move up +map j move down +map Ctrl+u move page up +map Ctrl+d move page down +map 0 move first +map ^ move first nonwhite +map $ move last nonwhite +map g move top +map G move bottom +map b move word left +map w move word right + +#: Move the cursor around the screen. +#: This will scroll the buffer if needed and possible. +#: Note that due to https://github.com/kovidgoyal/kitty/issues/5469, the ctrl+d +#: shortcut will only work with kitty >= 0.26.2 + +map Ctrl+y scroll up +map Ctrl+e scroll down + +#: Scroll the buffer, if possible. +#: Cursor stays in the same position relative to the screen. + +map v set_mode visual +map Ctrl+v set_mode block +map Ctrl+Left_Bracket set_mode normal +map Escape set_mode normal + +#: Change the selecting mode. + +#: }}} diff --git a/systems/zw/home/nix/nix.conf b/systems/zw/home/nix/nix.conf new file mode 100644 index 0000000..c7d7291 --- /dev/null +++ b/systems/zw/home/nix/nix.conf @@ -0,0 +1 @@ +experimental-features = nix-command flakes diff --git a/systems/zw/home/notmuch/querymap-personal b/systems/zw/home/notmuch/querymap-personal new file mode 100644 index 0000000..c87db6f --- /dev/null +++ b/systems/zw/home/notmuch/querymap-personal @@ -0,0 +1,2 @@ +Inbox=tag:inbox and tag:personal and not tag:archived +Archive=tag:archived and tag:personal and not tag:inbox diff --git a/systems/zw/home/notmuch/querymap-zenity b/systems/zw/home/notmuch/querymap-zenity new file mode 100644 index 0000000..eb58ea3 --- /dev/null +++ b/systems/zw/home/notmuch/querymap-zenity @@ -0,0 +1,2 @@ +Inbox=tag:inbox and tag:zenity and not tag:archived +Archive=tag:archived and tag:zenity and not tag:inbox diff --git a/systems/zw/home/root.nix b/systems/zw/home/root.nix new file mode 100644 index 0000000..59138b6 --- /dev/null +++ b/systems/zw/home/root.nix @@ -0,0 +1,48 @@ +{ ... }: +{ + # This should be the same value as `system.stateVersion` in + # your `configuration.nix` file. + home.stateVersion = "23.05"; + + home.file = { + ".config/helix" = { + source = ./helix; + recursive = true; + }; + }; + + programs.helix = { + enable = true; + settings = (builtins.fromTOML (builtins.readFile ./helix/config.toml)); + languages = { + langauge = (builtins.fromTOML (builtins.readFile ./helix/languages.toml)); + }; + }; + + programs.git = { + enable = true; + userName = "Adriano Caloiaro"; + userEmail = "code@adriano.fyi"; + }; + + programs.zsh = { + enable = true; + shellAliases = { + ll = "ls -l"; + rebuild = "sudo nixos-rebuild switch"; + }; + + oh-my-zsh = { + enable = true; + plugins = [ + "sudo" + "git" + "dotenv" + "zsh-syntax-highlighting" + "fzf" + ]; + }; + + }; +} + diff --git a/systems/zw/home/tmux/tmux.conf b/systems/zw/home/tmux/tmux.conf new file mode 100644 index 0000000..eca459d --- /dev/null +++ b/systems/zw/home/tmux/tmux.conf @@ -0,0 +1,71 @@ +set -g default-terminal "screen-256color" + +# Enable mouse scrolling +set-option -g mouse on + +# Set the prefix to `ctrl + a` instead of `ctrl + b` +unbind C-b +set-option -g prefix C-a +bind-key C-a send-prefix + +set -g base-index 1 + +# Automatically set window title +set-option -g set-titles on +set-option -g status-interval 5 +set-option -g automatic-rename on +#set-option -g automatic-rename-format '#{=10:#{b:pane_current_path}}' +set-option -g automatic-rename-format '#{b:pane_current_path}' + +set -g status-keys vi +set -g history-limit 10000 + +setw -g mode-keys vi +setw -g monitor-activity on + +bind-key v split-window -h +bind-key s split-window -v + +bind-key J resize-pane -D 1 +bind-key K resize-pane -U 1 +bind-key H resize-pane -L 1 +bind-key L resize-pane -R 1 + +bind-key M-j resize-pane -D +bind-key M-k resize-pane -U +bind-key M-h resize-pane -L +bind-key M-l resize-pane -R + +# Vim style pane selection +bind h select-pane -L +bind j select-pane -D +bind k select-pane -U +bind l select-pane -R + +# Use Alt-vim keys without prefix key to switch panes +bind -n M-h select-pane -L +bind -n M-j select-pane -D +bind -n M-k select-pane -U +bind -n M-l select-pane -R + +# Use Alt-arrow keys without prefix key to switch panes +bind -n M-Left select-pane -L +bind -n M-Right select-pane -R +bind -n M-Up select-pane -U +bind -n M-Down select-pane -D + +# Shift arrow to switch windows +bind -n S-Left previous-window +bind -n S-Right next-window + +# No delay for escape key press +set -sg escape-time 0 + +# Copy to system clipboard +bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard' + +# Reload tmux config +bind r source-file ~/.config/tmux/tmux.conf + +# Add theme +source-file ~/.config/tmux/tmuxline.tmux diff --git a/systems/zw/home/tmux/tmuxline.tmux b/systems/zw/home/tmux/tmuxline.tmux new file mode 100644 index 0000000..ee51ee8 --- /dev/null +++ b/systems/zw/home/tmux/tmuxline.tmux @@ -0,0 +1,21 @@ +# This tmux statusbar config was created by tmuxline.vim +# on Mon, 23 Sep 2019 + +set -g status-justify "centre" +set -g status "on" +set -g status-left-style "none" +set -g message-command-style "fg=colour255,bg=colour238" +set -g status-right-style "none" +set -g pane-active-border-style "fg=colour190" +set -g status-style "none,bg=colour234" +set -g message-style "fg=colour255,bg=colour238" +set -g pane-border-style "fg=colour238" +set -g status-right-length "100" +set -g status-left-length "100" +setw -g window-status-activity-style "none,fg=colour190,bg=colour234" +setw -g window-status-separator "" +setw -g window-status-style "none,fg=colour85,bg=colour234" +set -g status-left "#[fg=colour17,bg=colour190] #S #[fg=colour190,bg=colour238,nobold,nounderscore,noitalics]#[fg=colour255,bg=colour238] #[fg=colour238,bg=colour234,nobold,nounderscore,noitalics]#[fg=colour85,bg=colour234] #[fg=colour234,bg=colour234,nobold,nounderscore,noitalics]" +set -g status-right "#[fg=colour234,bg=colour234,nobold,nounderscore,noitalics]#[fg=colour85,bg=colour234] %a #[fg=colour238,bg=colour234,nobold,nounderscore,noitalics]#[fg=colour255,bg=colour238] %R" +setw -g window-status-format "#[fg=colour234,bg=colour234,nobold,nounderscore,noitalics]#[default] #I #W #[fg=colour234,bg=colour234,nobold,nounderscore,noitalics]" +setw -g window-status-current-format "#[fg=colour234,bg=colour238,nobold,nounderscore,noitalics]#[fg=colour255,bg=colour238] #I #W #[fg=colour238,bg=colour234,nobold,nounderscore,noitalics]" diff --git a/systems/zw/home/tmux/tomorrow-night.tmux b/systems/zw/home/tmux/tomorrow-night.tmux new file mode 100644 index 0000000..664ee53 --- /dev/null +++ b/systems/zw/home/tmux/tomorrow-night.tmux @@ -0,0 +1,58 @@ +# Color key: +# #1d1f21 Background +# #282a2e Current Line +# #373b41 Selection +# #c5c8c6 Foreground +# #969896 Comment +# #cc6666 Red +# #de935f Orange +# #f0c674 Yellow +# #b5bd68 Green +# #8abeb7 Aqua +# #81a2be Blue +# #b294bb Purple + + +## set status bar +set -g status-bg default +setw -g window-status-current-style bg="#282a2e",fg="#81a2be" + +## highlight active window +setw -g window-style 'bg=#282a2e' +setw -g window-active-style 'bg=#1d1f21' +setw -g pane-active-border-style '' + +## highlight activity in status bar +setw -g window-status-activity-style fg="#8abeb7",bg="#1d1f21" + +## pane border and colors +set -g pane-active-border-style bg=default,fg="#373b41" +set -g pane-border-style bg=default,fg="#373b41" + +set -g clock-mode-colour "#81a2be" +set -g clock-mode-style 24 + +set -g message-style bg="#8abeb7",fg="#000000" + +set -g message-command-style bg="#8abeb7",fg="#000000" + +# message bar or "prompt" +set -g message-style bg="#2d2d2d",fg="#cc99cc" + +set -g mode-style bg="#1d1f21",fg="#de935f" + +# right side of status bar holds "[host name] (date time)" +set -g status-right-length 100 +set -g status-right-style fg=black,bold +set -g status-right '#[fg=#f99157,bg=#2d2d2d] %H:%M |#[fg=#6699cc] %y.%m.%d ' + +# make background window look like white tab +set-window-option -g window-status-style bg=default,fg=white +set-window-option -g window-status-format '#[fg=#6699cc,bg=colour235] #I #[fg=#999999,bg=#2d2d2d] #W #[default]' + +# make foreground window look like bold yellow foreground tab +set-window-option -g window-status-current-format '#[fg=#f99157,bg=#2d2d2d] #I #[fg=#cccccc,bg=#393939] #W #[default]' + +# active terminal yellow border, non-active white +set -g pane-border-style bg=default,fg="#999999" +set -g pane-active-border-style fg="#f99157" diff --git a/systems/zw/home/vimrc b/systems/zw/home/vimrc new file mode 100644 index 0000000..9584388 --- /dev/null +++ b/systems/zw/home/vimrc @@ -0,0 +1,235 @@ +syntax on + +set nocompatible " be iMproved, required +filetype off " required + +" set the runtime path to include Vundle and initialize +set rtp+=~/.vim/bundle/Vundle.vim +call vundle#begin() + +Plugin 'airblade/vim-gitgutter' " Add git indicators in the gutter +Plugin 'ddollar/nerdcommenter' " Add nice commenting shortcuts +Plugin 'fatih/vim-go', { 'do': ':GoInstallBinaries' } " Go/lsp support +Plugin 'flazz/vim-colorschemes' " A collection of color scheme +Plugin 'jremmen/vim-ripgrep' " Search with ripgrep +Plugin 'junegunn/fzf.vim' " FZF search for all things +Plugin 'junegunn/fzf', { 'do': { -> fzf#install() } } +Plugin 'reedes/vim-lexical' " Spell checking +Plugin 'ludovicchabant/vim-gutentags' " Use ctags +Plugin 'reedes/vim-pencil' " Better prose authorship support +Plugin 'scrooloose/nerdtree' " View stuff in trees +Plugin 'tpope/vim-fugitive' " Git support +Plugin 'vim-airline/vim-airline' " Airline +Plugin 'VundleVim/Vundle.vim' " Vundle manages itself +Plugin 'w0rp/ale' " Async linting +Plugin 'hashivim/vim-terraform' " Terraform/hcl support +Plugin 'alvan/vim-closetag' " Automatically close HTML tags +Plugin 'luochen1990/rainbow' +Plugin 'LnL7/vim-nix' " nix syntax highlighting +call vundle#end() + +filetype plugin indent on + +"" General +colorscheme Tomorrow-Night + +set clipboard=unnamedplus +set encoding=utf-8 +set number " Show line numbers +set linebreak " Break lines at word (requires Wrap lines) +set textwidth=120 " Line wrap (number of cols) +set showmatch " Highlight matching brace +set showcmd " Show the current command +set errorbells " Beep or flash screen on errors +set visualbell " Use visual bell (no beeping) +set hlsearch " Highlight all search results +set smartcase " Enable smart-case search +set gdefault " Always substitute all matches in a line +set ignorecase " Always case-insensitive +set incsearch " Searches for strings incrementally +set autoindent " Auto-indent new lines +set expandtab " Use spaces instead of tabs +set shiftwidth=2 " Number of auto-indent spaces +set smartindent " Enable smart-indent +"set smarttab " Enable smart-tabs +set softtabstop=2 " Number of spaces per Tab +"set termguicolors " Enable to enable rich colors outside of tmux +set t_Co=256 + +"" Visual settings + +"" Dark blue background for highlights to extenuate the cursor +hi Search term=bold ctermbg=24 guibg=#2B5B77 + +"" Advanced +set ruler " Show row and column ruler information +set undolevels=1000 " Number of undo levels +set backspace=indent,eol,start " Backspace behaviour +set wildmenu " pop-up menu for file completion +set updatetime=250 " Update interval -- useful for git-gutter updates " +set hidden +set equalalways + +if has('persistent_undo') + set undofile + set undodir=~/.vim/undo +endif + +set sw=2 +set ts=2 +autocmd Filetype ruby set softtabstop=2 +autocmd Filetype ruby set sw=2 +autocmd Filetype ruby set ts=2 +autocmd BufWritePre * %s/\s\+$//e " remove trailing whitespaces on save +autocmd FileType make set noexpandtab + +"" Custom keybindings +let mapleader = "," +"map y "+y +"map p "+p +nnoremap :GFiles +noremap c :close +noremap gr :GoRun +noremap gt :GoTest + +"" For authoring in mutt +au BufNewFile,BufRead neomutt-*-\w\+,neomutt[[:alnum:]_-]\\\{6\} setfiletype mail + +"" Formatting for authoring text +let g:pencil#wrapModeDefault = 'soft' +let g:pencil#textwidth = 120 +augroup pencil + autocmd! + autocmd FileType markdown,mkd,text,mail call pencil#init({'wrap': 'soft', 'autoformat': 1}) + \ | call lexical#init() + augroup END +" Module configurations + +" GO +let g:go_fmt_command = "goimports" +let g:go_rename_command = 'gopls' +let g:go_def_mode = 'gopls' +let g:go_info_mode = 'gopls' +let g:go_auto_type_info = 1 +let g:go_auto_sameids = 1 " Highlight all the things with the same IDs on hover +au FileType go nmap d (go-doc) " Go documentation + +" NERDTree +nmap nt :NERDTreeFind +nmap nc :NERDTreeClose +map b :NERDTreeToggle + +" fzf.vim +set rtp+=/usr/bin/fzf + +" coc-vim {{{ +" if hidden is not set, TextEdit might fail. +set hidden +nnoremap h :call CocActionAsync('doHover') +" }}} + +" ALE {{{ +let g:ale_completion_enabled = 0 +let g:ale_set_highlights = 0 +let g:ale_fix_on_save = 1 +let g:ale_lint_on_enter = 1 +let g:ale_lint_on_save = 1 +let g:ale_linters = { + \ 'ruby': ['solargraph', 'rubocop'], + \ 'javascript.jsx': ['eslint'], + \ 'go': ['bingo', 'staticcheck', 'govet', 'golint'], + \ 'diff': [], + \ } +let g:ale_fixers = { + \ 'eruby.yaml': [ + \ 'remove_trailing_lines', + \ 'trim_whitespace', + \ 'prettier', + \ ], + \ 'go': [ + \ 'gofmt', + \ 'goimports', + \ 'remove_trailing_lines', + \ 'trim_whitespace', + \ ], + \ 'javascript': [ + \ 'remove_trailing_lines', + \ 'trim_whitespace', + \ 'eslint', + \ 'prettier', + \ 'standard', + \ ], + \ 'make': [ + \ 'remove_trailing_lines', + \ 'trim_whitespace', + \ ], + \ 'ruby': [ + \ 'remove_trailing_lines', + \ 'trim_whitespace', + \ 'rubocop', + \ 'rufo', + \ 'standardrb', + \ ], + \ 'yaml': [ + \ 'remove_trailing_lines', + \ 'trim_whitespace', + \ 'prettier', + \ ], + \ 'diff': [], + \ 'sh': [ + \ 'remove_trailing_lines', + \ 'trim_whitespace', + \ 'shfmt', + \ ], + \ 'python': [ + \ 'reorder-python-imports', + \ 'autopep8', + \ 'remove_trailing_lines', + \ 'trim_whitespace', + \ ], + \ } + +set completeopt=menu,menuone,preview,noselect,noinsert +let g:ale_ruby_solargraph_executable = 'bundle' +let g:ale_ruby_rubocop_executable = 'bundle' +let g:ale_go_bingo_executable = $GOPATH."/bin/gopls" +let g:ale_go_goimports_executable = $GOPATH.'/bin/goimports' +let g:ale_sh_shfmt_options = "-i 2 -ci" +highlight ALEWarning ctermbg=none cterm=underline +highlight ALEError ctermbg=lightgray cterm=none +autocmd BufEnter diff let ale_fix_on_save=0 +set omnifunc=ale#completion#OmniFunc +" }}} + +"" Tmuxline +let g:tmuxline_separators = { + \ 'left' : '', + \ 'left_alt': '>', + \ 'right' : '', + \ 'right_alt' : '<', + \ 'space' : ' '} + +let g:tmuxline_preset = { + \'a' : '#S', + \'b' : '#W', + \'c' : '#H', + \'win' : '#I #W', + \'cwin' : '#I #W', + \'x' : '%a', + \'y' : '#W %R', + \'z' : '#H'} + +"" Aliases +noremap md :w !pandoc -f markdown -t html \> report.html + +"" Python +au BufRead,BufNewFile *.py setlocal textwidth=80 + +"" Pymode +let g:pymode_trim_whitespaces = 1 +let g:pymode_options_max_line_length = 120 +let g:pymode_options_colorcolumn = 0 +let g:pymode = 1 +let g:pymode_virtualenv = 1 +noremap f :PymodeLintAuto + diff --git a/systems/zw/nixos-zfs-setup.sh b/systems/zw/nixos-zfs-setup.sh new file mode 100644 index 0000000..645c9b9 --- /dev/null +++ b/systems/zw/nixos-zfs-setup.sh @@ -0,0 +1,332 @@ +# vim: ts=4 sw=4 ai noet si sta fdm=marker +# +# Edit the variables below. Then run this by issuing: +# `bash ./nixos-zfs-setup.sh` +# +# WARNING: this script will clear partition tables of existing disks. +# Make sure that you set the DISK variable correctly. Additionally, it +# is a good idea to clean your disk(s) current partitions first. Use the +# command `wipefs` for this. +# +############################################################################### +# nixos-zfs-setup.sh: a bash script that sets up zfs disks for NixOS. # +# Copyright (C) 2022 Mark (voidzero) van Dijk, The Netherlands. # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +############################################################################### + +set -ex + +DISK=(/dev/nvme0n1) + +# For qemu +# DISK=(/dev/vda) + +# How to name the partitions. This will be visible in 'gdisk -l /dev/disk' and +# in /dev/disk/by-partlabel. +PART_MBR="bootcode" +PART_EFI="nixos-efi-boot" +PART_BOOT="bpool" +PART_SWAP="swap" +PART_ROOT="rpool" + +# How much swap per disk? +SWAPSIZE=2G + +# The type of virtual device for boot and root. If kept empty, the disks will +# be joined (two 1T disks will give you ~2TB of data). Other valid options are +# mirror, raidz types and draid types. You will have to manually add other +# devices like spares, intent log devices, cache and so on. Here we're just +# setting this up for installation after all. +#ZFS_BOOT_VDEV="mirror" +#ZFS_ROOT_VDEV="mirror" + +# How to name the boot pool and root pool. +ZFS_BOOT="bpool" +ZFS_ROOT="rpool" + +# How to name the root volume in which nixos will be installed. +# If ZFS_ROOT is set to "rpool" and ZFS_ROOT_VOL is set to "nixos", +# nixos will be installed in rpool/nixos, with a few extra subvolumes +# (datasets). +ZFS_ROOT_VOL="nixos" + +# Generate a root password with mkpasswd -m SHA-512 +ROOTPW='$6$bTEEFEO9FnFo5rF.$n0UlhI3VzPpoiWTHwALK0Xs/B7.XlutijAYFXRXix/TdDEo2/9rbV4p5CCwELilbbxZIFi4EKl4RnxuCOBvgL/' + +# Do you want impermanence? In that case set this to 1. Not yes, not hai, 1. +IMPERMANENCE=0 + +# If IMPERMANENCE is 1, this will be the name of the empty snapshots +EMPTYSNAP="SYSINIT" + +# If 1, do the partition step +DO_PARTITION=1 + +# If 1, generate nixos configs +DO_CONFIG_GEN=1 + +# End of settings. + +set +x + +MAINCFG="/mnt/etc/nixos/configuration.nix" +HWCFG="/mnt/etc/nixos/hardware-configuration.nix" +ZFSCFG="/mnt/etc/nixos/zfs.nix" + +if [[ ${#DISK[*]} -eq 1 ]] && [[ -n ${ZFS_BOOT_VDEV} || -n ${ZFS_ROOT_VDEV} ]] +then + echo "Error: You have only specified one disk. ZFS_BOOT_VDEV and ZFS_ROOT_DEV must be unset or empty." >&2 + false +fi + +if [[ -z ${ROOTPW} ]] +then + echo "Error: Please generate a password hash and put that in this file's ROOTPW variable." >&2 + false +fi + +set -x +if (( $DO_PARTITION )) +then + i=0 SWAPDEVS=() + for d in ${DISK[*]} + do + sgdisk --zap-all ${d} + sgdisk -a1 -n1:0:+1M -t1:EF02 -c 1:${PART_MBR}${i} ${d} + sgdisk -n2:0:+1G -t2:EF00 -c 2:${PART_EFI}${i} ${d} + sgdisk -n3:0:+4G -t3:BE00 -c 3:${PART_BOOT}${i} ${d} + sgdisk -n4:0:+${SWAPSIZE} -t4:8200 -c 4:${PART_SWAP}${i} ${d} + SWAPDEVS+=(${d}4) + sgdisk -n5:0:0 -t5:BF00 -c 5:${PART_ROOT}${i} ${d} + + partprobe ${d} + sleep 2 + mkswap -L ${PART_SWAP}fs${i} /dev/disk/by-partlabel/${PART_SWAP}${i} + swapon /dev/disk/by-partlabel/${PART_SWAP}${i} + (( i++ )) || true + done + unset i d + + # Wait for a bit to let udev catch up and generate /dev/disk/by-partlabel. + sleep 3s + +fi + +# Create the boot pool +zpool create -f \ + -o compatibility=grub2 \ + -o ashift=12 \ + -o autotrim=on \ + -O acltype=posixacl \ + -O compression=lz4 \ + -O devices=off \ + -O normalization=formD \ + -O relatime=on \ + -O xattr=sa \ + -O mountpoint=none \ + -O checksum=sha256 \ + -R /mnt \ + ${ZFS_BOOT} ${ZFS_BOOT_VDEV} /dev/disk/by-partlabel/${PART_BOOT}* + +# Create the root pool +zpool create -f \ + -o ashift=12 \ + -o autotrim=on \ + -O acltype=posixacl \ + -O compression=zstd \ + -O dnodesize=auto -O normalization=formD \ + -O relatime=on \ + -O xattr=sa \ + -O mountpoint=none \ + -O checksum=edonr \ + -R /mnt \ + ${ZFS_ROOT} ${ZFS_ROOT_VDEV} /dev/disk/by-partlabel/${PART_ROOT}* + +# Create the boot dataset +zfs create ${ZFS_BOOT}/${ZFS_ROOT_VOL} + +# Create the root dataset +zfs create -o encryption=on -o keylocation=prompt -o keyformat=passphrase -o mountpoint=/ ${ZFS_ROOT}/${ZFS_ROOT_VOL} + +# Create datasets (subvolumes) in the root dataset +zfs create ${ZFS_ROOT}/${ZFS_ROOT_VOL}/home +(( $IMPERMANENCE )) && zfs create ${ZFS_ROOT}/${ZFS_ROOT_VOL}/keep || true +zfs create -o atime=off ${ZFS_ROOT}/${ZFS_ROOT_VOL}/nix +zfs create ${ZFS_ROOT}/${ZFS_ROOT_VOL}/root +zfs create ${ZFS_ROOT}/${ZFS_ROOT_VOL}/usr +zfs create ${ZFS_ROOT}/${ZFS_ROOT_VOL}/var + +# Create datasets (subvolumes) in the boot dataset +# This comes last because boot order matters +zfs create -o mountpoint=/boot ${ZFS_BOOT}/${ZFS_ROOT_VOL}/boot + +# Make empty snapshots of impermanent volumes +if (( $IMPERMANENCE )) +then + for i in "" /usr /var + do + zfs snapshot ${ZFS_ROOT}/${ZFS_ROOT_VOL}${i}@${EMPTYSNAP} + done +fi + +# Create, mount and populate the efi partitions +i=0 +for d in ${DISK[*]} +do + mkfs.vfat -n nixos-boot /dev/disk/by-partlabel/${PART_EFI}${i} + mkdir -p /mnt/boot/efis/${PART_EFI}${i} + mount -t vfat /dev/disk/by-partlabel/${PART_EFI}${i} /mnt/boot/efis/${PART_EFI}${i} + (( i++ )) || true +done +unset i d + +# Mount the first drive's efi partition to /mnt/boot/efi +mkdir /mnt/boot/efi +mount -t vfat /dev/disk/by-partlabel/${PART_EFI}0 /mnt/boot/efi + +# Make sure we won't trip over zpool.cache later +mkdir -p /mnt/etc/zfs/ +rm -f /mnt/etc/zfs/zpool.cache +touch /mnt/etc/zfs/zpool.cache +chmod a-w /mnt/etc/zfs/zpool.cache +chattr +i /mnt/etc/zfs/zpool.cache + +# Generate and edit configs +if (( $DO_CONFIG_GEN )) +then + nixos-generate-config --root /mnt +fi + +sed -i -e "s|./hardware-configuration.nix|& ./zfs.nix|" ${MAINCFG} + +if (( $IMPERMANENCE )) +then + echo '{ config, lib, pkgs, ... }:' +else + echo '{ config, pkgs, ... }:' +fi | tee -a ${ZFSCFG} + +tee -a ${ZFSCFG} <>${ZFSCFG} +done + +tee -a ${ZFSCFG} < /etc/nixos + # here, and copy the files and actually mount the bind later + ADDNR=$(awk '/^ swapDevices =/ {print NR-1}' ${HWCFG}) + TMPFILE=$(mktemp) + head -n ${ADDNR} ${HWCFG} > ${TMPFILE} + + tee -a ${TMPFILE} <> ${TMPFILE} + cat ${TMPFILE} > ${HWCFG} + rm -f ${TMPFILE} + unset ADDNR TMPFILE +fi + +tee -a ${ZFSCFG} < ssh-keygen -t rsa -b 4096 -C "code@adriano.fyi" -f ~/.ssh/id_rsa_ -P "" + +Once keys have been generated for the new system, the private key needs to be transferred to the new system: `/root/.ssh/id_rsa` + +## Dependencies + +Adding keys and re-keying require `agenix` to be installed. On a nix system, install with `nix-shell -p agenix`. + +## Re-keying + +Re-keying must be done when new keys are added. + +> agenix -r + +## Adding secrets + +To add new secrets, edit `secrets.nix` and then edit this contents of the new secrets with: + +> agenix -e + +Don't forget to commit new secrets to git. diff --git a/systems/zw/secrets/nomad_token.age b/systems/zw/secrets/nomad_token.age new file mode 100644 index 0000000..b49aba5 --- /dev/null +++ b/systems/zw/secrets/nomad_token.age @@ -0,0 +1,16 @@ +age-encryption.org/v1 +-> ssh-rsa QGRkYA +BOSiYT5elxD2WMIRkLdOeXG7xSpniyTpoZ+CBG1fKjMA3Rif2Yi7W9x9tHLlJ9A9 +/TS/E3Jia9yeqw2rWlWozN5E4mz0UnWgvNYtCQRDjSUZHhN+sLD3j78+bwRgpl0U +JFJ/G2f4zJqEBhyefpkOBCDvlzgFskWAKMnOdlnA4LLH18Wll/0rUN3zb+tcxCE1 +vEIbFbSSSz9lkKijqna0Yohsp6tJ+R1yLSoe6SDJhO1u+eeujdttkD8uygpjhd4r +NrWa4NijTTXpL8zWUs0W08Hx+oxsbU6LP4SVNASYpyTZZ6/4L0CAFN9aLZnSay6j +iGzCjcJbXtm0DR2lSG9XwvVcvbWj5uOuccN8tlV/Nk6UGA6c2V76Hj8i9cmxsQFj +IHT21wSi+2mpN47tPDRENeg+gqlIWc8mKa199+as7y1J/e6+sc71KHvlSQAdZAFb +Tu/l0+bF1MoVgcCDDOwyf+RHA8Bt4/HET0/kX+/fTiCuaQ4vHQ0tesCu0qnS/zsH + +-> &S}Rck-grease aS8C^ 2 +iWvWSmCGTH1fHZcm5fsb04nWWfTXY0q3dRmtrU5lLos6o+WvGJabxEJPtt/rJf8/ +4DtW +--- JOLnZsMpQvMk1Vll4gd1gAAR+Heoy1jtBFEyR1VHc2A + Hh0ۧCsz Pឦv1|xt6@H5<@W"b:u \ No newline at end of file diff --git a/systems/zw/secrets/secrets.nix b/systems/zw/secrets/secrets.nix new file mode 100644 index 0000000..d068fbb --- /dev/null +++ b/systems/zw/secrets/secrets.nix @@ -0,0 +1,10 @@ +let + agenix = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCx/tvR11RUMbYaauuHPxR3j79vm1Hxg+Y3LXR+rLgZ7N/2ulvIzLLZgVuIUbmJHDqkp9Au5zZPMZjsKbaqQ8V75wSEcyaSMbaxC9PaNDCwEHMJWaz8XPQe5IjVRE5O+4sTyh7ZBx+NMQmPcQbrNInoKuy4EjFmwTW/t0xYo/sCrC0NX0cCyeBwii2JdFXytXfxF+RMzGNXw1xfcOFJe6F7JdS/Cpf/0fe+VmNg8d0nic4Obcb/djYsRLAAC6Cvb+4i3EBZWl+9Ih9hId8bFCRKhI6TmGT2z4YUTa+v+3j/JZUh1gD5n4vRGf8QjLj9N6DrBnKcbywwqyqnLhTLgBBN35rcLdU1k3n0NorRRDCU0Lg/ejsFe3oi2FmOwNmmd8zqBNZHjJTi5Wy63EXMFwHltEY2M+hAhgWsQ5U4zuVPgv1HfD6LYPodRwhdZivwTNr2IClAiVVxR//O0WtrRXrrEM5uudj+Y30/ah7bn9Mje86UV0TqfS2tdjtMkySHL+M= adriano@z1"; + +in { + "wireless_networks.age".publicKeys = [ agenix ]; + "tailscale_key.age".publicKeys = [ agenix ]; + "nomad_token.age".publicKeys = [ agenix ]; + "spotify_password.age".publicKeys = [ agenix ]; +} + diff --git a/systems/zw/secrets/spotify_password.age b/systems/zw/secrets/spotify_password.age new file mode 100644 index 0000000..cc6ec8a --- /dev/null +++ b/systems/zw/secrets/spotify_password.age @@ -0,0 +1,14 @@ +age-encryption.org/v1 +-> ssh-rsa QGRkYA +X5rAkPPnzvbHhZ8REWWBjOPylBIWiN0W2JjCsY4BLn7MLMRlf0kLG1Ftr3f5A4XP +Hb8SIgIQO4pc7DOKCp9ZY7x3zfY7U/zncukk5sdQxPIqP7CpkjINUv3D6EmXeXTv +/m/asDMONAu0ZWeRCTQxJeymPaWEM76emwmAIQxYLiCIDiiIBcwtyC5fjflBDOK7 +KPKbt1TrGSrAA9bv6X7j1ZIKjVYgAT3MLY0/r0rKmskhg2qI5ZOmA6J+ETSj0G2c +0rZshSxB5vIoWHA1CJ6DIur8mXilx1bJgqe47/f7gEFWm/MKqkNNIQtm0txEGDFs +Vpp4HukQS2omQhJDSuRaMPgvL3y6wkqvJG9R+on4t94fvsBtZvM2IA5aE9hJIYVj +MhDtiNgxMji+x+ydz3D5e6aGKb/GlkaBm3oACItJlLyqPcGx+JWC+0M8f5DNhWtB +Lby2rzeMzUyFwAmYGVh4DPZasssRZCAkINbSjBkprAEXIlFGEVAagv2eaR93NmOq + +--- l1p7/OZ3bPAJi46WwJSKsTgvXmXtGnBvPF4jgfNuDD4 + '>•yɨ +d-U׷cCY" /r.rv/XuP8& \ No newline at end of file diff --git a/systems/zw/secrets/tailscale_key.age b/systems/zw/secrets/tailscale_key.age new file mode 100644 index 0000000..87fea97 --- /dev/null +++ b/systems/zw/secrets/tailscale_key.age @@ -0,0 +1,29 @@ +age-encryption.org/v1 +-> ssh-rsa QGRkYA +hQUb0jDFAosYx2tKt+0dIM1OGwrcVqFx5qciTiDGF78nTJZCinQ8hiaaIo4Yw+Ch +h8JLwJyU5kYXOXE4aeuzXYtzPYvAzOkxh9+6ydh0eBkr/Sqs7Kd3U8pou4u9QQO1 +iho00Lrru4h8HatV7IGEqdQ9qvCZPG0YQzk90uLBFmCxGNd0eMzzbbEAmGOdm21X +GHKx14pryqfyUKj52bRzgxDPj/qIrCf4ZHGseczQpTK20yncIaktWPq5zFtwPrGf +PIzsnisp9s1bfO4MmcIZiqb/3PGrlzWpCA5iYfdcoM/x85qnYJggBSeDBL17kbCh +iKF6Yb1zLXYap2bmDtIh09rsyndC4ym/kNOcFQsK32Lf7qqZEvwP4wr5z4eEvySK +Q06YufBG8nu5XHbUBSATzBq/nJynv9lkCkaWHXymabop+MD7YO9SXFfi8e6hRi8z +lulhw+m01tw+WF/kSfVEwXLEDp6wXkN2f54CegF3CjZlKMx7AAj2v9DY0NKaAD5M + +-> ssh-rsa tXyJsA +Y3GN+HwoRXI/OUMmJekJcXQeSlmu3Ahqhyn19nakqR/CA5ulAggdGAPiek0TuR43 +b/+sVhzKs5sPcXyw8yALAdKKQpwsAPiKnsGEo2xYIZcv5QDNApvMLzi0I9E+z3ns +IrFN/RLnKeeKkIRRq0CLdh/GGtjVMZhrazlLyD9cBdVM3XXNc7MvKGeZDdmUp46S +uVrUjXCp21X3W9eiVZ/h31h79NxF6DQfVQD9/JtMsaZOMCL8IMSucvgMTVMQA4yW +Cf8O7I/hkqJWDt4Vf8FFNyxm+CL+iKATwyQx4eqtemvy+/WBwHPE6qZvrS3uBtxv +w/uqd7Rp+4FV2p2OFIHVTZHjAJ4WkuxYUn1ZX6H+Jlzn2jOxhHw5uG9YBwVhN3hw +hwJRaZHzTcOeoK82j5kCVY0J+6ydUGIJCeTDWIVoz2CtaR/ir4PPRlj/BI1ImOBN +5P1ecNYVlweD3E7uhq4yWJ5x2Z+J3xkBnge5Rs6fc8mYvLGgYDzJZXIh+4+QZfcJ +V0fIyxOpHn/U0FUv2aDCq1HLqGcJghc9yh8RVBisbjzaaPWGrvTRTBapEJAaf+GY +gO7UWwHv1h3MMKjymwaxCMQ83NQ4nQUCbJsQA2SUczY1BpuPYcYJpnoiel7YNp+9 +OuEpSkivk5uQXSVvFloEg6J6uj64upuFmGNpGShZALY +-> n"-grease Wf5s 1 +a5NrucjdMCV2Qnkcg/1I +--- rMSZcgKmk0dqWfOj57p6hkQqPhx5LWShz65J+NeyLvg +=%B0+ۂ1uc,6ăN3640/! +K/F;YثH\Ph0cI. +l \ No newline at end of file diff --git a/systems/zw/secrets/wireless_networks.age b/systems/zw/secrets/wireless_networks.age new file mode 100644 index 0000000..5a9e8e8 --- /dev/null +++ b/systems/zw/secrets/wireless_networks.age @@ -0,0 +1,27 @@ +age-encryption.org/v1 +-> ssh-rsa QGRkYA +MRsfQcRUklPdwy64pFThkaOvA5/R3GeYz2nkIpNEl26vvQl7eIP3RFtpP1z7g2An ++KuMX9MrlwynjvNRVX84MWX6hREOMBUGM28SRVfbBB13H8tFfyKOpMMT+DnxuY04 +f6t+N8i2bnl6rbW55MOCHBVvvmscrqG4c2UBZF+Ab82QjszE7q1QM+B4ojEmbDZu +Mn+A9xvEujxhIS7bnieynNkLkdmRuK60Vbuw5SeC4/FYW9Eq0Y/+iwx7XTIb6tbW +Jk9jPWFAswyZ4DDH4HWctxTUvcAq/5k/wiw3LyimxR91RcE7QE8dPrEmuuM8+LOr +iQmHacyZXEqzZDM/Gtr+/OyabjccPFHQpgc3IkPUEBwYXXzJ1fIWUuaf93KVbPTk +/68mzUIflF7AZvJCgRoDDebZal6dgpIznPdX5FHM9B4ZNzMXLHJbUWKzl1E0rRGd +T0+jPzjhKQCNK8Ru8lJ9okiatV8+s3+RpIHWdRD99WXOnCjmVOiLg/GlweRr00Yg + +-> ssh-rsa tXyJsA +bu584TBsqrk4ad8cwlSV/AGzucpXQkYvC/SoP3IQLb0Yc3k3qm1seuGJB///USHh +cJBWkN/tv0fr5TT25CdDr8siVY6Y96qNzcb8POXFQskm0xyE92qcKRaZRfm+Vdll +i1kJqaX9SMpuS9o4xo4AUql8yLJrD8JtLcH0QN4dCOXSYeeNY/64k8C7q6IvDbB2 +IgW2eHN+M/PgeL5hLh+/siFiqAqjS17Swxfqwj7FLiO5WiM4zuG1ZPx7o40idF5B +UQ5HGDUvLnLeSArl09gDWHCESV1r69ZgWY5fwaugixk/Dx3jIc2bHKUiifj40v38 +wPfZJ5Hug03aDlZnUEO1LhpMlfIw0ARn+AOqMF92kURPXy9jmrcYC3ocglAUDr1b +n6L3F0QQWsYR9eVRqjXuHTD0t5kSPndjlzNecqo4crlRZiJ8iN4yxUQ3e7fCWFAQ +z8RRXHZOVeMqeUd0ufb+RlTXRvihOho+Vx4PXBsdUnFaynWD2zckM6VhZ/apT/JI +/k/rzmKBb8fHMAs60nRG3cnfQu/j2fyeBBfGESOWwT37TgIT2TJZeaSu7O8NjDgg +JQIHBrMZS8PR1L9IuO0QwCKBAB8TgQQJdo9AdP5xoaI0yvD8PTVkcNyKqGze7Mw8 +GVWffIW7rFe2E4sXqnNqBIXiP6PNHf1IFBoDQEULyso +--- JdW81keMuc3KLIZO/MDzH9qp8Cw/x5jXo648siUsArY +J -wu"ۨ x$JE\~6_