diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/programs/git/default.nix | 3 | ||||
| -rw-r--r-- | modules/programs/pass/default.nix | 30 | ||||
| -rw-r--r-- | modules/programs/ssh/default.nix | 9 | ||||
| -rw-r--r-- | modules/programs/ssh/git.nix | 52 |
4 files changed, 55 insertions, 39 deletions
diff --git a/modules/programs/git/default.nix b/modules/programs/git/default.nix index 3d367df..305112f 100644 --- a/modules/programs/git/default.nix +++ b/modules/programs/git/default.nix @@ -1,7 +1,6 @@ { config, lib, - pkgs, ... }: @@ -22,8 +21,6 @@ }; config = lib.mkIf config.programs.git.enable { - home.packages = lib.mkIf config.programs.pass.enable [ pkgs.pass-git-helper ]; - programs.git = { settings = lib.recursiveUpdate diff --git a/modules/programs/pass/default.nix b/modules/programs/pass/default.nix index 0455d31..b7a8e2a 100644 --- a/modules/programs/pass/default.nix +++ b/modules/programs/pass/default.nix @@ -11,12 +11,6 @@ enable = lib.mkEnableOption "Enables pass."; package = lib.mkPackageOption pkgs "pass" { }; - - storeDir = lib.mkOption { - type = lib.types.str; - default = "${config.home.homeDirectory}/.password-store"; - description = "Path to the pass password store."; - }; }; config = lib.mkIf config.programs.pass.enable { @@ -24,30 +18,8 @@ enable = true; package = config.programs.pass.package; settings = { - PASSWORD_STORE_DIR = config.programs.pass.storeDir; + PASSWORD_STORE_DIR = "${config.home.homeDirectory}/.local/share/pass"; }; }; - - # home.file.".config/pass-git-helper/git-pass-mapping.ini".text = '' - # [github.com] - # target = github/token - # username = ${config.programs.pass.github.username} - # username_extractor = static - # - # [github.com/*] - # target = github/token - # username = ${config.programs.pass.github.username} - # username_extractor = static - # - # [*.github.com] - # target = github/token - # username = ${config.programs.pass.github.username} - # username_extractor = static - # - # [*.github.com/*] - # target = github/token - # username = ${config.programs.pass.github.username} - # username_extractor = static - # ''; }; } diff --git a/modules/programs/ssh/default.nix b/modules/programs/ssh/default.nix index 4b47256..7e8752a 100644 --- a/modules/programs/ssh/default.nix +++ b/modules/programs/ssh/default.nix @@ -7,6 +7,8 @@ # OpenSSH - Secure shell (SSH) client for encrypted remote connections { + imports = [ ./git.nix ]; + config = lib.mkIf config.programs.ssh.enable { programs.ssh = { package = pkgs.openssh; @@ -19,13 +21,6 @@ VisualHostKey = "yes"; HashKnownHosts = "yes"; }; - settings = { - "github.com" = { - hostname = "github.com"; - user = "git"; - identityFile = "${config.home.homeDirectory}/.ssh/github"; - }; - }; }; }; } diff --git a/modules/programs/ssh/git.nix b/modules/programs/ssh/git.nix new file mode 100644 index 0000000..de4fb40 --- /dev/null +++ b/modules/programs/ssh/git.nix @@ -0,0 +1,52 @@ +{ config, lib, ... }: + +let + homeDir = config.home.homeDirectory; + keyDir = "${homeDir}/.local/share/ssh/git"; + + hosts = [ + { + domain = "github.com"; + identityName = "github"; + } + { + domain = "gitlab.com"; + identityName = "gitlab"; + } + { + domain = "bitbucket.org"; + identityName = "bitbucket"; + } + { + domain = "codeberg.org"; + identityName = "codeberg"; + } + { + domain = "git.sr.ht"; + identityName = "sourcehut"; + } + ]; + + mkGitHost = + { domain, identityName }: + lib.nameValuePair domain { + hostname = domain; + user = "git"; + identityFile = "${keyDir}/${identityName}"; + }; + + mkKeyFile = + { identityName, ... }: + lib.nameValuePair identityName { + enable = true; + text = ""; + force = false; + }; +in +{ + config = lib.mkIf (config.programs.ssh.enable && config.programs.git.useSSH) { + home.file = builtins.listToAttrs (map mkKeyFile hosts); + + programs.ssh.settings = builtins.listToAttrs (map mkGitHost hosts); + }; +} |
