diff options
Diffstat (limited to 'Biz/Bild/Builder.nix')
-rw-r--r-- | Biz/Bild/Builder.nix | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/Biz/Bild/Builder.nix b/Biz/Bild/Builder.nix index a5a31c7..342569b 100644 --- a/Biz/Bild/Builder.nix +++ b/Biz/Bild/Builder.nix @@ -22,9 +22,9 @@ let skip = ["_" ".direnv"]; filter = file: type: if lib.lists.elem (builtins.baseNameOf file) skip then false - # TODO: this means any new directory will cause a rebuild. this bad. i + # TODO: this means any new directory will cause a rebuild. this bad. i # should recurse into the directory and match against the srcs. for now I - # just use postUnpack to delete empty dirs + # just use preBuild to delete empty dirs else if type == "directory" then true else if type == "regular" then lib.trivial.pipe file [ (f: lib.strings.removePrefix "${root}/" f) @@ -32,8 +32,8 @@ let ] else false; - # clean up empty dirs - #postUnpack = "find $src -type d -empty -delete"; + # remove empty directories, leftover from the src filter + preBuild = "find . -type d -empty -delete"; src = lib.sources.cleanSourceWith {inherit filter; src = lib.sources.cleanSource root;}; @@ -41,26 +41,28 @@ let if isEmpty target.langdeps then [] else - lib.attrsets.attrVals + lib.attrsets.attrVals target.langdeps (lib.attrsets.getAttrFromPath (lib.strings.splitString "." target.packageSet) bild); + sysdeps_ = if isEmpty target.sysdeps then [] else lib.attrsets.attrVals target.sysdeps pkgs; + BIZ_ROOT = "."; builders = { base = stdenv.mkDerivation rec { - inherit name src BIZ_ROOT; + inherit name src BIZ_ROOT preBuild; buildInputs = langdeps_ ++ sysdeps_; installPhase = "install -D ${name} $out/bin/${name}"; buildPhase = compileLine; }; haskell = stdenv.mkDerivation rec { - inherit name src BIZ_ROOT; + inherit name src BIZ_ROOT preBuild; buildInputs = sysdeps_ ++ [ (bild.haskell.ghcWith (p: (lib.attrsets.attrVals target.langdeps p) @@ -71,7 +73,7 @@ let }; c = stdenv.mkDerivation rec { - inherit name src BIZ_ROOT; + inherit name src BIZ_ROOT preBuild; buildInputs = langdeps_ ++ sysdeps_; installPhase = "install -D ${name} $out/bin/${name}"; buildPhase = lib.strings.concatStringsSep " " [ @@ -98,7 +100,9 @@ let check python -m ${mainModule} test ''; preBuild = '' - # initialize possibly-empty subdirectories as python modules + # remove empty directories, leftover from the src filter + find . -type d -empty -delete + # initialize remaining dirs as python modules find . -type d -exec touch {}/__init__.py \; # generate a minimal setup.py cat > setup.py << EOF @@ -120,7 +124,7 @@ let }; }; in builders.${target.builder}; -# the caller gives us the Analysis type, which is a hashmap, but i need to +# the bild caller gives us the Analysis type, which is a hashmap, but i need to # return a single drv, so just take the first one for now. ideally i would only # pass Target, one at a time, (perhaps parallelized in haskell land) and then i # wouldn't need all of this let nesting |