feat: multi user

This commit is contained in:
Ryan Yin
2024-08-16 10:33:07 +08:00
parent 42bcfeb47c
commit adc91138c5
9 changed files with 122 additions and 53 deletions
+38 -26
View File
@@ -38,39 +38,51 @@
... ...
}: { }: {
nixosConfigurations = { nixosConfigurations = {
nixos-test = nixpkgs.lib.nixosSystem { nixos-test = let
system = "x86_64-linux"; username = "ryan";
specialArgs = {inherit username;};
in
nixpkgs.lib.nixosSystem {
inherit specialArgs;
system = "x86_64-linux";
modules = [ modules = [
./hosts/nixos-test ./hosts/nixos-test
./users/${username}/nixos.nix
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
{ {
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = inputs; home-manager.extraSpecialArgs = inputs // specialArgs;
home-manager.users.ryan = import ./home; home-manager.users.${username} = import ./users/${username}/home.nix;
} }
]; ];
}; };
msi-rtx4090 = nixpkgs.lib.nixosSystem { msi-rtx4090 = let
system = "x86_64-linux"; username = "suzi"; # another username for this machine
specialArgs = {inherit username;};
in
nixpkgs.lib.nixosSystem {
inherit specialArgs;
system = "x86_64-linux";
modules = [ modules = [
./hosts/msi-rtx4090 ./hosts/msi-rtx4090
./users/${username}/nixos.nix
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
{ {
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = inputs; home-manager.extraSpecialArgs = inputs // specialArgs;
home-manager.users.ryan = import ./home; home-manager.users.${username} = import ./users/${username}/home.nix;
} }
]; ];
}; };
}; };
}; };
} }
+3 -14
View File
@@ -1,20 +1,9 @@
{ config, pkgs, ... }: {username, ...}: {
{
imports = [
./fcitx5
./i3
./programs
./rofi
./shell
];
# Home Manager needs a bit of information about you and the # Home Manager needs a bit of information about you and the
# paths it should manage. # paths it should manage.
home = { home = {
username = "ryan"; inherit username;
homeDirectory = "/home/ryan"; homeDirectory = "/home/${username}";
# This value determines the Home Manager release that your # This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage # configuration is compatible with. This helps avoid breakage
+3 -2
View File
@@ -1,6 +1,7 @@
{ {
pkgs, pkgs,
config, config,
username,
... ...
}: { }: {
programs = { programs = {
@@ -14,7 +15,7 @@
firefox = { firefox = {
enable = true; enable = true;
profiles.ryan = {}; profiles.${username} = {};
}; };
}; };
} }
+2 -3
View File
@@ -7,7 +7,6 @@
programs.git = { programs.git = {
enable = true; enable = true;
userName = "Ryan Yin"; # ... Other options ...
userEmail = "xiaoyin_c@qq.com";
}; };
} }
+4 -8
View File
@@ -1,20 +1,16 @@
{ {
pkgs, pkgs,
lib, lib,
username,
... ...
}: let }: {
username = "ryan";
in {
# ============================= User related ============================= # ============================= User related =============================
# Define a user account. Don't forget to set a password with passwd. # Define a user account. Don't forget to set a password with passwd.
users.users.ryan = { users.users.${username} = {
isNormalUser = true; isNormalUser = true;
description = "ryan"; description = username;
extraGroups = ["networkmanager" "wheel"]; extraGroups = ["networkmanager" "wheel"];
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJx3Sk20pLL1b2PPKZey2oTyioODrErq83xG78YpFBoj admin@ryan-MBP"
];
}; };
# given the users in this list the right to specify additional substituters via: # given the users in this list the right to specify additional substituters via:
# 1. `nixConfig.substituers` in `flake.nix` # 1. `nixConfig.substituers` in `flake.nix`
+22
View File
@@ -0,0 +1,22 @@
{pkgs, ...}: {
##################################################################################################################
#
# All Ryan's Home Manager Configuration
#
##################################################################################################################
imports = [
../../home/core.nix
../../home/fcitx5
../../home/i3
../../home/programs
../../home/rofi
../../home/shell
];
programs.git = {
userName = "Ryan Yin";
userEmail = "xiaoyin_c@qq.com";
};
}
+14
View File
@@ -0,0 +1,14 @@
{
##################################################################################################################
#
# NixOS Configuration
#
##################################################################################################################
users.users.ryan = {
# Ryan's authorizedKeys
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJx3Sk20pLL1b2PPKZey2oTyioODrErq83xG78YpFBoj ryan@ryan"
];
};
}
+22
View File
@@ -0,0 +1,22 @@
{pkgs, ...}: {
##################################################################################################################
#
# All Suzi's Home Manager Configuration
#
##################################################################################################################
imports = [
../../home/core.nix
./fcitx5
./i3
./programs
./rofi
./shell
];
programs.git = {
userName = "Suzi";
userEmail = "suzi@writefor.fun";
};
}
+14
View File
@@ -0,0 +1,14 @@
{
##################################################################################################################
#
# NixOS Configuration
#
##################################################################################################################
users.users.suzi = {
# Suzi's authorizedKeys
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJx3Sk20pLL1b2PPKZey2oTyioODrErq83xG78YpFBoj suzi@suzi"
];
};
}