forked from auxolotl/labs
refactor: make dag helpers easier to reason about
This commit is contained in:
parent
0a63667459
commit
0ad14e8795
|
@ -95,7 +95,7 @@ lib: {
|
|||
## Create a new DAG entry.
|
||||
##
|
||||
## @type List String -> List String -> a -> { before :: List String, after :: List String, value :: a }
|
||||
between = before: after: value: { inherit before after value; };
|
||||
between = after: before: value: { inherit before after value; };
|
||||
|
||||
## Create a new DAG entry with no dependencies.
|
||||
##
|
||||
|
@ -105,12 +105,12 @@ lib: {
|
|||
## Create a new DAG entry that occurs before other entries.
|
||||
##
|
||||
## @type List String -> a -> { before :: List String, after :: List String, value :: a }
|
||||
before = before: lib.dag.entry.between before [ ];
|
||||
before = before: lib.dag.entry.between [ ] before;
|
||||
|
||||
## Create a new DAG entry that occurs after other entries.
|
||||
##
|
||||
## @type List String -> a -> { before :: List String, after :: List String, value :: a }
|
||||
after = lib.dag.entry.between [ ];
|
||||
after = after: lib.dag.entry.between after [ ];
|
||||
};
|
||||
|
||||
entries = {
|
||||
|
@ -121,7 +121,7 @@ lib: {
|
|||
tag:
|
||||
let
|
||||
process =
|
||||
i: before: after: entries:
|
||||
i: after: before: entries:
|
||||
let
|
||||
name = "${tag}-${builtins.toString i}";
|
||||
entry = builtins.head entries;
|
||||
|
@ -130,7 +130,7 @@ lib: {
|
|||
if builtins.length entries == 0 then
|
||||
{ }
|
||||
else if builtins.length entries == 1 then
|
||||
{ "${name}" = lib.dag.entry.between before after entry; }
|
||||
{ "${name}" = lib.dag.entry.between after before entry; }
|
||||
else
|
||||
{ "${name}" = lib.dag.entry.after after entry; } // (process (i + 1) before [ name ] rest);
|
||||
in
|
||||
|
@ -144,12 +144,12 @@ lib: {
|
|||
## Create a DAG from a list of entries, prefixed with a tag, that occurs before other entries.
|
||||
##
|
||||
## @type String -> List String -> List a -> Dag a
|
||||
before = tag: before: lib.dag.entries.between tag before [ ];
|
||||
before = tag: before: lib.dag.entries.between tag [ ] before;
|
||||
|
||||
## Create a DAG from a list of entries, prefixed with a tag, that occurs after other entries.
|
||||
##
|
||||
## @type String -> List String -> List a -> Dag a
|
||||
after = tag: lib.dag.entries.between tag [ ];
|
||||
after = tag: after: lib.dag.entries.between tag after [ ];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -17,11 +17,11 @@ in
|
|||
phases = lib.dag.apply.defaults package.phases {
|
||||
unpack = lib.dag.entry.before [ "patch" ] "";
|
||||
|
||||
patch = lib.dag.entry.between [ "configure" ] [ "unpack" ] "";
|
||||
patch = lib.dag.entry.between [ "unpack" ] [ "configure" ] "";
|
||||
|
||||
configure = lib.dag.entry.between [ "build" ] [ "patch" ] "";
|
||||
configure = lib.dag.entry.between [ "patch" ] [ "build" ] "";
|
||||
|
||||
build = lib.dag.entry.between [ "install" ] [ "configure" ] "";
|
||||
build = lib.dag.entry.between [ "configure" ] [ "install" ] "";
|
||||
|
||||
install = lib.dag.entry.after [ "build" ] "";
|
||||
};
|
||||
|
|
|
@ -79,12 +79,12 @@ in
|
|||
};
|
||||
|
||||
phases = {
|
||||
unpack = lib.dag.entry.before [ "patch" ] ''
|
||||
unpack = ''
|
||||
tar xf ${config.src}
|
||||
cd glibc-${config.version}
|
||||
'';
|
||||
|
||||
configure = lib.dag.entry.between [ "build" ] [ "patch" ] ''
|
||||
configure = ''
|
||||
mkdir build
|
||||
cd build
|
||||
# libstdc++.so is built against musl and fails to link
|
||||
|
@ -96,12 +96,12 @@ in
|
|||
--with-headers=${foundation.stage1-linux-headers}/include
|
||||
'';
|
||||
|
||||
build = lib.dag.entry.between [ "install" ] [ "configure" ] ''
|
||||
build = ''
|
||||
# Build
|
||||
make -j $NIX_BUILD_CORES
|
||||
'';
|
||||
|
||||
install = lib.dag.entry.after [ "build" ] ''
|
||||
install = ''
|
||||
# Install
|
||||
make -j $NIX_BUILD_CORES install-strip
|
||||
'';
|
||||
|
|
Loading…
Reference in a new issue