File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 262262 interpreter = mkDefault interpreterReg ;
263263 fixBinary = mkDefault useStaticEmulator ;
264264 wrapInterpreterInShell = mkDefault ( ! config . preserveArgvZero && ! config . fixBinary ) ;
265- interpreterSandboxPath = mkDefault ( dirOf ( dirOf config . interpreter ) ) ;
265+ interpreterSandboxPath = mkDefault (
266+ if config . fixBinary then null else dirOf ( dirOf config . interpreter )
267+ ) ;
266268 }
267269 // ( magics . ${ system } or ( throw "Cannot create binfmt registration for system ${ system } " ) )
268270 ) ;
276278 let
277279 ruleFor = system : cfg . registrations . ${ system } ;
278280 hasWrappedRule = lib . any ( system : ( ruleFor system ) . wrapInterpreterInShell ) cfg . emulatedSystems ;
281+ allFixBinary = lib . all ( system : ( ruleFor system ) . fixBinary ) cfg . emulatedSystems ;
279282 in
280- [ "/run/binfmt" ]
283+ lib . optional ( ! allFixBinary ) "/run/binfmt"
281284 ++ lib . optional hasWrappedRule "${ pkgs . bash } "
282- ++ ( map ( system : ( ruleFor system ) . interpreterSandboxPath ) cfg . emulatedSystems ) ;
285+ ++ lib . filter ( x : x != null ) (
286+ map ( system : ( ruleFor system ) . interpreterSandboxPath ) cfg . emulatedSystems
287+ ) ;
283288 } ;
284289
285290 environment . etc . "binfmt.d/nixos.conf" . source = builtins . toFile "binfmt_nixos.conf" (
Original file line number Diff line number Diff line change 103103 chroot = makeTest {
104104 name = "systemd-binfmt-chroot" ;
105105 nodes . machine =
106- { pkgs , lib , ... } :
106+ {
107+ pkgs ,
108+ lib ,
109+ config ,
110+ ...
111+ } :
107112 {
108113 boot . binfmt . emulatedSystems = [
109114 "aarch64-linux"
121126 echo 42 | chroot /tmp/chroot /yaml2json | grep 42
122127 '' )
123128 ] ;
129+
130+ assertions = [
131+ {
132+ assertion = config . nix . settings . extra-sandbox-paths == [ ] ;
133+ message = "Using binfmt_misc with static emulators, nix.settings.extra-sandbox-paths should be empty" ;
134+ }
135+ ] ;
124136 } ;
125137 testScript = ''
126138 machine.start()
You can’t perform that action at this time.
0 commit comments