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

nixos/no-x-libs: add more replacements #204287

Merged
merged 1 commit into from
Jan 20, 2023

Conversation

Artturin
Copy link
Member

@Artturin Artturin commented Dec 3, 2022

all-packages: change -nox overrides to callPackage's so there is no infinite recursion when replacing the package with a overlay

Description of changes
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Dec 3, 2022
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Dec 3, 2022
@RaitoBezarius
Copy link
Member

@Artturin Is there an easy way to measure the delta in the closure size?

@Artturin
Copy link
Member Author

Artturin commented Dec 3, 2022

@Artturin Is there an easy way to measure the delta in the closure size?

this doesn't change the closure size much (atleast for a minimal-ish system assuming i did the comparison correctly) but instead reduces the dependency tree size ( reducing compilation times if compiling from ex staging)

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/refs/pull/204287/head";
    # commit before the above pr
    nixpkgs-before.url = "github:NixOS/nixpkgs/7bfceb02093f2c7ea0ea7e353c99b26e9a4022fc";
  };

  outputs = inputs:
    let
      pkgs = import inputs.nixpkgs { system = "x86_64-linux"; };
      pkgs-before = import inputs.nixpkgs-before { system = "x86_64-linux"; };

      node = pkgs.nixos ({ modulesPath, ... }: {
        fileSystems."/".device = "ignore-root-device";
        boot.loader.grub.enable = false;
        imports = [
          (modulesPath + "/profiles/minimal.nix")
        ];
        networking.networkmanager = {
          enable = true;
          plugins = pkgs.lib.mkForce [];
        };
      });
      node-before = pkgs-before.nixos ({ modulesPath, ... }: {
        fileSystems."/".device = "ignore-root-device";
        boot.loader.grub.enable = false;
        imports = [
          (modulesPath + "/profiles/minimal.nix")
        ];
        networking.networkmanager = {
          enable = true;
          plugins = pkgs.lib.mkForce [];
        };
        nixpkgs.overlays = [
          (_: super: {
           # had to add this because the compilation was broken before
            stoken = super.stoken.override { withGTK3 = false; };
          })
        ];
      });

      closureInfo = pkgs.closureInfo { rootPaths = [ node.config.system.build.toplevel ]; };
      closureInfoBefore = pkgs.closureInfo { rootPaths = [ node-before.config.system.build.toplevel ]; };
    in
    {
      packages.x86_64-linux.default = pkgs.runCommand "compare"
        {
          inherit closureInfo closureInfoBefore;
          nativeBuildInputs = [ pkgs.nodePackages.insect ];
        } ''
        sizeBytes=$(cat $closureInfo/total-nar-size)
        sizeBeforeBytes=$(cat $closureInfoBefore/total-nar-size)
        insect "$((sizeBeforeBytes - sizeBytes)) bytes -> megabytes"
        touch $out
      '';
      packages.x86_64-linux.has-libX = closureInfoBefore;
      packages.x86_64-linux.no-libX = closureInfo;
    };
}
nix path-info -rsSh ".#packages.x86_64-linux.has-libX" --derivation | wc -l
2167
$ nix path-info -rsSh ".#packages.x86_64-linux.no-libX" --derivation | wc -l
1866

# translateManpages -> perlPackages.po4a -> texlive-combined-basic -> texlive-core-big -> libX11
util-linux = super.util-linux.override { translateManpages = false; };
# dep of graphviz, libXpm is optional for Xpm support
gd = super.gd.override { libXpm = null; };
Copy link
Member

Choose a reason for hiding this comment

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

Can we please add an option instead of overwriting packages to null? This would for example break if we access libXpm.version.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
gd = super.gd.override { libXpm = null; };
gd = super.gd.override { withXorg = false; };

Comment on lines 20157 to 20158
libX11 = null;
libGL = null;
Copy link
Member

Choose a reason for hiding this comment

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

Let me create a PR that adds a proper option for this.

Copy link
Member

Choose a reason for hiding this comment

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

@mweinelt mweinelt added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Dec 4, 2022
nixos/modules/config/no-x-libs.nix Show resolved Hide resolved
# translateManpages -> perlPackages.po4a -> texlive-combined-basic -> texlive-core-big -> libX11
util-linux = super.util-linux.override { translateManpages = false; };
# dep of graphviz, libXpm is optional for Xpm support
gd = super.gd.override { libXpm = null; };
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
gd = super.gd.override { libXpm = null; };
gd = super.gd.override { withXorg = false; };

pkgs/top-level/all-packages.nix Outdated Show resolved Hide resolved
@SuperSandro2000
Copy link
Member

FYI you motivated to try this again especially for my simd branch and I created the following PRs:

@roberth
Copy link
Member

roberth commented Dec 7, 2022

Related

I'm not doing this through the NixOS no-x-libs overlay, because this should improve many packages that have no business having graphical libraries in their build closure, saving many rebuilds, regardless of whether the user wants to optimize for a non-graphical system configuration.

@roberth roberth added the 6.topic: closure size The final size of a derivation, including its dependencies label Dec 7, 2022
@SuperSandro2000 SuperSandro2000 force-pushed the addmorenox branch 2 times, most recently from eccd9f5 to b7afcc1 Compare December 9, 2022 10:33
@Artturin Artturin force-pushed the addmorenox branch 2 times, most recently from 2be05f1 to 2cff6fd Compare December 10, 2022 19:53
@Artturin
Copy link
Member Author

wait until https://nixpk.gs/pr-tracker.html?pr=204426 is in master

@Artturin Artturin marked this pull request as draft December 10, 2022 19:54
@SuperSandro2000
Copy link
Member

Why not merge this into staging?

@SuperSandro2000 SuperSandro2000 marked this pull request as ready for review January 18, 2023 16:13
@SuperSandro2000
Copy link
Member

Needed to create a new PR because force pushing that one almost deadlocked my computer. #211428

all-packages: change -nox overrides to callPackage's so there is no
infinite recursion when replacing the package with a overlay
@SuperSandro2000 SuperSandro2000 merged commit fe34a63 into NixOS:master Jan 20, 2023
@Izorkin
Copy link
Contributor

Izorkin commented Jan 20, 2023

This PR causes this error:

error: infinite recursion encountered

       at /home/user/works/src-nix/nixpkgs/pkgs/top-level/all-packages.nix:20695:3:

        20694|
        20695|   libdevil-nox = libdevil.override {
             |   ^
        20696|     inherit (darwin.apple_sdk.frameworks) OpenGL;
(use '--show-trace' to show detailed location information)

imagemagick = super.imagemagick.override { libX11Support = false; libXtSupport = false; };
imagemagickBig = super.imagemagickBig.override { libX11Support = false; libXtSupport = false; };
libdevil = super.libdevil-nox;
Copy link
Member Author

Choose a reason for hiding this comment

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

libdevil -> libdevil-nox -> libdevil -> libdevil-nox ...

Copy link
Member Author

@Artturin Artturin Jan 20, 2023

Choose a reason for hiding this comment

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

changing this back to

  libdevil-nox = callPackage ../development/libraries/libdevil {
    inherit (darwin.apple_sdk.frameworks) OpenGL;
    withXorg = false;
  };

will work

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, working!

Copy link
Member

Choose a reason for hiding this comment

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

Ahh, sorry, messed this up when rebasing.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: closure size The final size of a derivation, including its dependencies 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 12.approvals: 1 This PR was reviewed and approved by one reputable person
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants