Add go devshell

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2025-01-06 13:44:43 +02:00
parent 249c089718
commit 31f3364f06
14 changed files with 111 additions and 34 deletions

View File

@@ -102,6 +102,7 @@
{
devShells = {
bun = import ./hosts/common/shells/bun { inherit pkgs; };
go = import ./hosts/common/shells/go { inherit pkgs; };
nix = import ./hosts/common/shells/nix { inherit pkgs; };
nodejs = import ./hosts/common/shells/nodejs { inherit pkgs; };
python = import ./hosts/common/shells/python { inherit pkgs; };

View File

@@ -10,11 +10,6 @@
kubectl
];
programs.zsh.initExtra = ''
export P10K_EXTRA_RIGHT_PROMPT_ELEMENTS=(
kubecontext
"''${P10K_EXTRA_RIGHT_PROMPT_ELEMENTS[@]}"
)
'';
programs.zsh.p10k.extraRightPromptElements = [ "kubecontext" ];
};
}

View File

@@ -4,7 +4,8 @@
}:
{ ... }:
{
home-manager.users.${user}.programs.neovim = {
home-manager.users.${user}.programs = {
neovim = {
enable = true;
defaultEditor = true;
viAlias = true;
@@ -17,4 +18,7 @@
set smartindent
'';
};
zsh.p10k.extraRightPromptElements = [ "vim_shell" ];
};
}

View File

@@ -19,14 +19,24 @@
initExtra = ''
nix-direnv() {
if [ -z "$1" ]; then
echo "Usage: nix-direnv <shell>"
return 1
echo "use flake" > .envrc
else
echo "use flake self#$1" > .envrc
fi
if git rev-parse --is-inside-work-tree &> /dev/null && ! grep -q "^\.envrc$" .gitignore .git/info/exclude; then
echo "Do you want to hide the .envrc file from git? (y/N)"
read -r answer
if [[ "$answer" =~ ^[Yy]$ ]]; then
echo ".envrc" >> .git/info/exclude
fi
fi
echo "use $1" > .envrc
direnv allow
}
'';
p10k.extraRightPromptElements = [ "direnv" ];
};
};

View File

@@ -6,7 +6,8 @@
{
environment.persistence."/cache"."${home}/.cache/ranger" = { };
home-manager.users.${user}.programs.ranger = {
home-manager.users.${user}.programs = {
ranger = {
enable = true;
settings = {
@@ -14,4 +15,7 @@
preview_images_method = "kitty";
};
};
zsh.p10k.extraRightPromptElements = [ "ranger" ];
};
}

View File

@@ -22,9 +22,6 @@
status
command_execution_time
background_jobs
direnv
ranger
vim_shell
nix_shell
per_directory_history
"${P10K_EXTRA_RIGHT_PROMPT_ELEMENTS[@]}"
@@ -228,6 +225,12 @@
typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_FOREGROUND=134
typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION='${P9K_KUBECONTEXT_CLOUD_CLUSTER:-${P9K_KUBECONTEXT_NAME}}${${:-/$P9K_KUBECONTEXT_NAMESPACE}:#/default}'
################[ goenv: go environment (https://github.com/syndbg/goenv) ]################
typeset -g POWERLEVEL9K_GOENV_FOREGROUND=37
typeset -g POWERLEVEL9K_GOENV_SOURCES=(shell local global)
typeset -g POWERLEVEL9K_GOENV_PROMPT_ALWAYS_SHOW=true
typeset -g POWERLEVEL9K_GOENV_SHOW_SYSTEM=true
##################################[ context: user@hostname ]##################################
typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=178
typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_FOREGROUND=180

View File

@@ -10,6 +10,8 @@
};
home-manager.users.${user} = {
imports = [ ./options.nix ];
programs.zsh = {
enable = true;
dotDir = ".config/zsh";

View File

@@ -0,0 +1,25 @@
{ config, lib, ... }:
let
cfg = config.programs.zsh;
in
{
options.programs.zsh =
with lib;
with types;
{
p10k.extraRightPromptElements = mkOption {
type = listOf str;
default = [ ];
description = "Extra elements to display on the right side of the prompt.";
};
};
config.programs.zsh =
with lib;
with cfg;
{
initExtra = ''
export P10K_EXTRA_RIGHT_PROMPT_ELEMENTS=(${strings.concatStringsSep " " cfg.p10k.extraRightPromptElements})
'';
};
}

View File

@@ -116,6 +116,7 @@ in
imports = [
./langs/c
./langs/go
./langs/lua
./langs/nix
./langs/python

View File

@@ -0,0 +1,9 @@
{ pkgs, ... }:
{
programs.vscode.extensions =
with pkgs;
with vscode-extensions;
[
golang.go
];
}

View File

@@ -0,0 +1,22 @@
{ pkgs, ... }:
pkgs.mkShell {
packages = with pkgs; [
go
gopls
go-tools
];
shellHook = ''
export P10K_EXTRA_RIGHT_PROMPT_ELEMENTS=(
goenv
"''${P10K_EXTRA_RIGHT_PROMPT_ELEMENTS[@]}"
)
if git rev-parse --is-inside-work-tree &> /dev/null && ! grep -q "^\.go$" .gitignore .git/info/exclude; then
echo ".go" >> .git/info/exclude
export GOPATH="$(git rev-parse --show-toplevel)/.go"
else
export GOPATH="$(pwd)/.go"
fi
'';
}

View File

@@ -125,7 +125,7 @@ in
hostname = "github.com";
user = "git";
identityFile = "${home}/.ssh/ssh_git_personal_ed25519_key";
extraOptions.StrictHostKeyChecking = "accept-new";
extraOptions.StrictHostKeyChecking = "no";
};
};

View File

@@ -144,7 +144,7 @@ in
hostname = "github.com";
user = "git";
identityFile = "${home}/.ssh/ssh_git_personal_ed25519_key";
extraOptions.StrictHostKeyChecking = "accept-new";
extraOptions.StrictHostKeyChecking = "no";
};
# SAS
@@ -152,13 +152,14 @@ in
hostname = "github.com";
user = "git";
identityFile = "${home}/.ssh/ssh_git_sas_ed25519_key";
extraOptions.StrictHostKeyChecking = "accept-new";
extraOptions.StrictHostKeyChecking = "no";
};
"gitlab.sas.com" = {
hostname = "gitlab.sas.com";
user = "git";
identityFile = "${home}/.ssh/ssh_git_sas_ed25519_key";
extraOptions.StrictHostKeyChecking = "accept-new";
extraOptions.StrictHostKeyChecking = "no";
};
};

View File

@@ -81,7 +81,7 @@ in
hostname = "github.com";
user = "git";
identityFile = "${home}/.ssh/ssh_git_personal_ed25519_key";
extraOptions.StrictHostKeyChecking = "accept-new";
extraOptions.StrictHostKeyChecking = "no";
};
};
};