From e89b461b01bdcd1b8bac761eb8756ce8f640ae3b Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Tue, 24 Dec 2024 09:02:51 -0500 Subject: [PATCH 1/4] nix: Update all inputs --- emanote/emanote.cabal | 2 +- flake.lock | 42 +++++++++++++++++++++--------------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/emanote/emanote.cabal b/emanote/emanote.cabal index 6f3b8cd9a..1eadb2aff 100644 --- a/emanote/emanote.cabal +++ b/emanote/emanote.cabal @@ -1,6 +1,6 @@ cabal-version: 2.4 name: emanote -version: 1.3.18.0 +version: 1.3.18.1 license: AGPL-3.0-only copyright: 2022 Sridhar Ratnakumar maintainer: srid@srid.ca diff --git a/flake.lock b/flake.lock index 5249b2947..7883ab119 100644 --- a/flake.lock +++ b/flake.lock @@ -51,11 +51,11 @@ "emanote-template": { "flake": false, "locked": { - "lastModified": 1711847690, - "narHash": "sha256-A/5b7vB1+FI2qsuPJL/pZ9CkWozSCbOoaqqN4y+Pmxc=", + "lastModified": 1731804312, + "narHash": "sha256-3rKT3H5UYbLtFm10ioIEO+7WEgTFT21vUry/0Oj9OWo=", "owner": "srid", "repo": "emanote-template", - "rev": "32330b5e3bdca89ca67f5c212be6db43dbb13cd8", + "rev": "5fa04e49ab6b47f8d9a53f754265d2277e94a5ae", "type": "github" }, "original": { @@ -71,11 +71,11 @@ ] }, "locked": { - "lastModified": 1727826117, - "narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=", + "lastModified": 1733312601, + "narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1", + "rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9", "type": "github" }, "original": { @@ -86,11 +86,11 @@ }, "flake-root": { "locked": { - "lastModified": 1692742795, - "narHash": "sha256-f+Y0YhVCIJ06LemO+3Xx00lIcqQxSKJHXT/yk1RTKxw=", + "lastModified": 1723604017, + "narHash": "sha256-rBtQ8gg+Dn4Sx/s+pvjdq3CB2wQNzx9XGFq/JVGCB6k=", "owner": "srid", "repo": "flake-root", - "rev": "d9a70d9c7a5fd7f3258ccf48da9335e9b47c3937", + "rev": "b759a56851e10cb13f6b8e5698af7b59c44be26e", "type": "github" }, "original": { @@ -101,11 +101,11 @@ }, "haskell-flake": { "locked": { - "lastModified": 1725314890, - "narHash": "sha256-jjVrhLOlPjQiZ/8pe+g6Xc5sa563WXnNZDwGXVl4PXQ=", + "lastModified": 1734984991, + "narHash": "sha256-oUYtRBD3Yhw2jvKYo0lfd82fgEQQbFoiJcHO923gmOc=", "owner": "srid", "repo": "haskell-flake", - "rev": "ed94388c2e622f28cb45108a4e73c9d2b2a796da", + "rev": "daf00052906bdd977e57a07f7048437214232e87", "type": "github" }, "original": { @@ -132,11 +132,11 @@ }, "nixos-unified": { "locked": { - "lastModified": 1729549045, - "narHash": "sha256-W0VyC1MueUy6zMzcKZ9Ofnz/03da+SPFCYdbQ3MugfM=", + "lastModified": 1729697921, + "narHash": "sha256-gqcmWE+4Vr5/l6AoQc2jIbJHCAXAY+qWPC0ruoAHV1Q=", "owner": "srid", "repo": "nixos-unified", - "rev": "09752a3c33541b7342416fb968c299c03c3e7e39", + "rev": "e60e64841e74c777799624531dcb2f311f95f639", "type": "github" }, "original": { @@ -147,11 +147,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1712883908, - "narHash": "sha256-icE1IJE9fHcbDfJ0+qWoDdcBXUoZCcIJxME4lMHwvSM=", + "lastModified": 1734988233, + "narHash": "sha256-Ucfnxq1rF/GjNP3kTL+uTfgdoE9a3fxDftSfeLIS8mA=", "owner": "nixos", "repo": "nixpkgs", - "rev": "a0c9e3aee1000ac2bfb0e5b98c94c946a5d180a9", + "rev": "de1864217bfa9b5845f465e771e0ecb48b30e02d", "type": "github" }, "original": { @@ -184,11 +184,11 @@ ] }, "locked": { - "lastModified": 1711963903, - "narHash": "sha256-N3QDhoaX+paWXHbEXZapqd1r95mdshxToGowtjtYkGI=", + "lastModified": 1734982074, + "narHash": "sha256-N7M37KP7cHWoXicuE536GrVvU8nMDT/gpI1kja2hkdg=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "49dc4a92b02b8e68798abd99184f228243b6e3ac", + "rev": "e41e948cf097cbf96ba4dff47a30ea6891af9f33", "type": "github" }, "original": { From 392b4d4c624caf51f43d0695ea37508b9b253b88 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Tue, 24 Dec 2024 09:05:49 -0500 Subject: [PATCH 2/4] ci: Fix closure check for new Nix --- nix/modules/flake-parts/haskell.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/modules/flake-parts/haskell.nix b/nix/modules/flake-parts/haskell.nix index 50d87e797..b924095ce 100644 --- a/nix/modules/flake-parts/haskell.nix +++ b/nix/modules/flake-parts/haskell.nix @@ -76,7 +76,7 @@ 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 '.[0]'.closureSize) + 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 From 7a7a41a8e89873064bda73edcc3d51534edfc08d Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Tue, 24 Dec 2024 12:12:49 -0500 Subject: [PATCH 3/4] refactor(nix): isolate closure* to its own file --- nix/modules/flake-parts/extra/default.nix | 5 ++ .../flake-parts/extra/small-closure.nix | 58 +++++++++++++++++++ nix/modules/flake-parts/haskell.nix | 27 --------- nix/modules/flake-parts/toplevel.nix | 13 ----- 4 files changed, 63 insertions(+), 40 deletions(-) create mode 100644 nix/modules/flake-parts/extra/default.nix create mode 100644 nix/modules/flake-parts/extra/small-closure.nix diff --git a/nix/modules/flake-parts/extra/default.nix b/nix/modules/flake-parts/extra/default.nix new file mode 100644 index 000000000..1e34ad195 --- /dev/null +++ b/nix/modules/flake-parts/extra/default.nix @@ -0,0 +1,5 @@ +{ + imports = [ + ./small-closure.nix + ]; +} diff --git a/nix/modules/flake-parts/extra/small-closure.nix b/nix/modules/flake-parts/extra/small-closure.nix new file mode 100644 index 000000000..3fdff0b21 --- /dev/null +++ b/nix/modules/flake-parts/extra/small-closure.nix @@ -0,0 +1,58 @@ +# 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; + }; + }; + }; +} diff --git a/nix/modules/flake-parts/haskell.nix b/nix/modules/flake-parts/haskell.nix index b924095ce..1618e83fe 100644 --- a/nix/modules/flake-parts/haskell.nix +++ b/nix/modules/flake-parts/haskell.nix @@ -44,13 +44,6 @@ emanote = { name, pkgs, self, super, ... }: { check = false; extraBuildDepends = [ pkgs.stork ]; - separateBinOutput = false; # removeReferencesTo.nix doesn't work otherwise - justStaticExecutables = true; - removeReferencesTo = [ - self.pandoc - self.pandoc-types - self.warp - ]; custom = pkg: pkg.overrideAttrs (lib.addMetaAttrs { # https://github.com/NixOS/cabal2nix/issues/608 longDescription = '' @@ -68,25 +61,5 @@ packages.default = config.packages.emanote; apps.default = config.apps.emanote; - 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 - ''; - }; - }; }; } diff --git a/nix/modules/flake-parts/toplevel.nix b/nix/modules/flake-parts/toplevel.nix index ad89b9503..5f5b1a8c6 100644 --- a/nix/modules/flake-parts/toplevel.nix +++ b/nix/modules/flake-parts/toplevel.nix @@ -7,18 +7,5 @@ description = "A simple flake.nix template for emanote notebooks"; path = builtins.path { path = inputs.emanote-template; filter = path: _: baseNameOf path == "flake.nix"; }; }; - om = { - ci.default = { - emanote = { - dir = "."; - steps.custom = { - closure-size = { - type = "app"; - name = "check-closure-size"; - }; - }; - }; - }; - }; }; } From e4d7a29af5def0de9233146e69ae43783de5fc21 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Tue, 24 Dec 2024 12:25:05 -0500 Subject: [PATCH 4/4] Disable closure size reduction on macOS - https://github.com/NixOS/nixpkgs/issues/318013 - https://github.com/NixOS/nixpkgs/pull/304352 Related: https://github.com/NixOS/nix/pull/10877 --- nix/modules/flake-parts/extra/small-closure.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nix/modules/flake-parts/extra/small-closure.nix b/nix/modules/flake-parts/extra/small-closure.nix index 3fdff0b21..0304f5fa0 100644 --- a/nix/modules/flake-parts/extra/small-closure.nix +++ b/nix/modules/flake-parts/extra/small-closure.nix @@ -3,7 +3,12 @@ let allowedSystems = [ "x86_64-linux" - "aarch64-darwin" + + # Disabling on macOS due to upstream bug: + # - https://github.com/NixOS/nixpkgs/issues/318013 + # - https://github.com/NixOS/nixpkgs/pull/304352 + # - Related: https://github.com/NixOS/nix/pull/10877 + # "aarch64-darwin" ]; in {