2018-02-28 21:02:21 +01:00
|
|
|
{ lib }: rec {
|
|
|
|
|
|
|
|
source = lib.types.submodule ({ config, ... }: {
|
|
|
|
options = {
|
|
|
|
type = let
|
|
|
|
known-types = lib.attrNames source-types;
|
|
|
|
type-candidates = lib.filter (k: config.${k} != null) known-types;
|
|
|
|
in lib.mkOption {
|
|
|
|
default = if lib.length type-candidates == 1
|
|
|
|
then lib.head type-candidates
|
|
|
|
else throw "cannot determine type";
|
|
|
|
type = lib.types.enum known-types;
|
|
|
|
};
|
2018-12-01 04:20:50 +01:00
|
|
|
derivation = lib.mkOption {
|
|
|
|
apply = x:
|
|
|
|
if lib.types.str.check x
|
|
|
|
then { text = x; }
|
|
|
|
else x;
|
|
|
|
default = null;
|
|
|
|
type = lib.types.nullOr (lib.types.either lib.types.str source-types.derivation);
|
|
|
|
};
|
2018-02-28 21:02:21 +01:00
|
|
|
file = lib.mkOption {
|
|
|
|
apply = x:
|
2021-10-26 13:05:49 +02:00
|
|
|
if lib.types.absolute-pathname.check x || lib.types.package.check x
|
2018-02-28 21:02:21 +01:00
|
|
|
then { path = x; }
|
|
|
|
else x;
|
|
|
|
default = null;
|
2021-10-26 13:05:49 +02:00
|
|
|
type = lib.types.nullOr (lib.types.oneOf [
|
|
|
|
lib.types.absolute-pathname
|
|
|
|
lib.types.package
|
|
|
|
source-types.file
|
|
|
|
]);
|
2018-02-28 21:02:21 +01:00
|
|
|
};
|
|
|
|
git = lib.mkOption {
|
|
|
|
default = null;
|
|
|
|
type = lib.types.nullOr source-types.git;
|
|
|
|
};
|
|
|
|
pass = lib.mkOption {
|
|
|
|
default = null;
|
|
|
|
type = lib.types.nullOr source-types.pass;
|
|
|
|
};
|
|
|
|
pipe = lib.mkOption {
|
|
|
|
apply = x:
|
|
|
|
if lib.types.absolute-pathname.check x
|
|
|
|
then { command = x; }
|
|
|
|
else x;
|
|
|
|
default = null;
|
|
|
|
type = lib.types.nullOr (lib.types.either lib.types.absolute-pathname source-types.pipe);
|
|
|
|
};
|
|
|
|
symlink = lib.mkOption {
|
|
|
|
apply = x:
|
|
|
|
if lib.types.pathname.check x
|
|
|
|
then { target = x; }
|
|
|
|
else x;
|
|
|
|
default = null;
|
|
|
|
type = lib.types.nullOr (lib.types.either lib.types.pathname source-types.symlink);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2020-02-03 16:37:55 +01:00
|
|
|
filter = lib.types.submodule {
|
|
|
|
options = {
|
|
|
|
type = lib.mkOption {
|
|
|
|
type = lib.types.enum ["include" "exclude"];
|
|
|
|
default = "exclude";
|
|
|
|
};
|
|
|
|
pattern = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-02-28 21:02:21 +01:00
|
|
|
source-types = {
|
2018-12-01 04:20:50 +01:00
|
|
|
derivation = lib.types.submodule {
|
|
|
|
options = {
|
|
|
|
text = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2018-02-28 21:02:21 +01:00
|
|
|
file = lib.types.submodule {
|
|
|
|
options = {
|
|
|
|
path = lib.mkOption {
|
|
|
|
type = lib.types.absolute-pathname;
|
|
|
|
};
|
2018-11-28 08:34:19 +01:00
|
|
|
useChecksum = lib.mkOption {
|
|
|
|
default = false;
|
|
|
|
type = lib.types.bool;
|
|
|
|
};
|
2019-12-22 14:07:51 +01:00
|
|
|
exclude = lib.mkOption {
|
2020-03-17 19:32:46 +01:00
|
|
|
apply = x:
|
|
|
|
if x != [] then
|
|
|
|
lib.warn
|
|
|
|
"file.*.exclude is deprecated in favor of file.*.filters"
|
|
|
|
x
|
|
|
|
else
|
|
|
|
x;
|
|
|
|
description = ''
|
|
|
|
DEPRECATED, use `filters`.
|
|
|
|
'';
|
2019-12-22 14:07:51 +01:00
|
|
|
type = lib.types.listOf lib.types.str;
|
|
|
|
default = [];
|
|
|
|
example = [".git"];
|
|
|
|
};
|
2020-02-03 16:37:55 +01:00
|
|
|
filters = lib.mkOption {
|
|
|
|
type = lib.types.listOf filter;
|
|
|
|
default = [];
|
|
|
|
example = [
|
|
|
|
{
|
|
|
|
type = "include";
|
|
|
|
pattern = "*.nix";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
type = "include";
|
|
|
|
pattern = "*/";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
type = "exclude";
|
|
|
|
pattern = "*";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
deleteExcluded = lib.mkOption {
|
|
|
|
default = true;
|
|
|
|
type = lib.types.bool;
|
|
|
|
};
|
2018-02-28 21:02:21 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
git = lib.types.submodule {
|
|
|
|
options = {
|
2018-10-31 18:24:57 +01:00
|
|
|
clean = {
|
|
|
|
exclude = lib.mkOption {
|
|
|
|
default = [];
|
|
|
|
type = lib.types.listOf lib.types.str;
|
|
|
|
};
|
|
|
|
};
|
2019-08-08 17:12:48 +02:00
|
|
|
fetchAlways = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = false;
|
|
|
|
};
|
2018-02-28 21:02:21 +01:00
|
|
|
ref = lib.mkOption {
|
|
|
|
type = lib.types.str; # TODO lib.types.git.ref
|
|
|
|
};
|
|
|
|
url = lib.mkOption {
|
|
|
|
type = lib.types.str; # TODO lib.types.git.url
|
|
|
|
};
|
2020-07-02 09:27:55 +02:00
|
|
|
shallow = lib.mkOption {
|
|
|
|
default = false;
|
|
|
|
type = lib.types.bool;
|
|
|
|
};
|
2018-02-28 21:02:21 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
pass = lib.types.submodule {
|
|
|
|
options = {
|
|
|
|
dir = lib.mkOption {
|
|
|
|
type = lib.types.absolute-pathname;
|
|
|
|
};
|
|
|
|
name = lib.mkOption {
|
|
|
|
type = lib.types.pathname; # TODO relative-pathname
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
pipe = lib.types.submodule {
|
|
|
|
options = {
|
|
|
|
command = lib.mkOption {
|
|
|
|
type = lib.types.absolute-pathname;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
symlink = lib.types.submodule {
|
|
|
|
options = {
|
|
|
|
target = lib.mkOption {
|
|
|
|
type = lib.types.pathname; # TODO relative-pathname
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|