Skip to content

Commit

Permalink
Extract ssh identity management into separate module
Browse files Browse the repository at this point in the history
  • Loading branch information
rake5k committed Oct 14, 2023
1 parent dd56851 commit a0a1db2
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 21 deletions.
33 changes: 33 additions & 0 deletions home/programs/logseq/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{ config, lib, pkgs, ... }:

with lib;

let

cfg = config.custom.programs.logseq;

sshKey = "id_logseq";
sshPubKey = "${sshKey}.pub";

in

{
options = {
custom.programs.logseq = {
enable = mkEnableOption "Logseq";
};
};

config = mkIf cfg.enable {

custom = {
programs.ssh = {
enable = true;
identities = [ sshKey sshPubKey ];
};
roles.homeage.secrets = [ sshKey sshPubKey ];
};

home.packages = [ pkgs.logseq ];
};
}
36 changes: 36 additions & 0 deletions home/programs/ssh/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{ config, lib, pkgs, ... }:

with lib;

let

cfg = config.custom.programs.ssh;

inherit (config.custom.roles.homeage) secretsPath;
sshDirectory = ".ssh";
mkFileEntry = identity: {
name = "${sshDirectory}/${identity}";
value = { source = "${secretsPath}/${identity}"; };
};

in

{
options = {
custom.programs.ssh = {
enable = mkEnableOption "SSH client";

identities = mkOption {
type = with types; listOf str;
default = [ ];
description = "SSH identities managed by homeage";
};
};
};

config = mkIf cfg.enable {
custom.roles.homeage.secrets = cfg.identities;
home.file = listToAttrs (map mkFileEntry cfg.identities);
programs.ssh.enable = true;
};
}
38 changes: 20 additions & 18 deletions home/roles/desktop/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -88,26 +88,28 @@ in

config = mkIf cfg.enable {

custom.roles.desktop = {
cursors.enable = true;
grobi.enable = true;
gtk.enable = true;
redshift.enable = true;
terminal.enable = true;
xmonad.enable = true;
custom = {
programs.logseq.enable = true;
roles = {
desktop = {
cursors.enable = true;
grobi.enable = true;
gtk.enable = true;
redshift.enable = true;
terminal.enable = true;
xmonad.enable = true;
};
};
};

home = {
packages = with pkgs; [
gnome.pomodoro
logseq
mupdf
peek
gifski
xclip
xzoom
];
};
home.packages = with pkgs; [
gnome.pomodoro
mupdf
peek
gifski
xclip
xzoom
];

xsession = {
enable = true;
Expand Down
18 changes: 15 additions & 3 deletions home/roles/mobile/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ let
cfg = config.custom.roles.mobile;
username = "nix-on-droid";

logseqSshKey = "id_logseq";
logseqSshPubKey = "${logseqSshKey}.pub";

in

{
Expand All @@ -21,9 +24,18 @@ in
inherit username;
};

custom.base.non-nixos = {
enable = true;
installNix = false;
custom = {
base.non-nixos = {
enable = true;
installNix = false;
};

programs.ssh = {
enable = true;
identities = [ logseqSshKey logseqSshPubKey ];
};

roles.homeage.secrets = [ logseqSshKey logseqSshPubKey ];
};
};
}

0 comments on commit a0a1db2

Please sign in to comment.