refactor: avoid using // where we know the sets should be disjoint
This commit is contained in:
parent
b2774a4004
commit
f17ae1ca7b
|
@ -3,7 +3,7 @@
|
|||
|
||||
let
|
||||
# make the logs for this host "public" so that they show up in e.g. metrics
|
||||
publog = vhost: vhost // {
|
||||
publog = vhost: lib.attrsets.unionOfDisjoint vhost {
|
||||
extraConfig = (vhost.extraConfig or "") + ''
|
||||
access_log /var/log/nginx/public.log vcombined;
|
||||
'';
|
||||
|
|
|
@ -131,11 +131,14 @@ in
|
|||
# <item oor:path="/org.openoffice.Setup/Product"><prop oor:name="LastTimeGetInvolvedShown" oor:op="fuse"><value>1667693880</value></prop></item>
|
||||
|
||||
|
||||
programs = {
|
||||
programs = lib.mkMerge [
|
||||
{
|
||||
home-manager.enable = true; # this lets home-manager manage dot-files in user dirs, i think
|
||||
# "command not found" will cause the command to be searched in nixpkgs
|
||||
nix-index.enable = true;
|
||||
} // cfg.programs;
|
||||
}
|
||||
cfg.programs
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -10,9 +10,10 @@ in {
|
|||
builtins.toJSON {
|
||||
# feed format is a map from URL to a dict,
|
||||
# with dict["tags"] a list of string tags.
|
||||
feeds = builtins.foldl' (acc: feed: acc // {
|
||||
"${feed.url}".tags = [ feed.cat feed.freq ];
|
||||
}) {} wanted-feeds;
|
||||
feeds = sane-lib.mapToAttrs (feed: {
|
||||
name = feed.url;
|
||||
value.tags = [ feed.cat feed.freq ];
|
||||
}) wanted-feeds;
|
||||
dark_reader = false;
|
||||
new_first = true;
|
||||
# windowsize = {
|
||||
|
|
|
@ -16,12 +16,18 @@ rec {
|
|||
# Type: filterNonNull :: AttrSet -> AttrSet
|
||||
filterNonNull = attrs: lib.filterAttrsRecursive (n: v: v != null) attrs;
|
||||
|
||||
# return only the subset of `attrs` whose name is in the provided set.
|
||||
# Type: filterByName :: [String] -> AttrSet
|
||||
filterByName = names: attrs: lib.filterAttrs
|
||||
(name: value: builtins.elem name names)
|
||||
attrs;
|
||||
|
||||
# transform a list into an AttrSet via a function which maps an element to a name + value
|
||||
# Type: mapToAttrs :: (a -> { name, value }) -> [a] -> AttrSet
|
||||
# Type: mapToAttrs :: (a -> { name :: String, value :: Any }) -> [a] -> AttrSet
|
||||
mapToAttrs = f: list: builtins.listToAttrs (builtins.map f list);
|
||||
|
||||
# flatten a nested AttrSet into a list of { path = [str]; value } items.
|
||||
# Type: flattenAttrs :: AttrSet[item|AttrSet] -> [{ path; value; }]
|
||||
# flatten a nested AttrSet into a list of { path = [String]; value } items.
|
||||
# Type: flattenAttrs :: AttrSet[AttrSet|Any] -> [{ path :: String, value :: Any }]
|
||||
flattenAttrs = flattenAttrs' [];
|
||||
flattenAttrs' = path: value: if builtins.isAttrs value then (
|
||||
builtins.concatLists (
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{ lib, ... }:
|
||||
|
||||
rec {
|
||||
wanted = lib.mergeAttrs { wantedBeforeBy = [ "multi-user.target" ]; };
|
||||
wanted = lib.attrsets.unionOfDisjoint { wantedBeforeBy = [ "multi-user.target" ]; };
|
||||
wantedSymlink = symlink: wanted { inherit symlink; };
|
||||
wantedSymlinkTo = target: wantedSymlink { inherit target; };
|
||||
wantedText = text: wantedSymlink { inherit text; };
|
||||
|
|
|
@ -100,13 +100,12 @@ let
|
|||
# toplevel and move them into an `acl` attribute.
|
||||
convertInlineAcl = to: types.coercedTo
|
||||
types.attrs
|
||||
(orig: (builtins.removeAttrs orig ["user" "group" "mode" ]) // {
|
||||
acl = (orig.acl or {}) // (sane-lib.filterNonNull {
|
||||
user = orig.user or null;
|
||||
group = orig.group or null;
|
||||
mode = orig.mode or null;
|
||||
});
|
||||
})
|
||||
(orig: lib.recursiveUpdate
|
||||
(builtins.removeAttrs orig ["user" "group" "mode" ])
|
||||
{
|
||||
acl = sane-lib.filterByName ["user" "group" "mode"] (orig.acl or {});
|
||||
}
|
||||
)
|
||||
to;
|
||||
|
||||
# entry where the path is specified externally
|
||||
|
@ -125,7 +124,8 @@ let
|
|||
# <option>.private.".cache/vim" = { mode = "0700"; };
|
||||
# to place ".cache/vim" into the private store and create with the appropriate mode
|
||||
dirsSubModule = types.submodule ({ config, ... }: {
|
||||
options = (mapAttrs (store: store-cfg: mkOption {
|
||||
options = lib.attrsets.unionOfDisjoint
|
||||
(mapAttrs (store: store-cfg: mkOption {
|
||||
default = [];
|
||||
type = types.listOf (convertInlineAcl entryInStoreOrShorthand);
|
||||
description = let
|
||||
|
@ -133,7 +133,8 @@ let
|
|||
": ${store-cfg.storeDescription}"
|
||||
else "";
|
||||
in "directories to persist in ${store}${suffix}";
|
||||
}) cfg.stores) // {
|
||||
}) cfg.stores)
|
||||
{
|
||||
byPath = mkOption {
|
||||
type = types.attrsOf (convertInlineAcl entryAtPath);
|
||||
default = {};
|
||||
|
|
Loading…
Reference in New Issue
Block a user