Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flake: switch to cached nixpkgs channel #1714

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
nixpkgs-update.inputs.mmdoc.follows = "empty";
nixpkgs-update.inputs.treefmt-nix.follows = "treefmt-nix";
nixpkgs-update.url = "github:nix-community/nixpkgs-update/infra";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";
nixpkgs.url = "https://nixos.org/channels/nixos-unstable-small/nixexprs.tar.xz";
Copy link
Member

@Mic92 Mic92 Feb 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually shallow clone are faster if you regularly switch between nixpkgs versions:

--- flake.nix
+++ flake.nix
@@ -2,7 +2,7 @@
   description = "A universal nixos installer, just needs ssh access to the target system";
 
   inputs = {
-    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable-small";
+    nixpkgs.url = "git+https://github.com/NixOS/nixpkgs?shallow=1&ref=nixos-unstable-small";
     flake-parts = { url = "github:hercules-ci/flake-parts"; inputs.nixpkgs-lib.follows = "nixpkgs"; };
 
     # used for testing

That cache should work both locally and in buildbot. For fresh clones it's almost as fast as downloading the github archive (tested in github actions)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC github has asked projects (homebrew and others) to stop using shallow clones because they are expensive to run on the servers.

Copy link
Member

@Mic92 Mic92 Feb 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only a shallow clone on the first run because than the cache takes over and it's just a handful commit that is fetched (which should be way cheaper than the github archive, especially if the internet isn't great). For this repository no one is using this flake in CIs where we would run into this issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That isn't what I was referring to, just using it in this repo isn't the issue, other people copying the pattern is.

nur-update.inputs.nixpkgs.follows = "nixpkgs";
nur-update.url = "github:nix-community/nur-update";
sops-nix.inputs.nixpkgs.follows = "nixpkgs";
Expand Down