almost there for multiple users????

This commit is contained in:
Chris Kruining 2025-03-23 20:27:14 +01:00
parent f40207c455
commit ce69116c39
Signed by: chris
SSH key fingerprint: SHA256:nG82MUfuVdRVyCKKWqhY+pCrbz9nbX6uzUns4RKa1Pg
8 changed files with 68 additions and 50 deletions

22
lib/_root.nix Normal file
View file

@ -0,0 +1,22 @@
args@{ self, inputs, lib, pkgs, system ? "", config, options, ... }: let
inherit (lib.my) mapModulesRec';
in
{
imports = [
# (import ../modules/home/shell/default.nix (args // { user = "root"; }))
]
++(mapModulesRec' ../modules/home (file: (import file (args // { user = "root"; }))));
config = {
modules.root = {
user = {
full_name = "__ROOT__";
email = "__ROOT__@${config.networking.hostName}";
};
shell = {
default = "zsh";
};
};
};
}

View file

@ -11,7 +11,7 @@ in rec
mapFilterAttrs (n: v: v != null && !(hasPrefix "_" n)) (n: v: let path = "${toString dir}/${n}"; in mapFilterAttrs (n: v: v != null && !(hasPrefix "_" n)) (n: v: let path = "${toString dir}/${n}"; in
if v == "directory" && pathExists "${path}/default.nix" if v == "directory" && pathExists "${path}/default.nix"
then nameValuePair n (fn path) then nameValuePair n (fn path)
else if v == "regular" && n != "default.nix" && hasSuffix ".nix" n else if v == "regular" && n != "default.nix" && hasSuffix ".nix" n && !(hasPrefix "_" n)
then nameValuePair (removeSuffix ".nix" n) (fn path) then nameValuePair (removeSuffix ".nix" n) (fn path)
else nameValuePair "" null else nameValuePair "" null
) (readDir dir); ) (readDir dir);

View file

@ -6,8 +6,8 @@ args@{
... ...
}: let }: let
inherit (inputs.nixpkgs.lib) nixosSystem; inherit (inputs.nixpkgs.lib) nixosSystem;
inherit (builtins) baseNameOf elem map mapAttrs; inherit (builtins) baseNameOf elem map listToAttrs;
inherit (lib) filterAttrs attrValues attrNames; inherit (lib) filterAttrs nameValuePair attrNames;
inherit (lib.modules) mkAliasOptionModule mkDefault mkIf; inherit (lib.modules) mkAliasOptionModule mkDefault mkIf;
inherit (lib.strings) removeSuffix; inherit (lib.strings) removeSuffix;
inherit (self.modules) mapModules mapModulesRec'; inherit (self.modules) mapModules mapModulesRec';
@ -38,6 +38,7 @@ in rec
imports = [ imports = [
inputs.home-manager.nixosModules.home-manager inputs.home-manager.nixosModules.home-manager
"${path}/hardware.nix" "${path}/hardware.nix"
./_root.nix
] ]
++ (mapModulesRec' ../modules/system import); ++ (mapModulesRec' ../modules/system import);
@ -47,13 +48,13 @@ in rec
}; };
home-manager = { home-manager = {
backupFileExtension = "bak";
useGlobalPkgs = true; useGlobalPkgs = true;
useUserPackages = true;
sharedModules = [ sharedModules = [
inputs.plasma-manager.homeManagerModules.plasma-manager inputs.plasma-manager.homeManagerModules.plasma-manager
]; ];
users = mapModules "${path}/users" (p: mkHmUser p { inherit inputs lib options config system pkgs self stateVersion; }); users = listToAttrs (map (user: (nameValuePair user { home = { inherit stateVersion; }; })) (users ++ [ "root" ]));
}; };
}) })
(filterAttrs (n: v: !elem n ["system"]) attrs) (filterAttrs (n: v: !elem n ["system"]) attrs)

View file

@ -16,14 +16,11 @@ in rec
group = "users"; group = "users";
}; };
mkHmUser = path: args@{stateVersion, ...}: let mkHmUser = path: {stateVersion, ...}:
name = removeSuffix ".nix" (baseNameOf path); {
in home = {
{ inherit stateVersion;
# imports = (mapModulesRec' ../modules/home (file: import file (args // { user = name; }))); sessionPath = [ "$XDG_BIN_HOME" "$PATH" ]; # Pretty sure I don't need this.
home = {
inherit stateVersion;
sessionPath = [ "$XDG_BIN_HOME" "$PATH" ]; # Pretty sure I don't need this.
};
}; };
};
} }

View file

@ -12,27 +12,17 @@ in
home-manager.users.${user}.programs.starship = { home-manager.users.${user}.programs.starship = {
enable = true; enable = true;
settings = { settings = {
scan_timeout = 10; format = "[](bold green) $username@$hostname$nix_shell: $directory$cmd_duration$git_branch$git_commit$git_state$git_status$line_break[](green bold)$character";
# Inserts a blank line between shell prompts
add_newline = true;
line_break.disabled = true;
format = "[ ](bold green)$os$username$hostname$nix_shell$git_branch$git_commit$git_state$git_status$directory$jobs$cmd_duration\n$character";
username = { username = {
style_user = "cyan bold"; format = "[$user]($style)";
style_root = "red bold";
format = "[$user]($style) ";
disabled = false;
show_always = true; show_always = true;
}; };
hostname = { hostname = {
ssh_only = false; ssh_only = false;
ssh_symbol = "🌐 "; ssh_symbol = "🌐 ";
format = "on [$hostname](bold red) "; format = "[$hostname](bold red)";
trim_at = ".local"; trim_at = ".local";
disabled = false; disabled = false;
}; };
@ -51,9 +41,7 @@ in
}; };
git_commit = { git_commit = {
only_detached = true; tag_disabled = false;
format = "[$hash]($style) ";
style = "yellow bold";
}; };
git_state = { git_state = {
@ -61,12 +49,23 @@ in
}; };
git_status = { git_status = {
style = "green bold"; format = "[$all_status $ahead_behind]($style) ";
style = "bold green";
conflicted = "🏳";
up_to_date = "";
untracked = " ";
ahead = "\${count}";
diverged = "\${ahead_count}\${behind_count}";
behind = "\${count}";
stashed = " ";
modified = " ";
staged = "[++\($count\)](green)";
renamed = " ";
deleted = " ";
}; };
directory = { directory = {
read_only = " 󰌾"; read_only = " 󰌾";
truncation_length = 0;
}; };
cmd_duration = { cmd_duration = {
@ -74,12 +73,8 @@ in
style = "blue"; style = "blue";
}; };
jobs = {
style = "green bold";
};
os = { os = {
format = "[$symbol](bold white) "; format = "[$symbol](bold white)";
disabled = false; disabled = false;
symbols = { symbols = {
@ -93,9 +88,8 @@ in
}; };
}; };
character = { fill = {
success_symbol = "[>](green bold)"; symbol = " ";
error_symbol = "[x](red bold)";
}; };
}; };
}; };

View file

@ -1,16 +1,16 @@
{ config, options, lib, pkgs, user, ... }: { config, lib, user, ... }:
let let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.strings) concatStringsSep; inherit (lib.options) mkEnableOption;
cfg = config.modules.${user}.shell.toolset.yazi;
in in
{ {
options.modules.${user}.shell.toolset.yazi = let options.modules.${user}.shell.toolset.yazi = {
inherit (lib.options) mkEnableOption;
in {
enable = mkEnableOption "system-monitor"; enable = mkEnableOption "system-monitor";
}; };
config = mkIf config.modules.${user}.shell.toolset.yazi.enable { config = mkIf cfg.enable {
home-manager.users.${user}.programs.yazi = { home-manager.users.${user}.programs.yazi = {
enable = true; enable = true;
}; };

View file

@ -39,7 +39,7 @@ in
}; };
}; };
config = { config = mkIf (user != "root") {
users.users.${user} = { users.users.${user} = {
description = (cfg.full_name or user); description = (cfg.full_name or user);
extraGroups = cfg.groups ++ (if cfg.is_trusted then [ "wheel" ] else []); extraGroups = cfg.groups ++ (if cfg.is_trusted then [ "wheel" ] else []);

4
shell.nix Normal file
View file

@ -0,0 +1,4 @@
{}:
{
}