From ed114a6a8300a4a47e1973ad99e3443ed0712a91 Mon Sep 17 00:00:00 2001 From: Ariel Richtman <10679234+arichtman@users.noreply.github.com> Date: Sat, 16 Nov 2024 17:42:19 +1000 Subject: [PATCH] feat: add and configure mergiraf for git --- flake.lock | 17 +++++++++++++++++ flake.nix | 1 + modules/home/default-home/default.nix | 14 +++++++++++++- modules/home/default-home/git/.gitattributes | 19 +++++++++++++++++++ .../default-home/{ => git}/.gitignore.nix | 0 5 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 modules/home/default-home/git/.gitattributes rename modules/home/default-home/{ => git}/.gitignore.nix (100%) diff --git a/flake.lock b/flake.lock index 9872454..b55953e 100644 --- a/flake.lock +++ b/flake.lock @@ -393,6 +393,22 @@ "type": "github" } }, + "pkgsMaster": { + "locked": { + "lastModified": 1731738178, + "narHash": "sha256-2+Ezy1XdeoAO+CTpo+XHfG2z1X1szoNsQmllYRHyDt8=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "e2b0cccf5508f35c234ab79dc29c471e60825d7c", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "master", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "darwin": "darwin", @@ -401,6 +417,7 @@ "mac-app-util": "mac-app-util", "nixgl": "nixgl", "nixpkgs": "nixpkgs_2", + "pkgsMaster": "pkgsMaster", "snowfall-lib": "snowfall-lib", "snowfall-thaw": "snowfall-thaw", "yaml2nix": "yaml2nix" diff --git a/flake.nix b/flake.nix index 0b41b86..3a5595a 100644 --- a/flake.nix +++ b/flake.nix @@ -2,6 +2,7 @@ description = "Ariel's machine configs"; inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + pkgsMaster.url = "github:nixos/nixpkgs/master"; snowfall-lib = { url = "github:snowfallorg/lib/v3.0.2"; diff --git a/modules/home/default-home/default.nix b/modules/home/default-home/default.nix index aecfea3..961cf70 100644 --- a/modules/home/default-home/default.nix +++ b/modules/home/default-home/default.nix @@ -2,6 +2,7 @@ config, pkgs, lib, + inputs, ... }: let cfg = config.default-home; @@ -248,7 +249,7 @@ in }; # Note: regex to select non-comments ^[^#\n].* # TODO: Generate the file from fetchURL call, run regex, remove .envrc line? - ignores = import ./.gitignore.nix; + ignores = import ./git/.gitignore.nix; signing = { signByDefault = true; key = "~/.ssh/id_ed25519.pub"; @@ -279,6 +280,13 @@ in autoSetupRemote = true; default = "current"; }; + merge.mergiraf = { + name = "mergiraf"; + driver = "mergiraf merge --git %O %A %B -s %S -x %X -y %Y -p %P"; + }; + core = { + attributesfile = "~/.gitattributes"; + }; url = { "https://github.com" = {insteadOf = "gh";}; "https://gitlab.com" = {insteadOf = "gl";}; @@ -380,6 +388,9 @@ in nixd nil ruff-lsp + # diff tool + # TODO: simplify when this hits unstable or whatever + inputs.pkgsMaster.legacyPackages.${system}.mergiraf # langs rustup #TODO: dont have these on mac, aarch64 at least @@ -399,6 +410,7 @@ in source = ./terraform; recursive = true; }; + ".config/git/.gitattributes".source = git/.gitattributes; # Required to create empty directory for Terraform plugin cache since TF won't create if not exist 🙄 # https://github.com/nix-community/home-manager/issues/2104 ".terraform.d/plugin-cache/.keep".text = ""; diff --git a/modules/home/default-home/git/.gitattributes b/modules/home/default-home/git/.gitattributes new file mode 100644 index 0000000..a2a20b1 --- /dev/null +++ b/modules/home/default-home/git/.gitattributes @@ -0,0 +1,19 @@ +*.java merge=mergiraf +*.rs merge=mergiraf +*.go merge=mergiraf +*.js merge=mergiraf +*.jsx merge=mergiraf +*.json merge=mergiraf +*.yml merge=mergiraf +*.yaml merge=mergiraf +*.html merge=mergiraf +*.htm merge=mergiraf +*.xhtml merge=mergiraf +*.xml merge=mergiraf +*.c merge=mergiraf +*.cc merge=mergiraf +*.h merge=mergiraf +*.cpp merge=mergiraf +*.hpp merge=mergiraf +*.cs merge=mergiraf +*.dart merge=mergiraf diff --git a/modules/home/default-home/.gitignore.nix b/modules/home/default-home/git/.gitignore.nix similarity index 100% rename from modules/home/default-home/.gitignore.nix rename to modules/home/default-home/git/.gitignore.nix