-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable git signing commits and ssh-agent service (#264)
1. [x] Manage git with home-manager 2. [x] Enable ssh commit sign with *.pub by #263 3. [x] Resolves #265 May relate to #262 in future --------- Signed-off-by: Kenichi Kamiya <[email protected]>
- Loading branch information
Showing
14 changed files
with
189 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
"strings" | ||
|
||
"golang.org/x/sys/unix" | ||
) | ||
|
||
// Exists for remember https://github.com/kachick/dotfiles/pull/264#discussion_r1289600371 | ||
|
||
// This script requires sudo execution | ||
|
||
func main() { | ||
// wsl.exe returns non English even in called on the VM https://github.com/microsoft/WSL/issues/9242 | ||
// And always having non ASCII, annoy to depend with the output :< | ||
uname := unix.Utsname{} | ||
err := unix.Uname(&uname) | ||
if err != nil { | ||
log.Fatalf("cannot get uname: %+v\n", err) | ||
} | ||
unameStr := "" | ||
// So here, using uname, as I understand it is same as `uname -r` | ||
for _, i8 := range uname.Release { | ||
unameStr += string(rune(int(i8))) | ||
} | ||
if !strings.Contains(unameStr, "microsoft-standard-WSL2") { | ||
log.Fatalf("Looks executed on non WSL systems: %s", unameStr) | ||
} | ||
|
||
const path = "/etc/wsl.conf" | ||
|
||
const systemdEnablingEntry = `[boot] | ||
systemd=true` | ||
|
||
wslConfigBytes, err := os.ReadFile(path) | ||
if err != nil && !os.IsNotExist(err) { | ||
log.Fatalf("%v\n", err) | ||
} | ||
|
||
wslConfig := "" | ||
|
||
if wslConfigBytes != nil { | ||
wslConfig = string(wslConfigBytes) + "\n" | ||
} | ||
|
||
if strings.Contains(wslConfig, "systemd") { | ||
log.Fatalf("Looks areleady exists the systemd config") | ||
} | ||
|
||
dirty := strings.Clone(wslConfig) | ||
|
||
dirty += fmt.Sprintln(systemdEnablingEntry) | ||
|
||
if dirty != wslConfig { | ||
err = os.WriteFile(path, []byte(dirty), os.ModePerm) | ||
if err != nil { | ||
log.Fatalf("failed - could you correctly run this with sudo? - %v\n", err) | ||
} | ||
|
||
fmt.Printf(`Done! Restart wsl.exe as follows in your Windows PowerShell | ||
wsl.exe --shutdown | ||
See https://learn.microsoft.com/ja-jp/windows/wsl/systemd for further detail | ||
`) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b h1:r+vk0EmXNmekl0S0BascoeeoHk/L7wmaW2QF90K+kYI= | ||
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= | ||
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= | ||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,71 @@ | ||
{ ... }: | ||
{ config, pkgs, ... }: | ||
|
||
# https://github.com/nix-community/home-manager/blob/master/modules/programs/lazygit.nix | ||
{ | ||
xdg.configFile."git/config".source = ../home/.config/git/config; | ||
# https://github.com/nix-community/home-manager/blob/master/modules/programs/git.nix | ||
# xdg will be used in home-manager: https://github.com/nix-community/home-manager/blob/7b8d43fbaf8450c30caaed5eab876897d0af891b/modules/programs/git.nix#L417-L418 | ||
programs.git = { | ||
enable = true; | ||
|
||
userEmail = "[email protected]"; | ||
userName = "Kenichi Kamiya"; | ||
|
||
aliases = { | ||
fixup = "commit --all --amend"; | ||
empty = "commit --allow-empty -m 'Add an empty commit'"; | ||
current = "symbolic-ref --short HEAD"; | ||
switch-default = "!git checkout main 2>/dev/null || git checkout master 2>/dev/null"; | ||
upstream = "!git remote | grep -E '^upstream$'|| git remote | grep -E '^origin$'"; | ||
duster = "remote update origin --prune"; | ||
refresh = "!git switch-default && git pull \"$(git upstream)\" \"$(git current)\""; | ||
all = "!git refresh && gh poi"; | ||
gui = "!lazygit"; | ||
}; | ||
|
||
extraConfig = { | ||
user = { | ||
# https://stackoverflow.com/questions/48065535/should-i-keep-gitconfigs-signingkey-private | ||
# TODO: Share code to get the path with ./ssh.nix | ||
signingkey = "${config.home.homeDirectory}/.ssh/id_ed25519.pub"; | ||
}; | ||
|
||
core = { | ||
editor = "vim"; | ||
quotepath = false; | ||
}; | ||
|
||
gpg = { | ||
format = "ssh"; | ||
}; | ||
|
||
commit = { | ||
# https://stackoverflow.com/questions/10161198/is-there-a-way-to-autosign-commits-in-git-with-a-gpg-key | ||
gpgsign = true; | ||
}; | ||
|
||
init = { | ||
defaultBranch = "main"; | ||
}; | ||
|
||
color = { | ||
ui = true; | ||
}; | ||
|
||
grep = { | ||
lineNumber = true; | ||
}; | ||
|
||
pull = { | ||
ff = "only"; | ||
}; | ||
|
||
credential = { | ||
"https://github.com".helper = "!${pkgs.gh}/bin/gh auth git-credential"; | ||
"https://gist.github.com".helper = "!${pkgs.gh}/bin/gh auth git-credential"; | ||
}; | ||
}; | ||
}; | ||
|
||
# https://github.com/nix-community/home-manager/blob/master/modules/programs/lazygit.nix | ||
programs.lazygit = { | ||
enable = true; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters