mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-01-11 22:30:25 +01:00
feat: multi user
This commit is contained in:
64
flake.nix
64
flake.nix
@@ -38,39 +38,51 @@
|
||||
...
|
||||
}: {
|
||||
nixosConfigurations = {
|
||||
nixos-test = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
nixos-test = let
|
||||
username = "ryan";
|
||||
specialArgs = {inherit username;};
|
||||
in
|
||||
nixpkgs.lib.nixosSystem {
|
||||
inherit specialArgs;
|
||||
system = "x86_64-linux";
|
||||
|
||||
modules = [
|
||||
./hosts/nixos-test
|
||||
modules = [
|
||||
./hosts/nixos-test
|
||||
./users/${username}/nixos.nix
|
||||
|
||||
home-manager.nixosModules.home-manager
|
||||
{
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
home-manager.nixosModules.home-manager
|
||||
{
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
|
||||
home-manager.extraSpecialArgs = inputs;
|
||||
home-manager.users.ryan = import ./home;
|
||||
}
|
||||
];
|
||||
};
|
||||
home-manager.extraSpecialArgs = inputs // specialArgs;
|
||||
home-manager.users.${username} = import ./users/${username}/home.nix;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
msi-rtx4090 = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
msi-rtx4090 = let
|
||||
username = "suzi"; # another username for this machine
|
||||
specialArgs = {inherit username;};
|
||||
in
|
||||
nixpkgs.lib.nixosSystem {
|
||||
inherit specialArgs;
|
||||
system = "x86_64-linux";
|
||||
|
||||
modules = [
|
||||
./hosts/msi-rtx4090
|
||||
modules = [
|
||||
./hosts/msi-rtx4090
|
||||
./users/${username}/nixos.nix
|
||||
|
||||
home-manager.nixosModules.home-manager
|
||||
{
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
home-manager.nixosModules.home-manager
|
||||
{
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
|
||||
home-manager.extraSpecialArgs = inputs;
|
||||
home-manager.users.ryan = import ./home;
|
||||
}
|
||||
];
|
||||
};
|
||||
home-manager.extraSpecialArgs = inputs // specialArgs;
|
||||
home-manager.users.${username} = import ./users/${username}/home.nix;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,20 +1,9 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
|
||||
imports = [
|
||||
./fcitx5
|
||||
./i3
|
||||
./programs
|
||||
./rofi
|
||||
./shell
|
||||
];
|
||||
|
||||
{username, ...}: {
|
||||
# Home Manager needs a bit of information about you and the
|
||||
# paths it should manage.
|
||||
home = {
|
||||
username = "ryan";
|
||||
homeDirectory = "/home/ryan";
|
||||
inherit username;
|
||||
homeDirectory = "/home/${username}";
|
||||
|
||||
# This value determines the Home Manager release that your
|
||||
# configuration is compatible with. This helps avoid breakage
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
username,
|
||||
...
|
||||
}: {
|
||||
programs = {
|
||||
@@ -14,7 +15,7 @@
|
||||
|
||||
firefox = {
|
||||
enable = true;
|
||||
profiles.ryan = {};
|
||||
profiles.${username} = {};
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
programs.git = {
|
||||
enable = true;
|
||||
|
||||
userName = "Ryan Yin";
|
||||
userEmail = "xiaoyin_c@qq.com";
|
||||
# ... Other options ...
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,16 @@
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
username,
|
||||
...
|
||||
}: let
|
||||
username = "ryan";
|
||||
in {
|
||||
}: {
|
||||
# ============================= User related =============================
|
||||
|
||||
# Define a user account. Don't forget to set a password with ‘passwd’.
|
||||
users.users.ryan = {
|
||||
users.users.${username} = {
|
||||
isNormalUser = true;
|
||||
description = "ryan";
|
||||
description = username;
|
||||
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:
|
||||
# 1. `nixConfig.substituers` in `flake.nix`
|
||||
|
||||
22
users/ryan/home.nix
Normal file
22
users/ryan/home.nix
Normal 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
users/ryan/nixos.nix
Normal file
14
users/ryan/nixos.nix
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
##################################################################################################################
|
||||
#
|
||||
# NixOS Configuration
|
||||
#
|
||||
##################################################################################################################
|
||||
|
||||
users.users.ryan = {
|
||||
# Ryan's authorizedKeys
|
||||
openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJx3Sk20pLL1b2PPKZey2oTyioODrErq83xG78YpFBoj ryan@ryan"
|
||||
];
|
||||
};
|
||||
}
|
||||
22
users/suzi/home.nix
Normal file
22
users/suzi/home.nix
Normal 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
users/suzi/nixos.nix
Normal file
14
users/suzi/nixos.nix
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
##################################################################################################################
|
||||
#
|
||||
# NixOS Configuration
|
||||
#
|
||||
##################################################################################################################
|
||||
|
||||
users.users.suzi = {
|
||||
# Suzi's authorizedKeys
|
||||
openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJx3Sk20pLL1b2PPKZey2oTyioODrErq83xG78YpFBoj suzi@suzi"
|
||||
];
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user