Simplify user config
parent
a07217278b
commit
6cf8344ed9
|
@ -3,15 +3,15 @@
|
|||
flake.darwinModules = {
|
||||
home =
|
||||
let
|
||||
inherit (config.users) me;
|
||||
inherit (config.me) username;
|
||||
in
|
||||
{
|
||||
home-manager.users.${me} = {
|
||||
home-manager.users.${username} = {
|
||||
imports = [ self.homeModules.darwin ];
|
||||
};
|
||||
users.users.${me} = {
|
||||
name = me;
|
||||
home = "/Users/${me}";
|
||||
users.users.${username} = {
|
||||
name = username;
|
||||
home = "/Users/${username}";
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -71,9 +71,9 @@
|
|||
inputs.pre-commit.flakeModule
|
||||
./darwin
|
||||
./home
|
||||
./me
|
||||
./nixos
|
||||
./templates
|
||||
./users
|
||||
];
|
||||
flake = {
|
||||
nixosConfigurations = {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
{ flake, ... }:
|
||||
let
|
||||
inherit (flake.config.users) me';
|
||||
inherit (flake.config) me;
|
||||
in
|
||||
{
|
||||
programs.git = {
|
||||
enable = true;
|
||||
|
||||
userEmail = me'.email;
|
||||
userName = me'.name;
|
||||
userEmail = me.email;
|
||||
userName = me.name;
|
||||
|
||||
extraConfig = {
|
||||
help.autocorrect = "prompt";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{ flake, pkgs, ... }:
|
||||
let
|
||||
inherit (flake.config.users) me me';
|
||||
inherit (flake.config) me;
|
||||
tomlFormat = pkgs.formats.toml { };
|
||||
in
|
||||
{
|
||||
|
@ -10,9 +10,9 @@ in
|
|||
# hardcode .config because pijul doesn't support XDG (yet?)
|
||||
".config/pijul/config.toml".source = tomlFormat.generate "pijul-config" {
|
||||
author = {
|
||||
name = me;
|
||||
full_name = me'.name;
|
||||
inherit (me') email;
|
||||
name = me.username;
|
||||
full_name = me.name;
|
||||
inherit (me) email;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
name = "sloane ess";
|
||||
username = "sloane";
|
||||
email = "sloane@sloane.lol";
|
||||
sshKeys = [
|
||||
# secretive
|
||||
"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBKTVoMVtHSvosU9SCam4S5RTP0R2V09vqw5Xiuff+x4J7NtUxsBhqIrkPSfJHSbYlBKITX5RFyFBo5mtsTa95v0= sloane"
|
||||
];
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
{ lib, ... }:
|
||||
let
|
||||
userSubmodule = lib.types.submodule {
|
||||
options = {
|
||||
name = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
full name
|
||||
'';
|
||||
};
|
||||
username = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
user account name
|
||||
'';
|
||||
};
|
||||
email = lib.mkOption { type = lib.types.str; };
|
||||
sshKeys = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
description = ''
|
||||
SSH public keys
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options.me = lib.mkOption { type = userSubmodule; };
|
||||
# TODO: currently multiplexing this on the work branch
|
||||
# how can we vary the config username based on the hostname?
|
||||
# e.g. https://github.com/srid/nixos-flake/discussions/22#discussioncomment-5909499
|
||||
config.me = import ./config.nix;
|
||||
}
|
|
@ -8,15 +8,15 @@
|
|||
|
||||
home =
|
||||
let
|
||||
inherit (config.users) me;
|
||||
inherit (config.me) username;
|
||||
in
|
||||
{
|
||||
home-manager.users.${me} = {
|
||||
home-manager.users.${username} = {
|
||||
imports = [ self.homeModules.linux ];
|
||||
};
|
||||
users.users.${me} = {
|
||||
name = me;
|
||||
home = "/home/${me}";
|
||||
users.users.${username} = {
|
||||
name = username;
|
||||
home = "/home/${username}";
|
||||
isNormalUser = true;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
# wipe out the registry for purity, cf. https://github.com/MatthewCroughan/nixcfg/commit/ce86bee2755127a4fdaca91e5e037d3fe625cba9
|
||||
flake-registry = builtins.toFile "empty-flake-registry.json" ''{"flakes":[],"version":2}'';
|
||||
trusted-users = [
|
||||
flake.config.users.me
|
||||
flake.config.me.username
|
||||
"root"
|
||||
"@admin"
|
||||
"@wheel"
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
# remote access
|
||||
users.users =
|
||||
let
|
||||
inherit (flake.config.users) me me';
|
||||
myKeys = me'.sshKeys;
|
||||
inherit (flake.config) me;
|
||||
myKeys = me.sshKeys;
|
||||
in
|
||||
{
|
||||
root.openssh.authorizedKeys.keys = myKeys;
|
||||
${me}.openssh.authorizedKeys.keys = myKeys;
|
||||
${me.username}.openssh.authorizedKeys.keys = myKeys;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
{
|
||||
me = "sloane";
|
||||
users = {
|
||||
sloane = {
|
||||
name = "sloane ess";
|
||||
username = "sloane";
|
||||
email = "sloane@sloane.lol";
|
||||
sshKeys = [
|
||||
# secretive
|
||||
"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBKTVoMVtHSvosU9SCam4S5RTP0R2V09vqw5Xiuff+x4J7NtUxsBhqIrkPSfJHSbYlBKITX5RFyFBo5mtsTa95v0= sloane"
|
||||
];
|
||||
};
|
||||
sloane-work = {
|
||||
name = "Sloane Ess";
|
||||
username = "sloane";
|
||||
email = "sloane@yelp.com";
|
||||
sshKeys = [
|
||||
# secretive
|
||||
"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLWD/lvxFOdmE48MUKdigYZOAc3bSIyPxW4M7frWe8Nks9cr58Z/1btvUUmAK+u+J6gw5g+Mt9X0uwR7KPQlavg= sloane"
|
||||
"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOkqyHm9fBDXChdmNgbhxd2U1IpkiD4xjC8AVOvil+uEeKYqDi5mF3oeAGYJrV6BRc7hEO+DQP60pN0wI5tMoYE= yelp"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
userSubmodule = lib.types.submodule {
|
||||
options = {
|
||||
name = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
full name
|
||||
'';
|
||||
};
|
||||
username = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
user account name
|
||||
'';
|
||||
};
|
||||
email = lib.mkOption { type = lib.types.str; };
|
||||
sshKeys = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
description = ''
|
||||
SSH public keys
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
usersSubmodule = lib.types.submodule {
|
||||
options = {
|
||||
users = lib.mkOption { type = lib.types.attrsOf userSubmodule; };
|
||||
me = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
The name of the user that represents me.
|
||||
|
||||
Admin user in all contexts.
|
||||
|
||||
Should be a key into the `users` attribute set.
|
||||
'';
|
||||
};
|
||||
me' = lib.mkOption {
|
||||
type = userSubmodule;
|
||||
description = ''
|
||||
The rest of the user data for `me`.
|
||||
'';
|
||||
readOnly = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
# TODO: can we hack in an assertion that `me` is a key in `users`?
|
||||
options.users = lib.mkOption { type = usersSubmodule; };
|
||||
config.users = (import ./config.nix) // {
|
||||
me' = lib.mkDefault config.users.users.${config.users.me};
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue