From 13a4a648fd8c573ee9e384ef5744e3a5f54f506e Mon Sep 17 00:00:00 2001 From: Chris Toph Date: Sat, 31 May 2025 14:27:31 -0400 Subject: [PATCH] Changes to streamline Home Core, and added ms-edit --- flake.lock | 36 +++++++-------- home/global/common/vscode/default.nix | 9 ++++ home/global/core/bat.nix | 33 -------------- home/global/core/btop.nix | 10 +++++ home/global/core/default.nix | 18 ++------ home/global/core/fish/init.fish | 6 +-- home/global/core/zoxide.nix | 10 ----- pkgs/microsoft-edit/package.nix | 51 ++++++++++++++++++++++ pkgs/microsoft-edit/write-filled-fix.patch | 15 +++++++ 9 files changed, 107 insertions(+), 81 deletions(-) delete mode 100644 home/global/core/bat.nix create mode 100644 home/global/core/btop.nix delete mode 100644 home/global/core/zoxide.nix create mode 100644 pkgs/microsoft-edit/package.nix create mode 100644 pkgs/microsoft-edit/write-filled-fix.patch diff --git a/flake.lock b/flake.lock index 972b7f1..485b0f9 100644 --- a/flake.lock +++ b/flake.lock @@ -333,11 +333,11 @@ }, "hardware": { "locked": { - "lastModified": 1747900541, - "narHash": "sha256-dn64Pg9xLETjblwZs9Euu/SsjW80pd6lr5qSiyLY1pg=", + "lastModified": 1748634340, + "narHash": "sha256-pZH4bqbOd8S+si6UcfjHovWDiWKiIGRNRMpmRWaDIms=", "owner": "nixos", "repo": "nixos-hardware", - "rev": "11f2d9ea49c3e964315215d6baa73a8d42672f06", + "rev": "daa628a725ab4948e0e2b795e8fb6f4c3e289a7a", "type": "github" }, "original": { @@ -374,11 +374,11 @@ ] }, "locked": { - "lastModified": 1748570847, - "narHash": "sha256-XU1a6wFctd+s3ZvBIFB6s4GhPJ+Oc6pkeOrEsbA2fMo=", + "lastModified": 1748668774, + "narHash": "sha256-fYk/vk4ClmvHIgnGv/5GNRiDLtNCwXo9aLq36L/x+P4=", "owner": "nix-community", "repo": "home-manager", - "rev": "4e9efaa68b0be7e19127dad4f0506a9b89e28ef4", + "rev": "60e4624302d956fe94d3f7d96a560d14d70591b9", "type": "github" }, "original": { @@ -460,11 +460,11 @@ ] }, "locked": { - "lastModified": 1748570315, - "narHash": "sha256-laTKC6M+ciljWgUpzhLHyoz1+iRaMBWbQoycX0hhbe8=", + "lastModified": 1748656608, + "narHash": "sha256-VU+8/kZ57Y7XTmgMBpybGMxO/elvUn/4yMndZji2pY8=", "owner": "fufexan", "repo": "nix-gaming", - "rev": "f85768830fdaee114ea6d18dee80737c74a8dcc9", + "rev": "b585487bb87faec1c7a09aada7cfe77dd7b3c5fe", "type": "github" }, "original": { @@ -545,11 +545,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1748370509, - "narHash": "sha256-QlL8slIgc16W5UaI3w7xHQEP+Qmv/6vSNTpoZrrSlbk=", + "lastModified": 1748460289, + "narHash": "sha256-7doLyJBzCllvqX4gszYtmZUToxKvMUrg45EUWaUYmBg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "4faa5f5321320e49a78ae7848582f684d64783e9", + "rev": "96ec055edbe5ee227f28cdbc3f1ddf1df5965102", "type": "github" }, "original": { @@ -561,11 +561,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1748370509, - "narHash": "sha256-QlL8slIgc16W5UaI3w7xHQEP+Qmv/6vSNTpoZrrSlbk=", + "lastModified": 1748460289, + "narHash": "sha256-7doLyJBzCllvqX4gszYtmZUToxKvMUrg45EUWaUYmBg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "4faa5f5321320e49a78ae7848582f684d64783e9", + "rev": "96ec055edbe5ee227f28cdbc3f1ddf1df5965102", "type": "github" }, "original": { @@ -768,11 +768,11 @@ "tinted-zed": "tinted-zed" }, "locked": { - "lastModified": 1748572239, - "narHash": "sha256-Of7bmWQUEVILpx1GJz0gLHmRoGrEP/G7q9RnidxW5Go=", + "lastModified": 1748699906, + "narHash": "sha256-pu2UKagKKysJ7EYeOcm8vWoZq1lcxfwfu3/C1Y3OFz8=", "owner": "danth", "repo": "stylix", - "rev": "0512b0f685ab2ac0586c897460c247f49670460b", + "rev": "8762da957b8b04b8b73248144f1c0ff7a88924b5", "type": "github" }, "original": { diff --git a/home/global/common/vscode/default.nix b/home/global/common/vscode/default.nix index e98b1e3..74411c4 100644 --- a/home/global/common/vscode/default.nix +++ b/home/global/common/vscode/default.nix @@ -9,4 +9,13 @@ in enable = true; package = pkgs.vscode.fhsWithPackages (_: [ patched-openssh ]); }; + + # Pkgs used with vscode regularly + home.packages = builtins.attrValues { + inherit (pkgs) + nixfmt-rfc-style # nix formatter + nixpkgs-review # nix review tool + biome + ; + }; } diff --git a/home/global/core/bat.nix b/home/global/core/bat.nix deleted file mode 100644 index fb69392..0000000 --- a/home/global/core/bat.nix +++ /dev/null @@ -1,33 +0,0 @@ -# https://github.com/sharkdp/bat -# https://github.com/eth-p/bat-extras - -{ pkgs, ... }: -{ - programs.bat = { - enable = true; - config = { - # Git modifications and file header (but no grid) - style = "changes,header"; - # theme = "gruvbox-dark"; - }; - extraPackages = builtins.attrValues { - inherit (pkgs.bat-extras) - - batgrep # search through and highlight files using ripgrep - batdiff # Diff a file against the current git index, or display the diff between to files - batman # read manpages using bat as the formatter - ; - }; - }; - - # Avoid [bat error]: The binary caches for the user-customized syntaxes and themes in - # '/home//.cache/bat' are not compatible with this version of bat (0.25.0). - home.activation.batCacheRebuild = { - after = [ "linkGeneration" ]; - before = [ ]; - data = '' - ${pkgs.bat}/bin/bat cache --build - ''; - }; - -} diff --git a/home/global/core/btop.nix b/home/global/core/btop.nix new file mode 100644 index 0000000..3461278 --- /dev/null +++ b/home/global/core/btop.nix @@ -0,0 +1,10 @@ +{ + # Processes and system monitor + programs.btop = { + enable = true; + settings = { + color_theme = "stylix"; + theme_background = false; + }; + }; +} diff --git a/home/global/core/default.nix b/home/global/core/default.nix index dce2e68..70dbc94 100644 --- a/home/global/core/default.nix +++ b/home/global/core/default.nix @@ -30,10 +30,9 @@ in ]; sessionVariables = { EDITOR = "micro"; - FLAKE = lib.mkDefault "${homeDir}/git/Nix/dot.nix"; - MANPAGER = "batman"; - SHELL = lib.getExe shell; VISUAL = "micro"; + FLAKE = lib.mkDefault "${homeDir}/git/Nix/dot.nix"; + SHELL = lib.getExe shell; }; preferXdgDirectories = true; # whether to make programs use XDG directories whenever supported @@ -57,27 +56,16 @@ in # Core pkgs with no configs home.packages = builtins.attrValues { inherit (pkgs) - btop # resource monitor coreutils # basic gnu utils - delta # diffing - difftastic # diffing direnv # environment per directory dust # disk usage eza # ls replacement - gh # github cli - jq # json parser - man-pages - man-pages-posix - nixfmt-rfc-style # nix formatter - nixpkgs-review # nix review tool nmap # network scanner - pre-commit # git hooks trashy # trash cli unrar # rar extraction unzip # zip extraction - xdg-user-dirs - xdg-utils # provide cli tools such as `xdg-mime` and `xdg-open` zip # zip compression + microsoft-edit ; }; diff --git a/home/global/core/fish/init.fish b/home/global/core/fish/init.fish index f6033ff..39deee4 100644 --- a/home/global/core/fish/init.fish +++ b/home/global/core/fish/init.fish @@ -2,10 +2,6 @@ set fish_greeting # Disable greeting ## Aliases and Overrides ## -function cd - zoxide $argv -end - function ls eza $argv end @@ -62,7 +58,7 @@ function zipz # - The tar command outputs the archive to stdout. # - zstd compresses it using 4 threads (-T4) and a compression level of 12 (-12). # - The -c flag forces zstd to write to stdout. - tar cf - $directory | nix run nixpkgs#zstd -- -c -T5 -15 -v > $output_file + tar cf - $directory | nix run nixpkgs#zstd -- -c -T5 -15 -v >$output_file # Check the exit status of the pipeline if test $status -eq 0 diff --git a/home/global/core/zoxide.nix b/home/global/core/zoxide.nix deleted file mode 100644 index 3f02805..0000000 --- a/home/global/core/zoxide.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ - programs.zoxide = { - enable = true; - enableBashIntegration = true; - enableFishIntegration = true; - options = [ - "--cmd cd" # replace cd with z and zi (via cdi) - ]; - }; -} diff --git a/pkgs/microsoft-edit/package.nix b/pkgs/microsoft-edit/package.nix new file mode 100644 index 0000000..2414a28 --- /dev/null +++ b/pkgs/microsoft-edit/package.nix @@ -0,0 +1,51 @@ +{ + lib, + rustPlatform, + fetchFromGitHub, + versionCheckHook, + nix-update-script, +}: +rustPlatform.buildRustPackage (finalAttrs: { + pname = "microsoft-edit"; + version = "1.0.0"; + + src = fetchFromGitHub { + owner = "microsoft"; + repo = "edit"; + tag = "v${finalAttrs.version}"; + hash = "sha256-5GUAHa0/7k4uVNWEjn0hd1YvkRnUk6AdxTQhw5z95BY="; + }; + + useFetchCargoVendor = true; + cargoHash = "sha256-DEzjfrXSmum/GJdYanaRDKxG4+eNPWf5echLhStxcIg="; + # Requires nightly features + env.RUSTC_BOOTSTRAP = 1; + + # Add a patch to fix the write_filled error + patches = [ + ./write-filled-fix.patch + ]; + + # Disabled for now, microsoft/edit#194 + doInstallCheck = false; + nativeInstallCheckInputs = [ versionCheckHook ]; + versionCheckProgram = "${placeholder "out"}/bin/edit"; + versionCheckProgramArg = "--version"; + + passthru.updateScript = nix-update-script { }; + + meta = { + description = "Simple editor for simple needs"; + longDescription = '' + This editor pays homage to the classic MS-DOS Editor, + but with a modern interface and input controls similar to VS Code. + The goal is to provide an accessible editor that even users largely + unfamiliar with terminals can easily use. + ''; + mainProgram = "edit"; + homepage = "https://github.com/microsoft/edit"; + changelog = "https://github.com/microsoft/edit/releases/tag/v${finalAttrs.version}"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ RossSmyth ]; # https://github.com/NixOS/nixpkgs/pull/409075 + }; +}) diff --git a/pkgs/microsoft-edit/write-filled-fix.patch b/pkgs/microsoft-edit/write-filled-fix.patch new file mode 100644 index 0000000..8c0e9c7 --- /dev/null +++ b/pkgs/microsoft-edit/write-filled-fix.patch @@ -0,0 +1,15 @@ +--- a/src/tui.rs ++++ b/src/tui.rs +@@ -3529,7 +3529,11 @@ impl<'a> NodeMap<'a> { + let shift = 64 - width; + let mask = (slots - 1) as u64; + +- let slots = arena.alloc_uninit_slice(slots).write_filled(None); ++ let uninit_slots = arena.alloc_uninit_slice(slots); ++ for slot in uninit_slots.iter_mut() { ++ slot.write(None); ++ } ++ let slots = unsafe { std::mem::transmute::<&mut [std::mem::MaybeUninit>>], &mut [Option<&'a NodeCell<'a>>]>(uninit_slots) }; + let mut node = tree.root_first; + + loop {