2022-09-27 16:16:53 +00:00
|
|
|
with builtins;
|
|
|
|
with import (toString ../functions);
|
|
|
|
|
2022-09-28 12:08:26 +00:00
|
|
|
{pkgs, config, lib, ...}: {
|
2022-09-27 16:16:53 +00:00
|
|
|
|
|
|
|
options = with lib; with types; {
|
2022-09-28 12:08:26 +00:00
|
|
|
cascade.source.enable = mkOption {
|
2022-09-27 16:16:53 +00:00
|
|
|
default = true;
|
|
|
|
type = bool;
|
|
|
|
description = ''
|
|
|
|
Include cascade source code configured for nixos-rebuild.
|
|
|
|
'';
|
|
|
|
};
|
2022-09-28 12:08:26 +00:00
|
|
|
cascade.source.git-url = mkOption {
|
|
|
|
default = "https://gitlab.com/jamesandariese/cascade";
|
|
|
|
type = str;
|
|
|
|
description = ''
|
|
|
|
git URL where cascade sources can be found
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
cascade.source.set-nix-path = mkOption {
|
|
|
|
default = true;
|
|
|
|
type = bool;
|
|
|
|
description = ''
|
|
|
|
set cascade=/usr/src/cascade in NIX_PATH if cascade.source.enable is also true.
|
|
|
|
|
|
|
|
if this option or cascade.source.enable are false, this will not be done.
|
|
|
|
'';
|
|
|
|
};
|
2022-09-27 16:16:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = with lib; {
|
|
|
|
system.activationScripts.cascade-source = mkMerge [
|
2022-09-28 12:08:26 +00:00
|
|
|
(mkIf config.cascade.source.enable ''
|
|
|
|
if [ ! -f /usr/src/cascade/.created-by-nixos ];then
|
|
|
|
mkdir -m 0755 -p /usr/src /etc/nixos
|
|
|
|
[ -e /usr/src/cascade ] && mv /usr/src/cascade /usr/src/cascade.before-nixos
|
|
|
|
${pkgs.git}/bin/git clone ${config.cascade.source.git-url} /usr/src/cascade
|
|
|
|
touch /usr/src/cascade/.created-by-nixos
|
|
|
|
fi
|
2022-09-27 16:16:53 +00:00
|
|
|
'')
|
2022-09-28 12:08:26 +00:00
|
|
|
(mkIf (!config.cascade.source.enable) ''
|
|
|
|
# only cleanup if we actually created /usr/src/cascade
|
|
|
|
if [ -f /usr/src/cascade/.created-by-nixos ];then
|
|
|
|
rm -rf /usr/src/cascade && \
|
|
|
|
[ -e /usr/src/cascade.before-nixos ] && mv /usr/src/cascade.before-nixos /usr/src/cascade
|
|
|
|
fi
|
2022-09-27 16:16:53 +00:00
|
|
|
'')
|
|
|
|
];
|
2022-09-28 13:37:32 +00:00
|
|
|
nix.nixPath = mkMerge [
|
|
|
|
(mkIf (config.cascade.source.set-nix-path && config.cascade.source.enable) [ "cascade=/usr/src/cascade" ])
|
|
|
|
(mkIf (!(config.cascade.source.set-nix-path && config.cascade.source.enable)) [ "cascade=https://gitlab.com/jamesandariese/cascade/-/archive/main/cascade-main.tar.gz" ])
|
|
|
|
];
|
2022-09-27 16:16:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|