mirror of
https://github.com/srid/nixos-config.git
synced 2025-12-26 15:04:59 +08:00
Factor out users and ssh keys in one place
This commit is contained in:
parent
421e5e6351
commit
485e559fe1
9 changed files with 39 additions and 24 deletions
|
|
@ -19,8 +19,7 @@ nix run
|
|||
- Clone this repo at `/etc/nixos`
|
||||
- Edit `flake.nix` and
|
||||
- add your Linux's hostname in the `nixosConfigurations` set, as well as
|
||||
- update `people.myself` to your desired username.
|
||||
- put your SSH keys in `./nixos/takemessh`
|
||||
- update `users.nix` to contain your user(s) information
|
||||
- Run `nix run`. That's it. Re-open your shell.
|
||||
- macOS:
|
||||
- Install Nix normally (multi-user)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,12 @@ let
|
|||
email = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
sshKeyPub = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
SSH public key
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
peopleSubmodule = lib.types.submodule {
|
||||
|
|
|
|||
11
flake.nix
11
flake.nix
|
|
@ -50,16 +50,7 @@
|
|||
|
||||
people = {
|
||||
myself = "srid";
|
||||
users = {
|
||||
srid = {
|
||||
name = "Sridhar Ratnakumar";
|
||||
email = "srid@srid.ca";
|
||||
};
|
||||
uday = {
|
||||
name = "Uday Kiran";
|
||||
email = "udaycruise2903@gmail.com";
|
||||
};
|
||||
};
|
||||
users = import ./users.nix;
|
||||
};
|
||||
|
||||
flake = {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ in
|
|||
inputs.agenix.nixosModule
|
||||
./caches
|
||||
./self-ide.nix
|
||||
./takemessh
|
||||
./ssh-authorize.nix
|
||||
./current-location.nix
|
||||
];
|
||||
};
|
||||
|
|
|
|||
18
nixos/ssh-authorize.nix
Normal file
18
nixos/ssh-authorize.nix
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{ config, pkgs, lib, flake, ... }:
|
||||
|
||||
{
|
||||
# Let me login
|
||||
users.users =
|
||||
let
|
||||
people = flake.config.people;
|
||||
myPubKey = people.users.${people.myself}.sshKeyPub;
|
||||
in
|
||||
{
|
||||
root.openssh.authorizedKeys.keys = [
|
||||
myPubKey
|
||||
];
|
||||
${people.myself}.openssh.authorizedKeys.keys = [
|
||||
myPubKey
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
{ config, pkgs, lib, flake, ... }:
|
||||
|
||||
{
|
||||
# Let me login
|
||||
users.users = {
|
||||
root.openssh.authorizedKeys.keys = [ (builtins.readFile ./id_rsa.pub) ];
|
||||
${flake.config.people.myself}.openssh.authorizedKeys.keys = [ (builtins.readFile ./id_rsa.pub) ];
|
||||
};
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCYQ003p7fB5ICQehLwhDBomY9WzkNBeijkSw9ADGU+ECrPakeIH3pntUWRJH1W93vKnLqpkn6HLGEXD9MCR0s98uhh8hT7uAYCxQTbEeKT3PYkfz3oe7XaR8rE601sds0ZyFwH7l8cvK97pGr+uhFXAaohiV6VqmLVXhManEjZZ8GfYWBD9BCmIJk43G3OGa5QYFeHqztprXaJNU5dFPv2Uq2C+L6EvfCfkK2OO1BLZgL+Rai5jjyy6k0fcfsxxd9BdGUwqDhcBeyTIzX9rePMugf/xD+6uNRxTU+vjVpGUtFOw6rpgmVyFv9mn3QMNdQBc5hYKVbIQwMNGTzGgcQv srid@nixos
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
let
|
||||
keys = [
|
||||
(builtins.readFile ../nixos/takemessh/id_rsa.pub)
|
||||
(import ../users.nix).srid.sshKeyPub
|
||||
(import ../systems/hetzner/ax41.info.nix).hostKeyPub
|
||||
];
|
||||
in
|
||||
|
|
|
|||
11
users.nix
Normal file
11
users.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
srid = {
|
||||
name = "Sridhar Ratnakumar";
|
||||
email = "srid@srid.ca";
|
||||
sshKeyPub = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCYQ003p7fB5ICQehLwhDBomY9WzkNBeijkSw9ADGU+ECrPakeIH3pntUWRJH1W93vKnLqpkn6HLGEXD9MCR0s98uhh8hT7uAYCxQTbEeKT3PYkfz3oe7XaR8rE601sds0ZyFwH7l8cvK97pGr+uhFXAaohiV6VqmLVXhManEjZZ8GfYWBD9BCmIJk43G3OGa5QYFeHqztprXaJNU5dFPv2Uq2C+L6EvfCfkK2OO1BLZgL+Rai5jjyy6k0fcfsxxd9BdGUwqDhcBeyTIzX9rePMugf/xD+6uNRxTU+vjVpGUtFOw6rpgmVyFv9mn3QMNdQBc5hYKVbIQwMNGTzGgcQv srid@nixos";
|
||||
};
|
||||
uday = {
|
||||
name = "Uday Kiran";
|
||||
email = "udaycruise2903@gmail.com";
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue