From 8ae633a5e4ff05c0ec437471efb476d441f1098b Mon Sep 17 00:00:00 2001 From: RGBCube Date: Sat, 18 Jan 2025 20:39:18 +0300 Subject: [PATCH] Use a WIP branch of starship for jj --- modules/common/nushell/default.nix | 106 ++++++++++++++++++++++++++++- 1 file changed, 103 insertions(+), 3 deletions(-) diff --git a/modules/common/nushell/default.nix b/modules/common/nushell/default.nix index 84f560f..082bc5f 100644 --- a/modules/common/nushell/default.nix +++ b/modules/common/nushell/default.nix @@ -1,5 +1,5 @@ { config, lib, pkgs, ... }: let - inherit (lib) enabled filter first foldl' getExe last match mkIf nameValuePair optionalAttrs readFile removeAttrs splitString; + inherit (lib) enabled const filter first foldl' getExe last match mkIf nameValuePair optionalAttrs readFile removeAttrs splitString; in { users = optionalAttrs config.isLinux { defaultUserShell = pkgs.nushell; }; @@ -43,11 +43,111 @@ in { programs.starship = enabled { # No because we are doing it at build time instead of the way - # this retarded does it. Why the hell do you generate the config - # every time the shell is launched? + # this retarded module does it. Why the hell do you generate + # the config every time the shell is launched? enableNushellIntegration = false; + # package = pkgs.starship.overrideAttrs (const { + # src = pkgs.fetchFromGitHub { + # owner = "poliorcetics"; + # repo = "starship"; + # rev = "19926e1e0aa25eddf63f93ba270d60eef023338f"; + # hash = "sha256-mi2O8JzXNLIF0/GuXVyf27JVV7d6zoskIjB29r5fPso="; + # }; + + # cargoHash = "sha256-sOjCkRHknc0SWNEItEvD6ajk/5W2kfbD1bw8T+wzGeU="; + # }); + + package = pkgs.callPackage ({ + lib, + stdenv, + fetchFromGitHub, + rustPlatform, + installShellFiles, + cmake, + git, + nixosTests, + Security, + Foundation, + Cocoa, + }: + + rustPlatform.buildRustPackage { + pname = "starship"; + version = "1.22.1"; + + src = pkgs.fetchFromGitHub { + owner = "poliorcetics"; + repo = "starship"; + rev = "19926e1e0aa25eddf63f93ba270d60eef023338f"; + hash = "sha256-mi2O8JzXNLIF0/GuXVyf27JVV7d6zoskIjB29r5fPso="; + }; + + nativeBuildInputs = [ + installShellFiles + cmake + ]; + + buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ + Security + Foundation + Cocoa + ]; + + NIX_LDFLAGS = lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [ + "-framework" + "AppKit" + ]; + + # tries to access HOME only in aarch64-darwin environment when building mac-notification-sys + preBuild = lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) '' + export HOME=$TMPDIR + ''; + + postInstall = + '' + presetdir=$out/share/starship/presets/ + mkdir -p $presetdir + cp docs/public/presets/toml/*.toml $presetdir + '' + + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' + installShellCompletion --cmd starship \ + --bash <($out/bin/starship completions bash) \ + --fish <($out/bin/starship completions fish) \ + --zsh <($out/bin/starship completions zsh) + ''; + + cargoHash = "sha256-sOjCkRHknc0SWNEItEvD6ajk/5W2kfbD1bw8T+wzGeU="; + + nativeCheckInputs = [ git ]; + + preCheck = '' + HOME=$TMPDIR + ''; + + passthru.tests = { + inherit (nixosTests) starship; + }; + + meta = with lib; { + description = "Minimal, blazing fast, and extremely customizable prompt for any shell"; + homepage = "https://starship.rs"; + license = licenses.isc; + maintainers = with maintainers; [ + danth + davidtwco + Br1ght0ne + Frostman + ]; + mainProgram = "starship"; + }; + }) { + inherit (pkgs.darwin.apple_sdk.frameworks) Security Foundation Cocoa; + }; + settings = { + vcs.disabled = false; + command_timeout = 100; scan_timeout = 20;