From 0c461e9422b87327c367b1ef8167b104dbbb5885 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Sat, 9 May 2020 14:42:19 +0100 Subject: [PATCH] common: add my hgrc so I can have evolve everywhere --- ops/nixos/lib/common.nix | 4 ++- ops/nixos/lib/hgrc.nix | 59 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 ops/nixos/lib/hgrc.nix diff --git a/ops/nixos/lib/common.nix b/ops/nixos/lib/common.nix index a42292fcbd..b900a921d6 100644 --- a/ops/nixos/lib/common.nix +++ b/ops/nixos/lib/common.nix @@ -1,8 +1,10 @@ { pkgs, depot, lib, rebuilder, ... }: let -inherit (lib) mkDefault; + inherit (lib) mkDefault; in { + imports = [ ./hgrc.nix ]; + hardware.enableRedistributableFirmware = true; nix = { diff --git a/ops/nixos/lib/hgrc.nix b/ops/nixos/lib/hgrc.nix new file mode 100644 index 0000000000..7b860a7bcb --- /dev/null +++ b/ops/nixos/lib/hgrc.nix @@ -0,0 +1,59 @@ +{ pkgs, lib, ... }: +let + hgrcPkg = pkgs.writeText "lukegb-hgrc" '' + [ui] + username = Luke Granger-Brown + interface = curses + tweakdefaults = True + merge = internal:merge3 + + [alias] + log = log --template lukegblogshort --graph + xl = log -r 'smartlog()' + + [revsetalias] + # We're interested in the current commit, and any non-extinct commits in the draft or secret phases. + smartlogstart() = . | ((draft() | secret()) - extinct()) + # Now expand smartlogstart to go up to the parent public commit. + publichead(r1) = ancestors(r1) - (descendants(public(), 1) and public()) + smartlogstart() = (parents(not public()) or not public() or . or head()) and (not obsolete() or unstable()^) and not closed() + smartlog() = publichead(smartlogstart())::smartlogstart() | smartlogstart() + + [color] + mode = terminfo + + custom.rev = green bold + custom.revprefix = green bold inverse + custom.author = red + custom.currentcommit_message = magenta + custom.bookmarks = bold orange + custom.date = lightyellow + + color.orange = 202 + color.lightyellow = 191 + + [templates] + lukegblogshort = {label('custom.rev', lukegbnode)} {label('custom.date', lukegbdate)} {label('custom.author', lukegbauthor)} {label(ifcontains(rev, revset('.'), 'custom.currentcommit_message', 'custom.message'), lukegbmsg)} {label('custom.bookmarks', bookmarks)}\n + lukegbdate = {date|age} + lukegbmsg = {desc|firstline} + lukegbcopybarain = {sub('^noreply\+([^@]+)@lukegb.com$', 'copybara:\\1', author|email)} + lukegbcopybara = {ifcontains(lukegbcopybarain, '@', "", lukegbcopybarain)} + lukegbauthor = {ifeq('hg@lukegb.com', author|email, 'lukegb', if(lukegbcopybara, lukegbcopybara, author|email))} + lukegbnode = {label('custom.revprefix', lukegbnodesh)}{lukegbnodelng} + lukegbnodesh = {node|shortest} + lukegbnodelng = {sub('^{lukegbnodesh}', "", '{node|short}')} + + [extensions] + histedit = + rebase = + strip = + remotenames = + amend = + evolve = + ''; +in +{ + system.activationScripts.lukegb-hgrc = lib.stringAfter [ "users" "groups" ] '' + ln -sfn ${hgrcPkg} /home/lukegb/.hgrc + ''; +}