create people module

This commit is contained in:
Sridhar Ratnakumar 2022-12-03 14:40:11 -05:00
parent 5da95cf5d2
commit 3fc619bae1
7 changed files with 66 additions and 30 deletions

View file

@ -19,14 +19,14 @@ 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 `myUserName`.
- update `people.myself` to your desired username.
- Run `nix run`. That's it. Re-open your shell.
- macOS:
- Install Nix normally (multi-user)
- Install [nix-darwin](https://github.com/LnL7/nix-darwin)
- This will create a `~/.nixpkgs/darwin-configuration.nix`, but we do not need that.
- Clone this repo anywhere
- Edit `flake.nix` to update `myUserName`.
- Edit `flake.nix` to update `people.myself` to your desired username.
- Run `nix run`.[^cleanup] That's it. Re-open your shell.
[^cleanup]: You might have to `rm -rf /etc/nix/nix.conf`, so our flake.nix can do its thing.

View file

@ -1,9 +1,33 @@
{ config, lib, ... }:
let
userSubmodule = lib.types.submodule {
options = {
name = lib.mkOption {
type = lib.types.str;
};
email = lib.mkOption {
type = lib.types.str;
};
};
};
peopleSubmodule = lib.types.submodule {
options = {
users = lib.mkOption {
type = lib.types.attrsOf userSubmodule;
};
myself = lib.mkOption {
type = lib.types.str;
description = ''
The name of the user that represents myself.
'';
};
};
};
in
{
options = {
myUserName = lib.mkOption {
type = lib.types.str;
description = "The canonical (only) user to add to all systems.";
people = lib.mkOption {
type = peopleSubmodule;
};
};
}

View file

@ -40,7 +40,19 @@
./activate.nix
];
myUserName = "srid";
people = {
myself = "srid";
users = {
srid = {
name = "Sridhar Ratnakumar";
email = "srid@srid.ca";
};
uday = {
name = "Uday Kiran";
email = "udaycruise2903@gmail.com";
};
};
};
flake = {
# Configurations for Linux (NixOS) systems
nixosConfigurations = {
@ -49,8 +61,8 @@
[
./systems/hetzner/ax41.nix
./nixos/server/harden.nix
# Temporarily sharing with Uday.
(import ./uday.nix { inherit self; })
# I share my Hetzner server with other people who need it.
self.nixosModules.other-people
];
};
# Configurations for my only[^1] macOS machine (using nix-darwin)

View file

@ -1,12 +1,13 @@
{ userName, userEmail }:
{ pkgs, ... }:
{ user }:
{ pkgs, config, ... }:
{
home.packages = [ pkgs.git-lfs ];
programs.git = {
package = pkgs.gitAndTools.gitFull;
enable = true;
inherit userName userEmail;
userName = user.name;
userEmail = user.email;
aliases = {
co = "checkout";
ci = "commit";

View file

@ -30,13 +30,12 @@
self.darwinModules.default
../systems/darwin.nix
{
home-manager.users.${config.myUserName} = { pkgs, ... }: {
home-manager.users.${config.people.myself} = { pkgs, ... }: {
imports = [
self.homeModules.common-darwin
../home/shellcommon.nix
(import ../home/git.nix {
userName = "Sridhar Ratnakumar";
userEmail = "srid@srid.ca";
user = config.people.users.${config.people.myself};
})
];
};

View file

@ -18,6 +18,20 @@
};
})
];
other-people.imports = [
# Temporarily sharing with Uday.
{
users.users.uday.isNormalUser = true;
home-manager.users."uday" = {
imports = [
self.homeModules.common-linux
(import ../home/git.nix {
user = config.people.users.uday;
})
];
};
}
];
default.imports =
self.nixosModules.common.imports ++
self.nixosModules.home.imports ++
@ -35,13 +49,12 @@
modules = [
self.nixosModules.default
{
home-manager.users.${config.myUserName} = { pkgs, ... }: {
home-manager.users.${config.people.myself} = { pkgs, ... }: {
imports = [
self.homeModules.common-linux
../home/shellcommon.nix
(import ../home/git.nix {
userName = "Sridhar Ratnakumar";
userEmail = "srid@srid.ca";
user = config.people.users.${config.people.myself};
})
];
};

View file

@ -1,13 +0,0 @@
{ self }:
{
users.users.uday.isNormalUser = true;
home-manager.users."uday" = {
imports = [
self.homeModules.common-linux
(import ./home/git.nix {
userName = "Uday Kiran";
userEmail = "udaycruise2903@gmail.com";
})
];
};
}