1
1
mirror of https://github.com/nmattia/snack.git synced 2024-09-21 00:29:37 +03:00

reduce re-computation

Nix is not smart enough to promote calculated thunks to constants
between function invocations
This commit is contained in:
zimbatm 2018-04-08 12:43:42 +01:00
parent 13c120327c
commit 153673db9e

View File

@ -13,14 +13,14 @@ let
# that file only)
singleOut = base: file:
let
basePrefix = (builtins.toString base) + "/";
pred = file: path: type:
let
topLevel = (builtins.toString base) + "/";
actual = (pkgs.lib.strings.removePrefix topLevel path);
actual = (pkgs.lib.strings.removePrefix basePrefix path);
expected = file;
in
(expected == actual) ||
(type == "directory" && (pkgs.lib.strings.hasPrefix actual expected));
in
(expected == actual) ||
(type == "directory" && (pkgs.lib.strings.hasPrefix actual expected));
mod = fileToModule file;
# TODO: even though we're doing a lot of cleaning, there's sitll some
# 'does-file-exist' happening