From 9eac46cfeddc65938b3cc946629a9c3d93ac35ee Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Tue, 22 Aug 2023 10:53:12 -0400 Subject: Add a commit-msg hook lint and various other cleanups Turns out that gitlint by default enforces the exact commit-msg format that I like to use. I'm enabling this because even I write poor commit messages sometimes, and looking back on my commits from even a few days ago is sometimes not very helpful. I also made some minor comment and nix changes that I noticed while reviewing my work from the last few days. --- Biz/Bild/Builder.nix | 24 ++++++++++++++---------- Biz/Bild/Example.py | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) (limited to 'Biz/Bild') 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 diff --git a/Biz/Bild/Example.py b/Biz/Bild/Example.py index 25686fa..5d165d8 100644 --- a/Biz/Bild/Example.py +++ b/Biz/Bild/Example.py @@ -1,6 +1,6 @@ """ Example Python file that also serves as a test case for bild. -fernet.""" +""" # : out example # : dep cryptography import sys -- cgit v1.2.3