almost there for multiple users????
This commit is contained in:
parent
f40207c455
commit
ce69116c39
8 changed files with 68 additions and 50 deletions
22
lib/_root.nix
Normal file
22
lib/_root.nix
Normal 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";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -8,10 +8,10 @@ let
|
|||
in rec
|
||||
{
|
||||
mapModules = dir: fn:
|
||||
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"
|
||||
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)
|
||||
else nameValuePair "" null
|
||||
) (readDir dir);
|
||||
|
@ -19,7 +19,7 @@ in rec
|
|||
mapModules' = dir: fn: attrValues (mapModules dir fn);
|
||||
|
||||
mapModulesRec = dir: fn:
|
||||
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"
|
||||
then nameValuePair n (mapModulesRec path fn)
|
||||
else if v == "regular" && n != "default.nix" && hasSuffix ".nix" n
|
||||
|
|
|
@ -6,8 +6,8 @@ args@{
|
|||
...
|
||||
}: let
|
||||
inherit (inputs.nixpkgs.lib) nixosSystem;
|
||||
inherit (builtins) baseNameOf elem map mapAttrs;
|
||||
inherit (lib) filterAttrs attrValues attrNames;
|
||||
inherit (builtins) baseNameOf elem map listToAttrs;
|
||||
inherit (lib) filterAttrs nameValuePair attrNames;
|
||||
inherit (lib.modules) mkAliasOptionModule mkDefault mkIf;
|
||||
inherit (lib.strings) removeSuffix;
|
||||
inherit (self.modules) mapModules mapModulesRec';
|
||||
|
@ -38,6 +38,7 @@ in rec
|
|||
imports = [
|
||||
inputs.home-manager.nixosModules.home-manager
|
||||
"${path}/hardware.nix"
|
||||
./_root.nix
|
||||
]
|
||||
++ (mapModulesRec' ../modules/system import);
|
||||
|
||||
|
@ -47,13 +48,13 @@ in rec
|
|||
};
|
||||
|
||||
home-manager = {
|
||||
backupFileExtension = "bak";
|
||||
useGlobalPkgs = true;
|
||||
useUserPackages = true;
|
||||
sharedModules = [
|
||||
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)
|
||||
|
|
15
lib/user.nix
15
lib/user.nix
|
@ -16,14 +16,11 @@ in rec
|
|||
group = "users";
|
||||
};
|
||||
|
||||
mkHmUser = path: args@{stateVersion, ...}: let
|
||||
name = removeSuffix ".nix" (baseNameOf path);
|
||||
in
|
||||
{
|
||||
# imports = (mapModulesRec' ../modules/home (file: import file (args // { user = name; })));
|
||||
home = {
|
||||
inherit stateVersion;
|
||||
sessionPath = [ "$XDG_BIN_HOME" "$PATH" ]; # Pretty sure I don't need this.
|
||||
};
|
||||
mkHmUser = path: {stateVersion, ...}:
|
||||
{
|
||||
home = {
|
||||
inherit stateVersion;
|
||||
sessionPath = [ "$XDG_BIN_HOME" "$PATH" ]; # Pretty sure I don't need this.
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue