Nixpkgs: nixos-option intermittently fails

Created on 28 Jan 2020  路  4Comments  路  Source: NixOS/nixpkgs

Describe the bug
The nixos-option command occasionally (and infrequently) fails with syntax error, unexpected ID, expecting '{'. Re-running the command a second time generally works as expected.

$ nixos-option services.xserver
error: syntax error, unexpected ID, expecting '{'
An error occurred while looking for attribute names. Are you sure that 'services.xserver' exists?

$ nixos-option services.xserver
This attribute set contains:
autoRepeatDelay
autoRepeatInterval
...
xrandrHeads

I haven't been able to identify a pattern to the occurrences, so this is not easily reproducible.

To Reproduce
Steps to reproduce the behavior:

  1. Run a nixos-option command, e.g. nixos-option services.xserver

Expected behavior
Description of the specified option printed to stdout.

Metadata

  • system: "x86_64-linux"
  • host os: Linux 4.19.66, NixOS, 19.09pre188690.8746c77a383 (Loris)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.2.2
  • channels(root): "nixos-19.09pre188690.8746c77a383"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs
bug nixos

All 4 comments

@chkno

Ooh, yup, I see that. I ran nixos-option services.xserver 1000 times and got:

976 Normal output
13 An empty attribute list with no indication that anything went wrong!
11 The error you mention

There's a new, rewritten-from-scratch nixos-option on the unstable branch that will go out with the 20.03 release. The new implementation does not have this problem. I ran it 1000 times and got:

992 Normal output
8 The note waiting for lock on '/home/username/.cache/nix/.... followed by normal output

I don't think it makes sense to try to fix this problem in the old version with the new version expected to be released so soon, and usable now from the unstable channel. Sorry. :(

Here is an example of how to use the new version transiently:

$(nix-build '<nixpkgs/nixos>' -A config.system.build.nixos-option -I nixpkgs=https://nixos.org/channels/nixpkgs-unstable/nixexprs.tar.xz)/bin/nixos-option services.xserver

And here's an example overlay that would allow one to "install" the new version with nix-env -iA nixos.new-nixos-option:

# in ~/.config/nixpkgs/overlays/new-nixos-option.nix
let
  unstable = builtins.fetchGit {
    url = "https://github.com/NixOS/nixpkgs.git";
    ref = "master";
    rev = "9300e2038d15b1f9639e119e26d6f4b7e523d56f";
  };
in self: super: {
  new-nixos-option = (import unstable { }).callPackage
    "${unstable}/nixos/modules/installer/tools/nixos-option" { };
}

(Remember to undo this (nix-env --uninstall nixos-option and remove the overlay file) after the 20.03 release so you don't get stuck on this version of nixos-option forever. :)

Oh, I thought this was an issue with unstable. @ivanbrennan this will be fixed in the next release.
Closing.

@chkno Thanks! This bug is so infrequent (and inconsequential) I don't mind waiting for the next release. Thanks for describing the workaround though, it's much appreciated!

Was this page helpful?
0 / 5 - 0 ratings