generated from srid/ema-template
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(nix): isolate closure* to its own file
- Loading branch information
Showing
4 changed files
with
60 additions
and
40 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
imports = [ | ||
./small-closure.nix | ||
]; | ||
} |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# To make sure that Emanote's closure size is small. | ||
{ root, inputs, ... }: | ||
let | ||
allowedSystems = [ "x86_64-linux" "aarch64-darwin" ]; | ||
in | ||
{ | ||
perSystem = { pkgs, lib, config, system, ... }: lib.mkIf (lib.elem system allowedSystems) { | ||
haskellProjects.default = { | ||
settings = { | ||
emanote = { name, pkgs, self, super, ... }: { | ||
separateBinOutput = false; # removeReferencesTo.nix doesn't work otherwise | ||
justStaticExecutables = true; | ||
removeReferencesTo = [ | ||
self.ghc | ||
self.pandoc | ||
self.pandoc-types | ||
self.warp | ||
]; | ||
}; | ||
}; | ||
}; | ||
|
||
apps.check-closure-size = rec { | ||
inherit (program) meta; | ||
program = pkgs.writeShellApplication { | ||
name = "emanote-check-closure-size"; | ||
runtimeInputs = [ pkgs.jq pkgs.bc pkgs.nix ]; | ||
meta.description = "Check that emanote's nix closure size remains reasonably small"; | ||
text = '' | ||
MAX_CLOSURE_SIZE=$(echo "600 * 1000000" | bc) | ||
CLOSURE_SIZE=$(nix path-info --json -S .#default | jq 'first(.[])'.closureSize) | ||
echo "Emanote closure size: $CLOSURE_SIZE" | ||
echo " Max closure size: $MAX_CLOSURE_SIZE" | ||
if [ "$CLOSURE_SIZE" -gt "$MAX_CLOSURE_SIZE" ]; then | ||
echo "ERROR: Emanote's nix closure size has increased" | ||
exit 3 | ||
else | ||
echo "OK: Emanote's nix closure size is within limits" | ||
fi | ||
''; | ||
}; | ||
}; | ||
}; | ||
|
||
flake.om.ci.default.emanote = { | ||
dir = "."; | ||
steps.custom = { | ||
closure-size = { | ||
type = "app"; | ||
name = "check-closure-size"; | ||
systems = allowedSystems; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains 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 characters
This file contains 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 characters