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

purism/librem/5r4: make it usuable without an overlay #932

Merged
merged 2 commits into from May 8, 2024
Merged

Conversation

Mic92
Copy link
Member

@Mic92 Mic92 commented May 5, 2024

In larger installations nixpkgs.overlays adds significant overhead because it's harder to share nixpkgs between different NixOS machines i.e. using nixpkgs.pkgs

Description of changes
Things done
  • Tested the changes in your own NixOS Configuration
  • Tested the changes end-to-end by using your fork of nixos-hardware and
    importing it via <nixos-hardware> or Flake input

@SuperSandro2000
Copy link
Member

SuperSandro2000 commented May 5, 2024

Hiding packages in let ins blocks any overlays and you have no way to access the package without reimporting it (if that is possible).

I think you are the only person I know which hacks around overlays like that and we've seen in the past, that silently overwriting any option under nixpkgs. is not that great or straight forward.

@Mic92
Copy link
Member Author

Mic92 commented May 6, 2024

Hiding packages in let ins blocks any overlays and you have no way to access the package without reimporting it (if that is possible).

I think you are the only person I know which hacks around overlays like that and we've seen in the past, that silently overwriting any option under nixpkgs. is not that great or straight forward.

Hiding overlays inside a NixOS is also not great, because you if you use flakes you will always end up with two nixpkgs instances, if you also include packages imported in your flake:

  inputs.nixpkgs.url = "github:foo/nixpkgs";
  
  inputs.some-package-flake.url = "github:Mic92/some-package-flake";
  inputs.some-package-flake.follows = "nixpkgs";

  outputs = { nixpkgs, some-package-flake, ... }: {
    nixosConfigurations.foo = nixpkgs.lib.nixosSystem {
      modules = [
        {
          # This is the second copy of nixpkgs, NixOS creates the other copy with `nixpkgs.overlays`
          # It's also inconsistent because nixpkgs.overlays is applied in one case but not the other.
          environment.systemPackages = [ inputs.some-package-flake.packages.mypackage ];
        }
      ];
    };
  }; 

How do solve that? Also each overlay makes nixpkgs signifantly slower. Here is a micro benchmark:

# ./hello.nix
 with import <nixpkgs> {
   overlays = [];
 };
 hello

And than with 10, 20, 30 overlays:

# ./hello-slow10.nix
with import <nixpkgs> {
  overlays = builtins.map (_:
    (self: super: {
      foo = super.foo.overrideAttrs (oldAttrs: {});
    })) [ 1 2 3 4 5 6 7 8 9 10 ];
};
hello

Here is the benchmark when running with [hyperfine] like this:

taskset -c 0 hyperfine "nix-instantiate ./hello.nix" "nix-instantiate ./hello-slow10.nix" "nix-instantiate ./hello-slow20.nix" "nix-instantiate ./hello-slow30.nix"
Command Mean [ms] Relative
nix-instantiate ./hello.nix 228.5 ± 7.8 1.00
nix-instantiate ./hello-slow10.nix 243.9 ± 3.9 1.07 ± 0.04
nix-instantiate ./hello-slow20.nix 253.7 ± 2.8 1.11 ± 0.04
nix-instantiate ./hello-slow30.nix 268.1 ± 6.3 1.17 ± 0.05

@Mic92
Copy link
Member Author

Mic92 commented May 6, 2024

I think you are the only person I know which hacks around overlays like that and we've seen in the past, that silently overwriting any option under nixpkgs. is not that great or straight forward.

Most large scale deployments of NixOS are not so open in the public, but it's certainly a well-known trick to get 30% faster evaluation speeds even if you just have 5 machines.

@Mic92
Copy link
Member Author

Mic92 commented May 6, 2024

@SuperSandro2000 Please check again. Packages are now accessible through NixOS options.


nixpkgs.hostPlatform = "armv7l-linux";

boot.initrd.availableKernelModules = [ "ahci_mvebu" ];

boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux_5_15_helios4;
boot.kernelPackages = pkgs.linuxPackagesFor linux_5_15_helios4;
Copy link
Member Author

Choose a reason for hiding this comment

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

Linux kernels should be always accessed via config.kernelPackages.kernel, so no need for an overlay here.

in {
options = {
hardware.librem5 = {
package = lib.mkOption {
Copy link
Member Author

Choose a reason for hiding this comment

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

With that the package is no longer hidden.

@SuperSandro2000
Copy link
Member

@SuperSandro2000 Please check again. Packages are now accessible through NixOS options.

that looks a lot better. Thanks for taking that time.

@Mic92
Copy link
Member Author

Mic92 commented May 8, 2024

@mergify queue

Copy link
Contributor

mergify bot commented May 8, 2024

queue

☑️ GitHub can't merge the pull request for now.

GitHub can't merge the pull request for an unknown reason. You should retry later.

@Mic92
Copy link
Member Author

Mic92 commented May 8, 2024

@mergify rebase

Mic92 added 2 commits May 8, 2024 05:57
In larger installations nixpkgs.overlays adds significant overhead
because it's harder to share nixpkgs between different NixOS machines
i.e. using nixpkgs.pkgs
Note that the linux kernel can and should be accessed through
config.kernelPackages.kernel.
Copy link
Contributor

mergify bot commented May 8, 2024

rebase

✅ Branch has been successfully rebased

@Mic92
Copy link
Member Author

Mic92 commented May 8, 2024

@mergify queue

Copy link
Contributor

mergify bot commented May 8, 2024

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at a4e2b79

@mergify mergify bot merged commit a4e2b79 into master May 8, 2024
3 checks passed
@samueldr samueldr deleted the no-overlay branch May 8, 2024 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants