Skip to content

nixos-generate-config: add 'lib' arg to configuration.nix#244653

Merged
roberth merged 1 commit intoNixOS:masterfrom
bjornfor:nixos-generate-config-emit-lib
Jul 23, 2023
Merged

nixos-generate-config: add 'lib' arg to configuration.nix#244653
roberth merged 1 commit intoNixOS:masterfrom
bjornfor:nixos-generate-config-emit-lib

Conversation

@bjornfor
Copy link
Contributor

Description of changes

Although 'lib' isn't needed by the default configuration, new NixOS uses
can get confused when being recommended configuration.nix snippets like

  systemd.services.NetworkManager-wait-online.enable = lib.mkForce false;

and have sudo nixos-rebuild switch fail with

  error: undefined variable 'lib'
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.11 Release Notes (or backporting 23.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Although 'lib' isn't needed by the default configuration, new NixOS uses
can get confused when being recommended configuration.nix snippets like

  systemd.services.NetworkManager-wait-online.enable = lib.mkForce false;

and have `sudo nixos-rebuild switch` fail with

  error: undefined variable 'lib'
@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Jul 21, 2023
@bjornfor bjornfor marked this pull request as ready for review July 21, 2023 12:02
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Jul 21, 2023
@bjornfor
Copy link
Contributor Author

@SuperSandro2000, @roberth: Can you please review? (You're the last people to touch this file.)

# and in the NixOS manual (accessible by running `nixos-help`).

{ config, pkgs, ... }:
{ config, lib, pkgs, ... }:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not go all the way and put options, utils and add a comment to document them?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

options is basically only useful to module authors and probably distracting for beginners, and I think utils is frowned upon

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it

@roberth roberth merged commit 35a0bd3 into NixOS:master Jul 23, 2023
@bjornfor bjornfor deleted the nixos-generate-config-emit-lib branch July 24, 2023 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants