mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 19:46:07 +01:00
Add rollback functionality in nix-on-droid
This commit is contained in:
parent
8ad0e40c2b
commit
41fca9b4e9
2 changed files with 72 additions and 20 deletions
|
|
@ -8,6 +8,8 @@ with lib;
|
|||
let
|
||||
cfg = config.build;
|
||||
|
||||
profileDirectory = "/nix/var/nix/profiles/nix-on-droid";
|
||||
|
||||
# Programs that always should be available on the activation
|
||||
# script's PATH.
|
||||
activationBinPaths = lib.makeBinPath [
|
||||
|
|
@ -108,13 +110,6 @@ in
|
|||
internal = true;
|
||||
description = "Package containing /etc files.";
|
||||
};
|
||||
|
||||
profileDirectory = mkOption {
|
||||
type = types.path;
|
||||
readOnly = true;
|
||||
internal = true;
|
||||
description = "Path to nix-on-droid profile.";
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
|
@ -126,8 +121,13 @@ in
|
|||
|
||||
build = {
|
||||
activationAfter.linkProfile = ''
|
||||
generationDir="$(dirname "$(realpath $0)")"
|
||||
$DRY_RUN_CMD nix-env --profile "${cfg.profileDirectory}" --set "$generationDir"
|
||||
generationDir="$(dirname $0)"
|
||||
|
||||
if [[ $generationDir =~ ^${profileDirectory}-([0-9]+)-link$ ]]; then
|
||||
$DRY_RUN_CMD nix-env --profile "${profileDirectory}" --switch-generation "''${BASH_REMATCH[1]}"
|
||||
else
|
||||
$DRY_RUN_CMD nix-env --profile "${profileDirectory}" --set "$generationDir"
|
||||
fi
|
||||
'';
|
||||
|
||||
activationPackage =
|
||||
|
|
@ -151,8 +151,6 @@ in
|
|||
ln --symbolic ${config.environment.binSh} $out/filesystem/bin/sh
|
||||
ln --symbolic ${config.environment.usrBinEnv} $out/filesystem/usr/bin/env
|
||||
'';
|
||||
|
||||
profileDirectory = "/nix/var/nix/profiles/nix-on-droid";
|
||||
};
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue