mirror of
https://github.com/itme-brain/nixos.git
synced 2026-03-24 00:29:43 -04:00
added programmatic dynamic generation of user defined keys
This commit is contained in:
parent
18a94b74fb
commit
6ccfd709d0
10 changed files with 41 additions and 20 deletions
|
|
@ -7,7 +7,7 @@
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
extraGroups = config.user.groups
|
extraGroups = config.user.groups
|
||||||
++ [ "video" "audio" "kvm" "libvirtd" ];
|
++ [ "video" "audio" "kvm" "libvirtd" ];
|
||||||
openssh.authorizedKeys.keys = [ "${config.user.sshKeys.key2}" ];
|
openssh.authorizedKeys.keys = [ "${config.user.keys.ssh.android}" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
${config.user.name} = {
|
${config.user.name} = {
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
extraGroups = config.user.groups;
|
extraGroups = config.user.groups;
|
||||||
openssh.authorizedKeys.keys = [ "${config.user.sshKeys.key1}" ];
|
openssh.authorizedKeys.keys = [ "${config.user.keys.ssh.primary}" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
${config.user.name} = {
|
${config.user.name} = {
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
extraGroups = config.user.groups;
|
extraGroups = config.user.groups;
|
||||||
openssh.authorizedKeys.keys = [ "${config.user.sshKeys.key1}" ];
|
openssh.authorizedKeys.keys = [ "${config.user.keys.ssh.primary}" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
${config.user.name} = {
|
${config.user.name} = {
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
extraGroups = config.user.groups;
|
extraGroups = config.user.groups;
|
||||||
openssh.authorizedKeys.keys = config.user.sshKeys.key1;
|
openssh.authorizedKeys.keys = [ "${config.user.keys.ssh.primary}" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
boot.isContainer = true;
|
boot.isContainer = true;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
gpg = config.modules.user.security.gpg;
|
modules = config.modules.user;
|
||||||
|
|
||||||
userConfigs = rec {
|
userConfigs = rec {
|
||||||
name = "bryan";
|
name = "bryan";
|
||||||
|
|
@ -14,24 +14,16 @@ userConfigs = rec {
|
||||||
|
|
||||||
groups = [ "wheel" "networkmanager" "home-manager" "input" ];
|
groups = [ "wheel" "networkmanager" "home-manager" "input" ];
|
||||||
|
|
||||||
gitConfig = {
|
keys = import ./keys;
|
||||||
|
|
||||||
|
gitConfig = optionalAttrs modules.git.enable {
|
||||||
userName = "Bryan Ramos";
|
userName = "Bryan Ramos";
|
||||||
userEmail = email;
|
userEmail = email;
|
||||||
signing = optionalAttrs gpg.enable {
|
signing = optionalAttrs modules.security.gpg.enable {
|
||||||
key = "F1F3466458452B2DF351F1E864D12BA95ACE1F2D";
|
key = "F1F3466458452B2DF351F1E864D12BA95ACE1F2D";
|
||||||
signByDefault = true;
|
signByDefault = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
pgpKey = {
|
|
||||||
text = import ./keys/pgpKey.nix;
|
|
||||||
trust = 5;
|
|
||||||
};
|
|
||||||
|
|
||||||
sshKeys = {
|
|
||||||
key1 = import ./keys/sshKey1.nix;
|
|
||||||
key2 = import ./keys/sshKey2.nix;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
|
||||||
26
src/user/configs/keys/default.nix
Normal file
26
src/user/configs/keys/default.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
with builtins;
|
||||||
|
let
|
||||||
|
extractName = string:
|
||||||
|
let
|
||||||
|
metadata = [
|
||||||
|
"pub" "public" "priv" "private"
|
||||||
|
"key" "file" "." "_" "-" "pk"
|
||||||
|
];
|
||||||
|
in
|
||||||
|
replaceStrings metadata (builtins.map (_: "") metadata) string;
|
||||||
|
|
||||||
|
constructKeys = dir: (
|
||||||
|
listToAttrs (
|
||||||
|
map (subdir: {
|
||||||
|
name = subdir;
|
||||||
|
value = listToAttrs (
|
||||||
|
map (file: {
|
||||||
|
name = extractName file;
|
||||||
|
value = readFile "${dir}/${subdir}/${file}";
|
||||||
|
}) (filter (node: (readDir "${dir}/${subdir}").${node} == "regular") (attrNames (readDir "${dir}/${subdir}")))
|
||||||
|
);
|
||||||
|
}) (filter (node: (readDir dir).${node} == "directory") (attrNames (readDir dir)))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
in
|
||||||
|
constructKeys ./.
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
''
|
|
||||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
|
|
||||||
mQINBGP0BgMBEAC2v+n9plI0p+TqIrmvz7JHoYbtUK3NDkyNeIsgS+sE5nfLB1Ef
|
mQINBGP0BgMBEAC2v+n9plI0p+TqIrmvz7JHoYbtUK3NDkyNeIsgS+sE5nfLB1Ef
|
||||||
|
|
@ -108,4 +107,3 @@ OEpwdDwa67AtzYKG0ssOJI+po9TlbKYS4O4H8XnPhYSOEw8eObNPYCX7jyAjXloo
|
||||||
1hbflYLyMYo1BxGR6bPS9gJA2w==
|
1hbflYLyMYo1BxGR6bPS9gJA2w==
|
||||||
=5uun
|
=5uun
|
||||||
-----END PGP PUBLIC KEY BLOCK-----
|
-----END PGP PUBLIC KEY BLOCK-----
|
||||||
''
|
|
||||||
|
|
@ -9,7 +9,12 @@ in
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
programs.gpg = {
|
programs.gpg = {
|
||||||
enable = true;
|
enable = true;
|
||||||
publicKeys = [ config.user.pgpKey ];
|
publicKeys = [
|
||||||
|
{
|
||||||
|
text = "${config.user.keys.pgp.primary}";
|
||||||
|
trust = 5;
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
services.gpg-agent = {
|
services.gpg-agent = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue