From 0ad14e8795505916fbaabb93d2460abe02a73c92 Mon Sep 17 00:00:00 2001 From: Jake Hamilton Date: Sun, 7 Jul 2024 15:10:37 -0700 Subject: [PATCH] refactor: make dag helpers easier to reason about --- lib/src/dag/default.nix | 14 +++++++------- tidepool/src/builders/basic.nix | 6 +++--- tidepool/src/packages/foundation/glibc/default.nix | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/src/dag/default.nix b/lib/src/dag/default.nix index 493ef20..87f2275 100644 --- a/lib/src/dag/default.nix +++ b/lib/src/dag/default.nix @@ -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 [ ]; }; }; } diff --git a/tidepool/src/builders/basic.nix b/tidepool/src/builders/basic.nix index 0e2cee1..ed76bda 100644 --- a/tidepool/src/builders/basic.nix +++ b/tidepool/src/builders/basic.nix @@ -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" ] ""; }; diff --git a/tidepool/src/packages/foundation/glibc/default.nix b/tidepool/src/packages/foundation/glibc/default.nix index 3a55dc0..8e8de03 100644 --- a/tidepool/src/packages/foundation/glibc/default.nix +++ b/tidepool/src/packages/foundation/glibc/default.nix @@ -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 '';