mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-12-19 23:41:14 +01:00
99 lines
2.4 KiB
Nix
99 lines
2.4 KiB
Nix
# Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE.
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.environment;
|
|
in
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
environment = {
|
|
packages = mkOption {
|
|
type = types.listOf types.package;
|
|
default = [ ];
|
|
description = "List of packages to be installed as user packages.";
|
|
};
|
|
|
|
path = mkOption {
|
|
type = types.package;
|
|
readOnly = true;
|
|
internal = true;
|
|
description = "Derivation for installing user packages.";
|
|
};
|
|
|
|
extraOutputsToInstall = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [ ];
|
|
example = [ "doc" "info" "devdoc" ];
|
|
description = "List of additional package outputs to be installed as user packages.";
|
|
};
|
|
|
|
extraSetup = mkOption {
|
|
type = types.lines;
|
|
default = "";
|
|
description = "Shell fragments to be run after the system environment has been created. This should only be used for things that need to modify the internals of the environment, e.g. generating MIME caches. The environment being built can be accessed at $out.";
|
|
};
|
|
};
|
|
|
|
};
|
|
|
|
|
|
###### implementation
|
|
|
|
config = {
|
|
|
|
build.activation.installPackages = ''
|
|
if [[ -e "${config.user.home}/.nix-profile/manifest.json" ]]; then
|
|
# manual removal and installation as two non-atomical steps is required
|
|
# because of https://github.com/NixOS/nix/issues/6349
|
|
|
|
nix_previous="$(command -v nix)"
|
|
|
|
nix profile list \
|
|
| grep 'nix-on-droid-path$' \
|
|
| cut -d ' ' -f 4 \
|
|
| xargs -t $DRY_RUN_CMD nix profile remove $VERBOSE_ARG
|
|
|
|
$DRY_RUN_CMD $nix_previous profile install ${cfg.path}
|
|
|
|
unset nix_previous
|
|
else
|
|
$DRY_RUN_CMD nix-env --install ${cfg.path}
|
|
fi
|
|
'';
|
|
|
|
environment = {
|
|
packages = [
|
|
(pkgs.callPackage ../../nix-on-droid { nix = config.nix.package; })
|
|
pkgs.bashInteractive
|
|
pkgs.cacert
|
|
pkgs.coreutils
|
|
pkgs.less # since nix tools really want a pager available, #27
|
|
config.nix.package
|
|
];
|
|
|
|
path = pkgs.buildEnv {
|
|
name = "nix-on-droid-path";
|
|
|
|
paths = cfg.packages;
|
|
|
|
inherit (cfg) extraOutputsToInstall;
|
|
|
|
postBuild = cfg.extraSetup;
|
|
|
|
meta = {
|
|
description = "Environment of packages installed through Nix-on-Droid.";
|
|
};
|
|
};
|
|
};
|
|
|
|
};
|
|
|
|
}
|