Removed pipe operator.
The pipe operator '<|' was added in Nix 2.24 as experimental. In typical nix community fashion, an eternity has passed, it's still experimental, and they're still arguing about it. Thus, in order not to burden any users of this flake, they have been removed. To get this done quickly a utility function has been added called 'compose'. It is 'lib.trivial.pipe' written in reverse. This eliminates any bugs and performance regressions from unnecessary thunk evaluation.
This commit is contained in:
parent
0f0c4c7727
commit
2a5ced3905
7 changed files with 115 additions and 89 deletions
|
|
@ -14,9 +14,17 @@ let
|
|||
builtins.concatMap (y: builtins.concatMap (x: f x y) xs) ys;
|
||||
|
||||
# (Lib -> Profile -> c) -> ProfileSettings -> [c]
|
||||
mapLibAndProfile = f: x: mapProduct f allLibs <| builtins.attrValues <| x;
|
||||
mapLibAndProfile =
|
||||
f:
|
||||
sLib.compose [
|
||||
(mapProduct f allLibs)
|
||||
builtins.attrValues
|
||||
];
|
||||
|
||||
allLibs = builtins.attrValues <| lib.filterAttrs (k: _: k != "profiles") <| geckoLib;
|
||||
allLibs = sLib.compose [
|
||||
builtins.attrValues
|
||||
(lib.filterAttrs (k: _: k != "profiles"))
|
||||
] geckoLib;
|
||||
allLibs' = allLibs ++ [ geckoLib.profiles ];
|
||||
|
||||
submodule =
|
||||
|
|
@ -63,24 +71,23 @@ let
|
|||
|
||||
writeProfilesIni = configPath: profileSettings: {
|
||||
name = "${configPath}/profiles.ini";
|
||||
value.text =
|
||||
lib.generators.toINI { }
|
||||
<|
|
||||
lib.mapAttrs' (
|
||||
_: v:
|
||||
lib.nameValuePair "Profile${builtins.toString v.id}" {
|
||||
Name = v.name;
|
||||
Path = v.path;
|
||||
IsRelative = 1;
|
||||
Default = if v.isDefault then 1 else 0;
|
||||
}
|
||||
) profileSettings
|
||||
// {
|
||||
General = {
|
||||
StartWithLastProfile = 1;
|
||||
Version = 2;
|
||||
};
|
||||
value.text = lib.generators.toINI { } (
|
||||
lib.mapAttrs' (
|
||||
_: v:
|
||||
lib.nameValuePair "Profile${builtins.toString v.id}" {
|
||||
Name = v.name;
|
||||
Path = v.path;
|
||||
IsRelative = 1;
|
||||
Default = if v.isDefault then 1 else 0;
|
||||
}
|
||||
) profileSettings
|
||||
// {
|
||||
General = {
|
||||
StartWithLastProfile = 1;
|
||||
Version = 2;
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
in
|
||||
{
|
||||
|
|
@ -92,30 +99,31 @@ in
|
|||
|
||||
getDefaultProfileName =
|
||||
profileSettings:
|
||||
builtins.head
|
||||
<| builtins.filter (x: profileSettings.${x}.isDefault)
|
||||
<| builtins.attrNames
|
||||
<| profileSettings;
|
||||
sLib.compose [
|
||||
builtins.head
|
||||
(builtins.filter (x: profileSettings.${x}.isDefault))
|
||||
builtins.attrNames
|
||||
] profileSettings;
|
||||
|
||||
process =
|
||||
{ languagePacks, ... }:
|
||||
let
|
||||
extractVersion =
|
||||
extractVersion = sLib.compose [
|
||||
(x: if x == [ ] then info.base.version else builtins.head x)
|
||||
<| builtins.match "([^-]*)-.*"
|
||||
<| info.base.version;
|
||||
(builtins.match "([^-]*)-.*")
|
||||
] info.base.version;
|
||||
in
|
||||
{
|
||||
policies.ExtensionSettings =
|
||||
policies.ExtensionSettings = sLib.compose [
|
||||
builtins.listToAttrs
|
||||
<| builtins.map (lang: {
|
||||
(builtins.map (lang: {
|
||||
name = "langpack-${lang}@firefox.mozilla.org";
|
||||
value = {
|
||||
installation_mode = "force_installed";
|
||||
install_url = "https://releases.mozilla.org/pub/firefox/releases/${extractVersion}/linux-x86_64/xpi/${lang}.xpi";
|
||||
};
|
||||
})
|
||||
<| languagePacks;
|
||||
}))
|
||||
] languagePacks;
|
||||
};
|
||||
|
||||
assertions = profiles: [
|
||||
|
|
@ -124,12 +132,12 @@ in
|
|||
message = "No profiles are defined.";
|
||||
}
|
||||
{
|
||||
assertion =
|
||||
assertion = sLib.compose [
|
||||
(x: x == 1)
|
||||
<| builtins.length
|
||||
<| builtins.filter (x: profiles.${x}.isDefault)
|
||||
<| builtins.attrNames
|
||||
<| profiles;
|
||||
builtins.length
|
||||
(builtins.filter (x: profiles.${x}.isDefault))
|
||||
builtins.attrNames
|
||||
] profiles;
|
||||
message = "One, and only one, profile must be marked as 'isDefault'. If you have not set this option on any profile, then one and only one profile must have id '0'.";
|
||||
}
|
||||
];
|
||||
|
|
@ -141,15 +149,21 @@ in
|
|||
let
|
||||
processLevel =
|
||||
level: userConfig:
|
||||
sLib.recursiveMergeAll
|
||||
<| (x: [ userConfig ] ++ x)
|
||||
<| builtins.map (myLib: (myLib.${level} or (_: { })) userConfig)
|
||||
<| allLibs';
|
||||
sLib.compose [
|
||||
sLib.recursiveMergeAll
|
||||
(x: [ userConfig ] ++ x)
|
||||
(builtins.map (myLib: (myLib.${level} or (_: { })) userConfig))
|
||||
] allLibs';
|
||||
|
||||
# Internal libraries can create their own configuration that needs to be merged
|
||||
# into the user configuration (the user's takes priority). Generate that config.
|
||||
finalConfig = builtins.mapAttrs (
|
||||
_: v: processLevel "postprocess" <| processLevel "process" <| processLevel "preprocess" <| v
|
||||
_:
|
||||
sLib.compose [
|
||||
(processLevel "postprocess")
|
||||
(processLevel "process")
|
||||
(processLevel "preprocess")
|
||||
]
|
||||
) profiles;
|
||||
in
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue