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

make-disk-image: use nix path-info to automatically set the imageSize #465

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MatthewCroughan
Copy link
Contributor

This may not be the best approach, but it is an approach.

lib/make-disk-image.nix Outdated Show resolved Hide resolved
rootPaths = [ systemToInstall.config.system.build.toplevel ];
}}/registration

${lib.concatMapStringsSep "\n" (disk: "truncate -s $(($(set -x; nix path-info --json ${systemToInstall.config.system.build.toplevel} | jq .[].closureSize) + ${toString disk.imageSizeExtraBytes})) ${disk.name}.raw") (lib.attrValues nixosConfig.config.disko.devices.disk)}
Copy link
Collaborator

Choose a reason for hiding this comment

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

newlines could help to make that more readable. and probably using '' instead of "

Copy link
Member

Choose a reason for hiding this comment

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

I would also assign variables so that in the event of a failure it's easier to spot which part failed.

@iFreilicht
Copy link
Contributor

This seems like a nice QoL improvement. Could you rebase it and address the comments?

@iFreilicht iFreilicht added the stale No activity for a long time, might be irrelevant. PRs with this label may be closed after a while label Sep 20, 2024
@MatthewCroughan
Copy link
Contributor Author

@iFreilicht I don't have the time at the moment, but maybe you or @Enzime could

@Mic92
Copy link
Member

Mic92 commented Sep 21, 2024

This seems like a nice QoL improvement. Could you rebase it and address the comments?

I tried to come up with a more accurate algorithm, but it seems impossible. So I am not so sure if we should have this.

@iFreilicht
Copy link
Contributor

I tried to come up with a more accurate algorithm, but it seems impossible.

What's the risk? Having the image size reduced automatically seems quite neat, even if it isn't perfect. I see two potential issues:

  • If the result of the calculation is too small, the build will fail.
  • If the calculation is automatic, an explosive increase in size wouldn't be noticed

I don't know too much about how these disk images are used in practice, so I can't tell how bad these are and how big of a pain this PR solves. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale No activity for a long time, might be irrelevant. PRs with this label may be closed after a while
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants