forked from devcontainers/features
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost-install-steps.sh
More file actions
executable file
·37 lines (33 loc) · 1.02 KB
/
Copy pathpost-install-steps.sh
File metadata and controls
executable file
·37 lines (33 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
set -e
echo "(*) Executing post-installation steps..."
# if not starts with "nixpkgs." add it as prefix to package name
add_nixpkgs_prefix() {
local packages=$1
local -a addr
IFS=' ' read -ra addr <<<"$packages"
for i in "${!addr[@]}"; do
if [[ ${addr[i]} != nixpkgs.* ]]; then
addr[i]="nixpkgs.${addr[i]}"
fi
done
IFS=' ' echo "${addr[*]}"
}
# Install list of packages in profile if specified.
if [ ! -z "${PACKAGES}" ] && [ "${PACKAGES}" != "none" ]; then
if [ "${USEATTRIBUTEPATH}" = "true" ]; then
PACKAGES=$(add_nixpkgs_prefix "$PACKAGES")
echo "Installing packages \"${PACKAGES}\" in profile..."
nix-env -iA ${PACKAGES}
else
echo "Installing packages \"${PACKAGES}\" in profile..."
nix-env --install ${PACKAGES}
fi
fi
# Install Nix flake in profile if specified
if [ ! -z "${FLAKEURI}" ] && [ "${FLAKEURI}" != "none" ]; then
echo "Installing flake ${FLAKEURI} in profile..."
nix profile install "${FLAKEURI}"
fi
nix-collect-garbage --delete-old
nix-store --optimise