mirror of
https://github.com/DictXiong/dotfiles.git
synced 2026-11-23 20:38:16 +08:00
feat: verify signed updates and expose Nix values
Signed-off-by: Dict Xiong <me@dxng.cn>
This commit is contained in:
43
flake.nix
Normal file
43
flake.nix
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
description = "Reusable values from DictXiong's dotfiles";
|
||||
|
||||
outputs =
|
||||
{ self }:
|
||||
let
|
||||
files = {
|
||||
authorizedKeys = ./.ssh/authorized_keys2;
|
||||
authorizedCertificates = ./.eid/authorized_certificates;
|
||||
git = ./.gitconfig2;
|
||||
tmux = ./.tmux.conf2;
|
||||
vim = ./.vimrc2;
|
||||
zsh = ./.zshrc2;
|
||||
};
|
||||
authorizedKeys = builtins.filter (
|
||||
line: builtins.isString line && builtins.match "[[:blank:]]*(#.*)?" line == null
|
||||
) (builtins.split "\r?\n" (builtins.readFile files.authorizedKeys));
|
||||
in
|
||||
{
|
||||
lib = {
|
||||
inherit files;
|
||||
ssh = {
|
||||
inherit authorizedKeys;
|
||||
selectAuthorizedKeys =
|
||||
names:
|
||||
map (
|
||||
name:
|
||||
let
|
||||
matches = builtins.filter (
|
||||
key:
|
||||
builtins.match "[[:blank:]]*[^[:blank:]]+[[:blank:]]+[A-Za-z0-9+/=]+[[:blank:]]+(.*[^[:blank:]])[[:blank:]]*" key
|
||||
== [ name ]
|
||||
) authorizedKeys;
|
||||
in
|
||||
if builtins.length matches == 1 then
|
||||
builtins.head matches
|
||||
else
|
||||
throw "dotfiles: expected exactly one SSH authorized key with comment '${name}'"
|
||||
) names;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user