-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1df2b5c
commit e591cfc
Showing
94 changed files
with
1,326 additions
and
618 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
nixos/gcp-instance-2/default.nix → bastions/gcp-instance-2/default.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
{ pkgs, ... }: | ||
let | ||
nextAppWin = pkgs.writers.writePython3 "nextAppWin" { | ||
libraries = [ ]; | ||
flakeIgnore = [ "E501" ]; | ||
} (builtins.readFile ./next_app_win.py); | ||
searchWin = pkgs.writers.writePython3 "searchWin" { | ||
libraries = [ ]; | ||
flakeIgnore = [ "E501" ]; | ||
} (builtins.readFile ./search_win.py); | ||
in | ||
{ | ||
services.aerospace = { | ||
enable = true; | ||
settings = { | ||
enable-normalization-flatten-containers = false; | ||
enable-normalization-opposite-orientation-for-nested-containers = false; | ||
default-root-container-layout = "accordion"; | ||
exec = { | ||
inherit-env-vars = true; | ||
}; | ||
on-window-detected = [ | ||
# Termainal | ||
{ | ||
"if".app-id = "net.kovidgoyal.kitty"; | ||
run = [ "move-node-to-workspace 1" ]; | ||
} | ||
# Browsers | ||
{ | ||
"if".app-id = "org.mozilla.firefox"; | ||
run = [ "move-node-to-workspace 1" ]; | ||
} | ||
{ | ||
"if".app-id = "com.apple.mail"; | ||
run = [ "move-node-to-workspace 3" ]; | ||
} | ||
# Music | ||
{ | ||
"if".app-id = "com.apple.Music"; | ||
run = [ "move-node-to-workspace 4" ]; | ||
} | ||
# IMs | ||
{ | ||
"if".app-id = "ru.keepcoder.Telegram"; | ||
run = [ "move-node-to-workspace 2" ]; | ||
} | ||
{ | ||
"if".app-id = "com.hnc.Discord"; | ||
run = [ "move-node-to-workspace 2" ]; | ||
} | ||
{ | ||
"if".app-id = "com.tencent.xinWeChat"; | ||
run = [ "move-node-to-workspace 2" ]; | ||
} | ||
{ | ||
"if".app-id = "com.electron.lark"; | ||
run = [ "move-node-to-workspace 2" ]; | ||
} | ||
# Notes | ||
{ | ||
"if".app-id = "com.electron.logseq"; | ||
run = [ "move-node-to-workspace 5" ]; | ||
} | ||
]; | ||
mode.main.binding = { | ||
alt-s = "layout v_accordion"; # "layout stacking" in i3 | ||
alt-w = "layout h_accordion"; # "layout tabbed" in i3 | ||
alt-e = "layout tiles horizontal vertical"; # "layout toggle split" in i3 | ||
alt-shift-space = "layout floating tiling"; # 'floating toggle' in i3 | ||
|
||
alt-v = "split vertical"; | ||
alt-shift-v = "split horizontal"; | ||
|
||
alt-f = "fullscreen"; | ||
alt-shift-f = "macos-native-fullscreen"; | ||
alt-q = "close --quit-if-last-window"; | ||
|
||
alt-h = "focus left"; | ||
alt-j = "focus down"; | ||
alt-k = "focus up"; | ||
alt-l = "focus right"; | ||
alt-shift-h = "move left"; | ||
alt-shift-j = "move down"; | ||
alt-shift-k = "move up"; | ||
alt-shift-l = "move right"; | ||
|
||
alt-leftSquareBracket = "exec-and-forget ${nextAppWin} prev"; | ||
alt-rightSquareBracket = "exec-and-forget ${nextAppWin} next"; | ||
alt-p = "exec-and-forget ${searchWin}"; | ||
|
||
alt-1 = "workspace 1"; | ||
alt-2 = "workspace 2"; | ||
alt-3 = "workspace 3"; | ||
alt-4 = "workspace 4"; | ||
alt-5 = "workspace 5"; | ||
alt-shift-1 = "move-node-to-workspace 1"; | ||
alt-shift-2 = "move-node-to-workspace 2"; | ||
alt-shift-3 = "move-node-to-workspace 3"; | ||
alt-shift-4 = "move-node-to-workspace 4"; | ||
alt-shift-5 = "move-node-to-workspace 5"; | ||
|
||
alt-tab = "workspace-back-and-forth"; | ||
|
||
alt-b = "exec-and-forget open /Applications/Firefox.app"; | ||
alt-c = "exec-and-forget open ${pkgs.vscode}/Applications/Visual\\ Studio\\ Code.app"; | ||
alt-enter = "exec-and-forget open ${pkgs.kitty}/Applications/kitty.app"; | ||
alt-m = "exec-and-forget open /System/Applications/Music.app"; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import subprocess | ||
import sys | ||
import json | ||
|
||
|
||
def get_focused_window(): | ||
return json.loads( | ||
subprocess.check_output( | ||
["aerospace", "list-windows", "--focused", "--json"] | ||
).decode("utf-8") | ||
)[0] | ||
|
||
|
||
def get_all_windows_in_workspace(): | ||
return json.loads( | ||
subprocess.check_output( | ||
["aerospace", "list-windows", "--workspace", "focused", "--json"] | ||
).decode("utf-8") | ||
) | ||
|
||
|
||
def move_to_window(window_id): | ||
subprocess.run(["aerospace", "focus", "--window-id", str(window_id)]) | ||
|
||
|
||
if __name__ == "__main__": | ||
direction = 1 | ||
if sys.argv[1] == "prev": | ||
direction = -1 | ||
current_win = get_focused_window() | ||
all_win = get_all_windows_in_workspace() | ||
app_wins = list(filter(lambda w: w["app-name"] == current_win["app-name"], all_win)) | ||
next_idx = 0 | ||
for idx, win in enumerate(app_wins): | ||
if win["window-id"] == current_win["window-id"]: | ||
next_idx = (idx + direction) % len(app_wins) | ||
break | ||
move_to_window(app_wins[next_idx]["window-id"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import subprocess | ||
import json | ||
|
||
if __name__ == "__main__": | ||
wins = json.loads( | ||
subprocess.check_output( | ||
["aerospace", "list-windows", "--all", "--json"] | ||
).decode("utf-8") | ||
) | ||
output = "" | ||
for idx, win in enumerate(wins): | ||
output += f'{idx} | {win["app-name"]} {win['window-title']}\n' | ||
|
||
choose = subprocess.Popen(["choose"], stdin=subprocess.PIPE, stdout=subprocess.PIPE) | ||
|
||
selected, _ = choose.communicate(bytes(output, "utf-8")) | ||
selected_idx = int(selected.decode("utf-8").split("|")[0].strip()) | ||
subprocess.run( | ||
["aerospace", "focus", "--window-id", str(wins[selected_idx]["window-id"])] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
{ | ||
config, | ||
pkgs, | ||
hostName, | ||
... | ||
}: | ||
{ | ||
imports = [ | ||
./aerospace | ||
./homebrew | ||
./system | ||
]; | ||
|
||
sops.age.keyFile = "${config.admin.home}/.config/sops/age/keys.txt"; | ||
|
||
environment.variables = { | ||
SOPS_AGE_KEY_FILE = config.sops.age.keyFile; | ||
}; | ||
|
||
nixpkgs = { | ||
hostPlatform = "aarch64-darwin"; | ||
config = { | ||
allowUnfree = true; | ||
}; | ||
}; | ||
|
||
networking = { | ||
knownNetworkServices = [ | ||
"Wi-Fi" | ||
"Ethernet Adaptor" | ||
"Thunderbolt Ethernet" | ||
]; | ||
dns = [ | ||
"223.5.5.5" | ||
"114.114.114.114" | ||
"119.29.29.29" | ||
]; | ||
}; | ||
|
||
nix = { | ||
package = pkgs.nixVersions.nix_2_22; | ||
extraOptions = '' | ||
experimental-features = nix-command flakes | ||
keep-going = true | ||
download-attempts = 2 | ||
connect-timeout = 5 | ||
''; | ||
optimise = { | ||
automatic = true; | ||
}; | ||
gc = { | ||
automatic = true; | ||
options = "--delete-older-than 2d"; | ||
}; | ||
}; | ||
|
||
programs.zsh.enable = true; | ||
networking = { | ||
inherit hostName; | ||
computerName = hostName; | ||
}; | ||
|
||
users.users.${config.admin.name} = { | ||
inherit (config.admin) shell home; | ||
description = config.admin.name; | ||
openssh.authorizedKeys.keys = [ config.admin.sshPubKey ]; | ||
}; | ||
|
||
nix.settings.trusted-users = [ config.admin.name ]; | ||
|
||
services.sing-box = { | ||
enable = true; | ||
configPath = config.sops.secrets.sing-box.path; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
config, | ||
lib, | ||
... | ||
}: | ||
{ | ||
environment.systemPath = lib.optionals config.homebrew.enable [ | ||
config.homebrew.brewPrefix | ||
]; | ||
|
||
homebrew = { | ||
enable = true; | ||
caskArgs.no_quarantine = true; | ||
global.brewfile = true; | ||
masApps = { }; | ||
brews = [ | ||
"choose-gui" | ||
]; | ||
casks = [ | ||
"discord" | ||
"feishu" | ||
"firefox" | ||
"jetbrains-toolbox" | ||
"logi-options+" | ||
"logseq" | ||
"maccy" | ||
"sfm" | ||
"squirrel" | ||
"telegram" | ||
"wechat" | ||
]; | ||
}; | ||
} |
Oops, something went wrong.