refactor: potluck -> tidepool
This commit is contained in:
parent
e1321add05
commit
cdc90a4656
15 changed files with 0 additions and 0 deletions
14
tidepool/src/export.nix
Normal file
14
tidepool/src/export.nix
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# This file handles creating all of the exports for this project and is not
|
||||
# exported itself.
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
}: let
|
||||
in {
|
||||
config = {
|
||||
exports = {
|
||||
lib = config.lib;
|
||||
modules = import ./modules.nix;
|
||||
};
|
||||
};
|
||||
}
|
||||
7
tidepool/src/exports/default.nix
Normal file
7
tidepool/src/exports/default.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
includes = [
|
||||
./lib.nix
|
||||
./packages.nix
|
||||
./modules.nix
|
||||
];
|
||||
}
|
||||
19
tidepool/src/exports/lib.nix
Normal file
19
tidepool/src/exports/lib.nix
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
}: let
|
||||
in {
|
||||
options = {
|
||||
exports.lib = lib.options.create {
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
exported.lib = lib.options.create {
|
||||
default.value = {};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
exported.lib = config.exports.lib;
|
||||
};
|
||||
}
|
||||
34
tidepool/src/exports/modules.nix
Normal file
34
tidepool/src/exports/modules.nix
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
}: let
|
||||
cfg = config.exports;
|
||||
|
||||
type = lib.types.one [
|
||||
lib.types.path
|
||||
(lib.types.attrs.any)
|
||||
(lib.types.function lib.types.attrs.any)
|
||||
];
|
||||
in {
|
||||
options = {
|
||||
exports = {
|
||||
modules = lib.options.create {
|
||||
type = lib.types.attrs.of type;
|
||||
default.value = {};
|
||||
description = "An attribute set of modules to export.";
|
||||
};
|
||||
};
|
||||
|
||||
exported = {
|
||||
modules = lib.options.create {
|
||||
type = lib.types.attrs.of type;
|
||||
default.value = {};
|
||||
description = "An attribute set of modules to export.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
exported.modules = cfg.modules;
|
||||
};
|
||||
}
|
||||
22
tidepool/src/exports/packages.nix
Normal file
22
tidepool/src/exports/packages.nix
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
}: let
|
||||
lib' = config.lib;
|
||||
in {
|
||||
options = {
|
||||
exports.packages = lib.options.create {
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
exported.packages = lib.options.create {
|
||||
default.value = {};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
exported.packages = {
|
||||
# i686-linux = config.packages.foundation;
|
||||
};
|
||||
};
|
||||
}
|
||||
21
tidepool/src/lib/default.nix
Normal file
21
tidepool/src/lib/default.nix
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
}: let
|
||||
cfg = config.lib;
|
||||
in {
|
||||
includes = [
|
||||
./options.nix
|
||||
./systems.nix
|
||||
./types.nix
|
||||
];
|
||||
|
||||
options = {
|
||||
lib = lib.options.create {
|
||||
type = lib.types.attrs.any;
|
||||
default.value = {};
|
||||
description = "An attribute set of values to be added to `lib`.";
|
||||
apply = value: lib.extend (final: prev: prev.attrs.mergeRecursive prev value);
|
||||
};
|
||||
};
|
||||
}
|
||||
14
tidepool/src/lib/options.nix
Normal file
14
tidepool/src/lib/options.nix
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
}: let
|
||||
in {
|
||||
config = {
|
||||
lib.options = {
|
||||
package = lib.options.create {
|
||||
type = config.lib.types.package;
|
||||
description = "A package definition.";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
2187
tidepool/src/lib/systems.nix
Normal file
2187
tidepool/src/lib/systems.nix
Normal file
File diff suppressed because it is too large
Load diff
455
tidepool/src/lib/types.nix
Normal file
455
tidepool/src/lib/types.nix
Normal file
|
|
@ -0,0 +1,455 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
}: let
|
||||
lib' = config.lib;
|
||||
in {
|
||||
config = {
|
||||
lib.types = {
|
||||
license = let
|
||||
type = lib.types.submodule ({config}: {
|
||||
options = {
|
||||
name = {
|
||||
full = lib.options.create {
|
||||
type = lib.types.string;
|
||||
description = "The full name of the license.";
|
||||
};
|
||||
|
||||
short = lib.options.create {
|
||||
type = lib.types.string;
|
||||
description = "The short name of the license.";
|
||||
};
|
||||
};
|
||||
|
||||
spdx = lib.options.create {
|
||||
type = lib.types.nullish lib.types.string;
|
||||
default.value = null;
|
||||
description = "The SPDX identifier for the license.";
|
||||
};
|
||||
|
||||
url = lib.options.create {
|
||||
type = lib.types.nullish lib.types.string;
|
||||
description = "The URL for the license.";
|
||||
};
|
||||
|
||||
free = lib.options.create {
|
||||
type = lib.types.bool;
|
||||
default.value = true;
|
||||
description = "Whether the license is free.";
|
||||
};
|
||||
|
||||
redistributable = lib.options.create {
|
||||
type = lib.types.bool;
|
||||
default = {
|
||||
text = "config.free";
|
||||
value = config.free;
|
||||
};
|
||||
description = "Whether the license is allows redistribution.";
|
||||
};
|
||||
};
|
||||
});
|
||||
in
|
||||
lib.types.either type (lib.types.list.of type);
|
||||
|
||||
meta = lib.types.submodule {
|
||||
options = {
|
||||
name = lib.options.create {
|
||||
type = lib.types.string;
|
||||
description = "The name of the package.";
|
||||
};
|
||||
|
||||
description = lib.options.create {
|
||||
type = lib.types.nullish lib.types.string;
|
||||
default.value = null;
|
||||
description = "The description for the package.";
|
||||
};
|
||||
|
||||
homepage = lib.options.create {
|
||||
type = lib.types.nullish lib.types.string;
|
||||
default.value = null;
|
||||
description = "The homepage for the package.";
|
||||
};
|
||||
|
||||
license = lib.options.create {
|
||||
type = lib.types.nullish config.lib.types.license;
|
||||
default.value = null;
|
||||
description = "The license for the package.";
|
||||
};
|
||||
|
||||
free = lib.options.create {
|
||||
type = lib.types.bool;
|
||||
default.value = true;
|
||||
description = "Whether the package is free.";
|
||||
};
|
||||
|
||||
insecure = lib.options.create {
|
||||
type = lib.types.bool;
|
||||
default.value = false;
|
||||
description = "Whether the package is insecure.";
|
||||
};
|
||||
|
||||
broken = lib.options.create {
|
||||
type = lib.types.bool;
|
||||
default.value = false;
|
||||
description = "Whether the package is broken.";
|
||||
};
|
||||
|
||||
main = lib.options.create {
|
||||
type = lib.types.nullish lib.types.string;
|
||||
default.value = null;
|
||||
description = "The main entry point for the package.";
|
||||
};
|
||||
|
||||
platforms = lib.options.create {
|
||||
type = lib.types.list.of lib.types.string;
|
||||
default.value = [];
|
||||
description = "The platforms the package supports.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
builder = lib.types.submodule {
|
||||
freeform = lib.types.any;
|
||||
|
||||
options = {
|
||||
build = lib.options.create {
|
||||
type = lib.types.function lib.types.derivation;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
packages = {
|
||||
generic = lib.types.attrs.of (lib.types.submodule ({name}: {
|
||||
freeform = lib.types.attrs.of (lib.types.submodule [
|
||||
lib'.types.package.generic'
|
||||
]);
|
||||
}));
|
||||
|
||||
# packages.<system>
|
||||
targeted = lib.types.attrs.of (lib.types.submodule ({name}: let
|
||||
system = name;
|
||||
in {
|
||||
# packages.<system>.<namespace>
|
||||
freeform = lib.types.attrs.of (lib.types.submodule ({name}: let
|
||||
namespace = name;
|
||||
in {
|
||||
# packages.<system>.<namespace>.<name>
|
||||
freeform = lib.types.attrs.of (lib.types.submodule [
|
||||
lib'.types.package.targeted'
|
||||
{
|
||||
config = {
|
||||
namespace = namespace;
|
||||
|
||||
platform = {
|
||||
build = system;
|
||||
host = lib.modules.overrides.default system;
|
||||
target = lib.modules.overrides.default system;
|
||||
};
|
||||
};
|
||||
}
|
||||
]);
|
||||
}));
|
||||
|
||||
# packages.<system>.<cross>
|
||||
options.cross = lib.attrs.generate lib'.systems.doubles.all (cross:
|
||||
lib.options.create {
|
||||
default.value = {};
|
||||
# packages.<system>.<cross>.<namespace>
|
||||
type = lib.types.attrs.of (lib.types.submodule (
|
||||
{name}: let
|
||||
namespace = name;
|
||||
in {
|
||||
# packages.<system>.<cross>.<namespace>.<name>
|
||||
freeform = lib.types.attrs.of (lib.types.submodule [
|
||||
lib'.types.package.targeted'
|
||||
{
|
||||
config = {
|
||||
namespace = namespace;
|
||||
|
||||
platform = {
|
||||
build = system;
|
||||
host = cross;
|
||||
target = lib.modules.overrides.default cross;
|
||||
};
|
||||
};
|
||||
}
|
||||
]);
|
||||
}
|
||||
));
|
||||
});
|
||||
}));
|
||||
};
|
||||
|
||||
dependencies = {
|
||||
generic = lib.types.attrs.of (lib.types.nullish lib'.types.package.generic);
|
||||
|
||||
targeted = lib.types.attrs.of (lib.types.nullish lib'.types.package.targeted);
|
||||
};
|
||||
|
||||
package = {
|
||||
generic = lib.types.submodule lib'.types.package.generic';
|
||||
|
||||
generic' = args @ {
|
||||
name ? assert false; null,
|
||||
config,
|
||||
}: {
|
||||
options = {
|
||||
pname = lib.options.create {
|
||||
type = lib.types.string;
|
||||
default = {
|
||||
text = "<name> or \"unknown\"";
|
||||
value =
|
||||
if args ? name
|
||||
then args.name
|
||||
else "unknown";
|
||||
};
|
||||
};
|
||||
|
||||
version = lib.options.create {
|
||||
type = lib.types.nullish lib.types.version;
|
||||
default.value = null;
|
||||
};
|
||||
|
||||
meta = lib.options.create {
|
||||
type = lib'.types.meta;
|
||||
default.value = {
|
||||
name = config.pname;
|
||||
};
|
||||
};
|
||||
|
||||
phases = lib.options.create {
|
||||
type = lib.types.dag.of (
|
||||
lib.types.either
|
||||
lib.types.string
|
||||
(lib.types.function lib.types.string)
|
||||
);
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
env = lib.options.create {
|
||||
type = lib.types.attrs.of lib.types.string;
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
builder = lib.options.create {
|
||||
type = lib'.types.builder;
|
||||
};
|
||||
|
||||
deps = {
|
||||
build = {
|
||||
only = lib.options.create {
|
||||
type = lib'.types.dependencies.generic;
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
build = lib.options.create {
|
||||
type = lib'.types.dependencies.generic;
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
host = lib.options.create {
|
||||
type = lib'.types.dependencies.generic;
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
target = lib.options.create {
|
||||
type = lib'.types.dependencies.generic;
|
||||
default.value = {};
|
||||
};
|
||||
};
|
||||
|
||||
host = {
|
||||
only = lib.options.create {
|
||||
type = lib'.types.dependencies.generic;
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
host = lib.options.create {
|
||||
type = lib'.types.dependencies.generic;
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
target = lib.options.create {
|
||||
type = lib'.types.dependencies.generic;
|
||||
default.value = {};
|
||||
};
|
||||
};
|
||||
|
||||
target = {
|
||||
only = lib.options.create {
|
||||
type = lib'.types.dependencies.generic;
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
target = lib.options.create {
|
||||
type = lib'.types.dependencies.generic;
|
||||
default.value = {};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
versions = lib.options.create {
|
||||
type = lib.types.attrs.of lib'.types.packages.generic;
|
||||
default.value = {};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
targeted = lib.types.submodule lib'.types.package.targeted';
|
||||
|
||||
targeted' = args @ {
|
||||
name ? assert false; null,
|
||||
config,
|
||||
}: {
|
||||
options = {
|
||||
name = lib.options.create {
|
||||
type = lib.types.string;
|
||||
default = {
|
||||
text = "\${namespace}-\${pname}-\${version} or \${pname}-\${version}";
|
||||
value = let
|
||||
namespace =
|
||||
if config.namespace == null
|
||||
then ""
|
||||
else "${config.namespace}-";
|
||||
version =
|
||||
if config.version == null
|
||||
then ""
|
||||
else "-${config.version}";
|
||||
in "${namespace}${config.pname}${version}";
|
||||
};
|
||||
};
|
||||
|
||||
namespace = lib.options.create {
|
||||
type = lib.types.nullish lib.types.string;
|
||||
default.value = null;
|
||||
};
|
||||
|
||||
pname = lib.options.create {
|
||||
type = lib.types.string;
|
||||
default = {
|
||||
text = "<name> or \"unknown\"";
|
||||
value =
|
||||
if args ? name
|
||||
then args.name
|
||||
else "unknown";
|
||||
};
|
||||
};
|
||||
|
||||
version = lib.options.create {
|
||||
type = lib.types.nullish lib.types.version;
|
||||
default.value = null;
|
||||
};
|
||||
|
||||
meta = lib.options.create {
|
||||
type = lib'.types.meta;
|
||||
default.value = {
|
||||
name = config.pname;
|
||||
};
|
||||
};
|
||||
|
||||
platform = {
|
||||
build = lib.options.create {
|
||||
type = lib.types.nullish lib.types.string;
|
||||
default.value = null;
|
||||
};
|
||||
|
||||
host = lib.options.create {
|
||||
type = lib.types.nullish lib.types.string;
|
||||
default.value = null;
|
||||
};
|
||||
|
||||
target = lib.options.create {
|
||||
type = lib.types.nullish lib.types.string;
|
||||
default.value = null;
|
||||
};
|
||||
};
|
||||
|
||||
phases = lib.options.create {
|
||||
type = lib.types.dag.of (
|
||||
lib.types.either
|
||||
lib.types.string
|
||||
(lib.types.function lib.types.string)
|
||||
);
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
env = lib.options.create {
|
||||
type = lib.types.attrs.of lib.types.string;
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
builder = lib.options.create {
|
||||
type = lib'.types.builder;
|
||||
};
|
||||
|
||||
package = lib.options.create {
|
||||
type = lib.types.derivation;
|
||||
};
|
||||
|
||||
deps = {
|
||||
build = {
|
||||
only = lib.options.create {
|
||||
type = lib'.types.dependencies.targeted;
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
build = lib.options.create {
|
||||
type = lib'.types.dependencies.targeted;
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
host = lib.options.create {
|
||||
type = lib'.types.dependencies.targeted;
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
target = lib.options.create {
|
||||
type = lib'.types.dependencies.targeted;
|
||||
default.value = {};
|
||||
};
|
||||
};
|
||||
|
||||
host = {
|
||||
only = lib.options.create {
|
||||
type = lib'.types.dependencies.targeted;
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
host = lib.options.create {
|
||||
type = lib'.types.dependencies.targeted;
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
target = lib.options.create {
|
||||
type = lib'.types.dependencies.targeted;
|
||||
default.value = {};
|
||||
};
|
||||
};
|
||||
|
||||
target = {
|
||||
only = lib.options.create {
|
||||
type = lib'.types.dependencies.targeted;
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
target = lib.options.create {
|
||||
type = lib'.types.dependencies.targeted;
|
||||
default.value = {};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
versions = lib.options.create {
|
||||
type = lib.types.attrs.of lib'.types.packages.targeted;
|
||||
default.value = {};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
package = config.builder.build config;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
5
tidepool/src/modules.nix
Normal file
5
tidepool/src/modules.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
exports = ./exports;
|
||||
lib = ./lib;
|
||||
packages = ./packages;
|
||||
}
|
||||
86
tidepool/src/packages/default.nix
Normal file
86
tidepool/src/packages/default.nix
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
}: let
|
||||
lib' = config.lib;
|
||||
|
||||
doubles = lib'.systems.doubles.all;
|
||||
|
||||
generic = config.packages.generic;
|
||||
|
||||
getPackages = system:
|
||||
builtins.mapAttrs
|
||||
(
|
||||
namespace: packages:
|
||||
lib.attrs.filter
|
||||
(name: package: builtins.elem system package.meta.platforms)
|
||||
packages
|
||||
);
|
||||
|
||||
targeted' = {
|
||||
i686-linux =
|
||||
getPackages "i686-linux" generic
|
||||
// {
|
||||
cross = {
|
||||
x86_64-linux = getPackages "x86_64-linux" generic;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
targeted = lib.attrs.generate lib'.systems.doubles.all (system:
|
||||
getPackages system generic
|
||||
// {
|
||||
cross = lib.attrs.generate doubles (
|
||||
host: getPackages host generic
|
||||
);
|
||||
});
|
||||
in {
|
||||
includes = [
|
||||
# ./aux/foundation.nix
|
||||
];
|
||||
|
||||
options = {
|
||||
packages = {
|
||||
generic = lib.options.create {
|
||||
type = lib'.types.packages.generic;
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
targeted = lib.options.create {
|
||||
type = lib'.types.packages.targeted;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
packages = {
|
||||
generic = {
|
||||
example = {
|
||||
x = {
|
||||
meta.platforms = ["i686-linux" "x86_64-linux"];
|
||||
version = "1.0.0";
|
||||
|
||||
builder.build = package:
|
||||
derivation {
|
||||
name = package.name;
|
||||
builder = "/bin/sh";
|
||||
system = package.platform.build;
|
||||
};
|
||||
|
||||
phases = {
|
||||
build = package: ''
|
||||
make --build ${package.platform.build} --host ${package.platform.host}
|
||||
'';
|
||||
|
||||
install = lib.dag.entry.after ["build"] ''
|
||||
make install DESTDIR=$out
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
inherit targeted;
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue