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

nixosImages: add to pkgs #153551

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jonringer
Copy link
Contributor

Motivation for this change

Useful for testing purposes, to help avoid future #152505 scenarios

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/)
  • 22.05 Release Notes (or backporting 21.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.

@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Jan 5, 2022
Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

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

Normally, NixOS goes on top of Nixpkgs, so doing it the other way around will cause issues if expectations aren't managed and no checks are done.

@@ -111,6 +111,16 @@ with pkgs;

nix-update-script = callPackage ../common-updater/nix-update.nix { };

### Push NixOS images into the fixed point
Copy link
Member

@roberth roberth Jan 7, 2022

Choose a reason for hiding this comment

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

Are they really inside the fixpoint or dangling from it?
They don't use any other value from it than system. pkgsStatic.nixosImages is wrong; so are the cross sets.
Part of the problem of course is the nixpkgs.nix module, which is somewhat mandatory because of its existence in module-list.nix; mkForcing _module.args.pkgs or settings nixpkgs.pkgs is counter to traditional NixOS expectations, but probably ok if you use assertions to make sure no nixpkgs.overlays or nixpkgs.config are set.
If we insert pkgs into the images, which is not a technical problem, we do get a little eval performance improvement, as we evaluate pkgs once for all images instead of over and over for each.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can also conditionally add this if hostPlatform.system == targetPlatform.system

Copy link
Member

Choose a reason for hiding this comment

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

I don't think restricting is necessary, although it does reduce the changes to release.nix to make this work. The conditional attr does make the fixpoint attrset strict in stdenv, so that could slow down exclusive use of pkgsStatic for example (if it isn't already slowed down by that), but that can be fixed by supporting cross invocations later.

First, what you can do is define a module here that you pass as a new optional argument to release.nix, which in turn adds it directly in the list of modules that makeModules returns, and to the other modules = params.
The module then only has to set nixpkgs.pkgs and make sure no nixpkgs.config is set. Overlays are actually already supported by the nixpkgs.nix module.

supportedSystems = [ stdenv.hostPlatform.system ];
};
in lib.mapAttrs (name: value: value.${system})
{ inherit (release-packages) iso_minimal iso_gnome iso_plasma5 amazonImage; };
Copy link
Member

Choose a reason for hiding this comment

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

These underscores are counter to Nixpkgs conventions.

Does it make sense to use . here? If we use the same config to generate multiple images, it'd make sense to have minimal.iso for example. Otherwise, isoMinimal is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think something like isos.minimal would be better. But that should be done in another PR. This is trying to tackle, how to test images from packages.

@@ -111,6 +111,16 @@ with pkgs;

nix-update-script = callPackage ../common-updater/nix-update.nix { };

### Push NixOS images into the fixed point
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can also conditionally add this if hostPlatform.system == targetPlatform.system

# Conditional logic must use super, as using pkgs will
# cause infinite recursion when trying to determine a fixed point

} // lib.optionalAttrs (super.stdenv.isLinux && (super.hostPlatform.system == super.targetPlatform.system)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
} // lib.optionalAttrs (super.stdenv.isLinux && (super.hostPlatform.system == super.targetPlatform.system)) {
} // lib.optionalAttrs (super.stdenv.isLinux && super.hostPlatform.system == super.targetPlatform.system) {

Technically unnecessary, just liked how they read.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 10, 2022
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Mar 20, 2024
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 20, 2024
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: merge conflict This PR has merge conflicts with the target branch 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants