mirror of
https://github.com/srid/nixos-config.git
synced 2025-12-26 15:04:59 +08:00
create people module
This commit is contained in:
parent
5da95cf5d2
commit
3fc619bae1
7 changed files with 66 additions and 30 deletions
|
|
@ -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.
|
||||
|
|
|
|||
30
config.nix
30
config.nix
|
|
@ -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;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
18
flake.nix
18
flake.nix
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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};
|
||||
})
|
||||
];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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};
|
||||
})
|
||||
];
|
||||
};
|
||||
|
|
|
|||
13
uday.nix
13
uday.nix
|
|
@ -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";
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue