Refactor pubkey configuration
This commit is contained in:
parent
acc9940043
commit
bdc1c12f9c
|
@ -23,6 +23,7 @@
|
|||
./network-manager.nix
|
||||
./office.nix
|
||||
./prometheus/node_exporter.nix
|
||||
./pubkeys.nix
|
||||
./pulseaudio.nix
|
||||
./restic.nix
|
||||
./ssd.nix
|
||||
|
|
|
@ -1,4 +1,31 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.sbruder.pubkeys;
|
||||
in
|
||||
{
|
||||
options.sbruder.pubkeys = {
|
||||
keys = lib.mkOption {
|
||||
type = lib.types.attrsOf lib.types.str;
|
||||
description = "Known public keys that can be used in the configuration";
|
||||
default = {
|
||||
"simon@nunotaba" = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCwMo0mYcTU1Y4BKpEUsvKAtcTPq3ylKaw+ZjUxNg9VqU5gDy2TDUfWk2FjM2VYcqQJ9ZaNGKE1S18fRU7ZHrcgtFPMgAuji87yOKojH74cwz9ZRf5ZiluWBmR3dFd7kddqHUKVS8utpiQuTLIyQwpgmUHA81IasWXuB2pHaI6HGntMlJTm1CvpcQvwKsDBqJ2bFjFMk6EDgAZWXyooQgthYAfmc+YfAX5T9fWKiqFnEJ0ryN3/RngJZe65HWV8WZwY1CxgKQhOZuRcPdkTEQlUk9Qu0JbVa2sTgdYDpw/Dz0ma+h4rxOrH63MD6Cf0pFgOwLeZVSmXqKTjXVaH1QkHWRat88J8Q6MM6LlhLx/48VcQshhIssAZ37YoW2W0NxnGSM7YtlwTVe+w7rU//cS5TyIQa4joq2pnIh4uurbNkIULa4Q2t2nEMzlqI9gEE9DK1ctOcuCyFOerNZD0yRZ5Rs8WouDLL1PR6ps4czK2N7h2MXABcELuVwX+sdxwFgf6AJaRvrlw4qIOohpeX48FhzZfcI9Cqvnakm+O42J3qXuUDVc6/NjE9zBku3dNaeseGv9CQxtvyVDq6o9MRDiFror3yEiN0Fwou7CXBfXrbeb7MvahsRxSKkSDY0uA+AXmsm1UwdArjEc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iPldXhbc13XiNC3mpNGCLFj+nh1feazk8TeAVDBps6xaDkOd+hDwTBQh8LoimePK7MiShzLvC38Vd/sim5ym/IqY634CjqBDGCMp1KXnqHUTT8CqeifMv10+aRJKUPevVkO3nEE3VoSPt7Ui9ZzLnL4qhZyygoBau+PvD2WCWm+gRwBkvU1uNrYKi4HIGhB/gXcYHKJimqJwLMyqG5Wv1jfuhn3ZZN+uNqTgdAznGgPRU1Q/Mx6nMEDiQip78qdYEc0YGwdb/TldEL6aHRjuNuZPpTW+zakQHiQTRb/0VdZT1bAwyT9yL0Uf40h706Kh/pKiSQ1yq1dlSdl3RlfedbqLqGjspds1iRSrSXyH2MBghPbz/SF7Vt4LW/tXF0rcyV7CU98ZvxJDWeN60OE0vPf/AT5udYyfPO1691y0F8jGKxGYYPg9R/Y5o7J24PbQ==";
|
||||
};
|
||||
};
|
||||
trustedNames = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
description = "Names of trusted public keys, used to generate <literal>sbruder.pubkeys.trustedKeys</literal>";
|
||||
default = [
|
||||
"simon@nunotaba"
|
||||
"simon@sayuri"
|
||||
];
|
||||
};
|
||||
trustedKeys = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
description = "Trusted public keys, automatically generated from <literal>sbruder.pubkeys.trustedNames</literal>";
|
||||
default = builtins.map
|
||||
(name: cfg.keys."${name}")
|
||||
cfg.trustedNames;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
{ ... }:
|
||||
let
|
||||
pubkeys = import ./pubkeys.nix;
|
||||
in
|
||||
{ config, ... }:
|
||||
{
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
|
@ -9,7 +6,5 @@ in
|
|||
passwordAuthentication = false;
|
||||
};
|
||||
|
||||
users.users.root.openssh.authorizedKeys.keys = [
|
||||
pubkeys."simon@nunotaba"
|
||||
];
|
||||
users.users.root.openssh.authorizedKeys.keys = config.sbruder.pubkeys.trustedKeys;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
{ config, pkgs, ... }:
|
||||
let
|
||||
pubkeys = import ../../modules/pubkeys.nix;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
(import "${builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/release-20.09.tar.gz"}/nixos")
|
||||
|
@ -19,10 +16,7 @@ in
|
|||
"video"
|
||||
"wheel"
|
||||
];
|
||||
openssh.authorizedKeys.keys = [
|
||||
pubkeys."simon@nunotaba"
|
||||
pubkeys."simon@sayuri"
|
||||
];
|
||||
openssh.authorizedKeys.keys = config.sbruder.pubkeys.trustedKeys;
|
||||
};
|
||||
|
||||
home-manager.useUserPackages = true;
|
||||
|
|
Loading…
Reference in a new issue