Commit graph

2074 commits

Author SHA1 Message Date
Florian Klink 7c119675a3
Merge pull request #179002 from klemensn/move-passwdEntry-type
move passwdEntry type
2022-07-22 14:16:57 +07:00
K900 c9183d3738 nixos/systemd: make sure all the device nodes are created in stage1
The ConditionFileNotEmpty override patch wasn't correct for stage1, which
does have the modules in /lib. So, remove the patch and set
the right path with overrides in the final system.

Also, make sure systemd-tmpfiles-setup-dev is pulled in to create
all the necessary symlinks.
2022-07-22 10:01:21 +03:00
Netali 93132dc09c
nixos/pam: refactor pam_mount unmounting fix 2022-07-22 04:17:14 +02:00
Robert Hensing ec3e1c6a3a nixos/documentation: Remove systemd/initrd dependency
Working towards a unit-testable documentation module.
2022-07-21 15:32:10 +02:00
pennae 7388711363 nixos/resolved: convert option docs to MD 2022-07-19 16:23:57 +02:00
Sandro Jäckel 4396fd615c
nixos/systemd-boot: remove default log message if nothing changes 2022-07-17 21:46:50 +02:00
Bernardo Meurer c6b0888a86
Merge pull request #180991 from aij/raspberrypi-bootloader-config.txt
raspberrypi-bootloader: Update doc URL for config.txt options
2022-07-10 14:09:43 -07:00
Sandro 366683965e
Merge pull request #166308 from ncfavier/wg-resolvconf
nixos/resolvconf: allow different implementations
2022-07-10 21:00:00 +02:00
Ivan Jager 34aa4fe7a9 raspberrypi-bootloader: Update doc URL for config.txt options
The old URL was redirecting to more generic Rasbperry Pi documentation.
2022-07-10 06:58:32 -05:00
Et7f3 6b820ecfab
nixos: systemd: add missing sliceToUnit (#179841)
Seem to be omitted in 022b4209a3 (diff-5ea4693beb4bdd8f7efcdd3204ceea67c86f59b3d1c28cde063ddf03e1d20fbfL29).
2022-07-02 18:56:53 +03:00
Piotr Dobrowolski 348b88545c nixos/plymouth: fix theme dependency resolution in systemd stage 1
Some plymouth themes use assets of others, like is the case with our
default bgrt depending on spinner. Missing assets would cause the
splashscreen to not render at all in stage 1.

Preliminary dependency resolution code seemed to be broken, and this
should fix it.

Only direct dependencies of selected theme are pulled in.
2022-06-29 21:38:34 +02:00
Klemens Nanni 30c36b4706 nixos/systemd-stage-1: use types.passwdEntry in emergencyAccess
`boot.initrd.systemd.emergencyAccess` expects passwd(5) formatted
strings, hence `singleLineStr` is too broad.

Use the same type as `users.users.*.hashedPassword` to ensure
consistency across all options where password hashes are used.

From `modules/config/users-groups.nix`:
```
       hashedPassword = mkOption {
         type = with types; nullOr (passwdEntry str);
       ...
       };
```
2022-06-25 16:34:49 +04:00
Naïm Favier 203696f098
nixos/resolvconf: add package
Expose the package that provides the system-wide `resolvconf` command
(either openresolv or systemd) to allow implementation-agnostic modules.
2022-06-21 22:58:43 +02:00
Sandro Jäckel 3df045e6d5
nixos/systemd: use cfg.package in systemPackages to avoid confusion 2022-06-09 22:44:28 +02:00
Matthias Treydte ff24f484af nixos/systemd-boot: fix systemd-boot-builder refusing to update
Handling of the string length condition in should_update
was broken, as evident with the log message

> leaving systemd-boot 246 in place (250.4 is not newer)

Discussion with @mweinelt came to the conclusion
that Python's "<" operator already does what we need,
so the should_update function can be dropped.

Fixes a30de3b849
2022-06-01 11:49:07 +02:00
Florian Klink f12a263b69
Merge pull request #172707 from klemensn/init-zfs-mount-options
nixos/stage-1: Fix library path in libraries, fix ZFS mount options
2022-05-30 10:51:17 +02:00
Matthias Treydte a30de3b849 nixos/systemd-boot: fix systemd-boot-builder dowgrade to fail
Since, 4ddc78818e systemd-boot-builder
is broken in two ways:

  * if no systemd-boot is currently installed *and* the NIXOS_INSTALL_BOOTLOADER
    env variable is not set, it will try to run "bootctl update", which will fail
  * if the currently installed systemd-boot version is newer than the version
    we're about to install, it will also try to run "bootctl update", which will fail

This patch changes the behaviour,

  * for the first case to still fail, but not even bother to try running
    "bootctl update" and instead erroring out with an exception
  * for the second case to leave the newer version in place, restoring
    the pre - 4ddc78818e behaviour

To do the proper version check a new "should_update" helper function was introduced,
mimicing the compare_product C function from bootctl. If the following systemd
issue gets resolved, we would have a nice way to get rid of this function:

> https://github.com/systemd/systemd/issues/23450

This change allows to again switch to a different NixOS configuration which contains
an older systemd-boot.

Co-authored-by: Martin Weinelt <mweinelt@users.noreply.github.com>
2022-05-28 13:18:21 +02:00
Klemens Nanni 9eb704b65a nixos/stage-1: Zap no longer needed LD_LIBRARY_PATH
The previous commit properly adjusts all library paths, thus no need to
forcefully adjust the path at runtime any longer.
2022-05-26 22:17:02 +02:00
Klemens Nanni d33e52b253 nixos/stage-1: Fix library path in libraries also
`extra-utils` composes the set of programs and libraries needed by

1. copying over all programs
2. copying over all libraries any program directly links against
3. set the runtime path for every program to the library directory

It seems that this approach misses the case where a library itself links
against another library.  That is to say, `extra-utils` assumes that
either only progams link against libraries or that every library linked
to by a library is already linked to by a program.

`mount.zfs` linking against `libcrypto`, in turn linking against `libdl`
shows how the current approach falls short:

```
$ objdump -p $(which mount.zfs) | grep NEEDED | grep -e libdl -e libcrypto
  NEEDED               libcrypto.so.1.1
$ ldd (which mount.zfs) | grep libdl
        libdl.so.2 => /nix/store/ybkkrhdwdj227kr20vk8qnzqnmj7a06x-glibc-2.34-115/lib/libdl.so.2 (0x00007f9967a9a000
```

Using `mount.zfs` directly in stage 1 init still works since
`LD_LIBRARY_PATH` overrides this (as intended).

util-linux's `mount` however executes `mount.zfs` with LD_LIBRARY_PATH
removed from its environment as can be seen with strace(1) in an
interactive stage 1 init shell (`boot.shell_on_fail` kernel parameter):

```
 # env -i LD_LIBRARY_PATH=$LD_LIBRARY_PATH $(which strace) -ff -e trace=/exec -v -qqq $(which mount) /mnt-root
execve("/nix/store/3gqbb3swgiy749fxd5a4k6kirkr2jr9n-extra-utils/bin/mount", ["/nix/store/3gqbb3swgiy749fxd5a4k"..., "/mnt-root"], ["LD_LIBRARY_PATH=/nix/store/3gqbb"...]) = 0
[pid  1026] execve("/sbin/mount.zfs", ["/sbin/mount.zfs", "<redacted>", "/mnt-root", "-o", "rw,zfsutil"], []) = 0
/sbin/mount.zfs: error while loading shared libraries: libdl.so.2: cannot open shared object file: No such file or directory
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=1026, si_uid=0, si_status=127, si_utime=0, si_stime=0} ---
```

env(1) is used for clarity (hence subshells for absoloute paths).

While `mount` uses the right library path, `mount.zfs` is stripped of
it, so ld.so(8) fails resolve `libdl` (as required by `libcrypto`).

To fix this and not rely on `LD_LIBRARY_PATH` to be set, fix the library
path inside libraries as well.

This finally mounts all ZFS filesystems using `zfsutil` with correct and
intended mount options.
2022-05-26 22:17:02 +02:00
Klemens Nanni 4b045c7066 nixos/stage-1: Remove redundant symlink check
find(1)'s test `-type f` already excludes symbolic links, so `test -L`
will never return false for found files.
2022-05-26 22:17:02 +02:00
Klemens Nanni de77849ad6 nixos/stage-1: Account for hardcoded executable paths
At least pkgs/os-specific/linux/util-linux/default.nix uses
```
    "--enable-fs-paths-default=/run/wrappers/bin:/run/current-system/sw/bin:/sbin"
```

which does not cover stage 1 init's PATH as all executables are put
under /bin/.

Fix util-linux's `mount` usage by symlinking /sbin to it.
2022-05-26 22:17:02 +02:00
Klemens Nanni 9553106832 nixos/stage-1: Ensure correct ZFS mount options
Consider ZFS filesystems meant to be mounted with zfs.mount(8), e.g.
```
config.fileSystems."/media".options = [ "zfsutil" ];
config.fileSystems."/nix".options = [ "zfsutil" ];
```

`zfsutil` uses dataset properties as mount options such that zfsprops(7)
do not have to be duplicated in fstab(5) entries or manual mount(8)
invocations.

Given the example configuation above, /media is correctly mounted with
`setuid=off` translated into `nosuid`:

```
$ zfs get -Ho value setuid /media
off
$ findmnt -t zfs -no options /media
rw,nosuid,nodev,noexec,noatime,xattr,posixacl
```

/nix however was mounted with default mount(8) options:
```
$ zfs get -Ho value setuid /nix
off
$ findmnt -t zfs -no options /nix
rw,relatime,xattr,noacl
```

This holds true for all other ZFS properties/mount options, including
`exec/[no]exec`, `devices/[no]dev`, `atime/[no]atime`, etc.

/nix is mounted using BusyBox's `mount` during stage 1 init while /media
is mounted later using proper systemd and/or util-linux's `mount`.

Tracing stage 1 init showed that BusyBox never tried to execute
mount.zfs(8) as intended by `zfsutil`.

Replacing it with util-linux's `mount` and adding the mount helper
showed attempts to execute mount.zfs(8).

Ensure ZFS filesystems are mounted with correct options iff `zfsutil` is
used.
2022-05-26 22:16:53 +02:00
Martin Weinelt 6d8f8a7b46
Merge pull request #174090 from helsinki-systems/fix/plymouth
nixos/plymouth: Fix non-systemd initrd boot
2022-05-23 17:08:02 +02:00
Janne Heß 2cc4bf9427
nixos/plymouth: Fix non-systemd initrd boot 2022-05-23 11:17:21 +02:00
Klemens Nanni cbcc746f8f nixos/systemd: Package only built component units
Account for all `with*` options causing their respective unit files to
not be built, just like the current code `withCryptsetup` already does.

This fixes build errors like the following:
```
missing /nix/store/5fafsfms64fn3ywv274ky7arhm9yq2if-systemd-250.4/example/systemd/system/systemd-importd.service
error: builder for '/nix/store/67rdli5q5akzwmqgf8q0a1yp76jgr0px-system-units.drv' failed with exit code 1
```

Found by using a customised systemd package as follows:
```
systemd.package = pkgs.systemd-small;

nixpkgs.config.packageOverrides = pkgs: {

  "systemd-small" = pkgs.systemd.override {
    withImportd = false;
    withMachined = false;
    ...
  };

};
```
2022-05-16 16:52:25 +02:00
Alyssa Ross 85d792a928
nixos: don't put non-firmware in hardware.firmware
These two packages don't have a lib/firmware directory, so putting
them in hardware.firmware has no effect.  This will become a hard
error once firmware compression is implemented.

(In the case of Linux, the firmware was all moved to linux-firmware.)
2022-05-12 15:17:51 +00:00
Janne Heß e6fb1e63d1
Merge pull request #171650 from helsinki-systems/feat/config-systemd-package
treewide: pkgs.systemd -> config.systemd.package
2022-05-09 10:23:04 +02:00
Maximilian Bosch f0bb39d4b7
Merge pull request #167327 from lheckemann/networkd-usedhcp
nixos/networkd: reimplement useDHCP in a sensible way
2022-05-07 00:05:44 +02:00
Bernardo Meurer c4ad7519ef
Merge pull request #170136 from helsinki-systems/feat/systemd-stage-1-plymouth
nixos/plymouth: Add systemd stage 1 support
2022-05-05 14:49:26 -07:00
Sandro 836c52e625
Merge pull request #167208 from devplayer0/fix/missing-systemd-nspawn-options
nixos/systemd/nspawn: Add missing nspawn unit options
2022-05-05 22:58:59 +02:00
Janne Heß 57cd07f3a9
treewide: pkgs.systemd -> config.systemd.package
This ensures there is only one systemd package when e.g. testing the
next systemd version.
2022-05-05 20:00:31 +02:00
Rick van Schijndel ec4686ee14
Merge pull request #171247 from K900/systemd-boot-coreutils-mktemp
systemd-boot: use mktemp from coreutils in installer
2022-05-03 19:15:55 +02:00
Luflosi deed4a3d6c
nixos/stage-1: remove dead code
This special case for Btrfs was added in 51bc82960a. One year later beddd36c95 added code to skip the fsck entirely if the filesystem is Btrfs. This made the `if` statement unnecessary.
2022-05-03 16:15:51 +02:00
Janne Heß 2edce50847
Merge pull request #171134 from helsinki-systems/feat/make-initrd-ng-strip
makeInitrdNG: Strip more and remove output
2022-05-03 09:41:22 +02:00
K900 5a2f238b9a systemd-boot: use mktemp from coreutils in installer
People running nixos-install in non-NixOS environments
occasionally run into the mktemp builtin not being loaded
into bash (yes, even NixOS' bash). Rather than try and
figure out why exactly that is happening, just use a known
good mktemp from coreutils.
2022-05-02 15:44:55 +03:00
K900 5d02b86888 systemd-in-stage1: include firmware in initrd
duh.
2022-05-02 15:41:14 +03:00
Janne Heß bc53ac7753
nixos/systemd-shutdown: Remove unneeded binaries 2022-05-01 17:06:15 +02:00
Bernardo Meurer 78f6f77962
Merge pull request #169113 from ElvishJerricco/systemd-stage-1-installer-tests
nixos: Installer tests for systemd stage 1
2022-04-30 13:18:57 -07:00
Bernardo Meurer e1aa795705
Merge pull request #171024 from helsinki-systems/feat/systemd-stage-1-less-binaries
nixos/systemd-stage-1: Remove unnecessary binaries
2022-04-30 11:30:43 -07:00
Janne Heß 0411b51a00
nixos/systemd-stage-1: Remove unnecessary binaries
We can make the growfs and makefs binaries conditional because we know
if we'll need them. Also move the cryptsetup generator to the luksroot
so it's not included when not needed.

We drop some generators altogether: systemd-getty-generator because we
don't have getty anyway in stage 1, systemd-system-update-generator
because we don't use that logic in NixOS and
systemd-veritysetup-generator because stage 1 has no veritysetup support
(yet) and if it had, we still wouldn't want to include the generator
unconditionally.
2022-04-30 14:50:02 +02:00
Janne Heß fa2c9b41d4
nixos/systemd-stage-1: Add initrd secrets support 2022-04-30 11:41:27 +02:00
Maximilian Bosch 9c18662612
nixos/networkd: allow RouteMetric for IPv6AcceptRA
According to `systemd.network(5)` of systemd v249 this is a valid
option.

Fixes evaluation of the wildcard network definitions.
2022-04-30 00:30:04 +02:00
Will Fancher 2e96b64e02
Merge pull request #170123 from ElvishJerricco/systemd-shutdown-ramfs-fixup
Systemd shutdown ramfs fixup
2022-04-28 20:17:23 -04:00
Will Fancher 69d8047516 nixos: Fix up systemd shutdown ramfs 2022-04-28 14:12:14 -04:00
Bernardo Meurer 59aa6e4988
Merge pull request #170099 from helsinki-systems/feat/systemd-stage-1-no-random-seed
nixos/systemd-stage-1: Get rid of random-seed
2022-04-25 14:56:45 -07:00
Janne Heß 45494fab68
nixos/systemd-stage-1: Get rid of random-seed
This is not used at all since the unit has
ConditionPathExists=!/etc/initrd-release
2022-04-24 21:59:59 +01:00
Janne Heß acca3f4b81
nixos/plymouth: Add systemd stage 1 support 2022-04-24 21:47:49 +01:00
Janne Heß dc4b2812e4
nixos/stage-1-systemd: Also accept packages as store paths 2022-04-24 21:47:34 +01:00
Jack O'Sullivan 568cb2d6ab nixos/systemd/nspawn: Add missing nspawn unit options
A few options have been added to the `systemd.nspawn` unit type are
missing from `systemd.nspawn.*.*Config`. See systemd.nspawn(5).
2022-04-24 21:20:59 +01:00
Bernardo Meurer b23ec41f14
Merge pull request #168554 from helsinki-systems/feat/systemd-stage-1-luks
nixos/systemd-stage-1: Add basic LUKS support
2022-04-22 12:37:25 -07:00
Artturi 98ff3e401c
Merge pull request #165892 from tpwrules/fix-initrd-dirlinks
make-initrd: fix reproducibility problems
2022-04-21 20:51:35 +03:00
Janne Heß 1bea49d3bf
nixos/stage-1-systemd: Add LUKS w/ password support 2022-04-18 11:42:45 +01:00
Florian Klink 52e346d6dd
Merge pull request #168774 from helsinki-systems/feat/systemd-shutdown
nixos/systemd: Properly shut down the system
2022-04-18 09:52:07 +02:00
Will Fancher 9e8b463cce nixos: Handle panic_on_fail in systemd stage 1 2022-04-17 18:31:35 -04:00
Sandro b4e7303ddf
nixos/specialisation: fix curly brackets 2022-04-17 05:48:33 +02:00
Janne Heß 30a00c29c4
nixos/systemd: Properly shut down the system 2022-04-16 21:17:36 +01:00
Janne Heß 031b95e587
Merge pull request #168814 from helsinki-systems/feat/systemd-stage-1-pass-vars
nixos/systemd-stage-1: Pass more vars to the builder
2022-04-16 22:02:26 +02:00
Janne Heß b9bf28fd70
nixos/stage-1-init: Pass all parameters to the builder
This is for compatiblity with the old builder to get compat with uboot
support and to prepend microcode updates to the initrd
2022-04-16 20:36:18 +01:00
Janne Heß 01bc138a8e
nixos/stage-1-init: Merge mdraid module into swraid 2022-04-15 19:57:16 +01:00
Thomas Watson 7fd6cea253 make-initrd: fix reproducibility problems
cpio includes the number of directory hard links in archives it creates.
Some filesystems, like btrfs, do not count directory hard links the same
way as more common filesystems like ext4 or tmpfs, so archives built
when /tmp is on such a filesystem do not reproduce. This patch replaces
cpio with bsdtar, which does not have this issue. The specific
invocation is from this page:
https://reproducible-builds.org/docs/archives/
2022-04-14 19:06:30 -05:00
Lassulus 15b5c29a41
Merge pull request #168600 from helsinki-systems/feat/systemd-stage-1-keymap
nixos/stage-1-systemd: Add keymap support
2022-04-14 21:50:52 +01:00
Janne Heß 289f38a65b
Merge pull request #168301 from helsinki-systems/feat/systemd-stage-1-mdadm
nixos/stage-1-systemd: Add mdraid support (+ test)
2022-04-14 17:56:36 +02:00
Janne Heß dda7e9e3ee
nixos/stage-1-systemd: Add mdraid support (+ test) 2022-04-14 11:39:57 +01:00
Janne Heß 0581d31bf9
Merge pull request #167393 from iblech/patch-docs-cc
nixos-rebuild, switch-to-configuration: document and protect against cross compilation subtlety
2022-04-14 12:30:39 +02:00
Janne Heß 6d6c1c341c
nixos/stage-1-systemd: Add keymap support
Makes my life a lot easier with my non-american keyboard layout
2022-04-14 10:25:04 +01:00
Janne Heß aeb75b3b69
nixos/stage-1-systemd: Implement hibernation + test 2022-04-13 23:02:13 +01:00
Janne Heß ffb320378b
nixos/stage-1-systemd: Fix booting grub tests 2022-04-13 23:02:10 +01:00
Lassulus 65cc198539
Merge pull request #167349 from helsinki-systems/feat/udev-systemd-stage-1
nixos/udev: Add systemd stage 1 support
2022-04-12 21:02:52 +01:00
Lassulus c0139fe5c3
Merge pull request #167168 from helsinki-systems/feat/systemd-stage-1-proper-handover
nixos/stage-1-systemd: Handover between the systemds directly
2022-04-11 22:26:11 +01:00
Janne Heß 3df2691e6b
nixos/stage-1-systemd: Handover between the systemds directly 2022-04-11 20:04:33 +01:00
Janne Heß fb44ecd129
nixos/udev: Add systemd stage 1 support 2022-04-11 19:43:26 +01:00
Erik Arvstedt 63528cb1a6
nixos/systemd: remove duplicate definition of systemd.user.timers
It's already defined in `systemd/user.nix`.
This is a leftover from commit b6d50528dd
where all `systemd.user` settings were moved to `systemd/user.nix`.
2022-04-11 13:01:40 +02:00
Janne Heß adab6ce552
nixos/systemd-stage-1: Minor fixups
- Fix the name of the env
- Add the correct kmod to the initrd
- Add `less` to make journalctl usable
- Fix SYSTEMD_SULOGIN_FORCe for rescue.target
- Add some missing binaries
2022-04-11 11:13:01 +01:00
Luke Granger-Brown 4ea239aa70
Merge pull request #163958 from lukegb/networkd-main
nixos/networkd: configure /etc/systemd/networkd.conf
2022-04-11 02:01:19 +01:00
Luke Granger-Brown f47caf769b nixos/networkd: configure /etc/systemd/networkd.conf
The networkd.conf file controls a variety of interesting settings
which don't seem to be configurable at the moment, including
adding names to route tables (for networkd only, although this commit
also exports them into iproute2 for convenience's sake), and
the speed metering functionality built into networkd.

Importantly, however, this also allows disabling the systemd
functionality where it likes to delete all the routes and routing rules
that haven't been configured through networkd whenever something causes
it to perform a reconfiguration.
2022-04-11 00:28:33 +00:00
Thiago Kenji Okada d1f7cc85b5
Merge pull request #161272 from dmadisetti/master
nixos/grub: module options to modify entry classes
2022-04-06 23:14:15 +01:00
Ingo Blechschmidt c3428419e0 nixos/switch-to-configuration: Provider better error message in cross-compiling situations 2022-04-05 16:52:09 +02:00
github-actions[bot] 27a4e52731
Merge master into staging-next 2022-04-05 12:05:41 +00:00
Lassulus b69bd66518
Merge pull request #167242 from helsinki-systems/feat/systemd-stage-1-variable-bin
nixos/systemd-stage-1: Softcode bin tools...
2022-04-05 09:39:19 +01:00
Janne Heß acf089edef
nixos/systemd-stage-1: Softcode bin tools...
...and other cleanups and fixes
2022-04-04 22:56:31 +01:00
github-actions[bot] 5844b1c2fa
Merge master into staging-next 2022-04-04 18:01:27 +00:00
Lassulus 5083d22ec5
Merge pull request #167167 from helsinki-systems/feat/systemd-stage-1-less-systemd-files
nixos/stage-1-systemd: Limit files to the bare necessities
2022-04-04 18:25:55 +01:00
Janne Heß 41d3ca0677
nixos/systemd-stage-1: Use an own systemd package
We need more features than systemdMinimal but less than systemd so we
need some own packages :/
2022-04-04 18:12:45 +01:00
Martin Weinelt c6476294e1 Merge remote-tracking branch 'origin/master' into staging-next 2022-04-04 18:40:34 +02:00
Janne Heß 75ece4eb82
nixos/stage-1-systemd: Limit files to the bare necessities 2022-04-04 12:54:18 +01:00
Janne Heß 4b9efea255
nixos/stage-1-systemd: Implement job scripts 2022-04-04 11:44:31 +01:00
Martin Weinelt bb7e4b378e Merge remote-tracking branch 'origin/master' into staging-next 2022-04-04 00:46:44 +02:00
Janne Heß 56b4653904
nixos/stage-2-init: Re-add creation of /etc 2022-04-03 19:03:16 +01:00
github-actions[bot] c46200d454
Merge master into staging-next 2022-04-03 18:01:07 +00:00
Janne Heß 371504ac8e
Merge pull request #167019 from NixOS/fix/systemd-env
nixos/stage-2-init: Don't clear environment
2022-04-03 16:36:26 +02:00
Janne Heß 7cdc4dd5d1
Merge pull request #164943 from ElvishJerricco/systemd-initrd-reuse-systemd-module
initrd: Opt-in bare bones systemd-based initrd
2022-04-03 15:53:02 +02:00
Lassulus e65b825672
Merge pull request #165684 from helsinki-systems/clean/stage-2-init
nixos/stage-2-init: Clean up legacy commands
2022-04-03 14:12:52 +02:00
Janne Heß ea473fac72
nixos/stage-2-init: Don't clear environment
This breaks NixOS Containers because systemd needs some env variables
from the outside.
2022-04-03 11:12:00 +01:00
github-actions[bot] fc17fe6417
Merge master into staging-next 2022-04-02 18:01:07 +00:00
7c6f434c 8188f10752
Merge pull request #166430 from alyssais/openssl-static-retry
treewide: use lib.getLib for OpenSSL libraries
2022-04-02 12:59:55 +00:00
github-actions[bot] 8b4f11bb87
Merge master into staging-next 2022-04-02 00:02:09 +00:00
Florian Klink 401cb86da1
Merge pull request #166142 from ncfavier/wait-online
nixos/networkd: add `wait-online` options
2022-04-01 22:54:28 +02:00
Janne Heß 7ebb4ebe40
nixos/systemd-stage-1: Append (Initrd) to /etc/initrd-release
This is more in line with what dracut does (it appends "Initramfs") and
makes it clear where the boot is currently at when it hangs.
2022-04-01 13:54:09 +02:00
Janne Heß 5653209ed9
nixos/systemd-initrd: Redo object specifications
As requested by @roberth, we now have an option similar to
environment.etc. There's also extra store paths to copy and a way to
suppress store paths to make customizations possible.

We also link mount and umount to /bin to make recovery easier when
something fails
2022-04-01 13:26:06 +02:00
Janne Heß c465c8d719
nixos/systemd-initrd: Make emergency access more flexible 2022-04-01 11:58:31 +02:00
Janne Heß b7c62b8238
nixos/systemd-initrd: Remove unit options that don't work 2022-04-01 11:58:30 +02:00
github-actions[bot] 5e1c018e60
Merge master into staging-next 2022-04-01 06:01:23 +00:00
Dominique Martinet e92c05349c nixos/logrotate: convert to freeform
using freeform is the new standard way of using modules and should replace
extraConfig.
In particular, this will allow us to place a condition on mails
2022-04-01 07:09:26 +09:00
github-actions[bot] be4f006d3c
Merge master into staging-next 2022-03-31 18:01:13 +00:00
Silvan Mosberger 2da8e63ce8
Merge pull request #111595 from Luflosi/add-cherry-usb-kb-kernel-module
nixos/availableKernelModules: add cherry hid
2022-03-31 17:14:29 +02:00
madisetti 9dddd48c4c nixos/grub: added configuration option for entry options 2022-03-31 06:39:16 -04:00
Martin Weinelt d0bfb3ccbb Merge remote-tracking branch 'origin/master' into staging-next 2022-03-31 03:49:37 +02:00
ajs124 35619ce1e5
Merge pull request #165453 from helsinki-systems/feat/systemd-manager-environment
nixos/systemd: Switch to ManagerEnvironment=
2022-03-31 01:35:09 +02:00
Janne Heß a3e0698bf6
nixos/systemd: Switch to ManagerEnvironment=
This accomplishes multiple things:
- Allows us to start systemd without stage-2-init.sh. This was not
  possible before because the environment would have been wrong
- `systemctl daemon-reexec` also changes the environment, giving us
  newer tools for the fs packages
- Starts systemd in a fully clean environment, making everything more
  consistent and pure
2022-03-30 20:24:27 +02:00
Alyssa Ross fd78240ac8
treewide: use lib.getLib for OpenSSL libraries
At some point, I'd like to make another attempt at
71f1f4884b ("openssl: stop static binaries referencing libs"), which
was reverted in 195c7da07d.  One problem with my previous attempt is
that I moved OpenSSL's libraries to a lib output, but many dependent
packages were hardcoding the out output as the location of the
libraries.  This patch fixes every such case I could find in the tree.
It won't have any effect immediately, but will mean these packages
will automatically use an OpenSSL lib output if it is reintroduced in
future.

This patch should cause very few rebuilds, because it shouldn't make
any change at all to most packages I'm touching.  The few rebuilds
that are introduced come from when I've changed a package builder not
to use variable names like openssl.out in scripts / substitution
patterns, which would be confusing since they don't hardcode the
output any more.

I started by making the following global replacements:

    ${pkgs.openssl.out}/lib -> ${lib.getLib pkgs.openssl}/lib
    ${openssl.out}/lib -> ${lib.getLib openssl}/lib

Then I removed the ".out" suffix when part of the argument to
lib.makeLibraryPath, since that function uses lib.getLib internally.

Then I fixed up cases where openssl was part of the -L flag to the
compiler/linker, since that unambigously is referring to libraries.

Then I manually investigated and fixed the following packages:

 - pycurl
 - citrix-workspace
 - ppp
 - wraith
 - unbound
 - gambit
 - acl2

I'm reasonably confindent in my fixes for all of them.

For acl2, since the openssl library paths are manually provided above
anyway, I don't think openssl is required separately as a build input
at all.  Removing it doesn't make a difference to the output size, the
file list, or the closure.

I've tested evaluation with the OfBorg meta checks, to protect against
introducing evaluation failures.
2022-03-30 15:10:00 +00:00
Naïm Favier d113e4e06e
nixos/networkd: add wait-online options 2022-03-29 10:14:26 +02:00
github-actions[bot] df0f3ba49a
Merge master into staging-next 2022-03-29 06:01:16 +00:00
Janne Heß 452102db8f
nixos/stage-2-init: Clean up legacy commands
We can perform most of the mkdir/ln/rm using systemd-tmpfiles
instead which cleans up the script.

/bin and /home are created by their activation script snippets

usbfs is deprecated and unused.

hwclock seems to be automatically executed by systemd on startup.

The mkswap to prevent hibernation cycles seems to be executed by systemd
as well since the provided regression tests succeeds.
2022-03-27 13:51:02 +02:00
Janne Heß 158a2972eb
nixos/filesystems: Move options into the fs module
This was probably forgotten during a refactoring. The module is where
the values of the options are actually used.
2022-03-27 13:23:44 +02:00
Florian Klink e3083decc4 systemd-initrd, systemd-lib: drop initrdServiceToUnit
We can just use serviceToUnit here.
2022-03-24 18:57:16 +01:00
Florian Klink 74bae06748 systemd-initrd: use pkgs.fakeNss, document why we need libnss_files.so 2022-03-24 18:51:32 +01:00
Will Fancher 5bfe213315 Clarify suppressed units description 2022-03-22 21:28:51 -04:00
Will Fancher 213de9b108 systemd-initrd: autoFormat and autoResize in initrd 2022-03-22 21:28:51 -04:00
Will Fancher 1abf154179 systemd-initrd: Add PATH to everything 2022-03-22 21:28:50 -04:00
Will Fancher 2d4ebf1259 initrd: Optional systemd-based initrd 2022-03-22 21:28:43 -04:00
Will Fancher 25113740a5 nixos: systemd-lib: Make generateUnits general with default args 2022-03-22 07:02:23 -04:00
Will Fancher 52c98fc3e9 nixos: systemd: Split unit types into separate module 2022-03-21 10:25:27 -04:00
github-actions[bot] de642acb2e
Merge staging-next into staging 2022-03-21 12:10:50 +00:00
Florian Klink 9427a17ccb
Merge pull request #164016 from bobvanderlinden/pr-refactor-systemd-module
nixos: systemd: split module up into multiple files
2022-03-21 13:03:55 +01:00
Bob van der Linden 397b8257a0
nixos: systemd-user: fix additionalUpstreamUserUnits description
Co-authored-by: Martin Weinelt <mweinelt@users.noreply.github.com>
2022-03-21 12:30:37 +01:00
Bob van der Linden 92af44e04d
nixos: systemd: remove unhelpful comments in additionalUpstreamSystemUnits
Co-authored-by: Janne Heß <janne@hess.ooo>
2022-03-20 16:14:13 +01:00
Janne Heß 85874efcb0
nixos/switch-to-configuration: Make perlcritic happy 2022-03-20 13:04:23 +01:00
Janne Heß 9c494b5773
nixos/switch-to-configuration: Snake-case all variables
Also add a lot of comments and reorder some assignments
2022-03-20 13:03:39 +01:00
Janne Heß 67f84b4b87
nixos/switch-to-configuration: Snake-case all subroutines and add comments 2022-03-20 13:03:19 +01:00
Janne Heß 23ea9965bb
nixos/switch-to-configuration: Enforce consistent quoting 2022-03-20 13:01:11 +01:00
Janne Heß bdcd558812
nixos/switch-to-configuration: Get rid of all postfixes and unlesses 2022-03-20 13:01:11 +01:00
Bob van der Linden 6514bb4620
nixos: systemd-user: make additionalUpstreamUserUnits internal 2022-03-19 12:06:56 +01:00
Bob van der Linden 66759cea7d
nixos: systemd-user: expand on additionalUpstreamUserUnits description 2022-03-19 12:06:43 +01:00
Bob van der Linden 753b911708
nixos: systemd-tmpfiles: use cfg shorthand 2022-03-17 23:16:38 +01:00
Bob van der Linden 38d043de9c
nixos: systemd: split off systemd-tmpfiles into separate module 2022-03-17 23:16:37 +01:00
Bob van der Linden 0e665d1815
nixos: systemd-user: allow additional upstream user units
Currently it is only possible to add upstream _system_ units. The option
systemd.additionalUpstreamSystemUnits can be used for this.

However, this was not yet possible for systemd.user. In a similar
fashion this was added to systemd-user.nix.

This is intended to have other modules add upstream units.
2022-03-17 23:16:37 +01:00
Bob van der Linden b6d50528dd
nixos: systemd-user: use cfg shorthand 2022-03-17 23:16:37 +01:00
Bob van der Linden 022b4209a3
nixos: systemd: split off systemd-user into separate module 2022-03-17 23:16:37 +01:00
Bob van der Linden cae8ef1232
nixos: systemd-coredump: use cfg shorthand 2022-03-17 23:16:30 +01:00
Bob van der Linden ccfcb78a50
nixos: systemd: split off coredump into separate module 2022-03-17 23:15:49 +01:00
Bob van der Linden 7adc8ecac3
nixos: systemd-journald: use cfg shorthand 2022-03-17 23:13:36 +01:00
Bob van der Linden fee1e24b3b
nixos: systemd: split off journald into separate module 2022-03-17 23:13:36 +01:00
Bob van der Linden e2cb8903da
nixos: systemd-logind: use cfg shorthand 2022-03-17 23:13:27 +01:00
Bob van der Linden c647002a94
nixos: systemd: split off logind into separate module 2022-03-17 23:12:00 +01:00
Bob van der Linden 0c94a512dd
nixos: systemd: avoid using "with systemdUtils.lib" 2022-03-17 21:52:54 +01:00
Bob van der Linden 3420dba80a
nixos: systemd: move systemd-nspawn to systemd/nspawn 2022-03-17 21:52:37 +01:00
github-actions[bot] 739cf04cb7
Merge staging-next into staging 2022-03-17 18:02:05 +00:00
Luflosi 47b699fe6c
Revert "nixos/modprobe: add boot.initrd.extraModprobeConfig option"
This reverts commit 1c58cdbeed, since this change was made redundant by 3dc6fab5c9 and in https://github.com/NixOS/nixpkgs/pull/145013 we decided to revert this commit.
2022-03-17 12:56:02 +01:00
github-actions[bot] 2eac3106df
Merge staging-next into staging 2022-03-17 00:02:45 +00:00
Robert Hensing 0395086d0c
Merge pull request #162271 from Infinisil/warn-no-type
Throw an error for options without a type
2022-03-16 22:58:45 +01:00
Bob van der Linden 9bc093b30a
nixos: systemd: split off helper functions into systemd-lib 2022-03-15 21:52:13 +01:00
Alyssa Ross d7e181ff83
Merge remote-tracking branch 'nixpkgs/staging-next' into staging
Conflicts:
	pkgs/development/compilers/ocaml/4.12.nix
	pkgs/development/python-modules/oci/default.nix
	pkgs/tools/admin/bubblewrap/default.nix
2022-03-14 12:33:16 +00:00
Naïm Favier 9bdd2f852c
nixos/switch-to-configuration: fix installBootLoader escaping
Use a quoted heredoc to inject installBootLoader safely into the script,
and restore the previous invocation of `system` with a single argument so
that shell commands keep working.
2022-03-14 02:12:52 +01:00
Janne Heß 3148b3d365
Merge pull request #163069 from helsinki-systems/feat/minor-stc-improvements
nixos/switch-to-configuration: Few minor/medium improvements
2022-03-13 17:50:36 +01:00
Luke Granger-Brown 5f81753d1b
Merge pull request #162252 from sternenseemann/systemd-boot-builder-fix-errors
sdboot-builder: fix crash in exception handling
2022-03-13 14:19:54 +00:00
Maëlys Bras de fer 529b09a729 sdboot-builder: fix crash in exception handling 2022-03-13 14:38:01 +01:00
Luke Granger-Brown c30918d419 nixos/networkd: add support for more WireGuard options (introduced in systemd v250)
As of systemd/systemd@e908434458,
systemd-networkd now automatically configures routes to addresses
specified in AllowedIPs unless explicitly disabled with
"RouteTable=off".
2022-03-13 04:13:03 +00:00
Janne Heß 461c1c9e86
nixos/switch-to-configuration: Use parenthesis on all calls 2022-03-11 14:05:20 +01:00
Janne Heß bc58430068
nixos/switch-to-configuration: Fix reloading of stopped services 2022-03-11 14:05:19 +01:00
Janne Heß 3052d3aa50
nixos/switch-to-configuration: Fix restarting by activation script
This bug is so obscure and unlikely that I was honestly not able to
properly write a test for it. What happens is that we are calling
handleModifiedUnit() with $unitsToStart=\%unitsToRestart. We do this to
make sure that the unit is stopped before it's started again which is
not possible by regular means because the stop phase is already done
when calling the activation script.

recordUnit() still gets $startListFile, however which is the wrong file.
The bug would be triggered if an activation script requests a service
restart for a service that has `stopIfChanged = true` and
switch-to-configuration is killed before the restart phase was run. If
the script is run again, but the activation script is not requesting
more restarts, the unit would be started instead of restarted.
2022-03-11 13:30:03 +01:00
Janne Heß c96180c53f
nixos/switch-to-configuration: Ignore some unit keys
Some unit keys don't need to restart the service to make them effective.
Reduce the amount of service restarts by ignoring these keys
2022-03-11 13:30:03 +01:00
github-actions[bot] f6b4a4048a
Merge staging-next into staging 2022-03-09 12:01:59 +00:00
Peter Hoeg d44916d12f nixos/activation: allowed quoted values in /etc/os-release 2022-03-09 17:07:48 +08:00
Andreas Rammhold d67caf3c89 nixos/timesyncd: initialize clock file with current time
When initializing a system (e.g. first boot / livecd) we have no good
reference source for time. systemd-timesyncd however would revert back
to its configured fallback time (in our case 01.01.1980). Since we
probably don't want to hardcode a specific date as fallback we are now
using the current system time (wherever that might have come from) to
initialize the reference clock file.

The only systems that might be remotely affected by this change are
machines that have highly unreliable RTCs or those where the battery
that backs the RTC is running empty.

Historically these systems always had a tough time with anything time
related and likely required manual intervention.

For stateless systems (those that wipe / between reboots or our
installer CDs) this has the consequence that time will always be reset
to whatever the system comes up with on boot. This is likely the correct
time coming from an RTC. No harm done here the situation is likely
unchanged for them.

For stateful systems (those that retain the / partition across reboots)
there shouldn't be a change at all. They'll provide an initial clock
value once on their lifetime (during first boot / after installation).
From then onwards systemd-timesyncd will update the file with the newer
fallback time (that will be picked up on the next boot).
2022-03-05 21:27:45 +01:00
Alyssa Ross c010a19a56
Merge remote-tracking branch 'nixpkgs/staging-next' into staging
Conflicts:
	pkgs/development/python-modules/hypothesmith/default.nix
2022-03-04 14:53:05 +00:00
Janne Heß 1def557525
nixos/switch-to-configuration: Document and test socket-activated services 2022-03-03 20:49:20 +01:00
Silvan Mosberger b2d803ca57 nixos/treewide: Add last missing option types
Co-Authored-By: Janne Heß <janne@hess.ooo>
2022-02-28 22:50:06 +01:00
Maximilian Bosch 1077a6e040
nixos/stage-1: typo fixes 2022-02-27 14:07:31 +01:00
Maximilian Bosch da905d4cf9
nixos/stage-1: fix modprobe in initial ramdisk on systems w/glibc-2.34
This effectively fixes the majority of all VM tests which were broken
because `/dev/vda` (or any other block device) wasn't mountable:

      machine # mounting /dev/vda on /...
      machine # mount: mounting /dev/vda on /mnt-root/ failed: No such device[    2.820976] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000100
      machine # [    2.821757] CPU: 0 PID: 1 Comm: init Not tainted 5.10.72 #1-NixOS
      machine # [    2.821757] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
      machine # [    2.821757] Call Trace:
      machine # [    2.821757]  dump_stack+0x6b/0x83
      machine # [    2.821757]  panic+0x101/0x2c8
      machine # [    2.821757]  do_exit.cold+0x14/0xb3
      machine # [    2.821757]  do_group_exit+0x33/0xa0
      machine # [    2.821757]  __x64_sys_exit_group+0x14/0x20
      machine # [    2.821757]  do_syscall_64+0x33/0x40
      machine # [    2.821757]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      machine # [    2.821757] RIP: 0033:0x7f67ec2800f6
      machine # [    2.821757] Code: 00 4c 8b 0d 2c 5d 11 00 eb 19 66 2e 0f 1f 84 00 00 00 00 00 89 d7 89 f0 0f 05 48 3d 00 f0 ff ff 77 22 f4 89 d7 44 89 c0 0f 05 <48> 3d 00 f0 ff ff 76 e2 f7 d8 64 41 89 01 eb da 66 2e 0f 1f 84 00
      machine # [    2.821757] RSP: 002b:00007fff8f5a71d8 EFLAGS: 00000202 ORIG_RAX: 00000000000000e7
      machine # [    2.821757] RAX: ffffffffffffffda RBX: 0000000000699704 RCX: 00007f67ec2800f6
      machine # [    2.821757] RDX: 0000000000000001 RSI: 000000000000003c RDI: 0000000000000001
      machine # [    2.821757] RBP: 0000000000000004 R08: 00000000000000e7 R09: ffffffffffffff80
      machine # [    2.821757] R10: 00007f67ec33f3e0 R11: 0000000000000202 R12: 000000000000000b
      machine # [    2.821757] R13: 00007fff8f5a75a8 R14: 0000000000000000 R15: 00000000004fc198
      machine # [    2.821757] Kernel Offset: 0x31e00000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)
      machine # [    2.821757] Rebooting in 1 seconds..

This happened because the kernel failed to load modules such as `ext4`
from `boot.initrd.availableKernelModules`[1] on e.g. a `mount(2)` syscall.

The problem is that `kmod` isn't linked against `libpthread.so.0`
anymore because it got merged into `libc.so.6` (however, the .so still
exists), but still needs it:

      machine # newfstatat(AT_FDCWD, "/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-glibc-2.34-36/lib/x86_64", 0x7ffd951114c0, 0) = -1 ENOENT (No such file or directory)
      machine # openat(AT_FDCWD, "/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-glibc-2.34-36/lib/x86_64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
      machine # newfstatat(AT_FDCWD, "/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-glibc-2.34-36/lib/x86_64", 0x7ffd951114c0, 0) = -1 ENOENT (No such file or directory)
      machine # openat(AT_FDCWD, "/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-glibc-2.34-36/lib/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
      machine # newfstatat(AT_FDCWD, "/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-glibc-2.34-36/lib", 0x7ffd951114c0, 0) = -1 ENOENT (No such file or directory)
      machine # openat(AT_FDCWD, "/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-glibc-2.34-36/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
      machine # writev(2, [{iov_base="/nix/store/kdc9n48ksdc1a8y8w512w"..., iov_len=69}, {iov_base=": ", iov_len=2}, {iov_base="error while loading shared libra"..., iov_len=36}, {iov_base=": ", iov_len=2}, {iov_base="libpthread.so.0", iov_len=15}, {iov_base=": ", iov_len=2}, {iov_base="cy
      machine # ) = 184
      machine # exit_group(127)                         = ?
      machine # +++ exited with 127 +++
      machine # mount: mounting /dev/vda on /mnt-root/ failed: No such device
      machine # [   19.167180] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000100
      machine # [   19.167711] CPU: 0 PID: 1 Comm: init Not tainted 5.10.72 #1-NixOS

This is not a problem

* inside stage-1 because `LD_LIBRARY_PATH` points to `$out/lib` of
  extra-utils where `libpthread.so.6` also exists.
* on a running system because `${pkgs.glibc}/lib` is part of kmod's
  rpath.

However this is a problem inside the kernel which calls `modprobe` (in
our case `kmod`) to load modules and doesn't know about
`LD_LIBRARY_PATH`. Also, the rpath-reference was nuked.

To work around this, the kernel's `modprobe`
(i.e. `/proc/sys/kernel/modprobe`) now points to a wrapper which
explicitly declares `LD_LIBRARY_PATH`. We can't use `makeWrapper` here
because `modprobe` itself must not be renamed. Otherwise, `kmod` (which
is the link-target of `modprobe`) won't work because it expects
`argv[0] == "modprobe"` to perform modprobe's tasks.

[1] https://nixos.org/manual/nixos/stable/options.html#opt-boot.initrd.availableKernelModules
2022-02-27 10:26:51 +01:00
Dominique Martinet 0dadec45d8 logrotate/systemd: add 'minsize = 1M' to wtmp/btmp rotation
align with upstream logrotate which added the minsize rule at some point.
This avoids needlessly rotating the files too often as brought up in
https://github.com/NixOS/nixpkgs/pull/159187#issuecomment-1052426774
2022-02-27 07:20:26 +09:00
Janne Heß e5823f77b3
Merge pull request #159187 from martinetd/logrotate
logrotate service enhancements
2022-02-23 11:24:17 +01:00
Martin Weinelt c2147ab6a8
modprobe: install systemd's modprobe options
Shipped by systemd to combat kmod default options that interfere with
the netdev setup, when those drivers are initially loaded.
2022-02-22 17:22:57 +01:00
Christian Kögler 57fc08cfdb nixos: Switch to default systemd-nspawn behaviour 2022-02-19 09:52:37 +01:00
Janne Heß dcbacb0f62
Merge pull request #160458 from helsinki-systems/fix/stc-backslashes
nixos/switch-to-configuration: Fix backslashes in unit names
2022-02-17 19:08:02 +01:00
Vladimír Čunát 9d09daa0a9
Merge #157512: nixos/tmp: Fix format of /tmp mount options 2022-02-17 16:26:28 +01:00
Janne Heß 3617ecb67f
nixos/switch-to-configuration: Fix backslashes in unit names
systemd needs this so special characters (like the ones in wireguard
units that appear because they are part of base64) can be escaped using
the \x syntax.

Root of the issue is that `glob()` handles the backslash internally
which is obviously not what we want here.

Also add a test case and fix some perlcritic issues in the subroutine.
2022-02-17 12:49:45 +01:00
Stig Palmquist 3d713efe41 nixos/switch-to-configuration: avoid Array::Compare dependency
Replace Array::Compare with a simple function, since Array::Compare
pulls down Module::Build which breaks cross compilation.
2022-02-15 15:37:37 +01:00
Dominique Martinet 9917af7fe0 logrotate: move wtmp/btmp rules to systemd
wtmp and btmp are created by systemd, so the rules are more appropriate there.

They can be disabled explicitly with something like
  services.ogrotate.paths = {
    "/var/log/btmp".enable = false;
    "/var/log/wtmp".enable = false;
  };
if required.
2022-02-11 20:52:40 +09:00
Janne Heß 08cd8ab8b6
nixos/switch-to-configuration: Don't stop swaps in dry-activate 2022-02-09 15:14:38 +01:00
Janne Heß b5b3ee4f78
nixos/systemd: Add reloadTriggers to services 2022-02-09 15:14:37 +01:00
Janne Heß b9bb1de341
nixos/switch-to-configuration: Implement reload support
This is accomplished by comparing the hashes that the unit files
contain. By filtering for a special key `X-Reload-Triggers` in the
`[Unit]` section, we can differentiate between reloads and restarts.

Since activation scripts can request reloads of units as well, more
checking of this behaviour is implemented. If a unit is to be restarted,
it's never reloaded as well which would make no sense.

Also removes a useless subroutine and perl dependencies that are
nowadays handled by the propagated build inputs feature of
`perl.withPackages`.
2022-02-09 14:31:45 +01:00
Janne Heß 78db7b6529
nixos/switch-to-configuration: Allow passing parsed unit contents 2022-02-09 14:31:44 +01:00
Janne Heß d729cc8a53
nixos/switch-to-configuration: Skip [Install] section 2022-02-09 14:31:44 +01:00
Jörg Thalheim 82f2d81b22
Merge pull request #157839 from abbradar/stage-1-modprobe
Modprobe options in stage-1
2022-02-08 11:43:31 +00:00
Robert Hensing 6be11a84aa
Merge pull request #155892 from hercules-ci/nixos-etc-unit-test
nixos: Refactor to allow `etc` unit test
2022-02-06 16:12:25 +01:00
Nikolay Amiantov 3dc6fab5c9 nixos/stage-1: add nixos modprobe options 2022-02-02 15:18:09 +03:00
Maciej Krüger 8bb7bec755
Merge pull request #141122 from Luflosi/add-apfs-nixos-module 2022-02-01 17:29:10 +01:00
Ramses 4cea257440 nixos/tmp: Fix format of /tmp mount options
The mount options need to be passed as a comma-separated list of options so that they
end up one a single Options line in the resulting mount unit.
The current code passed the options as a list, resulting in several Options lines in
the mount unit, all but the first of these were ignored by systemd however.
This behaviour is not clearly defined in the systemd man page.
2022-01-31 12:49:29 +01:00
Guillaume Girol 0d5c5e46da
Merge pull request #157053 from lheckemann/systemd-optional-cryptsetup
nixos/systemd: only use cryptsetup units if systemd was built with it
2022-01-30 16:04:17 +00:00
Linus Heckemann 4b27d4f9f8 nixos/systemd: only use cryptsetup units if systemd was built with it 2022-01-30 12:00:37 +01:00
Robert Hensing 9809e1575b nixos/etc.nix: Make independent
(cherry picked from commit 56c283e5c8dfd4d8d5daa15dfa3896beef2ac012)
2022-01-30 09:01:27 +01:00
Bernardo Meurer 5f9b470ff0
Merge pull request #154809 from helsinki-systems/feat/stc-proper-unit-file-parser
nixos/switch-to-configuration: Proper unit file parser and clean/fix lower part of the script
2022-01-27 09:35:34 -08:00
Luflosi 26a695399a
nixos/apfs: init
Add the final missing pieces for full APFS support.
2022-01-27 15:18:45 +01:00
polykernel 4a9d9928dc nixos/nix-daemon: use structural settings
The `nix.*` options, apart from options for setting up the
daemon itself, currently provide a lot of setting mappings
for the Nix daemon configuration. The scope of the mapping yields
convience, but the line where an option is considered essential
is blurry. For instance, the `extra-sandbox-paths` mapping is
provided without its primary consumer, and the corresponding
`sandbox-paths` option is also not mapped.

The current system increases the maintenance burden as maintainers have to
closely follow upstream changes. In this case, there are two state versions
of Nix which have to be maintained collectively, with different options
avaliable.

This commit aims to following the standard outlined in RFC 42[1] to
implement a structural setting pattern. The Nix configuration is encoded
at its core as key-value pairs which maps nicely to attribute sets, making
it feasible to express in the Nix language itself. Some existing options are
kept such as `buildMachines` and `registry` which present a simplified interface
to managing the respective settings. The interface is exposed as `nix.settings`.

Legacy configurations are mapped to their corresponding options under `nix.settings`
for backwards compatibility.

Various options settings in other nixos modules and relevant tests have been
updated to use structural setting for consistency.

The generation and validation of the configration file has been modified to
use `writeTextFile` instead of `runCommand` for clarity. Note that validation
is now mandatory as strict checking of options has been pushed down to the
derivation level due to freeformType consuming unmatched options. Furthermore,
validation can not occur when cross-compiling due to current limitations.

A new option `publicHostKey` was added to the `buildMachines`
submodule corresponding to the base64 encoded public host key settings
exposed in the builder syntax. The build machine generation was subsequently
rewritten to use `concatStringsSep` for better performance by grouping
concatenations.

[1] - https://github.com/NixOS/rfcs/blob/master/rfcs/0042-config-option.md
2022-01-26 21:04:50 -05:00
Martin Weinelt 48f17360d9 Merge remote-tracking branch 'origin/master' into staging-next 2022-01-25 15:53:19 +01:00
Robert Hensing 8919495cac
Merge pull request #156503 from hercules-ci/nixos-add-system.build-options
nixos: Add `system.build.`{`toplevel`,`installBootLoader`}, improve error message
2022-01-25 14:13:24 +01:00
github-actions[bot] bbbd0a92af
Merge master into staging-next 2022-01-25 00:02:13 +00:00
Luflosi 1c58cdbeed
nixos/modprobe: add boot.initrd.extraModprobeConfig option
This option behaves exactly like `boot.extraModprobeConfig`, except that it also includes the generated modprobe.d file in the initrd.
Many years ago, someone tried to include the normal modprobe.d/nixos.conf file generated by `boot.extraModprobeConfig` in the initrd: 0aa2c1dc46. This file contains a reference to a directory with firmware files inside. Including firmware in the initrd made it too big, so the commit was reverted again in 4a4c051a95.
The `boot.extraModprobeConfig` option not changing the initrd caused me much confusion because I tried to set the maximum cache size for ZFS and it didn't work.
Closes https://github.com/NixOS/nixpkgs/issues/25456.
2022-01-24 22:56:14 +01:00
Robert Hensing 4800f30841 nixos: Explain system.build.installBootLoader's odd default
I don't really approve of this solution, but documenting its
purpose was the least I could do for now.
2022-01-24 16:17:20 +01:00
Robert Hensing 511e89f5a6 nixos: Make system.build.installBootLoader a proper option
This improves the error message when the configuration contains
more than one boot loader.
2022-01-24 16:17:19 +01:00
Robert Hensing 2aa7c25808 nixos: Document system.build.toplevel 2022-01-24 16:16:46 +01:00
Robert Hensing ccb85a53b6 nixos: Make system.build a submodule with freeformType
This allows the values below it to be specified as options, while
remaining compatible with existing code.
2022-01-24 00:52:46 +01:00
Robert Hensing 3ac955acf4 nixos/system/build: Extract
Modules that do not depend on e.g. toplevel should not have to include it just to set
things in `system.build`. As a general rule, this keeps tests simple, usage flexible
and evaluation fast. While one module is insignificant, consistency and good practices
are.
2022-01-24 00:47:57 +01:00
github-actions[bot] 93a9821309
Merge master into staging-next 2022-01-23 18:01:11 +00:00
Janne Heß ce8c102a46
Merge pull request #155054 from jonringer/fix-systemd-boot
nixos/systemd-boot: fix error output
2022-01-23 16:23:13 +01:00
github-actions[bot] fd5336b13e
Merge master into staging-next 2022-01-21 18:01:25 +00:00
Janne Heß 45048dfd0a
Merge pull request #153095 from Madouura/dev/bcachefs-init
nixos/stage-1: colon-separated multi-device support
2022-01-21 16:35:10 +01:00
github-actions[bot] fc3ddb8979
Merge master into staging-next 2022-01-21 00:01:42 +00:00
Naïm Favier 1147d72481
nixos: use uniq in the type of system.build
`unspecified` will happily concatenate strings together from two
unrelated modules, causing spurious errors (see #155925).
2022-01-20 23:28:09 +01:00
pennae 2ed91b7349
Merge pull request #155854 from datafoo/networkd-IPMasquerade-assert
nixos/networking: fix assertion on IPMasquerade
2022-01-20 20:56:55 +00:00
Alyssa Ross b1724b2f81 nixos/activation-script: ensure gcroots dir exists
If the Nix daemon has never been enabled (nix.enable has always been
set to false), the gcroots directory won't exist.  If the Nix daemon
is later enabled, the GC roots for booted-system and current-system
will be missing, and they might end up being garbage collected.  Since
it's cheap to add GC roots even if the daemon will never be enabled,
let's just always add them so we're okay in the case where the daemon
is enabled later.
2022-01-20 20:24:32 +00:00
Janne Heß b52372675d
nixos/switch-to-configuration: Clean up lower part of the script
- Fully get rid of `parseKeyValues` and use systemctl features for that
- Add some regex modifiers recommended by perlcritic
- Get rid of a postfix if
- Sort units when showing their status
- Clean the logic for showing what failed from `elif` to `next`
- Switch from `state` to `substate` for `auto-restart` because that's
  actually where the value is stored
- Show status of units with one single systemctl call and get rid of
  COLUMNS in favor of --full
- Add a test for failing units
2022-01-20 17:10:02 +01:00
Janne Heß 96d36b0c2e
nixos/switch-to-configuration: Proper unit file parser
This replaces the naive K=V unit parser with a proper INI parser from a
library and adds proper support for override files. Also adds a bunch of
comments about parsing, I hope this makes it easier to understand and
maintain in the future.

There are multiple reasons to do so, the first one is just general
correctness with is nice imo. But to get to more serious reasons (I
didn't put in all that effort for nothing) is that this is the first
step torwards more clever restart/reload handling. By using a library
like Data::Compare a future PR could replace the current way of
fingerprinting units (which is to compare store paths) by comparing the
hashes. This is more precise because units won't get restarted because
the order of the options change, comments are added, some dependency of
writeText changes, .... Also this allows us to add a feature like
`X-Reload-Triggers` so the unit can either be reloaded when these change
or restarted when everything else changes, giving module authors the
ability to have their services reloaded without having to fear that
updates are not applied because the service doesn't get restarted.
Another reason why this feature is nice is that now that the unit files
are parsed correctly (and values are just extracted from one section),
potential future rewrites can just rely on some INI library without
having to implement their own weird parser that is compatible with this
script.

This also comes with a new subroutine to handle systemd booleans because
I thought the current way of handling it was just ugly. This also allows
overriding values this script reads in an override file.

Apart from making this script more compatible with the world around it,
this also fixes two issues I saw bugging exactly 0 (zero) people. First
is that this script now supports multiple override files, also ones that
are not called override.conf and the second one is that `1` and `on` are
treated as bools by systemd but were previously not parsed as such by
switch-to-configuration.
2022-01-20 15:10:23 +01:00
datafoo 9bfb803dce nixos/networking: fix assertion on IPMasquerade 2022-01-20 13:43:12 +01:00
github-actions[bot] b456d67c98
Merge master into staging-next 2022-01-18 00:01:41 +00:00
Janne Heß 2cf157c781
nixos/switch-to-configuration: Rework activation script restarts
This removes `/run/nixos/activation-reload-list` (which we will need in
the future when reworking the reload logic) and makes
`/run/nixos/activation-restart-list` honor `restartIfChanged` and
`reloadIfChanged`. This way activation scripts don't have to bother with
choosing between reloading and restarting.
2022-01-17 17:57:23 +01:00
Jonathan Ringer 87502df43b
nixos/systemd-boot: fix error output 2022-01-14 15:42:19 -08:00
github-actions[bot] d5e672b839
Merge master into staging-next 2022-01-14 18:01:18 +00:00
Robert Hensing 2bf5958169
Merge pull request #151082 from hercules-ci/nixos-cleanup-vmWithBootLoader
nixos: turn vmWithBootLoader into option (`nixos-rebuild build-vm`)
2022-01-14 18:49:27 +01:00
github-actions[bot] a6928c74cc
Merge master into staging-next 2022-01-13 12:01:29 +00:00
pennae 466cb747c8
Merge pull request #150408 from Enzime/systemd-boot-extra-entries
nixos/systemd-boot: Add `extraEntries` and `extraFiles` options
2022-01-13 07:15:05 +00:00
github-actions[bot] 7def368b6f
Merge master into staging-next 2022-01-12 18:01:16 +00:00
Alyssa Ross 5c8ddfd0b5 nixos/stage-1: update udev.log_level name in docs
I was confused why I couldn't find a mention of udev.log_priority in
systemd-udevd.service(8).  It turns out that it was renamed[1] to
udev.log_level.  The old name is still accepted, but it'll avoid
further confusion if we use the new name in our documentation.

[1]: 64a3494c3d
2022-01-12 14:04:14 +00:00
Madoura f363642de7
nixos/stage-1: colon-separated multi-device support 2022-01-09 18:06:03 -06:00
github-actions[bot] cf7efe1192
Merge staging-next into staging 2022-01-08 12:01:36 +00:00
Maciej Krüger 801d832872
Merge pull request #125451 from zhaofengli/qemu-riscv64-sd-image 2022-01-07 22:14:05 +01:00
Zhaofeng Li 16a907b00b generic-extlinux-compatible: Allow disabling generation of device tree directives 2022-01-06 17:23:10 -08:00
github-actions[bot] 1342506d40
Merge staging-next into staging 2022-01-07 00:04:19 +00:00
0x4A6F 29acc14f0d
Merge pull request #143060 from zhaofengli/binfmt-argv0
nixos/binfmt: Add QEMU wrapper to preserve argv[0]
2022-01-06 19:21:47 +01:00
github-actions[bot] a738715d80
Merge staging-next into staging 2022-01-05 00:02:28 +00:00
pennae fc614c37c6 nixos/documentation: split options doc build
most modules can be evaluated for their documentation in a very
restricted environment that doesn't include all of nixpkgs. this
evaluation can then be cached and reused for subsequent builds, merging
only documentation that has changed into the cached set. since nixos
ships with a large number of modules of which only a few are used in any
given config this can save evaluation a huge percentage of nixos
options available in any given config.

in tests of this caching, despite having to copy most of nixos/, saves
about 80% of the time needed to build the system manual, or about two
second on the machine used for testing. build time for a full system
config shrank from 9.4s to 7.4s, while turning documentation off
entirely shortened the build to 7.1s.
2022-01-02 19:46:13 +01:00
Naïm Favier f2065d81ad stdenv/generic: introduce shellDryRun
Add `shellDryRun` to the generic stdenv and substitute it for uses of
`${stdenv.shell} -n`. The point of this layer of abstraction is to add
the flag `-O extglob`, which resolves #126344 in a more direct way.
2021-12-27 20:30:01 -05:00
Artturi 3239e947d1
Merge pull request #151156 from Artturin/fsckonbat 2021-12-27 04:18:40 +02:00
Michael Hoang 13903fef2d nixos/systemd-boot: Add option to add netboot.xyz 2021-12-23 11:44:29 +11:00
Michael Hoang f6b61981b1 nixos/systemd-boot: Support extra EFI entries 2021-12-23 11:44:29 +11:00
Florian Klink 60e571fa40
Merge pull request #150922 from ncfavier/systemd-tzdir
nixos/systemd: set TZDIR for PID 1
2021-12-22 11:52:27 +01:00
Artturin c44f95a855 nixos/stage1: run fsck on battery too
We are in 2021 almost 2022 not in 2004 when this may have been an issue!

https://alioth-lists.debian.net/pipermail/pkg-sysvinit-devel/2009-May/003196.html
https://www.nico.schottelius.org/blog/debian-ubuntu-fsck-skip-on-battery-bug/
d29daf3952
https://bugs.launchpad.net/ubuntu/+source/laptop-mode/+bug/11194
2021-12-18 06:06:10 +02:00
Graham Christensen 06edb74413
Merge pull request #148785 from pennae/more-option-doc-staticizing
treewide: more defaultText for options
2021-12-17 11:14:08 -05:00
Robert Hensing 4014fb6a64 nixos: Make system.build a lazyAttrsOf unspecified
Legacy types.attrs has really bad merging behavior and does not
support priorities.

f build
2021-12-17 14:42:44 +01:00
Naïm Favier 901d4f13a3
nixos/systemd: set TZDIR for PID 1
Fixes #105049
2021-12-16 04:09:07 +01:00
Bernardo Meurer f40283cf62
Merge pull request #149837 from helsinki-systems/feat/redo-activation-script-restarting
nixos/switch-to-configuration: Add a massive test and do a slight refactor
2021-12-13 11:37:20 -08:00
Janne Heß 6807628791
nixos/switch-to-configuraton: Add details about sockets 2021-12-09 13:51:18 +01:00
Andreas Rammhold 6e69e537ff
Merge pull request #145183 from veehaitch/networkd-DHCPServerStaticLease
nixos/networkd: add `dhcpServerStaticLeaseConfig` option
2021-12-09 12:57:46 +01:00
Janne Heß 2024306048
nixos/switch-to-configuration: Restart non-services 2021-12-09 12:31:48 +01:00
Janne Heß 393c721849
nixos/switch-to-configuration: Move handleModifiedUnit into a sub 2021-12-09 11:31:59 +01:00
pennae 2d564521c0 treewide: add literalDocBook text to options with complex defaults
some options have default that are best described in prose, such as
defaults that depend on the system stateVersion, defaults that are
derivations specific to the surrounding context, or those where the
expression is much longer and harder to understand than a simple text
snippet.
2021-12-09 01:38:24 +01:00
Florian Klink fec4daf38d
Merge pull request #149342 from helsinki-systems/feat/restart-systemd-on-systemconf-change
nixos/switch-to-configuration: Restart systemd when system.conf is changed
2021-12-08 23:23:04 +01:00
ajs124 eee45bb295
Merge pull request #146815 from ElvishJerricco/systemd-utils-expressions
Move systemd-lib.nix and systemd-unit-options.nix into utils
2021-12-08 15:07:28 +00:00
Janne Heß e36ceb65e6
Merge pull request #129449 from ddz/copy-initrd-secrets-after-early-mount-script
nixos/stage1: copy initrd secrets into place after special mounts
2021-12-08 15:38:02 +01:00
Janne Heß 1f41365cda
nixos/switch-to-configuration: Restart systemd when system.conf is changed 2021-12-07 14:32:19 +01:00