CASCADE/common/cascade-local.nix

64 lines
2.1 KiB
Nix
Raw Normal View History

with builtins;
with import (toString ../functions);
{pkgs, config, lib, ...}: {
options = with lib; with types; {
cascade.local.git-url = mkOption {
default = null;
type = nullOr str;
description = ''
git URL where cascade sources can be found
'';
};
};
config = with lib; {
#system.activationScripts.cascade-local-source = mkMerge [
# (mkIf (config.cascade.local.git-url != null) ''
# if [ ! -f /usr/src/cascade-local/.created-by-nixos ];then
# mkdir -m 0755 -p /usr/src
# # if it's just a symlink, delete it.
# if [ -e /usr/src/cascade-local.before-nixos ] ;then
# 1>&2 echo "there is already a backup at /usr/src/cascade-local.before-nixos"
# exit 1
# fi
# if [ -h /usr/src/cascade-local.before-nixos ];then
# rm -v /usr/src/cascade-local.before-nixos
# fi
# [ -e /usr/src/cascade-local ] && mv /usr/src/cascade-local /usr/src/cascade-local.before-nixos
# ${pkgs.git}/bin/git clone ${config.cascade.source.git-url} /usr/src/cascade-local
# touch /usr/src/cascade-local/.created-by-nixosa
# fi
# '')
# (mkIf (config.cascade.local.git-url == null) ''
# # if it's a symlink, just delete it.
# if [ -h /usr/src/cascade-local ];then
# rm -v /usr/src/cascade-local
# fi
# # only cleanup if we actually created /usr/src/cascade-local
# if [ -f /usr/src/cascade-local/.created-by-nixos ];then
# rm -rf /usr/src/cascade-local && \
# [ -e /usr/src/cascade-local.before-nixos ] && mv /usr/src/cascade-local.before-nixos /usr/src/cascade-local
# fi
#
# mkdir -m 0755 -p /usr/src
# if [ -h /usr/src/cascade-local.before-nixos ];then
# rm -v /usr/src/cascade-local.before-nixos
# fi
# if [ -e /usr/src/cascade-local ];then
# mv /usr/src/cascade-local /usr/src/cascade-local.before-nixos
# fi
# ln -sfn ${<cascade-local>} /usr/src/cascade-local
# '')
#];
# no matter what, we always set cascade-local in NIX_PATH to /usr/src/cascade-local
nix.nixPath = [ "cascade-local=/usr/src/cascade-local" ];
};
}