feat: working package export
This commit is contained in:
parent
cdc90a4656
commit
fea8c2cd9c
11 changed files with 168 additions and 59 deletions
|
|
@ -3,20 +3,43 @@
|
|||
lib,
|
||||
}: let
|
||||
lib' = config.lib;
|
||||
|
||||
cfg = config.exports;
|
||||
in {
|
||||
options = {
|
||||
exports.packages = lib.options.create {
|
||||
type = lib.types.attrs.of (lib.types.function (lib.types.nullish lib.types.derivation));
|
||||
default.value = {};
|
||||
};
|
||||
|
||||
exported.packages = lib.options.create {
|
||||
type = lib.types.attrs.of (lib.types.attrs.of lib.types.derivation);
|
||||
default.value = {};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
exported.packages = {
|
||||
# i686-linux = config.packages.foundation;
|
||||
};
|
||||
exported.packages = let
|
||||
all = lib.attrs.generate lib'.systems.doubles.all (
|
||||
system: let
|
||||
packages =
|
||||
builtins.mapAttrs
|
||||
(name: resolve: resolve system)
|
||||
cfg.packages;
|
||||
|
||||
available =
|
||||
lib.attrs.filter
|
||||
(name: package: package != null)
|
||||
packages;
|
||||
in
|
||||
available
|
||||
);
|
||||
|
||||
available =
|
||||
lib.attrs.filter
|
||||
(system: packages: builtins.length (builtins.attrNames packages) != 0)
|
||||
all;
|
||||
in
|
||||
available;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
in {
|
||||
includes = [
|
||||
./options.nix
|
||||
./packages.nix
|
||||
./systems.nix
|
||||
./types.nix
|
||||
];
|
||||
|
|
|
|||
37
tidepool/src/lib/packages.nix
Normal file
37
tidepool/src/lib/packages.nix
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
}: let
|
||||
lib' = config.lib;
|
||||
in {
|
||||
config = {
|
||||
lib.packages = {
|
||||
get = path: let
|
||||
resolved =
|
||||
if builtins.isList path
|
||||
then path
|
||||
else lib.strings.split "." path;
|
||||
|
||||
package = lib.attrs.selectOrThrow resolved config.packages.generic;
|
||||
in
|
||||
assert lib.errors.trace (builtins.length resolved > 1) "Packages must have a namespace specified.";
|
||||
package
|
||||
// {
|
||||
namespace = lib.modules.override 99 (builtins.head resolved);
|
||||
};
|
||||
|
||||
export = path: system: let
|
||||
resolved =
|
||||
if builtins.isList path
|
||||
then path
|
||||
else lib.strings.split "." path;
|
||||
|
||||
package = lib'.packages.get resolved;
|
||||
targeted = lib.attrs.selectOrThrow resolved config.packages.targeted.${system};
|
||||
in
|
||||
if builtins.elem system package.meta.platforms
|
||||
then targeted.package
|
||||
else null;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -53,11 +53,6 @@ in {
|
|||
|
||||
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;
|
||||
|
|
@ -138,7 +133,7 @@ in {
|
|||
lib'.types.package.targeted'
|
||||
{
|
||||
config = {
|
||||
namespace = namespace;
|
||||
namespace = lib.modules.override 99 namespace;
|
||||
|
||||
platform = {
|
||||
build = system;
|
||||
|
|
@ -164,7 +159,7 @@ in {
|
|||
lib'.types.package.targeted'
|
||||
{
|
||||
config = {
|
||||
namespace = namespace;
|
||||
namespace = lib.modules.override 99 namespace;
|
||||
|
||||
platform = {
|
||||
build = system;
|
||||
|
|
@ -194,6 +189,11 @@ in {
|
|||
config,
|
||||
}: {
|
||||
options = {
|
||||
namespace = lib.options.create {
|
||||
type = lib.types.nullish lib.types.string;
|
||||
default.value = null;
|
||||
};
|
||||
|
||||
pname = lib.options.create {
|
||||
type = lib.types.string;
|
||||
default = {
|
||||
|
|
|
|||
39
tidepool/src/packages/aux/foundation.nix
Normal file
39
tidepool/src/packages/aux/foundation.nix
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
options,
|
||||
}: let
|
||||
lib' = config.lib;
|
||||
in {
|
||||
config = {
|
||||
exports.packages.example-x = lib'.packages.export "example.x";
|
||||
|
||||
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
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -17,16 +17,6 @@
|
|||
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
|
||||
// {
|
||||
|
|
@ -36,7 +26,7 @@
|
|||
});
|
||||
in {
|
||||
includes = [
|
||||
# ./aux/foundation.nix
|
||||
./aux/foundation.nix
|
||||
];
|
||||
|
||||
options = {
|
||||
|
|
@ -54,32 +44,6 @@ in {
|
|||
|
||||
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