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
|
let
|
||||||
# make the logs for this host "public" so that they show up in e.g. metrics
|
# 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 "") + ''
|
extraConfig = (vhost.extraConfig or "") + ''
|
||||||
access_log /var/log/nginx/public.log vcombined;
|
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>
|
# <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
|
home-manager.enable = true; # this lets home-manager manage dot-files in user dirs, i think
|
||||||
nix-index.enable = true;
|
# "command not found" will cause the command to be searched in nixpkgs
|
||||||
} // cfg.programs;
|
nix-index.enable = true;
|
||||||
|
}
|
||||||
|
cfg.programs
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,10 @@ in {
|
||||||
builtins.toJSON {
|
builtins.toJSON {
|
||||||
# feed format is a map from URL to a dict,
|
# feed format is a map from URL to a dict,
|
||||||
# with dict["tags"] a list of string tags.
|
# with dict["tags"] a list of string tags.
|
||||||
feeds = builtins.foldl' (acc: feed: acc // {
|
feeds = sane-lib.mapToAttrs (feed: {
|
||||||
"${feed.url}".tags = [ feed.cat feed.freq ];
|
name = feed.url;
|
||||||
}) {} wanted-feeds;
|
value.tags = [ feed.cat feed.freq ];
|
||||||
|
}) wanted-feeds;
|
||||||
dark_reader = false;
|
dark_reader = false;
|
||||||
new_first = true;
|
new_first = true;
|
||||||
# windowsize = {
|
# windowsize = {
|
||||||
|
|
|
@ -16,12 +16,18 @@ rec {
|
||||||
# Type: filterNonNull :: AttrSet -> AttrSet
|
# Type: filterNonNull :: AttrSet -> AttrSet
|
||||||
filterNonNull = attrs: lib.filterAttrsRecursive (n: v: v != null) attrs;
|
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
|
# 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);
|
mapToAttrs = f: list: builtins.listToAttrs (builtins.map f list);
|
||||||
|
|
||||||
# flatten a nested AttrSet into a list of { path = [str]; value } items.
|
# flatten a nested AttrSet into a list of { path = [String]; value } items.
|
||||||
# Type: flattenAttrs :: AttrSet[item|AttrSet] -> [{ path; value; }]
|
# Type: flattenAttrs :: AttrSet[AttrSet|Any] -> [{ path :: String, value :: Any }]
|
||||||
flattenAttrs = flattenAttrs' [];
|
flattenAttrs = flattenAttrs' [];
|
||||||
flattenAttrs' = path: value: if builtins.isAttrs value then (
|
flattenAttrs' = path: value: if builtins.isAttrs value then (
|
||||||
builtins.concatLists (
|
builtins.concatLists (
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{ lib, ... }:
|
{ lib, ... }:
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
wanted = lib.mergeAttrs { wantedBeforeBy = [ "multi-user.target" ]; };
|
wanted = lib.attrsets.unionOfDisjoint { wantedBeforeBy = [ "multi-user.target" ]; };
|
||||||
wantedSymlink = symlink: wanted { inherit symlink; };
|
wantedSymlink = symlink: wanted { inherit symlink; };
|
||||||
wantedSymlinkTo = target: wantedSymlink { inherit target; };
|
wantedSymlinkTo = target: wantedSymlink { inherit target; };
|
||||||
wantedText = text: wantedSymlink { inherit text; };
|
wantedText = text: wantedSymlink { inherit text; };
|
||||||
|
|
|
@ -100,13 +100,12 @@ let
|
||||||
# toplevel and move them into an `acl` attribute.
|
# toplevel and move them into an `acl` attribute.
|
||||||
convertInlineAcl = to: types.coercedTo
|
convertInlineAcl = to: types.coercedTo
|
||||||
types.attrs
|
types.attrs
|
||||||
(orig: (builtins.removeAttrs orig ["user" "group" "mode" ]) // {
|
(orig: lib.recursiveUpdate
|
||||||
acl = (orig.acl or {}) // (sane-lib.filterNonNull {
|
(builtins.removeAttrs orig ["user" "group" "mode" ])
|
||||||
user = orig.user or null;
|
{
|
||||||
group = orig.group or null;
|
acl = sane-lib.filterByName ["user" "group" "mode"] (orig.acl or {});
|
||||||
mode = orig.mode or null;
|
}
|
||||||
});
|
)
|
||||||
})
|
|
||||||
to;
|
to;
|
||||||
|
|
||||||
# entry where the path is specified externally
|
# entry where the path is specified externally
|
||||||
|
@ -125,24 +124,26 @@ let
|
||||||
# <option>.private.".cache/vim" = { mode = "0700"; };
|
# <option>.private.".cache/vim" = { mode = "0700"; };
|
||||||
# to place ".cache/vim" into the private store and create with the appropriate mode
|
# to place ".cache/vim" into the private store and create with the appropriate mode
|
||||||
dirsSubModule = types.submodule ({ config, ... }: {
|
dirsSubModule = types.submodule ({ config, ... }: {
|
||||||
options = (mapAttrs (store: store-cfg: mkOption {
|
options = lib.attrsets.unionOfDisjoint
|
||||||
default = [];
|
(mapAttrs (store: store-cfg: mkOption {
|
||||||
type = types.listOf (convertInlineAcl entryInStoreOrShorthand);
|
default = [];
|
||||||
description = let
|
type = types.listOf (convertInlineAcl entryInStoreOrShorthand);
|
||||||
suffix = if store-cfg.storeDescription != null then
|
description = let
|
||||||
": ${store-cfg.storeDescription}"
|
suffix = if store-cfg.storeDescription != null then
|
||||||
else "";
|
": ${store-cfg.storeDescription}"
|
||||||
in "directories to persist in ${store}${suffix}";
|
else "";
|
||||||
}) cfg.stores) // {
|
in "directories to persist in ${store}${suffix}";
|
||||||
byPath = mkOption {
|
}) cfg.stores)
|
||||||
type = types.attrsOf (convertInlineAcl entryAtPath);
|
{
|
||||||
default = {};
|
byPath = mkOption {
|
||||||
description = ''
|
type = types.attrsOf (convertInlineAcl entryAtPath);
|
||||||
map of <path> => <path config> for all paths to be persisted.
|
default = {};
|
||||||
this is computed from the other options, but users can also set it explicitly (useful for overriding)
|
description = ''
|
||||||
'';
|
map of <path> => <path config> for all paths to be persisted.
|
||||||
|
this is computed from the other options, but users can also set it explicitly (useful for overriding)
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
config = let
|
config = let
|
||||||
# set the `store` attribute on one dir attrset
|
# set the `store` attribute on one dir attrset
|
||||||
annotateWithStore = store: dir: {
|
annotateWithStore = store: dir: {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user