Commit Graph

67 Commits

Author SHA1 Message Date
Julian Stecklina
cca4364ef0 modules/image/repart: fix typo in renamed option warning 2025-11-09 08:09:33 +01:00
Arthur Gautier
869de83cc4 modules/image/repart: fixup partitions example
`fat` is not a valid value for `Format`

See https://www.freedesktop.org/software/systemd/man/latest/repart.d.html#Format=
2025-10-24 13:36:33 -07:00
nikstur
3ba94658f0 modules/image/repart: repart.imageFile(Basename) -> image.baseName (#437117) 2025-09-29 12:58:44 +00:00
Vincent Haupert
973fbf96a4 nixos/image/repart: allow replacing /nix/store 2025-09-16 08:11:12 +02:00
phaer
3bb83bd10c modules/image/repart: repart.imageFile(Basename) -> image.baseName
Rename remaining uses of renamed option repart.imageFileBasename to
image.baseName.

Follow up to https://github.com/NixOS/nixpkgs/pull/401872
Removes a warning when using repart-verity-store.nix.
2025-08-26 14:58:23 +02:00
secufoe
77aebee8ac nixos/repart-verity-store: fix cross 2025-08-06 13:36:36 +02:00
Wolfgang Walther
5a0711127c treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
phaer
b8e5d76027 repart-image: do not run fixupPhase...
These derivation output one or more disk image files and metadata in
JSON, none of which seem to be good targets for patchelf, stripping
or other things that typically happen in fixupPhase.

I noticed that specifically shebang patching took a long time when
building bigger images, roughly doubling build times at times.

This might be due to a traversal of an entire disk images, dozens of
gigabytes in size while looking for interpreters.

All tests in

    nix-build -A nixosTests.systemd-repart

passed, but no further testing was done yet.
2025-06-27 19:56:09 +02:00
WilliButz
ed5f0fbfcd nixos/repart-image: don't pass seed when it's null, update documentation
From systemd-repart(8):

If not specified it is attempted to read the machine ID from the host
(or more precisely, the root directory configured via --root=) and use
it as seed instead, falling back to a randomized seed otherwise. Use
--seed=random to force a randomized seed.

The option documentation now suggests the special value "random", for
a random seed rather than relying on the implicit fact that there is
no machine ID available in the build sandbox, causing repart to fallback
on generating a random seed.

Fixes #419331
2025-06-23 20:25:13 +02:00
Robert Rose
0134a1d442 nixos/repart: update zeekstd command 2025-05-29 19:27:22 +02:00
Arian van Putten
871526be1f nixos/image/repart: Use own assertions / warnings. (#406940) 2025-05-15 19:14:53 +02:00
phaer
8a2195e94e repart: fix whitespace in option descriptions
I mistakenly added extra whitespace in
https://github.com/NixOS/nixpkgs/pull/401872 which negatively affects
aesthetics of our documentation.

Thought it was part of nixfmt-rfc-styles output, but can't reproduce.
Might have had configured the wrong nixfmt.
2025-05-14 09:32:18 +02:00
Will Fancher
26ccfb7a8c nixos/image/repart: Use own assertions / warnings.
It was easy to accidentally trigger infinite recursion if you depended
on `toplevel` in any way before. For instance, if you used
`CopyBlocks` with an image containing `toplevel`. This was because
`toplevel`'s assertion / warning logic has to be evaluated, but that
means evaluating `image.repart`'s assertions / warnings, which
requires evaluating the `repartConfig` attrsets to check for malformed
`Label`s. That causes the module system to type check *all*
`repartConfig` keys, even though most of them aren't used in the
assertions / warnings. So evaluating `system.build.image` evaluates
`repartConfig.CopyBlocks`, which evaluates `toplevel`, which evaluates
assertions / warnings, which evaluates `repartConfig.CopyBlocks` to
type check it. Infinite loop.

Even ignoring this recursion problem, it's still better for the repart
module to have its own assertions / warnings options. You don't have
to use `toplevel` in a repart image, so its assertions / warnings
would have been ignored in that case anyway. This way they're *always*
checked when you build an image.
2025-05-14 01:24:43 -04:00
phaer
9e6e5152ba image/repart: repart.imageFile(BaseName) -> image.baseName, etc
Replace image-specific options for file name (and basename) with
unified options for basename and extension in order to increase
compatibility with nixos-rebuild build-image
2025-04-26 10:55:23 +02:00
phaer
1df1c8828d image/repart: run nixfmt 2025-04-25 22:03:46 +02:00
phaer
0a8b014f67 image/file-options: use defaultText 2025-04-25 22:03:46 +02:00
jopejoe1
e6d927fcfd cloudstack: add to image/images (#398556) 2025-04-24 19:03:53 +02:00
Nico Felbinger
e0d1b49a46 chore: move meta option to top level in many modules 2025-04-19 18:27:48 +02:00
phaer
d7e76ed0a2 cloudstack: add to image/images
This was an oversight in https://github.com/NixOS/nixpkgs/pull/347275,
so it's currently missing from the variants listed in nixos-rebuild build-image
2025-04-14 14:03:58 +02:00
Silvan Mosberger
374e6bcc40 treewide: Format all Nix files
Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:

  nix-build ci -A fmt.check

This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).

This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).

Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase).

If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
2025-04-01 20:10:43 +02:00
Alexander Foremny
5c28518c4b nixos/modules/image: fix error message
When a module is not found, it did not show the intended error message
`The module ... does not exist`, but rather `path ... does not exist`.
2025-03-19 17:29:28 +00:00
nikstur
16c4ead8d7 zeekstd: init at 0.2.2 (#387636) 2025-03-16 19:17:30 +01:00
Robert Rose
119b75c310 nixos/repart: add zstd-seekable compression algorithm
The seekable format splits compressed data into a series of independent
frames, each of which can be decompressed individually. This allows to
distribute images in smaller chunks and allows image downloads to be
paused and resumed later from the same point.

Seekable archives as a whole can be decompressed with any regular zstd
decompressor. However, partial decompression requires to know the
starting position of the desired frame, which can be extracted from a
skippable frame (aka seektable) that is appended to the compressed data.
2025-03-16 18:32:56 +01:00
Florent Charpentier
631bed6ed9 nixos/systemd-repart: add support for repeating settings
fix https://github.com/NixOS/nixpkgs/issues/389478
2025-03-14 19:43:28 +01:00
Peder Bergebakken Sundt
527be14321 nixos/doc: convert links to manpages 2025-02-21 16:31:09 +01:00
Arian van Putten
098d858f3c nixos/image/images: fix sd-card image on aarch64 (#372783) 2025-02-17 15:04:27 +01:00
nikstur
8a12cae321 nixos/repart-image: support swap 2025-02-01 18:36:51 +01:00
nikstur
c613b0e446 nixos/repart-image: fix btrfs images 2025-02-01 17:58:01 +01:00
DavHau
6e6be76601 nixos/image.modules: siplify type for better UX
Usage before:

```
image.modules.my-format = [
  (
    { config, pkgs, ... }:
    {
      imports = [ ./my-other-module.nix ];
      foo = "bar";
    };
  )
]
```

Usage after:

```
image.modules.my-format = { config, pkgs, ... }: {
  imports = [ ./my-other-module.nix ];
  foo = "bar";
};
```

If the user wants to pass a list of modules only:
```
image.modules.my-format.imports = [
  ./module1.nix
  ./module2.nix
]
```

cc @phaer @zimbatm
2025-01-13 18:57:14 +07:00
phaer
54632790fb nixos/image/images: fix sd-card image on aarch64
by using qemuArch, not linuxArch. The former is "aarch64",
while the later is "arm64" on such machines.
2025-01-11 00:23:10 +01:00
Thiago Kenji Okada
6e6188af7b image/images: Adapt remaining images to system.build.image & normalized filenames, (#359345) 2025-01-05 20:28:23 +00:00
WilliButz
685d9fe348 nixos/repart-verity-store: use mkDefault for partition types
This makes it a bit easier to switch between using the default usr
veritysetup generator or the nix-store veritysetup generator.
2024-12-17 17:12:42 +01:00
WilliButz
8404744352 nixos/repart-verity-store: set supportedFilesystems, drop fileSystems entry from test
The `/usr` entry in `fileSystems` is superfluous and currently
interferes with the systemd generator. Dropping the `fileSystem` entry
requires making the appropriate module explicitly available in initrd.
2024-12-17 17:12:42 +01:00
phaer
e3347c19b3 image/images: Add remaining image modules
to achieve feature parity with nixos-generators
2024-12-16 15:35:22 +01:00
Silvan Mosberger
4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00
phaer
c78003c4e0 image/images: Add image modules defined in virtualisation/ 2024-11-29 17:13:54 +01:00
phaer
08b9155e20 image/images: init
A new NixOS module that adds two new options to `system.build`:

- imageModules: An attrset mapping image variant names to a list of nixos
  modules to use when building such images.

- images: An attrset mapping image variant names to a nixos instance
  based on the current config plus variant-specific modules (see
  `system.build.imageModules` above.
2024-11-26 19:04:53 +01:00
phaer
148ba06717 image/file-options: init 2024-11-26 19:04:53 +01:00
Arian van Putten
1b592cdeb4 nixos/image/repart: unsafeDiscardReferences.out = true
Lets set this in the repart module instead of the verity module
2024-10-10 11:48:36 +02:00
WilliButz
93c61c1e58 nixos/repart-verity-store: include original roothashes in repart-output.json 2024-09-30 22:45:05 +02:00
WilliButz
3f1f20b2a7 nixos/repart-image: pass partition attrs to builder instead of JSON file
Having access to the original Nix partition definitions in the builder
should make it a bit easier to manipulate them and still provide access
to the manipulated results.
2024-09-30 20:10:51 +02:00
WilliButz
942588c686 nixos/repart-verity-store: init
This module provides some abstraction for a multi-stage build to create
a dm-verity protected NixOS repart image.

The opinionated approach realized by this module is to first create an
immutable, verity-protected nix store partition, then embed the root
hash of the corresponding verity hash partition in a UKI, that is then
injected into the ESP of the resulting image.
The UKI can then precisely identify the corresponding data from which
the entire system is bootstrapped.

The module comes with a script that checks the UKI used in the final
image corresponds to the intermediate image created in the first step.
This is necessary to notice incompatible substitutions of
non-reproducible store paths, for example when working with distributed
builds, or when offline-signing the UKI.
2024-09-20 17:35:49 +02:00
WilliButz
0864b38144 nixos/repart-image: fix amend script
Calling ruff directly on files was deprecated in favor of
`ruff check`. Since #322953 usage without the subcommand is no longer
possible.
2024-07-10 11:40:40 +02:00
Jared Baur
7aff15e8c4 nixos/systemd-repart: respect NIX_BUILD_CORES for image compression 2024-06-13 21:11:40 -07:00
Daniel Barter
d7a9d49c42 repart-image: removing unshare (and util-linux dep) form systemd-repart invocation
..
2024-06-03 17:48:27 -07:00
stuebinm
6afb255d97 nixos: remove all uses of lib.mdDoc
these changes were generated with nixq 0.0.2, by running

  nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix

two mentions of the mdDoc function remain in nixos/, both of which
are inside of comments.

Since lib.mdDoc is already defined as just id, this commit is a no-op as
far as Nix (and the built manual) is concerned.
2024-04-13 10:07:35 -07:00
nikstur
80cafa6a29 Merge pull request #302590 from nikstur/repart-image-label-length
nixos/image/repart: assert maximum label length
2024-04-08 18:48:53 +02:00
nikstur
ad19cee09c nixos/image/repart: assert maximum label length
The maximum label length is specified by UEFI and enforced/asserted by
systemd-repart. This lets evaluation fail already and give the user
some more information about what's wrong.

Also warn when the suggested label length is exceeded. This serves as a
safety mechanism for using systemd-sysupdate style A/B updates where the
version number is encoded in the label and might not be incrementable
when the maximum label size is reached.
2024-04-08 16:42:25 +02:00
nikstur
b9fe4b1e26 nixos/repart-image: supply explicit --architecture to repart
This enables cross-compiling images.
2024-04-04 17:38:08 +02:00
WilliButz
d9264d0568 nixos/repart-image: add myself as maintainer 2024-03-21 11:37:43 +01:00