1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-13 20:30:02 +00:00

Refactor nix.nixPath to make diff easier to compare with NixOS module

This commit is contained in:
Malo Bourgon 2022-08-13 16:41:43 -07:00
parent c3bdd6d95f
commit 7648c9befc

View file

@ -88,6 +88,29 @@ let
in
attrsOf (either confAtom (listOf confAtom));
# Not in NixOS module
nixPathType = mkOptionType {
name = "nix path";
merge = loc: defs:
let
values = flatten (map (def:
(map (x:
if isAttrs x then (mapAttrsToList nameValuePair x)
else if isString x then x
else throw "The option value `${showOption loc}` in `${def.file}` is not a attset or string.")
(if isList def.value then def.value else [def.value]))) defs);
namedPaths = mapAttrsToList (n: v: "${n}=${(head v).value}")
(zipAttrs
(map (x: { "${x.name}" = { inherit (x) value; }; })
(filter isAttrs values)));
searchPaths = unique
(filter isString values);
in
namedPaths ++ searchPaths;
};
in
{
@ -291,37 +314,15 @@ in
'';
};
# Definition differs substantially from NixOS module
nixPath = mkOption {
type = mkOptionType {
name = "nix path";
merge = loc: defs:
let
values = flatten (map (def:
(map (x:
if isAttrs x then (mapAttrsToList nameValuePair x)
else if isString x then x
else throw "The option value `${showOption loc}` in `${def.file}` is not a attset or string.")
(if isList def.value then def.value else [def.value]))) defs);
namedPaths = mapAttrsToList (n: v: "${n}=${(head v).value}")
(zipAttrs
(map (x: { "${x.name}" = { inherit (x) value; }; })
(filter isAttrs values)));
searchPaths = unique
(filter isString values);
in
namedPaths ++ searchPaths;
};
default =
[ # Include default path <darwin-config>.
type = nixPathType;
default = [
# Include default path <darwin-config>.
{ darwin-config = "${config.environment.darwinConfig}"; }
"/nix/var/nix/profiles/per-user/root/channels"
"$HOME/.nix-defexpr/channels"
];
example =
[ { trunk = "/src/nixpkgs"; }
];
description = ''
The default Nix expression search path, used by the Nix
evaluator to look up paths enclosed in angle brackets
@ -664,7 +665,7 @@ in
];
# Set up the environment variables for running Nix.
environment.variables = cfg.envVars // { NIX_PATH = concatStringsSep ":" cfg.nixPath; };
environment.variables = cfg.envVars // { NIX_PATH = cfg.nixPath; };
# Unreladed to use in NixOS module
environment.extraInit = ''