Skip to content
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5817fe7
WIP
kachick Aug 9, 2023
302039d
Translate git config with home-manager and add ssh siginign
kachick Aug 9, 2023
9e88958
Add an empty commit
kachick Aug 9, 2023
355c8cb
Test commit sign with empty commit
kachick Aug 9, 2023
66bfec7
Test commit sign with empty commit
kachick Aug 9, 2023
c694ee9
Test commit sign with empty commit
kachick Aug 9, 2023
de766dd
Always sign for commits
kachick Aug 9, 2023
3cd9350
Enable IdentitiesOnly in ssh
kachick Aug 9, 2023
59d1a79
Is this actually enabling?
kachick Aug 9, 2023
f7d83aa
Enable openssh package again
kachick Aug 9, 2023
d80ca8b
Bump home-manager
kachick Aug 9, 2023
1e2fab1
Need to bump also pkgs
kachick Aug 9, 2023
2a0ee52
Test commit sign with empty commit
kachick Aug 9, 2023
c65d753
Test commit sign with empty commit
kachick Aug 9, 2023
e77c8b2
Test commit sign with empty commit
kachick Aug 9, 2023
88b70dc
Fix for mac
kachick Aug 9, 2023
a86c6ae
Manage gnome-keyring
kachick Aug 10, 2023
0a9b27f
Specify conponents
kachick Aug 10, 2023
fd259b3
Is this the answer for services?
kachick Aug 10, 2023
b1f640b
Fix merge miss
kachick Aug 10, 2023
e966da7
Using keychain looks fixed the problems, but makes 2x slower shell ex…
kachick Aug 10, 2023
366e9fa
Revert "Using keychain looks fixed the problems, but makes 2x slower …
kachick Aug 10, 2023
12a0962
Add script to remember WSL systemd problems
kachick Aug 10, 2023
4732d2d
Remove unintended appended whitspaces
kachick Aug 10, 2023
48faafb
Remove unused gnome-keyring
kachick Aug 10, 2023
e477796
Run development tasks in both macOS and Linux
kachick Aug 10, 2023
53b4432
Avoid to use uname syscall for macOS
kachick Aug 10, 2023
9183192
Suppress new nixpkgs alerts as non default exe
kachick Aug 10, 2023
589c238
Revert "Is this the answer for services?"
kachick Aug 10, 2023
9cba602
Test commit sign with empty commit
kachick Aug 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci-home.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- ubuntu-22.04
- macos-13
home-manager-channel-ref:
- 729ab77f9e998e0989fa30140ecc91e738bc0cb1 # Pinned for current use
- a8f8f48320c64bd4e3a266a850bbfde2c6fe3a04 # Pinned for current use
- master # unstable nixpkgs

runs-on: ${{ matrix.os }}
Expand All @@ -36,7 +36,7 @@ jobs:
- uses: DeterminateSystems/magic-nix-cache-action@v2
- name: Register Nix Channels
run: |
nix-channel --add https://releases.nixos.org/nixpkgs/nixpkgs-23.11pre509044.3acb5c4264c4/nixexprs.tar.xz nixpkgs
nix-channel --add https://releases.nixos.org/nixpkgs/nixpkgs-23.11pre511546.844ffa82bbe2/nixexprs.tar.xz nixpkgs
nix-channel --add https://github.com/nix-community/home-manager/archive/${{ matrix.home-manager-channel-ref }}.tar.gz home-manager
nix-channel --update
nix-channel --list
Expand Down
19 changes: 18 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
rec {
devShells.default = with pkgs;
mkShell {
buildInputs = [
Expand All @@ -36,6 +36,23 @@
jq
];
};

# https://gist.github.com/Scoder12/0538252ed4b82d65e59115075369d34d?permalink_comment_id=4650816#gistcomment-4650816
packages.json2nix = pkgs.writeScriptBin "json2nix" ''
${pkgs.python3}/bin/python ${pkgs.fetchurl {
url = "https://gist.githubusercontent.com/Scoder12/0538252ed4b82d65e59115075369d34d/raw/e86d1d64d1373a497118beb1259dab149cea951d/json2nix.py";
hash = "sha256-ROUIrOrY9Mp1F3m+bVaT+m8ASh2Bgz8VrPyyrQf9UNQ=";
}} $@
'';

apps = {
# nix run .#json2nix
json2nix = {
type = "app";
program = "${packages.json2nix}/bin/json2nix";
};
};
}
);
}

1 change: 1 addition & 0 deletions home-manager/bash.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
programs.zoxide.enableBashIntegration = true;
programs.fzf.enableBashIntegration = true;
programs.rtx.enableBashIntegration = true;
programs.keychain.enableBashIntegration = true;

# Used only in bash - https://unix.stackexchange.com/a/689403
# https://github.com/nix-community/home-manager/blob/master/modules/programs/readline.nix
Expand Down
1 change: 1 addition & 0 deletions home-manager/fish.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
programs.zoxide.enableFishIntegration = true;
programs.fzf.enableFishIntegration = true;
programs.rtx.enableFishIntegration = true;
programs.keychain.enableFishIntegration = true;

xdg.configFile."fish/fish_variables".source = ../home/.config/fish/fish_variables;
xdg.configFile."fish/functions/fish_prompt.fish".source = ../home/.config/fish/functions/fish_prompt.fish;
Expand Down
68 changes: 65 additions & 3 deletions home-manager/git.nix
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 = "kachick1@gmail.com";
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;

Expand Down
2 changes: 2 additions & 0 deletions home-manager/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# TODO: How to cover lima? The default is /home/kachick.local
home.homeDirectory = if pkgs.stdenv.isDarwin then "/Users/${config.home.username}" else "/home/${config.home.username}";

systemd.user.startServices = "sd-switch";

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes following error after several changes, I know nothing about them 🤷‍♂️

thread 'main' panicked at 'Error switching: Failed to connect to socket /run/user/1000/bus


# https://github.com/nix-community/home-manager/blob/master/modules/misc/xdg.nix
xdg.enable = true;

Expand Down
11 changes: 7 additions & 4 deletions home-manager/packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
# Required in many asdf plugins
unzip

# In macOS, starting ssh-agent is still /usr/bin/ssh-agent even added the nixpkgs
# So avoiding to add it for now
# openssh

git
tig
lazygit
Expand Down Expand Up @@ -97,6 +93,13 @@
[
# Fix missing locales as `locale: Cannot set LC_CTYPE to default locale`
glibc

# https://github.com/nix-community/home-manager/blob/a8f8f48320c64bd4e3a266a850bbfde2c6fe3a04/modules/services/ssh-agent.nix#L37
openssh

# gnome3.gnome-keyring

keychain
]
) ++ (lib.optionals stdenv.isDarwin
[
Expand Down
20 changes: 20 additions & 0 deletions home-manager/ssh.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@ let
# - id_*.pub: I CAN register them for different services.
in
{
# https://github.com/nix-community/home-manager/blob/master/modules/services/ssh-agent.nix
services.ssh-agent.enable = if pkgs.stdenv.isLinux then true else false;

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://unix.stackexchange.com/a/390631

> bat ~/.config/systemd/user/ssh-agent.service
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: /home/kachick/.config/systemd/user/ssh-agent.service
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ [Install]
   2   │ WantedBy=default.target
   3   │
   4   │ [Service]
   5   │ ExecStart=/nix/store/11p34v2dfzjavry4kmwlp4d8jhjz4c6c-openssh-9.3p2/bin/ssh-agent -D -a %t/ssh-agent
   6   │
   7   │ [Unit]
   8   │ Description=SSH authentication agent
   9   │ Documentation=man:ssh-agent(1)

Already exists 🤔

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After it

> ps -ef | grep ssh
kachick      516     504  0 15:06 ?        00:00:00 /nix/store/11p34v2dfzjavry4kmwlp4d8jhjz4c6c-openssh-9.3p2/bin/ssh-agent -D -a /run/user/1000/ssh-agent
kachick     1225     652  0 15:07 pts/0    00:00:00 grep ssh


# # https://github.com/nix-community/home-manager/blob/master/modules/services/gnome-keyring.nix
# services.gnome-keyring = {
# enable = if pkgs.stdenv.isLinux then true else false;

# components = [ "ssh" "secrets" "pkcs11" ];
# };

# https://github.com/nix-community/home-manager/blob/master/modules/programs/keychain.nix
programs.keychain = {
enable = true;
# https://github.com/nix-community/home-manager/blob/a8f8f48320c64bd4e3a266a850bbfde2c6fe3a04/modules/programs/keychain.nix#L35
keys = [ "id_ed25519" ];
};

# These hosts are taken from the public resources of each provider.
# - https://docs.github.com/ja/authentication/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints
# - https://docs.gitlab.com/ee/user/gitlab_com/#ssh-known_hosts-entries
Expand Down Expand Up @@ -70,16 +87,19 @@ in
matchBlocks = {
"github.com" = {
identityFile = "${sshDir}/id_ed25519";
identitiesOnly = true;
user = "git";
};

"gitlab.com" = {
identityFile = "${sshDir}/id_ed25519";
identitiesOnly = true;
user = "git";
};

"bitbucket.org" = {
identityFile = "${sshDir}/id_ed25519";
identitiesOnly = true;
user = "git";
};
};
Expand Down
1 change: 1 addition & 0 deletions home-manager/zsh.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
programs.zoxide.enableZshIntegration = true;
programs.fzf.enableZshIntegration = true;
programs.rtx.enableZshIntegration = true;
programs.keychain.enableZshIntegration = true;

# https://nixos.wiki/wiki/Zsh
# https://github.com/nix-community/home-manager/blob/master/modules/programs/zsh.nix
Expand Down
32 changes: 0 additions & 32 deletions home/.config/git/config

This file was deleted.

4 changes: 2 additions & 2 deletions home/.local/share/homemade/bin/add_nix_channels.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ set -euxo pipefail
# List of official resources:
# - https://channels.nixos.org
# - https://releases.nixos.org
nix-channel --add https://releases.nixos.org/nixpkgs/nixpkgs-23.11pre509044.3acb5c4264c4/nixexprs.tar.xz nixpkgs
nix-channel --add https://releases.nixos.org/nixpkgs/nixpkgs-23.11pre511546.844ffa82bbe2/nixexprs.tar.xz nixpkgs
# nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs-unstable
# nix-channel --add https://github.com/nix-community/home-manager/archive/release-23.05.tar.gz home-manager
nix-channel --add https://github.com/nix-community/home-manager/archive/729ab77f9e998e0989fa30140ecc91e738bc0cb1.tar.gz home-manager
nix-channel --add https://github.com/nix-community/home-manager/archive/a8f8f48320c64bd4e3a266a850bbfde2c6fe3a04.tar.gz home-manager
nix-channel --update

nix-channel --list