···26 "unshareUser" "unshareCgroup" "unshareUts" "unshareNet" "unsharePid" "unshareIpc"
27 ]);
2829- etcBindFlags = let
30 files = [
31 # NixOS Compatibility
32 "static"
···69 "ca-certificates"
70 "pki"
71 ];
72- in concatStringsSep "\n "
73- (map (file: "--ro-bind-try $(${coreutils}/bin/readlink -m /etc/${file}) /etc/${file}") files);
7475 # Create this on the fly instead of linking from /nix
76 # The container might have to modify it and re-run ldconfig if there are
···99 '';
100101 bwrapCmd = { initArgs ? "" }: ''
102- blacklist=(/nix /dev /proc /etc)
103 ro_mounts=()
104 symlinks=()
0105 for i in ${env}/*; do
106 path="/''${i##*/}"
107 if [[ $path == '/etc' ]]; then
108 :
109 elif [[ -L $i ]]; then
110 symlinks+=(--symlink "$(${coreutils}/bin/readlink "$i")" "$path")
111- blacklist+=("$path")
112 else
113 ro_mounts+=(--ro-bind "$i" "$path")
114- blacklist+=("$path")
115 fi
116 done
117···124 continue
125 fi
126 ro_mounts+=(--ro-bind "$i" "/etc$path")
0127 done
128 fi
12900000000000130 declare -a auto_mounts
131 # loop through all directories in the root
132 for dir in /*; do
133- # if it is a directory and it is not in the blacklist
134- if [[ -d "$dir" ]] && [[ ! "''${blacklist[@]}" =~ "$dir" ]]; then
135 # add it to the mount list
136 auto_mounts+=(--bind "$dir" "$dir")
137 fi
···179 --symlink /etc/ld.so.cache ${pkgsi686Linux.glibc}/etc/ld.so.cache \
180 --ro-bind ${pkgsi686Linux.glibc}/etc/rpc ${pkgsi686Linux.glibc}/etc/rpc \
181 --remount-ro ${pkgsi686Linux.glibc}/etc \
182- ${etcBindFlags}
183 "''${ro_mounts[@]}"
184 "''${symlinks[@]}"
185 "''${auto_mounts[@]}"
···26 "unshareUser" "unshareCgroup" "unshareUts" "unshareNet" "unsharePid" "unshareIpc"
27 ]);
2829+ etcBindEntries = let
30 files = [
31 # NixOS Compatibility
32 "static"
···69 "ca-certificates"
70 "pki"
71 ];
72+ in map (path: "/etc/${path}") files;
07374 # Create this on the fly instead of linking from /nix
75 # The container might have to modify it and re-run ldconfig if there are
···98 '';
99100 bwrapCmd = { initArgs ? "" }: ''
101+ ignored=(/nix /dev /proc /etc)
102 ro_mounts=()
103 symlinks=()
104+ etc_ignored=()
105 for i in ${env}/*; do
106 path="/''${i##*/}"
107 if [[ $path == '/etc' ]]; then
108 :
109 elif [[ -L $i ]]; then
110 symlinks+=(--symlink "$(${coreutils}/bin/readlink "$i")" "$path")
111+ ignored+=("$path")
112 else
113 ro_mounts+=(--ro-bind "$i" "$path")
114+ ignored+=("$path")
115 fi
116 done
117···124 continue
125 fi
126 ro_mounts+=(--ro-bind "$i" "/etc$path")
127+ etc_ignored+=("/etc$path")
128 done
129 fi
130131+ for i in ${lib.escapeShellArgs etcBindEntries}; do
132+ if [[ "''${etc_ignored[@]}" =~ "$i" ]]; then
133+ continue
134+ fi
135+ if [[ -L $i ]]; then
136+ symlinks+=(--symlink "$(${coreutils}/bin/readlink "$i")" "$i")
137+ else
138+ ro_mounts+=(--ro-bind-try "$i" "$i")
139+ fi
140+ done
141+142 declare -a auto_mounts
143 # loop through all directories in the root
144 for dir in /*; do
145+ # if it is a directory and it is not ignored
146+ if [[ -d "$dir" ]] && [[ ! "''${ignored[@]}" =~ "$dir" ]]; then
147 # add it to the mount list
148 auto_mounts+=(--bind "$dir" "$dir")
149 fi
···191 --symlink /etc/ld.so.cache ${pkgsi686Linux.glibc}/etc/ld.so.cache \
192 --ro-bind ${pkgsi686Linux.glibc}/etc/rpc ${pkgsi686Linux.glibc}/etc/rpc \
193 --remount-ro ${pkgsi686Linux.glibc}/etc \
0194 "''${ro_mounts[@]}"
195 "''${symlinks[@]}"
196 "''${auto_mounts[@]}"