24 lines
653 B
Nix
24 lines
653 B
Nix
{
|
|
description = "A flake that provides a set of useful helper functions";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
|
};
|
|
|
|
outputs = { self, nixpkgs }: {
|
|
mkIfElse = with nixpkgs.lib; p: yes: no: mkMerge [
|
|
(mkIf p yes)
|
|
(mkIf (!p) no)
|
|
];
|
|
|
|
mkSymlinkActivationScript = {target, source, isDir ? false}: ''
|
|
if [ ${if isDir then "-d" else "-f"} ${target} ]; then
|
|
rm${if isDir then " -rf" else ""} ${target}
|
|
fi
|
|
ln -s ${source} ${target}
|
|
'';
|
|
|
|
attrByStrPath = strPath: set: nixpkgs.lib.attrsets.attrByPath (nixpkgs.lib.strings.splitString "." strPath) null set;
|
|
};
|
|
}
|