Skip to content

nh os info silently exited when running nixos is a specialisation generation #508

@cloud-yu

Description

@cloud-yu

I have confirmed that this is a bug related to nh

  • This is a bug, and not an user error or a support request. I understand that my issue will be closed if it is not a bug in NH.
  • I have checked the issues tab and confirmed that my issue has not yet been reported. I understand that my issue will be closed if it is a duplicate.

Description

When nixos running in a generation with specialisation, nh os info silently exited.

❯ NH_LOG='nh=DEBUG' nh os info
DEBUG Main {
    verbosity: Verbosity {
        verbose: 0,
        quiet: 0,
        phantom: PhantomData<clap_verbosity_flag::InfoLevel>,
    },
    elevation_program: None,
    command: Os(
        OsArgs {
            subcommand: Info(
                OsGenerationsArgs {
                    profile: Some(
                        "/nix/var/nix/profiles/system",
                    ),
                },
            ),
        },
    ),
} (nh/src/main.rs:29)
DEBUG NH_VERSION=4.2.0 NH_REV=Some("v4.2.0") (nh/src/main.rs:30)
DEBUG cmd=Exec { nix --version } (nh/src/commands.rs:577)
DEBUG cmd=Exec { nix --version } (nh/src/commands.rs:577)
DEBUG Version normalized: 'nix (Lix, like Nix) 2.93.3' -> '2.93.3' (nh/src/util.rs:106)
DEBUG Got the following output for nix path-info: Output {
    status: ExitStatus(
        unix_wait_status(
            0,
        ),
    ),
    stdout: "[{\"closureSize\":3997111848,\"deriver\":\"/nix/store/y44h6mscrp56bvcsc14klij20vw30m58-nixos-system-nixos-25.11.20251130.8bb5646.drv\",\"narHash\":\"sha256-SHZ6tGE0/yt1JcBBl4+BBoBSoEjtYpRFNCfiSNLVuk8=\",\"narSize\":19280,\"path\":\"/nix/store/858h0rzja79l9m18m02yi98niw4b1zfh-nixos-system-nixos-25.11.20251130.8bb5646\",\"references\":[\"/nix/store/35yc81pz0q5yba14lxhn5r3jx5yg6c3l-bash-interactive-5.3p3\",\"/nix/store/3c6r8gh8zrqw8xmncmlj9vivz9rz6r30-util-linux-2.41.2-bin\",\"/nix/store/48p58ls5qwfpn6qwd0ls61akcr97w4rz-switch-to-configuration-0.1.0\",\"/nix/store/522vd4hl7dyk98cbi0y57vrhrlpg4sfp-local-cmds\",\"/nix/store/7gs397m7lpj02q8ag566bqsch4q7mdvq-etc\",\"/nix/store/7sb1nkpf82nb5kj7qc4bbqkwj1l1mdv9-update-users-groups.pl\",\"/nix/store/858h0rzja79l9m18m02yi98niw4b1zfh-nixos-system-nixos-25.11.20251130.8bb5646\",\"/nix/store/914x32c982bs3i1998yxvkg9svm3ycr5-shadow-4.18.0\",\"/nix/store/9fdfn5ra4ji67f4ifp6lyfjsww5c4nxx-perl-5.40.0-env\",\"/nix/store/9msqnxihyqc1qckwlsjixzz78xpav0hr-users-groups.json\",\"/nix/store/9vmxdn26pggj3glazmb68vhcf4smflvz-glibc-locales-2.40-66\",\"/nix/store/av4xw9f56xlx5pgv862wabfif6m1yc0a-findutils-4.10.0\",\"/nix/store/dl7wg5yg8h12a5bc97aqj4mdlywhihy1-getent-glibc-2.40-66\",\"/nix/store/imad8dvhp77h0pjbckp6wvmnyhp8dpgg-coreutils-9.8\",\"/nix/store/l9pbwhp06c7b122dj7km9j68zqwrka67-users-groups.json\",\"/nix/store/mhiwv5wazpj5kbvxnxxj4wnvyag6i0vc-sh\",\"/nix/store/mhxn5kwnri3z9hdzi3x0980id65p0icn-lib.sh\",\"/nix/store/pn5f4sck8ff0mdkqn21cl0zqij1r721l-pre-switch-checks\",\"/nix/store/q26j77br78jg5f4jh5n9wy1yk36grgk7-nixos-wsl-recovery\",\"/nix/store/q6wgv06q39bfhx2xl8ysc05wi6m2zdss-glibc-2.40-66-bin\",\"/nix/store/rg5rf512szdxmnj9qal3wfdnpfsx38qi-setup-etc.pl\",\"/nix/store/rlq03x4cwf8zn73hxaxnx0zn5q9kifls-bash-5.3p3\",\"/nix/store/vzr65nawnnqj58vwdf01cg15xyjyyazh-mounts.sh\",\"/nix/store/x3zjxxz8m4ki88axp0gn8q8m6bldybba-gnugrep-3.12\",\"/nix/store/xn2vzkk0ab5gn9d1h20yaghb652i34v1-perl-5.40.0-env\",\"/nix/store/yk1kqigwvvmh1v8yqwqg5xh4vyaq8zny-system-path\",\"/nix/store/ywnz6hd3afxkhg4j0mysfm77yzfvk0s3-nixos-wsl-utils-1.0.0\",\"/nix/store/zf8qy81dsw1vqwgh9p9n2h40s1k0g2l1-systemd-258.2\"],\"registrationTime\":1764744131,\"ultimate\":true,\"valid\":true}]",
    stderr: "",
} (nh/src/generations.rs:206)
DEBUG current_generation=None (nh/src/generations.rs:242)

WHA'S HAPPENING

When nixos switch to a generations with specialisation, /run/current-system not directly link to basement generations in /nix/var/nix/profiles/, it link to basement_generation/specialisation/xxx

Check if this generation is the current one should compare /nix/var/nix/profiles/system with /nix/var/nix/profiles/system-xx-link

❯ realpath /run/current-system
/nix/store/858h0rzja79l9m18m02yi98niw4b1zfh-nixos-system-nixos-25.11.20251130.8bb5646
❯ eza -lah /nix/var/nix/profiles
Permissions Size User Date Modified Name
drwxr-xr-x     - root 18 Aug 16:26  per-user
lrwxrwxrwx     - root 13 Dec 15:41  system -> /nix/var/nix/profiles/system-105-link
lrwxrwxrwx     - root 23 Oct 19:19  system-101-link -> /nix/store/aysfapyky8qsgm11bbzsig6rwlam6v20-nixos-system-nixos-25.05.20251021.481cf55
lrwxrwxrwx     - root 28 Oct 21:03  system-102-link -> /nix/store/1k35q6l0y4lr4dwfi9raxaf95h0dys9h-nixos-system-nixos-25.05.20251026.78e34d1
lrwxrwxrwx     - root  4 Nov 11:37  system-103-link -> /nix/store/jg7w59ikgdb81b4ra23aca455vh7bhc0-nixos-system-nixos-25.05.20251101.3de8f8d
lrwxrwxrwx     - root  3 Dec 14:23  system-104-link -> /nix/store/rjcyvc45fd9w6dbqmfxr7sc0mm612p4a-nixos-system-nixos-25.05.20251201.6c8f0cc
lrwxrwxrwx     - root  3 Dec 14:42  system-105-link -> /nix/store/j2hnzjjd676sjcz1svc48yb0kdjy96n2-nixos-system-nixos-25.11.20251130.8bb5646
❯ eza -lah /nix/var/nix/profiles/system/specialisation
Permissions Size User Date Modified Name
lrwxrwxrwx     - root  1 Jan  1970  lix -> /nix/store/858h0rzja79l9m18m02yi98niw4b1zfh-nixos-system-nixos-25.11.20251130.8bb5646

Installation Method

Stable Release (nixpkgs, pkgs.nh from nixos-unstable or nixos-yy-mm)

Installation Method (Other)

No response

NH Version

v4.2.0

System Information

  • system: "x86_64-linux"
  • host os: Linux 6.6.87.2-microsoft-standard-WSL2, NixOS, 25.11 (Xantusia), 25.11.20251130.8bb5646
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Lix, like Nix) 2.93.3 System type: x86_64-linux Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux, x86_64-v4-linux Features: gc, signed-caches System configuration file: /etc/nix/nix.conf Store directory: /nix/store State directory: /nix/var/nix Data directory: /nix/store/kg6pv5f01vj5w6k7scy2zfvnkcgbifcw-lix-2.93.3/share
  • nixpkgs: /nix/store/dgp9wmspgm6zhl66f0c81rvg3v7wwbsb-source

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug (requires confirmation)User might have misclassified, or might be an AI hallucination. We literally don't know.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions