@@ -176,24 +176,20 @@ let
176
176
"${ k } :x:${ toString gid } :${ lib . concatStringsSep "," members } " ;
177
177
groupContents = ( lib . concatStringsSep "\n " ( lib . attrValues ( lib . mapAttrs groupToGroup groups ) ) ) ;
178
178
179
- defaultNixConf = {
180
- sandbox = "false" ;
179
+ toConf =
180
+ with pkgs . lib . generators ;
181
+ toKeyValue {
182
+ mkKeyValue = mkKeyValueDefault {
183
+ mkValueString = v : if lib . isList v then lib . concatStringsSep " " v else mkValueStringDefault { } v ;
184
+ } " = " ;
185
+ } ;
186
+
187
+ nixConfContents = toConf {
188
+ sandbox = false ;
181
189
build-users-group = "nixbld" ;
182
190
trusted-public-keys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" ] ;
183
191
} ;
184
192
185
- nixConfContents =
186
- ( lib . concatStringsSep "\n " (
187
- lib . mapAttrsToList (
188
- n : v :
189
- let
190
- vStr = if builtins . isList v then lib . concatStringsSep " " v else v ;
191
- in
192
- "${ n } = ${ vStr } "
193
- ) ( defaultNixConf // nixConf )
194
- ) )
195
- + "\n " ;
196
-
197
193
userHome = if uid == 0 then "/root" else "/home/${ uname } " ;
198
194
199
195
baseSystem =
211
207
echo "[]" > $out/manifest.nix
212
208
fi
213
209
'' ;
214
- rootEnv = buildPackages . buildEnv {
215
- name = "root-profile-env" ;
216
- paths = defaultPkgs ;
217
- } ;
210
+ # doc/manual/source/command-ref/files/manifest.nix.md
218
211
manifest = buildPackages . runCommand "manifest.nix" { } ''
219
212
cat > $out <<EOF
220
213
[
@@ -244,11 +237,15 @@ let
244
237
]
245
238
EOF
246
239
'' ;
247
- profile = buildPackages . runCommand "user-environment" { } ''
248
- mkdir $out
249
- cp -a ${ rootEnv } /* $out/
250
- ln -s ${ manifest } $out/manifest.nix
251
- '' ;
240
+ profile = buildPackages . buildEnv {
241
+ name = "root-profile-env" ;
242
+ paths = defaultPkgs ;
243
+
244
+ postBuild = ''
245
+ mv $out/manifest $out/manifest.nix
246
+ '' ;
247
+ inherit manifest ;
248
+ } ;
252
249
flake-registry-path =
253
250
if ( flake-registry == null ) then
254
251
null
280
277
set -x
281
278
mkdir -p $out/etc
282
279
280
+ # may get replaced by pkgs.dockerTools.caCertificates
283
281
mkdir -p $out/etc/ssl/certs
284
282
ln -s /nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt $out/etc/ssl/certs
285
283
@@ -307,16 +305,20 @@ let
307
305
mkdir -p $out${ userHome }
308
306
mkdir -p $out/nix/var/nix/profiles/per-user/${ uname }
309
307
308
+ # see doc/manual/source/command-ref/files/profiles.md
310
309
ln -s ${ profile } $out/nix/var/nix/profiles/default-1-link
311
310
ln -s /nix/var/nix/profiles/default-1-link $out/nix/var/nix/profiles/default
312
311
312
+ # see doc/manual/source/command-ref/files/channels.md
313
313
ln -s ${ channel } $out/nix/var/nix/profiles/per-user/${ uname } /channels-1-link
314
314
ln -s /nix/var/nix/profiles/per-user/${ uname } /channels-1-link $out/nix/var/nix/profiles/per-user/${ uname } /channels
315
315
316
+ # see doc/manual/source/command-ref/files/default-nix-expression.md
316
317
mkdir -p $out${ userHome } /.nix-defexpr
317
318
ln -s /nix/var/nix/profiles/per-user/${ uname } /channels $out${ userHome } /.nix-defexpr/channels
318
319
echo "${ channelURL } ${ channelName } " > $out${ userHome } /.nix-channels
319
320
321
+ # may get replaced by pkgs.dockerTools.binSh & pkgs.dockerTools.usrBinEnv
320
322
mkdir -p $out/bin $out/usr/bin
321
323
ln -s ${ lib . getExe' coreutils-full "env" } $out/usr/bin/env
322
324
ln -s ${ lib . getExe bashInteractive } $out/bin/sh
0 commit comments