From 4a988dbce79997367e745498380c1456e55c752f Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Thu, 3 Aug 2023 23:16:12 +0800 Subject: [PATCH] refactor: development environment --- flake.lock | 34 ++++++++++++ flake.nix | 8 +++ home/base/desktop/cloud/default.nix | 22 ++++++++ home/base/desktop/container/container.nix | 14 +++++ home/base/desktop/container/default.nix | 6 +++ home/base/desktop/container/kubernetes.nix | 31 +++++++++++ home/base/desktop/default.nix | 5 +- home/base/desktop/development.nix | 18 ------- .../base/desktop/{ => terminal}/alacritty.nix | 0 home/base/desktop/terminal/default.nix | 7 +++ home/base/desktop/{ => terminal}/kitty.nix | 5 +- home/base/desktop/terminal/wezterm.nix | 52 +++++++++++++++++++ home/base/server/core.nix | 1 + 13 files changed, 182 insertions(+), 21 deletions(-) create mode 100644 home/base/desktop/cloud/default.nix create mode 100644 home/base/desktop/container/container.nix create mode 100644 home/base/desktop/container/default.nix create mode 100644 home/base/desktop/container/kubernetes.nix rename home/base/desktop/{ => terminal}/alacritty.nix (100%) create mode 100644 home/base/desktop/terminal/default.nix rename home/base/desktop/{ => terminal}/kitty.nix (89%) create mode 100644 home/base/desktop/terminal/wezterm.nix diff --git a/flake.lock b/flake.lock index 536fb8a3..88fc0b5a 100644 --- a/flake.lock +++ b/flake.lock @@ -187,6 +187,38 @@ "type": "github" } }, + "catppuccin-wezterm": { + "flake": false, + "locked": { + "lastModified": 1681259790, + "narHash": "sha256-McSWoZaJeK+oqdK/0vjiRxZGuLBpEB10Zg4+7p5dIGY=", + "owner": "catppuccin", + "repo": "wezterm", + "rev": "b1a81bae74d66eaae16457f2d8f151b5bd4fe5da", + "type": "github" + }, + "original": { + "owner": "catppuccin", + "repo": "wezterm", + "type": "github" + } + }, + "cattppuccin-k9s": { + "flake": false, + "locked": { + "lastModified": 1690140445, + "narHash": "sha256-PtBJRBNbLkj7D2ko7ebpEjbfK9Ywjs7zbE+Y8FQVEfA=", + "owner": "catppuccin", + "repo": "k9s", + "rev": "516f44dd1a6680357cb30d96f7e656b653aa5059", + "type": "github" + }, + "original": { + "owner": "catppuccin", + "repo": "k9s", + "type": "github" + } + }, "darwin": { "inputs": { "nixpkgs": [ @@ -659,6 +691,8 @@ "catppuccin-helix": "catppuccin-helix", "catppuccin-hyprland": "catppuccin-hyprland", "catppuccin-starship": "catppuccin-starship", + "catppuccin-wezterm": "catppuccin-wezterm", + "cattppuccin-k9s": "cattppuccin-k9s", "home-manager": "home-manager_2", "hyprland": "hyprland", "mysecrets": "mysecrets", diff --git a/flake.nix b/flake.nix index 06dcb892..fb700847 100644 --- a/flake.nix +++ b/flake.nix @@ -247,6 +247,10 @@ url = "github:catppuccin/alacritty"; flake = false; }; + catppuccin-wezterm = { + url = "github:catppuccin/wezterm"; + flake = false; + }; catppuccin-helix = { url = "github:catppuccin/helix"; flake = false; @@ -263,6 +267,10 @@ url = "github:catppuccin/cava"; flake = false; }; + cattppuccin-k9s = { + url = "github:catppuccin/k9s"; + flake = false; + }; }; diff --git a/home/base/desktop/cloud/default.nix b/home/base/desktop/cloud/default.nix new file mode 100644 index 00000000..2e8be6d4 --- /dev/null +++ b/home/base/desktop/cloud/default.nix @@ -0,0 +1,22 @@ +{ + pkgs, + pkgs-unstable, + ... +}: { + home.packages = with pkgs; [ + # general tools + terraform + # terraformer # generate terraform configs from existing cloud resources + pulumi + pulumictl + # istioctl + + # aws + awscli2 + aws-iam-authenticator + eksctl + ]; + + programs = { + }; +} diff --git a/home/base/desktop/container/container.nix b/home/base/desktop/container/container.nix new file mode 100644 index 00000000..717cfee8 --- /dev/null +++ b/home/base/desktop/container/container.nix @@ -0,0 +1,14 @@ +{ + pkgs, + pkgs-unstable, + ... +}: { + home.packages = with pkgs; [ + skopeo + docker-compose + dive # explore docker layers + ]; + + programs = { + }; +} diff --git a/home/base/desktop/container/default.nix b/home/base/desktop/container/default.nix new file mode 100644 index 00000000..1425f7e4 --- /dev/null +++ b/home/base/desktop/container/default.nix @@ -0,0 +1,6 @@ +{ ... }: { + imports = [ + ./container.nix + ./kubernetes.nix + ]; +} diff --git a/home/base/desktop/container/kubernetes.nix b/home/base/desktop/container/kubernetes.nix new file mode 100644 index 00000000..1a922379 --- /dev/null +++ b/home/base/desktop/container/kubernetes.nix @@ -0,0 +1,31 @@ +{ + pkgs, + pkgs-unstable, + cattppuccin-k9s, + ... +}: { + home.packages = with pkgs; [ + kubectl + kubernetes-helm + ]; + + programs = { + k9s = { + enable = true; + skin = + let + skin_file = "${cattppuccin-k9s}/dist/mocha.yml"; # theme - cattppuccin mocha + skin_attr = builtins.fromJSON (builtins.readFile + # replace 'base: &base "#1e1e2e"' with 'base: &base "default"' + # to make fg/bg color transparent + (pkgs.runCommandNoCC "get-skin-json" {} '' + cat ${skin_file} \ + | sed -E 's@(base: &base ).+@\1 "default"@g' \ + | ${pkgs.yj}/bin/yj > $out + '') + ); + in + skin_attr; + }; + }; +} diff --git a/home/base/desktop/default.nix b/home/base/desktop/default.nix index 5788be3c..1c360188 100644 --- a/home/base/desktop/default.nix +++ b/home/base/desktop/default.nix @@ -2,12 +2,13 @@ imports = [ ../server + ./cloud + ./container ./neovim + ./terminal - ./alacritty.nix ./development.nix ./helix.nix - ./kitty.nix ./media.nix ./shell.nix ]; diff --git a/home/base/desktop/development.nix b/home/base/desktop/development.nix index 8f597ad0..082b0783 100644 --- a/home/base/desktop/development.nix +++ b/home/base/desktop/development.nix @@ -16,24 +16,6 @@ home.packages = with pkgs; [ pkgs-unstable.devbox - # cloud native - skopeo - docker-compose - dive # explore docker layers - kubectl - kubernetes-helm - terraform - # terraformer # generate terraform configs from existing cloud resources - pulumi - pulumictl - k9s - # istioctl - - # cloud provider - awscli2 - aws-iam-authenticator - eksctl - # DO NOT install build tools for C/C++ and others, set it per project by devShell instead gnumake # used by this repo, to simplify the deployment jdk17 # used to run some java based tools(.jar) diff --git a/home/base/desktop/alacritty.nix b/home/base/desktop/terminal/alacritty.nix similarity index 100% rename from home/base/desktop/alacritty.nix rename to home/base/desktop/terminal/alacritty.nix diff --git a/home/base/desktop/terminal/default.nix b/home/base/desktop/terminal/default.nix new file mode 100644 index 00000000..a69bc60a --- /dev/null +++ b/home/base/desktop/terminal/default.nix @@ -0,0 +1,7 @@ +{...}: { + imports = [ + ./alacritty.nix + ./kitty.nix + ./wezterm.nix + ]; +} diff --git a/home/base/desktop/kitty.nix b/home/base/desktop/terminal/kitty.nix similarity index 89% rename from home/base/desktop/kitty.nix rename to home/base/desktop/terminal/kitty.nix index 155af489..f105ec90 100644 --- a/home/base/desktop/kitty.nix +++ b/home/base/desktop/terminal/kitty.nix @@ -30,7 +30,10 @@ { programs.kitty = { enable = true; - theme = "Catppuccin-Mocha"; # kitty has catppuccin theme built-in + # kitty has catppuccin theme built-in, + # all the built-in themes are packaged into an extra package named `kitty-themes` + # and it's installed by home-manager if `theme` is specified. + theme = "Catppuccin-Mocha"; font = { name = "JetBrainsMono Nerd Font"; # use different font size on macOS diff --git a/home/base/desktop/terminal/wezterm.nix b/home/base/desktop/terminal/wezterm.nix new file mode 100644 index 00000000..c3fcdb9a --- /dev/null +++ b/home/base/desktop/terminal/wezterm.nix @@ -0,0 +1,52 @@ +{ + lib, + pkgs, + catppuccin-wezterm, + ... +}: +########################################################### +# +# Wezterm Configuration +# +########################################################### +{ + # wezterm has catppuccin theme built-in, + # it's not necessary to install it separately. + # xdg.configFile."wezterm/colors".source = "${catppuccin-wezterm}/dist"; + + programs.wezterm = { + enable = true; + + extraConfig = + let + fontsize = if pkgs.stdenv.isDarwin then "14.0" else "13.0"; + in + '' + -- Pull in the wezterm API + local wezterm = require 'wezterm' + + -- This table will hold the configuration. + local config = {} + + -- In newer versions of wezterm, use the config_builder which will + -- help provide clearer error messages + if wezterm.config_builder then + config = wezterm.config_builder() + end + + -- This is where you actually apply your config choices + config.color_scheme = "Catppuccin Mocha" + config.font = wezterm.font("JetBrains Mono") + config.hide_tab_bar_if_only_one_tab = true + config.scrollback_lines = 10000 + config.enable_scroll_bar = true + + config.font_size = ${fontsize} + '' + (if pkgs.stdenv.isDarwin then '' + -- Spawn a fish shell in login mod + config.default_prog = { '/run/current-system/sw/bin/nu', '-l' } + '' else "") + '' + return config + ''; + }; +} diff --git a/home/base/server/core.nix b/home/base/server/core.nix index d080da00..66951b57 100644 --- a/home/base/server/core.nix +++ b/home/base/server/core.nix @@ -25,6 +25,7 @@ ipcalc # it is a calculator for the IPv4/v6 addresses # misc + tldr cowsay file which