Last active
January 8, 2018 12:57
-
-
Save taktoa/894ff2ba18bdde7142177f2c3ddcbaea to your computer and use it in GitHub Desktop.
Revisions
-
Remy Goldschmidt revised this gist
Jun 3, 2017 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -124,9 +124,9 @@ rec { inherit leaf; }); ninjaJSON = fromJSON (readFile ./ninja.json); exampleNinjaData = ninjaJSON // { src = toPath "${exampleSrc}/src"; }; exampleNinja = dynamize exampleNinjaData; File renamed without changes. -
Remy Goldschmidt revised this gist
Jun 3, 2017 . 2 changed files with 335 additions and 228 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,333 @@ { "defaults": [ "all" ], "graph": { "Data/Profunctor.hi": { "dependencies": [ "Data/Profunctor.o" ], "type": "phony" }, "Data/Profunctor.hs": { "path": "Data/Profunctor.hs", "type": "leaf" }, "Data/Profunctor.o": { "command": "/bin/sh -c \"ghc -c Data/Profunctor.hs\"", "dependencies": [ "Data/Profunctor.hs", "Data/Profunctor/Closed.hi", "Data/Profunctor/Strong.hi", "Data/Profunctor/Types.hi", "Data/Profunctor/Choice.hi", "Data/Profunctor/Mapping.hi" ], "type": "build" }, "Data/Profunctor/Adjunction.hi": { "dependencies": [ "Data/Profunctor/Adjunction.o" ], "type": "phony" }, "Data/Profunctor/Adjunction.hs": { "path": "Data/Profunctor/Adjunction.hs", "type": "leaf" }, "Data/Profunctor/Adjunction.o": { "command": "/bin/sh -c \"ghc -c Data/Profunctor/Adjunction.hs\"", "dependencies": [ "Data/Profunctor/Adjunction.hs", "Data/Profunctor/Monad.hi", "Data/Profunctor/Types.hi" ], "type": "build" }, "Data/Profunctor/Cayley.hi": { "dependencies": [ "Data/Profunctor/Cayley.o" ], "type": "phony" }, "Data/Profunctor/Cayley.hs": { "path": "Data/Profunctor/Cayley.hs", "type": "leaf" }, "Data/Profunctor/Cayley.o": { "command": "/bin/sh -c \"ghc -c Data/Profunctor/Cayley.hs\"", "dependencies": [ "Data/Profunctor/Cayley.hs", "Data/Profunctor/Unsafe.hi", "Data/Profunctor/Monad.hi", "Data/Profunctor.hi" ], "type": "build" }, "Data/Profunctor/Choice.hi": { "dependencies": [ "Data/Profunctor/Choice.o" ], "type": "phony" }, "Data/Profunctor/Choice.hs": { "path": "Data/Profunctor/Choice.hs", "type": "leaf" }, "Data/Profunctor/Choice.o": { "command": "/bin/sh -c \"ghc -c Data/Profunctor/Choice.hs\"", "dependencies": [ "Data/Profunctor/Choice.hs", "Data/Profunctor/Monad.hi", "Data/Profunctor/Unsafe.hi", "Data/Profunctor/Strong.hi", "Data/Profunctor/Types.hi", "Data/Profunctor/Adjunction.hi" ], "type": "build" }, "Data/Profunctor/Closed.hi": { "dependencies": [ "Data/Profunctor/Closed.o" ], "type": "phony" }, "Data/Profunctor/Closed.hs": { "path": "Data/Profunctor/Closed.hs", "type": "leaf" }, "Data/Profunctor/Closed.o": { "command": "/bin/sh -c \"ghc -c Data/Profunctor/Closed.hs\"", "dependencies": [ "Data/Profunctor/Closed.hs", "Data/Profunctor/Monad.hi", "Data/Profunctor/Unsafe.hi", "Data/Profunctor/Strong.hi", "Data/Profunctor/Types.hi", "Data/Profunctor/Adjunction.hi" ], "type": "build" }, "Data/Profunctor/Composition.hi": { "dependencies": [ "Data/Profunctor/Composition.o" ], "type": "phony" }, "Data/Profunctor/Composition.hs": { "path": "Data/Profunctor/Composition.hs", "type": "leaf" }, "Data/Profunctor/Composition.o": { "command": "/bin/sh -c \"ghc -c Data/Profunctor/Composition.hs\"", "dependencies": [ "Data/Profunctor/Composition.hs", "Data/Profunctor/Unsafe.hi", "Data/Profunctor/Sieve.hi", "Data/Profunctor/Rep.hi", "Data/Profunctor/Monad.hi", "Data/Profunctor/Adjunction.hi", "Data/Profunctor.hi" ], "type": "build" }, "Data/Profunctor/Mapping.hi": { "dependencies": [ "Data/Profunctor/Mapping.o" ], "type": "phony" }, "Data/Profunctor/Mapping.hs": { "path": "Data/Profunctor/Mapping.hs", "type": "leaf" }, "Data/Profunctor/Mapping.o": { "command": "/bin/sh -c \"ghc -c Data/Profunctor/Mapping.hs\"", "dependencies": [ "Data/Profunctor/Mapping.hs", "Data/Profunctor/Monad.hi", "Data/Profunctor/Unsafe.hi", "Data/Profunctor/Closed.hi", "Data/Profunctor/Strong.hi", "Data/Profunctor/Types.hi", "Data/Profunctor/Traversing.hi", "Data/Profunctor/Choice.hi" ], "type": "build" }, "Data/Profunctor/Monad.hi": { "dependencies": [ "Data/Profunctor/Monad.o" ], "type": "phony" }, "Data/Profunctor/Monad.hs": { "path": "Data/Profunctor/Monad.hs", "type": "leaf" }, "Data/Profunctor/Monad.o": { "command": "/bin/sh -c \"ghc -c Data/Profunctor/Monad.hs\"", "dependencies": [ "Data/Profunctor/Monad.hs", "Data/Profunctor/Types.hi" ], "type": "build" }, "Data/Profunctor/Ran.hi": { "dependencies": [ "Data/Profunctor/Ran.o" ], "type": "phony" }, "Data/Profunctor/Ran.hs": { "path": "Data/Profunctor/Ran.hs", "type": "leaf" }, "Data/Profunctor/Ran.o": { "command": "/bin/sh -c \"ghc -c Data/Profunctor/Ran.hs\"", "dependencies": [ "Data/Profunctor/Ran.hs", "Data/Profunctor/Unsafe.hi", "Data/Profunctor/Monad.hi", "Data/Profunctor/Composition.hi", "Data/Profunctor.hi" ], "type": "build" }, "Data/Profunctor/Rep.hi": { "dependencies": [ "Data/Profunctor/Rep.o" ], "type": "phony" }, "Data/Profunctor/Rep.hs": { "path": "Data/Profunctor/Rep.hs", "type": "leaf" }, "Data/Profunctor/Rep.o": { "command": "/bin/sh -c \"ghc -c Data/Profunctor/Rep.hs\"", "dependencies": [ "Data/Profunctor/Rep.hs", "Data/Profunctor/Sieve.hi", "Data/Profunctor.hi" ], "type": "build" }, "Data/Profunctor/Sieve.hi": { "dependencies": [ "Data/Profunctor/Sieve.o" ], "type": "phony" }, "Data/Profunctor/Sieve.hs": { "path": "Data/Profunctor/Sieve.hs", "type": "leaf" }, "Data/Profunctor/Sieve.o": { "command": "/bin/sh -c \"ghc -c Data/Profunctor/Sieve.hs\"", "dependencies": [ "Data/Profunctor/Sieve.hs", "Data/Profunctor.hi" ], "type": "build" }, "Data/Profunctor/Strong.hi": { "dependencies": [ "Data/Profunctor/Strong.o" ], "type": "phony" }, "Data/Profunctor/Strong.hs": { "path": "Data/Profunctor/Strong.hs", "type": "leaf" }, "Data/Profunctor/Strong.o": { "command": "/bin/sh -c \"ghc -c Data/Profunctor/Strong.hs\"", "dependencies": [ "Data/Profunctor/Strong.hs", "Data/Profunctor/Monad.hi", "Data/Profunctor/Unsafe.hi", "Data/Profunctor/Types.hi", "Data/Profunctor/Adjunction.hi" ], "type": "build" }, "Data/Profunctor/Traversing.hi": { "dependencies": [ "Data/Profunctor/Traversing.o" ], "type": "phony" }, "Data/Profunctor/Traversing.hs": { "path": "Data/Profunctor/Traversing.hs", "type": "leaf" }, "Data/Profunctor/Traversing.o": { "command": "/bin/sh -c \"ghc -c Data/Profunctor/Traversing.hs\"", "dependencies": [ "Data/Profunctor/Traversing.hs", "Data/Profunctor/Monad.hi", "Data/Profunctor/Unsafe.hi", "Data/Profunctor/Strong.hi", "Data/Profunctor/Types.hi", "Data/Profunctor/Choice.hi" ], "type": "build" }, "Data/Profunctor/Types.hi": { "dependencies": [ "Data/Profunctor/Types.o" ], "type": "phony" }, "Data/Profunctor/Types.hs": { "path": "Data/Profunctor/Types.hs", "type": "leaf" }, "Data/Profunctor/Types.o": { "command": "/bin/sh -c \"ghc -c Data/Profunctor/Types.hs\"", "dependencies": [ "Data/Profunctor/Types.hs", "Data/Profunctor/Unsafe.hi" ], "type": "build" }, "Data/Profunctor/Unsafe.hi": { "dependencies": [ "Data/Profunctor/Unsafe.o" ], "type": "phony" }, "Data/Profunctor/Unsafe.hs": { "path": "Data/Profunctor/Unsafe.hs", "type": "leaf" }, "Data/Profunctor/Unsafe.o": { "command": "/bin/sh -c \"ghc -c Data/Profunctor/Unsafe.hs\"", "dependencies": [ "Data/Profunctor/Unsafe.hs" ], "type": "build" }, "all": { "dependencies": [ "Data/Profunctor.o", "Data/Profunctor/Adjunction.o", "Data/Profunctor/Cayley.o", "Data/Profunctor/Choice.o", "Data/Profunctor/Closed.o", "Data/Profunctor/Composition.o", "Data/Profunctor/Mapping.o", "Data/Profunctor/Monad.o", "Data/Profunctor/Ran.o", "Data/Profunctor/Rep.o", "Data/Profunctor/Sieve.o", "Data/Profunctor/Strong.o", "Data/Profunctor/Traversing.o", "Data/Profunctor/Types.o", "Data/Profunctor/Unsafe.o" ], "type": "phony" } } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -124,235 +124,9 @@ rec { inherit leaf; }); buildJSON = fromJSON (readFile ./build.json); exampleNinjaData = buildJSON // { src = toPath "${exampleSrc}/src"; }; exampleNinja = dynamize exampleNinjaData; -
Remy Goldschmidt revised this gist
Jun 3, 2017 . 1 changed file with 110 additions and 73 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -89,6 +89,28 @@ rec { ''); }; exampleSrc = extractSrc pkgs.haskellPackages.profunctors { patches = []; #patches = [ ./example.patch ]; }; dynamize = data: { build, phony, leaf }: self: ( with rec { convertBuild = node: build self { inherit (node) command dependencies; }; convertPhony = node: phony self node.dependencies; convertLeaf = node: leaf self node.path; convertNode = node: ( if node.type == "build" then convertBuild node else if node.type == "phony" then convertPhony node else if node.type == "leaf" then convertLeaf node else abort ("invalid node type in build graph: " + node.type)); }; { inherit (data) src defaults; graph = pkgs.lib.attrsets.mapAttrs (key: val: convertNode val) data.graph; }); resolver = cb: { build, phony, leaf }: ( cb { build = self: { command, dependencies }: (build self { @@ -102,66 +124,65 @@ rec { inherit leaf; }); exampleNinjaData = { src = toPath "${exampleSrc}/src"; defaults = ["all"]; graph = { "all" = { type = "phony"; dependencies = [ "Data/Profunctor.o" "Data/Profunctor/Adjunction.o" "Data/Profunctor/Cayley.o" "Data/Profunctor/Choice.o" "Data/Profunctor/Closed.o" "Data/Profunctor/Composition.o" "Data/Profunctor/Mapping.o" "Data/Profunctor/Monad.o" "Data/Profunctor/Ran.o" "Data/Profunctor/Rep.o" "Data/Profunctor/Sieve.o" "Data/Profunctor/Strong.o" "Data/Profunctor/Traversing.o" "Data/Profunctor/Types.o" "Data/Profunctor/Unsafe.o" ]; }; "Data/Profunctor.hi" = { type = "phony"; dependencies = [ "Data/Profunctor.o" ]; }; "Data/Profunctor/Adjunction.hi" = { type = "phony"; dependencies = [ "Data/Profunctor/Adjunction.o" ]; }; "Data/Profunctor/Cayley.hi" = { type = "phony"; dependencies = [ "Data/Profunctor/Cayley.o" ]; }; "Data/Profunctor/Choice.hi" = { type = "phony"; dependencies = [ "Data/Profunctor/Choice.o" ]; }; "Data/Profunctor/Closed.hi" = { type = "phony"; dependencies = [ "Data/Profunctor/Closed.o" ]; }; "Data/Profunctor/Composition.hi" = { type = "phony"; dependencies = [ "Data/Profunctor/Composition.o" ]; }; "Data/Profunctor/Mapping.hi" = { type = "phony"; dependencies = [ "Data/Profunctor/Mapping.o" ]; }; "Data/Profunctor/Monad.hi" = { type = "phony"; dependencies = [ "Data/Profunctor/Monad.o" ]; }; "Data/Profunctor/Ran.hi" = { type = "phony"; dependencies = [ "Data/Profunctor/Ran.o" ]; }; "Data/Profunctor/Rep.hi" = { type = "phony"; dependencies = [ "Data/Profunctor/Rep.o" ]; }; "Data/Profunctor/Sieve.hi" = { type = "phony"; dependencies = [ "Data/Profunctor/Sieve.o" ]; }; "Data/Profunctor/Strong.hi" = { type = "phony"; dependencies = [ "Data/Profunctor/Strong.o" ]; }; "Data/Profunctor/Traversing.hi" = { type = "phony"; dependencies = [ "Data/Profunctor/Traversing.o" ]; }; "Data/Profunctor/Types.hi" = { type = "phony"; dependencies = [ "Data/Profunctor/Types.o" ]; }; "Data/Profunctor/Unsafe.hi" = { type = "phony"; dependencies = [ "Data/Profunctor/Unsafe.o" ]; }; "Data/Profunctor.hs" = { type = "leaf"; path = "Data/Profunctor.hs"; }; "Data/Profunctor/Adjunction.hs" = { type = "leaf"; path = "Data/Profunctor/Adjunction.hs"; }; "Data/Profunctor/Cayley.hs" = { type = "leaf"; path = "Data/Profunctor/Cayley.hs"; }; "Data/Profunctor/Choice.hs" = { type = "leaf"; path = "Data/Profunctor/Choice.hs"; }; "Data/Profunctor/Closed.hs" = { type = "leaf"; path = "Data/Profunctor/Closed.hs"; }; "Data/Profunctor/Composition.hs" = { type = "leaf"; path = "Data/Profunctor/Composition.hs"; }; "Data/Profunctor/Mapping.hs" = { type = "leaf"; path = "Data/Profunctor/Mapping.hs"; }; "Data/Profunctor/Monad.hs" = { type = "leaf"; path = "Data/Profunctor/Monad.hs"; }; "Data/Profunctor/Ran.hs" = { type = "leaf"; path = "Data/Profunctor/Ran.hs"; }; "Data/Profunctor/Rep.hs" = { type = "leaf"; path = "Data/Profunctor/Rep.hs"; }; "Data/Profunctor/Sieve.hs" = { type = "leaf"; path = "Data/Profunctor/Sieve.hs"; }; "Data/Profunctor/Strong.hs" = { type = "leaf"; path = "Data/Profunctor/Strong.hs"; }; "Data/Profunctor/Traversing.hs" = { type = "leaf"; path = "Data/Profunctor/Traversing.hs"; }; "Data/Profunctor/Types.hs" = { type = "leaf"; path = "Data/Profunctor/Types.hs"; }; "Data/Profunctor/Unsafe.hs" = { type = "leaf"; path = "Data/Profunctor/Unsafe.hs"; }; "Data/Profunctor/Traversing.o" = { type = "build"; command = "/bin/sh -c \"ghc -c Data/Profunctor/Traversing.hs\""; dependencies = [ "Data/Profunctor/Traversing.hs" @@ -173,7 +194,8 @@ rec { ]; }; "Data/Profunctor/Mapping.o" = { type = "build"; command = "/bin/sh -c \"ghc -c Data/Profunctor/Mapping.hs\""; dependencies = [ "Data/Profunctor/Mapping.hs" @@ -187,7 +209,8 @@ rec { ]; }; "Data/Profunctor/Strong.o" = { type = "build"; command = "/bin/sh -c \"ghc -c Data/Profunctor/Strong.hs\""; dependencies = [ "Data/Profunctor/Strong.hs" @@ -198,7 +221,8 @@ rec { ]; }; "Data/Profunctor/Adjunction.o" = { type = "build"; command = "/bin/sh -c \"ghc -c Data/Profunctor/Adjunction.hs\""; dependencies = [ "Data/Profunctor/Adjunction.hs" @@ -207,23 +231,26 @@ rec { ]; }; "Data/Profunctor/Types.o" = { type = "build"; command = "/bin/sh -c \"ghc -c Data/Profunctor/Types.hs\""; dependencies = [ "Data/Profunctor/Types.hs" "Data/Profunctor/Unsafe.hi" ]; }; "Data/Profunctor/Monad.o" = { type = "build"; command = "/bin/sh -c \"ghc -c Data/Profunctor/Monad.hs\""; dependencies = [ "Data/Profunctor/Monad.hs" "Data/Profunctor/Types.hi" ]; }; "Data/Profunctor/Choice.o" = { type = "build"; command = "/bin/sh -c \"ghc -c Data/Profunctor/Choice.hs\""; dependencies = [ "Data/Profunctor/Choice.hs" @@ -235,14 +262,16 @@ rec { ]; }; "Data/Profunctor/Unsafe.o" = { type = "build"; command = "/bin/sh -c \"ghc -c Data/Profunctor/Unsafe.hs\""; dependencies = [ "Data/Profunctor/Unsafe.hs" ]; }; "Data/Profunctor/Closed.o" = { type = "build"; command = "/bin/sh -c \"ghc -c Data/Profunctor/Closed.hs\""; dependencies = [ "Data/Profunctor/Closed.hs" @@ -254,7 +283,8 @@ rec { ]; }; "Data/Profunctor/Cayley.o" = { type = "build"; command = "/bin/sh -c \"ghc -c Data/Profunctor/Cayley.hs\""; dependencies = [ "Data/Profunctor/Cayley.hs" @@ -264,7 +294,8 @@ rec { ]; }; "Data/Profunctor/Composition.o" = { type = "build"; command = "/bin/sh -c \"ghc -c Data/Profunctor/Composition.hs\""; dependencies = [ "Data/Profunctor/Composition.hs" @@ -277,15 +308,17 @@ rec { ]; }; "Data/Profunctor/Sieve.o" = { type = "build"; command = "/bin/sh -c \"ghc -c Data/Profunctor/Sieve.hs\""; dependencies = [ "Data/Profunctor/Sieve.hs" "Data/Profunctor.hi" ]; }; "Data/Profunctor/Rep.o" = { type = "build"; command = "/bin/sh -c \"ghc -c Data/Profunctor/Rep.hs\""; dependencies = [ "Data/Profunctor/Rep.hs" @@ -294,7 +327,8 @@ rec { ]; }; "Data/Profunctor/Ran.o" = { type = "build"; command = "/bin/sh -c \"ghc -c Data/Profunctor/Ran.hs\""; dependencies = [ "Data/Profunctor/Ran.hs" @@ -305,7 +339,8 @@ rec { ]; }; "Data/Profunctor.o" = { type = "build"; command = "/bin/sh -c \"ghc -c Data/Profunctor.hs\""; dependencies = [ "Data/Profunctor.hs" @@ -319,6 +354,8 @@ rec { }; }; exampleNinja = dynamize exampleNinjaData; combineDefault = ({ defaults, graph, ... }: pkgs.buildEnv { name = "default"; @@ -328,4 +365,4 @@ rec { buildNinja = ninja: cbs: combineDefault (pkgs.lib.fix (resolver ninja cbs)); test = buildNinja exampleNinja (testCBs testInputs); } -
taktoa revised this gist
Jun 2, 2017 . 1 changed file with 17 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,10 +10,11 @@ rec { testInputs = [ testGHC pkgs.findutils pkgs.parallel ]; extractSrc = drv: { patches ? [] }: pkgs.stdenv.mkDerivation { name = "${drv.name}-src"; src = drv.src; phases = [ "unpackPhase" "patchPhase" "installPhase" ]; inherit patches; installPhase = '' mkdir -p $out/ cp -Rv ./* $out/ @@ -77,9 +78,14 @@ rec { }; leaf = self: path: ( with rec { file = readFile (toPath "${self.src}/${path}"); drv = toFile "interned-leaf" file; }; pkgs.runCommand "intermediate-leaf" {} '' mkdir -p "$out/$(dirname ${path})" cp -v "${drv}" "$out/$(dirname ${path})/$(basename ${path})" ''); }; @@ -96,8 +102,13 @@ rec { inherit leaf; }); exampleSrc = extractSrc pkgs.haskellPackages.profunctors { patches = []; #patches = [ ./example.patch ]; }; exampleNinja = { build, phony, leaf }: self: { src = toPath "${exampleSrc}/src"; defaults = ["Data/Profunctor.o"]; graph = { "all" = phony self [ @@ -317,4 +328,4 @@ rec { buildNinja = ninja: cbs: combineDefault (pkgs.lib.fix (resolver ninja cbs)); test = buildNinja exampleNinja (testCBs testInputs); } -
taktoa renamed this gist
Jun 1, 2017 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,6 @@ with builtins; rec { pkgs = import <nixpkgs> {}; testGHC = pkgs.haskellPackages.ghcWithPackages (p: with p; [ base base-orphans bifunctors comonad contravariant distributive -
taktoa created this gist
Jun 1, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,321 @@ with builtins; rec { pkgs = import <nixpkgs> {}; buildJSON = fromJSON (readFile ./build.json); testGHC = pkgs.haskellPackages.ghcWithPackages (p: with p; [ base base-orphans bifunctors comonad contravariant distributive tagged transformers ]); testInputs = [ testGHC pkgs.findutils pkgs.parallel ]; extractSrc = drv: pkgs.stdenv.mkDerivation { name = "${drv.name}-src"; src = drv.src; phases = [ "unpackPhase" "installPhase" ]; installPhase = '' mkdir -p $out/ cp -Rv ./* $out/ ''; }; testCBs = inputs: { build = self: { command, dependencies }: ( pkgs.stdenv.mkDerivation { name = "intermediate-build"; src = pkgs.buildEnv { name = "intermediate-build-env"; paths = dependencies; }; inherit command; buildInputs = inputs; phases = ["unpackPhase" "buildPhase" "installPhase"]; unpackPhase = '' cp -Lsrv "$src" . cd "$(basename "$src")" chmod -Rv u+w . ''; buildPhase = '' eval "$command" ''; installPhase = '' mkdir -p "$out" function helper () { FILE="$1" if test -e "$FILE"; then echo "helper: processing $FILE" if test -d "$FILE"; then echo "helper: $FILE is a directory, so we should make it" mkdir -pv "$out/$FILE" elif test -h "$FILE"; then echo "helper: $FILE is symlink, so we should symlink the original" cp -sv "$(readlink -f "$FILE")" "$out/$(dirname "$FILE")" else echo "helper: $FILE is a regular file, so we should copy it" cp -v "$FILE" "$out/$(dirname "$FILE")" fi else echo "helper: error: $FILE does not exist" fi } export -f helper find . | parallel "helper {}" ''; }); phony = self: dependencies: pkgs.buildEnv { name = "intermediate-phony"; paths = dependencies; }; leaf = self: path: ( pkgs.runCommand "intermediate-leaf" { input = "${self.src}/${path}"; } '' mkdir -p "$out/$(dirname ${path})" cp -v "${self.src}/${path}" "$out/$(dirname ${path})" ''); }; resolver = cb: { build, phony, leaf }: ( cb { build = self: { command, dependencies }: (build self { inherit command; dependencies = map (x: self.graph.${x}) dependencies; }); phony = self: dependencies: ( phony self (map (x: self.graph.${x}) dependencies)); inherit leaf; }); exampleNinja = { build, phony, leaf }: self: { src = toPath "${extractSrc pkgs.haskellPackages.profunctors}/src"; defaults = ["Data/Profunctor.o"]; graph = { "all" = phony self [ "Data/Profunctor.o" "Data/Profunctor/Adjunction.o" "Data/Profunctor/Cayley.o" "Data/Profunctor/Choice.o" "Data/Profunctor/Closed.o" "Data/Profunctor/Composition.o" "Data/Profunctor/Mapping.o" "Data/Profunctor/Monad.o" "Data/Profunctor/Ran.o" "Data/Profunctor/Rep.o" "Data/Profunctor/Sieve.o" "Data/Profunctor/Strong.o" "Data/Profunctor/Traversing.o" "Data/Profunctor/Types.o" "Data/Profunctor/Unsafe.o" ]; "Data/Profunctor.hi" = phony self [ "Data/Profunctor.o" ]; "Data/Profunctor/Adjunction.hi" = phony self [ "Data/Profunctor/Adjunction.o" ]; "Data/Profunctor/Cayley.hi" = phony self [ "Data/Profunctor/Cayley.o" ]; "Data/Profunctor/Choice.hi" = phony self [ "Data/Profunctor/Choice.o" ]; "Data/Profunctor/Closed.hi" = phony self [ "Data/Profunctor/Closed.o" ]; "Data/Profunctor/Composition.hi" = phony self [ "Data/Profunctor/Composition.o" ]; "Data/Profunctor/Mapping.hi" = phony self [ "Data/Profunctor/Mapping.o" ]; "Data/Profunctor/Monad.hi" = phony self [ "Data/Profunctor/Monad.o" ]; "Data/Profunctor/Ran.hi" = phony self [ "Data/Profunctor/Ran.o" ]; "Data/Profunctor/Rep.hi" = phony self [ "Data/Profunctor/Rep.o" ]; "Data/Profunctor/Sieve.hi" = phony self [ "Data/Profunctor/Sieve.o" ]; "Data/Profunctor/Strong.hi" = phony self [ "Data/Profunctor/Strong.o" ]; "Data/Profunctor/Traversing.hi" = phony self [ "Data/Profunctor/Traversing.o" ]; "Data/Profunctor/Types.hi" = phony self [ "Data/Profunctor/Types.o" ]; "Data/Profunctor/Unsafe.hi" = phony self [ "Data/Profunctor/Unsafe.o" ]; "Data/Profunctor.hs" = leaf self "Data/Profunctor.hs"; "Data/Profunctor/Adjunction.hs" = leaf self "Data/Profunctor/Adjunction.hs"; "Data/Profunctor/Cayley.hs" = leaf self "Data/Profunctor/Cayley.hs"; "Data/Profunctor/Choice.hs" = leaf self "Data/Profunctor/Choice.hs"; "Data/Profunctor/Closed.hs" = leaf self "Data/Profunctor/Closed.hs"; "Data/Profunctor/Composition.hs" = leaf self "Data/Profunctor/Composition.hs"; "Data/Profunctor/Mapping.hs" = leaf self "Data/Profunctor/Mapping.hs"; "Data/Profunctor/Monad.hs" = leaf self "Data/Profunctor/Monad.hs"; "Data/Profunctor/Ran.hs" = leaf self "Data/Profunctor/Ran.hs"; "Data/Profunctor/Rep.hs" = leaf self "Data/Profunctor/Rep.hs"; "Data/Profunctor/Sieve.hs" = leaf self "Data/Profunctor/Sieve.hs"; "Data/Profunctor/Strong.hs" = leaf self "Data/Profunctor/Strong.hs"; "Data/Profunctor/Traversing.hs" = leaf self "Data/Profunctor/Traversing.hs"; "Data/Profunctor/Types.hs" = leaf self "Data/Profunctor/Types.hs"; "Data/Profunctor/Unsafe.hs" = leaf self "Data/Profunctor/Unsafe.hs"; "Data/Profunctor/Traversing.o" = build self { command = "/bin/sh -c \"ghc -c Data/Profunctor/Traversing.hs\""; dependencies = [ "Data/Profunctor/Traversing.hs" "Data/Profunctor/Monad.hi" "Data/Profunctor/Unsafe.hi" "Data/Profunctor/Strong.hi" "Data/Profunctor/Types.hi" "Data/Profunctor/Choice.hi" ]; }; "Data/Profunctor/Mapping.o" = build self { command = "/bin/sh -c \"ghc -c Data/Profunctor/Mapping.hs\""; dependencies = [ "Data/Profunctor/Mapping.hs" "Data/Profunctor/Monad.hi" "Data/Profunctor/Unsafe.hi" "Data/Profunctor/Closed.hi" "Data/Profunctor/Strong.hi" "Data/Profunctor/Types.hi" "Data/Profunctor/Traversing.hi" "Data/Profunctor/Choice.hi" ]; }; "Data/Profunctor/Strong.o" = build self { command = "/bin/sh -c \"ghc -c Data/Profunctor/Strong.hs\""; dependencies = [ "Data/Profunctor/Strong.hs" "Data/Profunctor/Monad.hi" "Data/Profunctor/Unsafe.hi" "Data/Profunctor/Types.hi" "Data/Profunctor/Adjunction.hi" ]; }; "Data/Profunctor/Adjunction.o" = build self { command = "/bin/sh -c \"ghc -c Data/Profunctor/Adjunction.hs\""; dependencies = [ "Data/Profunctor/Adjunction.hs" "Data/Profunctor/Monad.hi" "Data/Profunctor/Types.hi" ]; }; "Data/Profunctor/Types.o" = build self { command = "/bin/sh -c \"ghc -c Data/Profunctor/Types.hs\""; dependencies = [ "Data/Profunctor/Types.hs" "Data/Profunctor/Unsafe.hi" ]; }; "Data/Profunctor/Monad.o" = build self { command = "/bin/sh -c \"ghc -c Data/Profunctor/Monad.hs\""; dependencies = [ "Data/Profunctor/Monad.hs" "Data/Profunctor/Types.hi" ]; }; "Data/Profunctor/Choice.o" = build self { command = "/bin/sh -c \"ghc -c Data/Profunctor/Choice.hs\""; dependencies = [ "Data/Profunctor/Choice.hs" "Data/Profunctor/Monad.hi" "Data/Profunctor/Unsafe.hi" "Data/Profunctor/Strong.hi" "Data/Profunctor/Types.hi" "Data/Profunctor/Adjunction.hi" ]; }; "Data/Profunctor/Unsafe.o" = build self { command = "/bin/sh -c \"ghc -c Data/Profunctor/Unsafe.hs\""; dependencies = [ "Data/Profunctor/Unsafe.hs" ]; }; "Data/Profunctor/Closed.o" = build self { command = "/bin/sh -c \"ghc -c Data/Profunctor/Closed.hs\""; dependencies = [ "Data/Profunctor/Closed.hs" "Data/Profunctor/Monad.hi" "Data/Profunctor/Unsafe.hi" "Data/Profunctor/Strong.hi" "Data/Profunctor/Types.hi" "Data/Profunctor/Adjunction.hi" ]; }; "Data/Profunctor/Cayley.o" = build self { command = "/bin/sh -c \"ghc -c Data/Profunctor/Cayley.hs\""; dependencies = [ "Data/Profunctor/Cayley.hs" "Data/Profunctor/Unsafe.hi" "Data/Profunctor/Monad.hi" "Data/Profunctor.hi" ]; }; "Data/Profunctor/Composition.o" = build self { command = "/bin/sh -c \"ghc -c Data/Profunctor/Composition.hs\""; dependencies = [ "Data/Profunctor/Composition.hs" "Data/Profunctor/Unsafe.hi" "Data/Profunctor/Sieve.hi" "Data/Profunctor/Rep.hi" "Data/Profunctor/Monad.hi" "Data/Profunctor/Adjunction.hi" "Data/Profunctor.hi" ]; }; "Data/Profunctor/Sieve.o" = build self { command = "/bin/sh -c \"ghc -c Data/Profunctor/Sieve.hs\""; dependencies = [ "Data/Profunctor/Sieve.hs" "Data/Profunctor.hi" ]; }; "Data/Profunctor/Rep.o" = build self { command = "/bin/sh -c \"ghc -c Data/Profunctor/Rep.hs\""; dependencies = [ "Data/Profunctor/Rep.hs" "Data/Profunctor/Sieve.hi" "Data/Profunctor.hi" ]; }; "Data/Profunctor/Ran.o" = build self { command = "/bin/sh -c \"ghc -c Data/Profunctor/Ran.hs\""; dependencies = [ "Data/Profunctor/Ran.hs" "Data/Profunctor/Unsafe.hi" "Data/Profunctor/Monad.hi" "Data/Profunctor/Composition.hi" "Data/Profunctor.hi" ]; }; "Data/Profunctor.o" = build self { command = "/bin/sh -c \"ghc -c Data/Profunctor.hs\""; dependencies = [ "Data/Profunctor.hs" "Data/Profunctor/Closed.hi" "Data/Profunctor/Strong.hi" "Data/Profunctor/Types.hi" "Data/Profunctor/Choice.hi" "Data/Profunctor/Mapping.hi" ]; }; }; }; combineDefault = ({ defaults, graph, ... }: pkgs.buildEnv { name = "default"; paths = (map (x: graph.${x}) defaults); }); buildNinja = ninja: cbs: combineDefault (pkgs.lib.fix (resolver ninja cbs)); test = buildNinja exampleNinja (testCBs testInputs); }