erikarvstedt / extra-container

Run declarative NixOS containers without full system rebuilds

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

missing system.stateVersion config

SCOTT-HAMILTON opened this issue · comments

When running the demo command from the README with extra-container 0.9 installed with https://github.com/erikarvstedt/extra-container#nixos-stable-without-flake-support

$ sudo extra-container create --start <<'EOF'
{
  containers.demo = {
    privateNetwork = true;
    hostAddress = "10.250.0.1";
    localAddress = "10.250.0.2";

    config = { pkgs, ... }: {
      systemd.services.hello = {
        wantedBy = [ "multi-user.target" ];
        script = ''
          while true; do
            echo hello | ${pkgs.netcat}/bin/nc -lN 50
          done
        '';
      };
      networking.firewall.allowedTCPPorts = [ 50 ];
    };
  };
}
EOF

I get this error:

Building containers...
error: attribute 'stateVersion' missing

       at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/virtualisation/nixos-containers.nix:7:56:

            6|
            7|   configurationPrefix = optionalString (versionAtLeast config.system.stateVersion "22.05") "nixos-";
             |                                                        ^
            8|   configurationDirectoryName = "${configurationPrefix}containers";
(use '--show-trace' to show detailed location information)
$ nix-info -m --sandbox --host-os
  • system: "x86_64-linux"
  • host os: Linux 5.15.46, NixOS, 22.05 (Quokka), 22.05.926.8b538fcb329
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.8.1
  • channels(root): "home-manager-22.05.tar.gz, nixos-22.05, nixos-unstable, nixpkgs-22.05, nixpkgs-unstable"
  • channels(instanttest): "home-manager-20.09, nixos-20.09.4407.1c1f5649bb9, nixos-unstable-21.11pre332033.715f6341195, nixpkgs-20.09.4407.1c1f5649bb9, nixpkgs-unstable-21.11pre332842.8afc4e54366"
  • channels(scott): "home-manager-22.05.tar.gz, nixgl, nixos-22.05, nixos-unstable, nixpkgs-22.05, nixpkgs-unstable, rust-overlay, shamilton"
  • nixpkgs: /home/scott/.nix-defexpr/channels/nixpkgs

I thought it was just a matter of adding system.stateVersion = "22.05" to the nixos container config, but apparently it's something else:

$ sudo extra-container create --start <<'EOF'
{
  containers.demo = {
    privateNetwork = true;
    hostAddress = "10.250.0.1";
    localAddress = "10.250.0.2";

    config = { pkgs, ... }: {
      systemd.services.hello = {
        wantedBy = [ "multi-user.target" ];
        script = ''
          while true; do
            echo hello | ${pkgs.netcat}/bin/nc -lN 50
          done
        '';
      };
      networking.firewall.allowedTCPPorts = [ 50 ];
      system.stateVersion = "22.05";    # ADDED THIS LINE
    };
  };
}
EOF
Building containers...
error: attribute 'stateVersion' missing

       at /etc/current-nixpkgs/nixos/modules/virtualisation/nixos-containers.nix:7:56:

            6|
            7|   configurationPrefix = optionalString (versionAtLeast config.system.stateVersion "22.05") "nixos-";
             |                                                        ^
            8|   configurationDirectoryName = "${configurationPrefix}containers";
(use '--show-trace' to show detailed location information)

Looks like something broke between nixos-21.11 and nixos-22.05. Bisecting...

This is a known bug, I'll fix this soon!

This is a known bug, I'll fix this soon!

Thanks!

(For some reason I got false results from git bisect, but manually bisected to NixOS/nixpkgs@f535d6f.)

Fixed in 738e506.

Thanks!