diff --git a/home-manager/opdavies/PW05CH3L.nix b/home-manager/opdavies/PW05CH3L.nix index 55cb3b65..7ad4743b 100644 --- a/home-manager/opdavies/PW05CH3L.nix +++ b/home-manager/opdavies/PW05CH3L.nix @@ -9,9 +9,6 @@ direnv.enable = true; fzf.enable = true; - git.enable = true; - git.user.emailAddress = "oliver.davies@tfw.wales"; - node.enable = true; notes.enable = true; ranger.enable = true; diff --git a/home-manager/opdavies/t480.nix b/home-manager/opdavies/t480.nix index 71558697..ea2a7404 100644 --- a/home-manager/opdavies/t480.nix +++ b/home-manager/opdavies/t480.nix @@ -13,9 +13,6 @@ direnv.enable = true; fzf.enable = true; - git.enable = true; - git.user.emailAddress = "oliver@oliverdavies.uk"; - node.enable = true; notes.enable = true; diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index 52fe37a2..dffcb5fc 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -9,7 +9,6 @@ ./direnv.nix ./flameshot.nix ./fzf.nix - ./git.nix ./gnupg.nix ./gtk.nix ./media/handbrake.nix diff --git a/modules/home-manager/git.nix b/modules/home-manager/git.nix deleted file mode 100644 index 762bb8db..00000000 --- a/modules/home-manager/git.nix +++ /dev/null @@ -1,184 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: - -with lib; - -let - cfg = config.features.cli.git; -in -{ - options.features.cli.git = { - enable = mkEnableOption "Enable git"; - - user = mkOption { - type = types.submodule { - options = { - emailAddress = mkOption { - description = "User email address."; - type = types.str; - apply = - x: - assert builtins.match "^[^@]+@[^@]+\\.[^@]+$" x != null; - x; - }; - }; - }; - }; - }; - - config = mkIf cfg.enable { - home.file."${config.xdg.configHome}/git/message".text = '' - - - # Description - # - # - Why is this change necessary? - # - How does it address the issue? - # - What side effects does this change have? - # - # For breaking changes, uncomment the following line and describe the change: - # - # BREAKING CHANGE: - # - # - # Add any issue IDs or commit SHAs that this commit references: - # - # Refs: - - ''; - - programs = { - git = { - enable = true; - userName = "Oliver Davies"; - userEmail = cfg.user.emailAddress; - - aliases = { - aa = "add --all"; - assume = "update-index --assume-unchanged"; - assumed = "!git ls-files -v | grep '^[hsmrck?]' | cut -c 3-"; - b = "branch"; - blame = "blame -w -C -C -C"; - browse = "!gh repo view --web"; - ca = "commit --amend --verbose"; - car = "commit --amend --no-edit"; - cl = "!hub clone"; - co = "checkout"; - compare = "!hub compare"; - current-branch = "rev-parse --abbrev-ref HEAD"; - dc = "diff --color --word-diff --cached"; - df = "diff --color --word-diff"; - dup = "!git checkout develop && git fetch origin && echo && git sl develop..origin/develop && echo && git pull --quiet && git checkout -"; - fixup = "commit --fixup"; - issues = "!gh issue list --web"; - mup = "!git master-to-main-wrapper checkout %BRANCH% && git fetch origin && echo && git sl %BRANCH%..origin/%BRANCH% && echo && git pull --quiet && git checkout -"; - no-ff = "merge --no-ff"; - pl = "pull"; - prune = "remote prune origin"; - ps = "push"; - pulls = "!gh pr list --web"; - rbc = "rebase --continue"; - rdup = "!git dup && git rebase develop"; - remotes = "remote -v"; - repush = "!git pull --rebase && git push"; - ri = "rebase --interactive"; - rid = "!git rebase -i $(git merge-base develop HEAD)"; - rim = "!git rebase -i $(git master-to-main-wrapper merge-base %BRANCH% HEAD)"; - rip = "!git rebase -i $(git merge-base production HEAD)"; - ris = "!git rebase -i $(git merge-base staging HEAD)"; - riu = "!git rebase -i $(git rev-parse --abbrev-ref --symbolic-full-name @{u})"; - rmup = "!git mup && git master-to-main-wrapper rebase %BRANCH%"; - sl = "log --oneline --decorate -20"; - sla = "log --oneline --decorate --graph --all -20"; - slap = "log --oneline --decorate --graph --all"; - slp = "log --oneline --decorate"; - stash = "stash --included-untracked"; - unassume = "update-index --no-assume-unchanged"; - uncommit = "reset --soft HEAD^"; - unstage = "reset"; - update = "!git fetch --all --jobs=4 --prune --progress && git rebase --autostash --stat"; - upstream = "rev-parse --abbrev-ref --symbolic-full-name @{u}"; - ureset = "!git reset --hard $(git upstream)"; - worktrees = "worktree list"; - }; - - ignores = [ - "/.ddev/providers/" - "/.direnv/" - "/.ignored/" - "/.issue-id" - "/.phpactor.json" - "/notes" - "/todo" - ]; - - extraConfig = { - branch = { - autosetupmerge = true; - autosetuprebase = "always"; - sort = "-committerdate"; - }; - - checkout.defaultRemote = "origin"; - color.ui = true; - column.ui = "auto"; - commit.template = "${config.xdg.configHome}/git/message"; - - core = { - editor = "nvim"; - excludesFile = "~/.config/git/ignore"; - }; - - diff.tool = "vimdiff"; - fetch.prune = true; - gpg.format = "ssh"; - grep.lineNumber = true; - help.autocorrect = "1"; - init.defaultBranch = "main"; - - maintenance = { - auto = false; - strategy = "incremental"; - }; - - merge.ff = "only"; - - push = { - autoSetupRemote = true; - default = "upstream"; - }; - - pull = { - ff = "only"; - rebase = true; - }; - - rebase = { - autosquash = true; - autostash = true; - }; - - user.signingkey = "~/.ssh/id_rsa.pub"; - }; - }; - }; - - home = { - packages = with pkgs; [ - git-exclude - git-extras - git-graph - git-trim - stable.git-instafix - ]; - - sessionVariables = { - GIT_INSTAFIX_UPSTREAM = "origin/main"; - }; - }; - }; -} diff --git a/modules/nixos/nixpad/default.nix b/modules/nixos/nixpad/default.nix index ace3213c..355cf52b 100644 --- a/modules/nixos/nixpad/default.nix +++ b/modules/nixos/nixpad/default.nix @@ -23,7 +23,6 @@ in programs = { firefox.enable = true; - git.enable = true; }; environment.systemPackages = with pkgs; [ diff --git a/modules2/git/aliases.nix b/modules2/git/aliases.nix new file mode 100644 index 00000000..ad52e1b7 --- /dev/null +++ b/modules2/git/aliases.nix @@ -0,0 +1,50 @@ +{ + flake.modules.homeManager.base.programs.git.aliases = { + aa = "add --all"; + assume = "update-index --assume-unchanged"; + assumed = "!git ls-files -v | grep '^[hsmrck?]' | cut -c 3-"; + b = "branch"; + blame = "blame -w -C -C -C"; + browse = "!gh repo view --web"; + ca = "commit --amend --verbose"; + car = "commit --amend --no-edit"; + cl = "!hub clone"; + co = "checkout"; + compare = "!hub compare"; + current-branch = "rev-parse --abbrev-ref HEAD"; + dc = "diff --color --word-diff --cached"; + df = "diff --color --word-diff"; + dup = "!git checkout develop && git fetch origin && echo && git sl develop..origin/develop && echo && git pull --quiet && git checkout -"; + fixup = "commit --fixup"; + issues = "!gh issue list --web"; + mup = "!git master-to-main-wrapper checkout %BRANCH% && git fetch origin && echo && git sl %BRANCH%..origin/%BRANCH% && echo && git pull --quiet && git checkout -"; + no-ff = "merge --no-ff"; + pl = "pull"; + prune = "remote prune origin"; + ps = "push"; + pulls = "!gh pr list --web"; + rbc = "rebase --continue"; + rdup = "!git dup && git rebase develop"; + remotes = "remote -v"; + repush = "!git pull --rebase && git push"; + ri = "rebase --interactive"; + rid = "!git rebase -i $(git merge-base develop HEAD)"; + rim = "!git rebase -i $(git master-to-main-wrapper merge-base %BRANCH% HEAD)"; + rip = "!git rebase -i $(git merge-base production HEAD)"; + ris = "!git rebase -i $(git merge-base staging HEAD)"; + riu = "!git rebase -i $(git rev-parse --abbrev-ref --symbolic-full-name @{u})"; + rmup = "!git mup && git master-to-main-wrapper rebase %BRANCH%"; + sl = "log --oneline --decorate -20"; + sla = "log --oneline --decorate --graph --all -20"; + slap = "log --oneline --decorate --graph --all"; + slp = "log --oneline --decorate"; + stash = "stash --included-untracked"; + unassume = "update-index --no-assume-unchanged"; + uncommit = "reset --soft HEAD^"; + unstage = "reset"; + update = "!git fetch --all --jobs=4 --prune --progress && git rebase --autostash --stat"; + upstream = "rev-parse --abbrev-ref --symbolic-full-name @{u}"; + ureset = "!git reset --hard $(git upstream)"; + worktrees = "worktree list"; + }; +} diff --git a/modules2/git/default-commit-message.nix b/modules2/git/default-commit-message.nix new file mode 100644 index 00000000..dfd1fe90 --- /dev/null +++ b/modules2/git/default-commit-message.nix @@ -0,0 +1,25 @@ +{ + flake.modules.homeManager.base = + { config, ... }: + { + home.file."${config.xdg.configHome}/git/message".text = '' + + + # Description + # + # - Why is this change necessary? + # - How does it address the issue? + # - What side effects does this change have? + # + # For breaking changes, uncomment the following line and describe the change: + # + # BREAKING CHANGE: + # + # + # Add any issue IDs or commit SHAs that this commit references: + # + # Refs: + + ''; + }; +} diff --git a/modules2/git/defaults.nix b/modules2/git/defaults.nix new file mode 100644 index 00000000..3af93d9f --- /dev/null +++ b/modules2/git/defaults.nix @@ -0,0 +1,64 @@ +{ config, ... }: + +let + cfg = config; +in +{ + flake.modules.homeManager.base = + { config, ... }: + { + programs.git = { + userName = cfg.flake.meta.owner.name; + userEmail = cfg.flake.meta.owner.email; + + extraConfig = { + branch = { + autosetupmerge = true; + autosetuprebase = "always"; + sort = "-committerdate"; + }; + + checkout.defaultRemote = "origin"; + color.ui = true; + column.ui = "auto"; + commit.template = "${config.xdg.configHome}/git/message"; + + core = { + editor = "nvim"; + excludesFile = "~/.config/git/ignore"; + }; + + diff.tool = "vimdiff"; + fetch.prune = true; + gpg.format = "ssh"; + grep.lineNumber = true; + help.autocorrect = "1"; + init.defaultBranch = "main"; + + maintenance = { + auto = false; + strategy = "incremental"; + }; + + merge.ff = "only"; + + push = { + autoSetupRemote = true; + default = "upstream"; + }; + + pull = { + ff = "only"; + rebase = true; + }; + + rebase = { + autosquash = true; + autostash = true; + }; + + user.signingkey = "~/.ssh/id_rsa.pub"; + }; + }; + }; +} diff --git a/modules2/git/enable.nix b/modules2/git/enable.nix new file mode 100644 index 00000000..da8cc9f0 --- /dev/null +++ b/modules2/git/enable.nix @@ -0,0 +1,3 @@ +{ + flake.modules.homeManager.base.programs.git.enable = true; +} diff --git a/modules2/git/extra-packages.nix b/modules2/git/extra-packages.nix new file mode 100644 index 00000000..6c610608 --- /dev/null +++ b/modules2/git/extra-packages.nix @@ -0,0 +1,13 @@ +{ + flake.modules.homeManager.base = + { pkgs, ... }: + { + home.packages = with pkgs; [ + git-exclude + git-extras + git-graph + git-trim + stable.git-instafix + ]; + }; +} diff --git a/modules2/git/ignores.nix b/modules2/git/ignores.nix new file mode 100644 index 00000000..00b04ffc --- /dev/null +++ b/modules2/git/ignores.nix @@ -0,0 +1,11 @@ +{ + flake.modules.homeManager.base.programs.git.ignores = [ + "/.ddev/providers/" + "/.direnv/" + "/.ignored/" + "/.issue-id" + "/.phpactor.json" + "/notes" + "/todo" + ]; +} diff --git a/modules2/git/variables.nix b/modules2/git/variables.nix new file mode 100644 index 00000000..e47ccb5f --- /dev/null +++ b/modules2/git/variables.nix @@ -0,0 +1,5 @@ +{ + flake.modules.homeManager.base.home.sessionVariables = { + GIT_INSTAFIX_UPSTREAM = "origin/main"; + }; +} diff --git a/modules2/owner.nix b/modules2/owner.nix index 399c83c2..c293caab 100644 --- a/modules2/owner.nix +++ b/modules2/owner.nix @@ -2,14 +2,21 @@ { flake = { - meta.owner.username = "opdavies"; + meta.owner = { + email = "oliver@oliverdavies.uk"; + name = "Oliver Davies"; + username = "opdavies"; + }; modules = { nixos.pc = { users.users.${config.flake.meta.owner.username} = { isNormalUser = true; initialPassword = lib.mkForce ""; - extraGroups = [ "input" "wheel" ]; + extraGroups = [ + "input" + "wheel" + ]; }; nix.settings.trusted-users = [ config.flake.meta.owner.username ];