From 5f141365afa8fcdd7fc7aee65031b850118f1bc0 Mon Sep 17 00:00:00 2001 From: Malo Bourgon Date: Sat, 13 Aug 2022 14:17:44 -0700 Subject: [PATCH] Update def and implementation of `nix.package` to match NixOS module Also remove `nix.version` option since it's no longer being used anywhere, old irrelevant `nix-info` module, and all support for legacy `nix.profile` option. --- modules/alias.nix | 6 +----- modules/module-list.nix | 1 - modules/nix/default.nix | 41 ++++++++++++++-------------------------- modules/nix/nix-info.nix | 15 --------------- 4 files changed, 15 insertions(+), 48 deletions(-) delete mode 100644 modules/nix/nix-info.nix diff --git a/modules/alias.nix b/modules/alias.nix index d495d2fe..cd7140fd 100644 --- a/modules/alias.nix +++ b/modules/alias.nix @@ -10,7 +10,6 @@ in options = { networking.networkservices = mkOption { internal = true; default = null; }; - nix.profile = mkOption { internal = true; default = null; }; security.enableAccessibilityAccess = mkOption { internal = true; default = null; }; security.accessibilityPrograms = mkOption { internal = true; default = null; }; @@ -19,8 +18,7 @@ in config = { assertions = - [ { assertion = config.nix.profile == null; message = "nix.profile was renamed to nix.package"; } - { assertion = config.security.enableAccessibilityAccess == null; message = "security.enableAccessibilityAccess was removed, it's broken since 10.12 because of SIP"; } + [ { assertion = config.security.enableAccessibilityAccess == null; message = "security.enableAccessibilityAccess was removed, it's broken since 10.12 because of SIP"; } { assertion = config.system.activationScripts.extraPostActivation.text == ""; message = "system.activationScripts.extraPostActivation was renamed to system.activationScripts.postActivation"; } { assertion = config.system.activationScripts.extraUserPostActivation.text == ""; message = "system.activationScripts.extraUserPostActivation was renamed to system.activationScripts.postUserActivation"; } ]; @@ -31,8 +29,6 @@ in networking.knownNetworkServices = mkIf (config.networking.networkservices != null) config.networking.networkservices; - nix.package = mkIf (config.nix.profile != null) config.nix.profile; - system.activationScripts.extraPostActivation.text = mkDefault ""; system.activationScripts.extraUserPostActivation.text = mkDefault ""; diff --git a/modules/module-list.nix b/modules/module-list.nix index d4c1b35b..f8ec8ddf 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -34,7 +34,6 @@ ./networking ./nix ./nix/nix-darwin.nix - ./nix/nix-info.nix ./nix/nixpkgs.nix ./environment ./fonts diff --git a/modules/nix/default.nix b/modules/nix/default.nix index 38e66e7a..92b7d175 100644 --- a/modules/nix/default.nix +++ b/modules/nix/default.nix @@ -6,7 +6,7 @@ let cfg = config.nix; - isNix20 = versionAtLeast (cfg.version or "") "1.12pre"; + nixPackage = cfg.package.out; nixConf = let @@ -61,9 +61,10 @@ let in { - imports = mapAttrsToList (oldConf: newConf: - mkRenamedOptionModule [ "nix" oldConf ] [ "nix" "settings" newConf ] - ) legacyConfMappings; + imports = [ + (mkRemovedOptionModule [ "nix" "profile" ] "Use `nix.package` instead.") + (mkRemovedOptionModule [ "nix" "version" ] "Consider using `nix.package.version` instead.") + ] ++ mapAttrsToList (oldConf: newConf: mkRenamedOptionModule [ "nix" oldConf ] [ "nix" "settings" newConf ]) legacyConfMappings; ###### interface @@ -72,26 +73,14 @@ in nix = { package = mkOption { - type = types.either types.package types.path; + type = types.package; default = pkgs.nix; - defaultText = "pkgs.nix"; - example = literalExpression "pkgs.nixUnstable"; + defaultText = literalExpression "pkgs.nix"; 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. - - eg. /nix/var/nix/profiles/default + This option specifies the Nix package instance to use throughout the system. ''; }; - # Not in NixOS module - version = mkOption { - type = types.str; - default = ""; - example = "1.11.6"; - description = "The version of nix. Used to determine what settings to configure in nix.conf"; - }; - # Not in NixOS module useDaemon = mkOption { type = types.bool; @@ -475,14 +464,12 @@ in ])) ]; - - nix.package = mkIf (config.system.stateVersion < 3) - (mkDefault "/nix/var/nix/profiles/default"); - - nix.version = mkIf (isDerivation cfg.package) cfg.package.version or ""; - - environment.systemPackages = mkIf (isDerivation cfg.package) - [ cfg.package ]; + environment.systemPackages = + [ + nixPackage + pkgs.nix-info + ] + ++ optional (config.programs.bash.enableCompletion) pkgs.nix-bash-completions; environment.etc."nix/nix.conf".source = nixConf; diff --git a/modules/nix/nix-info.nix b/modules/nix/nix-info.nix deleted file mode 100644 index 146a08c0..00000000 --- a/modules/nix/nix-info.nix +++ /dev/null @@ -1,15 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; - -let - nix-info = pkgs.nix-info or null; -in - -{ - config = { - - environment.systemPackages = mkIf (nix-info != null) [ nix-info ]; - - }; -}