From 44da835ac40dab5fd231298b59d83487382d2fab Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Sat, 23 Oct 2021 15:05:52 +0200 Subject: [PATCH] add forward compatibility for literalExample deprecation Fixes #367 --- doc/manual/options-to-docbook.xsl | 4 ++-- eval-config.nix | 8 +++++++- modules/environment/default.nix | 2 +- modules/fonts/default.nix | 2 +- modules/nix/default.nix | 4 ++-- modules/nix/nixpkgs.nix | 4 ++-- modules/programs/ssh/default.nix | 2 +- modules/programs/vim.nix | 2 +- modules/security/pki/default.nix | 4 ++-- modules/services/chunkwm.nix | 2 +- modules/services/dnsmasq.nix | 2 +- modules/services/mail/offlineimap.nix | 3 +-- modules/services/ofborg/default.nix | 2 +- modules/services/postgresql/default.nix | 2 +- modules/services/privoxy/default.nix | 2 +- modules/services/spacebar/default.nix | 4 ++-- modules/services/yabai/default.nix | 4 ++-- modules/system/patches.nix | 2 +- modules/system/shells.nix | 2 +- modules/users/user.nix | 4 ++-- pkgs/nix-tools/darwin-option.sh | 2 +- 21 files changed, 34 insertions(+), 29 deletions(-) diff --git a/doc/manual/options-to-docbook.xsl b/doc/manual/options-to-docbook.xsl index a65aa62f..74fb2705 100644 --- a/doc/manual/options-to-docbook.xsl +++ b/doc/manual/options-to-docbook.xsl @@ -62,7 +62,7 @@ Example: - + @@ -162,7 +162,7 @@ - + diff --git a/eval-config.nix b/eval-config.nix index e0ce18bb..99135fa9 100644 --- a/eval-config.nix +++ b/eval-config.nix @@ -26,7 +26,13 @@ let }; }; - eval = lib.evalModules (builtins.removeAttrs args [ "inputs" "system" ] // { + libExtended = lib.extend (self: super: { + # Added in nixpkgs #136909, adds forward compatibility until 22.03 is deprecated. + literalExpression = super.literalExpression or super.literalExample; + literalDocBook = super.literalDocBook or super.literalExample; + }); + + eval = libExtended.evalModules (builtins.removeAttrs args [ "inputs" "system" ] // { modules = modules ++ [ inputsModule pkgsModule ] ++ baseModules; args = { inherit baseModules modules; }; specialArgs = { modulesPath = builtins.toString ./modules; } // specialArgs; diff --git a/modules/environment/default.nix b/modules/environment/default.nix index eed16047..601b0ca8 100644 --- a/modules/environment/default.nix +++ b/modules/environment/default.nix @@ -19,7 +19,7 @@ in environment.systemPackages = mkOption { type = types.listOf types.package; default = []; - example = literalExample "[ pkgs.curl pkgs.vim ]"; + example = literalExpression "[ pkgs.curl pkgs.vim ]"; description = '' The set of packages that appear in /run/current-system/sw. These packages are diff --git a/modules/fonts/default.nix b/modules/fonts/default.nix index 195edd6e..2c7341aa 100644 --- a/modules/fonts/default.nix +++ b/modules/fonts/default.nix @@ -21,7 +21,7 @@ in fonts.fonts = mkOption { type = types.listOf types.path; default = []; - example = literalExample "[ pkgs.dejavu_fonts ]"; + example = literalExpression "[ pkgs.dejavu_fonts ]"; description = "List of fonts to install."; }; }; diff --git a/modules/nix/default.nix b/modules/nix/default.nix index 09b4e637..334243ed 100644 --- a/modules/nix/default.nix +++ b/modules/nix/default.nix @@ -48,7 +48,7 @@ in type = types.either types.package types.path; default = pkgs.nix; defaultText = "pkgs.nix"; - example = literalExample "pkgs.nixUnstable"; + example = literalExpression "pkgs.nixUnstable"; description = '' This option specifies the package or profile that contains the version of Nix to use throughout the system. To keep the version of nix originally installed the default profile can be used. @@ -366,7 +366,7 @@ in flake = mkOption { type = types.unspecified; default = null; - example = literalExample "nixpkgs"; + example = literalExpression "nixpkgs"; description = '' The flake input to which is to be rewritten. ''; diff --git a/modules/nix/nixpkgs.nix b/modules/nix/nixpkgs.nix index dc95f919..7746819a 100644 --- a/modules/nix/nixpkgs.nix +++ b/modules/nix/nixpkgs.nix @@ -50,7 +50,7 @@ in options = { nixpkgs.config = mkOption { default = {}; - example = literalExample + example = literalExpression '' { firefox.enableGeckoMediaPlayer = true; packageOverrides = pkgs: { @@ -75,7 +75,7 @@ in nixpkgs.overlays = mkOption { type = types.listOf overlayType; default = []; - example = literalExample '' + example = literalExpression '' [ (self: super: { openssh = super.openssh.override { hpnSupport = true; diff --git a/modules/programs/ssh/default.nix b/modules/programs/ssh/default.nix index af2d76b9..f93890fb 100644 --- a/modules/programs/ssh/default.nix +++ b/modules/programs/ssh/default.nix @@ -58,7 +58,7 @@ in description = '' The set of system-wide known SSH hosts. ''; - example = literalExample '' + example = literalExpression '' [ { hostNames = [ "myhost" "myhost.mydomain.com" "10.10.1.4" ]; diff --git a/modules/programs/vim.nix b/modules/programs/vim.nix index bceae54d..345532e5 100644 --- a/modules/programs/vim.nix +++ b/modules/programs/vim.nix @@ -31,7 +31,7 @@ in programs.vim.extraKnownPlugins = mkOption { type = types.attrsOf types.package; default = {}; - example = literalExample + example = literalExpression '' { vim-jsx = pkgs.vimUtils.buildVimPluginFrom2Nix { diff --git a/modules/security/pki/default.nix b/modules/security/pki/default.nix index b6e99d26..4f3cf303 100644 --- a/modules/security/pki/default.nix +++ b/modules/security/pki/default.nix @@ -24,7 +24,7 @@ in security.pki.certificateFiles = mkOption { type = types.listOf types.path; default = []; - example = literalExample "[ \"\${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt\" ]"; + example = literalExpression "[ \"\${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt\" ]"; description = '' A list of files containing trusted root certificates in PEM format. These are concatenated to form @@ -37,7 +37,7 @@ in security.pki.certificates = mkOption { type = types.listOf types.str; default = []; - example = literalExample '' + example = literalExpression '' [ ''' NixOS.org ========= diff --git a/modules/services/chunkwm.nix b/modules/services/chunkwm.nix index 21fa080c..3a592707 100644 --- a/modules/services/chunkwm.nix +++ b/modules/services/chunkwm.nix @@ -17,7 +17,7 @@ in services.chunkwm.package = mkOption { type = types.package; - example = literalExample "pkgs.chunkwm"; + example = literalExpression "pkgs.chunkwm"; description = "This option specifies the chunkwm package to use."; }; diff --git a/modules/services/dnsmasq.nix b/modules/services/dnsmasq.nix index 99486f13..7ea674f8 100644 --- a/modules/services/dnsmasq.nix +++ b/modules/services/dnsmasq.nix @@ -38,7 +38,7 @@ in type = types.attrs; default = {}; description = "List of domains that will be redirected by the DNSmasq."; - example = literalExample '' + example = literalExpression '' { localhost = "127.0.0.1"; } ''; }; diff --git a/modules/services/mail/offlineimap.nix b/modules/services/mail/offlineimap.nix index d7228c91..9d0d4dce 100644 --- a/modules/services/mail/offlineimap.nix +++ b/modules/services/mail/offlineimap.nix @@ -19,14 +19,13 @@ in { path = mkOption { type = types.listOf types.path; default = []; - example = literalExample "[ pkgs.pass pkgs.bash pkgs.notmuch ]"; + example = literalExpression "[ pkgs.pass pkgs.bash pkgs.notmuch ]"; description = "List of derivations to put in Offlineimap's path."; }; startInterval = mkOption { type = types.nullOr types.int; default = 300; - example = literalExample "300"; description = "Optional key to start offlineimap services each N seconds"; }; diff --git a/modules/services/ofborg/default.nix b/modules/services/ofborg/default.nix index 172ea773..5bc0f9df 100644 --- a/modules/services/ofborg/default.nix +++ b/modules/services/ofborg/default.nix @@ -17,7 +17,7 @@ in services.ofborg.package = mkOption { type = types.package; - example = literalExample "pkgs.ofborg"; + example = literalExpression "pkgs.ofborg"; description = '' This option specifies the ofborg package to use. eg. diff --git a/modules/services/postgresql/default.nix b/modules/services/postgresql/default.nix index a17ef3b9..db5c0255 100644 --- a/modules/services/postgresql/default.nix +++ b/modules/services/postgresql/default.nix @@ -81,7 +81,7 @@ in extraPlugins = mkOption { type = types.listOf types.path; default = []; - example = literalExample "[ (pkgs.postgis.override { postgresql = pkgs.postgresql94; }) ]"; + example = literalExpression "[ (pkgs.postgis.override { postgresql = pkgs.postgresql94; }) ]"; description = '' When this list contains elements a new store path is created. PostgreSQL and the elements are symlinked into it. Then pg_config, diff --git a/modules/services/privoxy/default.nix b/modules/services/privoxy/default.nix index 5cb16c82..b3147232 100644 --- a/modules/services/privoxy/default.nix +++ b/modules/services/privoxy/default.nix @@ -22,7 +22,7 @@ in services.privoxy.package = mkOption { type = types.package; default = pkgs.privoxy; - example = literalExample "pkgs.privoxy"; + example = literalExpression "pkgs.privoxy"; description = "This option specifies the privoxy package to use."; }; diff --git a/modules/services/spacebar/default.nix b/modules/services/spacebar/default.nix index 51ea998e..a56dac53 100644 --- a/modules/services/spacebar/default.nix +++ b/modules/services/spacebar/default.nix @@ -33,7 +33,7 @@ in services.spacebar.config = mkOption { type = attrs; default = {}; - example = literalExample '' + example = literalExpression '' { clock_format = "%R"; background_color = "0xff202020"; @@ -48,7 +48,7 @@ in services.spacebar.extraConfig = mkOption { type = str; default = ""; - example = literalExample '' + example = literalExpression '' echo "spacebar config loaded..." ''; description = '' diff --git a/modules/services/yabai/default.nix b/modules/services/yabai/default.nix index 8ac563ff..b4961d44 100644 --- a/modules/services/yabai/default.nix +++ b/modules/services/yabai/default.nix @@ -42,7 +42,7 @@ in services.yabai.config = mkOption { type = attrs; default = {}; - example = literalExample '' + example = literalExpression '' { focus_follows_mouse = "autoraise"; mouse_follows_focus = "off"; @@ -63,7 +63,7 @@ in services.yabai.extraConfig = mkOption { type = str; default = ""; - example = literalExample '' + example = literalExpression '' yabai -m rule --add app='System Preferences' manage=off ''; description = "Extra arbitrary configuration to append to the configuration file"; diff --git a/modules/system/patches.nix b/modules/system/patches.nix index 0ef3e731..e4348805 100644 --- a/modules/system/patches.nix +++ b/modules/system/patches.nix @@ -12,7 +12,7 @@ in system.patches = mkOption { type = types.listOf types.path; default = []; - example = literalExample '' + example = literalExpression '' [ (pkgs.writeText "bashrc.patch" '''' --- a/etc/bashrc diff --git a/modules/system/shells.nix b/modules/system/shells.nix index 30099275..ac9d6197 100644 --- a/modules/system/shells.nix +++ b/modules/system/shells.nix @@ -11,7 +11,7 @@ in environment.shells = mkOption { type = types.listOf (types.either types.shellPackage types.path); default = []; - example = literalExample "[ pkgs.bashInteractive pkgs.zsh ]"; + example = literalExpression "[ pkgs.bashInteractive pkgs.zsh ]"; description = '' A list of permissible login shells for user accounts. No need to mention /bin/sh diff --git a/modules/users/user.nix b/modules/users/user.nix index 44fb1071..4060a65a 100644 --- a/modules/users/user.nix +++ b/modules/users/user.nix @@ -60,14 +60,14 @@ with lib; shell = mkOption { type = types.either types.shellPackage types.path; default = "/sbin/nologin"; - example = literalExample "pkgs.bashInteractive"; + example = literalExpression "pkgs.bashInteractive"; description = "The user's shell."; }; packages = mkOption { type = types.listOf types.package; default = []; - example = literalExample "[ pkgs.firefox pkgs.thunderbird ]"; + example = literalExpression "[ pkgs.firefox pkgs.thunderbird ]"; description = '' The set of packages that should be made availabe to the user. This is in contrast to , diff --git a/pkgs/nix-tools/darwin-option.sh b/pkgs/nix-tools/darwin-option.sh index 57a73e55..d6d466b2 100755 --- a/pkgs/nix-tools/darwin-option.sh +++ b/pkgs/nix-tools/darwin-option.sh @@ -62,7 +62,7 @@ if [ "$(evalOpt "_type")" = '"option"' ]; then evalOpt "default" || evalOptText "defaultText" || echo "no default" echo echo "Example:" - if [ "$(evalOpt "example._type")" = '"literalExample"' ]; then + if [ "$(evalOpt "example._type")" = '"literalExpression"' ]; then evalOptText "example.text" || echo "no example" else evalOpt "example" || echo "no example"