add ghostty

This commit is contained in:
EdenQwQ 2025-07-18 19:47:09 +08:00
parent 9c8fedd831
commit c6bf1d959a
8 changed files with 402 additions and 50 deletions

208
flake.lock generated
View file

@ -143,6 +143,22 @@
}
},
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1747046372,
"narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-compat_3": {
"locked": {
"lastModified": 1746162366,
"narHash": "sha256-5SSSZ/oQkwfcAz/o/6TlejlVGqeK08wyREBQ5qFFPhM=",
@ -157,7 +173,7 @@
"type": "github"
}
},
"flake-compat_3": {
"flake-compat_4": {
"locked": {
"lastModified": 1747046372,
"narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=",
@ -358,6 +374,24 @@
"type": "github"
}
},
"flake-utils_3": {
"inputs": {
"systems": "systems_4"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"fromYaml": {
"flake": false,
"locked": {
@ -374,6 +408,28 @@
"type": "github"
}
},
"ghostty": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_2",
"zig": "zig",
"zon2nix": "zon2nix"
},
"locked": {
"lastModified": 1752747307,
"narHash": "sha256-Dxj78MePYfHnC5IROGJmThXGa6QY8C6iQi8lnzgewkw=",
"owner": "ghostty-org",
"repo": "ghostty",
"rev": "0d61b94c10147691851df37b6ee57d09745b1437",
"type": "github"
},
"original": {
"owner": "ghostty-org",
"repo": "ghostty",
"type": "github"
}
},
"git-hooks": {
"inputs": {
"flake-compat": [
@ -532,7 +588,7 @@
},
"lib-aggregate": {
"inputs": {
"flake-utils": "flake-utils",
"flake-utils": "flake-utils_2",
"nixpkgs-lib": "nixpkgs-lib_5"
},
"locked": {
@ -553,7 +609,7 @@
"inputs": {
"flake-parts": "flake-parts_2",
"mmsg": "mmsg",
"nixpkgs": "nixpkgs_2",
"nixpkgs": "nixpkgs_3",
"scenefx": "scenefx"
},
"locked": {
@ -594,7 +650,7 @@
},
"nh": {
"inputs": {
"nixpkgs": "nixpkgs_3"
"nixpkgs": "nixpkgs_4"
},
"locked": {
"lastModified": 1750610317,
@ -636,7 +692,7 @@
"niri-unstable": [
"niri-unstable"
],
"nixpkgs": "nixpkgs_4",
"nixpkgs": "nixpkgs_5",
"nixpkgs-stable": "nixpkgs-stable",
"xwayland-satellite-stable": "xwayland-satellite-stable",
"xwayland-satellite-unstable": "xwayland-satellite-unstable"
@ -690,7 +746,7 @@
},
"nix-matlab": {
"inputs": {
"flake-compat": "flake-compat",
"flake-compat": "flake-compat_2",
"nixpkgs": [
"nixpkgs"
]
@ -854,9 +910,9 @@
},
"nixpkgs-wayland": {
"inputs": {
"flake-compat": "flake-compat_2",
"flake-compat": "flake-compat_3",
"lib-aggregate": "lib-aggregate",
"nixpkgs": "nixpkgs_6"
"nixpkgs": "nixpkgs_7"
},
"locked": {
"lastModified": 1750992987,
@ -873,6 +929,19 @@
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1748189127,
"narHash": "sha256-zRDR+EbbeObu4V2X5QCd2Bk5eltfDlCr5yvhBwUT6pY=",
"rev": "7c43f080a7f28b2774f3b3f43234ca11661bf334",
"type": "tarball",
"url": "https://releases.nixos.org/nixos/25.05/nixos-25.05.802491.7c43f080a7f2/nixexprs.tar.xz"
},
"original": {
"type": "tarball",
"url": "https://channels.nixos.org/nixos-25.05/nixexprs.tar.xz"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1750386251,
"narHash": "sha256-1ovgdmuDYVo5OUC5NzdF+V4zx2uT8RtsgZahxidBTyw=",
@ -888,7 +957,7 @@
"type": "github"
}
},
"nixpkgs_3": {
"nixpkgs_4": {
"locked": {
"lastModified": 1748302896,
"narHash": "sha256-ixMT0a8mM091vSswlTORZj93WQAJsRNmEvqLL+qwTFM=",
@ -904,7 +973,7 @@
"type": "github"
}
},
"nixpkgs_4": {
"nixpkgs_5": {
"locked": {
"lastModified": 1750776420,
"narHash": "sha256-/CG+w0o0oJ5itVklOoLbdn2dGB0wbZVOoDm4np6w09A=",
@ -920,7 +989,7 @@
"type": "github"
}
},
"nixpkgs_5": {
"nixpkgs_6": {
"locked": {
"lastModified": 1751289723,
"narHash": "sha256-m8IS+7tq5YjRo6Ts1n9sxPKFKfW86AHtdrudJuuqfOw=",
@ -936,22 +1005,6 @@
"type": "github"
}
},
"nixpkgs_6": {
"locked": {
"lastModified": 1750776420,
"narHash": "sha256-/CG+w0o0oJ5itVklOoLbdn2dGB0wbZVOoDm4np6w09A=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "30a61f056ac492e3b7cdcb69c1e6abdcf00e39cf",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_7": {
"locked": {
"lastModified": 1750776420,
@ -969,6 +1022,22 @@
}
},
"nixpkgs_8": {
"locked": {
"lastModified": 1750776420,
"narHash": "sha256-/CG+w0o0oJ5itVklOoLbdn2dGB0wbZVOoDm4np6w09A=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "30a61f056ac492e3b7cdcb69c1e6abdcf00e39cf",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_9": {
"locked": {
"lastModified": 1747958103,
"narHash": "sha256-qmmFCrfBwSHoWw7cVK4Aj+fns+c54EBP8cGqp/yK410=",
@ -991,7 +1060,7 @@
"nixpkgs"
],
"nuschtosSearch": "nuschtosSearch",
"systems": "systems_4"
"systems": "systems_5"
},
"locked": {
"lastModified": 1750879244,
@ -1010,7 +1079,7 @@
"nur": {
"inputs": {
"flake-parts": "flake-parts_6",
"nixpkgs": "nixpkgs_7",
"nixpkgs": "nixpkgs_8",
"treefmt-nix": "treefmt-nix_2"
},
"locked": {
@ -1055,7 +1124,7 @@
},
"nuschtosSearch": {
"inputs": {
"flake-utils": "flake-utils_2",
"flake-utils": "flake-utils_3",
"ixx": "ixx",
"nixpkgs": [
"nixvim",
@ -1080,6 +1149,7 @@
"inputs": {
"agenix": "agenix",
"flake-parts": "flake-parts",
"ghostty": "ghostty",
"home-manager": "home-manager_2",
"maomaowm": "maomaowm",
"nh": "nh",
@ -1088,7 +1158,7 @@
"niri-unstable": "niri-unstable",
"nix-matlab": "nix-matlab",
"nixd": "nixd",
"nixpkgs": "nixpkgs_5",
"nixpkgs": "nixpkgs_6",
"nixpkgs-stable": "nixpkgs-stable_2",
"nixpkgs-wayland": "nixpkgs-wayland",
"nixvim": "nixvim",
@ -1142,7 +1212,7 @@
"base16-helix": "base16-helix",
"base16-vim": "base16-vim",
"firefox-gnome-theme": "firefox-gnome-theme",
"flake-compat": "flake-compat_3",
"flake-compat": "flake-compat_4",
"flake-parts": "flake-parts_7",
"git-hooks": "git-hooks",
"gnome-shell": "gnome-shell",
@ -1151,7 +1221,7 @@
"nixpkgs"
],
"nur": "nur_2",
"systems": "systems_5",
"systems": "systems_6",
"tinted-foot": "tinted-foot",
"tinted-kitty": "tinted-kitty",
"tinted-schemes": "tinted-schemes",
@ -1247,6 +1317,21 @@
"type": "github"
}
},
"systems_6": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"tinted-foot": {
"flake": false,
"locked": {
@ -1394,7 +1479,7 @@
},
"treefmt-nix_4": {
"inputs": {
"nixpkgs": "nixpkgs_8"
"nixpkgs": "nixpkgs_9"
},
"locked": {
"lastModified": 1750931469,
@ -1442,6 +1527,61 @@
"repo": "xwayland-satellite",
"type": "github"
}
},
"zig": {
"inputs": {
"flake-compat": [
"ghostty",
"flake-compat"
],
"flake-utils": [
"ghostty",
"flake-utils"
],
"nixpkgs": [
"ghostty",
"nixpkgs"
]
},
"locked": {
"lastModified": 1748261582,
"narHash": "sha256-3i0IL3s18hdDlbsf0/E+5kyPRkZwGPbSFngq5eToiAA=",
"owner": "mitchellh",
"repo": "zig-overlay",
"rev": "aafb1b093fb838f7a02613b719e85ec912914221",
"type": "github"
},
"original": {
"owner": "mitchellh",
"repo": "zig-overlay",
"type": "github"
}
},
"zon2nix": {
"inputs": {
"flake-utils": [
"ghostty",
"flake-utils"
],
"nixpkgs": [
"ghostty",
"nixpkgs"
]
},
"locked": {
"lastModified": 1742104771,
"narHash": "sha256-LhidlyEA9MP8jGe1rEnyjGFCzLLgCdDpYeWggibayr0=",
"owner": "jcollie",
"repo": "zon2nix",
"rev": "56c159be489cc6c0e73c3930bd908ddc6fe89613",
"type": "github"
},
"original": {
"owner": "jcollie",
"repo": "zon2nix",
"rev": "56c159be489cc6c0e73c3930bd908ddc6fe89613",
"type": "github"
}
}
},
"root": "root",

View file

@ -92,5 +92,6 @@
url = "gitlab:doronbehar/nix-matlab";
inputs.nixpkgs.follows = "nixpkgs";
};
ghostty.url = "github:ghostty-org/ghostty";
};
}

View file

@ -1,3 +1,4 @@
{ config, ... }:
{
imports = [
./colorScheme
@ -5,4 +6,19 @@
./swhkd.nix
./addFlags.nix
];
config.lib.misc = {
mkGLSLColor =
color:
let
inherit (config.lib.stylix) colors;
r = colors."${color}-rgb-r";
g = colors."${color}-rgb-g";
b = colors."${color}-rgb-b";
rf = "${r}.0 / 255.0";
gf = "${g}.0 / 255.0";
bf = "${b}.0 / 255.0";
in
"vec4(${rf}, ${gf}, ${bf}, 1.0)";
};
}

View file

@ -77,17 +77,7 @@
custom-shader =
let
inherit (config.lib.stylix) colors;
mkColor =
color:
let
r = colors."${color}-rgb-r";
g = colors."${color}-rgb-g";
b = colors."${color}-rgb-b";
rf = "${r}.0 / 255.0";
gf = "${g}.0 / 255.0";
bf = "${b}.0 / 255.0";
in
"vec4(${rf}, ${gf}, ${bf}, 1.0)";
inherit (config.lib.misc) mkGLSLColor;
in
# glsl
''
@ -143,11 +133,11 @@
steps[4] = 0.8;
vec4 colors[5];
colors[0] = ${mkColor "base00"} * 1.0;
colors[1] = ${mkColor "base08"} * 1.0;
colors[2] = ${mkColor "base09"} * 1.0;
colors[3] = ${mkColor "base0A"} * 1.0;
colors[4] = ${mkColor "base05"} * 1.0;
colors[0] = ${mkGLSLColor "base00"} * 1.0;
colors[1] = ${mkGLSLColor "base08"} * 1.0;
colors[2] = ${mkGLSLColor "base09"} * 1.0;
colors[3] = ${mkGLSLColor "base0A"} * 1.0;
colors[4] = ${mkGLSLColor "base05"} * 1.0;
if (v < steps[0]) {
return colors[0];

View file

@ -48,6 +48,7 @@
}) config.monitors;
binds = with config.lib.niri.actions; {
"Mod+Return".action = spawn "kitty";
"Mod+Shift+Return".action = spawn "ghostty";
"Mod+P".action = spawn [
"sh"
"-c"

View file

@ -0,0 +1,52 @@
// source: https://gist.github.com/qwerasd205/c3da6c610c8ffe17d6d2d3cc7068f17f
// credits: https://github.com/qwerasd205
// Golden spiral samples, [x, y, weight] weight is inverse of distance.
const vec3[24] samples = {
vec3(0.1693761725038636, 0.9855514761735895, 1),
vec3(-1.333070830962943, 0.4721463328627773, 0.7071067811865475),
vec3(-0.8464394909806497, -1.51113870578065, 0.5773502691896258),
vec3(1.554155680728463, -1.2588090085709776, 0.5),
vec3(1.681364377589461, 1.4741145918052656, 0.4472135954999579),
vec3(-1.2795157692199817, 2.088741103228784, 0.4082482904638631),
vec3(-2.4575847530631187, -0.9799373355024756, 0.3779644730092272),
vec3(0.5874641440200847, -2.7667464429345077, 0.35355339059327373),
vec3(2.997715703369726, 0.11704939884745152, 0.3333333333333333),
vec3(0.41360842451688395, 3.1351121305574803, 0.31622776601683794),
vec3(-3.167149933769243, 0.9844599011770256, 0.30151134457776363),
vec3(-1.5736713846521535, -3.0860263079123245, 0.2886751345948129),
vec3(2.888202648340422, -2.1583061557896213, 0.2773500981126146),
vec3(2.7150778983300325, 2.5745586041105715, 0.2672612419124244),
vec3(-2.1504069972377464, 3.2211410627650165, 0.2581988897471611),
vec3(-3.6548858794907493, -1.6253643308191343, 0.25),
vec3(1.0130775986052671, -3.9967078676335834, 0.24253562503633297),
vec3(4.229723673607257, 0.33081361055181563, 0.23570226039551587),
vec3(0.40107790291173834, 4.340407413572593, 0.22941573387056174),
vec3(-4.319124570236028, 1.159811599693438, 0.22360679774997896),
vec3(-1.9209044802827355, -4.160543952132907, 0.2182178902359924),
vec3(3.8639122286635708, -2.6589814382925123, 0.21320071635561041),
vec3(3.3486228404946234, 3.4331800232609, 0.20851441405707477),
vec3(-2.8769733643574344, 3.9652268864187157, 0.20412414523193154)
};
float lum(vec4 c) {
return 0.299 * c.r + 0.587 * c.g + 0.114 * c.b;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = fragCoord.xy / iResolution.xy;
vec4 color = texture(iChannel0, uv);
vec2 step = vec2(1.414) / iResolution.xy;
for (int i = 0; i < 24; i++) {
vec3 s = samples[i];
vec4 c = texture(iChannel0, uv + s.xy * step);
float l = lum(c);
if (l > 0.2) {
color += l * s.z * c * 0.15;
}
}
fragColor = color;
}

View file

@ -1,5 +1,6 @@
{
imports = [
./kitty.nix
./ghostty.nix
];
}

View file

@ -0,0 +1,151 @@
{
inputs,
pkgs,
config,
...
}:
{
stylix.targets.ghostty.enable = true;
programs.ghostty = {
enable = true;
package = inputs.ghostty.packages.${pkgs.system}.ghostty;
settings = {
font-family = [
"Symbols Nerd Font"
"Xiaolai Mono SC"
];
custom-shader = [
"${./bloom.glsl}"
"${pkgs.writeTextFile {
name = "ghostty-shader-cursor-blaze.glsl";
text =
let
inherit (config.lib.misc) mkGLSLColor;
in
''
// Copied from https://github.com/KroneCorylus/ghostty-shader-playground
float getSdfRectangle(in vec2 p, in vec2 xy, in vec2 b)
{
vec2 d = abs(p - xy) - b;
return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
}
// Based on Inigo Quilez's 2D distance functions article: https://iquilezles.org/articles/distfunctions2d/
// Potencially optimized by eliminating conditionals and loops to enhance performance and reduce branching
float seg(in vec2 p, in vec2 a, in vec2 b, inout float s, float d) {
vec2 e = b - a;
vec2 w = p - a;
vec2 proj = a + e * clamp(dot(w, e) / dot(e, e), 0.0, 1.0);
float segd = dot(p - proj, p - proj);
d = min(d, segd);
float c0 = step(0.0, p.y - a.y);
float c1 = 1.0 - step(0.0, p.y - b.y);
float c2 = 1.0 - step(0.0, e.x * w.y - e.y * w.x);
float allCond = c0 * c1 * c2;
float noneCond = (1.0 - c0) * (1.0 - c1) * (1.0 - c2);
float flip = mix(1.0, -1.0, step(0.5, allCond + noneCond));
s *= flip;
return d;
}
float getSdfParallelogram(in vec2 p, in vec2 v0, in vec2 v1, in vec2 v2, in vec2 v3) {
float s = 1.0;
float d = dot(p - v0, p - v0);
d = seg(p, v0, v3, s, d);
d = seg(p, v1, v0, s, d);
d = seg(p, v2, v1, s, d);
d = seg(p, v3, v2, s, d);
return s * sqrt(d);
}
vec2 normalize(vec2 value, float isPosition) {
return (value * 2.0 - (iResolution.xy * isPosition)) / iResolution.y;
}
float antialising(float distance) {
return 1. - smoothstep(0., normalize(vec2(2., 2.), 0.).x, distance);
}
float determineStartVertexFactor(vec2 c, vec2 p) {
// Conditions using step
float condition1 = step(p.x, c.x) * step(c.y, p.y); // c.x < p.x && c.y > p.y
float condition2 = step(c.x, p.x) * step(p.y, c.y); // c.x > p.x && c.y < p.y
// If neither condition is met, return 1 (else case)
return 1.0 - max(condition1, condition2);
}
vec2 getRectangleCenter(vec4 rectangle) {
return vec2(rectangle.x + (rectangle.z / 2.), rectangle.y - (rectangle.w / 2.));
}
float ease(float x) {
return pow(1.0 - x, 3.0);
}
vec4 saturate(vec4 color, float factor) {
float gray = dot(color, vec4(0.299, 0.587, 0.114, 0.)); // luminance
return mix(vec4(gray), color, factor);
}
const vec4 TRAIL_COLOR = ${mkGLSLColor "base05"};
const vec4 TRAIL_COLOR_ACCENT = ${mkGLSLColor "base0E"};
const float DURATION = 0.3; //IN SECONDS
void mainImage(out vec4 fragColor, in vec2 fragCoord)
{
#if !defined(WEB)
fragColor = texture(iChannel0, fragCoord.xy / iResolution.xy);
#endif
// Normalization for fragCoord to a space of -1 to 1;
vec2 vu = normalize(fragCoord, 1.);
vec2 offsetFactor = vec2(-.5, 0.5);
// Normalization for cursor position and size;
// cursor xy has the postion in a space of -1 to 1;
// zw has the width and height
vec4 currentCursor = vec4(normalize(iCurrentCursor.xy, 1.), normalize(iCurrentCursor.zw, 0.));
vec4 previousCursor = vec4(normalize(iPreviousCursor.xy, 1.), normalize(iPreviousCursor.zw, 0.));
vec2 centerCC = getRectangleCenter(currentCursor);
vec2 centerCP = getRectangleCenter(previousCursor);
// When drawing a parellelogram between cursors for the trail i need to determine where to start at the top-left or top-right vertex of the cursor
float vertexFactor = determineStartVertexFactor(currentCursor.xy, previousCursor.xy);
float invertedVertexFactor = 1.0 - vertexFactor;
// Set every vertex of my parellogram
vec2 v0 = vec2(currentCursor.x + currentCursor.z * vertexFactor, currentCursor.y - currentCursor.w);
vec2 v1 = vec2(currentCursor.x + currentCursor.z * invertedVertexFactor, currentCursor.y);
vec2 v2 = vec2(previousCursor.x + currentCursor.z * invertedVertexFactor, previousCursor.y);
vec2 v3 = vec2(previousCursor.x + currentCursor.z * vertexFactor, previousCursor.y - previousCursor.w);
float sdfCurrentCursor = getSdfRectangle(vu, currentCursor.xy - (currentCursor.zw * offsetFactor), currentCursor.zw * 0.5);
float sdfTrail = getSdfParallelogram(vu, v0, v1, v2, v3);
float progress = clamp((iTime - iTimeCursorChange) / DURATION, 0.0, 1.0);
float easedProgress = ease(progress);
// Distance between cursors determine the total length of the parallelogram;
float lineLength = distance(centerCC, centerCP);
float mod = .007;
//trailblaze
// HACK: Using the saturate function because I currently don't know how to blend colors without losing saturation.
vec4 trail = mix(saturate(TRAIL_COLOR_ACCENT, 1.5), fragColor, 1. - smoothstep(0., sdfTrail + mod, 0.007));
trail = mix(saturate(TRAIL_COLOR, 1.5), trail, 1. - smoothstep(0., sdfTrail + mod, 0.006));
trail = mix(trail, saturate(TRAIL_COLOR, 1.5), step(sdfTrail + mod, 0.));
//cursorblaze
trail = mix(saturate(TRAIL_COLOR_ACCENT, 1.5), trail, 1. - smoothstep(0., sdfCurrentCursor + .002, 0.004));
trail = mix(saturate(TRAIL_COLOR, 1.5), trail, 1. - smoothstep(0., sdfCurrentCursor + .002, 0.004));
fragColor = mix(trail, fragColor, 1. - smoothstep(0., sdfCurrentCursor, easedProgress * lineLength));
}
'';
}}"
];
window-padding-x = 20;
window-padding-y = 10;
window-decoration = "none";
};
};
}