add convenience functions to modules mylib
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
{ inputs, pkgs, lib, ... }:
|
{ inputs, pkgs, lib, ... }:
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
|
# Conveniance wrapper for mkOption with boolean type
|
||||||
mkBoolOpt = def: desc:
|
mkBoolOpt = def: desc:
|
||||||
lib.mkOption {
|
lib.mkOption {
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
@ -8,9 +9,11 @@ rec {
|
|||||||
description = desc;
|
description = desc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Like mkIf but the predicate is inverted
|
||||||
mkElse = pred: do:
|
mkElse = pred: do:
|
||||||
(lib.mkIf (!pred) do);
|
(lib.mkIf (!pred) do);
|
||||||
|
|
||||||
|
# Creates a symlink if it doesn't exist
|
||||||
mkLink = src: dest:
|
mkLink = src: dest:
|
||||||
''
|
''
|
||||||
if [ ! -L "${dest}" ]; then
|
if [ ! -L "${dest}" ]; then
|
||||||
@ -18,10 +21,31 @@ rec {
|
|||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
# Removes a symlink if it exists
|
||||||
mkUnlink = dest:
|
mkUnlink = dest:
|
||||||
''
|
''
|
||||||
if [ -L "${dest}" ]; then
|
if [ -L "${dest}" ]; then
|
||||||
rm ${dest}
|
rm ${dest}
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
mkMultiOptStr = { }:
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
mkMultiOptPkg = { }:
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
# Returns true if base contains element
|
||||||
|
contains = base: element:
|
||||||
|
lib.any (x: x == element) base;
|
||||||
|
|
||||||
|
# Returns base without occurences of elements that are also in remove
|
||||||
|
without = base: remove:
|
||||||
|
lib.filter (x: !(contains remove x)) base;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user