mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 19:46:07 +01:00
Add activationBefore and activationAfter options
This commit is contained in:
parent
867aa587ea
commit
cc77204f65
3 changed files with 37 additions and 5 deletions
|
|
@ -19,11 +19,11 @@ let
|
|||
pkgs.nix
|
||||
];
|
||||
|
||||
activationCmds = concatStringsSep "\n" (
|
||||
mkActivationCmds = activation: concatStringsSep "\n" (
|
||||
mapAttrsToList (name: value: ''
|
||||
noteEcho "Activating ${name}"
|
||||
${value}
|
||||
'') cfg.activation
|
||||
'') activation
|
||||
);
|
||||
|
||||
activationScript = pkgs.writeScript "activation-script" ''
|
||||
|
|
@ -39,7 +39,9 @@ let
|
|||
${builtins.readFile ../lib-bash/color-echo.sh}
|
||||
${builtins.readFile ../lib-bash/activation-init.sh}
|
||||
|
||||
${activationCmds}
|
||||
${mkActivationCmds cfg.activationBefore}
|
||||
${mkActivationCmds cfg.activation}
|
||||
${mkActivationCmds cfg.activationAfter}
|
||||
'';
|
||||
in
|
||||
|
||||
|
|
@ -64,6 +66,36 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
activationBefore = mkOption {
|
||||
default = {};
|
||||
type = types.attrs;
|
||||
description = ''
|
||||
Activation scripts for the nix-on-droid environment that
|
||||
need to be run first.
|
||||
</para><para>
|
||||
Any script should respect the <varname>DRY_RUN</varname>
|
||||
variable, if it is set then no actual action should be taken.
|
||||
The variable <varname>DRY_RUN_CMD</varname> is set to
|
||||
<code>echo</code> if dry run is enabled. Thus, many cases you
|
||||
can use the idiom <code>$DRY_RUN_CMD rm -rf /</code>.
|
||||
'';
|
||||
};
|
||||
|
||||
activationAfter = mkOption {
|
||||
default = {};
|
||||
type = types.attrs;
|
||||
description = ''
|
||||
Activation scripts for the nix-on-droid environment that
|
||||
need to be run last.
|
||||
</para><para>
|
||||
Any script should respect the <varname>DRY_RUN</varname>
|
||||
variable, if it is set then no actual action should be taken.
|
||||
The variable <varname>DRY_RUN_CMD</varname> is set to
|
||||
<code>echo</code> if dry run is enabled. Thus, many cases you
|
||||
can use the idiom <code>$DRY_RUN_CMD rm -rf /</code>.
|
||||
'';
|
||||
};
|
||||
|
||||
activationPackage = mkOption {
|
||||
type = types.package;
|
||||
readOnly = true;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ in
|
|||
|
||||
config = {
|
||||
|
||||
build.activation = {
|
||||
build.activationBefore = {
|
||||
linkBinSh = ''
|
||||
$DRY_RUN_CMD mkdir $VERBOSE_ARG --parents /bin
|
||||
$DRY_RUN_CMD ln $VERBOSE_ARG --symbolic --force ${cfg.binSh} /bin/.sh.tmp
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ in
|
|||
|
||||
inherit (cfg.config) assertions warnings;
|
||||
|
||||
build.activation.homeManager = ''
|
||||
build.activationAfter.homeManager = ''
|
||||
${cfg.config.home.activationPackage}/activate
|
||||
'';
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue