System, dynamic users for host, removes user.name
adds a new specialArg to hosts: usernameList, which is a list of users determined through user/user.nix in the host/hostname dir. This touches syncthing, tuigreet, jibril, shells, and system removes the user.name field, and converts user.timezone to system.timezone. This is to move user content off of the host. This old system is replaced with dynamic user creation based on the usernameList variable Because this removes the users.users.defaultUser shells now use the (more appropriate) users.defaultUserShell
This commit is contained in:
parent
6124a298eb
commit
d994e11918
8 changed files with 71 additions and 55 deletions
58
flake.nix
58
flake.nix
|
|
@ -17,18 +17,8 @@
|
|||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
fs = pkgs.lib.fileset;
|
||||
st = pkgs.lib.strings;
|
||||
as = pkgs.lib.attrsets;
|
||||
|
||||
hostConfig = hostname: hostpath: nixpkgs.lib.nixosSystem {
|
||||
specialArgs = {
|
||||
inherit inputs;
|
||||
inherit hostname;
|
||||
};
|
||||
system = system;
|
||||
modules = [
|
||||
./nixosModules
|
||||
hostpath
|
||||
];
|
||||
};
|
||||
hosts = let
|
||||
hostFilter = { name, ...}: name == "host.nix";
|
||||
hostPaths = fs.toList (fs.fileFilter hostFilter ./hosts);
|
||||
|
|
@ -43,17 +33,6 @@
|
|||
name = extractHostName path;
|
||||
}) hostPaths);
|
||||
|
||||
userConfig = usernameAtHostname: userpath: home-manager.lib.homeManagerConfiguration {
|
||||
inherit pkgs;
|
||||
extraSpecialArgs = {
|
||||
inherit inputs;
|
||||
inherit usernameAtHostname;
|
||||
};
|
||||
modules = [
|
||||
./hmModules
|
||||
userpath
|
||||
];
|
||||
};
|
||||
users = let
|
||||
userFilter = { name, ...}: name == "user.nix";
|
||||
userPaths = fs.toList (fs.fileFilter userFilter ./hosts);
|
||||
|
|
@ -70,6 +49,41 @@
|
|||
value = path;
|
||||
}
|
||||
) userPaths);
|
||||
|
||||
userConfig = usernameAtHostname: userpath: home-manager.lib.homeManagerConfiguration {
|
||||
inherit pkgs;
|
||||
extraSpecialArgs = {
|
||||
inherit inputs;
|
||||
inherit usernameAtHostname;
|
||||
};
|
||||
modules = [
|
||||
./hmModules
|
||||
userpath
|
||||
];
|
||||
};
|
||||
|
||||
hostConfig = hostname: hostpath: nixpkgs.lib.nixosSystem {
|
||||
specialArgs = let
|
||||
hostFilteredUsers = as.filterAttrs (
|
||||
name: value: let
|
||||
userHostname = builtins.elemAt (st.splitString "@" name) 1;
|
||||
in userHostname == hostname
|
||||
) users;
|
||||
|
||||
hostUsers = as.mapAttrsToList (
|
||||
name: value: builtins.elemAt (st.splitString "@" name) 0
|
||||
) hostFilteredUsers;
|
||||
in {
|
||||
inherit inputs;
|
||||
inherit hostname;
|
||||
"usernameList" = hostUsers;
|
||||
};
|
||||
system = system;
|
||||
modules = [
|
||||
./nixosModules
|
||||
hostpath
|
||||
];
|
||||
};
|
||||
in {
|
||||
nixosConfigurations = builtins.mapAttrs (name: path: hostConfig name path) hosts;
|
||||
homeConfigurations = builtins.mapAttrs (name: path: userConfig name path) users;
|
||||
|
|
|
|||
|
|
@ -22,8 +22,7 @@
|
|||
};
|
||||
};
|
||||
|
||||
user.name = "pan";
|
||||
user.timezone = "America/Los_Angeles";
|
||||
system.timezone = "America/Los_Angeles";
|
||||
|
||||
tuigreet.enable = true;
|
||||
hyprland.enable = true;
|
||||
|
|
@ -31,5 +30,4 @@
|
|||
librewolf.enable = true;
|
||||
fish.enable = true;
|
||||
fish.setDefault = true;
|
||||
syncthing.enable = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
config = lib.mkIf config.fish.enable {
|
||||
programs.fish.enable = true;
|
||||
users.users.defaultUser.shell = lib.mkIf config.fish.setDefault pkgs.fish;
|
||||
users.defaultUserShell = lib.mkIf config.fish.setDefault pkgs.fish;
|
||||
environment.shells = with pkgs; [ fish ];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
config = lib.mkIf config.xonsh.enable {
|
||||
programs.xonsh.enable = true;
|
||||
users.users.defaultUser.shell = lib.mkIf config.xonsh.setDefault pkgs.xonsh;
|
||||
users.defaultUserShell = lib.mkIf config.xonsh.setDefault pkgs.xonsh;
|
||||
environment.shells = with pkgs; [ xonsh ];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
histFile = "$HOME/.config/zsh/history";
|
||||
histSize = 2000;
|
||||
};
|
||||
users.users.defaultUser.shell = lib.mkIf config.zsh.setDefault pkgs.zsh;
|
||||
users.defaultUserShell = lib.mkIf config.zsh.setDefault pkgs.zsh;
|
||||
environment.shells = with pkgs; [ zsh ];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
{ config, lib, ... }:
|
||||
|
||||
{
|
||||
options = {
|
||||
|
|
@ -8,18 +8,18 @@
|
|||
config = lib.mkIf config.syncthing.enable {
|
||||
services.syncthing = {
|
||||
enable = true;
|
||||
user = config.user.name;
|
||||
dataDir = "/home/" + config.user.name + "/dox/Sync";
|
||||
configDir = "/home/" + config.user.name + "/.config/syncthing";
|
||||
overrideFolders = true;
|
||||
overrideDevices = true;
|
||||
|
||||
settings = {
|
||||
gui = {
|
||||
user = config.user.name;
|
||||
password = "password";
|
||||
};
|
||||
};
|
||||
# user = config.user.name;
|
||||
# dataDir = "/home/" + config.user.name + "/dox/Sync";
|
||||
# configDir = "/home/" + config.user.name + "/.config/syncthing";
|
||||
# overrideFolders = true;
|
||||
# overrideDevices = true;
|
||||
#
|
||||
# settings = {
|
||||
# gui = {
|
||||
# user = config.user.name;
|
||||
# password = "password";
|
||||
# };
|
||||
# };
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
};
|
||||
default_session = lib.mkIf config.hyprland.enable {
|
||||
command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd Hyprland";
|
||||
user = config.user.name;
|
||||
user = "greeter";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
{ config, inputs, pkgs, lib, hostname, ... }:
|
||||
{ config, inputs, pkgs, lib, hostname, usernameList, ... }:
|
||||
|
||||
{
|
||||
options = {
|
||||
user.name = lib.mkOption { default = "pan"; };
|
||||
user.timezone = lib.mkOption { default = "America/Los_Angeles"; };
|
||||
system.timezone = lib.mkOption { default = "America/Los_Angeles"; };
|
||||
system.extraFonts = lib.mkOption { default = []; };
|
||||
system.doAutoUpgrade = lib.mkEnableOption "Enable auto upgrading system";
|
||||
};
|
||||
|
|
@ -19,7 +18,7 @@
|
|||
nixpkgs.config.allowUnfree = true;
|
||||
system.stateVersion = "23.05";
|
||||
|
||||
time.timeZone = config.user.timezone;
|
||||
time.timeZone = config.system.timezone;
|
||||
|
||||
i18n.defaultLocale = "en_US.UTF-8";
|
||||
|
||||
|
|
@ -45,15 +44,20 @@
|
|||
};
|
||||
nix.settings.use-xdg-base-directories = true;
|
||||
|
||||
users.groups = {
|
||||
wheel = { };
|
||||
network = { };
|
||||
};
|
||||
|
||||
users.users.defaultUser = {
|
||||
name = config.user.name;
|
||||
isNormalUser = true;
|
||||
extraGroups = [ "wheel" "network" ];
|
||||
users = {
|
||||
users = builtins.listToAttrs (map (
|
||||
user: {
|
||||
name = user;
|
||||
value = {
|
||||
name = user;
|
||||
isNormalUser = true;
|
||||
};
|
||||
}
|
||||
) usernameList);
|
||||
groups = {
|
||||
wheel = { };
|
||||
network = { };
|
||||
};
|
||||
};
|
||||
|
||||
fonts = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue