making a mess of it, but getting to auto loading multi user setups!

This commit is contained in:
Chris Kruining 2025-03-13 00:50:41 +01:00
parent 20a2450683
commit b139021f8e
13 changed files with 139 additions and 216 deletions

View file

@ -1,24 +1,53 @@
{ inputs, lib, pkgs, self, ... }:
let
{
inputs,
lib,
pkgs,
self,
...
}: let
inherit (inputs.nixpkgs.lib) nixosSystem;
inherit (builtins) baseNameOf elem;
inherit (lib.attrsets) filterAttrs;
inherit (lib.modules) mkDefault;
inherit (lib.strings) removeSuffix;
inherit (self.modules) mapModules;
inherit (self) mkSysUser mkHmUser;
in rec
{
mkHost = path: attrs @ {system ? "x86_64-linux", ...}:
nixosSystem {
inherit system;
specialArgs = { inherit lib inputs system; };
specialArgs = {inherit lib inputs system;};
modules = [
modules =
let
stateVersion = "23.11";
in [
inputs.nixos-boot.nixosModules.default
{
nixpkgs.pkgs = pkgs;
networking.hostName = mkDefault (removeSuffix ".nix" (baseNameOf path));
system = {
inherit stateVersion;
configurationRevision = with inputs; mkIf (self ? rev) self.rev;
};
imports = [ "${path}/hardware.nix" ];
users = {
mutableUsers = false;
users = mapModules "${path}/users" mkSysUser;
};
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
sharedModules = [
inputs.plasma-manager.homeManagerModules.plasma-manager
];
users = mapModules "${path}/users" (p: mkHmUser p stateVersion);
};
}
(filterAttrs (n: v: !elem n ["system"]) attrs)
../. # ../default.nix
@ -26,6 +55,6 @@ in rec
];
};
mapHosts = dir: attrs @ { system ? system, ... }:
mapHosts = dir: attrs @ {system ? system, ...}:
mapModules dir (hostPath: mkHost hostPath attrs);
}

31
lib/user.nix Normal file
View file

@ -0,0 +1,31 @@
{ lib, ... }: let
inherit (builtins) baseNameOf;
inherit (lib.attrsets) filterAttrs;
inherit (lib.strings) removeSuffix;
in rec
{
mkSysUser = path: let
user = import path {};
name = removeSuffix ".nix" (baseNameOf path);
in
{
inherit name;
inherit (user) is_trusted;
description = user.full_name;
extraGroups = (if user.is_trusted then [ "wheel" ] else []);
isNormalUser = true;
home = "/home/${name}";
group = "users";
};
mkHmUser = path: stateVersion: let
user = import path {};
name = removeSuffix ".nix" (baseNameOf path);
in
{
home = {
inherit stateVersion;
sessionPath = [ "$SNEEUWVLOK_BIN" "$XDG_BIN_HOME" "$PATH" ]; # Pretty sure I don't need this.
};
};
}