persist: configure the private
store to symlink everyting by default
This commit is contained in:
@@ -4,6 +4,12 @@
|
|||||||
path = import ./path.nix moduleArgs;
|
path = import ./path.nix moduleArgs;
|
||||||
types = import ./types.nix moduleArgs;
|
types = import ./types.nix moduleArgs;
|
||||||
|
|
||||||
|
# if `maybe-null` is non-null, yield that. else, return the `default`.
|
||||||
|
withDefault = default: maybe-null: if maybe-null != null then
|
||||||
|
maybe-null
|
||||||
|
else
|
||||||
|
default;
|
||||||
|
|
||||||
filterNonNull = attrs: lib.filterAttrsRecursive (n: v: v != null) attrs;
|
filterNonNull = attrs: lib.filterAttrsRecursive (n: v: v != null) 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, value }) -> [a] -> AttrSet
|
||||||
|
@@ -34,6 +34,13 @@ let
|
|||||||
/mnt/crypt/private/var/private/www/root.
|
/mnt/crypt/private/var/private/www/root.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
defaultMethod = mkOption {
|
||||||
|
type = types.enum [ "bind" "symlink" ];
|
||||||
|
default = "bind";
|
||||||
|
description = ''
|
||||||
|
preferred way to link items from the store into the fs
|
||||||
|
'';
|
||||||
|
};
|
||||||
defaultOrdering.wantedBeforeBy = mkOption {
|
defaultOrdering.wantedBeforeBy = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ "local-fs.target" ];
|
default = [ "local-fs.target" ];
|
||||||
@@ -63,8 +70,8 @@ let
|
|||||||
default = {};
|
default = {};
|
||||||
};
|
};
|
||||||
method = mkOption {
|
method = mkOption {
|
||||||
type = types.enum [ "bind" "symlink" ];
|
type = types.nullOr (types.enum [ "bind" "symlink" ]);
|
||||||
default = "bind";
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
how to link the store entry into the fs
|
how to link the store entry into the fs
|
||||||
'';
|
'';
|
||||||
@@ -205,6 +212,7 @@ in
|
|||||||
cfgFor = fspath: opt:
|
cfgFor = fspath: opt:
|
||||||
let
|
let
|
||||||
store = opt.store;
|
store = opt.store;
|
||||||
|
method = (sane-lib.withDefault store.defaultMethod) opt.method;
|
||||||
fsPathToStoreRelPath = fspath: path.from store.prefix fspath;
|
fsPathToStoreRelPath = fspath: path.from store.prefix fspath;
|
||||||
fsPathToBackingPath = fspath: path.concat [ store.origin (fsPathToStoreRelPath fspath) ];
|
fsPathToBackingPath = fspath: path.concat [ store.origin (fsPathToStoreRelPath fspath) ];
|
||||||
in [
|
in [
|
||||||
@@ -212,11 +220,11 @@ in
|
|||||||
# create destination dir, with correct perms
|
# create destination dir, with correct perms
|
||||||
sane.fs."${fspath}" = {
|
sane.fs."${fspath}" = {
|
||||||
inherit (store.defaultOrdering) wantedBy wantedBeforeBy;
|
inherit (store.defaultOrdering) wantedBy wantedBeforeBy;
|
||||||
} // (lib.optionalAttrs (opt.method == "bind") {
|
} // (lib.optionalAttrs (method == "bind") {
|
||||||
# inherit perms & make sure we don't mount until after the mount point is setup correctly.
|
# inherit perms & make sure we don't mount until after the mount point is setup correctly.
|
||||||
dir.acl = opt.acl;
|
dir.acl = opt.acl;
|
||||||
mount.bind = fsPathToBackingPath fspath;
|
mount.bind = fsPathToBackingPath fspath;
|
||||||
}) // (lib.optionalAttrs (opt.method == "symlink") {
|
}) // (lib.optionalAttrs (method == "symlink") {
|
||||||
symlink.acl = opt.acl;
|
symlink.acl = opt.acl;
|
||||||
symlink.target = fsPathToBackingPath fspath;
|
symlink.target = fsPathToBackingPath fspath;
|
||||||
});
|
});
|
||||||
|
@@ -20,6 +20,7 @@ lib.mkIf config.sane.persist.enable
|
|||||||
# we can't create things in private before local-fs.target
|
# we can't create things in private before local-fs.target
|
||||||
wantedBeforeBy = [ ];
|
wantedBeforeBy = [ ];
|
||||||
};
|
};
|
||||||
|
defaultMethod = "symlink";
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems."/home/colin/private" = {
|
fileSystems."/home/colin/private" = {
|
||||||
|
Reference in New Issue
Block a user