From 35a57d2905ef28eb81221fc33c48416d0ebf3f2d Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Fri, 1 Jul 2022 08:45:07 -0400 Subject: [PATCH] gh repos and fix mac build --- hosts/macbook/default.nix | 2 +- modules/darwin/default.nix | 5 +++- modules/darwin/utilities.nix | 2 +- modules/programming/python.nix | 16 +++++++++---- modules/shell/fish/default.nix | 5 ---- modules/shell/github.nix | 42 ++++++++++++++++++++++++++++++++++ 6 files changed, 59 insertions(+), 13 deletions(-) diff --git a/hosts/macbook/default.nix b/hosts/macbook/default.nix index ac7eb37..58e5e6a 100644 --- a/hosts/macbook/default.nix +++ b/hosts/macbook/default.nix @@ -19,7 +19,7 @@ darwin.lib.darwinSystem { ../../modules/applications/discord.nix ../../modules/programming/nix.nix ../../modules/programming/terraform.nix - ../../modules/programming/python.nix + # ../../modules/programming/python.nix ../../modules/programming/lua.nix ../../modules/programming/kubernetes.nix ]; diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix index 16ed22f..ce24802 100644 --- a/modules/darwin/default.nix +++ b/modules/darwin/default.nix @@ -1,4 +1,4 @@ -{ ... }: { +{ config, ... }: { imports = [ ./alacritty.nix @@ -12,4 +12,7 @@ ./utilities.nix ]; + home-manager.users.${config.user}.home.stateVersion = "22.11"; + home-manager.users.root.home.stateVersion = "22.11"; + } diff --git a/modules/darwin/utilities.nix b/modules/darwin/utilities.nix index df9f35a..fd93007 100644 --- a/modules/darwin/utilities.nix +++ b/modules/darwin/utilities.nix @@ -3,7 +3,7 @@ home-manager.users.${config.user} = { home.packages = with pkgs; [ - visidata # CSV inspector + # visidata # CSV inspector dos2unix # Convert Windows text files inetutils # Includes telnet youtube-dl # Convert web videos diff --git a/modules/programming/python.nix b/modules/programming/python.nix index 97da31b..3e3cabd 100644 --- a/modules/programming/python.nix +++ b/modules/programming/python.nix @@ -1,9 +1,15 @@ { config, pkgs, ... }: { - home-manager.users.${config.user}.home.packages = with pkgs; [ - python310 # Standard Python interpreter - nodePackages.pyright # Python language server - black # Python formatter - ]; + home-manager.users.${config.user} = { + + home.packages = with pkgs; [ + # python310 # Standard Python interpreter + nodePackages.pyright # Python language server + black # Python formatter + ]; + + programs.fish.shellAbbrs = { py = "python"; }; + + }; } diff --git a/modules/shell/fish/default.nix b/modules/shell/fish/default.nix index 53c88d4..8008c60 100644 --- a/modules/shell/fish/default.nix +++ b/modules/shell/fish/default.nix @@ -117,11 +117,6 @@ dr = "docker run --rm -it"; db = "docker build . -t"; - # Python - py = "python"; - po = "poetry"; - pr = "poetry run python"; - # Rust ca = "cargo"; diff --git a/modules/shell/github.nix b/modules/shell/github.nix index 85c002d..aefe176 100644 --- a/modules/shell/github.nix +++ b/modules/shell/github.nix @@ -32,6 +32,48 @@ }; }; + home.packages = [ + (pkgs.writeShellScriptBin "gh-repos" '' + #!/bin/sh + + case $1 in + t2) organization="take-two" ;; + d2c) organization="take-two-t2gp" ;; + t2gp) organization="take-two-t2gp" ;; + pd) organization="private-division" ;; + dots) organization="playdots" ;; + *) organization="nmasur" ;; + esac + + selected=$(gh repo list "$organization" \ + --limit 50 \ + --no-archived \ + --json=name,description,isPrivate,updatedAt,primaryLanguage \ + | jq -r '.[] | .name + "," + if .description == "" then "-" else .description |= gsub(","; " ") | .description end + "," + .updatedAt + "," + .primaryLanguage.name' \ + | (echo "REPO,DESCRIPTION,UPDATED,LANGUAGE"; cat -) \ + | column -s , -t \ + | fzf \ + --header-lines=1 \ + --layout=reverse \ + --bind "ctrl-o:execute:gh repo view -w ''${organization}/{1}" \ + --bind "shift-up:preview-half-page-up" \ + --bind "shift-down:preview-half-page-down" \ + --preview "GH_FORCE_TTY=49% gh repo view ''${organization}/{1} | glow -" \ + --preview-window up + ) + [ -n "''${selected}" ] && { + directory="$HOME/dev/work" + if [ $organization = "nmasur" ]; then directory="$HOME/dev/personal"; fi + repo=$(echo "''${selected}" | awk '{print $1}') + repo_full="''${organization}/''${repo}" + if [ ! -d "''${directory}/''${repo}" ]; then + gh repo clone "$repo_full" "''${directory}/''${repo}" + fi + echo "''${directory}/''${repo}" + } + '') + ]; + }; }