57 lines
1.8 KiB
Nix
57 lines
1.8 KiB
Nix
with builtins;
|
|
with import (toString ../functions);
|
|
|
|
{pkgs, config, lib, ...}: {
|
|
|
|
options = with lib; with types; {
|
|
cascade.source.enable = mkOption {
|
|
default = true;
|
|
type = bool;
|
|
description = ''
|
|
Include cascade source code configured for nixos-rebuild.
|
|
'';
|
|
};
|
|
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.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = with lib; {
|
|
system.activationScripts.cascade-source = mkMerge [
|
|
(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
|
|
'')
|
|
(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
|
|
'')
|
|
];
|
|
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" ])
|
|
];
|
|
};
|
|
|
|
}
|