2013-10-23 08:50:55 -07:00
|
|
|
{ config, pkgs, options, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
2009-09-28 11:26:13 -07:00
|
|
|
|
|
|
|
let
|
2009-09-29 08:21:36 -07:00
|
|
|
|
|
|
|
alias = from: to: {
|
|
|
|
name = "Alias";
|
|
|
|
msg.use = x: x;
|
|
|
|
msg.define = x: x;
|
|
|
|
};
|
|
|
|
|
|
|
|
obsolete = from: to: {
|
|
|
|
name = "Obsolete name";
|
|
|
|
msg.use = x:
|
2010-05-07 08:14:50 -07:00
|
|
|
builtins.trace "Obsolete option `${from}' is used instead of `${to}'." x;
|
2009-09-29 08:21:36 -07:00
|
|
|
msg.define = x:
|
2010-05-07 08:14:50 -07:00
|
|
|
builtins.trace "Obsolete option `${from}' is defined instead of `${to}'." x;
|
2009-09-29 08:21:36 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
deprecated = from: to: {
|
|
|
|
name = "Deprecated name";
|
|
|
|
msg.use = x:
|
2010-05-07 08:14:50 -07:00
|
|
|
abort "Deprecated option `${from}' is used instead of `${to}'.";
|
2009-09-29 08:21:36 -07:00
|
|
|
msg.define = x:
|
2010-05-07 08:14:50 -07:00
|
|
|
abort "Deprecated option `${from}' is defined instead of `${to}'.";
|
2009-09-29 08:21:36 -07:00
|
|
|
};
|
|
|
|
|
2013-10-23 08:50:55 -07:00
|
|
|
zipModules = list:
|
2013-08-21 23:35:36 -07:00
|
|
|
zipAttrsWith (n: v:
|
2010-10-14 11:18:38 -07:00
|
|
|
if tail v != [] then
|
2013-02-21 11:43:02 -08:00
|
|
|
if n == "_type" then (head v)
|
|
|
|
else if n == "extraConfigs" then (concatLists v)
|
2010-10-14 11:18:38 -07:00
|
|
|
else if n == "description" || n == "apply" then
|
|
|
|
abort "Cannot rename an option to multiple options."
|
|
|
|
else zipModules v
|
|
|
|
else head v
|
2009-09-28 11:26:13 -07:00
|
|
|
) list;
|
|
|
|
|
2013-10-23 08:50:55 -07:00
|
|
|
rename = statusTemplate: from: to:
|
2009-09-28 11:26:13 -07:00
|
|
|
let
|
2009-09-29 08:21:36 -07:00
|
|
|
status = statusTemplate from to;
|
2009-09-28 11:26:13 -07:00
|
|
|
setTo = setAttrByPath (splitString "." to);
|
|
|
|
setFrom = setAttrByPath (splitString "." from);
|
2009-09-29 06:44:07 -07:00
|
|
|
toOf = attrByPath (splitString "." to)
|
2010-05-07 08:14:50 -07:00
|
|
|
(abort "Renaming error: option `${to}' does not exists.");
|
2009-09-29 06:44:07 -07:00
|
|
|
fromOf = attrByPath (splitString "." from)
|
2010-05-07 08:14:50 -07:00
|
|
|
(abort "Internal error: option `${from}' should be declared.");
|
2009-09-28 11:26:13 -07:00
|
|
|
in
|
2013-10-23 08:50:55 -07:00
|
|
|
[ { options = setFrom (mkOption {
|
|
|
|
description = "${status.name} of <option>${to}</option>.";
|
|
|
|
apply = x: status.msg.use (toOf config);
|
|
|
|
visible = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
{ options = setTo (mkOption {
|
|
|
|
extraConfigs =
|
|
|
|
let externalDefs = (fromOf options).definitions; in
|
|
|
|
if externalDefs == [] then []
|
|
|
|
else map (def: def.value) (status.msg.define externalDefs);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
];
|
2009-09-28 11:26:13 -07:00
|
|
|
|
|
|
|
in zipModules ([]
|
|
|
|
|
|
|
|
# usage example:
|
2010-10-14 06:57:15 -07:00
|
|
|
# ++ rename alias "services.xserver.slim.theme" "services.xserver.displayManager.slim.theme"
|
|
|
|
++ rename obsolete "environment.extraPackages" "environment.systemPackages"
|
2013-09-17 20:18:34 -07:00
|
|
|
++ rename obsolete "environment.enableBashCompletion" "programs.bash.enableCompletion"
|
2009-09-28 11:26:13 -07:00
|
|
|
|
2012-03-01 12:10:46 -08:00
|
|
|
++ rename obsolete "security.extraSetuidPrograms" "security.setuidPrograms"
|
2012-03-04 09:21:14 -08:00
|
|
|
++ rename obsolete "networking.enableWLAN" "networking.wireless.enable"
|
2012-08-11 05:54:43 -07:00
|
|
|
++ rename obsolete "networking.enableRT73Firmware" "networking.enableRalinkFirmware"
|
2012-03-01 12:10:46 -08:00
|
|
|
|
2013-01-16 03:33:18 -08:00
|
|
|
# FIXME: Remove these eventually.
|
|
|
|
++ rename obsolete "boot.systemd.sockets" "systemd.sockets"
|
|
|
|
++ rename obsolete "boot.systemd.targets" "systemd.targets"
|
|
|
|
++ rename obsolete "boot.systemd.services" "systemd.services"
|
|
|
|
|
2009-09-29 02:50:38 -07:00
|
|
|
# Old Grub-related options.
|
2010-10-14 06:57:15 -07:00
|
|
|
++ rename obsolete "boot.copyKernels" "boot.loader.grub.copyKernels"
|
|
|
|
++ rename obsolete "boot.extraGrubEntries" "boot.loader.grub.extraEntries"
|
|
|
|
++ rename obsolete "boot.extraGrubEntriesBeforeNixos" "boot.loader.grub.extraEntriesBeforeNixOS"
|
|
|
|
++ rename obsolete "boot.grubDevice" "boot.loader.grub.device"
|
|
|
|
++ rename obsolete "boot.bootMount" "boot.loader.grub.bootDevice"
|
|
|
|
++ rename obsolete "boot.grubSplashImage" "boot.loader.grub.splashImage"
|
2009-09-28 11:26:13 -07:00
|
|
|
|
2010-10-14 06:57:15 -07:00
|
|
|
++ rename obsolete "boot.initrd.extraKernelModules" "boot.initrd.kernelModules"
|
2009-12-15 06:05:01 -08:00
|
|
|
|
2010-03-11 09:02:49 -08:00
|
|
|
# OpenSSH
|
2010-10-14 06:57:15 -07:00
|
|
|
++ rename obsolete "services.sshd.ports" "services.openssh.ports"
|
2010-12-14 03:48:07 -08:00
|
|
|
++ rename alias "services.sshd.enable" "services.openssh.enable"
|
2010-10-14 06:57:15 -07:00
|
|
|
++ rename obsolete "services.sshd.allowSFTP" "services.openssh.allowSFTP"
|
|
|
|
++ rename obsolete "services.sshd.forwardX11" "services.openssh.forwardX11"
|
|
|
|
++ rename obsolete "services.sshd.gatewayPorts" "services.openssh.gatewayPorts"
|
|
|
|
++ rename obsolete "services.sshd.permitRootLogin" "services.openssh.permitRootLogin"
|
|
|
|
++ rename obsolete "services.xserver.startSSHAgent" "services.xserver.startOpenSSHAgent"
|
2009-11-21 16:40:53 -08:00
|
|
|
|
2009-10-12 10:09:38 -07:00
|
|
|
# KDE
|
2010-10-14 06:57:15 -07:00
|
|
|
++ rename deprecated "kde.extraPackages" "environment.kdePackages"
|
2010-10-14 07:57:38 -07:00
|
|
|
# ++ rename obsolete "environment.kdePackages" "environment.systemPackages" # !!! doesn't work!
|
2009-10-06 12:25:25 -07:00
|
|
|
|
2013-02-01 21:03:45 -08:00
|
|
|
# Multiple efi bootloaders now
|
2013-02-21 09:33:54 -08:00
|
|
|
++ rename obsolete "boot.loader.efi.efibootmgr.enable" "boot.loader.efi.canTouchEfiVariables"
|
2013-02-01 21:03:45 -08:00
|
|
|
|
2013-09-24 06:53:47 -07:00
|
|
|
# NixOS environment changes
|
|
|
|
# !!! this hardcodes bash, could we detect from config which shell is actually used?
|
|
|
|
++ rename obsolete "environment.promptInit" "programs.bash.promptInit"
|
|
|
|
|
2009-09-28 11:26:13 -07:00
|
|
|
) # do not add renaming after this.
|