diff options
author | Ben Sima <ben@bsima.me> | 2021-01-08 23:05:24 -0500 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2021-01-08 23:06:47 -0500 |
commit | ebefbd5ef277ac090021fd56f1eb6e75ed6e1f7c (patch) | |
tree | ea2bcbef2181233b593dd5e5cd80f0101c06a5f5 /Biz | |
parent | 3df9ae26ee786f4af6ba6d18bfa760fa9aac1e77 (diff) |
Refactor nix a bit
Using lib.pipe for readability. Moved analyze into the public functions so I can
debug things easier by calling bild.analyze from the nix repl.
Diffstat (limited to 'Biz')
-rw-r--r-- | Biz/Bild/Rules.nix | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/Biz/Bild/Rules.nix b/Biz/Bild/Rules.nix index 51fcb14..17461ef 100644 --- a/Biz/Bild/Rules.nix +++ b/Biz/Bild/Rules.nix @@ -25,6 +25,10 @@ let haskellDeps = hpkgs: import ./Deps/Haskell.nix hpkgs; + mkGhcPackageSet = pkgs.haskell.packages.${ghcCompiler}.ghcWithHoogle; + mkGhcjsPackageSet = pkgs.haskell.packages.${ghcjsCompiler}.ghcWithPackages; + +in rec { # gather data needed for compiling by analyzing the main module analyze = main: rec { # path to the module relative to the git root @@ -35,23 +39,29 @@ let # file contents content = builtins.readFile main; # search for the ': out' declaration - out = builtins.head (lib.lists.flatten (removeNull - (map (builtins.match "^-- : out ([[:alnum:]._-]*)$") - (lines content)))); + out = lib.pipe content [ + lines + (map (builtins.match "^-- : out ([[:alnum:]._-]*)$")) + removeNull + lib.lists.flatten + builtins.head + ]; # collect all of the ': dep' declarations - deps = lib.lists.flatten (removeNull - (map (builtins.match "^-- : dep ([[:alnum:]._-]*)$") - (lines content))); - - sysdeps = lib.lists.flatten (removeNull - (map (builtins.match "^-- : sys ([[:alnum:]._-]*)$") - (lines content))); + deps = lib.pipe content [ + lines + (map (builtins.match "^-- : dep ([[:alnum:]._-]*)$")) + removeNull + lib.lists.flatten + ]; + # collect ': sys' declarations + sysdeps = lib.pipe content [ + lines + (map (builtins.match "^-- : sys ([[:alnum:]._-]*)$")) + removeNull + lib.lists.flatten + ]; }; - mkGhcPackageSet = pkgs.haskell.packages.${ghcCompiler}.ghcWithHoogle; - mkGhcjsPackageSet = pkgs.haskell.packages.${ghcjsCompiler}.ghcWithPackages; - -in rec { ghcPackageSetFull = mkGhcPackageSet haskellDeps; ghc = main: |