Initial commit
This commit is contained in:
commit
cfcc57a8bd
353 changed files with 18756 additions and 0 deletions
55
flake/den/modules/aspects/provides/define-user.nix
Normal file
55
flake/den/modules/aspects/provides/define-user.nix
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
{ lib, den, ... }:
|
||||
let
|
||||
description = ''
|
||||
Defines a user at OS and Home levels.
|
||||
|
||||
Works in NixOS/Darwin and standalone Home-Manager
|
||||
|
||||
## Usage
|
||||
|
||||
# for NixOS/Darwin
|
||||
den.aspects.my-user.includes = [ den._.define-user ]
|
||||
|
||||
# for standalone home-manager
|
||||
den.aspects.my-home.includes = [ den._.define-user ]
|
||||
|
||||
or globally (automatically applied depending on context):
|
||||
|
||||
den.default.includes = [ den._.define-user ]
|
||||
'';
|
||||
|
||||
homeDir =
|
||||
host: user:
|
||||
if lib.hasSuffix "darwin" host.system then "/Users/${user.userName}" else "/home/${user.userName}";
|
||||
|
||||
userContext =
|
||||
{ host, user, ... }:
|
||||
{
|
||||
nixos.users.users.${user.userName}.isNormalUser = true;
|
||||
darwin.users.users.${user.userName} = {
|
||||
name = user.userName;
|
||||
home = homeDir host user;
|
||||
};
|
||||
homeManager = {
|
||||
home.username = user.userName;
|
||||
home.homeDirectory = homeDir host user;
|
||||
};
|
||||
};
|
||||
|
||||
hmContext =
|
||||
{ home, ... }:
|
||||
userContext {
|
||||
host.system = home.system;
|
||||
user.userName = home.userName;
|
||||
};
|
||||
in
|
||||
{
|
||||
den.provides.define-user = {
|
||||
inherit description;
|
||||
includes = [
|
||||
userContext
|
||||
hmContext
|
||||
];
|
||||
__functor = den.lib.parametric.atLeast;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue