From b9f6dfe8c5c8da09b6c2d8a8e168bdcf50a0aabd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Wed, 13 Jan 2016 11:49:19 +0100 Subject: [PATCH 1/2] nixos manuals: allow displaying package references The manuals are now evaluated with each derivation in `pkgs` (recursively) replaced by a fake with path "\${pkgs.path.to.the.attribute}". It isn't perfect, but it seems to cover a vast majority of use cases. Caveat: even if the package is reached by a different means, the path above will be shown and not e.g. `${config.services.foo.package}`. As before, defaults created by `mkDefault` aren't displayed, but documentation shouldn't (mostly) be a reason to use that anymore. Note: t wouldn't be enough to just use `lib.mapAttrsRecursive`, because derivations are also (special) attribute sets. --- lib/attrsets.nix | 2 +- nixos/release.nix | 28 +++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/lib/attrsets.nix b/lib/attrsets.nix index 84f6cb3658b9..e3721bd1e94c 100644 --- a/lib/attrsets.nix +++ b/lib/attrsets.nix @@ -207,7 +207,7 @@ rec { /* Like `mapAttrsRecursive', but it takes an additional predicate - function that tells it whether to recursive into an attribute + function that tells it whether to recurse into an attribute set. If it returns false, `mapAttrsRecursiveCond' does not recurse, but does apply the map function. It is returns true, it does recurse, and does not apply the map function. diff --git a/nixos/release.nix b/nixos/release.nix index 8a502ae2baa1..780ac56edf11 100644 --- a/nixos/release.nix +++ b/nixos/release.nix @@ -92,15 +92,33 @@ let }).config)); + cleanConfig = import ./lib/eval-config.nix { + system = "x86_64-linux"; + modules = [ ]; + pkgs = with pkgs.lib; + let + scrubDerivations = namePrefix: pkgSet: mapAttrs + (name: value: + let wholeName = "${namePrefix}.${name}"; in + if isAttrs value then + scrubDerivations wholeName value + // (optionalAttrs (isDerivation value) { outPath = "\${${wholeName}}"; }) + else value + ) + pkgSet; + in scrubDerivations "pkgs" pkgs; + }; + docs = (import ./doc/manual) { + inherit pkgs version; + revision = versionModule.system.nixosRevision; + inherit (cleanConfig) options; + }; + in rec { channel = import lib/make-channel.nix { inherit pkgs nixpkgs version versionSuffix; }; - manual = buildFromConfig ({ pkgs, ... }: { }) (config: config.system.build.manual.manual); - manualPDF = (buildFromConfig ({ pkgs, ... }: { }) (config: config.system.build.manual.manualPDF)).x86_64-linux; - manpages = buildFromConfig ({ pkgs, ... }: { }) (config: config.system.build.manual.manpages); - options = (buildFromConfig ({ pkgs, ... }: { }) (config: config.system.build.manual.optionsJSON)).x86_64-linux; - + inherit (docs) manual manualPDF manpages optionsJSON; # Build the initial ramdisk so Hydra can keep track of its size over time. initialRamdisk = buildFromConfig ({ pkgs, ... }: { }) (config: config.system.build.initialRamdisk); From 3bcf8ae8795ede9909df07fb97e049442b38c231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Wed, 13 Jan 2016 11:48:11 +0100 Subject: [PATCH 2/2] nixos manuals: bring back package references This reverts most of 89e983786a, as those references are sanitized now. Fixes #10039, at least most of it. The `sane` case wasn't fixed, as it calls a *function* in pkgs to get the default value. --- nixos/modules/programs/ssh.nix | 3 +-- nixos/modules/programs/venus.nix | 3 +-- nixos/modules/services/amqp/activemq/default.nix | 3 +-- nixos/modules/services/misc/nixos-manual.nix | 3 +-- nixos/modules/services/misc/subsonic.nix | 4 +--- nixos/modules/services/monitoring/grafana.nix | 4 +--- nixos/modules/services/networking/dnscrypt-proxy.nix | 5 ++++- nixos/modules/services/web-servers/phpfpm.nix | 5 ++--- nixos/modules/services/x11/display-managers/lightdm.nix | 4 +--- 9 files changed, 13 insertions(+), 21 deletions(-) diff --git a/nixos/modules/programs/ssh.nix b/nixos/modules/programs/ssh.nix index 87a7bac208b7..cf7ef455eb85 100644 --- a/nixos/modules/programs/ssh.nix +++ b/nixos/modules/programs/ssh.nix @@ -36,6 +36,7 @@ in askPassword = mkOption { type = types.str; + default = "${pkgs.x11_ssh_askpass}/libexec/x11-ssh-askpass"; description = ''Program used by SSH to ask for passwords.''; }; @@ -222,7 +223,5 @@ in export SSH_ASKPASS=${askPassword} ''; - programs.ssh.askPassword = mkDefault "${pkgs.x11_ssh_askpass}/libexec/x11-ssh-askpass"; - }; } diff --git a/nixos/modules/programs/venus.nix b/nixos/modules/programs/venus.nix index 8f85b602fe2c..ca3188b18199 100644 --- a/nixos/modules/programs/venus.nix +++ b/nixos/modules/programs/venus.nix @@ -99,6 +99,7 @@ in }; outputTheme = mkOption { + default = "${pkgs.venus}/themes/classic_fancy"; type = types.path; description = '' Directory containing a config.ini file which is merged with this one. @@ -169,7 +170,5 @@ in startAt = cfg.dates; }; - services.venus.outputTheme = mkDefault "${pkgs.venus}/themes/classic_fancy"; - }; } diff --git a/nixos/modules/services/amqp/activemq/default.nix b/nixos/modules/services/amqp/activemq/default.nix index 56ff388f8a9e..261f97617664 100644 --- a/nixos/modules/services/amqp/activemq/default.nix +++ b/nixos/modules/services/amqp/activemq/default.nix @@ -32,6 +32,7 @@ in { ''; }; configurationDir = mkOption { + default = "${activemq}/conf"; description = '' The base directory for ActiveMQ's configuration. By default, this directory is searched for a file named activemq.xml, @@ -125,8 +126,6 @@ in { ''; }; - services.activemq.configurationDir = mkDefault "${activemq}/conf"; - }; } diff --git a/nixos/modules/services/misc/nixos-manual.nix b/nixos/modules/services/misc/nixos-manual.nix index 3e1f53e79f3e..2aa8f4a06cc9 100644 --- a/nixos/modules/services/misc/nixos-manual.nix +++ b/nixos/modules/services/misc/nixos-manual.nix @@ -80,6 +80,7 @@ in services.nixosManual.browser = mkOption { type = types.path; + default = "${pkgs.w3m-nox}/bin/w3m"; description = '' Browser used to show the manual. ''; @@ -117,8 +118,6 @@ in services.mingetty.helpLine = mkIf cfg.showManual "\nPress for the NixOS manual."; - services.nixosManual.browser = mkDefault "${pkgs.w3m-nox}/bin/w3m"; - }; } diff --git a/nixos/modules/services/misc/subsonic.nix b/nixos/modules/services/misc/subsonic.nix index 2831e95b9480..020d53a481de 100644 --- a/nixos/modules/services/misc/subsonic.nix +++ b/nixos/modules/services/misc/subsonic.nix @@ -97,6 +97,7 @@ in transcoders = mkOption { type = types.listOf types.path; + default = [ "${pkgs.ffmpeg}/bin/ffmpeg" ]; description = '' List of paths to transcoder executables that should be accessible from Subsonic. Symlinks will be created to each executable inside @@ -152,8 +153,5 @@ in }; users.extraGroups.subsonic.gid = config.ids.gids.subsonic; - - services.subsonic.transcoders = mkDefault [ "${pkgs.ffmpeg}/bin/ffmpeg" ]; - }; } diff --git a/nixos/modules/services/monitoring/grafana.nix b/nixos/modules/services/monitoring/grafana.nix index 6053990e8d3b..a92ca4a54606 100644 --- a/nixos/modules/services/monitoring/grafana.nix +++ b/nixos/modules/services/monitoring/grafana.nix @@ -87,6 +87,7 @@ in { staticRootPath = mkOption { description = "Root path for static assets."; + default = "${cfg.package.out}/share/grafana/public"; type = types.str; }; @@ -231,8 +232,5 @@ in { home = cfg.dataDir; createHome = true; }; - - services.grafana.staticRootPath = mkDefault "${cfg.package}/share/grafana/public"; - }; } diff --git a/nixos/modules/services/networking/dnscrypt-proxy.nix b/nixos/modules/services/networking/dnscrypt-proxy.nix index 218bce2dbb31..c724ee979c2d 100644 --- a/nixos/modules/services/networking/dnscrypt-proxy.nix +++ b/nixos/modules/services/networking/dnscrypt-proxy.nix @@ -52,7 +52,10 @@ in default = "opendns"; type = types.nullOr types.string; description = '' - The name of the upstream DNSCrypt resolver to use. + The name of the upstream DNSCrypt resolver to use. See + ${resolverListFile} for alternative resolvers + (e.g., if you are concerned about logging and/or server + location). ''; }; customResolver = mkOption { diff --git a/nixos/modules/services/web-servers/phpfpm.nix b/nixos/modules/services/web-servers/phpfpm.nix index 82398948bfaa..41dbfff41cfe 100644 --- a/nixos/modules/services/web-servers/phpfpm.nix +++ b/nixos/modules/services/web-servers/phpfpm.nix @@ -44,7 +44,8 @@ in { phpIni = mkOption { type = types.path; - description = "PHP configuration file to use."; + default = "${cfg.phpPackage}/etc/php-recommended.ini"; + description = "php.ini file to use."; }; poolConfigs = mkOption { @@ -85,7 +86,5 @@ in { }; }; - services.phpfpm.phpIni = mkDefault "${cfg.phpPackage}/etc/php-recommended.ini"; - }; } diff --git a/nixos/modules/services/x11/display-managers/lightdm.nix b/nixos/modules/services/x11/display-managers/lightdm.nix index ded694d90d50..c45769119db9 100644 --- a/nixos/modules/services/x11/display-managers/lightdm.nix +++ b/nixos/modules/services/x11/display-managers/lightdm.nix @@ -86,6 +86,7 @@ in }; background = mkOption { + default = "${pkgs.nixos-artwork}/share/artwork/gnome/Gnome_Dark.png"; description = '' The background image or color to use. ''; @@ -151,9 +152,6 @@ in }; users.extraGroups.lightdm.gid = config.ids.gids.lightdm; - - services.xserver.displayManager.lightdm.background = mkDefault "${pkgs.nixos-artwork}/share/artwork/gnome/Gnome_Dark.png"; - services.xserver.tty = null; # We might start multiple X servers so let the tty increment themselves.. services.xserver.display = null; # We specify our own display (and logfile) in xserver-wrapper up there };