nixos: container profile, update /init symlink on rebuild

+8 -7
+8 -7
nixos/modules/profiles/container.nix
··· 20 20 contents = []; 21 21 extraArgs = "--owner=0"; 22 22 23 - # Some container managers like lxc need these 24 - extraCommands = "mkdir -p proc sys dev"; 25 - 26 23 # Add init script to image 27 24 storeContents = [ 28 25 { object = config.system.build.toplevel + "/init"; 29 26 symlink = "/init"; 30 27 } 31 28 ] ++ (pkgs2storeContents [ pkgs.stdenv ]); 29 + 30 + # Some container managers like lxc need these 31 + extraCommands = "mkdir -p proc sys dev"; 32 32 }; 33 33 34 + boot.isContainer = true; 34 35 boot.postBootCommands = 35 36 '' 36 37 # After booting, register the contents of the Nix store in the Nix ··· 46 47 ${config.nix.package}/bin/nix-env -p /nix/var/nix/profiles/system --set /run/current-system 47 48 ''; 48 49 49 - boot.isContainer = true; 50 - 51 50 # Disable some features that are not useful in a container. 52 51 sound.enable = mkDefault false; 53 52 services.udisks2.enable = mkDefault false; 54 53 55 - # Shut up warnings about not having a boot loader. 56 - system.build.installBootLoader = "${pkgs.coreutils}/bin/true"; 54 + # Install new init script 55 + system.activationScripts.installInitScript = '' 56 + ln -fs $systemConfig/init /init 57 + ''; 57 58 }