{"action":"created","comment":{"url":"https://api.github.com/repos/NixOS/nixpkgs/pulls/comments/85813397","pull_request_review_id":6506130,"id":85813397,"diff_hunk":"@@ -93,16 +93,24 @@ rec {\n           visible = opt.visible or true;\n           readOnly = opt.readOnly or false;\n           type = opt.type.name or null;\n-        }\n-        // (if opt ? example then { example = scrubOptionValue opt.example; } else {})\n-        // (if opt ? default then { default = scrubOptionValue opt.default; } else {})\n-        // (if opt ? defaultText then { default = opt.defaultText; } else {});\n+        };\n+        docOptionDefault =\n+          if opt ? defaultText then { default = opt.defaultText; }\n+          else if opt ? default then { default = scrubOptionValue opt.default; }\n+          else { };\n+        docOptionExample =\n+          if opt ? example then { example = scrubOptionValue opt.example; }\n+          else if opt.type == lib.types.bool then\n+            { example = !docOptionDefault.default or false; }\n+          else if opt ? type && isBool (docOptionDefault.default or null) && opt.type.check (!docOptionDefault.default) then\n+            { example = !docOptionDefault.default or false; }","path":"lib/options.nix","position":18,"original_position":18,"commit_id":"d592d90fda41fc585f51e55677c1647f68404b3c","original_commit_id":"d592d90fda41fc585f51e55677c1647f68404b3c","user":{"login":"nbp","id":1179566,"avatar_url":"https://avatars.githubusercontent.com/u/1179566?v=3","gravatar_id":"","url":"https://api.github.com/users/nbp","html_url":"https://github.com/nbp","followers_url":"https://api.github.com/users/nbp/followers","following_url":"https://api.github.com/users/nbp/following{/other_user}","gists_url":"https://api.github.com/users/nbp/gists{/gist_id}","starred_url":"https://api.github.com/users/nbp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nbp/subscriptions","organizations_url":"https://api.github.com/users/nbp/orgs","repos_url":"https://api.github.com/users/nbp/repos","events_url":"https://api.github.com/users/nbp/events{/privacy}","received_events_url":"https://api.github.com/users/nbp/received_events","type":"User","site_admin":false},"body":"nit: !(… or …)\r\nnit: factor this expression in a `let … in …`.\r\n","created_at":"2016-10-31T19:22:48Z","updated_at":"2016-10-31T19:25:21Z","html_url":"https://github.com/NixOS/nixpkgs/pull/18816#discussion_r85813397","pull_request_url":"https://api.github.com/repos/NixOS/nixpkgs/pulls/18816","_links":{"self":{"href":"https://api.github.com/repos/NixOS/nixpkgs/pulls/comments/85813397"},"html":{"href":"https://github.com/NixOS/nixpkgs/pull/18816#discussion_r85813397"},"pull_request":{"href":"https://api.github.com/repos/NixOS/nixpkgs/pulls/18816"}}},"pull_request":{"url":"https://api.github.com/repos/NixOS/nixpkgs/pulls/18816","id":86193553,"html_url":"https://github.com/NixOS/nixpkgs/pull/18816","diff_url":"https://github.com/NixOS/nixpkgs/pull/18816.diff","patch_url":"https://github.com/NixOS/nixpkgs/pull/18816.patch","issue_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/18816","number":18816,"state":"open","locked":false,"title":"lib.options: automatically generate example for booleans","user":{"login":"groxxda","id":5701271,"avatar_url":"https://avatars.githubusercontent.com/u/5701271?v=3","gravatar_id":"","url":"https://api.github.com/users/groxxda","html_url":"https://github.com/groxxda","followers_url":"https://api.github.com/users/groxxda/followers","following_url":"https://api.github.com/users/groxxda/following{/other_user}","gists_url":"https://api.github.com/users/groxxda/gists{/gist_id}","starred_url":"https://api.github.com/users/groxxda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/groxxda/subscriptions","organizations_url":"https://api.github.com/users/groxxda/orgs","repos_url":"https://api.github.com/users/groxxda/repos","events_url":"https://api.github.com/users/groxxda/events{/privacy}","received_events_url":"https://api.github.com/users/groxxda/received_events","type":"User","site_admin":false},"body":"###### Motivation for this change\n\nRemove the need to provide an example for boolean options. Since there are only two possibilities, setting `example = !default` is reasonable. This should remove the amount of boilerplate in nixpkgs by a few hundred lines.\n\nAlso catches cases where `type == bool` but `default` is not defined and provides `example = true`.\n\nThe second commit catches cases where `type != bool` but `isBool default` holds (type may be undefined or something like `nullOr bool`) and `!default` is a valid value.\nIf this is too expensive we can also drop it, but since this is only executed for the manual generation, it should be ok. \n\nThe first commit adds 853 example values to options-db.xml, the second one another 3.\n\nref #18803 could use this :wink: \n###### Things done\n- [x] Tested using sandboxing\n  ([nix.useSandbox](http://nixos.org/nixos/manual/options.html#opt-nix.useSandbox) on NixOS,\n    or option `build-use-sandbox` in [`nix.conf`](http://nixos.org/nix/manual/#sec-conf-file)\n    on non-NixOS)\n- Built on platform(s)\n  - [x] NixOS\n  - [ ] OS X\n  - [ ] Linux\n- [x] Tested compilation of all pkgs that depend on this change using `nix-shell -p nox --run \"nox-review wip\"`\n- [x] Fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/.github/CONTRIBUTING.md).\n---\n","created_at":"2016-09-21T16:07:25Z","updated_at":"2016-10-31T19:25:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"59bd4d3aa001a96018501a11727bb2e9a8d9c456","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/NixOS/nixpkgs/pulls/18816/commits","review_comments_url":"https://api.github.com/repos/NixOS/nixpkgs/pulls/18816/comments","review_comment_url":"https://api.github.com/repos/NixOS/nixpkgs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/18816/comments","statuses_url":"https://api.github.com/repos/NixOS/nixpkgs/statuses/d592d90fda41fc585f51e55677c1647f68404b3c","head":{"label":"groxxda:bool-auto-example","ref":"bool-auto-example","sha":"d592d90fda41fc585f51e55677c1647f68404b3c","user":{"login":"groxxda","id":5701271,"avatar_url":"https://avatars.githubusercontent.com/u/5701271?v=3","gravatar_id":"","url":"https://api.github.com/users/groxxda","html_url":"https://github.com/groxxda","followers_url":"https://api.github.com/users/groxxda/followers","following_url":"https://api.github.com/users/groxxda/following{/other_user}","gists_url":"https://api.github.com/users/groxxda/gists{/gist_id}","starred_url":"https://api.github.com/users/groxxda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/groxxda/subscriptions","organizations_url":"https://api.github.com/users/groxxda/orgs","repos_url":"https://api.github.com/users/groxxda/repos","events_url":"https://api.github.com/users/groxxda/events{/privacy}","received_events_url":"https://api.github.com/users/groxxda/received_events","type":"User","site_admin":false},"repo":{"id":31596664,"name":"nixpkgs","full_name":"groxxda/nixpkgs","owner":{"login":"groxxda","id":5701271,"avatar_url":"https://avatars.githubusercontent.com/u/5701271?v=3","gravatar_id":"","url":"https://api.github.com/users/groxxda","html_url":"https://github.com/groxxda","followers_url":"https://api.github.com/users/groxxda/followers","following_url":"https://api.github.com/users/groxxda/following{/other_user}","gists_url":"https://api.github.com/users/groxxda/gists{/gist_id}","starred_url":"https://api.github.com/users/groxxda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/groxxda/subscriptions","organizations_url":"https://api.github.com/users/groxxda/orgs","repos_url":"https://api.github.com/users/groxxda/repos","events_url":"https://api.github.com/users/groxxda/events{/privacy}","received_events_url":"https://api.github.com/users/groxxda/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/groxxda/nixpkgs","description":"Nix Packages collection","fork":true,"url":"https://api.github.com/repos/groxxda/nixpkgs","forks_url":"https://api.github.com/repos/groxxda/nixpkgs/forks","keys_url":"https://api.github.com/repos/groxxda/nixpkgs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/groxxda/nixpkgs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/groxxda/nixpkgs/teams","hooks_url":"https://api.github.com/repos/groxxda/nixpkgs/hooks","issue_events_url":"https://api.github.com/repos/groxxda/nixpkgs/issues/events{/number}","events_url":"https://api.github.com/repos/groxxda/nixpkgs/events","assignees_url":"https://api.github.com/repos/groxxda/nixpkgs/assignees{/user}","branches_url":"https://api.github.com/repos/groxxda/nixpkgs/branches{/branch}","tags_url":"https://api.github.com/repos/groxxda/nixpkgs/tags","blobs_url":"https://api.github.com/repos/groxxda/nixpkgs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/groxxda/nixpkgs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/groxxda/nixpkgs/git/refs{/sha}","trees_url":"https://api.github.com/repos/groxxda/nixpkgs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/groxxda/nixpkgs/statuses/{sha}","languages_url":"https://api.github.com/repos/groxxda/nixpkgs/languages","stargazers_url":"https://api.github.com/repos/groxxda/nixpkgs/stargazers","contributors_url":"https://api.github.com/repos/groxxda/nixpkgs/contributors","subscribers_url":"https://api.github.com/repos/groxxda/nixpkgs/subscribers","subscription_url":"https://api.github.com/repos/groxxda/nixpkgs/subscription","commits_url":"https://api.github.com/repos/groxxda/nixpkgs/commits{/sha}","git_commits_url":"https://api.github.com/repos/groxxda/nixpkgs/git/commits{/sha}","comments_url":"https://api.github.com/repos/groxxda/nixpkgs/comments{/number}","issue_comment_url":"https://api.github.com/repos/groxxda/nixpkgs/issues/comments{/number}","contents_url":"https://api.github.com/repos/groxxda/nixpkgs/contents/{+path}","compare_url":"https://api.github.com/repos/groxxda/nixpkgs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/groxxda/nixpkgs/merges","archive_url":"https://api.github.com/repos/groxxda/nixpkgs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/groxxda/nixpkgs/downloads","issues_url":"https://api.github.com/repos/groxxda/nixpkgs/issues{/number}","pulls_url":"https://api.github.com/repos/groxxda/nixpkgs/pulls{/number}","milestones_url":"https://api.github.com/repos/groxxda/nixpkgs/milestones{/number}","notifications_url":"https://api.github.com/repos/groxxda/nixpkgs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/groxxda/nixpkgs/labels{/name}","releases_url":"https://api.github.com/repos/groxxda/nixpkgs/releases{/id}","deployments_url":"https://api.github.com/repos/groxxda/nixpkgs/deployments","created_at":"2015-03-03T12:13:56Z","updated_at":"2016-04-08T20:57:01Z","pushed_at":"2016-10-29T15:57:48Z","git_url":"git://github.com/groxxda/nixpkgs.git","ssh_url":"git@github.com:groxxda/nixpkgs.git","clone_url":"https://github.com/groxxda/nixpkgs.git","svn_url":"https://github.com/groxxda/nixpkgs","homepage":null,"size":352674,"stargazers_count":0,"watchers_count":0,"language":"Nix","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"NixOS:master","ref":"master","sha":"237d049f3e2a203e9c039f2f927a9fec796fcb84","user":{"login":"NixOS","id":487568,"avatar_url":"https://avatars.githubusercontent.com/u/487568?v=3","gravatar_id":"","url":"https://api.github.com/users/NixOS","html_url":"https://github.com/NixOS","followers_url":"https://api.github.com/users/NixOS/followers","following_url":"https://api.github.com/users/NixOS/following{/other_user}","gists_url":"https://api.github.com/users/NixOS/gists{/gist_id}","starred_url":"https://api.github.com/users/NixOS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NixOS/subscriptions","organizations_url":"https://api.github.com/users/NixOS/orgs","repos_url":"https://api.github.com/users/NixOS/repos","events_url":"https://api.github.com/users/NixOS/events{/privacy}","received_events_url":"https://api.github.com/users/NixOS/received_events","type":"Organization","site_admin":false},"repo":{"id":4542716,"name":"nixpkgs","full_name":"NixOS/nixpkgs","owner":{"login":"NixOS","id":487568,"avatar_url":"https://avatars.githubusercontent.com/u/487568?v=3","gravatar_id":"","url":"https://api.github.com/users/NixOS","html_url":"https://github.com/NixOS","followers_url":"https://api.github.com/users/NixOS/followers","following_url":"https://api.github.com/users/NixOS/following{/other_user}","gists_url":"https://api.github.com/users/NixOS/gists{/gist_id}","starred_url":"https://api.github.com/users/NixOS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NixOS/subscriptions","organizations_url":"https://api.github.com/users/NixOS/orgs","repos_url":"https://api.github.com/users/NixOS/repos","events_url":"https://api.github.com/users/NixOS/events{/privacy}","received_events_url":"https://api.github.com/users/NixOS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NixOS/nixpkgs","description":"Nix Packages collection","fork":false,"url":"https://api.github.com/repos/NixOS/nixpkgs","forks_url":"https://api.github.com/repos/NixOS/nixpkgs/forks","keys_url":"https://api.github.com/repos/NixOS/nixpkgs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NixOS/nixpkgs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NixOS/nixpkgs/teams","hooks_url":"https://api.github.com/repos/NixOS/nixpkgs/hooks","issue_events_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/events{/number}","events_url":"https://api.github.com/repos/NixOS/nixpkgs/events","assignees_url":"https://api.github.com/repos/NixOS/nixpkgs/assignees{/user}","branches_url":"https://api.github.com/repos/NixOS/nixpkgs/branches{/branch}","tags_url":"https://api.github.com/repos/NixOS/nixpkgs/tags","blobs_url":"https://api.github.com/repos/NixOS/nixpkgs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NixOS/nixpkgs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NixOS/nixpkgs/git/refs{/sha}","trees_url":"https://api.github.com/repos/NixOS/nixpkgs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NixOS/nixpkgs/statuses/{sha}","languages_url":"https://api.github.com/repos/NixOS/nixpkgs/languages","stargazers_url":"https://api.github.com/repos/NixOS/nixpkgs/stargazers","contributors_url":"https://api.github.com/repos/NixOS/nixpkgs/contributors","subscribers_url":"https://api.github.com/repos/NixOS/nixpkgs/subscribers","subscription_url":"https://api.github.com/repos/NixOS/nixpkgs/subscription","commits_url":"https://api.github.com/repos/NixOS/nixpkgs/commits{/sha}","git_commits_url":"https://api.github.com/repos/NixOS/nixpkgs/git/commits{/sha}","comments_url":"https://api.github.com/repos/NixOS/nixpkgs/comments{/number}","issue_comment_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/comments{/number}","contents_url":"https://api.github.com/repos/NixOS/nixpkgs/contents/{+path}","compare_url":"https://api.github.com/repos/NixOS/nixpkgs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NixOS/nixpkgs/merges","archive_url":"https://api.github.com/repos/NixOS/nixpkgs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NixOS/nixpkgs/downloads","issues_url":"https://api.github.com/repos/NixOS/nixpkgs/issues{/number}","pulls_url":"https://api.github.com/repos/NixOS/nixpkgs/pulls{/number}","milestones_url":"https://api.github.com/repos/NixOS/nixpkgs/milestones{/number}","notifications_url":"https://api.github.com/repos/NixOS/nixpkgs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NixOS/nixpkgs/labels{/name}","releases_url":"https://api.github.com/repos/NixOS/nixpkgs/releases{/id}","deployments_url":"https://api.github.com/repos/NixOS/nixpkgs/deployments","created_at":"2012-06-04T02:49:46Z","updated_at":"2016-10-30T10:50:49Z","pushed_at":"2016-10-31T18:51:04Z","git_url":"git://github.com/NixOS/nixpkgs.git","ssh_url":"git@github.com:NixOS/nixpkgs.git","clone_url":"https://github.com/NixOS/nixpkgs.git","svn_url":"https://github.com/NixOS/nixpkgs","homepage":null,"size":628036,"stargazers_count":1363,"watchers_count":1363,"language":"Nix","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1689,"mirror_url":null,"open_issues_count":1577,"forks":1689,"open_issues":1577,"watchers":1363,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/NixOS/nixpkgs/pulls/18816"},"html":{"href":"https://github.com/NixOS/nixpkgs/pull/18816"},"issue":{"href":"https://api.github.com/repos/NixOS/nixpkgs/issues/18816"},"comments":{"href":"https://api.github.com/repos/NixOS/nixpkgs/issues/18816/comments"},"review_comments":{"href":"https://api.github.com/repos/NixOS/nixpkgs/pulls/18816/comments"},"review_comment":{"href":"https://api.github.com/repos/NixOS/nixpkgs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/NixOS/nixpkgs/pulls/18816/commits"},"statuses":{"href":"https://api.github.com/repos/NixOS/nixpkgs/statuses/d592d90fda41fc585f51e55677c1647f68404b3c"}}}}
{"actor":{"display_login":"nbp"}}