flake: move packages to packages dir

This commit is contained in:
Charlie Root 2025-03-03 15:43:20 +01:00
commit a3edf577dc
Signed by: faukah
SSH key fingerprint: SHA256:jpYIt4Vkz1NBTQcks/N9OPTfTFxE6KF2W/rV7hrfrIw
14 changed files with 22 additions and 21 deletions

7
packages/default.nix Normal file
View file

@ -0,0 +1,7 @@
pkgs: let
helix = pkgs.callPackage ./helix.nix {};
kakoune = null;
fish = pkgs.callPackage ./shell {};
in {
inherit helix kakoune fish;
}

301
packages/helix.nix Normal file
View file

@ -0,0 +1,301 @@
{
symlinkJoin,
makeWrapper,
helix,
alejandra,
bash-language-server,
black,
clang-tools,
cmake-format,
cmake-language-server,
deno,
dprint,
formats,
gdb,
lazygit,
lib,
lldb_19,
marksman,
nil,
pyright,
rust-analyzer,
shellcheck,
shfmt,
stdenv,
solargraph,
tinymist,
typescript-language-server,
...
}: let
inherit (lib) getExe;
toml = formats.toml {};
helix-config = {
theme = "catppuccin_mocha";
editor = {
cursorline = false;
color-modes = true;
indent-guides.render = true;
lsp = {
enable = true;
auto-signature-help = true;
display-inlay-hints = true;
display-messages = true;
snippets = true;
};
line-number = "relative";
true-color = true;
auto-format = true;
completion-timeout = 5;
mouse = true;
bufferline = "multiple";
soft-wrap.enable = true;
cursor-shape = {
insert = "bar";
normal = "block";
select = "underline";
};
statusline = {
left = ["spinner" "version-control" "diagnostics" "file-name"];
right = ["file-base-name" "file-type" "position" "file-encoding"];
};
gutters.layout = ["diff" "diagnostics" "line-numbers" "spacer"];
inline-diagnostics = {
cursor-line = "hint";
other-lines = "error";
};
};
keys = {
normal = {
space.g = [":new" ":insert-output XDG_CONFIG_HOME=~/.config ${getExe lazygit}" ":buffer-close!" ":redraw"];
esc = ["collapse_selection" "keep_primary_selection" "normal_mode"];
A-H = "goto_previous_buffer";
A-L = "goto_next_buffer";
A-w = ":buffer-close";
A-f = ":format";
A-r = ":reload";
A-x = "extend_to_line_bounds";
X = ["extend_line_up" "extend_to_line_bounds"];
};
select = {
A-x = "extend_to_line_bounds";
X = ["extend_line_up" "extend_to_line_bounds"];
};
};
};
helix-languages = {
language = let
extraFormatter = lang: {
command = getExe deno;
args = ["fmt" "-" "--ext" lang];
};
in [
{
name = "bash";
auto-format = true;
formatter = {
command = getExe shfmt;
args = ["-i" "2"];
};
}
{
name = "clojure";
injection-regex = "(clojure|clj|edn|boot|yuck)";
file-types = ["clj" "cljs" "cljc" "clje" "cljr" "cljx" "edn" "boot" "yuck"];
}
{
name = "cmake";
auto-format = true;
language-servers = ["cmake-language-server"];
formatter = {
command = getExe cmake-format;
args = ["-"];
};
}
{
name = "javascript";
auto-format = true;
language-servers = ["dprint" "typescript-language-server"];
}
{
name = "json";
formatter = extraFormatter "json";
}
{
name = "markdown";
auto-format = true;
formatter = extraFormatter "md";
}
{
name = "python";
language-servers = ["pyright"];
formatter = {
command = getExe black;
args = ["-" "--quiet" "--line-length 100"];
};
}
{
name = "typescript";
auto-format = true;
language-servers = ["dprint" "typescript-language-server"];
}
{
name = "rust";
debugger = {
command = "${lldb_19}/bin/lldb-dap";
name = "lldb";
transport = "stdio";
templates = [
{
name = "binary";
request = "launch";
completion = [
{
name = "binary";
completion = "filename";
}
];
args = {
program = "{0}";
runInTerminal = true;
};
}
];
};
}
{
name = "c";
auto-format = true;
language-servers = ["clangd"];
}
{
name = "c";
debugger = {
name = "gdb";
command = getExe gdb;
transport = "stdio";
templates = [
{
name = "binary";
request = "launch";
completion = [
{
name = "binary";
completion = "filename";
}
];
args = {
program = "{0}";
runInTerminal = true;
};
}
];
};
}
];
language-server = {
bash-language-server = {
command = getExe bash-language-server;
args = ["start"];
};
clangd = {
command = "${clang-tools}/bin/clangd";
clangd.fallbackFlags = ["-std=c++2b"];
};
cmake-language-server = {
command = getExe cmake-language-server;
};
dprint = {
command = getExe dprint;
args = ["lsp"];
};
nil = {
command = getExe nil;
# alejandro
config.nil.formatting.command = ["${getExe alejandra}" "-q"];
};
pyright = {
command = "${pyright}/bin/pyright-langserver";
args = ["--stdio"];
config = {
reportMissingTypeStubs = false;
analysis = {
typeCheckingMode = "basic";
autoImportCompletions = true;
};
};
};
typescript-language-server = {
command = getExe typescript-language-server;
args = ["--stdio"];
config = let
inlayHints = {
includeInlayEnumMemberValueHints = true;
includeInlayFunctionLikeReturnTypeHints = true;
includeInlayFunctionParameterTypeHints = true;
includeInlayParameterNameHints = "all";
includeInlayParameterNameHintsWhenArgumentMatchesName = true;
includeInlayPropertyDeclarationTypeHints = true;
includeInlayVariableTypeHints = true;
};
in {
typescript-language-server.source = {
addMissingImports.ts = true;
fixAll.ts = true;
organizeImports.ts = true;
removeUnusedImports.ts = true;
sortImports.ts = true;
};
typescript = {inherit inlayHints;};
javascript = {inherit inlayHints;};
hostInfo = "helix";
};
};
};
};
wrapped-helix = symlinkJoin {
name = "helix-wrapped";
paths = [
helix
rust-analyzer
# typst lsp
tinymist
# C/C++
clang-tools
# Markdown
marksman
# Nix
nil
lldb_19
# Bash
bash-language-server
# Shell
shellcheck
# ruby
solargraph
];
buildInputs = [makeWrapper];
postBuild = ''
mkdir -p $out/config/helix
cp "${toml.generate "config.toml" helix-config}" $out/config/helix/config.toml
cp "${toml.generate "languages.toml" helix-languages}" $out/config/helix/languages.toml
wrapProgram $out/bin/hx --set \
XDG_CONFIG_HOME $out/config
'';
};
in
wrapped-helix

65
packages/kakoune.nix Normal file
View file

@ -0,0 +1,65 @@
{
fetchFromGitHub,
makeWrapper,
stdenv,
symlinkJoin,
kakounePlugins,
...
}: let
custom-kakoune = stdenv.mkDerivation {
name = "custom-kakoune";
src = fetchFromGitHub {
owner = "mawww";
repo = "kakoune";
rev = "be82047dbf5f74f123e925b96e0e13962a4e0c09";
hash = "sha256-akSmIe0SUe9re8a90ssrykowCzThZnzqVow9erT+0U4=";
};
makeFlags = ["debug=no" "PREFIX=${placeholder "out"}"];
enableParallellBuilding = true;
doInstallCheck = false;
installCheckPhase = ''
$out/bin/kak -ui json -e "kill 0"
'';
postInstall = ''
cd "$out/share/kak"
autoload_target=$(readlink autoload)
rm autoload
mkdir autoload
ln -s --relative "$autoload_target" autoload
'';
};
plugins = builtins.attrValues {
inherit (kakounePlugins) fzf-kak kakoune-catppuccin;
};
kakoune-wrapped = symlinkJoin {
name = "kakoune-wrapped";
nativeBuildInputs = [makeWrapper];
paths = [custom-kakoune] ++ plugins;
postBuild = ''
# create a directory for bins that kakoune needs
# access to, without polluting the users path by adding
# that binary nested with this symlinkJoin.
mkdir -p $out/share/kak/bin
# location of kak binary is used to find ../share/kak/autoload,
# unless explicitly overriden with KAKOUNE_RUNTIME
rm "$out/bin/kak"
makeWrapper "${custom-kakoune}/bin/kak" "$out/bin/kak" \
--set KAKOUNE_RUNTIME "$out/share/kak" \
--suffix PATH : "$out/share/kak/bin"
# currently kakoune ignores doc files if they are symlinks, so workaround by
# copying doc files over, so they become regular files...
mkdir "$out/DELETE_ME"
mv "$out/share/kak/doc" "$out/DELETE_ME"
cp -r --dereference "$out/DELETE_ME/doc" "$out/share/kak"
rm -Rf "$out/DELETE_ME"
'';
};
in
kakoune-wrapped

View file

@ -0,0 +1,24 @@
{pkgs, ...}: let
inherit (pkgs.lib) getExe;
in {
ls = "${getExe pkgs.eza} --icons";
la = "${getExe pkgs.eza} --icons -lha --git";
g = "git";
n = "nix";
k = "kak";
c = "clear";
cc = "cd ~ && clear";
mv = "mv -iv";
rm = "${pkgs.trash-cli}/bin/trash";
lg = "${getExe pkgs.lazygit}";
ytopus = "yt-dlp -x --embed-metadata --audio-quality 0 --audio-format opus --embed-metadata --embed-thumbnail";
cat = "${getExe pkgs.bat} --plain";
kys = "shutdown now";
cd = "z";
}

View file

@ -0,0 +1 @@
set fish_greeting

View file

@ -0,0 +1,38 @@
# This shell setup was inspired by sioodmy. Check out his setup!
{pkgs, ...}: let
toml = pkgs.formats.toml {};
starship-config = import ./starship.nix;
aliases = import ./aliases.nix {inherit pkgs;};
fishinit = import ./fishinit.nix {inherit pkgs aliasesStr;};
aliasesStr =
pkgs.lib.concatStringsSep "\n"
(pkgs.lib.mapAttrsToList (k: v: "alias ${k}=\"${v}\"") aliases);
packages = import ./packages.nix pkgs;
# this was taken from viperml, check out his config for this!
custom-fish = pkgs.fish.overrideAttrs (old: {
patches = [./fish-on-tmpfs.patch];
doCheck = false;
postInstall =
old.postInstall
+ ''
echo "source ${fishinit}" >> $out/etc/fish/config.fish
'';
});
in
(pkgs.symlinkJoin {
name = "fish-wrapped";
paths = [custom-fish] ++ packages;
buildInputs = [pkgs.makeWrapper];
postBuild = ''
wrapProgram $out/bin/fish --set STARSHIP_CONFIG "${toml.generate "starship.toml" starship-config}" \
--set SSH_AUTH_SOCK /run/user/1000/ssh-agent \
'';
})
.overrideAttrs (_: {
passthru = {
shellPath = "/bin/fish";
};
})

View file

@ -0,0 +1,10 @@
--- a/src/path.cpp
+++ b/src/path.cpp
@@ -384,7 +384,7 @@ static const base_directory_t &get_data_directory() {
}
static const base_directory_t &get_config_directory() {
- static base_directory_t s_dir = make_base_directory(L"XDG_CONFIG_HOME", L"/.config/fish");
+ static base_directory_t s_dir = make_base_directory(L"XDG_RUNTIME_DIR", L"/.config/fish");
return s_dir;
}

View file

@ -0,0 +1,19 @@
{
pkgs,
aliasesStr,
}:
pkgs.writeText "config.fish" ''
# source ${pkgs.fishPlugins.sponge}/share/zsh-defer/zsh-defer.plugin.zsh
${pkgs.atuin}/bin/atuin init fish | source
${pkgs.zoxide}/bin/zoxide init fish | source
${pkgs.starship}/bin/starship init fish | source
${pkgs.direnv}/bin/direnv hook fish | source
${pkgs.pay-respects}/bin/pay-respects fish --alias f --nocnf | source
source ${./config.fish}
${aliasesStr}
''

View file

@ -0,0 +1,65 @@
pkgs:
builtins.attrValues {
inherit
(pkgs)
# better cd
zoxide
#better ls
eza
atuin
# better cat
bat
# clipboard
# yazi
serpl
diff-so-fancy
tig
direnv
sesh
mprocs
curlie
entr
procs
sd
# mult
glow
# dua-cli
dust
kondo
# better grep
ripgrep
# better dig
dogdns
# simply the best fetch tool out there
microfetch
fzf
element
carapace
difftastic
hexyl
iputils
gnumake
gping
asciinema
inetutils
scc
starship
onefetch
wget
cpufetch
yt-dlp
tealdeer
hyperfine
imagemagick
ffmpeg-full
# catimg
timg
nmap
fd
jq
rsync
figlet
unzip
zip
;
}

View file

@ -0,0 +1,60 @@
{
add_newline = false;
command_timeout = 2000;
# format = "$hostname$username$directory$shell$nix_shell$git_branch$git_commit$git_state$git_status$jobs$cmd_duration\n$character";
scan_timeout = 2;
character = {
error_symbol = "[](bold red)";
format = "$symbol [|](bold bright-black) ";
success_symbol = "[](bold green)";
vicmd_symbol = "[](bold yellow)";
};
directory = {
format = "[ ](bold green) [$path]($style) ";
truncation_length = 2;
};
git_branch = {
style = "bold purple";
};
git_commit.commit_hash_length = 7;
git_status = {
ahead = " ";
behind = " ";
conflicted = " ";
deleted = " ";
diverged = " ";
modified = "!";
renamed = "»";
staged = "+";
stashed = "";
style = "red";
untracked = "?";
};
hostname = {
disabled = false;
format = "@[$hostname](bold blue) ";
ssh_only = true;
};
line_break.disabled = false;
c.symbol = "[ ](black)";
lua.symbol = "[ ](blue) ";
golang.symbol = "[󰟓 ](blue)";
nix_shell.symbol = "[󱄅 ](blue) ";
nodejs.symbol = "[󰎙 ](yellow)";
package.symbol = "📦 ";
python.symbol = "[ ](blue) ";
rust.symbol = "[ ](red) ";
username.format = "[$user]($style) in ";
}