# 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."; }; }; }; ###### 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; meta = { description = "Environment of packages installed through Nix-on-Droid."; }; }; }; }; }