git.iko.soy/typeable/nixpkgs
on master help sign in
nixos: container profile, update /init symlink on rebuild
f2e20faJaka Hudoklin
nixos/modules/profiles/container.nix+8−7
@@ -20,17 +20,18 @@ in {
20 contents = [];
20 contents = [];
21 extraArgs = "--owner=0";
21 extraArgs = "--owner=0";
22
22
23− # Some container managers like lxc need these
24− extraCommands = "mkdir -p proc sys dev";
25−
26 # Add init script to image
23 # Add init script to image
27 storeContents = [
24 storeContents = [
28 { object = config.system.build.toplevel + "/init";
25 { object = config.system.build.toplevel + "/init";
29 symlink = "/init";
26 symlink = "/init";
30 }
27 }
31 ] ++ (pkgs2storeContents [ pkgs.stdenv ]);
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 boot.postBootCommands =
35 boot.postBootCommands =
35 ''
36 ''
36 # After booting, register the contents of the Nix store in the Nix
37 # After booting, register the contents of the Nix store in the Nix
@@ -46,12 +47,12 @@ in {
46 ${config.nix.package}/bin/nix-env -p /nix/var/nix/profiles/system --set /run/current-system
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 # Disable some features that are not useful in a container.
50 # Disable some features that are not useful in a container.
52 sound.enable = mkDefault false;
51 sound.enable = mkDefault false;
53 services.udisks2.enable = mkDefault false;
52 services.udisks2.enable = mkDefault false;
54
53
55− # Shut up warnings about not having a boot loader.
54+ # Install new init script
56− system.build.installBootLoader = "${pkgs.coreutils}/bin/true";
55+ system.activationScripts.installInitScript = ''
56+ ln -fs $systemConfig/init /init
57+ '';
57}
58}