Loading .git-blame-ignore-revs +3 −0 Original line number Diff line number Diff line Loading @@ -212,3 +212,6 @@ ce21e97a1f20dee15da85c084f9d1148d84f853b # format files with nixfmt (#347275) adb9714bd909df283c66bbd641bd631ff50a4260 # treewide: incus packages 9ab59bb5fb943ad6740f64f5a79eae9642fb8211 nixos/modules/virtualisation/lxc-image-metadata.nix +67 −42 Original line number Diff line number Diff line { lib, config, pkgs, ... }: { lib, config, pkgs, ... }: let templateSubmodule = {...}: { templateSubmodule = { ... }: { options = { enable = lib.mkEnableOption "this template"; Loading @@ -28,24 +35,37 @@ let toYAML = name: data: pkgs.writeText name (lib.generators.toYAML { } data); cfg = config.virtualisation.lxc; templates = if cfg.templates != {} then let list = lib.mapAttrsToList (name: value: { inherit name; } // value) (lib.filterAttrs (name: value: value.enable) cfg.templates); templates = if cfg.templates != { } then let list = lib.mapAttrsToList (name: value: { inherit name; } // value) ( lib.filterAttrs (name: value: value.enable) cfg.templates ); in { files = map (tpl: { source = tpl.template; target = "/templates/${tpl.name}.tpl"; }) list; properties = lib.listToAttrs (map (tpl: lib.nameValuePair tpl.target { properties = lib.listToAttrs ( map ( tpl: lib.nameValuePair tpl.target { when = tpl.when; template = "${tpl.name}.tpl"; properties = tpl.properties; }) list); } else { files = []; properties = {}; }; ) list ); } else { files = [ ]; properties = { }; }; in { in { imports = [ ../image/file-options.nix ]; Loading Loading @@ -91,7 +111,10 @@ in { }; config = { system.nixos.tags = [ "lxc" "metadata" ]; system.nixos.tags = [ "lxc" "metadata" ]; image.extension = "tar.xz"; image.filePath = "tarball/${config.image.fileName}"; system.build.image = config.system.build.metadata; Loading @@ -100,7 +123,9 @@ in { contents = [ { source = toYAML "metadata.yaml" { architecture = builtins.elemAt (builtins.match "^([a-z0-9_]+).+" (toString pkgs.stdenv.hostPlatform.system)) 0; architecture = builtins.elemAt (builtins.match "^([a-z0-9_]+).+" ( toString pkgs.stdenv.hostPlatform.system )) 0; creation_date = 1; properties = { description = "${config.system.nixos.distroName} ${config.system.nixos.codeName} ${config.system.nixos.label} ${pkgs.stdenv.hostPlatform.system}"; Loading nixos/modules/virtualisation/lxc.nix +53 −48 Original line number Diff line number Diff line # LXC Configuration { config, lib, pkgs, ... }: { config, lib, pkgs, ... }: let cfg = config.virtualisation.lxc; Loading @@ -12,8 +17,7 @@ in }; options.virtualisation.lxc = { enable = lib.mkOption { enable = lib.mkOption { type = lib.types.bool; default = false; description = '' Loading @@ -25,8 +29,7 @@ in unprivilegedContainers = lib.mkEnableOption "support for unprivileged users to launch containers"; systemConfig = lib.mkOption { systemConfig = lib.mkOption { type = lib.types.lines; default = ""; description = '' Loading @@ -36,8 +39,7 @@ in }; package = lib.mkPackageOption pkgs "lxc" { }; defaultConfig = lib.mkOption { defaultConfig = lib.mkOption { type = lib.types.lines; default = ""; description = '' Loading @@ -46,8 +48,7 @@ in ''; }; usernetConfig = lib.mkOption { usernetConfig = lib.mkOption { type = lib.types.lines; default = ""; description = '' Loading @@ -56,8 +57,7 @@ in ''; }; bridgeConfig = lib.mkOption { bridgeConfig = lib.mkOption { type = lib.types.lines; default = ""; description = '' Loading Loading @@ -108,7 +108,12 @@ in lxc-net = { enable = true; wantedBy = [ "multi-user.target" ]; path = [ pkgs.iproute2 pkgs.iptables pkgs.getent pkgs.dnsmasq ]; path = [ pkgs.iproute2 pkgs.iptables pkgs.getent pkgs.dnsmasq ]; }; }; }; Loading nixos/modules/virtualisation/lxcfs.nix +25 −20 Original line number Diff line number Diff line # LXC Configuration { config, lib, pkgs, ... }: { config, lib, pkgs, ... }: let cfg = config.virtualisation.lxc.lxcfs; in { in { meta = { maintainers = lib.teams.lxc.members; }; ###### interface options.virtualisation.lxc.lxcfs = { enable = lib.mkOption { enable = lib.mkOption { type = lib.types.bool; default = false; description = '' Loading nixos/tests/incus/container.nix +141 −127 Original line number Diff line number Diff line import ../make-test-python.nix ({ pkgs, lib, extra ? {}, name ? "incus-container", incus ? pkgs.incus-lts, ... } : import ../make-test-python.nix ( { pkgs, lib, extra ? { }, name ? "incus-container", incus ? pkgs.incus-lts, ... }: let releases = import ../../release.nix { Loading @@ -7,12 +15,15 @@ let documentation.enable = lib.mkForce false; boot.kernel.sysctl."net.ipv4.ip_forward" = "1"; } extra; } extra; }; container-image-metadata = "${releases.incusContainerMeta.${pkgs.stdenv.hostPlatform.system}}/tarball/nixos-system-${pkgs.stdenv.hostPlatform.system}.tar.xz"; container-image-rootfs = "${releases.incusContainerImage.${pkgs.stdenv.hostPlatform.system}}/nixos-lxc-image-${pkgs.stdenv.hostPlatform.system}.squashfs"; container-image-metadata = "${ releases.incusContainerMeta.${pkgs.stdenv.hostPlatform.system} }/tarball/nixos-image-lxc-*-${pkgs.stdenv.hostPlatform.system}.tar.xz"; container-image-rootfs = "${ releases.incusContainerImage.${pkgs.stdenv.hostPlatform.system} }/nixos-lxc-image-${pkgs.stdenv.hostPlatform.system}.squashfs"; in { inherit name; Loading @@ -21,7 +32,9 @@ in maintainers = lib.teams.lxc.members; }; nodes.machine = { ... }: { nodes.machine = { ... }: { virtualisation = { # Ensure test VM has enough resources for creating and managing guests cores = 2; Loading Loading @@ -137,4 +150,5 @@ in machine.succeed("systemctl stop incus") machine.succeed(f"ps {pid}") ''; }) } ) Loading
.git-blame-ignore-revs +3 −0 Original line number Diff line number Diff line Loading @@ -212,3 +212,6 @@ ce21e97a1f20dee15da85c084f9d1148d84f853b # format files with nixfmt (#347275) adb9714bd909df283c66bbd641bd631ff50a4260 # treewide: incus packages 9ab59bb5fb943ad6740f64f5a79eae9642fb8211
nixos/modules/virtualisation/lxc-image-metadata.nix +67 −42 Original line number Diff line number Diff line { lib, config, pkgs, ... }: { lib, config, pkgs, ... }: let templateSubmodule = {...}: { templateSubmodule = { ... }: { options = { enable = lib.mkEnableOption "this template"; Loading @@ -28,24 +35,37 @@ let toYAML = name: data: pkgs.writeText name (lib.generators.toYAML { } data); cfg = config.virtualisation.lxc; templates = if cfg.templates != {} then let list = lib.mapAttrsToList (name: value: { inherit name; } // value) (lib.filterAttrs (name: value: value.enable) cfg.templates); templates = if cfg.templates != { } then let list = lib.mapAttrsToList (name: value: { inherit name; } // value) ( lib.filterAttrs (name: value: value.enable) cfg.templates ); in { files = map (tpl: { source = tpl.template; target = "/templates/${tpl.name}.tpl"; }) list; properties = lib.listToAttrs (map (tpl: lib.nameValuePair tpl.target { properties = lib.listToAttrs ( map ( tpl: lib.nameValuePair tpl.target { when = tpl.when; template = "${tpl.name}.tpl"; properties = tpl.properties; }) list); } else { files = []; properties = {}; }; ) list ); } else { files = [ ]; properties = { }; }; in { in { imports = [ ../image/file-options.nix ]; Loading Loading @@ -91,7 +111,10 @@ in { }; config = { system.nixos.tags = [ "lxc" "metadata" ]; system.nixos.tags = [ "lxc" "metadata" ]; image.extension = "tar.xz"; image.filePath = "tarball/${config.image.fileName}"; system.build.image = config.system.build.metadata; Loading @@ -100,7 +123,9 @@ in { contents = [ { source = toYAML "metadata.yaml" { architecture = builtins.elemAt (builtins.match "^([a-z0-9_]+).+" (toString pkgs.stdenv.hostPlatform.system)) 0; architecture = builtins.elemAt (builtins.match "^([a-z0-9_]+).+" ( toString pkgs.stdenv.hostPlatform.system )) 0; creation_date = 1; properties = { description = "${config.system.nixos.distroName} ${config.system.nixos.codeName} ${config.system.nixos.label} ${pkgs.stdenv.hostPlatform.system}"; Loading
nixos/modules/virtualisation/lxc.nix +53 −48 Original line number Diff line number Diff line # LXC Configuration { config, lib, pkgs, ... }: { config, lib, pkgs, ... }: let cfg = config.virtualisation.lxc; Loading @@ -12,8 +17,7 @@ in }; options.virtualisation.lxc = { enable = lib.mkOption { enable = lib.mkOption { type = lib.types.bool; default = false; description = '' Loading @@ -25,8 +29,7 @@ in unprivilegedContainers = lib.mkEnableOption "support for unprivileged users to launch containers"; systemConfig = lib.mkOption { systemConfig = lib.mkOption { type = lib.types.lines; default = ""; description = '' Loading @@ -36,8 +39,7 @@ in }; package = lib.mkPackageOption pkgs "lxc" { }; defaultConfig = lib.mkOption { defaultConfig = lib.mkOption { type = lib.types.lines; default = ""; description = '' Loading @@ -46,8 +48,7 @@ in ''; }; usernetConfig = lib.mkOption { usernetConfig = lib.mkOption { type = lib.types.lines; default = ""; description = '' Loading @@ -56,8 +57,7 @@ in ''; }; bridgeConfig = lib.mkOption { bridgeConfig = lib.mkOption { type = lib.types.lines; default = ""; description = '' Loading Loading @@ -108,7 +108,12 @@ in lxc-net = { enable = true; wantedBy = [ "multi-user.target" ]; path = [ pkgs.iproute2 pkgs.iptables pkgs.getent pkgs.dnsmasq ]; path = [ pkgs.iproute2 pkgs.iptables pkgs.getent pkgs.dnsmasq ]; }; }; }; Loading
nixos/modules/virtualisation/lxcfs.nix +25 −20 Original line number Diff line number Diff line # LXC Configuration { config, lib, pkgs, ... }: { config, lib, pkgs, ... }: let cfg = config.virtualisation.lxc.lxcfs; in { in { meta = { maintainers = lib.teams.lxc.members; }; ###### interface options.virtualisation.lxc.lxcfs = { enable = lib.mkOption { enable = lib.mkOption { type = lib.types.bool; default = false; description = '' Loading
nixos/tests/incus/container.nix +141 −127 Original line number Diff line number Diff line import ../make-test-python.nix ({ pkgs, lib, extra ? {}, name ? "incus-container", incus ? pkgs.incus-lts, ... } : import ../make-test-python.nix ( { pkgs, lib, extra ? { }, name ? "incus-container", incus ? pkgs.incus-lts, ... }: let releases = import ../../release.nix { Loading @@ -7,12 +15,15 @@ let documentation.enable = lib.mkForce false; boot.kernel.sysctl."net.ipv4.ip_forward" = "1"; } extra; } extra; }; container-image-metadata = "${releases.incusContainerMeta.${pkgs.stdenv.hostPlatform.system}}/tarball/nixos-system-${pkgs.stdenv.hostPlatform.system}.tar.xz"; container-image-rootfs = "${releases.incusContainerImage.${pkgs.stdenv.hostPlatform.system}}/nixos-lxc-image-${pkgs.stdenv.hostPlatform.system}.squashfs"; container-image-metadata = "${ releases.incusContainerMeta.${pkgs.stdenv.hostPlatform.system} }/tarball/nixos-image-lxc-*-${pkgs.stdenv.hostPlatform.system}.tar.xz"; container-image-rootfs = "${ releases.incusContainerImage.${pkgs.stdenv.hostPlatform.system} }/nixos-lxc-image-${pkgs.stdenv.hostPlatform.system}.squashfs"; in { inherit name; Loading @@ -21,7 +32,9 @@ in maintainers = lib.teams.lxc.members; }; nodes.machine = { ... }: { nodes.machine = { ... }: { virtualisation = { # Ensure test VM has enough resources for creating and managing guests cores = 2; Loading Loading @@ -137,4 +150,5 @@ in machine.succeed("systemctl stop incus") machine.succeed(f"ps {pid}") ''; }) } )