1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-11 21:17:45 +03:00
Commit Graph

82 Commits

Author SHA1 Message Date
Samuel Dionne-Riel
bf78ef0ecf image-builder/makeGPT: Add postProcess 2022-10-20 20:43:26 -04:00
Samuel Dionne-Riel
6c7272ac4c image-builder: Use epoch+1 as epoch is messy
KDE things may fail in almost undebuggable ways.

With "firehose log level" I saw this message for files that were
present:

9eb46f9b20/src/sycoca/kbuildsycoca.cpp (L636)

This, in turn, is because "hash" is computed as a sum of all modified
dates

9eb46f9b20/src/sycoca/kbuildsycoca.cpp (L610)

(Weird hashing!)

Which, in turn, meant that it was `0` here.

Finally, `0` ends up magically breaking everything in a plasma mobile
system. Since apparently desktop files will not even be attempted to be
read or used if they are not cached by ksycoca.

The task panel broke in inscrutable ways, and there were no applications
found to run.
2022-10-19 15:31:05 -04:00
Samuel Dionne-Riel
72726bd6f4 image-builder/makeExt4: Fix inodes exhaustion
Let's ensure we have enough inodes. Twice the amount needed should be
fine, right?
2022-10-12 21:38:03 -04:00
Samuel Dionne-Riel
148861e67c treewide: utillinux -> util-linux 2022-09-26 23:44:11 -04:00
Samuel Dionne-Riel
1754276528 treewide: runCommandNoCC -> runCommand
*sighs*
2022-09-26 23:42:22 -04:00
Samuel Dionne-Riel
6c68869eed lib/configuration: Allow not providing a device name
This is useful for including the Mobile NixOS configuration to opt into
a single subsystem (e.g. stage-1).
2022-05-29 22:39:11 -04:00
Samuel Dionne-Riel
796040d35e
Merge pull request #405 from samueldr-wip/feature/pkgs-pinning
Pin Nixpkgs (without Flakes)
2021-08-31 14:34:59 -04:00
Samuel Dionne-Riel
1090d496be release-tools: Don't rely on <nixpkgs> anymore 2021-08-31 14:19:51 -04:00
Samuel Dionne-Riel
9a0fdf4e71 eval-with-configuration: Don't rely on <nixpkgs> anymore 2021-08-31 14:19:51 -04:00
Samuel Dionne-Riel
db537d8166 lib/eval-with-configuration: Use outputs, and merge system-specific outputs 2021-08-27 01:02:34 -04:00
Tom
be1863d5d8
imageBuilder: use du --files0-from rather than xargs -0
Co-authored-by: Samuel Dionne-Riel <samuel@dionne-riel.com>
2021-07-03 06:49:58 +00:00
Tom Fitzhenry
ffec1f669b imageBuilder: speed up gen by batching du calls: 44min -> 1min45s
fixes https://github.com/NixOS/mobile-nixos/issues/372

Per https://github.com/NixOS/mobile-nixos/issues/372, I observed
building an image takes ~40 minutes, and it spends the vast majority
of that performing `du` on the files that will be included in the image.

Most of that time is on process invocation overhead, and thus we can
save a lot by batching calls to `du`.

Per https://danielmiessler.com/blog/linux-xargs-vs-exec/, replacing
`find -exec du` with `find -print0 | xargs -0 du` is an optimisation to do
this. xargs will invoke du as "du fn1 fn2 fn3 fn4 ...", etc.

Before: 44mins (full output: https://paste.debian.net/1203075/ )
After: 1m45s (full output: https://paste.debian.net/1203076/ )

To reproduce this issue on a smaller dataset, try the before and after
on a directory with many files (e.g. nixpkgs checkout, which has ~27k files):

```
$ cd nixpkgs
$ time find . ! -type d -exec du {} \; | cut -f1 | sum
53288    55

real	0m20.802s
user	0m9.660s
sys	0m11.626s

$ time find . ! -type d -print0 | xargs -0 du | cut -f1 | sum
53288    55

real	0m0.097s
user	0m0.042s
sys	0m0.171s
```

That's a 200x speedup.

To discount the possibility of this issue being `find` or file I/O related:

```
$ time bash -c 'seq 27000 | xargs /run/current-system/sw/bin/echo | wc'
      2   27000  150894

real	0m0.008s
user	0m0.006s
sys	0m0.006s

$ time bash -c 'for i in $(seq 27000); do /run/current-system/sw/bin/echo $i; done | wc'
  27000   27000  150894

real	0m19.815s
user	0m9.876s
sys	0m10.755s
```

The ~27k process invocation still takes ~20s.

This shows the problem is process invocation.

Is this safe?

* Both before and after produce the same sector result: "926478
sectors for files" and "21491 sectors for directories"
* `-print0` and `-0` are needed to ensure this works with filenames
that contain spaces.
2021-07-02 08:05:35 +10:00
Linus Heckemann
f6a8c83c6d makeBtrfs: add scope hack 2021-06-18 21:50:42 +02:00
Linus Heckemann
10000edcda imageBuilder: add btrfs support 2021-05-21 17:45:32 +02:00
Samuel Dionne-Riel
500d3d95b1 lib: Add missing eval-with-configuration.nix file 2021-02-23 21:05:28 -05:00
Samuel Dionne-Riel
f1268082f9 lib/release-tools: eval helpers don't include default.nix anymore
This is required for more hermetic evals.

A simple thing to try is, before this change, replace `default.nix` with
`throw "No thanks..."`. It would throw. It was also possible to observe
`local.nix` was being included by the warnings.

Wioth this change, `release.nix` does not include `local.nix` through
`default.nix`.

I think this was the last piece of Mobile NixOS that actually relied on
`default.nix` being a thing. We have finally completely inverted the
control, where `default.nix` uses the helpers, rather than the helpers
evaluating a specialized `default.nix`.

From now on, it should be entirely safe to experiment with
`default.nix`. We should be able to **fail noisily** when a user builds
the default empty configuration!
2021-02-21 17:34:12 -05:00
Samuel Dionne-Riel
34b033330f Replace evalConfig with config.lib.mobile-nixos.composeConfig 2021-02-02 01:58:41 -05:00
Samuel Dionne-Riel
b57495c363 release-tools: Remove _mobile-nixos.nixpkgsPath
`modulesPath` is enough for our needs.
2021-02-02 01:58:41 -05:00
Edward Amsden
c507b39099 Make the package set a parameter instead of using <nixpkgs> everywhere.
Co-authored-by: Samuel Dionne-Riel <samuel@dionne-riel.com>
Co-authored-by: Edward Amsden <edward@blackriversoft.com>
2021-02-02 01:58:41 -05:00
Samuel Dionne-Riel
c2ac23379c image-builder: Provide a LUKS partition type UUID 2020-12-29 18:21:52 -05:00
Samuel Dionne-Riel
96a71e1b2b makeFAT32: fix build for bigger filesystems 2020-12-29 18:21:52 -05:00
Samuel Dionne-Riel
aca6dc811b image-builder: build GPT using cgpt
This allows us to make a hold in the header, while all other options
apparently can't cope with that in scriptable and stable manner.
2020-10-15 19:15:46 -04:00
Samuel Dionne-Riel
1ba61f1860 release-tools: Remove usage of removed option
Recent changes in Nixpkgs makes it more strict.

This is a change that wasn't caught as needed from the migration to
structured options for device infos.
2020-08-18 17:45:03 -04:00
Samuel Dionne-Riel
d5dc607443 Allow evaluating a device from a path
This allows external device definitions to be used.
2020-07-28 00:05:14 -04:00
Samuel Dionne-Riel
c26105eabf release-tools: Eval using imports to get the file name
Instead of the following error message:

```
error: The option `mobile.device.info' defined in `<unknown-file>' does not exist.
(use '--show-trace' to show detailed location information)
```

We now get:

```
error: The option `mobile.device.info' defined in `.../mobile-nixos/devices/asus-z00t' does not exist.
(use '--show-trace' to show detailed location information)
```
2020-05-24 20:13:07 -04:00
Samuel Dionne-Riel
12f1c29655 lib/configuration.nix: Add method for importing in system configuration 2020-04-06 23:01:57 -04:00
Samuel Dionne-Riel
fb64a005de Allow evaluating without NixOS.
We are now splitting the concerns more clearly, by making `baseModules`
the reason we are evaluating NixOS, rather than wholesale always
including it into the modules.
2020-04-06 18:32:45 -04:00
Samuel Dionne-Riel
9179158645 release-tools: Split useful Mobile NixOS evaluation tools
This is to be used by the documentation system, without requiring to
repeat all of the code.
2020-04-04 14:39:23 -04:00
Samuel Dionne-Riel
f7506b5ec8 image-builder: Filesystems can be post-processed 2020-03-31 00:33:16 -04:00
Samuel Dionne-Riel
ddfd04c26e lib/eval-config.nix: Directly use the upstream one
Though with *our* modules.

With https://github.com/NixOS/nixpkgs/pull/82960 this fixes the
regression from https://github.com/NixOS/nixpkgs/pull/82751.
2020-03-19 16:29:44 -04:00
Samuel Dionne-Riel
e9b6c145fa imageBuilder.makeMBR: Fixes bug with gap
The size wasn't fixed after aligning the result, this dividing the sizes
by as the alignment.
2019-11-21 22:26:10 -05:00
Samuel Dionne-Riel
683ce12eb7 Removes custom porcelain...
Let's rely on nix-build mainly.
2019-09-21 22:45:08 -04:00
Samuel Dionne-Riel
a04255b4eb image-builder: FIXME disables ext4 fsck...
I *think* there is a new check that wasn't previously (in 19.03) part of
e2fsck. This is now causing the check to fail.

FIXME : figure out a way to disable the check, or make the image comply.
2019-09-21 13:58:03 -04:00
Samuel Dionne-Riel
9264c6afc7 image-builder: WIP adds makeGPT
TODO : review makeMBR
TODO : share common code into makeFromSfdisk
TODO : add tests
2019-09-21 13:57:12 -04:00
Samuel Dionne-Riel
4e0b281d99 misc. removes unneeded comments 2019-09-21 13:56:51 -04:00
Samuel Dionne-Riel
565d938228 image-builder: Adds a test involving a real bootable image
This creates a disk image that acts *just about* like how the NixOS
sd_image acts. Though it is much less useful as there is no system, not
even an initrd.
2019-09-05 00:39:42 -04:00
Samuel Dionne-Riel
039a166937 image-builder: Adds support for adding gaps.
This is a "tangible" item you add to a `partitions` list. The partition
scheme will know what to do with a gap item.
2019-09-05 00:39:42 -04:00
Samuel Dionne-Riel
ed10664fc9 image-builder: makeFAT32: Let mkfs.fat set the FAT type
It turns out the warnings it spits out when forcing FAT32 with too few
clusters is not for nothing. At the very least the Raspberry Pi 3B does
not like the forced FAT 32. Though, it was validated that a large enough
FAT32 partition is fine with the Raspberry Pi 3B.
2019-09-04 23:07:19 -04:00
Samuel Dionne-Riel
6f52ba48d9 image-builder: Adds in-depth tests for ext4 images 2019-09-04 20:21:14 -04:00
Samuel Dionne-Riel
49d61da7f6 image-build: Fixes test broken by previosu commit
The size of the filesystem has changed because the way it is computed
has changed.
2019-09-04 20:18:21 -04:00
Samuel Dionne-Riel
f777cbdadb image-builder: makeExt4: implements minimal resizing
The algorithms inside `make_ext4fs` can be followed, but it ends up
being a bit complex. I did not figure out all variables, but the amount
of them made me reluctant to implement it as a complte formula.

Instead, I looked at the actual usable space using `df` and mapped it in
a spreadsheet. With the knowledge from actively looking at the source
code, and other data, it is known that the lookup table will work, while
not be ideal.

The fudge factor starting at 256MiB is about stable, but there is a
slight downward deviation at 512MiB, which is why 512MiB was used. The
downward deviation was not observed in other values.

Here's the table as computed.

```
MIB	Fudge
5	0.84609375
8	0.5419921875
16	0.288818359375
32	0.1622314453125
64	0.09893798828125
128	0.067291259765625
256	0.0518646240234375
512	0.05208587646484375
1024	0.048187255859375
2048	0.04060554504394531
4096	0.03718090057373047
```

The difference from .52% to .37% is negligible for 0.5 vs. 4 GiB is
annoying me. The lookup table could be changed to include all known
values instead, I guess.
2019-09-04 20:11:12 -04:00
Samuel Dionne-Riel
f9a719d00f image-builder: makeFAT32: Adjusts sizes
The factor was derived from first making a few test images, finding
there was a common thread, and then looking at what parts of FAT32 were
generated, and how they were generated. That was fun. (Yes, really.)
2019-09-04 00:49:13 -04:00
Samuel Dionne-Riel
b4600a4d23 image-builder: makeFilesystem: prepares API for adjusting sizes 2019-09-04 00:48:58 -04:00
Samuel Dionne-Riel
0f790274da image-builder: makeMBR: work with tiny partitions 2019-09-04 00:47:10 -04:00
Samuel Dionne-Riel
a5cdf69a6a image-builder: Adds alignment tests 2019-09-04 00:47:10 -04:00
Samuel Dionne-Riel
e44bd5ca1a image-builder: makeMBR: Align partitions 2019-09-03 16:52:56 -04:00
Samuel Dionne-Riel
223f6edb1b image-builder: clean-up in makeMBR 2019-09-02 17:48:03 -04:00
Samuel Dionne-Riel
bb095d2f14 image-builder: makeExt4: implements blockSize
The value chosen is the current default from make_ext4fs.

This makes the current tests still valid.
2019-09-02 17:48:03 -04:00
Samuel Dionne-Riel
e008cb416c image-builder: makeFAT32: use block size
In addition, present the sector size as an option.

The sector size is required to set a block size in bytes, so giving the
option to the end-user is probably for the best.

The values here were chosen to keep the builder compatible with the
existing tests.

In addition, the values are quite optimized for smaller filesystem
images, e.g. building a FIRMWARE partition for the Raspberry Pi.
2019-09-02 17:48:03 -04:00
Samuel Dionne-Riel
c0001af576 image-builder: makeFilesystem: reviews minimum size with blockSize
First of all, `du -s` will always combine the sizes into the multiple of
its given --block-size, so 4×1 byte files will show up as 1 block size
(assuming a block size > 4). The expected size would have been at least
one block size per file, so for 512, 512×4 thus 2048.

With this change, we sum the sizes ourselves.

This adds a new requirement to the filesystems, that they pass the block
size to the generic builder, though this is good, as it will increases
reproducibility. In addition, filesystems can present the option to
users, allowing the user to set their block sizes as expected.
2019-09-02 16:29:07 -04:00