lib/ Functions
lib.asserts: assertion functions#
{#sec-functions-library-asserts} ##
lib.asserts.assertHomeManagerLoaded
{#function-library-lib.asserts.assertHomeManagerLoaded} Asserts that the
home-manager module is installed and imported. Type:
assertHomeManagerLoaded :: AttrSet a -> (AttrSet a | Error)
cfg
: (AttrSet) An AttrSet with the already parsed NixOS config :::
lib.asserts.assertHomeManagerLoaded
usage example ```nix#
nix title="Example" linenums="1" config = mkIf cfg.enable
(mkMerge [ ({ assertions = with tensorfiles.asserts; [ (mkIf
cfg.home.enable (assertHomeManagerLoaded config)) ]; }) ]);
``` :::
Declared by: - /nix/store/d0di7dp3rn81gv0x7i7ki1gj7n3yjrgv-lib/asserts.nix
lib.attrsets: attribute set functions#
{#sec-functions-library-attrsets} ## lib.attrsets.mapFilterAttrs
{#function-library-lib.attrsets.mapFilterAttrs} Apply a map to every
attribute of an attrset and then filter the resulting attrset based on a
given predicate function. Type: mapFilterAttrs :: (AttrSet b ->
Bool) -> (AttrSet a -> AttrSet b) -> AttrSet a -> AttrSet b
pred
: (AttrSet b -> Bool) Predicate used for filtering f
:
(AttrSet a -> AttrSet b) Function used for transforming the given
AttrSets attrs
: (AttrSet a) Initial attrset ##
lib.attrsets.mergeAttrs
{#function-library-lib.attrsets.mergeAttrs}
Recursively merges a list of attrsets. Type: mergeAttrs ::
[AttrSet] -> AttrSet
attrs
: ([AttrSet]) The list of attrsets
::: {.example #function-library-example-lib.attrsets.mergeAttrs} #
lib.attrsets.mergeAttrs
usage example nix
nix
title="Example" linenums="1" mergeAttrs [ { keyA = 1; keyB = 3; } {
keyB = 10; keyC = "hey"; nestedKey = { A = null; }; } { nestedKey = {
A = 3; B = 4; }; } ] => { keyA = 1; keyB = 10; keyC = "hey";
nestedKey = { A = 3; B = 4; };} ::: ##
lib.attrsets.mapToAttrsAndMerge
{#function-library-lib.attrsets.mapToAttrsAndMerge} Given a list of
elements, applies a transformation to each of the element to an attrset
and then recursively merges the resulting attrset. Type:
mapToAttrsAndMerge :: [a] -> (a -> AttrSet) -> AttrSet
list
: ([a]) Initial list of elements f
: (a -> AttrSet) Function used
for transforming the initial elements to attrsets ::: {.example
function-library-example-lib.attrsets.mapToAttrsAndMerge}#
lib.attrsets.mapToAttrsAndMerge
usage example nix
nix
title="Example" linenums="1" mapToAttrsAndMerge [ 1 2 3 ] (x: {
"key_${toString x}": x * x }) => { "key_1" = 1; "key_2" = 4;
"key_3" = 9; } ::: ##
lib.attrsets.flatten
{#function-library-lib.attrsets.flatten} Recursively flattens a nested
attrset into a list of just its values. Type: flatten :: AttrSet a
-> [a]
attrs
: (AttrSet a) Initial nested attrset ::: {.example
function-library-example-lib.attrsets.flatten}#
lib.attrsets.flatten
usage example nix
nix
title="Example" linenums="1" flatten { keyA = 10; keyB = "str20";
keyC = { keyD = false; keyE = { a = 10; b = "20"; c = false; }; }; }
=> [ 10 "str20" false 10 "20" false ] ::: ##
lib.attrsets.groupAttrsetBySublistElems
{#function-library-lib.attrsets.groupAttrsetBySublistElems} Performs a
groupBy
element based grouping operation on nested attrset. Isn't
natively supported so the strategy is to first convert the attrset into
a list of nameValuePair
s and then perform the groupBy
on
(item: item.value)
. After a successful grouping the list is
converted back to an attrset Note: This function should work with
arbitrary objects as long as the values themselves are not nested again
-- for arbitrarily large nests you should instead apply this function
recursively. Type: groupAttrsetBySublistElems :: AttrSet a(b) ->
AttrSet b(a)
inputAttrset
: (AttrSet a(b)) The initial nested
attrset ::: {.example
function-library-example-lib.attrsets.groupAttrsetBySublistElems}#
lib.attrsets.groupAttrsetBySublistElems
usage example nix
nix title="Example" linenums="1" groupAttrsetBySublistElems {
pkg1 = [ "aarch64_linux" "x86_64-linux" ]; pkg2 = [
"x86_64-linux" ]; pkg3 = [ "aarch64-linux" ] } => {
"aarch64-linux" = [ "pkg1" "pkg3" ]; "x86_64-linux" = [
"pkg1" "pkg2" ]; } :::
Declared by: - /nix/store/d0di7dp3rn81gv0x7i7ki1gj7n3yjrgv-lib/attrsets.nix
lib.licenses: tensorfiles licenses#
{#sec-functions-library-licenses}
Declared by: - /nix/store/d0di7dp3rn81gv0x7i7ki1gj7n3yjrgv-lib/licenses.nix
lib.lists: list manipulation functions#
{#sec-functions-library-lists} ## lib.lists.flipMap
{#function-library-lib.lists.flipMap} Map function with flipped
arguments. Type: flipMap :: (a -> b) -> [a] -> [b]
:::
{.example #function-library-example-lib.lists.flipMap} #
lib.lists.flipMap
usage example nix
nix
title="Example" linenums="1" flipmap (x: x * x) [ 1 2 3 ] => [
1 4 9 ] :::
Declared by: - /nix/store/d0di7dp3rn81gv0x7i7ki1gj7n3yjrgv-lib/lists.nix
lib.maintainers: tensorfiles maintainers#
{#sec-functions-library-maintainers}
Declared by: - /nix/store/d0di7dp3rn81gv0x7i7ki1gj7n3yjrgv-lib/maintainers.nix
lib.modules: general modularity functions#
{#sec-functions-library-modules} ##
lib.modules.mkOverrideAtModuleLevel
{#function-library-lib.modules.mkOverrideAtModuleLevel} mkOverride
function with a preset priority set for all of the nixos modules.
Type: mkOverrideAtModuleLevel :: AttrSet a -> { _type :: String;
priority :: Int; content :: AttrSet a; }
##
lib.modules.mkOverrideAtProfileLevel
{#function-library-lib.modules.mkOverrideAtProfileLevel} mkOverride
function with a preset priority set for all of the nixos profiles, that
is, modules that preconfigure other modules. Type:
mkOverrideAtProfileLevel :: AttrSet a -> { _type :: String; priority
:: Int; content :: AttrSet a; }
## lib.modules.mapModules
{#function-library-lib.modules.mapModules} Recursively read a directory
and apply a provided function to every .nix
file. Returns an attrset
that reflects the filenames and directory structure of the root.
Notes: 1. Files and directories starting with the _
or .git
prefix will be completely ignored. 2. If a directory with a
myDir/default.nix
file will be encountered, the function will be
applied to the myDir/default.nix
file instead of recursively loading
myDir
and applying it to every file. Type: mapModules :: Path
-> (Path -> AttrSet a) -> { name :: String; value :: AttrSet a; }
dir
: (Path) Root directory on which should the recursive mapping be
applied fn
: (Path -> AttrSet a) Function that transforms node
paths to their custom attrsets ::: {.example
function-library-example-lib.modules.mapModules}#
lib.modules.mapModules
usage example nix
nix
title="Example" linenums="1" mapModules ./modules import => {
hardware = { moduleA = { ... }; }; system = { moduleB = { ... }; }; }
mapModules ./hosts (host: mkHostCustomFunction myArg host) => { hostA =
{ ... }; hostB = { ... }; } ::: ##
lib.modules.mkNixpkgs
{#function-library-lib.modules.mkNixpkgs}
Custom nixpkgs constructor. Its purpose is to import provided nixpkgs
while setting the target platform and all over the needed overlays.
Type: mkNixpkgs :: AttrSet -> String -> [(AttrSet -> AttrSet
-> AttrSet)] -> Attrset
pkgs
: (AttrSet) TODO (this is probably
not an actual attrset?) system
: (String) System string identifier
(eg: "x86_64-linux", "aarch64-linux", "aarch64-darwin")
extraOverlays
: ([AttrSet -> AttrSet -> AttrSet]) Extra overlays
that should be applied to the created pkgs ::: {.example
function-library-example-lib.modules.mkNixpkgs}#
lib.modules.mkNixpkgs
usage example nix
nix
title="Example" linenums="1" mkNixpkgs inputs.nixpkgs
"x86_64-linux" [] => { ... } mkNixpkgs inputs.nixpkgs
"aarch64-linux" [ (final: prev: { customPkgs = inputs.customPkgs {
pkgs = final; }; }) ] => { ... } ::: ##
lib.modules.mkHost
{#function-library-lib.modules.mkHost} Custom
host (that is, nixosSystem) constructor. It expects a target host dir
path as its first argument, that is, not a .nix
file, but a
directory. The reasons for this are the following: 1. Each host gets its
specifically constructed version of nixpkgs for its target platform,
which is specified in the myHostDir/system
file. 2. Apart from some
main host .nix
file almost every host has some
hardware-configuration.nix
thus implying a host directory structure
holding atleast 2 files + the system file. This means that the minimal
required structure for a host dir is - myHostDir/ - (required)
default.nix - (required) system - (optional) hardware-configuration.nix
Type: mkHost :: Path -> Attrset
dir
: (Path) Path to the
root directory further providing the "system" and "default.nix"
files ## lib.modules.mkDummyDerivation
{#function-library-lib.modules.mkDummyDerivation} Returns a dummy
derivation with a given name as and a platform specific builder. Useful
when constructing certain defaults or general debugging. The resulting
derivation can be compiled without errors, but obviously doesn't
produce any nontrivial output. Type: mkDummyDerivation :: String
-> String -> AttrSet a -> Package a
name
: (String) Name of the
dummy derivation system
: (String) System architecture string. This
is going to be used for choosing the target derivation builder
extraArgs
: (AttrSet a) An attrset with possibly any additional
values that are going to be passed to the mkDerivation call :::
{.example #function-library-example-lib.modules.mkDummyDerivation} #
lib.modules.mkDummyDerivation
usage example nix
nix
title="Example" linenums="1" mkDummyDerivation "example-pkg"
"aarch64-linux" {} => derivation mkDummyDerivation "example-pkg2"
"x86_64-linux" { meta.license = lib.licenses.gpl20; } => derivation
:::
Declared by: - /nix/store/d0di7dp3rn81gv0x7i7ki1gj7n3yjrgv-lib/modules.nix
lib.nixos: NixOS related functionality#
{#sec-functions-library-nixos} ## lib.nixos.isPersistenceEnabled
{#function-library-lib.nixos.isPersistenceEnabled} Check whether the
persistence system is enabled, that is whether 1. The
tensorfiles.system.persistence
module is imported 2. It is also
enabled Type: isPersistenceEnabled :: AttrSet -> Bool
cfg
:
(AttrSet) An AttrSet with the already parsed NixOS config ##
lib.nixos.isAgenixEnabled
{#function-library-lib.nixos.isAgenixEnabled} Check whether the agenix
system is enabled, that is whether 1. The
tensorfiles.security.agenix
moduls is imported 2. It is also enabled
Type: isAgenixEnabled :: AttrSet -> Bool
cfg
: (AttrSet) An
AttrSet with the already parsed NixOS config ##
lib.nixos.isUsersSystemEnabled
{#function-library-lib.nixos.isUsersSystemEnabled} Check whether the
agenix system is enabled, that is whether 1. The
tensorfiles.system.users
module is imported 2. It is also enabled
Type: isUsersSystemEnabled :: AttrSet -> Bool
cfg
:
(AttrSet) An AttrSet with the already parsed NixOS config ##
lib.nixos.isPywalEnabled
{#function-library-lib.nixos.isPywalEnabled} Check whether the pywal
theme system module is enabled, that is whether 1. The
tensorfiles.programs.pywal
module is imported 2. It is also enabled
Type: isPywalEnabled:: AttrSet -> Bool
cfg
: (AttrSet) An
AttrSet with the already parsed NixOS config ##
lib.nixos.absolutePathToRelativeHome
{#function-library-lib.nixos.absolutePathToRelativeHome} Transforms an
absolute path to a one relative to the given user home directory. It
basically functions as a case handler for lib.strings.removePrefix
to handle a variety of different cases. 1. If you pass cfg = config;
then the function will load the homeDir
specified in the users
system module (tensorfiles.system.users). Note that the module has to be
also enabled. 2. You can instead just pass the username directly
instead, in that case it will remove either /home/$user
or
/root
depending on the provided user. 3. You can also just pass the
home
. In that case it behaves basically just like a direct call to
lib.strings.removePrefix
4. You can omit passing any variables, in
that case the function will try to parse the user that has been passed
for the initialization of the whole lib/ (if any was provided). If no
user was provided in this manner, it will fallback to /root. Type:
absolutePathToRelativeHome :: Path -> { _user :: String; home ::
String; cfg :: AttrSet } -> String
path
: (Path) The absolute
path that should be transformed to a relative one structured function
argument : _user
: (String) Username that will be used to parse the
homedir. Default: module level user if provided, otherwise "root"
home
: (Path) In case of a nontraditional /home structure, you can
provide the full homedir path. Default: null cfg
: (AttrSet) An
AttrSet with the already parsed NixOS config. Passing this attrset
enabled parsing homedir directly via the usersSystem module. Default:
null ::: {.example
function-library-example-lib.nixos.absolutePathToRelativeHome}#
lib.nixos.absolutePathToRelativeHome
usage example nix
nix title="Example" linenums="1" absolutePathToRelativeHome
"/home/myUser/myDir/file.txt" { cfg = config; user = "myUser"; } =>
"myDir/file.txt" absolutePathToRelativeHome
"/home/myUser/myDir/file.txt" { user = "myUser"; } =>
"myDir/file.txt" absolutePathToRelativeHome "/root/myDir/file.txt" {
user = "root"; } => "myDir/file.txt" absolutePathToRelativeHome
"/var/myUserHome/myDir/file.txt" { home = "/var/myUserHome"; } =>
"myDir/file.txt" absolutePathToRelativeHome
"/home/myUser/myDir/file.txt" {} => "myDir/file.txt"
::: ##
lib.nixos.getUserHomeDir
{#function-library-lib.nixos.getUserHomeDir} A generic function for
parsing the user home directory. The parsing will be attempted in the
following order: 1. In case that the users system is enabled, the value
will be parsed from the homeDir home.settings option of the users module
(if the user is entry is well defined in the home.settings attrset). 2.
If not, it will check whether home-manager is enabled, loaded and if the
user is well defined inside, in that case it will return the
home.homeDirectory variable. 3. If not, it will check whether the user
is well defined in the users.users attrset and if yes, it will return
the home variable. 4. If not, it will manually return either the usual
"/home/$user" or "/root" depending on the context This method is
designed to be an abstraction between different modules/systems that
provide this kind of functionality. It enables writing extensible nix
expressions instead of relying on any specific module that the end user
might not have enabled or might even remove in the future. Type: {
_user :: String; cfg :: AttrSet } -> Path
structured function
argument : _user
: (String) Target user whose home directory should
be parsed. Default: user passed during lib init cfg
: (AttrSet) An
AttrSet with the already parsed NixOS config. Passing this attribute
enables parsing the home directory dynamically from the configuration
itself rather than statically. ::: {.example
function-library-example-lib.nixos.getUserHomeDir}#
lib.nixos.getUserHomeDir
usage example nix
nix
title="Example" linenums="1" getUserHomeDir { _user = "myUser"; }
=> "/home/myUser" getUserHomeDir { _user = "root"; } => "/root"
tensorfiles.system.users.enable = true;
tensorfiles.system.users.home.enable = true;
tensorfiles.system.users.home."myUser".homeDir = "/var/mySecretDir";
getUserHomeDir { _user = "myUser"; cfg = config; } =>
"/var/mySecretDir" tensorfiles.system.users.enable = false;
home-manager.users."myUser".home.homeDirectory = null;
users.users."myUser".home = "/var/myOtherSecretDir"; getUserHomeDir
{ _user = "myUser"; cfg = config; } => "/var/myOtherSecretDir"
::: ##
lib.nixos.getUserConfigDir
{#function-library-lib.nixos.getUserConfigDir} A generic function for
parsing the user config directory. The parsing will be attempted in the
following order: 1. In case that the users system is enabled, the value
will be parsed from the configDir home.settings option of the users
module (if the user is entry is well defined in the home.settings
attrset). 2. If not, the home directory will be dynamically retrieved
using the getUserHomeDir
function and .config
will simply be
appended to it and returned. This method is designed to be an
abstraction between different modules/systems that provide this kind of
functionality. It enables writing extensible nix expressions instead of
relying on any specific module that the end user might not have enabled
or might even remove in the future. Type: { _user :: String; cfg
:: AttrSet } -> Path
structured function argument : _user
:
(String) Target user whose config directory should be parsed. Default:
user passed during lib init cfg
: (AttrSet) An AttrSet with the
already parsed NixOS config. Passing this attribute enables parsing the
config directory dynamically from the configuration itself rather than
statically. ::: {.example
function-library-example-lib.nixos.getUserConfigDir}#
lib.nixos.getUserConfigDir
usage example nix
nix
title="Example" linenums="1" getUserConfigDir { _user = "myUser";
} => "/home/myUser/.config" getUserConfigDir { _user = "root"; }
=> "/root/.config" tensorfiles.system.users.enable = true;
tensorfiles.system.users.home.enable = true;
tensorfiles.system.users.home."myUser".configDir =
"/var/mySecretDir/configuration"; getUserConfigDir { _user =
"myUser"; cfg = config; } => "/var/mySecretDir/configuration"
::: ##
lib.nixos.getUserCacheDir
{#function-library-lib.nixos.getUserCacheDir} A generic function for
parsing the user cache directory. The parsing will be attempted in the
following order: 1. In case that the users system is enabled, the value
will be parsed from the cacheDir home.settings option of the users
module (if the user is entry is well defined in the home.settings
attrset). 2. If not, the home directory will be dynamically retrieved
using the getUserHomeDir
function and .cache
will simply be
appended to it and returned. This method is designed to be an
abstraction between different modules/systems that provide this kind of
functionality. It enables writing extensible nix expressions instead of
relying on any specific module that the end user might not have enabled
or might even remove in the future. Type: { _user :: String; cfg
:: AttrSet } -> Path
structured function argument : _user
:
(String) Target user whose cache directory should be parsed. Default:
user passed during lib init cfg
: (AttrSet) An AttrSet with the
already parsed NixOS config. Passing this attribute enables parsing the
cache directory dynamically from the configuration itself rather than
statically. ::: {.example
function-library-example-lib.nixos.getUserCacheDir}#
lib.nixos.getUserCacheDir
usage example nix
nix
title="Example" linenums="1" getUserCacheDir { _user = "myUser";
} => "/home/myUser/.cache" getUserCacheDir { _user = "root"; } =>
"/root/.cache" tensorfiles.system.users.enable = true;
tensorfiles.system.users.home.enable = true;
tensorfiles.system.users.home."myUser".cacheDir =
"/var/mySecretDir/cache"; getUserCacheDir { _user = "myUser"; cfg =
config; } => "/var/mySecretDir/cache" ::: ##
lib.nixos.getUserAppDataDir
{#function-library-lib.nixos.getUserAppDataDir} A generic function for
parsing the user app data directory. The parsing will be attempted in
the following order: 1. In case that the users system is enabled, the
value will be parsed from the appDataDir home.settings option of the
users module (if the user is entry is well defined in the home.settings
attrset). 2. If not, the home directory will be dynamically retrieved
using the getUserHomeDir
function and .local/share
will simply
be appended to it and returned. This method is designed to be an
abstraction between different modules/systems that provide this kind of
functionality. It enables writing extensible nix expressions instead of
relying on any specific module that the end user might not have enabled
or might even remove in the future. Type: { _user :: String; cfg
:: AttrSet } -> Path
structured function argument : _user
:
(String) Target user whose app data directory should be parsed. Default:
user passed during lib init cfg
: (AttrSet) An AttrSet with the
already parsed NixOS config. Passing this attribute enables parsing the
app data directory dynamically from the configuration itself rather than
statically. ::: {.example
function-library-example-lib.nixos.getUserAppDataDir}#
lib.nixos.getUserAppDataDir
usage example nix
nix
title="Example" linenums="1" getUserAppDataDir { _user =
"myUser"; } => "/home/myUser/.local/share" getUserAppDataDir {
_user = "root"; } => "/root/.local/share"
tensorfiles.system.users.enable = true;
tensorfiles.system.users.home.enable = true;
tensorfiles.system.users.home."myUser".appDataDir =
"/var/mySecretDir/appData"; getUserAppDataDir { _user = "myUser";
cfg = config; } => "/var/mySecretDir/appData" ::: ##
lib.nixos.getUserAppStateDir
{#function-library-lib.nixos.getUserAppStateDir} A generic function for
parsing the user app state directory. The parsing will be attempted in
the following order: 1. In case that the users system is enabled, the
value will be parsed from the appStateDir home.settings option of the
users module (if the user is entry is well defined in the home.settings
attrset). 2. If not, the home directory will be dynamically retrieved
using the getUserHomeDir
function and .local/state
will simply
be appended to it and returned. This method is designed to be an
abstraction between different modules/systems that provide this kind of
functionality. It enables writing extensible nix expressions instead of
relying on any specific module that the end user might not have enabled
or might even remove in the future. Type: { _user :: String; cfg
:: AttrSet } -> Path
structured function argument : _user
:
(String) Target user whose app state directory should be parsed.
Default: user passed during lib init cfg
: (AttrSet) An AttrSet with
the already parsed NixOS config. Passing this attribute enables parsing
the app state directory dynamically from the configuration itself rather
than statically. ::: {.example
function-library-example-lib.nixos.getUserAppStateDir}#
lib.nixos.getUserAppStateDir
usage example nix
nix
title="Example" linenums="1" getUserAppStateDir { _user =
"myUser"; } => "/home/myUser/.local/state" getUserAppStateDir {
_user = "root"; } => "/root/.local/state"
tensorfiles.system.users.enable = true;
tensorfiles.system.users.home.enable = true;
tensorfiles.system.users.home."myUser".appStateDir =
"/var/mySecretDir/appState"; getUserAppStateDir { _user = "myUser";
cfg = config; } => "/var/mySecretDir/appState" `` ::: ##
lib.nixos.getUserDownloadsDir{#function-library-lib.nixos.getUserDownloadsDir} A generic function for
parsing the user Downloads directory. The parsing will be attempted in
the following order: 1. In case that the users system is enabled, the
value will be parsed from the downloadsDir home.settings option of the
users module (if the user is entry is well defined in the home.settings
attrset). 2. If not, the home directory will be dynamically retrieved
using the
getUserHomeDirfunction and
Downloadswill simply be
appended to it and returned. This method is designed to be an
abstraction between different modules/systems that provide this kind of
functionality. It enables writing extensible nix expressions instead of
relying on any specific module that the end user might not have enabled
or might even remove in the future. *Type*:
{ _user :: String; cfg
:: AttrSet } -> Pathstructured function argument :
_user:
(String) Target user whose Downloads directory should be parsed.
Default: user passed during lib init
cfg` : (AttrSet) An AttrSet with
the already parsed NixOS config. Passing this attribute enables parsing
the Downloads directory dynamically from the configuration itself rather
than statically. ::: {.example
function-library-example-lib.nixos.getUserDownloadsDir}#
lib.nixos.getUserDownloadsDir
usage example nix
nix
title="Example" linenums="1" getUserDownloadsDir { _user =
"myUser"; } => "/home/myUser/Downloads" getUserDownloadsDir {
_user = "root"; } => "/root/Downloads"
tensorfiles.system.users.enable = true;
tensorfiles.system.users.home.enable = true;
tensorfiles.system.users.home."myUser".downloadsDir =
"/var/mySecretDir/downloaded_stuff"; getUserHomeDir { _user =
"myUser"; cfg = config; } => "/var/mySecretDir/downloaded_stuff"
::: ##
lib.nixos.getUserEmail
{#function-library-lib.nixos.getUserEmail} A generic function for
parsing the user email. The parsing will be attempted in the following
order: 1. In case that the users system is enabled, the value will be
parsed from the appStateDir home.settings option of the users module (if
the user is entry is well defined in the home.settings attrset). 2. If
not, it will return null
, since that's for now the only available
option. This method is designed to be an abstraction between different
modules/systems that provide this kind of functionality. It enables
writing extensible nix expressions instead of relying on any specific
module that the end user might not have enabled or might even remove in
the future. Type: { _user :: String; cfg :: AttrSet } -> (String
| null)
structured function argument : _user
: (String) Target
user whose email should be parsed. Default: user passed during lib init
cfg
: (AttrSet) An AttrSet with the already parsed NixOS config.
Passing this attribute enables parsing the email dynamically from the
configuration itself rather than statically. ::: {.example
function-library-example-lib.nixos.getUserEmail}#
lib.nixos.getUserEmail
usage example nix
nix
title="Example" linenums="1" getUserEmail { _user = "myUser"; }
=> null tensorfiles.system.users.enable = true;
tensorfiles.system.users.home.enable = true;
tensorfiles.system.users.home."myUser".email = "myUser@email.com";
getUserEmail { _user = "myUser"; cfg = config; } =>
"myUser@email.com" :::
Declared by: - /nix/store/d0di7dp3rn81gv0x7i7ki1gj7n3yjrgv-lib/nixos.nix
lib.options: NixOS / nixpkgs option handling#
{#sec-functions-library-options} ##
lib.options.mkAlreadyEnabledOption
{#function-library-lib.options.mkAlreadyEnabledOption} Creates an
enableOption (ie mkEnableOption
), however, already preenabled.
Type: String -> Option
description
: Function argument ##
lib.options.mkPersistenceEnableOption
{#function-library-lib.options.mkPersistenceEnableOption} Creates an
enableOption targeted for the management of the persistence system.
Type: Option
## lib.options.mkPywalEnableOption
{#function-library-lib.options.mkPywalEnableOption} Creates an
enableOption targeted for the integration with the pywal colorscheme
generator. Type: Option
## lib.options.mkAgenixEnableOption
{#function-library-lib.options.mkAgenixEnableOption} Creates an
enableOption targeted for the management of the agenix security system.
Type: Option
## lib.options.mkHomeEnableOption
{#function-library-lib.options.mkHomeEnableOption} Creates an
enableOption targeted for the management of the home system. Type:
Option
## lib.options.mkHomeSettingsOption
{#function-library-lib.options.mkHomeSettingsOption} Creates an
enableOption targeted for the management of the home system. Type:
(String -> AttrSet a) -> Option
generatorFunction
: (String
-> AttrSet a) Function that, given a username, yields all of the home
related options for that given user
Declared by: - /nix/store/d0di7dp3rn81gv0x7i7ki1gj7n3yjrgv-lib/options.nix
lib.strings: string manipulation functions#
{#sec-functions-library-strings} ## lib.strings.dirnameFromPath
{#function-library-lib.strings.dirnameFromPath} Given an absolute path
to a file, return the dirname of that file. Type: dirnameFromPath
:: Path -> Path
dir
: (Path) Absolute path to a given file :::
{.example #function-library-example-lib.strings.dirnameFromPath} #
lib.strings.dirnameFromPath
usage example nix
nix
title="Example" linenums="1" dirnameFromPath "/etc/myDir/file.nix"
=> "/etc/myDir" :::
Declared by: - /nix/store/d0di7dp3rn81gv0x7i7ki1gj7n3yjrgv-lib/strings.nix
lib.types: additional types definitions#
{#sec-functions-library-types}
Declared by: - /nix/store/d0di7dp3rn81gv0x7i7ki1gj7n3yjrgv-lib/types.nix