Use fetchTree / github fetcher for CI
This seems to be much more space-efficient: ~/.cache/nix/tarball-cache is about 700MiB uncompressed, under 300MiB as tzst (using tar's defaults, CI uses zstdmt but I assume will be in the same ballpark). The gitv3 cache is multiple GiB. CI will still build doom-example using fetchGit. I intend to shrink the number of modules enabled in the example to keep gitv3 cache size under control.
This commit is contained in:
parent
645f79a916
commit
2af26fcfa1
3 changed files with 37 additions and 20 deletions
|
|
@ -31,6 +31,7 @@ let
|
||||||
# TODO: drop after NixOS 24.05 release.
|
# TODO: drop after NixOS 24.05 release.
|
||||||
emacs = emacs29;
|
emacs = emacs29;
|
||||||
doomLocalDir = "~/.local/share/nix-doom-unstraightened";
|
doomLocalDir = "~/.local/share/nix-doom-unstraightened";
|
||||||
|
experimentalFetchTree = true;
|
||||||
};
|
};
|
||||||
mkDoom = args: (makeDoomPackages (common // args)).doomEmacs;
|
mkDoom = args: (makeDoomPackages (common // args)).doomEmacs;
|
||||||
mkDoomDir = args: writeTextDir "init.el" (toInit args);
|
mkDoomDir = args: writeTextDir "init.el" (toInit args);
|
||||||
|
|
|
||||||
55
default.nix
55
default.nix
|
|
@ -39,6 +39,8 @@
|
||||||
profileName ? "nix",
|
profileName ? "nix",
|
||||||
/* Disable profile early in startup, so "normal" cache/state dirs are used. */
|
/* Disable profile early in startup, so "normal" cache/state dirs are used. */
|
||||||
noProfileHack ? false,
|
noProfileHack ? false,
|
||||||
|
/* Use fetchTree instead of fetchGit for package fetches. */
|
||||||
|
experimentalFetchTree ? false,
|
||||||
|
|
||||||
callPackages,
|
callPackages,
|
||||||
git,
|
git,
|
||||||
|
|
@ -233,27 +235,40 @@ let
|
||||||
else (throw "${name}: cannot derive url from recipe ${p.recipe or "<missing>"}"));
|
else (throw "${name}: cannot derive url from recipe ${p.recipe or "<missing>"}"));
|
||||||
# Use builtins.fetchGit instead of nixpkgs's fetchFromGitHub because
|
# Use builtins.fetchGit instead of nixpkgs's fetchFromGitHub because
|
||||||
# fetchGit allows fetching a specific git commit without a hash.
|
# fetchGit allows fetching a specific git commit without a hash.
|
||||||
# TODO: port to fetchTree once (mostly) stable
|
fetchGitArgs = {
|
||||||
# (in particular the github fetcher may be noticably more efficient)
|
inherit url;
|
||||||
src = builtins.fetchGit (
|
rev = pin;
|
||||||
{
|
allRefs = true;
|
||||||
inherit url;
|
# Skip submodules by default because they seem to be hitting
|
||||||
rev = pin;
|
# https://github.com/NixOS/nix/issues/10773 (or a similar caching issue) and for
|
||||||
allRefs = true;
|
# parity between fetchTree's github fetcher and fetchGit (Github's exports don't
|
||||||
# Skip submodules by default because they seem to be hitting
|
# seem to contain submodules).
|
||||||
# https://github.com/NixOS/nix/issues/10773 (or a similar caching issue) and for
|
submodules = !(p.recipe.nonrecursive or true);
|
||||||
# parity between fetchTree's github fetcher and fetchGit (Github's exports don't
|
# TODO: pull ref from derivation.src when not pulling it from p.recipe?
|
||||||
# seem to contain submodules).
|
# Note Doom does have packages with pin + branch (or nonrecursive) set,
|
||||||
submodules = !(p.recipe.nonrecursive or true);
|
# expecting to inherit the rest of the recipe from Straight.
|
||||||
# TODO: pull ref from derivation.src when not pulling it from p.recipe?
|
|
||||||
# Note Doom does have packages with pin + branch (or nonrecursive) set,
|
|
||||||
# expecting to inherit the rest of the recipe from Straight.
|
|
||||||
|
|
||||||
# Always specify a ref to work around https://github.com/NixOS/nix/issues/10773
|
# Always specify a ref to work around https://github.com/NixOS/nix/issues/10773
|
||||||
ref = p.recipe.branch or "HEAD";
|
ref = p.recipe.branch or "HEAD";
|
||||||
}
|
}
|
||||||
// optionalAttrs (p ? recipe.depth) { shallow = p.recipe.depth == 1; }
|
// optionalAttrs (p ? recipe.depth) { shallow = p.recipe.depth == 1; };
|
||||||
);
|
src =
|
||||||
|
if experimentalFetchTree
|
||||||
|
then builtins.fetchTree (
|
||||||
|
if lib.hasPrefix "https://github.com/" url
|
||||||
|
then let
|
||||||
|
tail = lib.removePrefix "https://github.com/" url;
|
||||||
|
split = lib.splitString "/" tail;
|
||||||
|
owner = lib.head split;
|
||||||
|
repo = lib.removeSuffix ".git" (lib.elemAt split 1);
|
||||||
|
in {
|
||||||
|
type = "github";
|
||||||
|
inherit owner repo;
|
||||||
|
rev = pin;
|
||||||
|
} else ({
|
||||||
|
type = "git";
|
||||||
|
} // fetchGitArgs))
|
||||||
|
else builtins.fetchGit fetchGitArgs;
|
||||||
# Run locally to avoid a network roundtrip.
|
# Run locally to avoid a network roundtrip.
|
||||||
reqfile = runCommandLocal "${name}-deps" { } ''
|
reqfile = runCommandLocal "${name}-deps" { } ''
|
||||||
${lib.getExe emacs} -Q --batch --script \
|
${lib.getExe emacs} -Q --batch --script \
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,7 @@
|
||||||
doomDir = ./doomdirs/minimal;
|
doomDir = ./doomdirs/minimal;
|
||||||
doomLocalDir = "~/.local/share/nix-doom-unstraightened";
|
doomLocalDir = "~/.local/share/nix-doom-unstraightened";
|
||||||
full = true;
|
full = true;
|
||||||
|
experimentalFetchTree = true;
|
||||||
}).doomEmacs.emacsWithPackages.deps;
|
}).doomEmacs.emacsWithPackages.deps;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue