about summary refs log tree commit diff
path: root/nixos/lib
AgeCommit message (Collapse)AuthorFilesLines
2021-06-14Merge pull request #86967 from jakobrs/more-general-fsbeforeKim Lindberger1-2/+24
nixos/lib/utils: Add `fileSystems.<name>.depends` option and generalise fsBefore (fixes #86955)
2021-06-08nixos/lib, nixos/filesystems: Make fsBefore more stable, and add `depends` ↵jakobrs1-2/+24
option
2021-06-06nixos/tests/test-driver: cleanup "dead" code (USE_SERIAL)David Arnold2-3/+1
At nixpkgs root: `rg redirectSerial ./` does not result in any other match nor does `rg USE_SERIAL ./` except for an unrelated match in: pkgs/tools/graphics/argyllcms/default.nix
2021-06-05nixos/test-driver: Run commands with error handlingtalyz1-1/+1
Bash's standard behavior of not propagating non-zero exit codes through a pipeline is unexpected and almost universally unwanted. Default to setting `pipefail` for the command being run; it can still be turned off by prefixing the pipeline with `set +o pipefail` if needed. Also, set `errexit` and `nonunset` options to make the first command of consecutive commands separated by `;` fail, and disallow dereferencing unset variables respectively.
2021-06-03make-test-python: disallow aliasesFrederik Rietdijk1-1/+7
When importing Nixpkgs within Nixpkgs, we should not consider aliases to ensure we don't rely on them internally. There are probably more places that need to be converted.
2021-06-03Merge pull request #125372 from Synthetica9/shell_interactDomen Kožar1-0/+11
nixos/tests/test-driver: add shell_interact
2021-06-03nixos/tests/test-driver: make it clear when shell is readyPatrick Hilhorst1-0/+1
Co-authored-by: Domen Kožar <domen@enlambda.com>
2021-06-02nixos/tests/test-driver: document shell_interactPatrick Hilhorst1-1/+1
2021-06-02nixos/tests/test-driver: add shell_interactPatrick Hilhorst1-0/+10
2021-05-31nixos/lib/make-ext4-fs: Fix: `resize2fs -M' can leave insufficient slackDamien Diederen1-5/+3
The root filesystem resizing step, `resize2fs -M', does not provide any control over the amount of slack left in the result. It can produce an arbitrarily tight fit, depending on how well the payload aligns with ext4 data structures. This is problematic, as NixOS must create a few files and directories during its first boot, before the root is enlarged to match the size of the containing SD card. An overly tight fit can cause failures in the first stage: mkdir: can't create directory '/mnt-root/proc': No space left on device or in the second stage: install: cannot create directory '/var': No space left on device A previous version of `make-ext4-fs' (before PR #79368) was explicitly "reserving" 16 MiB of free space in the final filesystem. Manually calculating the size of an ext4 filesystem is a perilous endeavor, however, and the method it employed was apparently unreliable. Reverting is consequently not a good option. A solution would be to create some sort of "balloon" occupying inodes and blocks in the image prior to invoking `resize2fs -M', and to remove these temporary files/directories before the compression step. This changeset takes the simpler approach of simply dropping the resizing step. Note that this does *not* result in a larger image in general, as the current procedure does not truncate the `.img' file anyway. In fact, it has been observed to yield *smaller* compressed images---probably because of some "noise" left after resizing. E.g., before-vs-after: -r--r--r-- 2 root root 607M 1. Jan 1970 nixos-sd-image-21.11pre-git-x86_64-linux.img.zst -r--r--r-- 2 root root 606M 1. Jan 1970 nixos-sd-image-21.11pre-git-x86_64-linux.img.zst
2021-05-30nixos/test-driver: mention the elapsed time when it times outAndreas Rammhold1-3/+3
For now you had to know that the actions are retried for 900s when seeing an error like > Traceback (most recent call last): > File "/nix/store/dbvmxk60sv87xsxm7kwzzjm7a4fhgy6y-nixos-test-driver/bin/.nixos-test-driver-wrapped", line 927, in run_tests > exec(tests, globals()) > File "<string>", line 1, in <module> > File "<string>", line 31, in <module> > File "/nix/store/dbvmxk60sv87xsxm7kwzzjm7a4fhgy6y-nixos-test-driver/bin/.nixos-test-driver-wrapped", line 565, in wait_for_file > retry(check_file) > File "/nix/store/dbvmxk60sv87xsxm7kwzzjm7a4fhgy6y-nixos-test-driver/bin/.nixos-test-driver-wrapped", line 142, in retry > raise Exception("action timed out") > Exception: action timed out in your (hydra) build failure. Due to the absence of timestamps you were left guessing if the machine was just slow, someone passed a low timeout value (which they couldn't until now) or whatever might have happened. By making this error a bit more descriptive (by including the elapsed time) these hopefully become more useful.
2021-05-21Merge pull request #123823 from misuzu/test-driver-usb-boot-speedupJacek Galowicz1-1/+2
nixos/test-driver: use usb-ehci controller instead of piix3-usb-uhci
2021-05-20nixos/test-driver: use usb-ehci controller instead of piix3-usb-uhcimisuzu1-1/+2
On my system this change offers ~5X speed up of nixosTests.boot.biosUsb and nixosTests.boot.uefiUsb tests.
2021-05-20Merge pull request #123052 from xoe-labs/da-test-vm-innteractive-log-switchRobert Hensing2-7/+28
nixos/testing: add interactive serial stdout logs switch and dim them
2021-05-20Merge pull request #117275 from hercules-ci/nixosTest-remove-nixpkgs-commit-hashRobert Hensing1-0/+7
nixosTest: Make system.nixos.revision constant
2021-05-14nixos/testing: add interactive serial stdout logs switch and dim themDavid Arnold2-7/+28
2021-05-09nixos/testing-python.nix: Move makeWrapper to nativeBuildInputsRobert Hensing1-1/+1
2021-05-09nixos/testing: Set up scope for testScript linterRobert Hensing1-1/+16
Our test driver exposes a bunch of variables and functions, which pyflakes doesn't recognise by default because it assumes that the test script is executed standalone. In reality however the test driver script is using exec() on the testScript. Fortunately pyflakes has $PYFLAKES_BUILTINS, which are the attributes that are globally available on all modules to be checked. Since we only have one module, using this environment variable is fine as opposed to my first approach to this, which tried to use the unstable internal API of pyflakes. The attributes are gathered by the main derivation of the test driver, because we don't want to end up defining a new attribute in the test driver module just to being confused why using it in a test will result in an error. Another way we could have gathered these attributes would be in mkDriver, which is where the linting takes place. However, we do have a different set of Python dependencies in scope and duplicating these will again just cause confusion over having it at one location only. Signed-off-by: aszlig <aszlig@nix.build> Co-Authored-By: aszlig <aszlig@nix.build>
2021-05-09nixos/testing-python.nix: Expose driverRobert Hensing1-1/+3
(cherry picked from commit a2c9220568648b4528154ebd8e657add243ed0b4)
2021-05-09nixos/testing: Switch from black to pyflakesaszlig1-1/+1
So far, we have used "black" for formatting the test code, which is rather strict and opinionated and when used inline in Nix expressions it creates all sorts of trouble. One of the main annoyances is that when using strings coming from Nix expressions (eg. store paths or option definitions from NixOS modules), completely unrelated changes could cause tests to fail, since eg. black wants lines to be broken. Another downside of enforcing a certain kind of formatting is that it makes the Nix expression code inconsistent because we're mixing two spaces of indentation (common in nixpkgs) with four spaces of indentation as defined in PEP-8. While this is perfectly fine for standalone Python files, it really looks ugly and inconsistent IMO when used within Nix strings. What we actually want though is a linter that catches problems early on before actually running the test, because this is *actually* helping in development because running the actual VM test takes much longer. This is the reason why I switched from black to pyflakes, because the latter actually has useful checks, eg. usage of undefined variables, invalid format arguments, duplicate arguments, shadowed loop vars and more. Signed-off-by: aszlig <aszlig@nix.build> Closes: https://github.com/NixOS/nixpkgs/issues/72964
2021-05-04nixos/test-driver: Allow interactive testing on Wayland-only setupsMichael Weiss1-1/+2
On my system I have XWayland disabled and therefore only WAYLAND_DISPLAY is set. This ensures that the graphical output will still be enabled on such setups (both Wayland and X11 are supported by the viewer).
2021-05-03testing-python.nix: document runTests pos argumentRobert Hensing1-2/+7
2021-05-03Merge pull request #112504 from hercules-ci/fix-nixosTest-meta-positionRobert Hensing1-2/+9
nixosTest: fix meta.position
2021-04-28treewide: use lib.warnIf where appropriateAlyssa Ross1-3/+1
2021-04-26Merge pull request #120489 from samueldr/fix/make-disk-image-auto-sizeLassulus1-6/+69
Fix make disk image automatic size
2021-04-26Merge pull request #120251 from mschwaig/fix-make-disk-image-for-efi-2Lassulus1-0/+3
make-disk-image: fix broken EFI image builds
2021-04-26make-disk-image: fix broken EFI image buildsMartin Schwaighofer1-0/+3
Work around missing /dev files inside runInLinuxVM by creating a symlink before calling nixos-enter. This fixes https://github.com/NixOS/nixpkgs/issues/93381. I ran into this issue when trying to create a VMware image that boots from EFI. Thanks @colemickens for reporting this and @danielfullmer for fixing the same thing in in qemu-vm.nix (37676e77cb5adab936606838d6465faafda54f61) and explaining what the issue was.
2021-04-25make-disk-image: Round image size to the next mebibyteSamuel Dionne-Riel1-2/+12
This ensures the following gptfdisk warning won't happen: ``` Warning: File size is not a multiple of 512 bytes! Misbehavior is likely! ``` Additionally, helps towards aligning the partition to be more optimal for the underlying storage. It is actually impossible to align for the actual underlying storage optimally because we don't know what the block device will be! But aligning on 1MiB should help.
2021-04-24make-disk-image: Account for reserved disk spaceSamuel Dionne-Riel1-2/+19
This is a bit of a thorny issue. See, the actual `diskSize` variable is for the *total* disk size, not for the filesystem! The automatic numbers are meant to compute the *filesystem* required space. So we have to add any other reserved space! We have different requirements for reserved space. E.g. there could be none (when it's actually a filesystem image). There could also be 1MiB for alignment for an MBR image, legacy+gpt needs 2MiB, then GPT with an ESP ("bootSize") needs to take the boot partition and GPT size into account too! Though luckily(?) for this latter situation we can cheat! As noted in the change, `bootSize` is NOT the boot partition size. It is actually the offset where the target filesystem starts.
2021-04-24make-disk-image: Account for the ext4 reserved spaceSamuel Dionne-Riel1-6/+20
Reserved space includes: - inodes space in use (2 blocks per) - about 5.2% of the space The 5.2% reserved space was computed empirically when working on a previous EXT4 image builder. It seems to stabilize around 5% even for much larger filesystems.
2021-04-24make-disk-image: Get proper size for automatic sizeSamuel Dionne-Riel1-6/+28
On some filesystems, `du` without `--apparent-size` will not give the actual size for a file. Using `--apparent-size` will give us the actual file size. Though, this is not actually correct still. 1000 × 1 bytes is not 1000 bytes. It is 1000 × ceil(filesize/blockSize)*blockSize. So instead of adding up the actual file sizes. We are adding up the block sizes. Note that this also changes the builder to work with *bytes*, rather than with any other units. Doing maths on bytes is less likely to go awry than doing it on other units.
2021-04-23nixos/test-driver: use a variety of different Tesseract settings for OCRLuke Granger-Brown1-31/+48
When performing OCR, some of the Tesseract settings perform better than others on a variety of different workloads, but they mostly take ~negligible incremental time to run compared to the overhead of running the ImageMagick filters. After this commit, we try using all three of the current Tesseract models (classic, LSTM, and classic+LSTM) to generate output text. This fixes chromium-90's tests at release-20.09, and should make cases where you're looking for *specific* text better, with the tradeoff of running Tesseract multiple times. To make it sensible to cherrypick this into release-20.09, this doesn't change the existing API surface for the test driver. In particular, get_screen_text continues to have the existing behaviour.
2021-04-13nixosOptionsDoc: add markdown formattingPacman991-0/+26
2021-03-23nixosTest: fix meta.positionRobert Hensing1-2/+9
2021-03-22nixosTest: Make system.nixos.revision constantRobert Hensing1-0/+7
Make the revision metadata constant, in order to avoid needless retesting. The human version (e.g. 21.05-pre) is left as is, because it is useful for external modules that test with e.g. nixosTest and rely on that version number.
2021-03-05nixos/qemu-flags: add ppc64Ryan Burns1-1/+3
* PPC uses ttyAMA0 as its serial device, similar to ARM. * PowerNV is a typical platform for testing and distro development
2021-02-28squashfs: use -no-hardlinks for reproducible squashfs images (#114454)Arnout Engelen1-1/+1
the nix store may contain hardlinks: derivations may output them directly, or users may be using store optimization which automatically hardlinks identical files in the nix store. The presence of these links are intended to be a 'transparent' optimization. However, when creating a squashfs image, the image will be different depending on whether hard links were present on the filesystem, leading to reproducibility problems. By passing '-no-hardlinks' to mksquashfs the files are stored as duplicates in the squashfs image. Since squashfs has support for duplicate files this does not lead to a larger image. For more details see https://github.com/NixOS/nixpkgs/issues/114331
2021-01-29Merge pull request #67493 from clefru/make-disk-imageJörg Thalheim1-1/+2
2021-01-22Update nixos/lib/make-disk-image.nixclefru1-1/+1
Co-authored-by: Alyssa Ross <hi@alyssa.is>
2020-12-21Merge pull request #104292 from fgaz/image-contentsLéo Gaspard1-5/+43
nixos/lib/make-disk-image.nix: support content mode and ownership
2020-12-20nixos/lib/make-disk-image.nix: support content mode and ownershipFrancesco Gazzetta1-5/+43
2020-12-09nixos/lib/testing-python.nix: Wire up passthruRobert Hensing1-1/+4
2020-11-24utillinux: rename to util-linuxGraham Christensen1-2/+2
2020-11-21nixos test-driver: fix single line docstrings, fixes #104467Frederik Rietdijk1-4/+2
Single line docstrings should have the """ on a single line according to PEP 8. It seems support for this landed in the latest version of Black.
2020-11-18nixos: use nativeBuildInputs in make- iso9660-image and system-tarballEmery Hemingway2-2/+2
The tools used to create iso9660 images and tarballs are independent of the platform of the closure contained within.
2020-10-30make-disk-image: support legacy+gptGraham Christensen1-1/+15
2020-10-27nixos/tests: fix wrong inherit that passes on the nodes attrsAndreas Rammhold1-1/+1
The hydra tarball step would fail due to the nodes attribute not being properly inherited. Since we can't execute all the tests and release steps locally anymore (thanks to the JSONification and faster hydra eval) these errors will probably keep in appearing. This is hopefully the last of those introduced by me test runner refactoring. Error was seen on hydra (https://hydra.nixos.org/build/129282411): > unpacking sources > unpacking source archive /nix/store/bp95x52h6nv3j8apxrryyj2rviw682k1-source > source root is source > patching sources > autoconfPhase > No bootstrap, bootstrap.sh, configure.in or configure.ac. Assuming this is not an GNU Autotools package. > configuring > release name is nixpkgs-21.03pre249116.1088f059401 > git-revision is 1088f059401c43450ed85e4a4ec3f57dc8aa992f > building > no Makefile, doing nothing > running tests > warning: you did not specify '--add-root'; the result might be removed by the garbage collector > warning: you did not specify '--add-root'; the result might be removed by the garbage collector > checking Nixpkgs on i686-linux > checking Nixpkgs on x86_64-linux > checking Nixpkgs on x86_64-darwin > checking eval-release.nix > trace: `mkStrict' is obsolete; use `mkOverride 0' instead. > trace: `lib.nixpkgsVersion` is deprecated, use `lib.version` instead! > trace: warning: lib.readPathsFromFile is deprecated, use a list instead > trace: Warning: `showVal` is deprecated and will be removed in the next release, please use `traceSeqN` > trace: lib.zip is deprecated, use lib.zipAttrsWith instead > checking find-tarballs.nix > trace: `mkStrict' is obsolete; use `mkOverride 0' instead. > trace: `lib.nixpkgsVersion` is deprecated, use `lib.version` instead! > trace: warning: lib.readPathsFromFile is deprecated, use a list instead > trace: Warning: `showVal` is deprecated and will be removed in the next release, please use `traceSeqN` > trace: lib.zip is deprecated, use lib.zipAttrsWith instead > error: while evaluating anonymous function at /build/source/maintainers/scripts/find-tarballs.nix:6:1, called from undefined position: > while evaluating 'operator' at /build/source/maintainers/scripts/find-tarballs.nix:27:16, called from undefined position: > while evaluating 'immediateDependenciesOf' at /build/source/maintainers/scripts/find-tarballs.nix:39:29, called from /build/source/maintainers/scripts/find-tarballs.nix:27:44: > while evaluating anonymous function at /build/source/lib/attrsets.nix:234:10, called from undefined position: > while evaluating anonymous function at /build/source/maintainers/scripts/find-tarballs.nix:40:37, called from /build/source/lib/attrsets.nix:234:16: > while evaluating 'derivationsIn' at /build/source/maintainers/scripts/find-tarballs.nix:42:19, called from /build/source/maintainers/scripts/find-tarballs.nix:40:40: > while evaluating 'canEval' at /build/source/maintainers/scripts/find-tarballs.nix:48:13, called from /build/source/maintainers/scripts/find-tarballs.nix:43:9: > while evaluating the attribute 'nodes' at /build/source/nixos/lib/testing-python.nix:195:23: > attribute 'nodes' missing, at /build/source/nixos/lib/testing-python.nix:193:16 > build time elapsed: 0m0.122s 0m0.043s 17m51.526s 0m56.668s > builder for '/nix/store/96rk3c74vrk6m3snm7n6jhis3j640pn4-nixpkgs-tarball-21.03pre249116.1088f059401.drv' failed with exit code 1
2020-10-25nixos/tests: fix runInMachineAndreas Rammhold1-1/+1
In 5500dc8 we introduced the --keep-vm-state flag and defaulted to that flag not being set. This lead to the `runInMachine` tests not longer working and that going unnoticed for quite some time now.
2020-10-25nixos/tests: fix testDriver reference in runInMachine functionAndreas Rammhold1-1/+2
In a previous commit I broke this as there is no longer one testDriver but only a function to generate one based on some QEMU inputs.
2020-10-25nixos/tests: format the testing-python.nix file more consistenlyAndreas Rammhold1-98/+106