diff --git a/README.md b/README.md index 2eb5721..dfcee96 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/config.nix b/config.nix index ce9c0c9..772e0b7 100644 --- a/config.nix +++ b/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; }; }; } diff --git a/flake.nix b/flake.nix index c0cfaf4..15d942d 100644 --- a/flake.nix +++ b/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) diff --git a/home/git.nix b/home/git.nix index b804a03..5cd0427 100644 --- a/home/git.nix +++ b/home/git.nix @@ -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"; diff --git a/nix-darwin/default.nix b/nix-darwin/default.nix index 1247c64..fd7ad0f 100644 --- a/nix-darwin/default.nix +++ b/nix-darwin/default.nix @@ -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}; }) ]; }; diff --git a/nixos/default.nix b/nixos/default.nix index 8e13fcc..40daf63 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -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}; }) ]; }; diff --git a/uday.nix b/uday.nix deleted file mode 100644 index c2d9c63..0000000 --- a/uday.nix +++ /dev/null @@ -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"; - }) - ]; - }; -}