From 424a1db3a7997a2f7d8617aee0ac5f11f6d468c0 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Fri, 9 Feb 2024 19:18:33 +0100 Subject: [PATCH] Improve setup in many small ways - ircgay command for catgirl - fish keybinds for launching $EDITOR - uptimes script - fix neovide launch flags --- home/features/cli/catgirl.nix | 11 +++-- home/features/cli/default.nix | 1 + home/features/cli/fish/config.fish | 8 ++++ home/features/cli/scripts/default.nix | 6 +++ home/features/cli/scripts/uptimes.sh | 21 +++++++++ home/features/neovim/default.nix | 65 ++++++++++++++------------- hosts/nixos/common/secrets.yaml | 6 +-- 7 files changed, 80 insertions(+), 38 deletions(-) create mode 100644 home/features/cli/scripts/default.nix create mode 100755 home/features/cli/scripts/uptimes.sh diff --git a/home/features/cli/catgirl.nix b/home/features/cli/catgirl.nix index 00c2ba0..effdcb6 100644 --- a/home/features/cli/catgirl.nix +++ b/home/features/cli/catgirl.nix @@ -1,5 +1,5 @@ # Catgirl is a terminal based irc client -{ config, pkgs, hostname ? "hermes", ... }: +{ config, pkgs, lib, hostname ? "hermes", ... }: let mkCatgirlNetwork = network: '' host = ${network}.irc.moonythm.dev @@ -7,9 +7,14 @@ let user = ${hostname} port = 6697 ''; + + # prints an irc message in rainbow text + ircgay = pkgs.writeShellScriptBin "ircgay" '' + ${lib.getExe pkgs.toilet} -f term --irc --gay "$*" + ''; in { - satellite.persistence.at.state.apps.catgirl.directories = [ "${config.xdg.dataHome}/catgirl" ]; - home.packages = [ pkgs.catgirl ]; + home.packages = [ ircgay pkgs.catgirl ]; xdg.configFile."catgirl/tilde".text = mkCatgirlNetwork "tilde"; + satellite.persistence.at.state.apps.catgirl.directories = [ "${config.xdg.dataHome}/catgirl" ]; } diff --git a/home/features/cli/default.nix b/home/features/cli/default.nix index 2f80c70..2b0978e 100644 --- a/home/features/cli/default.nix +++ b/home/features/cli/default.nix @@ -1,5 +1,6 @@ { pkgs, inputs, ... }: { imports = [ + ./scripts ./eza.nix ./bat.nix ./ssh.nix diff --git a/home/features/cli/fish/config.fish b/home/features/cli/fish/config.fish index 803aa91..6190dd0 100644 --- a/home/features/cli/fish/config.fish +++ b/home/features/cli/fish/config.fish @@ -43,6 +43,14 @@ function fish_user_key_bindings bind -M default \cg "nvim +Neogit" bind -M insert \cg "nvim +Neogit" # }}} + # {{{ C-e to open $EDITOR + bind -M default \ce "$EDITOR" + bind -M insert \ce "$EDITOR" + # }}} + # {{{ C-S-e to open commandline in $EDITOR + bind -M default \e\[69\;5u "commandline -f edit_command_buffer" + bind -M insert \e\[69\;5u "commandline -f edit_command_buffer" + # }}} end # }}} # {{{ Helpers diff --git a/home/features/cli/scripts/default.nix b/home/features/cli/scripts/default.nix new file mode 100644 index 0000000..87584fe --- /dev/null +++ b/home/features/cli/scripts/default.nix @@ -0,0 +1,6 @@ +{ pkgs, ... }: +let uptimes = pkgs.writeShellScriptBin "uptimes" (builtins.readFile ./uptimes.sh); +in +{ + home.packages = [ uptimes ]; +} diff --git a/home/features/cli/scripts/uptimes.sh b/home/features/cli/scripts/uptimes.sh new file mode 100755 index 0000000..a2bcfc5 --- /dev/null +++ b/home/features/cli/scripts/uptimes.sh @@ -0,0 +1,21 @@ +print_uptime() { + local HOST=$1 + local EMOJI=$2 + + # -n: do not echo a newline + echo -n "$EMOJI $HOST: " + + # The output of `uptime` looks like this: + # `18:40:54 up 1 day 0:51, 0 users, load average: 0.79, 0.68, 0.69`, + # so we use awk to trim it down to the parts we care about. + # + # For awk: + # -F: splits the input by a string + ssh adrielus@$HOST uptime \ + | awk -F "up" '{print $2}' \ + | awk -F " " '{print $1, $2}' +} + +echo "Uptimes:" +print_uptime "tethys" "🔥" +print_uptime "lapetus" "⛵" diff --git a/home/features/neovim/default.nix b/home/features/neovim/default.nix index 201856f..93e5109 100644 --- a/home/features/neovim/default.nix +++ b/home/features/neovim/default.nix @@ -1447,16 +1447,19 @@ let # - NVIM_EXTRA_RUNTIME provides extra directories to add to the runtimepath. # I cannot just install those dirs using the builtin package support because # my package manager (lazy.nvim) disables those. - wrapClient = { base, name, binName ? name, extraArgs ? "" }: - let startupScript = config.satellite.lib.lua.writeFile - "." "startup" /* lua */ '' - vim.g.nix_extra_runtime = ${nlib.encode extraRuntime} - vim.g.nix_projects_dir = ${nlib.encode config.xdg.userDirs.extraConfig.XDG_PROJECTS_DIR} - vim.g.nix_theme = ${config.satellite.colorscheme.lua} - -- Provide hints as to what app we are running in - -- (Useful because neovide does not provide the info itself right away) - vim.g.nix_neovim_app = ${nlib.encode name} - ''; + wrapClient = { base, name, binName ? name, extraArgs ? "", wrapFlags ? lib.id }: + let + startupScript = config.satellite.lib.lua.writeFile + "." "startup" /* lua */ '' + vim.g.nix_extra_runtime = ${nlib.encode extraRuntime} + vim.g.nix_projects_dir = ${nlib.encode config.xdg.userDirs.extraConfig.XDG_PROJECTS_DIR} + vim.g.nix_theme = ${config.satellite.colorscheme.lua} + -- Provide hints as to what app we are running in + -- (Useful because neovide does not provide the info itself right away) + vim.g.nix_neovim_app = ${nlib.encode name} + ''; + extraFlags = lib.escapeShellArg (wrapFlags + ''--cmd "lua dofile('${startupScript}/startup.lua')"''); in pkgs.symlinkJoin { inherit (base) name meta; @@ -1465,35 +1468,33 @@ let postBuild = '' wrapProgram $out/bin/${binName} \ --prefix PATH : ${lib.makeBinPath extraPackages} \ - --add-flags ${lib.escapeShellArg ''--cmd "lua dofile('${startupScript}/startup.lua')"''} \ + --add-flags ${extraFlags} \ ${extraArgs} ''; }; # }}} # {{{ Clients - neovim = wrapClient - { - base = - if config.satellite.toggles.neovim-nightly.enable - then pkgs.neovim-nightly - else pkgs.neovim; - name = "nvim"; - }; + neovim = wrapClient { + base = + if config.satellite.toggles.neovim-nightly.enable + then pkgs.neovim-nightly + else pkgs.neovim; + name = "nvim"; + }; - neovide = wrapClient - { - base = pkgs.neovide; - name = "neovide"; - extraArgs = "--set NEOVIDE_MULTIGRID true"; - }; + neovide = wrapClient { + base = pkgs.neovide; + name = "neovide"; + extraArgs = "--set NEOVIDE_MULTIGRID true"; + wrapFlags = flags: "-- ${flags}"; + }; - firenvim = wrapClient - { - base = pkgs.neovim; - name = "firenvim"; - binName = "nvim"; - extraArgs = "--set GIT_DISCOVERY_ACROSS_FILESYSTEM 1"; - }; + firenvim = wrapClient { + base = pkgs.neovim; + name = "firenvim"; + binName = "nvim"; + extraArgs = "--set GIT_DISCOVERY_ACROSS_FILESYSTEM 1"; + }; # }}} in { diff --git a/hosts/nixos/common/secrets.yaml b/hosts/nixos/common/secrets.yaml index 735a672..a58eda1 100644 --- a/hosts/nixos/common/secrets.yaml +++ b/hosts/nixos/common/secrets.yaml @@ -1,4 +1,4 @@ -wireless: ENC[AES256_GCM,data:QKM3llNba24/3Hfjph9JFpOF+G4aGuGDfhlwE/bfvvAX7G/dYRZ5GMZtUIifREviacCywtqYcmLe+IIA9/NtLom3JkgXV5VEoaNym78fMaY5fVvsjqOgzp1O0XXu70UYvHgtA1pDZrCQEv/q7slkBS7mYP+g8NaRff9eIzs6zMWIl3HzqQbdwb5TOzsKzPNZgNp8f9nTmxm6EVdEHx0fhBLepXw6uDGA2Op12XDvR9UDkzwOkyy7oxEhKiPhqi5in8OqfhBGmQ73WV+g38pUNobp5cGL0YjjxHIWKEbX0N6ov2DH4QkeQhJgWNtEsTuGugjWkPvoAgfARMirt+PFZotFPBib1/xZHB7H,iv:TruRRS9fAGjkQU4zs2cOs1olxUYkOOypMmpxOIw9N9o=,tag:Yd4t0DKVpaUul4CrA8hYPA==,type:str] +wireless: ENC[AES256_GCM,data:Ib0PdBd2r/DPyE6Ah9NffT8Tw8c2y+seGFrE0e9GkyRaStdYMiiIlWCiaBO0u1HHaVV+2MQ33MnMdqyCGRlqGk45kl0GIwVR5iAiSYnobj/6wcse+kx/+5mzNOHXD1kJRGJBm5+SN9ntiGABNkQXJdn/Qoc/ukY1uaGe2nBeFKmGdD9JL7KfgdI5jYjQYyDbCL9JUszxkXNcplIRBAAy8JDaBVeo9HgI0QDIZToPKwuEeQoA9XzdimrjbCazlZy3ZvjAuoQXmrc1nIRHF5GabSRGTFTnTfcBeW2fGpUxmIhLyucn2DIQBXLm+RDdMLWoqcGbKiLVqKyUXck3ZZyoHMf2b9N52xMUwcS7,iv:ozkDwWmurWTD8TZHGvWL9Yh8cOrP1PzSBkz+1bBZybo=,tag:iGPjRaOoGRcOWJMweTL2yA==,type:str] adrielus_password: ENC[AES256_GCM,data:lREgbcKwzAJQ3PPTWt7LXmgAsrKFCN+baQx4Q2YrHlu16yvKpmaZzPHJ/C5IjucUNbdceTs6Ef99IWzju0d8Hl5Z5UTMspYIhQ==,iv:JqnL3zfCd/xMRqTciA/Q6nYmFKzJkBqda4zucsE5KFw=,tag:RGZ/0/NEpdchj9h/l3Z7Ig==,type:str] sops: kms: [] @@ -33,8 +33,8 @@ sops: WFd4ZFNHWG5Cakw5cU9MRE9HWHQ4THMKr/S7v1Oj3zQziMtI/NuFVm6AaJF5JV5U sEr2nEptYFz4G6YL5psQGXHaKzQKBg+crgKRbYL4akhqT7pfYPC0bQ== -----END AGE ENCRYPTED FILE----- - lastmodified: "2024-01-31T18:18:48Z" - mac: ENC[AES256_GCM,data:9kYBMib8MuIdcJK0Lxh3sYP4OrlFCn3DZP8X82mSvnK15l8rVXFu2xfIbt1nviDj9IFhsZ3+2qzUnPq650erG6JpuHdzdmxIE49nU8BqmqtiQ4SAFAdC7zEbWaWk3SKmm1ouarBuHWtfvN3uw/ULpdExxt8Or8kvgvoVPX2L85E=,iv:wDWg/ba89AqW5bwqVydLZdfhPFgkNLRTKx1caER6SmI=,tag:1JY/HsipandxtmCmYXuavQ==,type:str] + lastmodified: "2024-02-07T14:49:34Z" + mac: ENC[AES256_GCM,data:ZLMz0YRnEdq8jjlKPPrpudD8RVtr+ayfjGP7lXEiNUbHxhDClo/WjVpCd6HKdjy/76TZvb5Jq7+e3GTbBGm7CJjt7gS7b10gKAfqB+DwXrtO5PD9TeZOP0HCK5TwEKGjFDoPadKmQQyeBciLLZmKKmW3rtvL/G+U5ZkoPcedG1I=,iv:s7zaPCcYQFHEyNl99HAw3Ds2SUEhgAO5n4X0gODHMUY=,tag:VhqQnQv1wE7/k5GkzYNN3A==,type:str] pgp: [] unencrypted_suffix: _unencrypted version: 3.8.1