aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/nixos
diff options
context:
space:
mode:
authorKatharina Fey <kookie@spacekookie.de>2020-01-12 01:00:12 +0000
committerKatharina Fey <kookie@spacekookie.de>2020-01-12 01:00:12 +0000
commiteeaf5d25d5f6ae7ae1f5bf8a3dee4559693f8147 (patch)
treeafc41ca8dde96b41089ca324533084aef570322f /nixpkgs/nixos
parent63c4c4dda49dc69e5812faa7ef8406180998f3ae (diff)
parente4134747f5666bcab8680aff67fa3b63384f9a0f (diff)
Merge commit 'e4134747f5666bcab8680aff67fa3b63384f9a0f'
Diffstat (limited to 'nixpkgs/nixos')
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/abstractions.xml135
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/config-file.xml8
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/x-windows.xml3
-rw-r--r--nixpkgs/nixos/doc/manual/configuration/xfce.xml19
-rw-r--r--nixpkgs/nixos/doc/manual/development/option-types.xml56
-rw-r--r--nixpkgs/nixos/doc/manual/development/replace-modules.xml4
-rw-r--r--nixpkgs/nixos/doc/manual/development/writing-nixos-tests.xml19
-rw-r--r--nixpkgs/nixos/doc/manual/installation/installing.xml7
-rw-r--r--nixpkgs/nixos/doc/manual/man-nixos-install.xml62
-rw-r--r--nixpkgs/nixos/doc/manual/man-nixos-option.xml9
-rw-r--r--nixpkgs/nixos/doc/manual/release-notes/rl-2003.xml230
-rw-r--r--nixpkgs/nixos/lib/make-ext4-fs.nix44
-rw-r--r--nixpkgs/nixos/lib/test-driver/test-driver.py143
-rw-r--r--nixpkgs/nixos/lib/testing-python.nix13
-rw-r--r--nixpkgs/nixos/lib/testing.nix3
-rwxr-xr-xnixpkgs/nixos/maintainers/scripts/azure/create-azure.sh4
-rw-r--r--nixpkgs/nixos/modules/config/console.nix203
-rw-r--r--nixpkgs/nixos/modules/config/fonts/fontconfig.nix10
-rw-r--r--nixpkgs/nixos/modules/config/fonts/fonts.nix3
-rw-r--r--nixpkgs/nixos/modules/config/i18n.nix76
-rw-r--r--nixpkgs/nixos/modules/config/ldap.nix4
-rw-r--r--nixpkgs/nixos/modules/config/networking.nix20
-rw-r--r--nixpkgs/nixos/modules/config/pulseaudio.nix27
-rw-r--r--nixpkgs/nixos/modules/config/resolvconf.nix6
-rw-r--r--nixpkgs/nixos/modules/config/swap.nix2
-rw-r--r--nixpkgs/nixos/modules/config/users-groups.nix4
-rw-r--r--nixpkgs/nixos/modules/config/xdg/portal.nix4
-rw-r--r--nixpkgs/nixos/modules/hardware/all-firmware.nix8
-rw-r--r--nixpkgs/nixos/modules/hardware/ckb-next.nix5
-rw-r--r--nixpkgs/nixos/modules/hardware/ksm.nix4
-rw-r--r--nixpkgs/nixos/modules/hardware/opengl.nix5
-rw-r--r--nixpkgs/nixos/modules/hardware/video/nvidia.nix9
-rw-r--r--nixpkgs/nixos/modules/i18n/input-method/ibus.nix16
-rw-r--r--nixpkgs/nixos/modules/installer/cd-dvd/iso-image.nix11
-rw-r--r--nixpkgs/nixos/modules/installer/cd-dvd/sd-image.nix13
-rw-r--r--nixpkgs/nixos/modules/installer/cd-dvd/system-tarball-pc.nix5
-rw-r--r--nixpkgs/nixos/modules/installer/cd-dvd/system-tarball-sheevaplug.nix5
-rw-r--r--nixpkgs/nixos/modules/installer/cd-dvd/system-tarball.nix2
-rw-r--r--nixpkgs/nixos/modules/installer/tools/nix-fallback-paths.nix8
-rw-r--r--nixpkgs/nixos/modules/installer/tools/nixos-generate-config.pl5
-rw-r--r--nixpkgs/nixos/modules/installer/tools/nixos-install.sh15
-rw-r--r--nixpkgs/nixos/modules/misc/documentation.nix12
-rw-r--r--nixpkgs/nixos/modules/misc/ids.nix4
-rw-r--r--nixpkgs/nixos/modules/misc/locate.nix5
-rw-r--r--nixpkgs/nixos/modules/misc/version.nix8
-rw-r--r--nixpkgs/nixos/modules/module-list.nix16
-rw-r--r--nixpkgs/nixos/modules/programs/bandwhich.nix29
-rw-r--r--nixpkgs/nixos/modules/programs/bash/bash.nix4
-rw-r--r--nixpkgs/nixos/modules/programs/dconf.nix15
-rw-r--r--nixpkgs/nixos/modules/programs/nm-applet.nix2
-rw-r--r--nixpkgs/nixos/modules/programs/oblogout.nix171
-rw-r--r--nixpkgs/nixos/modules/programs/screen.nix1
-rw-r--r--nixpkgs/nixos/modules/programs/shadow.nix28
-rw-r--r--nixpkgs/nixos/modules/programs/ssmtp.nix5
-rw-r--r--nixpkgs/nixos/modules/programs/sway.nix66
-rw-r--r--nixpkgs/nixos/modules/programs/zsh/oh-my-zsh.nix7
-rw-r--r--nixpkgs/nixos/modules/programs/zsh/zsh-autosuggestions.nix4
-rw-r--r--nixpkgs/nixos/modules/programs/zsh/zsh-syntax-highlighting.nix7
-rw-r--r--nixpkgs/nixos/modules/rename.nix309
-rw-r--r--nixpkgs/nixos/modules/security/acme.nix7
-rw-r--r--nixpkgs/nixos/modules/security/apparmor-suid.nix3
-rw-r--r--nixpkgs/nixos/modules/security/chromium-suid-sandbox.nix4
-rw-r--r--nixpkgs/nixos/modules/security/duosec.nix28
-rw-r--r--nixpkgs/nixos/modules/security/pam.nix18
-rw-r--r--nixpkgs/nixos/modules/security/pam_mount.nix5
-rw-r--r--nixpkgs/nixos/modules/security/polkit.nix5
-rw-r--r--nixpkgs/nixos/modules/security/rtkit.nix5
-rw-r--r--nixpkgs/nixos/modules/security/sudo.nix3
-rw-r--r--nixpkgs/nixos/modules/security/wrappers/default.nix4
-rw-r--r--nixpkgs/nixos/modules/services/admin/oxidized.nix1
-rw-r--r--nixpkgs/nixos/modules/services/audio/alsa.nix3
-rw-r--r--nixpkgs/nixos/modules/services/audio/mpd.nix26
-rw-r--r--nixpkgs/nixos/modules/services/backup/bacula.nix166
-rw-r--r--nixpkgs/nixos/modules/services/backup/borgbackup.nix27
-rw-r--r--nixpkgs/nixos/modules/services/backup/mysql-backup.nix7
-rw-r--r--nixpkgs/nixos/modules/services/backup/postgresql-backup.nix9
-rw-r--r--nixpkgs/nixos/modules/services/backup/tarsnap.nix4
-rw-r--r--nixpkgs/nixos/modules/services/cluster/kubernetes/addons/dashboard.nix4
-rw-r--r--nixpkgs/nixos/modules/services/cluster/kubernetes/apiserver.nix12
-rw-r--r--nixpkgs/nixos/modules/services/cluster/kubernetes/controller-manager.nix5
-rw-r--r--nixpkgs/nixos/modules/services/cluster/kubernetes/default.nix7
-rw-r--r--nixpkgs/nixos/modules/services/cluster/kubernetes/kubelet.nix6
-rw-r--r--nixpkgs/nixos/modules/services/cluster/kubernetes/proxy.nix3
-rw-r--r--nixpkgs/nixos/modules/services/continuous-integration/buildbot/master.nix21
-rw-r--r--nixpkgs/nixos/modules/services/continuous-integration/buildbot/worker.nix21
-rw-r--r--nixpkgs/nixos/modules/services/continuous-integration/gocd-agent/default.nix24
-rw-r--r--nixpkgs/nixos/modules/services/continuous-integration/gocd-server/default.nix24
-rw-r--r--nixpkgs/nixos/modules/services/continuous-integration/jenkins/default.nix24
-rw-r--r--nixpkgs/nixos/modules/services/continuous-integration/jenkins/slave.nix20
-rw-r--r--nixpkgs/nixos/modules/services/databases/4store-endpoint.nix74
-rw-r--r--nixpkgs/nixos/modules/services/databases/4store.nix72
-rw-r--r--nixpkgs/nixos/modules/services/databases/cockroachdb.nix14
-rw-r--r--nixpkgs/nixos/modules/services/databases/foundationdb.nix14
-rw-r--r--nixpkgs/nixos/modules/services/databases/influxdb.nix14
-rw-r--r--nixpkgs/nixos/modules/services/databases/memcached.nix7
-rw-r--r--nixpkgs/nixos/modules/services/databases/mysql.nix6
-rw-r--r--nixpkgs/nixos/modules/services/databases/neo4j.nix15
-rw-r--r--nixpkgs/nixos/modules/services/databases/postgresql.nix4
-rw-r--r--nixpkgs/nixos/modules/services/databases/redis.nix7
-rw-r--r--nixpkgs/nixos/modules/services/databases/virtuoso.nix5
-rw-r--r--nixpkgs/nixos/modules/services/desktops/pantheon/contractor.nix25
-rw-r--r--nixpkgs/nixos/modules/services/desktops/pantheon/files.nix31
-rw-r--r--nixpkgs/nixos/modules/services/development/lorri.nix2
-rw-r--r--nixpkgs/nixos/modules/services/editors/infinoted.nix15
-rw-r--r--nixpkgs/nixos/modules/services/hardware/bluetooth.nix8
-rw-r--r--nixpkgs/nixos/modules/services/hardware/sane_extra_backends/brscan4.nix11
-rw-r--r--nixpkgs/nixos/modules/services/hardware/tcsd.nix14
-rw-r--r--nixpkgs/nixos/modules/services/hardware/tlp.nix15
-rw-r--r--nixpkgs/nixos/modules/services/hardware/udev.nix15
-rw-r--r--nixpkgs/nixos/modules/services/hardware/upower.nix181
-rw-r--r--nixpkgs/nixos/modules/services/hardware/usbmuxd.nix13
-rw-r--r--nixpkgs/nixos/modules/services/logging/awstats.nix298
-rw-r--r--nixpkgs/nixos/modules/services/logging/logcheck.nix7
-rw-r--r--nixpkgs/nixos/modules/services/logging/logstash.nix5
-rw-r--r--nixpkgs/nixos/modules/services/logging/syslog-ng.nix4
-rw-r--r--nixpkgs/nixos/modules/services/mail/dovecot.nix57
-rw-r--r--nixpkgs/nixos/modules/services/mail/dspam.nix14
-rw-r--r--nixpkgs/nixos/modules/services/mail/exim.nix6
-rw-r--r--nixpkgs/nixos/modules/services/mail/mlmmj.nix6
-rw-r--r--nixpkgs/nixos/modules/services/mail/nullmailer.nix7
-rw-r--r--nixpkgs/nixos/modules/services/mail/opendkim.nix17
-rw-r--r--nixpkgs/nixos/modules/services/mail/postfix.nix21
-rw-r--r--nixpkgs/nixos/modules/services/mail/postgrey.nix11
-rw-r--r--nixpkgs/nixos/modules/services/mail/postsrsd.nix14
-rw-r--r--nixpkgs/nixos/modules/services/mail/rspamd.nix8
-rw-r--r--nixpkgs/nixos/modules/services/mail/spamassassin.nix6
-rw-r--r--nixpkgs/nixos/modules/services/misc/apache-kafka.nix5
-rw-r--r--nixpkgs/nixos/modules/services/misc/bepasty.nix18
-rw-r--r--nixpkgs/nixos/modules/services/misc/cgminer.nix7
-rw-r--r--nixpkgs/nixos/modules/services/misc/couchpotato.nix11
-rw-r--r--nixpkgs/nixos/modules/services/misc/dictd.nix10
-rw-r--r--nixpkgs/nixos/modules/services/misc/etcd.nix3
-rw-r--r--nixpkgs/nixos/modules/services/misc/ethminer.nix4
-rw-r--r--nixpkgs/nixos/modules/services/misc/exhibitor.nix3
-rw-r--r--nixpkgs/nixos/modules/services/misc/felix.nix10
-rw-r--r--nixpkgs/nixos/modules/services/misc/folding-at-home.nix5
-rw-r--r--nixpkgs/nixos/modules/services/misc/gitea.nix21
-rw-r--r--nixpkgs/nixos/modules/services/misc/gitlab.nix19
-rw-r--r--nixpkgs/nixos/modules/services/misc/gpsd.nix10
-rw-r--r--nixpkgs/nixos/modules/services/misc/headphones.nix24
-rw-r--r--nixpkgs/nixos/modules/services/misc/home-assistant.nix9
-rw-r--r--nixpkgs/nixos/modules/services/misc/mame.nix67
-rw-r--r--nixpkgs/nixos/modules/services/misc/matrix-synapse.nix43
-rw-r--r--nixpkgs/nixos/modules/services/misc/mediatomb.nix24
-rw-r--r--nixpkgs/nixos/modules/services/misc/nix-daemon.nix14
-rw-r--r--nixpkgs/nixos/modules/services/misc/nixos-manual.nix2
-rw-r--r--nixpkgs/nixos/modules/services/misc/nzbget.nix6
-rw-r--r--nixpkgs/nixos/modules/services/misc/octoprint.nix14
-rw-r--r--nixpkgs/nixos/modules/services/misc/parsoid.nix4
-rw-r--r--nixpkgs/nixos/modules/services/misc/pykms.nix4
-rw-r--r--nixpkgs/nixos/modules/services/misc/redmine.nix16
-rw-r--r--nixpkgs/nixos/modules/services/misc/ripple-data-api.nix5
-rw-r--r--nixpkgs/nixos/modules/services/misc/rippled.nix5
-rw-r--r--nixpkgs/nixos/modules/services/misc/rogue.nix2
-rw-r--r--nixpkgs/nixos/modules/services/misc/serviio.nix13
-rw-r--r--nixpkgs/nixos/modules/services/misc/sickbeard.nix24
-rw-r--r--nixpkgs/nixos/modules/services/misc/siproxd.nix3
-rw-r--r--nixpkgs/nixos/modules/services/misc/taskserver/default.nix16
-rw-r--r--nixpkgs/nixos/modules/services/misc/tautulli.nix4
-rw-r--r--nixpkgs/nixos/modules/services/misc/uhub.nix24
-rw-r--r--nixpkgs/nixos/modules/services/misc/zookeeper.nix3
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/collectd.nix7
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/datadog-agent.nix21
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/dd-agent/dd-agent.nix60
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/fusion-inventory.nix3
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/graphite.nix3
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/heapster.nix3
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/munin.nix10
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/nagios.nix153
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/netdata.nix11
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/prometheus/alertmanager.nix9
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/prometheus/default.nix5
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/prometheus/exporters.nix18
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/statsd.nix3
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/sysstat.nix12
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/telegraf.nix5
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/ups.nix45
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/zabbix-server.nix5
-rw-r--r--nixpkgs/nixos/modules/services/network-filesystems/ceph.nix7
-rw-r--r--nixpkgs/nixos/modules/services/network-filesystems/davfs2.nix23
-rw-r--r--nixpkgs/nixos/modules/services/network-filesystems/drbd.nix6
-rw-r--r--nixpkgs/nixos/modules/services/network-filesystems/nfsd.nix4
-rw-r--r--nixpkgs/nixos/modules/services/network-filesystems/samba.nix3
-rw-r--r--nixpkgs/nixos/modules/services/networking/3proxy.nix424
-rw-r--r--nixpkgs/nixos/modules/services/networking/bind.nix5
-rw-r--r--nixpkgs/nixos/modules/services/networking/bitlbee.nix3
-rw-r--r--nixpkgs/nixos/modules/services/networking/charybdis.nix6
-rw-r--r--nixpkgs/nixos/modules/services/networking/connman.nix36
-rw-r--r--nixpkgs/nixos/modules/services/networking/coturn.nix14
-rw-r--r--nixpkgs/nixos/modules/services/networking/ddclient.nix8
-rw-r--r--nixpkgs/nixos/modules/services/networking/dhcpcd.nix6
-rw-r--r--nixpkgs/nixos/modules/services/networking/dhcpd.nix4
-rw-r--r--nixpkgs/nixos/modules/services/networking/dnschain.nix5
-rw-r--r--nixpkgs/nixos/modules/services/networking/dnscrypt-wrapper.nix3
-rw-r--r--nixpkgs/nixos/modules/services/networking/dnsmasq.nix3
-rw-r--r--nixpkgs/nixos/modules/services/networking/ejabberd.nix14
-rw-r--r--nixpkgs/nixos/modules/services/networking/fakeroute.nix2
-rw-r--r--nixpkgs/nixos/modules/services/networking/firewall.nix15
-rw-r--r--nixpkgs/nixos/modules/services/networking/gale.nix5
-rw-r--r--nixpkgs/nixos/modules/services/networking/git-daemon.nix12
-rw-r--r--nixpkgs/nixos/modules/services/networking/gnunet.nix8
-rw-r--r--nixpkgs/nixos/modules/services/networking/hans.nix3
-rw-r--r--nixpkgs/nixos/modules/services/networking/helpers.nix11
-rw-r--r--nixpkgs/nixos/modules/services/networking/i2pd.nix22
-rw-r--r--nixpkgs/nixos/modules/services/networking/iodine.nix10
-rw-r--r--nixpkgs/nixos/modules/services/networking/ircd-hybrid/default.nix5
-rw-r--r--nixpkgs/nixos/modules/services/networking/kippo.nix5
-rw-r--r--nixpkgs/nixos/modules/services/networking/kresd.nix35
-rw-r--r--nixpkgs/nixos/modules/services/networking/matterbridge.nix13
-rw-r--r--nixpkgs/nixos/modules/services/networking/mjpg-streamer.nix9
-rw-r--r--nixpkgs/nixos/modules/services/networking/monero.nix20
-rw-r--r--nixpkgs/nixos/modules/services/networking/murmur.nix5
-rw-r--r--nixpkgs/nixos/modules/services/networking/mxisd.nix12
-rw-r--r--nixpkgs/nixos/modules/services/networking/namecoind.nix8
-rw-r--r--nixpkgs/nixos/modules/services/networking/nat.nix30
-rw-r--r--nixpkgs/nixos/modules/services/networking/networkmanager.nix103
-rw-r--r--nixpkgs/nixos/modules/services/networking/nntp-proxy.nix5
-rw-r--r--nixpkgs/nixos/modules/services/networking/nsd.nix8
-rw-r--r--nixpkgs/nixos/modules/services/networking/ntp/chrony.nix10
-rw-r--r--nixpkgs/nixos/modules/services/networking/ntp/ntpd.nix5
-rw-r--r--nixpkgs/nixos/modules/services/networking/ntp/openntpd.nix3
-rw-r--r--nixpkgs/nixos/modules/services/networking/openvpn.nix3
-rw-r--r--nixpkgs/nixos/modules/services/networking/owamp.nix7
-rw-r--r--nixpkgs/nixos/modules/services/networking/pdns-recursor.nix2
-rw-r--r--nixpkgs/nixos/modules/services/networking/pdnsd.nix6
-rw-r--r--nixpkgs/nixos/modules/services/networking/polipo.nix10
-rw-r--r--nixpkgs/nixos/modules/services/networking/pppd.nix10
-rw-r--r--nixpkgs/nixos/modules/services/networking/prayer.nix11
-rw-r--r--nixpkgs/nixos/modules/services/networking/privoxy.nix2
-rw-r--r--nixpkgs/nixos/modules/services/networking/quassel.nix16
-rw-r--r--nixpkgs/nixos/modules/services/networking/radicale.nix11
-rw-r--r--nixpkgs/nixos/modules/services/networking/searx.nix2
-rw-r--r--nixpkgs/nixos/modules/services/networking/shairport-sync.nix5
-rw-r--r--nixpkgs/nixos/modules/services/networking/shorewall.nix75
-rw-r--r--nixpkgs/nixos/modules/services/networking/shorewall6.nix75
-rw-r--r--nixpkgs/nixos/modules/services/networking/shout.nix3
-rw-r--r--nixpkgs/nixos/modules/services/networking/smokeping.nix3
-rw-r--r--nixpkgs/nixos/modules/services/networking/spacecookie.nix83
-rw-r--r--nixpkgs/nixos/modules/services/networking/ssh/sshd.nix4
-rw-r--r--nixpkgs/nixos/modules/services/networking/supybot.nix4
-rw-r--r--nixpkgs/nixos/modules/services/networking/syncthing.nix12
-rw-r--r--nixpkgs/nixos/modules/services/networking/tcpcrypt.nix3
-rw-r--r--nixpkgs/nixos/modules/services/networking/tox-bootstrapd.nix5
-rw-r--r--nixpkgs/nixos/modules/services/networking/unbound.nix13
-rw-r--r--nixpkgs/nixos/modules/services/networking/v2ray.nix81
-rw-r--r--nixpkgs/nixos/modules/services/networking/vsftpd.nix21
-rw-r--r--nixpkgs/nixos/modules/services/networking/yggdrasil.nix6
-rw-r--r--nixpkgs/nixos/modules/services/networking/znc/default.nix26
-rw-r--r--nixpkgs/nixos/modules/services/printing/cupsd.nix14
-rw-r--r--nixpkgs/nixos/modules/services/scheduling/atd.nix10
-rw-r--r--nixpkgs/nixos/modules/services/scheduling/fcron.nix5
-rw-r--r--nixpkgs/nixos/modules/services/search/hound.nix22
-rw-r--r--nixpkgs/nixos/modules/services/search/kibana.nix3
-rw-r--r--nixpkgs/nixos/modules/services/search/solr.nix14
-rw-r--r--nixpkgs/nixos/modules/services/security/clamav.nix13
-rw-r--r--nixpkgs/nixos/modules/services/security/fprot.nix14
-rw-r--r--nixpkgs/nixos/modules/services/security/tor.nix6
-rw-r--r--nixpkgs/nixos/modules/services/security/torify.nix3
-rw-r--r--nixpkgs/nixos/modules/services/security/torsocks.nix9
-rw-r--r--nixpkgs/nixos/modules/services/system/dbus.nix5
-rw-r--r--nixpkgs/nixos/modules/services/system/localtime.nix4
-rw-r--r--nixpkgs/nixos/modules/services/torrent/magnetico.nix2
-rw-r--r--nixpkgs/nixos/modules/services/torrent/transmission.nix21
-rw-r--r--nixpkgs/nixos/modules/services/ttys/agetty.nix3
-rw-r--r--nixpkgs/nixos/modules/services/web-apps/frab.nix10
-rw-r--r--nixpkgs/nixos/modules/services/web-apps/ihatemoney/default.nix141
-rw-r--r--nixpkgs/nixos/modules/services/web-apps/limesurvey.nix88
-rw-r--r--nixpkgs/nixos/modules/services/web-apps/matomo.nix8
-rw-r--r--nixpkgs/nixos/modules/services/web-apps/mattermost.nix22
-rw-r--r--nixpkgs/nixos/modules/services/web-apps/mediawiki.nix59
-rw-r--r--nixpkgs/nixos/modules/services/web-apps/moodle.nix54
-rw-r--r--nixpkgs/nixos/modules/services/web-apps/nextcloud.nix11
-rw-r--r--nixpkgs/nixos/modules/services/web-apps/restya-board.nix4
-rw-r--r--nixpkgs/nixos/modules/services/web-apps/trilium.nix137
-rw-r--r--nixpkgs/nixos/modules/services/web-apps/wordpress.nix82
-rw-r--r--nixpkgs/nixos/modules/services/web-apps/zabbix.nix54
-rw-r--r--nixpkgs/nixos/modules/services/web-servers/apache-httpd/default.nix416
-rw-r--r--nixpkgs/nixos/modules/services/web-servers/apache-httpd/per-server-options.nix401
-rw-r--r--nixpkgs/nixos/modules/services/web-servers/nginx/default.nix60
-rw-r--r--nixpkgs/nixos/modules/services/web-servers/nginx/location-options.nix2
-rw-r--r--nixpkgs/nixos/modules/services/web-servers/nginx/vhost-options.nix1
-rw-r--r--nixpkgs/nixos/modules/services/web-servers/phpfpm/default.nix4
-rw-r--r--nixpkgs/nixos/modules/services/web-servers/tomcat.nix10
-rw-r--r--nixpkgs/nixos/modules/services/web-servers/unit/default.nix42
-rw-r--r--nixpkgs/nixos/modules/services/web-servers/uwsgi.nix33
-rw-r--r--nixpkgs/nixos/modules/services/x11/desktop-managers/cde.nix55
-rw-r--r--nixpkgs/nixos/modules/services/x11/desktop-managers/default.nix25
-rw-r--r--nixpkgs/nixos/modules/services/x11/desktop-managers/enlightenment.nix9
-rw-r--r--nixpkgs/nixos/modules/services/x11/desktop-managers/gnome3.nix4
-rw-r--r--nixpkgs/nixos/modules/services/x11/desktop-managers/mate.nix1
-rw-r--r--nixpkgs/nixos/modules/services/x11/desktop-managers/pantheon.nix323
-rw-r--r--nixpkgs/nixos/modules/services/x11/desktop-managers/plasma5.nix8
-rw-r--r--nixpkgs/nixos/modules/services/x11/desktop-managers/surf-display.nix2
-rw-r--r--nixpkgs/nixos/modules/services/x11/desktop-managers/xfce.nix1
-rw-r--r--nixpkgs/nixos/modules/services/x11/display-managers/account-service-util.nix39
-rw-r--r--nixpkgs/nixos/modules/services/x11/display-managers/default.nix256
-rw-r--r--nixpkgs/nixos/modules/services/x11/display-managers/gdm.nix78
-rw-r--r--nixpkgs/nixos/modules/services/x11/display-managers/lightdm-greeters/mini.nix5
-rw-r--r--nixpkgs/nixos/modules/services/x11/display-managers/lightdm-greeters/pantheon.nix3
-rw-r--r--nixpkgs/nixos/modules/services/x11/display-managers/lightdm.nix35
-rw-r--r--nixpkgs/nixos/modules/services/x11/display-managers/sddm.nix25
-rw-r--r--nixpkgs/nixos/modules/services/x11/extra-layouts.nix8
-rw-r--r--nixpkgs/nixos/modules/services/x11/hardware/libinput.nix13
-rw-r--r--nixpkgs/nixos/modules/services/x11/imwheel.nix68
-rw-r--r--nixpkgs/nixos/modules/services/x11/picom.nix (renamed from nixpkgs/nixos/modules/services/x11/compton.nix)34
-rw-r--r--nixpkgs/nixos/modules/services/x11/unclutter.nix3
-rw-r--r--nixpkgs/nixos/modules/services/x11/urxvtd.nix2
-rw-r--r--nixpkgs/nixos/modules/services/x11/window-managers/default.nix15
-rw-r--r--nixpkgs/nixos/modules/services/x11/xserver.nix36
-rw-r--r--nixpkgs/nixos/modules/system/activation/switch-to-configuration.pl12
-rw-r--r--nixpkgs/nixos/modules/system/boot/binfmt.nix4
-rw-r--r--nixpkgs/nixos/modules/system/boot/grow-partition.nix3
-rw-r--r--nixpkgs/nixos/modules/system/boot/kernel.nix5
-rw-r--r--nixpkgs/nixos/modules/system/boot/loader/loader.nix7
-rw-r--r--nixpkgs/nixos/modules/system/boot/luksroot.nix5
-rw-r--r--nixpkgs/nixos/modules/system/boot/networkd.nix14
-rw-r--r--nixpkgs/nixos/modules/system/boot/systemd-nspawn.nix2
-rw-r--r--nixpkgs/nixos/modules/system/boot/systemd.nix5
-rw-r--r--nixpkgs/nixos/modules/tasks/filesystems/nfs.nix6
-rw-r--r--nixpkgs/nixos/modules/tasks/filesystems/zfs.nix70
-rw-r--r--nixpkgs/nixos/modules/tasks/kbd.nix127
-rw-r--r--nixpkgs/nixos/modules/tasks/network-interfaces-systemd.nix4
-rw-r--r--nixpkgs/nixos/modules/virtualisation/container-config.nix1
-rw-r--r--nixpkgs/nixos/modules/virtualisation/containers.nix15
-rw-r--r--nixpkgs/nixos/modules/virtualisation/docker-containers.nix2
-rw-r--r--nixpkgs/nixos/modules/virtualisation/ec2-data.nix4
-rw-r--r--nixpkgs/nixos/modules/virtualisation/libvirtd.nix5
-rw-r--r--nixpkgs/nixos/modules/virtualisation/lxc.nix2
-rw-r--r--nixpkgs/nixos/modules/virtualisation/lxd.nix28
-rw-r--r--nixpkgs/nixos/modules/virtualisation/vmware-guest.nix4
-rw-r--r--nixpkgs/nixos/modules/virtualisation/xen-dom0.nix36
-rw-r--r--nixpkgs/nixos/release-combined.nix4
-rw-r--r--nixpkgs/nixos/tests/3proxy.nix185
-rw-r--r--nixpkgs/nixos/tests/all-tests.nix19
-rw-r--r--nixpkgs/nixos/tests/ceph-multi-node.nix56
-rw-r--r--nixpkgs/nixos/tests/ceph-single-node.nix23
-rw-r--r--nixpkgs/nixos/tests/chromium.nix2
-rw-r--r--nixpkgs/nixos/tests/common/user-account.nix1
-rw-r--r--nixpkgs/nixos/tests/common/x11.nix8
-rw-r--r--nixpkgs/nixos/tests/consul.nix143
-rw-r--r--nixpkgs/nixos/tests/containers-extra_veth.nix71
-rw-r--r--nixpkgs/nixos/tests/containers-macvlans.nix28
-rw-r--r--nixpkgs/nixos/tests/containers-physical_interfaces.nix91
-rw-r--r--nixpkgs/nixos/tests/containers-portforward.nix22
-rw-r--r--nixpkgs/nixos/tests/containers-restart_networking.nix90
-rw-r--r--nixpkgs/nixos/tests/dhparams.nix98
-rw-r--r--nixpkgs/nixos/tests/docker-tools-overlay.nix15
-rw-r--r--nixpkgs/nixos/tests/ec2.nix2
-rw-r--r--nixpkgs/nixos/tests/ecryptfs.nix121
-rw-r--r--nixpkgs/nixos/tests/env.nix25
-rw-r--r--nixpkgs/nixos/tests/ferm.nix30
-rw-r--r--nixpkgs/nixos/tests/gitea.nix134
-rw-r--r--nixpkgs/nixos/tests/gitolite-fcgiwrap.nix93
-rw-r--r--nixpkgs/nixos/tests/gnome3-xorg.nix80
-rw-r--r--nixpkgs/nixos/tests/gocd-agent.nix24
-rw-r--r--nixpkgs/nixos/tests/gocd-server.nix26
-rw-r--r--nixpkgs/nixos/tests/gvisor.nix49
-rw-r--r--nixpkgs/nixos/tests/hadoop/hdfs.nix26
-rw-r--r--nixpkgs/nixos/tests/hadoop/yarn.nix24
-rw-r--r--nixpkgs/nixos/tests/haka.nix10
-rw-r--r--nixpkgs/nixos/tests/haproxy.nix30
-rw-r--r--nixpkgs/nixos/tests/hitch/default.nix14
-rw-r--r--nixpkgs/nixos/tests/home-assistant.nix71
-rw-r--r--nixpkgs/nixos/tests/hydra/default.nix30
-rw-r--r--nixpkgs/nixos/tests/i3wm.nix53
-rw-r--r--nixpkgs/nixos/tests/ihatemoney.nix52
-rw-r--r--nixpkgs/nixos/tests/initrd-network.nix8
-rw-r--r--nixpkgs/nixos/tests/installed-tests/default.nix76
-rw-r--r--nixpkgs/nixos/tests/installed-tests/ibus.nix20
-rw-r--r--nixpkgs/nixos/tests/ipv6.nix81
-rw-r--r--nixpkgs/nixos/tests/keepalived.nix42
-rw-r--r--nixpkgs/nixos/tests/kexec.nix18
-rw-r--r--nixpkgs/nixos/tests/ldap.nix212
-rw-r--r--nixpkgs/nixos/tests/leaps.nix12
-rw-r--r--nixpkgs/nixos/tests/lidarr.nix10
-rw-r--r--nixpkgs/nixos/tests/lightdm.nix3
-rw-r--r--nixpkgs/nixos/tests/mailcatcher.nix16
-rw-r--r--nixpkgs/nixos/tests/matomo.nix17
-rw-r--r--nixpkgs/nixos/tests/mediawiki.nix10
-rw-r--r--nixpkgs/nixos/tests/moinmoin.nix20
-rw-r--r--nixpkgs/nixos/tests/mumble.nix66
-rw-r--r--nixpkgs/nixos/tests/munin.nix44
-rw-r--r--nixpkgs/nixos/tests/mutable-users.nix28
-rw-r--r--nixpkgs/nixos/tests/mxisd.nix17
-rw-r--r--nixpkgs/nixos/tests/mysql.nix18
-rw-r--r--nixpkgs/nixos/tests/nagios.nix116
-rw-r--r--nixpkgs/nixos/tests/nat.nix55
-rw-r--r--nixpkgs/nixos/tests/nesting.nix36
-rw-r--r--nixpkgs/nixos/tests/netdata.nix1
-rw-r--r--nixpkgs/nixos/tests/networking.nix473
-rw-r--r--nixpkgs/nixos/tests/nfs.nix90
-rw-r--r--nixpkgs/nixos/tests/nfs/default.nix9
-rw-r--r--nixpkgs/nixos/tests/nfs/kerberos.nix133
-rw-r--r--nixpkgs/nixos/tests/nfs/simple.nix94
-rw-r--r--nixpkgs/nixos/tests/nghttpx.nix10
-rw-r--r--nixpkgs/nixos/tests/nginx-etag.nix89
-rw-r--r--nixpkgs/nixos/tests/nginx-sso.nix24
-rw-r--r--nixpkgs/nixos/tests/nginx.nix97
-rw-r--r--nixpkgs/nixos/tests/novacomd.nix32
-rw-r--r--nixpkgs/nixos/tests/nzbget.nix18
-rw-r--r--nixpkgs/nixos/tests/openarena.nix15
-rw-r--r--nixpkgs/nixos/tests/openldap.nix10
-rw-r--r--nixpkgs/nixos/tests/orangefs.nix52
-rw-r--r--nixpkgs/nixos/tests/osrm-backend.nix14
-rw-r--r--nixpkgs/nixos/tests/overlayfs.nix77
-rw-r--r--nixpkgs/nixos/tests/pam-oath-login.nix110
-rw-r--r--nixpkgs/nixos/tests/pam-u2f.nix8
-rw-r--r--nixpkgs/nixos/tests/paperless.nix29
-rw-r--r--nixpkgs/nixos/tests/pdns-recursor.nix6
-rw-r--r--nixpkgs/nixos/tests/peerflix.nix8
-rw-r--r--nixpkgs/nixos/tests/pgmanage.nix12
-rw-r--r--nixpkgs/nixos/tests/php-pcre.nix9
-rw-r--r--nixpkgs/nixos/tests/plasma5.nix2
-rw-r--r--nixpkgs/nixos/tests/postgis.nix12
-rw-r--r--nixpkgs/nixos/tests/predictable-interface-names.nix6
-rw-r--r--nixpkgs/nixos/tests/proxy.nix15
-rw-r--r--nixpkgs/nixos/tests/quagga.nix28
-rw-r--r--nixpkgs/nixos/tests/radicale.nix88
-rw-r--r--nixpkgs/nixos/tests/resolv.nix46
-rw-r--r--nixpkgs/nixos/tests/rspamd.nix159
-rw-r--r--nixpkgs/nixos/tests/sddm.nix6
-rw-r--r--nixpkgs/nixos/tests/slurm.nix2
-rw-r--r--nixpkgs/nixos/tests/sonarr.nix8
-rw-r--r--nixpkgs/nixos/tests/spacecookie.nix51
-rw-r--r--nixpkgs/nixos/tests/switch-test.nix10
-rw-r--r--nixpkgs/nixos/tests/systemd-analyze.nix46
-rw-r--r--nixpkgs/nixos/tests/systemd-timesyncd.nix24
-rw-r--r--nixpkgs/nixos/tests/tiddlywiki.nix80
-rw-r--r--nixpkgs/nixos/tests/timezone.nix95
-rw-r--r--nixpkgs/nixos/tests/trilium-server.nix53
-rw-r--r--nixpkgs/nixos/tests/upnp.nix8
-rw-r--r--nixpkgs/nixos/tests/wireguard/namespaces.nix18
-rw-r--r--nixpkgs/nixos/tests/xmonad.nix8
-rw-r--r--nixpkgs/nixos/tests/xrdp.nix36
-rw-r--r--nixpkgs/nixos/tests/zsh-history.nix35
435 files changed, 8798 insertions, 5052 deletions
diff --git a/nixpkgs/nixos/doc/manual/configuration/abstractions.xml b/nixpkgs/nixos/doc/manual/configuration/abstractions.xml
index 5bf0635cc1a..df9ff2615e1 100644
--- a/nixpkgs/nixos/doc/manual/configuration/abstractions.xml
+++ b/nixpkgs/nixos/doc/manual/configuration/abstractions.xml
@@ -11,50 +11,46 @@
<programlisting>
{
<xref linkend="opt-services.httpd.virtualHosts"/> =
- [ { hostName = "example.org";
- documentRoot = "/webroot";
+ { "blog.example.org" = {
+ documentRoot = "/webroot/blog.example.org";
adminAddr = "alice@example.org";
- enableUserDir = true;
- }
- { hostName = "example.org";
- documentRoot = "/webroot";
+ forceSSL = true;
+ enableACME = true;
+ enablePHP = true;
+ };
+ "wiki.example.org" = {
+ documentRoot = "/webroot/wiki.example.org";
adminAddr = "alice@example.org";
- enableUserDir = true;
- enableSSL = true;
- sslServerCert = "/root/ssl-example-org.crt";
- sslServerKey = "/root/ssl-example-org.key";
- }
- ];
+ forceSSL = true;
+ enableACME = true;
+ enablePHP = true;
+ };
+ };
}
</programlisting>
It defines two virtual hosts with nearly identical configuration; the only
- difference is that the second one has SSL enabled. To prevent this
+ difference is the document root directories. To prevent this
duplication, we can use a <literal>let</literal>:
<programlisting>
let
- exampleOrgCommon =
- { hostName = "example.org";
- documentRoot = "/webroot";
- adminAddr = "alice@example.org";
- enableUserDir = true;
+ commonConfig =
+ { adminAddr = "alice@example.org";
+ forceSSL = true;
+ enableACME = true;
};
in
{
<xref linkend="opt-services.httpd.virtualHosts"/> =
- [ exampleOrgCommon
- (exampleOrgCommon // {
- enableSSL = true;
- sslServerCert = "/root/ssl-example-org.crt";
- sslServerKey = "/root/ssl-example-org.key";
- })
- ];
+ { "blog.example.org" = (commonConfig // { documentRoot = "/webroot/blog.example.org"; });
+ "wiki.example.org" = (commonConfig // { documentRoot = "/webroot/wiki.example.com"; });
+ };
}
</programlisting>
- The <literal>let exampleOrgCommon = <replaceable>...</replaceable></literal>
- defines a variable named <literal>exampleOrgCommon</literal>. The
+ The <literal>let commonConfig = <replaceable>...</replaceable></literal>
+ defines a variable named <literal>commonConfig</literal>. The
<literal>//</literal> operator merges two attribute sets, so the
configuration of the second virtual host is the set
- <literal>exampleOrgCommon</literal> extended with the SSL options.
+ <literal>commonConfig</literal> extended with the document root option.
</para>
<para>
@@ -63,13 +59,13 @@ in
<programlisting>
{
<xref linkend="opt-services.httpd.virtualHosts"/> =
- let exampleOrgCommon = <replaceable>...</replaceable>; in
- [ exampleOrgCommon
- (exampleOrgCommon // { <replaceable>...</replaceable> })
- ];
+ let commonConfig = <replaceable>...</replaceable>; in
+ { "blog.example.org" = (commonConfig // { <replaceable>...</replaceable> })
+ "wiki.example.org" = (commonConfig // { <replaceable>...</replaceable> })
+ };
}
</programlisting>
- but not <literal>{ let exampleOrgCommon = <replaceable>...</replaceable>; in
+ but not <literal>{ let commonConfig = <replaceable>...</replaceable>; in
<replaceable>...</replaceable>; }</literal> since attributes (as opposed to
attribute values) are not expressions.
</para>
@@ -77,80 +73,29 @@ in
<para>
<emphasis>Functions</emphasis> provide another method of abstraction. For
instance, suppose that we want to generate lots of different virtual hosts,
- all with identical configuration except for the host name. This can be done
+ all with identical configuration except for the document root. This can be done
as follows:
<programlisting>
{
<xref linkend="opt-services.httpd.virtualHosts"/> =
let
- makeVirtualHost = name:
- { hostName = name;
- documentRoot = "/webroot";
+ makeVirtualHost = webroot:
+ { documentRoot = webroot;
adminAddr = "alice@example.org";
+ forceSSL = true;
+ enableACME = true;
};
in
- [ (makeVirtualHost "example.org")
- (makeVirtualHost "example.com")
- (makeVirtualHost "example.gov")
- (makeVirtualHost "example.nl")
- ];
+ { "example.org" = (makeVirtualHost "/webroot/example.org");
+ "example.com" = (makeVirtualHost "/webroot/example.com");
+ "example.gov" = (makeVirtualHost "/webroot/example.gov");
+ "example.nl" = (makeVirtualHost "/webroot/example.nl");
+ };
}
</programlisting>
Here, <varname>makeVirtualHost</varname> is a function that takes a single
- argument <literal>name</literal> and returns the configuration for a virtual
+ argument <literal>webroot</literal> and returns the configuration for a virtual
host. That function is then called for several names to produce the list of
virtual host configurations.
</para>
-
- <para>
- We can further improve on this by using the function <varname>map</varname>,
- which applies another function to every element in a list:
-<programlisting>
-{
- <xref linkend="opt-services.httpd.virtualHosts"/> =
- let
- makeVirtualHost = <replaceable>...</replaceable>;
- in map makeVirtualHost
- [ "example.org" "example.com" "example.gov" "example.nl" ];
-}
-</programlisting>
- (The function <literal>map</literal> is called a <emphasis>higher-order
- function</emphasis> because it takes another function as an argument.)
- </para>
-
- <para>
- What if you need more than one argument, for instance, if we want to use a
- different <literal>documentRoot</literal> for each virtual host? Then we can
- make <varname>makeVirtualHost</varname> a function that takes a
- <emphasis>set</emphasis> as its argument, like this:
-<programlisting>
-{
- <xref linkend="opt-services.httpd.virtualHosts"/> =
- let
- makeVirtualHost = { name, root }:
- { hostName = name;
- documentRoot = root;
- adminAddr = "alice@example.org";
- };
- in map makeVirtualHost
- [ { name = "example.org"; root = "/sites/example.org"; }
- { name = "example.com"; root = "/sites/example.com"; }
- { name = "example.gov"; root = "/sites/example.gov"; }
- { name = "example.nl"; root = "/sites/example.nl"; }
- ];
-}
-</programlisting>
- But in this case (where every root is a subdirectory of
- <filename>/sites</filename> named after the virtual host), it would have been
- shorter to define <varname>makeVirtualHost</varname> as
-<programlisting>
-makeVirtualHost = name:
- { hostName = name;
- documentRoot = "/sites/${name}";
- adminAddr = "alice@example.org";
- };
-</programlisting>
- Here, the construct <literal>${<replaceable>...</replaceable>}</literal>
- allows the result of an expression to be spliced into a string.
- </para>
</section>
diff --git a/nixpkgs/nixos/doc/manual/configuration/config-file.xml b/nixpkgs/nixos/doc/manual/configuration/config-file.xml
index eadafb94b8f..7ccb5b3664e 100644
--- a/nixpkgs/nixos/doc/manual/configuration/config-file.xml
+++ b/nixpkgs/nixos/doc/manual/configuration/config-file.xml
@@ -27,7 +27,7 @@
{ <xref linkend="opt-services.httpd.enable"/> = true;
<xref linkend="opt-services.httpd.adminAddr"/> = "alice@example.org";
- <xref linkend="opt-services.httpd.documentRoot"/> = "/webroot";
+ <link linkend="opt-services.httpd.virtualHosts">services.httpd.virtualHosts.localhost.documentRoot</link> = "/webroot";
}
</programlisting>
defines a configuration with three option definitions that together enable
@@ -50,7 +50,11 @@
httpd = {
enable = true;
adminAddr = "alice@example.org";
- documentRoot = "/webroot";
+ virtualHosts = {
+ localhost = {
+ documentRoot = "/webroot";
+ };
+ };
};
};
}
diff --git a/nixpkgs/nixos/doc/manual/configuration/x-windows.xml b/nixpkgs/nixos/doc/manual/configuration/x-windows.xml
index 9206f43ea39..55ad9fe6e65 100644
--- a/nixpkgs/nixos/doc/manual/configuration/x-windows.xml
+++ b/nixpkgs/nixos/doc/manual/configuration/x-windows.xml
@@ -83,8 +83,7 @@
desktop environment. If you wanted no desktop environment and i3 as your your
window manager, you'd define:
<programlisting>
-<xref linkend="opt-services.xserver.desktopManager.default"/> = "none";
-<xref linkend="opt-services.xserver.windowManager.default"/> = "i3";
+<xref linkend="opt-services.xserver.displayManager.defaultSession"/> = "none+i3";
</programlisting>
And, finally, to enable auto-login for a user <literal>johndoe</literal>:
<programlisting>
diff --git a/nixpkgs/nixos/doc/manual/configuration/xfce.xml b/nixpkgs/nixos/doc/manual/configuration/xfce.xml
index 6ac99c6b2be..7d2862f8b31 100644
--- a/nixpkgs/nixos/doc/manual/configuration/xfce.xml
+++ b/nixpkgs/nixos/doc/manual/configuration/xfce.xml
@@ -7,22 +7,21 @@
<para>
To enable the Xfce Desktop Environment, set
<programlisting>
-<link linkend="opt-services.xserver.desktopManager.default">services.xserver.desktopManager</link> = {
- <link linkend="opt-services.xserver.desktopManager.xfce.enable">xfce.enable</link> = true;
- <link linkend="opt-services.xserver.desktopManager.default">default</link> = "xfce";
+<xref linkend="opt-services.xserver.desktopManager.xfce.enable" /> = true;
+<xref linkend="opt-services.xserver.displayManager.defaultSession" /> = "xfce";
};
</programlisting>
</para>
<para>
- Optionally, <emphasis>compton</emphasis> can be enabled for nice graphical
+ Optionally, <emphasis>picom</emphasis> can be enabled for nice graphical
effects, some example settings:
<programlisting>
-<link linkend="opt-services.compton.enable">services.compton</link> = {
- <link linkend="opt-services.compton.enable">enable</link> = true;
- <link linkend="opt-services.compton.fade">fade</link> = true;
- <link linkend="opt-services.compton.inactiveOpacity">inactiveOpacity</link> = "0.9";
- <link linkend="opt-services.compton.shadow">shadow</link> = true;
- <link linkend="opt-services.compton.fadeDelta">fadeDelta</link> = 4;
+<link linkend="opt-services.picom.enable">services.picom</link> = {
+ <link linkend="opt-services.picom.enable">enable</link> = true;
+ <link linkend="opt-services.picom.fade">fade</link> = true;
+ <link linkend="opt-services.picom.inactiveOpacity">inactiveOpacity</link> = "0.9";
+ <link linkend="opt-services.picom.shadow">shadow</link> = true;
+ <link linkend="opt-services.picom.fadeDelta">fadeDelta</link> = 4;
};
</programlisting>
</para>
diff --git a/nixpkgs/nixos/doc/manual/development/option-types.xml b/nixpkgs/nixos/doc/manual/development/option-types.xml
index 8fcbb627342..1ec7e3efad7 100644
--- a/nixpkgs/nixos/doc/manual/development/option-types.xml
+++ b/nixpkgs/nixos/doc/manual/development/option-types.xml
@@ -259,12 +259,66 @@
A set of sub options <replaceable>o</replaceable>.
<replaceable>o</replaceable> can be an attribute set or a function
returning an attribute set. Submodules are used in composed types to
- create modular options. Submodule are detailed in
+ create modular options. This is equivalent to
+ <literal>types.submoduleWith { modules = toList o; shorthandOnlyDefinesConfig = true; }</literal>.
+ Submodules are detailed in
<xref
linkend='section-option-types-submodule' />.
</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>
+ <varname>types.submoduleWith</varname> {
+ <replaceable>modules</replaceable>,
+ <replaceable>specialArgs</replaceable> ? {},
+ <replaceable>shorthandOnlyDefinesConfig</replaceable> ? false }
+ </term>
+ <listitem>
+ <para>
+ Like <varname>types.submodule</varname>, but more flexible and with better defaults.
+ It has parameters
+ <itemizedlist>
+ <listitem><para>
+ <replaceable>modules</replaceable>
+ A list of modules to use by default for this submodule type. This gets combined
+ with all option definitions to build the final list of modules that will be included.
+ <note><para>
+ Only options defined with this argument are included in rendered documentation.
+ </para></note>
+ </para></listitem>
+ <listitem><para>
+ <replaceable>specialArgs</replaceable>
+ An attribute set of extra arguments to be passed to the module functions.
+ The option <literal>_module.args</literal> should be used instead
+ for most arguments since it allows overriding. <replaceable>specialArgs</replaceable> should only be
+ used for arguments that can&apos;t go through the module fixed-point, because of
+ infinite recursion or other problems. An example is overriding the
+ <varname>lib</varname> argument, because <varname>lib</varname> itself is used
+ to define <literal>_module.args</literal>, which makes using
+ <literal>_module.args</literal> to define it impossible.
+ </para></listitem>
+ <listitem><para>
+ <replaceable>shorthandOnlyDefinesConfig</replaceable>
+ Whether definitions of this type should default to the <literal>config</literal>
+ section of a module (see <xref linkend='ex-module-syntax'/>) if it is an attribute
+ set. Enabling this only has a benefit when the submodule defines an option named
+ <literal>config</literal> or <literal>options</literal>. In such a case it would
+ allow the option to be set with <literal>the-submodule.config = "value"</literal>
+ instead of requiring <literal>the-submodule.config.config = "value"</literal>.
+ This is because only when modules <emphasis>don&apos;t</emphasis> set the
+ <literal>config</literal> or <literal>options</literal> keys, all keys are interpreted
+ as option definitions in the <literal>config</literal> section. Enabling this option
+ implicitly puts all attributes in the <literal>config</literal> section.
+ </para>
+ <para>
+ With this option enabled, defining a non-<literal>config</literal> section requires
+ using a function: <literal>the-submodule = { ... }: { options = { ... }; }</literal>.
+ </para></listitem>
+ </itemizedlist>
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</section>
diff --git a/nixpkgs/nixos/doc/manual/development/replace-modules.xml b/nixpkgs/nixos/doc/manual/development/replace-modules.xml
index 7b103c36d90..b4a466e2294 100644
--- a/nixpkgs/nixos/doc/manual/development/replace-modules.xml
+++ b/nixpkgs/nixos/doc/manual/development/replace-modules.xml
@@ -6,8 +6,8 @@
<title>Replace Modules</title>
<para>
- Modules that are imported can also be disabled. The option declarations and
- config implementation of a disabled module will be ignored, allowing another
+ Modules that are imported can also be disabled. The option declarations,
+ config implementation and the imports of a disabled module will be ignored, allowing another
to take it's place. This can be used to import a set of modules from another
channel while keeping the rest of the system on a stable release.
</para>
diff --git a/nixpkgs/nixos/doc/manual/development/writing-nixos-tests.xml b/nixpkgs/nixos/doc/manual/development/writing-nixos-tests.xml
index 24efd2e3273..e5a887c18c7 100644
--- a/nixpkgs/nixos/doc/manual/development/writing-nixos-tests.xml
+++ b/nixpkgs/nixos/doc/manual/development/writing-nixos-tests.xml
@@ -419,4 +419,23 @@ machine.wait_for_unit("xautolock.service", "x-session-user")
<literal>wait_for_unit</literal>, <literal>start_job</literal> and
<literal>stop_job</literal>.
</para>
+
+ <para>
+ For faster dev cycles it's also possible to disable the code-linters (this shouldn't
+ be commited though):
+<programlisting>
+import ./make-test-python.nix {
+ skipLint = true;
+ machine =
+ { config, pkgs, ... }:
+ { <replaceable>configuration…</replaceable>
+ };
+
+ testScript =
+ ''
+ <replaceable>Python code…</replaceable>
+ '';
+}
+</programlisting>
+ </para>
</section>
diff --git a/nixpkgs/nixos/doc/manual/installation/installing.xml b/nixpkgs/nixos/doc/manual/installation/installing.xml
index 7991c43e01f..4041b4ad163 100644
--- a/nixpkgs/nixos/doc/manual/installation/installing.xml
+++ b/nixpkgs/nixos/doc/manual/installation/installing.xml
@@ -380,7 +380,10 @@
</para>
<para>
If you need to configure networking for your machine the configuration
- options are described in <xref linkend="sec-networking"/>.
+ options are described in <xref linkend="sec-networking"/>. In particular,
+ while wifi is supported on the installation image, it is not enabled by
+ default in the configuration generated by
+ <command>nixos-generate-config</command>.
</para>
<para>
Another critical option is <option>fileSystems</option>, specifying the
@@ -475,7 +478,7 @@ Retype new UNIX password: ***</screen>
shows what packages are available, and
<screen>
<prompt>$ </prompt>nix-env -f '&lt;nixpkgs&gt;' -iA w3m</screen>
- install the <literal>w3m</literal> browser.
+ installs the <literal>w3m</literal> browser.
</para>
</listitem>
</orderedlist>
diff --git a/nixpkgs/nixos/doc/manual/man-nixos-install.xml b/nixpkgs/nixos/doc/manual/man-nixos-install.xml
index 45bbd5d81ff..0752c397182 100644
--- a/nixpkgs/nixos/doc/manual/man-nixos-install.xml
+++ b/nixpkgs/nixos/doc/manual/man-nixos-install.xml
@@ -15,6 +15,26 @@
<cmdsynopsis>
<command>nixos-install</command>
<arg>
+ <group choice='req'>
+ <arg choice='plain'>
+ <option>--verbose</option>
+ </arg>
+ <arg choice='plain'>
+ <option>-v</option>
+ </arg>
+ </group>
+ </arg>
+ <arg>
+ <group choice='req'>
+ <arg choice='plain'>
+ <option>--print-build-logs</option>
+ </arg>
+ <arg choice='plain'>
+ <option>-L</option>
+ </arg>
+ </group>
+ </arg>
+ <arg>
<arg choice='plain'>
<option>-I</option>
</arg>
@@ -36,6 +56,13 @@
</arg>
<arg>
+ <arg choice='plain'>
+ <option>--channel</option>
+ </arg>
+ <replaceable>channel</replaceable>
+ </arg>
+
+ <arg>
<arg choice='plain'>
<option>--no-channel-copy</option>
</arg>
@@ -107,6 +134,12 @@
</para>
</listitem>
<listitem>
+ <para>
+ It installs the current channel <quote>nixos</quote> in the target channel
+ profile (unless <option>--no-channel-copy</option> is specified).
+ </para>
+ </listitem>
+ <listitem>
<para>
It installs the GRUB boot loader on the device specified in the option
<option>boot.loader.grub.device</option> (unless
@@ -135,6 +168,23 @@
</para>
<variablelist>
<varlistentry>
+ <term><option>--verbose</option> / <option>-v</option></term>
+ <listitem>
+ <para>Increases the level of verbosity of diagnostic messages
+ printed on standard error. For each Nix operation, the information
+ printed on standard output is well-defined; any diagnostic
+ information is printed on standard error, never on standard
+ output.</para>
+ <para>Please note that this option may be specified repeatedly.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>--print-build-logs</option> / <option>-L</option></term>
+ <listitem>
+ <para>Print the full build logs of <command>nix build</command> to stderr.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term>
<option>--root</option>
</term>
@@ -166,6 +216,18 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term>
+ <option>--channel</option>
+ </term>
+ <listitem>
+ <para>
+ If this option is provided, do not copy the current
+ <quote>nixos</quote> channel to the target host. Instead, use the
+ specified derivation.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term>
<option>-I</option>
</term>
diff --git a/nixpkgs/nixos/doc/manual/man-nixos-option.xml b/nixpkgs/nixos/doc/manual/man-nixos-option.xml
index beabf020c92..b82f3125609 100644
--- a/nixpkgs/nixos/doc/manual/man-nixos-option.xml
+++ b/nixpkgs/nixos/doc/manual/man-nixos-option.xml
@@ -119,4 +119,13 @@ Defined by:
bug, please report to Nicolas Pierron.
</para>
</refsection>
+ <refsection>
+ <title>See also</title>
+ <para>
+ <citerefentry>
+ <refentrytitle>configuration.nix</refentrytitle>
+ <manvolnum>5</manvolnum>
+ </citerefentry>
+ </para>
+ </refsection>
</refentry>
diff --git a/nixpkgs/nixos/doc/manual/release-notes/rl-2003.xml b/nixpkgs/nixos/doc/manual/release-notes/rl-2003.xml
index 2a5064c71b0..ca319dfea41 100644
--- a/nixpkgs/nixos/doc/manual/release-notes/rl-2003.xml
+++ b/nixpkgs/nixos/doc/manual/release-notes/rl-2003.xml
@@ -55,6 +55,19 @@
and adding a <option>--all</option> option which prints all options and their values.
</para>
</listitem>
+ <listitem>
+ <para>
+ <option>services.xserver.desktopManager.default</option> and <option>services.xserver.windowManager.default</option> options were replaced by a single <xref linkend="opt-services.xserver.displayManager.defaultSession"/> option to improve support for upstream session files. If you used something like:
+<programlisting>
+services.xserver.desktopManager.default = "xfce";
+services.xserver.windowManager.default = "icewm";
+</programlisting>
+ you should change it to:
+<programlisting>
+services.xserver.displayManager.defaultSession = "xfce+icewm";
+</programlisting>
+ </para>
+ </listitem>
</itemizedlist>
</section>
@@ -77,6 +90,12 @@
be set if the hostname of the node should be non default.
</para>
</listitem>
+ <listitem>
+ <para>
+ UPower's configuration is now managed by NixOS and can be customized
+ via <option>services.upower</option>.
+ </para>
+ </listitem>
</itemizedlist>
</section>
@@ -121,18 +140,18 @@
</listitem>
<listitem>
<para>
- The <literal>99-main.network</literal> file was removed. Maching all
- network interfaces caused many breakages, see
- <link xlink:href="https://github.com/NixOS/nixpkgs/pull/18962">#18962</link>
- and <link xlink:href="https://github.com/NixOS/nixpkgs/pull/71106">#71106</link>.
+ The <literal>99-main.network</literal> file was removed. Maching all
+ network interfaces caused many breakages, see
+ <link xlink:href="https://github.com/NixOS/nixpkgs/pull/18962">#18962</link>
+ and <link xlink:href="https://github.com/NixOS/nixpkgs/pull/71106">#71106</link>.
</para>
<para>
- We already don't support the global <link linkend="opt-networking.useDHCP">networking.useDHCP</link>,
- <link linkend="opt-networking.defaultGateway">networking.defaultGateway</link> and
- <link linkend="opt-networking.defaultGateway6">networking.defaultGateway6</link> options
- if <link linkend="opt-networking.useNetworkd">networking.useNetworkd</link> is enabled,
- but direct users to configure the per-device
- <link linkend="opt-networking.interfaces">networking.interfaces.&lt;name&gt;.…</link> options.
+ We already don't support the global <link linkend="opt-networking.useDHCP">networking.useDHCP</link>,
+ <link linkend="opt-networking.defaultGateway">networking.defaultGateway</link> and
+ <link linkend="opt-networking.defaultGateway6">networking.defaultGateway6</link> options
+ if <link linkend="opt-networking.useNetworkd">networking.useNetworkd</link> is enabled,
+ but direct users to configure the per-device
+ <link linkend="opt-networking.interfaces">networking.interfaces.&lt;name&gt;.…</link> options.
</para>
</listitem>
<listitem>
@@ -198,6 +217,179 @@
The <literal>buildRustCrate</literal> infrastructure now produces <literal>lib</literal> outputs in addition to the <literal>out</literal> output.
This has led to drastically reduced closed sizes for some rust crates since development dependencies are now in the <literal>lib</literal> output.
</para>
+ </listitem>
+ <listitem>
+ <para>
+ Pango was upgraded to 1.44, which no longer uses freetype for font loading. This means that type1
+ and bitmap fonts are no longer supported in applications relying on Pango for font rendering
+ (notably, GTK application). See <link xlink:href="https://gitlab.gnome.org/GNOME/pango/issues/386">
+ upstream issue</link> for more information.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ The packages <literal>openobex</literal> and <literal>obexftp</literal>
+ are no longer installed when enabling Bluetooth via
+ <option>hardware.bluetooth.enable</option>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ The <literal>dump1090</literal> derivation has been changed to use FlightAware's dump1090
+ as its upstream. However, this version does not have an internal webserver anymore. The
+ assets in the <literal>share/dump1090</literal> directory of the derivation can be used
+ in conjunction with an external webserver to replace this functionality.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ The fourStore and fourStoreEndpoint modules have been removed.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Polkit no longer has the user of uid 0 (root) as an admin identity.
+ We now follow the upstream default of only having every member of the wheel
+ group admin privileged. Before it was root and members of wheel.
+ The positive outcome of this is pkexec GUI popups or terminal prompts
+ will no longer require the user to choose between two essentially equivalent
+ choices (whether to perform the action as themselves with wheel permissions, or as the root user).
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ NixOS containers no longer build NixOS manual by default. This saves evaluation time,
+ especially if there are many declarative containers defined. Note that this is already done
+ when <literal>&lt;nixos/modules/profiles/minimal.nix&gt;</literal> module is included
+ in container config.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ The <literal>kresd</literal> services deprecates the <literal>interfaces</literal> option
+ in favor of the <literal>listenPlain</literal> option which requires full
+ <link xlink:href="https://www.freedesktop.org/software/systemd/man/systemd.socket.html#ListenStream=">systemd.socket compatible</link>
+ declaration which always include a port.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Virtual console options have been reorganized and can be found under
+ a single top-level attribute: <literal>console</literal>.
+ The full set of changes is as follows:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>i18n.consoleFont</literal> renamed to
+ <link linkend="opt-console.font">console.font</link>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>i18n.consoleKeyMap</literal> renamed to
+ <link linkend="opt-console.keyMap">console.keyMap</link>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>i18n.consoleColors</literal> renamed to
+ <link linkend="opt-console.colors">console.colors</link>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>i18n.consolePackages</literal> renamed to
+ <link linkend="opt-console.packages">console.packages</link>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>i18n.consoleUseXkbConfig</literal> renamed to
+ <link linkend="opt-console.useXkbConfig">console.useXkbConfig</link>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>boot.earlyVconsoleSetup</literal> renamed to
+ <link linkend="opt-console.earlySetup">console.earlySetup</link>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>boot.extraTTYs</literal> renamed to
+ <link linkend="opt-console.extraTTYs">console.extraTTYs</link>
+ </para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ <listitem>
+ <para>
+ The <link linkend="opt-services.awstats.enable">awstats</link> module has been rewritten
+ to serve stats via static html pages, updated on a timer, over <link linkend="opt-services.nginx.virtualHosts">nginx</link>,
+ instead of dynamic cgi pages over <link linkend="opt-services.httpd.enable">apache</link>.
+ </para>
+ <para>
+ Minor changes will be required to migrate existing configurations. Details of the
+ required changes can seen by looking through the <link linkend="opt-services.awstats.enable">awstats</link>
+ module.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ The httpd module no longer provides options to support serving web content without defining a virtual host. As a
+ result of this the <link linkend="opt-services.httpd.logPerVirtualHost">services.httpd.logPerVirtualHost</link>
+ option now defaults to <literal>true</literal> instead of <literal>false</literal>. Please update your
+ configuration to make use of <link linkend="opt-services.httpd.virtualHosts">services.httpd.virtualHosts</link>.
+ </para>
+ <para>
+ The <link linkend="opt-services.httpd.virtualHosts">services.httpd.virtualHosts.&lt;name&gt;</link>
+ option has changed type from a list of submodules to an attribute set of submodules, better matching
+ <link linkend="opt-services.nginx.virtualHosts">services.nginx.virtualHosts.&lt;name&gt;</link>.
+ </para>
+ <para>
+ This change comes with the addition of the following options which mimic the functionality of their <literal>nginx</literal> counterparts:
+ <link linkend="opt-services.httpd.virtualHosts">services.httpd.virtualHosts.&lt;name&gt;.addSSL</link>,
+ <link linkend="opt-services.httpd.virtualHosts">services.httpd.virtualHosts.&lt;name&gt;.forceSSL</link>,
+ <link linkend="opt-services.httpd.virtualHosts">services.httpd.virtualHosts.&lt;name&gt;.onlySSL</link>,
+ <link linkend="opt-services.httpd.virtualHosts">services.httpd.virtualHosts.&lt;name&gt;.enableACME</link>,
+ <link linkend="opt-services.httpd.virtualHosts">services.httpd.virtualHosts.&lt;name&gt;.acmeRoot</link>, and
+ <link linkend="opt-services.httpd.virtualHosts">services.httpd.virtualHosts.&lt;name&gt;.useACMEHost</link>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ For NixOS configuration options, the <literal>loaOf</literal> type has
+ been deprecated and will be removed in a future release. In nixpkgs,
+ options of this type will be changed to <literal>attrsOf</literal>
+ instead. If you were using one of these in your configuration, you will
+ see a warning suggesting what changes will be required.
+ </para>
+ <para>
+ For example, <link linkend="opt-users.users">users.users</link> is a
+ <literal>loaOf</literal> option that is commonly used as follows:
+ <programlisting>
+users.users =
+ [ { name = "me";
+ description = "My personal user.";
+ isNormalUser = true;
+ }
+ ];
+ </programlisting>
+ This should be rewritten by removing the list and using the
+ value of <literal>name</literal> as the name of the attribute set:
+ <programlisting>
+users.users.me =
+ { description = "My personal user.";
+ isNormalUser = true;
+ };
+ </programlisting>
+ </para>
+ <para>
+ For more information on this change have look at these links:
+ <link xlink:href="https://github.com/NixOS/nixpkgs/issues/1800">issue #1800</link>,
+ <link xlink:href="https://github.com/NixOS/nixpkgs/pull/63103">PR #63103</link>.
+ </para>
</listitem>
</itemizedlist>
</section>
@@ -215,12 +407,30 @@
</listitem>
<listitem>
<para>
+ The nginx web server previously started its master process as root
+ privileged, then ran worker processes as a less privileged identity user.
+ This was changed to start all of nginx as a less privileged user (defined by
+ <literal>services.nginx.user</literal> and
+ <literal>services.nginx.group</literal>). As a consequence, all files that
+ are needed for nginx to run (included configuration fragments, SSL
+ certificates and keys, etc.) must now be readable by this less privileged
+ user/group.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
OpenSSH has been upgraded from 7.9 to 8.1, improving security and adding features
but with potential incompatibilities. Consult the
<link xlink:href="https://www.openssh.com/txt/release-8.1">
release announcement</link> for more information.
</para>
</listitem>
+ <listitem>
+ <para>
+ <literal>PRETTY_NAME</literal> in <literal>/etc/os-release</literal>
+ now uses the short rather than full version string.
+ </para>
+ </listitem>
</itemizedlist>
</section>
</section>
diff --git a/nixpkgs/nixos/lib/make-ext4-fs.nix b/nixpkgs/nixos/lib/make-ext4-fs.nix
index 932adcd9796..f46d3990c06 100644
--- a/nixpkgs/nixos/lib/make-ext4-fs.nix
+++ b/nixpkgs/nixos/lib/make-ext4-fs.nix
@@ -4,8 +4,11 @@
# generated image is sized to only fit its contents, with the expectation
# that a script resizes the filesystem at boot time.
{ pkgs
+, lib
# List of derivations to be included
, storePaths
+# Whether or not to compress the resulting image with zstd
+, compressImage ? false, zstd
# Shell commands to populate the ./files directory.
# All files in that directory are copied to the root of the FS.
, populateImageCommands ? ""
@@ -20,18 +23,20 @@
let
sdClosureInfo = pkgs.buildPackages.closureInfo { rootPaths = storePaths; };
in
-
pkgs.stdenv.mkDerivation {
- name = "ext4-fs.img";
+ name = "ext4-fs.img${lib.optionalString compressImage ".zst"}";
- nativeBuildInputs = [e2fsprogs.bin libfaketime perl lkl];
+ nativeBuildInputs = [ e2fsprogs.bin libfaketime perl lkl ]
+ ++ lib.optional compressImage zstd;
buildCommand =
''
+ ${if compressImage then "img=temp.img" else "img=$out"}
(
mkdir -p ./files
${populateImageCommands}
)
+
# Add the closures of the top-level store objects.
storePaths=$(cat ${sdClosureInfo}/store-paths)
@@ -42,28 +47,26 @@ pkgs.stdenv.mkDerivation {
bytes=$((2 * 4096 * $numInodes + 4096 * $numDataBlocks))
echo "Creating an EXT4 image of $bytes bytes (numInodes=$numInodes, numDataBlocks=$numDataBlocks)"
- truncate -s $bytes $out
- faketime -f "1970-01-01 00:00:01" mkfs.ext4 -L ${volumeLabel} -U ${uuid} $out
+ truncate -s $bytes $img
+ faketime -f "1970-01-01 00:00:01" mkfs.ext4 -L ${volumeLabel} -U ${uuid} $img
# Also include a manifest of the closures in a format suitable for nix-store --load-db.
cp ${sdClosureInfo}/registration nix-path-registration
- cptofs -t ext4 -i $out nix-path-registration /
+ cptofs -t ext4 -i $img nix-path-registration /
# Create nix/store before copying paths
faketime -f "1970-01-01 00:00:01" mkdir -p nix/store
- cptofs -t ext4 -i $out nix /
+ cptofs -t ext4 -i $img nix /
echo "copying store paths to image..."
- cptofs -t ext4 -i $out $storePaths /nix/store/
+ cptofs -t ext4 -i $img $storePaths /nix/store/
- (
echo "copying files to image..."
- cd ./files
- cptofs -t ext4 -i $out ./* /
- )
+ cptofs -t ext4 -i $img ./files/* /
+
# I have ended up with corrupted images sometimes, I suspect that happens when the build machine's disk gets full during the build.
- if ! fsck.ext4 -n -f $out; then
+ if ! fsck.ext4 -n -f $img; then
echo "--- Fsck failed for EXT4 image of $bytes bytes (numInodes=$numInodes, numDataBlocks=$numDataBlocks) ---"
cat errorlog
return 1
@@ -71,9 +74,9 @@ pkgs.stdenv.mkDerivation {
(
# Resizes **snugly** to its actual limits (or closer to)
- free=$(dumpe2fs $out | grep '^Free blocks:')
- blocksize=$(dumpe2fs $out | grep '^Block size:')
- blocks=$(dumpe2fs $out | grep '^Block count:')
+ free=$(dumpe2fs $img | grep '^Free blocks:')
+ blocksize=$(dumpe2fs $img | grep '^Block size:')
+ blocks=$(dumpe2fs $img | grep '^Block count:')
blocks=$((''${blocks##*:})) # format the number.
blocksize=$((''${blocksize##*:})) # format the number.
# System can't boot with 0 blocks free.
@@ -82,10 +85,15 @@ pkgs.stdenv.mkDerivation {
size=$(( blocks - ''${free##*:} + fudge ))
echo "Resizing from $blocks blocks to $size blocks. (~ $((size*blocksize/1024/1024))MiB)"
- EXT2FS_NO_MTAB_OK=yes resize2fs $out -f $size
+ EXT2FS_NO_MTAB_OK=yes resize2fs $img -f $size
)
# And a final fsck, because of the previous truncating.
- fsck.ext4 -n -f $out
+ fsck.ext4 -n -f $img
+
+ if [ ${builtins.toString compressImage} ]; then
+ echo "Compressing image"
+ zstd -v --no-progress ./$img -o $out
+ fi
'';
}
diff --git a/nixpkgs/nixos/lib/test-driver/test-driver.py b/nixpkgs/nixos/lib/test-driver/test-driver.py
index e45521424de..7e575189209 100644
--- a/nixpkgs/nixos/lib/test-driver/test-driver.py
+++ b/nixpkgs/nixos/lib/test-driver/test-driver.py
@@ -16,6 +16,8 @@ import tempfile
import time
import unicodedata
from typing import Tuple, Any, Callable, Dict, Iterator, Optional, List
+import shlex
+import pathlib
CHAR_TO_KEY = {
"A": "shift-a",
@@ -91,6 +93,10 @@ def eprint(*args: object, **kwargs: Any) -> None:
print(*args, file=sys.stderr, **kwargs)
+def make_command(args: list) -> str:
+ return " ".join(map(shlex.quote, (map(str, args))))
+
+
def create_vlan(vlan_nr: str) -> Tuple[str, str, "subprocess.Popen[bytes]", Any]:
global log
log.log("starting VDE switch for network {}".format(vlan_nr))
@@ -215,7 +221,7 @@ class Machine:
return path
self.state_dir = create_dir("vm-state-{}".format(self.name))
- self.shared_dir = create_dir("xchg-shared")
+ self.shared_dir = create_dir("{}/xchg".format(self.state_dir))
self.booted = False
self.connected = False
@@ -306,8 +312,13 @@ class Machine:
self.monitor.send(message)
return self.wait_for_monitor_prompt()
- def wait_for_unit(self, unit: str, user: Optional[str] = None) -> bool:
- while True:
+ def wait_for_unit(self, unit: str, user: Optional[str] = None) -> None:
+ """Wait for a systemd unit to get into "active" state.
+ Throws exceptions on "failed" and "inactive" states as well as
+ after timing out.
+ """
+
+ def check_active(_: Any) -> bool:
info = self.get_unit_info(unit, user)
state = info["ActiveState"]
if state == "failed":
@@ -323,8 +334,10 @@ class Machine:
'unit "{}" is inactive and there ' "are no pending jobs"
).format(unit)
)
- if state == "active":
- return True
+
+ return state == "active"
+
+ retry(check_active)
def get_unit_info(self, unit: str, user: Optional[str] = None) -> Dict[str, str]:
status, lines = self.systemctl('--no-pager show "{}"'.format(unit), user)
@@ -415,18 +428,34 @@ class Machine:
)
def wait_until_succeeds(self, command: str) -> str:
+ """Wait until a command returns success and return its output.
+ Throws an exception on timeout.
+ """
+ output = ""
+
+ def check_success(_: Any) -> bool:
+ nonlocal output
+ status, output = self.execute(command)
+ return status == 0
+
with self.nested("waiting for success: {}".format(command)):
- while True:
- status, output = self.execute(command)
- if status == 0:
- return output
+ retry(check_success)
+ return output
def wait_until_fails(self, command: str) -> str:
+ """Wait until a command returns failure.
+ Throws an exception on timeout.
+ """
+ output = ""
+
+ def check_failure(_: Any) -> bool:
+ nonlocal output
+ status, output = self.execute(command)
+ return status != 0
+
with self.nested("waiting for failure: {}".format(command)):
- while True:
- status, output = self.execute(command)
- if status != 0:
- return output
+ retry(check_failure)
+ return output
def wait_for_shutdown(self) -> None:
if not self.booted:
@@ -447,25 +476,38 @@ class Machine:
)
return output
- def wait_until_tty_matches(self, tty: str, regexp: str) -> bool:
+ def wait_until_tty_matches(self, tty: str, regexp: str) -> None:
+ """Wait until the visible output on the chosen TTY matches regular
+ expression. Throws an exception on timeout.
+ """
matcher = re.compile(regexp)
+
+ def tty_matches(last: bool) -> bool:
+ text = self.get_tty_text(tty)
+ if last:
+ self.log(
+ f"Last chance to match /{regexp}/ on TTY{tty}, "
+ f"which currently contains: {text}"
+ )
+ return len(matcher.findall(text)) > 0
+
with self.nested("waiting for {} to appear on tty {}".format(regexp, tty)):
- while True:
- text = self.get_tty_text(tty)
- if len(matcher.findall(text)) > 0:
- return True
+ retry(tty_matches)
def send_chars(self, chars: List[str]) -> None:
with self.nested("sending keys ‘{}‘".format(chars)):
for char in chars:
self.send_key(char)
- def wait_for_file(self, filename: str) -> bool:
+ def wait_for_file(self, filename: str) -> None:
+ """Waits until the file exists in machine's file system."""
+
+ def check_file(_: Any) -> bool:
+ status, _ = self.execute("test -e {}".format(filename))
+ return status == 0
+
with self.nested("waiting for file ‘{}‘".format(filename)):
- while True:
- status, _ = self.execute("test -e {}".format(filename))
- if status == 0:
- return True
+ retry(check_file)
def wait_for_open_port(self, port: int) -> None:
def port_is_open(_: Any) -> bool:
@@ -488,8 +530,8 @@ class Machine:
def stop_job(self, jobname: str, user: Optional[str] = None) -> Tuple[int, str]:
return self.systemctl("stop {}".format(jobname), user)
- def wait_for_job(self, jobname: str) -> bool:
- return self.wait_for_unit(jobname)
+ def wait_for_job(self, jobname: str) -> None:
+ self.wait_for_unit(jobname)
def connect(self) -> None:
if self.connected:
@@ -524,6 +566,33 @@ class Machine:
if ret.returncode != 0:
raise Exception("Cannot convert screenshot")
+ def copy_from_vm(self, source: str, target_dir: str = "") -> None:
+ """Copy a file from the VM (specified by an in-VM source path) to a path
+ relative to `$out`. The file is copied via the `shared_dir` shared among
+ all the VMs (using a temporary directory).
+ """
+ # Compute the source, target, and intermediate shared file names
+ out_dir = pathlib.Path(os.environ.get("out", os.getcwd()))
+ vm_src = pathlib.Path(source)
+ with tempfile.TemporaryDirectory(dir=self.shared_dir) as shared_td:
+ shared_temp = pathlib.Path(shared_td)
+ vm_shared_temp = pathlib.Path("/tmp/xchg") / shared_temp.name
+ vm_intermediate = vm_shared_temp / vm_src.name
+ intermediate = shared_temp / vm_src.name
+ # Copy the file to the shared directory inside VM
+ self.succeed(make_command(["mkdir", "-p", vm_shared_temp]))
+ self.succeed(make_command(["cp", "-r", vm_src, vm_intermediate]))
+ self.succeed("sync")
+ abs_target = out_dir / target_dir / vm_src.name
+ abs_target.parent.mkdir(exist_ok=True, parents=True)
+ # Copy the file from the shared directory outside VM
+ if intermediate.is_dir():
+ shutil.copytree(intermediate, abs_target)
+ else:
+ shutil.copy(intermediate, abs_target)
+ # Make sure the cleanup is synced into VM
+ self.succeed("sync")
+
def dump_tty_contents(self, tty: str) -> None:
"""Debugging: Dump the contents of the TTY<n>
"""
@@ -667,18 +736,20 @@ class Machine:
"""Wait until it is possible to connect to the X server. Note that
testing the existence of /tmp/.X11-unix/X0 is insufficient.
"""
+
+ def check_x(_: Any) -> bool:
+ cmd = (
+ "journalctl -b SYSLOG_IDENTIFIER=systemd | "
+ + 'grep "Reached target Current graphical"'
+ )
+ status, _ = self.execute(cmd)
+ if status != 0:
+ return False
+ status, _ = self.execute("[ -e /tmp/.X11-unix/X0 ]")
+ return status == 0
+
with self.nested("waiting for the X11 server"):
- while True:
- cmd = (
- "journalctl -b SYSLOG_IDENTIFIER=systemd | "
- + 'grep "Reached target Current graphical"'
- )
- status, _ = self.execute(cmd)
- if status != 0:
- continue
- status, _ = self.execute("[ -e /tmp/.X11-unix/X0 ]")
- if status == 0:
- return
+ retry(check_x)
def get_window_names(self) -> List[str]:
return self.succeed(
diff --git a/nixpkgs/nixos/lib/testing-python.nix b/nixpkgs/nixos/lib/testing-python.nix
index d567d268765..3d09be3b6cd 100644
--- a/nixpkgs/nixos/lib/testing-python.nix
+++ b/nixpkgs/nixos/lib/testing-python.nix
@@ -95,6 +95,8 @@ in rec {
, makeCoverageReport ? false
, enableOCR ? false
, name ? "unnamed"
+ # Skip linting (mainly intended for faster dev cycles)
+ , skipLint ? false
, ...
} @ t:
@@ -133,7 +135,7 @@ in rec {
# Generate onvenience wrappers for running the test driver
# interactively with the specified network, and for starting the
# VMs from the command line.
- driver = runCommand testDriverName
+ driver = let warn = if skipLint then lib.warn "Linting is disabled!" else lib.id; in warn (runCommand testDriverName
{ buildInputs = [ makeWrapper];
testScript = testScript';
preferLocalBuild = true;
@@ -143,7 +145,9 @@ in rec {
mkdir -p $out/bin
echo -n "$testScript" > $out/test-script
- ${python3Packages.black}/bin/black --check --diff $out/test-script
+ ${lib.optionalString (!skipLint) ''
+ ${python3Packages.black}/bin/black --check --diff $out/test-script
+ ''}
ln -s ${testDriver}/bin/nixos-test-driver $out/bin/
vms=($(for i in ${toString vms}; do echo $i/bin/run-*-vm; done))
@@ -160,7 +164,7 @@ in rec {
--set tests 'start_all(); join_all();' \
--set VLANS '${toString vlans}' \
${lib.optionalString (builtins.length vms == 1) "--set USE_SERIAL 1"}
- ''; # "
+ ''); # "
passMeta = drv: drv // lib.optionalAttrs (t ? meta) {
meta = (drv.meta or {}) // t.meta;
@@ -262,9 +266,8 @@ in rec {
virtualisation.memorySize = 1024;
services.xserver.enable = true;
services.xserver.displayManager.auto.enable = true;
- services.xserver.windowManager.default = "icewm";
+ services.xserver.displayManager.defaultSession = "none+icewm";
services.xserver.windowManager.icewm.enable = true;
- services.xserver.desktopManager.default = "none";
};
in
runInMachine ({
diff --git a/nixpkgs/nixos/lib/testing.nix b/nixpkgs/nixos/lib/testing.nix
index a5f060a8d8e..ae8ecd6270c 100644
--- a/nixpkgs/nixos/lib/testing.nix
+++ b/nixpkgs/nixos/lib/testing.nix
@@ -249,9 +249,8 @@ in rec {
virtualisation.memorySize = 1024;
services.xserver.enable = true;
services.xserver.displayManager.auto.enable = true;
- services.xserver.windowManager.default = "icewm";
+ services.xserver.displayManager.defaultSession = "none+icewm";
services.xserver.windowManager.icewm.enable = true;
- services.xserver.desktopManager.default = "none";
};
in
runInMachine ({
diff --git a/nixpkgs/nixos/maintainers/scripts/azure/create-azure.sh b/nixpkgs/nixos/maintainers/scripts/azure/create-azure.sh
index 2b22cb53661..0558f8dfffc 100755
--- a/nixpkgs/nixos/maintainers/scripts/azure/create-azure.sh
+++ b/nixpkgs/nixos/maintainers/scripts/azure/create-azure.sh
@@ -1,6 +1,6 @@
-#! /bin/sh -e
+#! /bin/sh -eu
-export NIX_PATH=nixpkgs=../../../..
+export NIX_PATH=nixpkgs=$(dirname $(readlink -f $0))/../../../..
export NIXOS_CONFIG=$(dirname $(readlink -f $0))/../../../modules/virtualisation/azure-image.nix
export TIMESTAMP=$(date +%Y%m%d%H%M)
diff --git a/nixpkgs/nixos/modules/config/console.nix b/nixpkgs/nixos/modules/config/console.nix
new file mode 100644
index 00000000000..f662ed62d31
--- /dev/null
+++ b/nixpkgs/nixos/modules/config/console.nix
@@ -0,0 +1,203 @@
+
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+ cfg = config.console;
+
+ makeColor = i: concatMapStringsSep "," (x: "0x" + substring (2*i) 2 x);
+
+ isUnicode = hasSuffix "UTF-8" (toUpper config.i18n.defaultLocale);
+
+ optimizedKeymap = pkgs.runCommand "keymap" {
+ nativeBuildInputs = [ pkgs.buildPackages.kbd ];
+ LOADKEYS_KEYMAP_PATH = "${consoleEnv}/share/keymaps/**";
+ preferLocalBuild = true;
+ } ''
+ loadkeys -b ${optionalString isUnicode "-u"} "${cfg.keyMap}" > $out
+ '';
+
+ # Sadly, systemd-vconsole-setup doesn't support binary keymaps.
+ vconsoleConf = pkgs.writeText "vconsole.conf" ''
+ KEYMAP=${cfg.keyMap}
+ FONT=${cfg.font}
+ '';
+
+ consoleEnv = pkgs.buildEnv {
+ name = "console-env";
+ paths = [ pkgs.kbd ] ++ cfg.packages;
+ pathsToLink = [
+ "/share/consolefonts"
+ "/share/consoletrans"
+ "/share/keymaps"
+ "/share/unimaps"
+ ];
+ };
+
+ setVconsole = !config.boot.isContainer;
+in
+
+{
+ ###### interface
+
+ options.console = {
+ font = mkOption {
+ type = types.str;
+ default = "Lat2-Terminus16";
+ example = "LatArCyrHeb-16";
+ description = ''
+ The font used for the virtual consoles. Leave empty to use
+ whatever the <command>setfont</command> program considers the
+ default font.
+ '';
+ };
+
+ keyMap = mkOption {
+ type = with types; either str path;
+ default = "us";
+ example = "fr";
+ description = ''
+ The keyboard mapping table for the virtual consoles.
+ '';
+ };
+
+ colors = mkOption {
+ type = types.listOf types.str;
+ default = [];
+ example = [
+ "002b36" "dc322f" "859900" "b58900"
+ "268bd2" "d33682" "2aa198" "eee8d5"
+ "002b36" "cb4b16" "586e75" "657b83"
+ "839496" "6c71c4" "93a1a1" "fdf6e3"
+ ];
+ description = ''
+ The 16 colors palette used by the virtual consoles.
+ Leave empty to use the default colors.
+ Colors must be in hexadecimal format and listed in
+ order from color 0 to color 15.
+ '';
+
+ };
+
+ packages = mkOption {
+ type = types.listOf types.package;
+ default = with pkgs.kbdKeymaps; [ dvp neo ];
+ defaultText = ''with pkgs.kbdKeymaps; [ dvp neo ]'';
+ description = ''
+ List of additional packages that provide console fonts, keymaps and
+ other resources for virtual consoles use.
+ '';
+ };
+
+ extraTTYs = mkOption {
+ default = [];
+ type = types.listOf types.str;
+ example = ["tty8" "tty9"];
+ description = ''
+ TTY (virtual console) devices, in addition to the consoles on
+ which mingetty and syslogd run, that must be initialised.
+ Only useful if you have some program that you want to run on
+ some fixed console. For example, the NixOS installation CD
+ opens the manual in a web browser on console 7, so it sets
+ <option>console.extraTTYs</option> to <literal>["tty7"]</literal>.
+ '';
+ };
+
+ useXkbConfig = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ If set, configure the virtual console keymap from the xserver
+ keyboard settings.
+ '';
+ };
+
+ earlySetup = mkOption {
+ default = false;
+ type = types.bool;
+ description = ''
+ Enable setting virtual console options as early as possible (in initrd).
+ '';
+ };
+
+ };
+
+
+ ###### implementation
+
+ config = mkMerge [
+ { console.keyMap = with config.services.xserver;
+ mkIf cfg.useXkbConfig
+ (pkgs.runCommand "xkb-console-keymap" { preferLocalBuild = true; } ''
+ '${pkgs.ckbcomp}/bin/ckbcomp' -model '${xkbModel}' -layout '${layout}' \
+ -option '${xkbOptions}' -variant '${xkbVariant}' > "$out"
+ '');
+ }
+
+ (mkIf (!setVconsole) {
+ systemd.services.systemd-vconsole-setup.enable = false;
+ })
+
+ (mkIf setVconsole (mkMerge [
+ { environment.systemPackages = [ pkgs.kbd ];
+
+ # Let systemd-vconsole-setup.service do the work of setting up the
+ # virtual consoles.
+ environment.etc."vconsole.conf".source = vconsoleConf;
+ # Provide kbd with additional packages.
+ environment.etc.kbd.source = "${consoleEnv}/share";
+
+ boot.initrd.preLVMCommands = mkBefore ''
+ kbd_mode ${if isUnicode then "-u" else "-a"} -C /dev/console
+ printf "\033%%${if isUnicode then "G" else "@"}" >> /dev/console
+ loadkmap < ${optimizedKeymap}
+
+ ${optionalString cfg.earlySetup ''
+ setfont -C /dev/console $extraUtils/share/consolefonts/font.psf
+ ''}
+ '';
+
+ systemd.services.systemd-vconsole-setup =
+ { before = [ "display-manager.service" ];
+ after = [ "systemd-udev-settle.service" ];
+ restartTriggers = [ vconsoleConf consoleEnv ];
+ };
+ }
+
+ (mkIf (cfg.colors != []) {
+ boot.kernelParams = [
+ "vt.default_red=${makeColor 0 cfg.colors}"
+ "vt.default_grn=${makeColor 1 cfg.colors}"
+ "vt.default_blu=${makeColor 2 cfg.colors}"
+ ];
+ })
+
+ (mkIf cfg.earlySetup {
+ boot.initrd.extraUtilsCommands = ''
+ mkdir -p $out/share/consolefonts
+ ${if substring 0 1 cfg.font == "/" then ''
+ font="${cfg.font}"
+ '' else ''
+ font="$(echo ${consoleEnv}/share/consolefonts/${cfg.font}.*)"
+ ''}
+ if [[ $font == *.gz ]]; then
+ gzip -cd $font > $out/share/consolefonts/font.psf
+ else
+ cp -L $font $out/share/consolefonts/font.psf
+ fi
+ '';
+ })
+ ]))
+ ];
+
+ imports = [
+ (mkRenamedOptionModule [ "i18n" "consoleFont" ] [ "console" "font" ])
+ (mkRenamedOptionModule [ "i18n" "consoleKeyMap" ] [ "console" "keyMap" ])
+ (mkRenamedOptionModule [ "i18n" "consoleColors" ] [ "console" "colors" ])
+ (mkRenamedOptionModule [ "i18n" "consolePackages" ] [ "console" "packages" ])
+ (mkRenamedOptionModule [ "i18n" "consoleUseXkbConfig" ] [ "console" "useXkbConfig" ])
+ (mkRenamedOptionModule [ "boot" "earlyVconsoleSetup" ] [ "console" "earlySetup" ])
+ (mkRenamedOptionModule [ "boot" "extraTTYs" ] [ "console" "extraTTYs" ])
+ ];
+}
diff --git a/nixpkgs/nixos/modules/config/fonts/fontconfig.nix b/nixpkgs/nixos/modules/config/fonts/fontconfig.nix
index 8f227c42326..3bfa1893a8b 100644
--- a/nixpkgs/nixos/modules/config/fonts/fontconfig.nix
+++ b/nixpkgs/nixos/modules/config/fonts/fontconfig.nix
@@ -264,6 +264,16 @@ let
};
in
{
+ imports = [
+ (mkRenamedOptionModule [ "fonts" "fontconfig" "ultimate" "allowBitmaps" ] [ "fonts" "fontconfig" "allowBitmaps" ])
+ (mkRenamedOptionModule [ "fonts" "fontconfig" "ultimate" "allowType1" ] [ "fonts" "fontconfig" "allowType1" ])
+ (mkRenamedOptionModule [ "fonts" "fontconfig" "ultimate" "useEmbeddedBitmaps" ] [ "fonts" "fontconfig" "useEmbeddedBitmaps" ])
+ (mkRenamedOptionModule [ "fonts" "fontconfig" "ultimate" "forceAutohint" ] [ "fonts" "fontconfig" "forceAutohint" ])
+ (mkRenamedOptionModule [ "fonts" "fontconfig" "ultimate" "renderMonoTTFAsBitmap" ] [ "fonts" "fontconfig" "renderMonoTTFAsBitmap" ])
+ (mkRemovedOptionModule [ "fonts" "fontconfig" "hinting" "style" ] "")
+ (mkRemovedOptionModule [ "fonts" "fontconfig" "forceAutohint" ] "")
+ (mkRemovedOptionModule [ "fonts" "fontconfig" "renderMonoTTFAsBitmap" ] "")
+ ];
options = {
diff --git a/nixpkgs/nixos/modules/config/fonts/fonts.nix b/nixpkgs/nixos/modules/config/fonts/fonts.nix
index abb806b601a..b9bae44b2f9 100644
--- a/nixpkgs/nixos/modules/config/fonts/fonts.nix
+++ b/nixpkgs/nixos/modules/config/fonts/fonts.nix
@@ -3,6 +3,9 @@
with lib;
{
+ imports = [
+ (mkRemovedOptionModule [ "fonts" "enableCoreFonts" ] "Use fonts.fonts = [ pkgs.corefonts ]; instead.")
+ ];
options = {
diff --git a/nixpkgs/nixos/modules/config/i18n.nix b/nixpkgs/nixos/modules/config/i18n.nix
index d0db8fedecd..cc2ddda9d32 100644
--- a/nixpkgs/nixos/modules/config/i18n.nix
+++ b/nixpkgs/nixos/modules/config/i18n.nix
@@ -58,62 +58,6 @@ with lib;
'';
};
- consolePackages = mkOption {
- type = types.listOf types.package;
- default = with pkgs.kbdKeymaps; [ dvp neo ];
- defaultText = ''with pkgs.kbdKeymaps; [ dvp neo ]'';
- description = ''
- List of additional packages that provide console fonts, keymaps and
- other resources.
- '';
- };
-
- consoleFont = mkOption {
- type = types.str;
- default = "Lat2-Terminus16";
- example = "LatArCyrHeb-16";
- description = ''
- The font used for the virtual consoles. Leave empty to use
- whatever the <command>setfont</command> program considers the
- default font.
- '';
- };
-
- consoleUseXkbConfig = mkOption {
- type = types.bool;
- default = false;
- description = ''
- If set, configure the console keymap from the xserver keyboard
- settings.
- '';
- };
-
- consoleKeyMap = mkOption {
- type = with types; either str path;
- default = "us";
- example = "fr";
- description = ''
- The keyboard mapping table for the virtual consoles.
- '';
- };
-
- consoleColors = mkOption {
- type = types.listOf types.str;
- default = [];
- example = [
- "002b36" "dc322f" "859900" "b58900"
- "268bd2" "d33682" "2aa198" "eee8d5"
- "002b36" "cb4b16" "586e75" "657b83"
- "839496" "6c71c4" "93a1a1" "fdf6e3"
- ];
- description = ''
- The 16 colors palette used by the virtual consoles.
- Leave empty to use the default colors.
- Colors must be in hexadecimal format and listed in
- order from color 0 to color 15.
- '';
- };
-
};
};
@@ -123,13 +67,6 @@ with lib;
config = {
- i18n.consoleKeyMap = with config.services.xserver;
- mkIf config.i18n.consoleUseXkbConfig
- (pkgs.runCommand "xkb-console-keymap" { preferLocalBuild = true; } ''
- '${pkgs.ckbcomp}/bin/ckbcomp' -model '${xkbModel}' -layout '${layout}' \
- -option '${xkbOptions}' -variant '${xkbVariant}' > "$out"
- '');
-
environment.systemPackages =
optional (config.i18n.supportedLocales != []) config.i18n.glibcLocales;
@@ -143,14 +80,11 @@ with lib;
};
# ‘/etc/locale.conf’ is used by systemd.
- environment.etc = singleton
- { target = "locale.conf";
- source = pkgs.writeText "locale.conf"
- ''
- LANG=${config.i18n.defaultLocale}
- ${concatStringsSep "\n" (mapAttrsToList (n: v: ''${n}=${v}'') config.i18n.extraLocaleSettings)}
- '';
- };
+ environment.etc."locale.conf".source = pkgs.writeText "locale.conf"
+ ''
+ LANG=${config.i18n.defaultLocale}
+ ${concatStringsSep "\n" (mapAttrsToList (n: v: ''${n}=${v}'') config.i18n.extraLocaleSettings)}
+ '';
};
}
diff --git a/nixpkgs/nixos/modules/config/ldap.nix b/nixpkgs/nixos/modules/config/ldap.nix
index e008497a2a6..9c8e9d14937 100644
--- a/nixpkgs/nixos/modules/config/ldap.nix
+++ b/nixpkgs/nixos/modules/config/ldap.nix
@@ -224,7 +224,9 @@ in
config = mkIf cfg.enable {
- environment.etc = optional (!cfg.daemon.enable) ldapConfig;
+ environment.etc = optionalAttrs (!cfg.daemon.enable) {
+ "ldap.conf" = ldapConfig;
+ };
system.activationScripts = mkIf (!cfg.daemon.enable) {
ldap = stringAfter [ "etc" "groups" "users" ] ''
diff --git a/nixpkgs/nixos/modules/config/networking.nix b/nixpkgs/nixos/modules/config/networking.nix
index a89667ea221..81427bb8ee6 100644
--- a/nixpkgs/nixos/modules/config/networking.nix
+++ b/nixpkgs/nixos/modules/config/networking.nix
@@ -16,6 +16,9 @@ let
in
{
+ imports = [
+ (mkRemovedOptionModule [ "networking" "hostConf" ] "Use environment.etc.\"host.conf\" instead.")
+ ];
options = {
@@ -41,19 +44,6 @@ in
'';
};
- networking.hostConf = lib.mkOption {
- type = types.lines;
- default = "multi on";
- example = ''
- multi on
- reorder on
- trim lan
- '';
- description = ''
- The contents of <filename>/etc/host.conf</filename>. See also <citerefentry><refentrytitle>host.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
- '';
- };
-
networking.timeServers = mkOption {
default = [
"0.nixos.pool.ntp.org"
@@ -186,7 +176,9 @@ in
'';
# /etc/host.conf: resolver configuration file
- "host.conf".text = cfg.hostConf;
+ "host.conf".text = ''
+ multi on
+ '';
} // optionalAttrs (pkgs.stdenv.hostPlatform.libc == "glibc") {
# /etc/rpc: RPC program numbers.
diff --git a/nixpkgs/nixos/modules/config/pulseaudio.nix b/nixpkgs/nixos/modules/config/pulseaudio.nix
index 9baad9b5854..048bbb30c73 100644
--- a/nixpkgs/nixos/modules/config/pulseaudio.nix
+++ b/nixpkgs/nixos/modules/config/pulseaudio.nix
@@ -215,9 +215,8 @@ in {
config = mkMerge [
{
- environment.etc = singleton {
- target = "pulse/client.conf";
- source = clientConf;
+ environment.etc = {
+ "pulse/client.conf".source = clientConf;
};
hardware.pulseaudio.configFile = mkDefault "${getBin overriddenPackage}/etc/pulse/default.pa";
@@ -228,19 +227,16 @@ in {
sound.enable = true;
- environment.etc = [
- { target = "asound.conf";
- source = alsaConf; }
+ environment.etc = {
+ "asound.conf".source = alsaConf;
- { target = "pulse/daemon.conf";
- source = writeText "daemon.conf" (lib.generators.toKeyValue {} cfg.daemon.config); }
+ "pulse/daemon.conf".source = writeText "daemon.conf"
+ (lib.generators.toKeyValue {} cfg.daemon.config);
- { target = "openal/alsoft.conf";
- source = writeText "alsoft.conf" "drivers=pulse"; }
+ "openal/alsoft.conf".source = writeText "alsoft.conf" "drivers=pulse";
- { target = "libao.conf";
- source = writeText "libao.conf" "default_driver=pulse"; }
- ];
+ "libao.conf".source = writeText "libao.conf" "default_driver=pulse";
+ };
# Disable flat volumes to enable relative ones
hardware.pulseaudio.daemon.config.flat-volumes = mkDefault "no";
@@ -275,9 +271,8 @@ in {
})
(mkIf nonSystemWide {
- environment.etc = singleton {
- target = "pulse/default.pa";
- source = myConfigFile;
+ environment.etc = {
+ "pulse/default.pa".source = myConfigFile;
};
systemd.user = {
services.pulseaudio = {
diff --git a/nixpkgs/nixos/modules/config/resolvconf.nix b/nixpkgs/nixos/modules/config/resolvconf.nix
index 406c6a7ac32..7d2f252a888 100644
--- a/nixpkgs/nixos/modules/config/resolvconf.nix
+++ b/nixpkgs/nixos/modules/config/resolvconf.nix
@@ -33,6 +33,12 @@ let
in
{
+ imports = [
+ (mkRenamedOptionModule [ "networking" "dnsSingleRequest" ] [ "networking" "resolvconf" "dnsSingleRequest" ])
+ (mkRenamedOptionModule [ "networking" "dnsExtensionMechanism" ] [ "networking" "resolvconf" "dnsExtensionMechanism" ])
+ (mkRenamedOptionModule [ "networking" "extraResolvconfConf" ] [ "networking" "resolvconf" "extraConfig" ])
+ (mkRenamedOptionModule [ "networking" "resolvconfOptions" ] [ "networking" "resolvconf" "extraOptions" ])
+ ];
options = {
diff --git a/nixpkgs/nixos/modules/config/swap.nix b/nixpkgs/nixos/modules/config/swap.nix
index fed3fa3bc7c..d0fc0d4a3ea 100644
--- a/nixpkgs/nixos/modules/config/swap.nix
+++ b/nixpkgs/nixos/modules/config/swap.nix
@@ -58,7 +58,7 @@ let
device = mkOption {
example = "/dev/sda3";
type = types.str;
- description = "Path of the device.";
+ description = "Path of the device or swap file.";
};
label = mkOption {
diff --git a/nixpkgs/nixos/modules/config/users-groups.nix b/nixpkgs/nixos/modules/config/users-groups.nix
index ae3bdeb00e6..141e43fec39 100644
--- a/nixpkgs/nixos/modules/config/users-groups.nix
+++ b/nixpkgs/nixos/modules/config/users-groups.nix
@@ -403,6 +403,10 @@ let
filter types.shellPackage.check shells;
in {
+ imports = [
+ (mkAliasOptionModule [ "users" "extraUsers" ] [ "users" "users" ])
+ (mkAliasOptionModule [ "users" "extraGroups" ] [ "users" "groups" ])
+ ];
###### interface
diff --git a/nixpkgs/nixos/modules/config/xdg/portal.nix b/nixpkgs/nixos/modules/config/xdg/portal.nix
index bdbbfda2bb4..95fa8e05fa3 100644
--- a/nixpkgs/nixos/modules/config/xdg/portal.nix
+++ b/nixpkgs/nixos/modules/config/xdg/portal.nix
@@ -3,6 +3,10 @@
with lib;
{
+ imports = [
+ (mkRenamedOptionModule [ "services" "flatpak" "extraPortals" ] [ "xdg" "portal" "extraPortals" ])
+ ];
+
options.xdg.portal = {
enable =
mkEnableOption "<link xlink:href='https://github.com/flatpak/xdg-desktop-portal'>xdg desktop integration</link>"//{
diff --git a/nixpkgs/nixos/modules/hardware/all-firmware.nix b/nixpkgs/nixos/modules/hardware/all-firmware.nix
index 534fcc34276..16be8bcfdd7 100644
--- a/nixpkgs/nixos/modules/hardware/all-firmware.nix
+++ b/nixpkgs/nixos/modules/hardware/all-firmware.nix
@@ -6,6 +6,14 @@ let
cfg = config.hardware;
in {
+ imports = [
+ (mkRenamedOptionModule [ "networking" "enableRT73Firmware" ] [ "hardware" "enableRedistributableFirmware" ])
+ (mkRenamedOptionModule [ "networking" "enableIntel3945ABGFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
+ (mkRenamedOptionModule [ "networking" "enableIntel2100BGFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
+ (mkRenamedOptionModule [ "networking" "enableRalinkFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
+ (mkRenamedOptionModule [ "networking" "enableRTL8192cFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
+ ];
+
###### interface
options = {
diff --git a/nixpkgs/nixos/modules/hardware/ckb-next.nix b/nixpkgs/nixos/modules/hardware/ckb-next.nix
index 20b2756d8b2..fe0ca9f26d5 100644
--- a/nixpkgs/nixos/modules/hardware/ckb-next.nix
+++ b/nixpkgs/nixos/modules/hardware/ckb-next.nix
@@ -7,6 +7,11 @@ let
in
{
+ imports = [
+ (mkRenamedOptionModule [ "hardware" "ckb" "enable" ] [ "hardware" "ckb-next" "enable" ])
+ (mkRenamedOptionModule [ "hardware" "ckb" "package" ] [ "hardware" "ckb-next" "package" ])
+ ];
+
options.hardware.ckb-next = {
enable = mkEnableOption "the Corsair keyboard/mouse driver";
diff --git a/nixpkgs/nixos/modules/hardware/ksm.nix b/nixpkgs/nixos/modules/hardware/ksm.nix
index 99d46c25236..0938dbdc110 100644
--- a/nixpkgs/nixos/modules/hardware/ksm.nix
+++ b/nixpkgs/nixos/modules/hardware/ksm.nix
@@ -6,6 +6,10 @@ let
cfg = config.hardware.ksm;
in {
+ imports = [
+ (mkRenamedOptionModule [ "hardware" "enableKSM" ] [ "hardware" "ksm" "enable" ])
+ ];
+
options.hardware.ksm = {
enable = mkEnableOption "Kernel Same-Page Merging";
sleep = mkOption {
diff --git a/nixpkgs/nixos/modules/hardware/opengl.nix b/nixpkgs/nixos/modules/hardware/opengl.nix
index 57cac56bd8a..89dc5008df5 100644
--- a/nixpkgs/nixos/modules/hardware/opengl.nix
+++ b/nixpkgs/nixos/modules/hardware/opengl.nix
@@ -31,6 +31,11 @@ let
in
{
+
+ imports = [
+ (mkRenamedOptionModule [ "services" "xserver" "vaapiDrivers" ] [ "hardware" "opengl" "extraPackages" ])
+ ];
+
options = {
hardware.opengl = {
diff --git a/nixpkgs/nixos/modules/hardware/video/nvidia.nix b/nixpkgs/nixos/modules/hardware/video/nvidia.nix
index fcb30187fa2..1794bb4b433 100644
--- a/nixpkgs/nixos/modules/hardware/video/nvidia.nix
+++ b/nixpkgs/nixos/modules/hardware/video/nvidia.nix
@@ -198,10 +198,11 @@ in
# Create /dev/nvidia-uvm when the nvidia-uvm module is loaded.
services.udev.extraRules =
''
- KERNEL=="nvidia", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidiactl c $(grep nvidia-frontend /proc/devices | cut -d \ -f 1) 255'"
- KERNEL=="nvidia_modeset", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidia-modeset c $(grep nvidia-frontend /proc/devices | cut -d \ -f 1) 254'"
- KERNEL=="card*", SUBSYSTEM=="drm", DRIVERS=="nvidia", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidia%n c $(grep nvidia-frontend /proc/devices | cut -d \ -f 1) %n'"
- KERNEL=="nvidia_uvm", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidia-uvm c $(grep nvidia-uvm /proc/devices | cut -d \ -f 1) 0'"
+ KERNEL=="nvidia", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidiactl c $$(grep nvidia-frontend /proc/devices | cut -d \ -f 1) 255'"
+ KERNEL=="nvidia_modeset", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidia-modeset c $$(grep nvidia-frontend /proc/devices | cut -d \ -f 1) 254'"
+ KERNEL=="card*", SUBSYSTEM=="drm", DRIVERS=="nvidia", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidia%n c $$(grep nvidia-frontend /proc/devices | cut -d \ -f 1) %n'"
+ KERNEL=="nvidia_uvm", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidia-uvm c $$(grep nvidia-uvm /proc/devices | cut -d \ -f 1) 0'"
+ KERNEL=="nvidia_uvm", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidia-uvm-tools c $$(grep nvidia-uvm /proc/devices | cut -d \ -f 1) 0'"
'';
boot.blacklistedKernelModules = [ "nouveau" "nvidiafb" ];
diff --git a/nixpkgs/nixos/modules/i18n/input-method/ibus.nix b/nixpkgs/nixos/modules/i18n/input-method/ibus.nix
index 8109ef76c40..a3d97619fc4 100644
--- a/nixpkgs/nixos/modules/i18n/input-method/ibus.nix
+++ b/nixpkgs/nixos/modules/i18n/input-method/ibus.nix
@@ -27,6 +27,10 @@ let
};
in
{
+ imports = [
+ (mkRenamedOptionModule [ "programs" "ibus" "plugins" ] [ "i18n" "inputMethod" "ibus" "engines" ])
+ ];
+
options = {
i18n.inputMethod.ibus = {
engines = mkOption {
@@ -53,9 +57,17 @@ in
config = mkIf (config.i18n.inputMethod.enabled == "ibus") {
i18n.inputMethod.package = ibusPackage;
+ environment.systemPackages = [
+ ibusAutostart
+ ];
+
# Without dconf enabled it is impossible to use IBus
- environment.systemPackages = with pkgs; [
- gnome3.dconf ibusAutostart
+ programs.dconf.enable = true;
+
+ programs.dconf.profiles.ibus = "${ibusPackage}/etc/dconf/profile/ibus";
+
+ services.dbus.packages = [
+ ibusAutostart
];
environment.variables = {
diff --git a/nixpkgs/nixos/modules/installer/cd-dvd/iso-image.nix b/nixpkgs/nixos/modules/installer/cd-dvd/iso-image.nix
index 009f1e2c543..11319e5f4f8 100644
--- a/nixpkgs/nixos/modules/installer/cd-dvd/iso-image.nix
+++ b/nixpkgs/nixos/modules/installer/cd-dvd/iso-image.nix
@@ -603,9 +603,6 @@ in
{ source = config.system.build.squashfsStore;
target = "/nix-store.squashfs";
}
- { source = config.isoImage.efiSplashImage;
- target = "/EFI/boot/efi-background.png";
- }
{ source = config.isoImage.splashImage;
target = "/isolinux/background.png";
}
@@ -630,8 +627,8 @@ in
{ source = "${efiDir}/EFI";
target = "/EFI";
}
- { source = pkgs.writeText "loopback.cfg" "source /EFI/boot/grub.cfg";
- target = "/boot/grub/loopback.cfg";
+ { source = (pkgs.writeTextDir "grub/loopback.cfg" "source /EFI/boot/grub.cfg") + "/grub";
+ target = "/boot/grub";
}
] ++ optionals (config.boot.loader.grub.memtest86.enable && canx86BiosBoot) [
{ source = "${pkgs.memtest86plus}/memtest.bin";
@@ -641,6 +638,10 @@ in
{ source = config.isoImage.grubTheme;
target = "/EFI/boot/grub-theme";
}
+ ] ++ [
+ { source = config.isoImage.efiSplashImage;
+ target = "/EFI/boot/efi-background.png";
+ }
];
boot.loader.timeout = 10;
diff --git a/nixpkgs/nixos/modules/installer/cd-dvd/sd-image.nix b/nixpkgs/nixos/modules/installer/cd-dvd/sd-image.nix
index 7865b767f0b..901c60befb6 100644
--- a/nixpkgs/nixos/modules/installer/cd-dvd/sd-image.nix
+++ b/nixpkgs/nixos/modules/installer/cd-dvd/sd-image.nix
@@ -18,6 +18,7 @@ with lib;
let
rootfsImage = pkgs.callPackage ../../../lib/make-ext4-fs.nix ({
inherit (config.sdImage) storePaths;
+ compressImage = true;
populateImageCommands = config.sdImage.populateRootCommands;
volumeLabel = "NIXOS_SD";
} // optionalAttrs (config.sdImage.rootPartitionUUID != null) {
@@ -128,10 +129,11 @@ in
sdImage.storePaths = [ config.system.build.toplevel ];
- system.build.sdImage = pkgs.callPackage ({ stdenv, dosfstools, e2fsprogs, mtools, libfaketime, utillinux, bzip2 }: stdenv.mkDerivation {
+ system.build.sdImage = pkgs.callPackage ({ stdenv, dosfstools, e2fsprogs,
+ mtools, libfaketime, utillinux, bzip2, zstd }: stdenv.mkDerivation {
name = config.sdImage.imageName;
- nativeBuildInputs = [ dosfstools e2fsprogs mtools libfaketime utillinux bzip2 ];
+ nativeBuildInputs = [ dosfstools e2fsprogs mtools libfaketime utillinux bzip2 zstd ];
inherit (config.sdImage) compressImage;
@@ -146,11 +148,14 @@ in
echo "file sd-image $img" >> $out/nix-support/hydra-build-products
fi
+ echo "Decompressing rootfs image"
+ zstd -d --no-progress "${rootfsImage}" -o ./root-fs.img
+
# Gap in front of the first partition, in MiB
gap=8
# Create the image file sized to fit /boot/firmware and /, plus slack for the gap.
- rootSizeBlocks=$(du -B 512 --apparent-size ${rootfsImage} | awk '{ print $1 }')
+ rootSizeBlocks=$(du -B 512 --apparent-size ./root-fs.img | awk '{ print $1 }')
firmwareSizeBlocks=$((${toString config.sdImage.firmwareSize} * 1024 * 1024 / 512))
imageSize=$((rootSizeBlocks * 512 + firmwareSizeBlocks * 512 + gap * 1024 * 1024))
truncate -s $imageSize $img
@@ -168,7 +173,7 @@ in
# Copy the rootfs into the SD image
eval $(partx $img -o START,SECTORS --nr 2 --pairs)
- dd conv=notrunc if=${rootfsImage} of=$img seek=$START count=$SECTORS
+ dd conv=notrunc if=./root-fs.img of=$img seek=$START count=$SECTORS
# Create a FAT32 /boot/firmware partition of suitable size into firmware_part.img
eval $(partx $img -o START,SECTORS --nr 1 --pairs)
diff --git a/nixpkgs/nixos/modules/installer/cd-dvd/system-tarball-pc.nix b/nixpkgs/nixos/modules/installer/cd-dvd/system-tarball-pc.nix
index bf8b7deb59e..f2af7dcde3d 100644
--- a/nixpkgs/nixos/modules/installer/cd-dvd/system-tarball-pc.nix
+++ b/nixpkgs/nixos/modules/installer/cd-dvd/system-tarball-pc.nix
@@ -122,11 +122,10 @@ in
/* fake entry, just to have a happy stage-1. Users
may boot without having stage-1 though */
- fileSystems = [
+ fileSystems.fake =
{ mountPoint = "/";
device = "/dev/something";
- }
- ];
+ };
nixpkgs.config = {
packageOverrides = p: {
diff --git a/nixpkgs/nixos/modules/installer/cd-dvd/system-tarball-sheevaplug.nix b/nixpkgs/nixos/modules/installer/cd-dvd/system-tarball-sheevaplug.nix
index 90a5128c02a..8408f56f94f 100644
--- a/nixpkgs/nixos/modules/installer/cd-dvd/system-tarball-sheevaplug.nix
+++ b/nixpkgs/nixos/modules/installer/cd-dvd/system-tarball-sheevaplug.nix
@@ -117,11 +117,10 @@ in
/* fake entry, just to have a happy stage-1. Users
may boot without having stage-1 though */
- fileSystems = [
+ fileSystems.fake =
{ mountPoint = "/";
device = "/dev/something";
- }
- ];
+ };
services.mingetty = {
# Some more help text.
diff --git a/nixpkgs/nixos/modules/installer/cd-dvd/system-tarball.nix b/nixpkgs/nixos/modules/installer/cd-dvd/system-tarball.nix
index b84096861f5..58098c45535 100644
--- a/nixpkgs/nixos/modules/installer/cd-dvd/system-tarball.nix
+++ b/nixpkgs/nixos/modules/installer/cd-dvd/system-tarball.nix
@@ -41,7 +41,7 @@ in
# In stage 1 of the boot, mount the CD/DVD as the root FS by label
# so that we don't need to know its device.
- fileSystems = [ ];
+ fileSystems = { };
# boot.initrd.availableKernelModules = [ "mvsdio" "reiserfs" "ext3" "ext4" ];
diff --git a/nixpkgs/nixos/modules/installer/tools/nix-fallback-paths.nix b/nixpkgs/nixos/modules/installer/tools/nix-fallback-paths.nix
index d7149b35d4c..c2f2578733b 100644
--- a/nixpkgs/nixos/modules/installer/tools/nix-fallback-paths.nix
+++ b/nixpkgs/nixos/modules/installer/tools/nix-fallback-paths.nix
@@ -1,6 +1,6 @@
{
- x86_64-linux = "/nix/store/6chjfy4j6hjwj5f8zcbbdg02i21x1qsi-nix-2.3.1";
- i686-linux = "/nix/store/xa8z7fwszjjm4kiwrxfc8xv9c1pzzm7a-nix-2.3.1";
- aarch64-linux = "/nix/store/8cac1ivcnchlpzmdjby2f71l1fwpnymr-nix-2.3.1";
- x86_64-darwin = "/nix/store/6639l9815ggdnb4aka22qcjy7p8w4hb9-nix-2.3.1";
+ x86_64-linux = "/nix/store/0q5qnh10m2sfrriszc1ysmggw659q6qm-nix-2.3.2";
+ i686-linux = "/nix/store/i7ad7r5d8a5b3l22hg4a1im2qq05y6vd-nix-2.3.2";
+ aarch64-linux = "/nix/store/bv06pavfw0dbqzr8w3l7s71nx27gnxa0-nix-2.3.2";
+ x86_64-darwin = "/nix/store/x6mnl1nij7y4v5ihlplr4k937ayr403r-nix-2.3.2";
}
diff --git a/nixpkgs/nixos/modules/installer/tools/nixos-generate-config.pl b/nixpkgs/nixos/modules/installer/tools/nixos-generate-config.pl
index f2ffe61c42c..629c56814a1 100644
--- a/nixpkgs/nixos/modules/installer/tools/nixos-generate-config.pl
+++ b/nixpkgs/nixos/modules/installer/tools/nixos-generate-config.pl
@@ -335,6 +335,9 @@ if (@swaps) {
next unless -e $swapFilename;
my $dev = findStableDevPath $swapFilename;
if ($swapType =~ "partition") {
+ # zram devices are more likely created by configuration.nix, so
+ # ignore them here
+ next if ($swapFilename =~ /^\/dev\/zram/);
push @swapDevices, "{ device = \"$dev\"; }";
} elsif ($swapType =~ "file") {
# swap *files* are more likely specified in configuration.nix, so
@@ -498,7 +501,7 @@ if (-f $fb_modes_file && -r $fb_modes_file) {
my $console_width = $1, my $console_height = $2;
if ($console_width > 1920) {
push @attrs, "# High-DPI console";
- push @attrs, 'i18n.consoleFont = lib.mkDefault "${pkgs.terminus_font}/share/consolefonts/ter-u28n.psf.gz";';
+ push @attrs, 'console.font = lib.mkDefault "${pkgs.terminus_font}/share/consolefonts/ter-u28n.psf.gz";';
}
}
diff --git a/nixpkgs/nixos/modules/installer/tools/nixos-install.sh b/nixpkgs/nixos/modules/installer/tools/nixos-install.sh
index 8685cb345e1..a3ff3fe2c0c 100644
--- a/nixpkgs/nixos/modules/installer/tools/nixos-install.sh
+++ b/nixpkgs/nixos/modules/installer/tools/nixos-install.sh
@@ -14,6 +14,8 @@ extraBuildFlags=()
mountPoint=/mnt
channelPath=
system=
+verbosity=()
+buildLogs=
while [ "$#" -gt 0 ]; do
i="$1"; shift 1
@@ -55,6 +57,12 @@ while [ "$#" -gt 0 ]; do
--debug)
set -x
;;
+ -v*|--verbose)
+ verbosity+=("$i")
+ ;;
+ -L|--print-build-logs)
+ buildLogs="$i"
+ ;;
*)
echo "$0: unknown option \`$i'"
exit 1
@@ -94,7 +102,7 @@ if [[ -z $system ]]; then
outLink="$tmpdir/system"
nix build --out-link "$outLink" --store "$mountPoint" "${extraBuildFlags[@]}" \
--extra-substituters "$sub" \
- -f '<nixpkgs/nixos>' system -I "nixos-config=$NIXOS_CONFIG"
+ -f '<nixpkgs/nixos>' system -I "nixos-config=$NIXOS_CONFIG" ${verbosity[@]} ${buildLogs}
system=$(readlink -f $outLink)
fi
@@ -103,7 +111,7 @@ fi
# a progress bar.
nix-env --store "$mountPoint" "${extraBuildFlags[@]}" \
--extra-substituters "$sub" \
- -p $mountPoint/nix/var/nix/profiles/system --set "$system"
+ -p $mountPoint/nix/var/nix/profiles/system --set "$system" ${verbosity[@]}
# Copy the NixOS/Nixpkgs sources to the target as the initial contents
# of the NixOS channel.
@@ -115,7 +123,8 @@ if [[ -z $noChannelCopy ]]; then
echo "copying channel..."
mkdir -p $mountPoint/nix/var/nix/profiles/per-user/root
nix-env --store "$mountPoint" "${extraBuildFlags[@]}" --extra-substituters "$sub" \
- -p $mountPoint/nix/var/nix/profiles/per-user/root/channels --set "$channelPath" --quiet
+ -p $mountPoint/nix/var/nix/profiles/per-user/root/channels --set "$channelPath" --quiet \
+ ${verbosity[@]}
install -m 0700 -d $mountPoint/root/.nix-defexpr
ln -sfn /nix/var/nix/profiles/per-user/root/channels $mountPoint/root/.nix-defexpr/channels
fi
diff --git a/nixpkgs/nixos/modules/misc/documentation.nix b/nixpkgs/nixos/modules/misc/documentation.nix
index deecb005270..d09afadd609 100644
--- a/nixpkgs/nixos/modules/misc/documentation.nix
+++ b/nixpkgs/nixos/modules/misc/documentation.nix
@@ -1,4 +1,4 @@
-{ config, lib, pkgs, baseModules, extraModules, modules, ... }:
+{ config, lib, pkgs, baseModules, extraModules, modules, modulesPath, ... }:
with lib;
@@ -22,7 +22,10 @@ let
scrubbedEval = evalModules {
modules = [ { nixpkgs.localSystem = config.nixpkgs.localSystem; } ] ++ manualModules;
args = (config._module.args) // { modules = [ ]; };
- specialArgs = { pkgs = scrubDerivations "pkgs" pkgs; };
+ specialArgs = {
+ pkgs = scrubDerivations "pkgs" pkgs;
+ inherit modulesPath;
+ };
};
scrubDerivations = namePrefix: pkgSet: mapAttrs
(name: value:
@@ -67,6 +70,11 @@ let
in
{
+ imports = [
+ (mkRenamedOptionModule [ "programs" "info" "enable" ] [ "documentation" "info" "enable" ])
+ (mkRenamedOptionModule [ "programs" "man" "enable" ] [ "documentation" "man" "enable" ])
+ (mkRenamedOptionModule [ "services" "nixosManual" "enable" ] [ "documentation" "nixos" "enable" ])
+ ];
options = {
diff --git a/nixpkgs/nixos/modules/misc/ids.nix b/nixpkgs/nixos/modules/misc/ids.nix
index f8b188e7b1c..bedd87a368e 100644
--- a/nixpkgs/nixos/modules/misc/ids.nix
+++ b/nixpkgs/nixos/modules/misc/ids.nix
@@ -80,8 +80,8 @@ in
#kdm = 39; # dropped in 17.03
#ghostone = 40; # dropped in 18.03
git = 41;
- fourstore = 42;
- fourstorehttp = 43;
+ #fourstore = 42; # dropped in 20.03
+ #fourstorehttp = 43; # dropped in 20.03
virtuoso = 44;
rtkit = 45;
dovecot2 = 46;
diff --git a/nixpkgs/nixos/modules/misc/locate.nix b/nixpkgs/nixos/modules/misc/locate.nix
index 737ed5c0a3f..552535c253e 100644
--- a/nixpkgs/nixos/modules/misc/locate.nix
+++ b/nixpkgs/nixos/modules/misc/locate.nix
@@ -7,6 +7,11 @@ let
isMLocate = hasPrefix "mlocate" cfg.locate.name;
isFindutils = hasPrefix "findutils" cfg.locate.name;
in {
+ imports = [
+ (mkRenamedOptionModule [ "services" "locate" "period" ] [ "services" "locate" "interval" ])
+ (mkRemovedOptionModule [ "services" "locate" "includeStore" ] "Use services.locate.prunePaths" )
+ ];
+
options.services.locate = with types; {
enable = mkOption {
type = bool;
diff --git a/nixpkgs/nixos/modules/misc/version.nix b/nixpkgs/nixos/modules/misc/version.nix
index 773724ffbd5..0540b493003 100644
--- a/nixpkgs/nixos/modules/misc/version.nix
+++ b/nixpkgs/nixos/modules/misc/version.nix
@@ -10,6 +10,12 @@ let
in
{
+ imports = [
+ (mkRenamedOptionModule [ "system" "nixosVersion" ] [ "system" "nixos" "version" ])
+ (mkRenamedOptionModule [ "system" "nixosVersionSuffix" ] [ "system" "nixos" "versionSuffix" ])
+ (mkRenamedOptionModule [ "system" "nixosRevision" ] [ "system" "nixos" "revision" ])
+ (mkRenamedOptionModule [ "system" "nixosLabel" ] [ "system" "nixos" "label" ])
+ ];
options.system = {
@@ -92,7 +98,7 @@ in
VERSION="${cfg.version} (${cfg.codeName})"
VERSION_CODENAME=${toLower cfg.codeName}
VERSION_ID="${cfg.version}"
- PRETTY_NAME="NixOS ${cfg.version} (${cfg.codeName})"
+ PRETTY_NAME="NixOS ${cfg.release} (${cfg.codeName})"
LOGO="nix-snowflake"
HOME_URL="https://nixos.org/"
DOCUMENTATION_URL="https://nixos.org/nixos/manual/index.html"
diff --git a/nixpkgs/nixos/modules/module-list.nix b/nixpkgs/nixos/modules/module-list.nix
index 076e1654818..a6c1d7c5d66 100644
--- a/nixpkgs/nixos/modules/module-list.nix
+++ b/nixpkgs/nixos/modules/module-list.nix
@@ -11,6 +11,7 @@
./config/xdg/mime.nix
./config/xdg/portal.nix
./config/appstream.nix
+ ./config/console.nix
./config/xdg/sounds.nix
./config/gtk/gtk-icon-cache.nix
./config/gnu.nix
@@ -94,6 +95,7 @@
./programs/adb.nix
./programs/atop.nix
./programs/autojump.nix
+ ./programs/bandwhich.nix
./programs/bash/bash.nix
./programs/bcc.nix
./programs/browserpass.nix
@@ -254,8 +256,6 @@
./services/continuous-integration/jenkins/default.nix
./services/continuous-integration/jenkins/job-builder.nix
./services/continuous-integration/jenkins/slave.nix
- ./services/databases/4store-endpoint.nix
- ./services/databases/4store.nix
./services/databases/aerospike.nix
./services/databases/cassandra.nix
./services/databases/clickhouse.nix
@@ -445,6 +445,7 @@
./services/misc/logkeys.nix
./services/misc/leaps.nix
./services/misc/lidarr.nix
+ ./services/misc/mame.nix
./services/misc/mathics.nix
./services/misc/matrix-synapse.nix
./services/misc/mbpfan.nix
@@ -558,6 +559,7 @@
./services/network-filesystems/yandex-disk.nix
./services/network-filesystems/xtreemfs.nix
./services/network-filesystems/ceph.nix
+ ./services/networking/3proxy.nix
./services/networking/amuled.nix
./services/networking/aria2.nix
./services/networking/asterisk.nix
@@ -690,10 +692,13 @@
./services/networking/skydns.nix
./services/networking/shadowsocks.nix
./services/networking/shairport-sync.nix
+ ./services/networking/shorewall.nix
+ ./services/networking/shorewall6.nix
./services/networking/shout.nix
./services/networking/sniproxy.nix
./services/networking/smokeping.nix
./services/networking/softether.nix
+ ./services/networking/spacecookie.nix
./services/networking/spiped.nix
./services/networking/squid.nix
./services/networking/sslh.nix
@@ -722,6 +727,7 @@
./services/networking/tvheadend.nix
./services/networking/unbound.nix
./services/networking/unifi.nix
+ ./services/networking/v2ray.nix
./services/networking/vsftpd.nix
./services/networking/wakeonlan.nix
./services/networking/websockify.nix
@@ -800,6 +806,7 @@
./services/web-apps/gotify-server.nix
./services/web-apps/icingaweb2/icingaweb2.nix
./services/web-apps/icingaweb2/module-monitoring.nix
+ ./services/web-apps/ihatemoney
./services/web-apps/limesurvey.nix
./services/web-apps/mattermost.nix
./services/web-apps/mediawiki.nix
@@ -813,6 +820,7 @@
./services/web-apps/restya-board.nix
./services/web-apps/tt-rss.nix
./services/web-apps/trac.nix
+ ./services/web-apps/trilium.nix
./services/web-apps/selfoss.nix
./services/web-apps/shiori.nix
./services/web-apps/virtlyst.nix
@@ -847,7 +855,7 @@
./services/x11/extra-layouts.nix
./services/x11/clight.nix
./services/x11/colord.nix
- ./services/x11/compton.nix
+ ./services/x11/picom.nix
./services/x11/unclutter.nix
./services/x11/unclutter-xfixes.nix
./services/x11/desktop-managers/default.nix
@@ -867,6 +875,7 @@
./services/x11/hardware/digimend.nix
./services/x11/hardware/cmt.nix
./services/x11/gdk-pixbuf.nix
+ ./services/x11/imwheel.nix
./services/x11/redshift.nix
./services/x11/urxvtd.nix
./services/x11/window-managers/awesome.nix
@@ -937,7 +946,6 @@
./tasks/filesystems/vfat.nix
./tasks/filesystems/xfs.nix
./tasks/filesystems/zfs.nix
- ./tasks/kbd.nix
./tasks/lvm.nix
./tasks/network-interfaces.nix
./tasks/network-interfaces-systemd.nix
diff --git a/nixpkgs/nixos/modules/programs/bandwhich.nix b/nixpkgs/nixos/modules/programs/bandwhich.nix
new file mode 100644
index 00000000000..5413044f461
--- /dev/null
+++ b/nixpkgs/nixos/modules/programs/bandwhich.nix
@@ -0,0 +1,29 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let cfg = config.programs.bandwhich;
+in {
+ meta.maintainers = with maintainers; [ filalex77 ];
+
+ options = {
+ programs.bandwhich = {
+ enable = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Whether to add bandwhich to the global environment and configure a
+ setcap wrapper for it.
+ '';
+ };
+ };
+ };
+
+ config = mkIf cfg.enable {
+ environment.systemPackages = with pkgs; [ bandwhich ];
+ security.wrappers.bandwhich = {
+ source = "${pkgs.bandwhich}/bin/bandwhich";
+ capabilities = "cap_net_raw,cap_net_admin+ep";
+ };
+ };
+}
diff --git a/nixpkgs/nixos/modules/programs/bash/bash.nix b/nixpkgs/nixos/modules/programs/bash/bash.nix
index 548babac38c..366c07c0a35 100644
--- a/nixpkgs/nixos/modules/programs/bash/bash.nix
+++ b/nixpkgs/nixos/modules/programs/bash/bash.nix
@@ -40,6 +40,10 @@ let
in
{
+ imports = [
+ (mkRemovedOptionModule [ "programs" "bash" "enable" ] "")
+ ];
+
options = {
programs.bash = {
diff --git a/nixpkgs/nixos/modules/programs/dconf.nix b/nixpkgs/nixos/modules/programs/dconf.nix
index eeebc3558bd..6702e8efd1c 100644
--- a/nixpkgs/nixos/modules/programs/dconf.nix
+++ b/nixpkgs/nixos/modules/programs/dconf.nix
@@ -6,7 +6,10 @@ let
cfg = config.programs.dconf;
mkDconfProfile = name: path:
- { source = path; target = "dconf/profile/${name}"; };
+ {
+ name = "dconf/profile/${name}";
+ value.source = path;
+ };
in
{
@@ -29,16 +32,16 @@ in
###### implementation
config = mkIf (cfg.profiles != {} || cfg.enable) {
- environment.etc = optionals (cfg.profiles != {})
- (mapAttrsToList mkDconfProfile cfg.profiles);
+ environment.etc = optionalAttrs (cfg.profiles != {})
+ (mapAttrs' mkDconfProfile cfg.profiles);
- services.dbus.packages = [ pkgs.gnome3.dconf ];
+ services.dbus.packages = [ pkgs.dconf ];
# For dconf executable
- environment.systemPackages = [ pkgs.gnome3.dconf ];
+ environment.systemPackages = [ pkgs.dconf ];
# Needed for unwrapped applications
- environment.variables.GIO_EXTRA_MODULES = mkIf cfg.enable [ "${pkgs.gnome3.dconf.lib}/lib/gio/modules" ];
+ environment.variables.GIO_EXTRA_MODULES = mkIf cfg.enable [ "${pkgs.dconf.lib}/lib/gio/modules" ];
};
}
diff --git a/nixpkgs/nixos/modules/programs/nm-applet.nix b/nixpkgs/nixos/modules/programs/nm-applet.nix
index e42219e9638..1b806071c43 100644
--- a/nixpkgs/nixos/modules/programs/nm-applet.nix
+++ b/nixpkgs/nixos/modules/programs/nm-applet.nix
@@ -10,5 +10,7 @@
partOf = [ "graphical-session.target" ];
serviceConfig.ExecStart = "${pkgs.networkmanagerapplet}/bin/nm-applet";
};
+
+ services.dbus.packages = [ pkgs.gcr ];
};
}
diff --git a/nixpkgs/nixos/modules/programs/oblogout.nix b/nixpkgs/nixos/modules/programs/oblogout.nix
index 720c29b1eae..a039b0623b5 100644
--- a/nixpkgs/nixos/modules/programs/oblogout.nix
+++ b/nixpkgs/nixos/modules/programs/oblogout.nix
@@ -1,176 +1,11 @@
-# Global configuration for oblogout.
-
{ config, lib, pkgs, ... }:
with lib;
-let cfg = config.programs.oblogout;
-
-in
{
- ###### interface
-
- options = {
-
- programs.oblogout = {
-
- enable = mkOption {
- type = types.bool;
- default = false;
- description = ''
- Whether to install OBLogout and create <filename>/etc/oblogout.conf</filename>.
- See <filename>${pkgs.oblogout}/share/doc/README</filename>.
- '';
- };
-
- opacity = mkOption {
- type = types.int;
- default = 70;
- description = ''
- Opacity percentage of Cairo rendered backgrounds.
- '';
- };
-
- bgcolor = mkOption {
- type = types.str;
- default = "black";
- description = ''
- Colour name or hex code (#ffffff) of the background color.
- '';
- };
-
- buttontheme = mkOption {
- type = types.str;
- default = "simplistic";
- description = ''
- Icon theme for the buttons, must be in the themes folder of
- the package, or in
- <filename>~/.themes/&lt;name&gt;/oblogout/</filename>.
- '';
- };
-
- buttons = mkOption {
- type = types.str;
- default = "cancel, logout, restart, shutdown, suspend, hibernate";
- description = ''
- List and order of buttons to show.
- '';
- };
-
- cancel = mkOption {
- type = types.str;
- default = "Escape";
- description = ''
- Cancel logout/shutdown shortcut.
- '';
- };
-
- shutdown = mkOption {
- type = types.str;
- default = "S";
- description = ''
- Shutdown shortcut.
- '';
- };
-
- restart = mkOption {
- type = types.str;
- default = "R";
- description = ''
- Restart shortcut.
- '';
- };
-
- suspend = mkOption {
- type = types.str;
- default = "U";
- description = ''
- Suspend shortcut.
- '';
- };
-
- logout = mkOption {
- type = types.str;
- default = "L";
- description = ''
- Logout shortcut.
- '';
- };
-
- lock = mkOption {
- type = types.str;
- default = "K";
- description = ''
- Lock session shortcut.
- '';
- };
-
- hibernate = mkOption {
- type = types.str;
- default = "H";
- description = ''
- Hibernate shortcut.
- '';
- };
-
- clogout = mkOption {
- type = types.str;
- default = "openbox --exit";
- description = ''
- Command to logout.
- '';
- };
-
- clock = mkOption {
- type = types.str;
- default = "";
- description = ''
- Command to lock screen.
- '';
- };
-
- cswitchuser = mkOption {
- type = types.str;
- default = "";
- description = ''
- Command to switch user.
- '';
- };
- };
- };
-
- ###### implementation
-
- config = mkIf cfg.enable {
- environment.systemPackages = [ pkgs.oblogout ];
-
- environment.etc."oblogout.conf".text = ''
- [settings]
- usehal = false
-
- [looks]
- opacity = ${toString cfg.opacity}
- bgcolor = ${cfg.bgcolor}
- buttontheme = ${cfg.buttontheme}
- buttons = ${cfg.buttons}
- [shortcuts]
- cancel = ${cfg.cancel}
- shutdown = ${cfg.shutdown}
- restart = ${cfg.restart}
- suspend = ${cfg.suspend}
- logout = ${cfg.logout}
- lock = ${cfg.lock}
- hibernate = ${cfg.hibernate}
+ imports = [
+ (mkRemovedOptionModule [ "programs" "oblogout" ] "programs.oblogout has been removed from NixOS. This is because the oblogout repository has been archived upstream.")
+ ];
- [commands]
- shutdown = systemctl poweroff
- restart = systemctl reboot
- suspend = systemctl suspend
- hibernate = systemctl hibernate
- logout = ${cfg.clogout}
- lock = ${cfg.clock}
- switchuser = ${cfg.cswitchuser}
- '';
- };
}
diff --git a/nixpkgs/nixos/modules/programs/screen.nix b/nixpkgs/nixos/modules/programs/screen.nix
index 4fd800dbae7..728a0eb8cea 100644
--- a/nixpkgs/nixos/modules/programs/screen.nix
+++ b/nixpkgs/nixos/modules/programs/screen.nix
@@ -27,6 +27,7 @@ in
environment.etc.screenrc.text = cfg.screenrc;
environment.systemPackages = [ pkgs.screen ];
+ security.pam.services.screen = {};
};
}
diff --git a/nixpkgs/nixos/modules/programs/shadow.nix b/nixpkgs/nixos/modules/programs/shadow.nix
index 7eaf79d864e..fc352795c01 100644
--- a/nixpkgs/nixos/modules/programs/shadow.nix
+++ b/nixpkgs/nixos/modules/programs/shadow.nix
@@ -76,22 +76,18 @@ in
config.users.defaultUserShell;
environment.etc =
- [ { # /etc/login.defs: global configuration for pwdutils. You
- # cannot login without it!
- source = pkgs.writeText "login.defs" loginDefs;
- target = "login.defs";
- }
-
- { # /etc/default/useradd: configuration for useradd.
- source = pkgs.writeText "useradd"
- ''
- GROUP=100
- HOME=/home
- SHELL=${utils.toShellPath config.users.defaultUserShell}
- '';
- target = "default/useradd";
- }
- ];
+ { # /etc/login.defs: global configuration for pwdutils. You
+ # cannot login without it!
+ "login.defs".source = pkgs.writeText "login.defs" loginDefs;
+
+ # /etc/default/useradd: configuration for useradd.
+ "default/useradd".source = pkgs.writeText "useradd"
+ ''
+ GROUP=100
+ HOME=/home
+ SHELL=${utils.toShellPath config.users.defaultUserShell}
+ '';
+ };
security.pam.services =
{ chsh = { rootOK = true; };
diff --git a/nixpkgs/nixos/modules/programs/ssmtp.nix b/nixpkgs/nixos/modules/programs/ssmtp.nix
index e45748af205..f794eac8af0 100644
--- a/nixpkgs/nixos/modules/programs/ssmtp.nix
+++ b/nixpkgs/nixos/modules/programs/ssmtp.nix
@@ -13,6 +13,11 @@ let
in
{
+ imports = [
+ (mkRenamedOptionModule [ "networking" "defaultMailServer" ] [ "services" "ssmtp" ])
+ (mkRenamedOptionModule [ "services" "ssmtp" "directDelivery" ] [ "services" "ssmtp" "enable" ])
+ ];
+
options = {
services.ssmtp = {
diff --git a/nixpkgs/nixos/modules/programs/sway.nix b/nixpkgs/nixos/modules/programs/sway.nix
index f92d09a7ef4..e2a4018e902 100644
--- a/nixpkgs/nixos/modules/programs/sway.nix
+++ b/nixpkgs/nixos/modules/programs/sway.nix
@@ -4,26 +4,32 @@ with lib;
let
cfg = config.programs.sway;
- swayPackage = pkgs.sway;
- swayWrapped = pkgs.writeShellScriptBin "sway" ''
- set -o errexit
-
- if [ ! "$_SWAY_WRAPPER_ALREADY_EXECUTED" ]; then
- export _SWAY_WRAPPER_ALREADY_EXECUTED=1
- ${cfg.extraSessionCommands}
- fi
+ wrapperOptions = types.submodule {
+ options =
+ let
+ mkWrapperFeature = default: description: mkOption {
+ type = types.bool;
+ inherit default;
+ example = !default;
+ description = "Whether to make use of the ${description}";
+ };
+ in {
+ base = mkWrapperFeature true ''
+ base wrapper to execute extra session commands and prepend a
+ dbus-run-session to the sway command.
+ '';
+ gtk = mkWrapperFeature false ''
+ wrapGAppsHook wrapper to execute sway with required environment
+ variables for GTK applications.
+ '';
+ };
+ };
- if [ "$DBUS_SESSION_BUS_ADDRESS" ]; then
- export DBUS_SESSION_BUS_ADDRESS
- exec ${swayPackage}/bin/sway "$@"
- else
- exec ${pkgs.dbus}/bin/dbus-run-session ${swayPackage}/bin/sway "$@"
- fi
- '';
- swayJoined = pkgs.symlinkJoin {
- name = "sway-joined";
- paths = [ swayWrapped swayPackage ];
+ swayPackage = pkgs.sway.override {
+ extraSessionCommands = cfg.extraSessionCommands;
+ withBaseWrapper = cfg.wrapperFeatures.base;
+ withGtkWrapper = cfg.wrapperFeatures.gtk;
};
in {
options.programs.sway = {
@@ -35,6 +41,15 @@ in {
Please have a look at the "extraSessionCommands" example for running
programs natively under Wayland'';
+ wrapperFeatures = mkOption {
+ type = wrapperOptions;
+ default = { };
+ example = { gtk = true; };
+ description = ''
+ Attribute set of features to enable in the wrapper.
+ '';
+ };
+
extraSessionCommands = mkOption {
type = types.lines;
default = "";
@@ -55,7 +70,7 @@ in {
extraPackages = mkOption {
type = with types; listOf package;
default = with pkgs; [
- swaylock swayidle swaybg
+ swaylock swayidle
xwayland rxvt_unicode dmenu
];
defaultText = literalExample ''
@@ -75,8 +90,17 @@ in {
};
config = mkIf cfg.enable {
+ assertions = [
+ {
+ assertion = cfg.extraSessionCommands != "" -> cfg.wrapperFeatures.base;
+ message = ''
+ The extraSessionCommands for Sway will not be run if
+ wrapperFeatures.base is disabled.
+ '';
+ }
+ ];
environment = {
- systemPackages = [ swayJoined ] ++ cfg.extraPackages;
+ systemPackages = [ swayPackage ] ++ cfg.extraPackages;
etc = {
"sway/config".source = mkOptionDefault "${swayPackage}/etc/sway/config";
#"sway/security.d".source = mkOptionDefault "${swayPackage}/etc/sway/security.d/";
@@ -87,6 +111,8 @@ in {
hardware.opengl.enable = mkDefault true;
fonts.enableDefaultFonts = mkDefault true;
programs.dconf.enable = mkDefault true;
+ # To make a Sway session available if a display manager like SDDM is enabled:
+ services.xserver.displayManager.sessionPackages = [ swayPackage ];
};
meta.maintainers = with lib.maintainers; [ gnidorah primeos colemickens ];
diff --git a/nixpkgs/nixos/modules/programs/zsh/oh-my-zsh.nix b/nixpkgs/nixos/modules/programs/zsh/oh-my-zsh.nix
index f4df4e983e4..932a780a356 100644
--- a/nixpkgs/nixos/modules/programs/zsh/oh-my-zsh.nix
+++ b/nixpkgs/nixos/modules/programs/zsh/oh-my-zsh.nix
@@ -29,6 +29,13 @@ let
in
{
+ imports = [
+ (mkRenamedOptionModule [ "programs" "zsh" "oh-my-zsh" "enable" ] [ "programs" "zsh" "ohMyZsh" "enable" ])
+ (mkRenamedOptionModule [ "programs" "zsh" "oh-my-zsh" "theme" ] [ "programs" "zsh" "ohMyZsh" "theme" ])
+ (mkRenamedOptionModule [ "programs" "zsh" "oh-my-zsh" "custom" ] [ "programs" "zsh" "ohMyZsh" "custom" ])
+ (mkRenamedOptionModule [ "programs" "zsh" "oh-my-zsh" "plugins" ] [ "programs" "zsh" "ohMyZsh" "plugins" ])
+ ];
+
options = {
programs.zsh.ohMyZsh = {
enable = mkOption {
diff --git a/nixpkgs/nixos/modules/programs/zsh/zsh-autosuggestions.nix b/nixpkgs/nixos/modules/programs/zsh/zsh-autosuggestions.nix
index ded17f38a61..037888fdc5a 100644
--- a/nixpkgs/nixos/modules/programs/zsh/zsh-autosuggestions.nix
+++ b/nixpkgs/nixos/modules/programs/zsh/zsh-autosuggestions.nix
@@ -6,6 +6,10 @@ let
cfg = config.programs.zsh.autosuggestions;
in
{
+ imports = [
+ (mkRenamedOptionModule [ "programs" "zsh" "enableAutosuggestions" ] [ "programs" "zsh" "autosuggestions" "enable" ])
+ ];
+
options.programs.zsh.autosuggestions = {
enable = mkEnableOption "zsh-autosuggestions";
diff --git a/nixpkgs/nixos/modules/programs/zsh/zsh-syntax-highlighting.nix b/nixpkgs/nixos/modules/programs/zsh/zsh-syntax-highlighting.nix
index c84d26a7921..927a904369d 100644
--- a/nixpkgs/nixos/modules/programs/zsh/zsh-syntax-highlighting.nix
+++ b/nixpkgs/nixos/modules/programs/zsh/zsh-syntax-highlighting.nix
@@ -6,6 +6,13 @@ let
cfg = config.programs.zsh.syntaxHighlighting;
in
{
+ imports = [
+ (mkRenamedOptionModule [ "programs" "zsh" "enableSyntaxHighlighting" ] [ "programs" "zsh" "syntaxHighlighting" "enable" ])
+ (mkRenamedOptionModule [ "programs" "zsh" "syntax-highlighting" "enable" ] [ "programs" "zsh" "syntaxHighlighting" "enable" ])
+ (mkRenamedOptionModule [ "programs" "zsh" "syntax-highlighting" "highlighters" ] [ "programs" "zsh" "syntaxHighlighting" "highlighters" ])
+ (mkRenamedOptionModule [ "programs" "zsh" "syntax-highlighting" "patterns" ] [ "programs" "zsh" "syntaxHighlighting" "patterns" ])
+ ];
+
options = {
programs.zsh.syntaxHighlighting = {
enable = mkEnableOption "zsh-syntax-highlighting";
diff --git a/nixpkgs/nixos/modules/rename.nix b/nixpkgs/nixos/modules/rename.nix
index e392fef54dd..7109ab5a109 100644
--- a/nixpkgs/nixos/modules/rename.nix
+++ b/nixpkgs/nixos/modules/rename.nix
@@ -4,313 +4,30 @@ with lib;
{
imports = [
- (mkRenamedOptionModule [ "networking" "enableRT73Firmware" ] [ "hardware" "enableRedistributableFirmware" ])
- (mkRenamedOptionModule [ "networking" "enableIntel3945ABGFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
- (mkRenamedOptionModule [ "networking" "enableIntel2100BGFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
- (mkRenamedOptionModule [ "networking" "enableRalinkFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
- (mkRenamedOptionModule [ "networking" "enableRTL8192cFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
- (mkRenamedOptionModule [ "networking" "networkmanager" "useDnsmasq" ] [ "networking" "networkmanager" "dns" ])
- (mkRenamedOptionModule [ "networking" "connman" ] [ "services" "connman" ])
- (mkRenamedOptionModule [ "networking" "defaultMailServer" ] [ "services" "ssmtp" ])
- (mkRenamedOptionModule [ "services" "ssmtp" "directDelivery" ] [ "services" "ssmtp" "enable" ])
- (mkChangedOptionModule [ "services" "printing" "gutenprint" ] [ "services" "printing" "drivers" ]
- (config:
- let enabled = getAttrFromPath [ "services" "printing" "gutenprint" ] config;
- in if enabled then [ pkgs.gutenprint ] else [ ]))
- (mkChangedOptionModule [ "services" "ddclient" "domain" ] [ "services" "ddclient" "domains" ]
- (config:
- let value = getAttrFromPath [ "services" "ddclient" "domain" ] config;
- in if value != "" then [ value ] else []))
- (mkRemovedOptionModule [ "services" "ddclient" "homeDir" ] "")
- (mkRenamedOptionModule [ "services" "flatpak" "extraPortals" ] [ "xdg" "portal" "extraPortals" ])
- (mkRenamedOptionModule [ "services" "i2pd" "extIp" ] [ "services" "i2pd" "address" ])
- (mkRenamedOptionModule [ "services" "kubernetes" "apiserver" "admissionControl" ] [ "services" "kubernetes" "apiserver" "enableAdmissionPlugins" ])
- (mkRenamedOptionModule [ "services" "kubernetes" "apiserver" "address" ] ["services" "kubernetes" "apiserver" "bindAddress"])
- (mkRenamedOptionModule [ "services" "kubernetes" "apiserver" "port" ] ["services" "kubernetes" "apiserver" "insecurePort"])
- (mkRemovedOptionModule [ "services" "kubernetes" "apiserver" "publicAddress" ] "")
- (mkRenamedOptionModule [ "services" "kubernetes" "addons" "dashboard" "enableRBAC" ] [ "services" "kubernetes" "addons" "dashboard" "rbac" "enable" ])
- (mkRenamedOptionModule [ "services" "kubernetes" "controllerManager" "address" ] ["services" "kubernetes" "controllerManager" "bindAddress"])
- (mkRenamedOptionModule [ "services" "kubernetes" "controllerManager" "port" ] ["services" "kubernetes" "controllerManager" "insecurePort"])
- (mkRenamedOptionModule [ "services" "kubernetes" "etcd" "servers" ] [ "services" "kubernetes" "apiserver" "etcd" "servers" ])
- (mkRenamedOptionModule [ "services" "kubernetes" "etcd" "keyFile" ] [ "services" "kubernetes" "apiserver" "etcd" "keyFile" ])
- (mkRenamedOptionModule [ "services" "kubernetes" "etcd" "certFile" ] [ "services" "kubernetes" "apiserver" "etcd" "certFile" ])
- (mkRenamedOptionModule [ "services" "kubernetes" "etcd" "caFile" ] [ "services" "kubernetes" "apiserver" "etcd" "caFile" ])
- (mkRemovedOptionModule [ "services" "kubernetes" "kubelet" "applyManifests" ] "")
- (mkRemovedOptionModule [ "services" "kubernetes" "kubelet" "cadvisorPort" ] "")
- (mkRemovedOptionModule [ "services" "kubernetes" "kubelet" "allowPrivileged" ] "")
- (mkRenamedOptionModule [ "services" "kubernetes" "proxy" "address" ] ["services" "kubernetes" "proxy" "bindAddress"])
- (mkRemovedOptionModule [ "services" "kubernetes" "verbose" ] "")
- (mkRenamedOptionModule [ "services" "logstash" "address" ] [ "services" "logstash" "listenAddress" ])
- (mkRenamedOptionModule [ "services" "neo4j" "host" ] [ "services" "neo4j" "defaultListenAddress" ])
- (mkRenamedOptionModule [ "services" "neo4j" "listenAddress" ] [ "services" "neo4j" "defaultListenAddress" ])
- (mkRenamedOptionModule [ "services" "neo4j" "enableBolt" ] [ "services" "neo4j" "bolt" "enable" ])
- (mkRenamedOptionModule [ "services" "neo4j" "enableHttps" ] [ "services" "neo4j" "https" "enable" ])
- (mkRenamedOptionModule [ "services" "neo4j" "certDir" ] [ "services" "neo4j" "directories" "certificates" ])
- (mkRenamedOptionModule [ "services" "neo4j" "dataDir" ] [ "services" "neo4j" "directories" "home" ])
- (mkRemovedOptionModule [ "services" "neo4j" "port" ] "Use services.neo4j.http.listenAddress instead.")
- (mkRemovedOptionModule [ "services" "neo4j" "boltPort" ] "Use services.neo4j.bolt.listenAddress instead.")
- (mkRemovedOptionModule [ "services" "neo4j" "httpsPort" ] "Use services.neo4j.https.listenAddress instead.")
- (mkRemovedOptionModule [ "services" "misc" "nzbget" "configFile" ] "The configuration of nzbget is now managed by users through the web interface.")
- (mkRemovedOptionModule [ "services" "misc" "nzbget" "dataDir" ] "The data directory for nzbget is now /var/lib/nzbget.")
- (mkRemovedOptionModule [ "services" "misc" "nzbget" "openFirewall" ] "The port used by nzbget is managed through the web interface so you should adjust your firewall rules accordingly.")
- (mkRemovedOptionModule [ "services" "prometheus" "alertmanager" "user" ] "The alertmanager service is now using systemd's DynamicUser mechanism which obviates a user setting.")
- (mkRemovedOptionModule [ "services" "prometheus" "alertmanager" "group" ] "The alertmanager service is now using systemd's DynamicUser mechanism which obviates a group setting.")
- (mkRemovedOptionModule [ "services" "prometheus" "alertmanagerURL" ] ''
- Due to incompatibility, the alertmanagerURL option has been removed,
- please use 'services.prometheus2.alertmanagers' instead.
- '')
- (mkRenamedOptionModule [ "services" "prometheus2" ] [ "services" "prometheus" ])
- (mkRenamedOptionModule [ "services" "tor" "relay" "portSpec" ] [ "services" "tor" "relay" "port" ])
- (mkRenamedOptionModule [ "services" "vmwareGuest" ] [ "virtualisation" "vmware" "guest" ])
- (mkRenamedOptionModule [ "jobs" ] [ "systemd" "services" ])
+ /*
+ This file defines some renaming/removing options for backwards compatibility
- (mkRenamedOptionModule [ "services" "gitlab" "stateDir" ] [ "services" "gitlab" "statePath" ])
- (mkRemovedOptionModule [ "services" "gitlab" "satelliteDir" ] "")
-
- (mkRenamedOptionModule [ "services" "clamav" "updater" "config" ] [ "services" "clamav" "updater" "extraConfig" ])
-
- (mkRemovedOptionModule [ "services" "pykms" "verbose" ] "Use services.pykms.logLevel instead")
-
- (mkRemovedOptionModule [ "security" "setuidOwners" ] "Use security.wrappers instead")
- (mkRemovedOptionModule [ "security" "setuidPrograms" ] "Use security.wrappers instead")
-
- (mkRenamedOptionModule [ "security" "virtualization" "flushL1DataCache" ] [ "security" "virtualisation" "flushL1DataCache" ])
-
- # PAM
- (mkRenamedOptionModule [ "security" "pam" "enableU2F" ] [ "security" "pam" "u2f" "enable" ])
-
- # rmilter/rspamd
- (mkRemovedOptionModule [ "services" "rmilter" ] "Use services.rspamd.* instead to set up milter service")
-
- # Xsession script
- (mkRenamedOptionModule [ "services" "xserver" "displayManager" "job" "logsXsession" ] [ "services" "xserver" "displayManager" "job" "logToFile" ])
- (mkRenamedOptionModule [ "services" "xserver" "displayManager" "logToJournal" ] [ "services" "xserver" "displayManager" "job" "logToJournal" ])
-
- # Old Grub-related options.
- (mkRenamedOptionModule [ "boot" "loader" "grub" "timeout" ] [ "boot" "loader" "timeout" ])
- (mkRenamedOptionModule [ "boot" "loader" "gummiboot" "timeout" ] [ "boot" "loader" "timeout" ])
-
- # OpenSSH
- (mkAliasOptionModule [ "services" "sshd" "enable" ] [ "services" "openssh" "enable" ])
- (mkAliasOptionModule [ "services" "openssh" "knownHosts" ] [ "programs" "ssh" "knownHosts" ])
-
- # libvirtd
- (mkRemovedOptionModule [ "virtualisation" "libvirtd" "enableKVM" ]
- "Set the option `virtualisation.libvirtd.qemuPackage' instead.")
-
- # ibus
- (mkRenamedOptionModule [ "programs" "ibus" "plugins" ] [ "i18n" "inputMethod" "ibus" "engines" ])
-
- # sandboxing
- (mkRenamedOptionModule [ "nix" "useChroot" ] [ "nix" "useSandbox" ])
- (mkRenamedOptionModule [ "nix" "chrootDirs" ] [ "nix" "sandboxPaths" ])
-
- (mkRenamedOptionModule [ "services" "xserver" "vaapiDrivers" ] [ "hardware" "opengl" "extraPackages" ])
+ It should ONLY be used when the relevant module can't define these imports
+ itself, such as when the module was removed completely.
+ See https://github.com/NixOS/nixpkgs/pull/61570 for explanation
+ */
+ # This alias module can't be where _module.check is defined because it would
+ # be added to submodules as well there
(mkAliasOptionModule [ "environment" "checkConfigurationOptions" ] [ "_module" "check" ])
- # opendkim
- (mkRenamedOptionModule [ "services" "opendkim" "keyFile" ] [ "services" "opendkim" "keyPath" ])
-
- # Enlightenment
- (mkRenamedOptionModule [ "services" "xserver" "desktopManager" "e19" "enable" ] [ "services" "xserver" "desktopManager" "enlightenment" "enable" ])
-
- # Iodine
- (mkRenamedOptionModule [ "services" "iodined" "enable" ] [ "services" "iodine" "server" "enable" ])
- (mkRenamedOptionModule [ "services" "iodined" "domain" ] [ "services" "iodine" "server" "domain" ])
- (mkRenamedOptionModule [ "services" "iodined" "ip" ] [ "services" "iodine" "server" "ip" ])
- (mkRenamedOptionModule [ "services" "iodined" "extraConfig" ] [ "services" "iodine" "server" "extraConfig" ])
- (mkRemovedOptionModule [ "services" "iodined" "client" ] "")
-
- # Unity3D
- (mkRenamedOptionModule [ "programs" "unity3d" "enable" ] [ "security" "chromiumSuidSandbox" "enable" ])
-
- # murmur
- (mkRenamedOptionModule [ "services" "murmur" "welcome" ] [ "services" "murmur" "welcometext" ])
- (mkRemovedOptionModule [ "services" "murmur" "pidfile" ] "Hardcoded to /run/murmur/murmurd.pid now")
-
- # parsoid
- (mkRemovedOptionModule [ "services" "parsoid" "interwikis" ] "Use services.parsoid.wikis instead")
-
- # plexpy / tautulli
- (mkRenamedOptionModule [ "services" "plexpy" ] [ "services" "tautulli" ])
-
- # piwik was renamed to matomo
- (mkRenamedOptionModule [ "services" "piwik" "enable" ] [ "services" "matomo" "enable" ])
- (mkRenamedOptionModule [ "services" "piwik" "webServerUser" ] [ "services" "matomo" "webServerUser" ])
- (mkRemovedOptionModule [ "services" "piwik" "phpfpmProcessManagerConfig" ] "Use services.phpfpm.pools.<name>.settings")
- (mkRemovedOptionModule [ "services" "matomo" "phpfpmProcessManagerConfig" ] "Use services.phpfpm.pools.<name>.settings")
- (mkRenamedOptionModule [ "services" "piwik" "nginx" ] [ "services" "matomo" "nginx" ])
-
- # tarsnap
- (mkRemovedOptionModule [ "services" "tarsnap" "cachedir" ] "Use services.tarsnap.archives.<name>.cachedir")
-
- # alsa
- (mkRenamedOptionModule [ "sound" "enableMediaKeys" ] [ "sound" "mediaKeys" "enable" ])
-
- # postgrey
- (mkMergedOptionModule [ [ "services" "postgrey" "inetAddr" ] [ "services" "postgrey" "inetPort" ] ] [ "services" "postgrey" "socket" ] (config: let
- value = p: getAttrFromPath p config;
- inetAddr = [ "services" "postgrey" "inetAddr" ];
- inetPort = [ "services" "postgrey" "inetPort" ];
- in
- if value inetAddr == null
- then { path = "/run/postgrey.sock"; }
- else { addr = value inetAddr; port = value inetPort; }
- ))
-
- # dhcpd
- (mkRenamedOptionModule [ "services" "dhcpd" ] [ "services" "dhcpd4" ])
-
- # locate
- (mkRenamedOptionModule [ "services" "locate" "period" ] [ "services" "locate" "interval" ])
- (mkRemovedOptionModule [ "services" "locate" "includeStore" ] "Use services.locate.prunePaths" )
-
- # nfs
- (mkRenamedOptionModule [ "services" "nfs" "lockdPort" ] [ "services" "nfs" "server" "lockdPort" ])
- (mkRenamedOptionModule [ "services" "nfs" "statdPort" ] [ "services" "nfs" "server" "statdPort" ])
-
- # KDE Plasma 5
- (mkRenamedOptionModule [ "services" "xserver" "desktopManager" "kde5" ] [ "services" "xserver" "desktopManager" "plasma5" ])
-
- # Fontconfig
- (mkRenamedOptionModule [ "fonts" "fontconfig" "ultimate" "allowBitmaps" ] [ "fonts" "fontconfig" "allowBitmaps" ])
- (mkRenamedOptionModule [ "fonts" "fontconfig" "ultimate" "allowType1" ] [ "fonts" "fontconfig" "allowType1" ])
- (mkRenamedOptionModule [ "fonts" "fontconfig" "ultimate" "useEmbeddedBitmaps" ] [ "fonts" "fontconfig" "useEmbeddedBitmaps" ])
- (mkRenamedOptionModule [ "fonts" "fontconfig" "ultimate" "forceAutohint" ] [ "fonts" "fontconfig" "forceAutohint" ])
- (mkRenamedOptionModule [ "fonts" "fontconfig" "ultimate" "renderMonoTTFAsBitmap" ] [ "fonts" "fontconfig" "renderMonoTTFAsBitmap" ])
-
- # postgresqlBackup
- (mkRemovedOptionModule [ "services" "postgresqlBackup" "period" ] ''
- A systemd timer is now used instead of cron.
- The starting time can be configured via <literal>services.postgresqlBackup.startAt</literal>.
- '')
-
- # phpfpm
- (mkRemovedOptionModule [ "services" "phpfpm" "poolConfigs" ] "Use services.phpfpm.pools instead.")
-
- # zabbixServer
- (mkRenamedOptionModule [ "services" "zabbixServer" "dbServer" ] [ "services" "zabbixServer" "database" "host" ])
-
- # Profile splitting
- (mkRenamedOptionModule [ "virtualisation" "growPartition" ] [ "boot" "growPartition" ])
-
- # misc/version.nix
- (mkRenamedOptionModule [ "system" "nixosVersion" ] [ "system" "nixos" "version" ])
- (mkRenamedOptionModule [ "system" "nixosVersionSuffix" ] [ "system" "nixos" "versionSuffix" ])
- (mkRenamedOptionModule [ "system" "nixosRevision" ] [ "system" "nixos" "revision" ])
- (mkRenamedOptionModule [ "system" "nixosLabel" ] [ "system" "nixos" "label" ])
-
- # Users
- (mkAliasOptionModule [ "users" "extraUsers" ] [ "users" "users" ])
- (mkAliasOptionModule [ "users" "extraGroups" ] [ "users" "groups" ])
-
- # Options that are obsolete and have no replacement.
- (mkRemovedOptionModule [ "boot" "initrd" "luks" "enable" ] "")
- (mkRemovedOptionModule [ "programs" "bash" "enable" ] "")
- (mkRemovedOptionModule [ "services" "samba" "defaultShare" ] "")
- (mkRemovedOptionModule [ "services" "syslog-ng" "serviceName" ] "")
- (mkRemovedOptionModule [ "services" "syslog-ng" "listenToJournal" ] "")
- (mkRemovedOptionModule [ "ec2" "metadata" ] "")
- (mkRemovedOptionModule [ "services" "openvpn" "enable" ] "")
- (mkRemovedOptionModule [ "services" "printing" "cupsFilesConf" ] "")
- (mkRemovedOptionModule [ "services" "printing" "cupsdConf" ] "")
- (mkRemovedOptionModule [ "services" "tor" "relay" "isBridge" ] "Use services.tor.relay.role instead.")
- (mkRemovedOptionModule [ "services" "tor" "relay" "isExit" ] "Use services.tor.relay.role instead.")
- (mkRemovedOptionModule [ "services" "xserver" "startGnuPGAgent" ]
- "See the 16.09 release notes for more information.")
- (mkRemovedOptionModule [ "services" "phpfpm" "phpIni" ] "")
- (mkRemovedOptionModule [ "services" "dovecot2" "package" ] "")
+ # Completely removed modules
(mkRemovedOptionModule [ "services" "firefox" "syncserver" "user" ] "")
(mkRemovedOptionModule [ "services" "firefox" "syncserver" "group" ] "")
- (mkRemovedOptionModule [ "fonts" "fontconfig" "hinting" "style" ] "")
- (mkRemovedOptionModule [ "services" "xserver" "displayManager" "sddm" "themes" ]
- "Set the option `services.xserver.displayManager.sddm.package' instead.")
- (mkRemovedOptionModule [ "services" "xserver" "desktopManager" "xfce" "screenLock" ] "")
- (mkRemovedOptionModule [ "fonts" "fontconfig" "forceAutohint" ] "")
- (mkRemovedOptionModule [ "fonts" "fontconfig" "renderMonoTTFAsBitmap" ] "")
- (mkRemovedOptionModule [ "virtualisation" "xen" "qemu" ] "You don't need this option anymore, it will work without it.")
- (mkRemovedOptionModule [ "services" "logstash" "enableWeb" ] "The web interface was removed from logstash")
- (mkRemovedOptionModule [ "boot" "zfs" "enableLegacyCrypto" ] "The corresponding package was removed from nixpkgs.")
(mkRemovedOptionModule [ "services" "winstone" ] "The corresponding package was removed from nixpkgs.")
- (mkRemovedOptionModule [ "services" "mysql" "pidDir" ] "Don't wait for pidfiles, describe dependencies through systemd")
- (mkRemovedOptionModule [ "services" "mysql" "rootPassword" ] "Use socket authentication or set the password outside of the nix store.")
- (mkRemovedOptionModule [ "services" "zabbixServer" "dbPassword" ] "Use services.zabbixServer.database.passwordFile instead.")
- (mkRemovedOptionModule [ "systemd" "generator-packages" ] "Use systemd.packages instead.")
- (mkRemovedOptionModule [ "fonts" "enableCoreFonts" ] "Use fonts.fonts = [ pkgs.corefonts ]; instead.")
(mkRemovedOptionModule [ "networking" "vpnc" ] "Use environment.etc.\"vpnc/service.conf\" instead.")
-
- # ZSH
- (mkRenamedOptionModule [ "programs" "zsh" "enableSyntaxHighlighting" ] [ "programs" "zsh" "syntaxHighlighting" "enable" ])
- (mkRenamedOptionModule [ "programs" "zsh" "syntax-highlighting" "enable" ] [ "programs" "zsh" "syntaxHighlighting" "enable" ])
- (mkRenamedOptionModule [ "programs" "zsh" "syntax-highlighting" "highlighters" ] [ "programs" "zsh" "syntaxHighlighting" "highlighters" ])
- (mkRenamedOptionModule [ "programs" "zsh" "syntax-highlighting" "patterns" ] [ "programs" "zsh" "syntaxHighlighting" "patterns" ])
- (mkRenamedOptionModule [ "programs" "zsh" "oh-my-zsh" "enable" ] [ "programs" "zsh" "ohMyZsh" "enable" ])
- (mkRenamedOptionModule [ "programs" "zsh" "oh-my-zsh" "theme" ] [ "programs" "zsh" "ohMyZsh" "theme" ])
- (mkRenamedOptionModule [ "programs" "zsh" "oh-my-zsh" "custom" ] [ "programs" "zsh" "ohMyZsh" "custom" ])
- (mkRenamedOptionModule [ "programs" "zsh" "oh-my-zsh" "plugins" ] [ "programs" "zsh" "ohMyZsh" "plugins" ])
-
- (mkRenamedOptionModule [ "programs" "zsh" "enableAutosuggestions" ] [ "programs" "zsh" "autosuggestions" "enable" ])
-
- # Xen
- (mkRenamedOptionModule [ "virtualisation" "xen" "qemu-package" ] [ "virtualisation" "xen" "package-qemu" ])
-
- (mkRenamedOptionModule [ "programs" "info" "enable" ] [ "documentation" "info" "enable" ])
- (mkRenamedOptionModule [ "programs" "man" "enable" ] [ "documentation" "man" "enable" ])
- (mkRenamedOptionModule [ "services" "nixosManual" "enable" ] [ "documentation" "nixos" "enable" ])
-
- # ckb
- (mkRenamedOptionModule [ "hardware" "ckb" "enable" ] [ "hardware" "ckb-next" "enable" ])
- (mkRenamedOptionModule [ "hardware" "ckb" "package" ] [ "hardware" "ckb-next" "package" ])
-
- # binfmt
- (mkRenamedOptionModule [ "boot" "binfmtMiscRegistrations" ] [ "boot" "binfmt" "registrations" ])
-
- # ACME
- (mkRemovedOptionModule [ "security" "acme" "directory"] "ACME Directory is now hardcoded to /var/lib/acme and its permisisons are managed by systemd. See https://github.com/NixOS/nixpkgs/issues/53852 for more info.")
- (mkRemovedOptionModule [ "security" "acme" "preDelay"] "This option has been removed. If you want to make sure that something executes before certificates are provisioned, add a RequiredBy=acme-\${cert}.service to the service you want to execute before the cert renewal")
- (mkRemovedOptionModule [ "security" "acme" "activationDelay"] "This option has been removed. If you want to make sure that something executes before certificates are provisioned, add a RequiredBy=acme-\${cert}.service to the service you want to execute before the cert renewal")
-
- # KSM
- (mkRenamedOptionModule [ "hardware" "enableKSM" ] [ "hardware" "ksm" "enable" ])
-
- # resolvconf
- (mkRenamedOptionModule [ "networking" "dnsSingleRequest" ] [ "networking" "resolvconf" "dnsSingleRequest" ])
- (mkRenamedOptionModule [ "networking" "dnsExtensionMechanism" ] [ "networking" "resolvconf" "dnsExtensionMechanism" ])
- (mkRenamedOptionModule [ "networking" "extraResolvconfConf" ] [ "networking" "resolvconf" "extraConfig" ])
- (mkRenamedOptionModule [ "networking" "resolvconfOptions" ] [ "networking" "resolvconf" "extraOptions" ])
-
- # BLCR
(mkRemovedOptionModule [ "environment.blcr.enable" ] "The BLCR module has been removed")
-
- # beegfs
(mkRemovedOptionModule [ "services.beegfsEnable" ] "The BeeGFS module has been removed")
(mkRemovedOptionModule [ "services.beegfs" ] "The BeeGFS module has been removed")
-
- # osquery
(mkRemovedOptionModule [ "services.osquery" ] "The osquery module has been removed")
+ (mkRemovedOptionModule [ "services.fourStore" ] "The fourStore module has been removed")
+ (mkRemovedOptionModule [ "services.fourStoreEndpoint" ] "The fourStoreEndpoint module has been removed")
- # Redis
- (mkRemovedOptionModule [ "services" "redis" "user" ] "The redis module now is hardcoded to the redis user.")
- (mkRemovedOptionModule [ "services" "redis" "dbpath" ] "The redis module now uses /var/lib/redis as data directory.")
- (mkRemovedOptionModule [ "services" "redis" "dbFilename" ] "The redis module now uses /var/lib/redis/dump.rdb as database dump location.")
- (mkRemovedOptionModule [ "services" "redis" "appendOnlyFilename" ] "This option was never used.")
- (mkRemovedOptionModule [ "services" "redis" "pidFile" ] "This option was removed.")
-
- ] ++ (forEach [ "blackboxExporter" "collectdExporter" "fritzboxExporter"
- "jsonExporter" "minioExporter" "nginxExporter" "nodeExporter"
- "snmpExporter" "unifiExporter" "varnishExporter" ]
- (opt: mkRemovedOptionModule [ "services" "prometheus" "${opt}" ] ''
- The prometheus exporters are now configured using `services.prometheus.exporters'.
- See the 18.03 release notes for more information.
- '' ))
-
- ++ (forEach [ "enable" "substitutions" "preset" ]
- (opt: mkRemovedOptionModule [ "fonts" "fontconfig" "ultimate" "${opt}" ] ''
- The fonts.fontconfig.ultimate module and configuration is obsolete.
- The repository has since been archived and activity has ceased.
- https://github.com/bohoomil/fontconfig-ultimate/issues/171.
- No action should be needed for font configuration, as the fonts.fontconfig
- module is already used by default.
- '' ));
+ # Do NOT add any option renames here, see top of the file
+ ];
}
diff --git a/nixpkgs/nixos/modules/security/acme.nix b/nixpkgs/nixos/modules/security/acme.nix
index 9563029f030..890c421b0ea 100644
--- a/nixpkgs/nixos/modules/security/acme.nix
+++ b/nixpkgs/nixos/modules/security/acme.nix
@@ -127,6 +127,9 @@ in
"https://acme-staging-v02.api.letsencrypt.org/directory".
''
)
+ (mkRemovedOptionModule [ "security" "acme" "directory"] "ACME Directory is now hardcoded to /var/lib/acme and its permisisons are managed by systemd. See https://github.com/NixOS/nixpkgs/issues/53852 for more info.")
+ (mkRemovedOptionModule [ "security" "acme" "preDelay"] "This option has been removed. If you want to make sure that something executes before certificates are provisioned, add a RequiredBy=acme-\${cert}.service to the service you want to execute before the cert renewal")
+ (mkRemovedOptionModule [ "security" "acme" "activationDelay"] "This option has been removed. If you want to make sure that something executes before certificates are provisioned, add a RequiredBy=acme-\${cert}.service to the service you want to execute before the cert renewal")
];
options = {
security.acme = {
@@ -238,9 +241,9 @@ in
StateDirectoryMode = rights;
WorkingDirectory = "/var/lib/${lpath}";
ExecStart = "${pkgs.simp_le}/bin/simp_le ${escapeShellArgs cmdline}";
- ExecStopPost =
+ ExecStartPost =
let
- script = pkgs.writeScript "acme-post-stop" ''
+ script = pkgs.writeScript "acme-post-start" ''
#!${pkgs.runtimeShell} -e
${data.postRun}
'';
diff --git a/nixpkgs/nixos/modules/security/apparmor-suid.nix b/nixpkgs/nixos/modules/security/apparmor-suid.nix
index 498c2f25d1c..3c93f5440ab 100644
--- a/nixpkgs/nixos/modules/security/apparmor-suid.nix
+++ b/nixpkgs/nixos/modules/security/apparmor-suid.nix
@@ -4,6 +4,9 @@ let
in
with lib;
{
+ imports = [
+ (mkRenamedOptionModule [ "security" "virtualization" "flushL1DataCache" ] [ "security" "virtualisation" "flushL1DataCache" ])
+ ];
options.security.apparmor.confineSUIDApplications = mkOption {
default = true;
diff --git a/nixpkgs/nixos/modules/security/chromium-suid-sandbox.nix b/nixpkgs/nixos/modules/security/chromium-suid-sandbox.nix
index 2255477f26e..b83dbc4202a 100644
--- a/nixpkgs/nixos/modules/security/chromium-suid-sandbox.nix
+++ b/nixpkgs/nixos/modules/security/chromium-suid-sandbox.nix
@@ -7,6 +7,10 @@ let
sandbox = pkgs.chromium.sandbox;
in
{
+ imports = [
+ (mkRenamedOptionModule [ "programs" "unity3d" "enable" ] [ "security" "chromiumSuidSandbox" "enable" ])
+ ];
+
options.security.chromiumSuidSandbox.enable = mkOption {
type = types.bool;
default = false;
diff --git a/nixpkgs/nixos/modules/security/duosec.nix b/nixpkgs/nixos/modules/security/duosec.nix
index 997328ad9e6..78a82b7154e 100644
--- a/nixpkgs/nixos/modules/security/duosec.nix
+++ b/nixpkgs/nixos/modules/security/duosec.nix
@@ -25,19 +25,21 @@ let
accept_env_factor=${boolToStr cfg.acceptEnvFactor}
'';
- loginCfgFile = optional cfg.ssh.enable
- { source = pkgs.writeText "login_duo.conf" configFileLogin;
- mode = "0600";
- user = "sshd";
- target = "duo/login_duo.conf";
- };
+ loginCfgFile = optionalAttrs cfg.ssh.enable {
+ "duo/login_duo.conf" =
+ { source = pkgs.writeText "login_duo.conf" configFileLogin;
+ mode = "0600";
+ user = "sshd";
+ };
+ };
- pamCfgFile = optional cfg.pam.enable
- { source = pkgs.writeText "pam_duo.conf" configFilePam;
- mode = "0600";
- user = "sshd";
- target = "duo/pam_duo.conf";
- };
+ pamCfgFile = optional cfg.pam.enable {
+ "duo/pam_duo.conf" =
+ { source = pkgs.writeText "pam_duo.conf" configFilePam;
+ mode = "0600";
+ user = "sshd";
+ };
+ };
in
{
options = {
@@ -186,7 +188,7 @@ in
environment.systemPackages = [ pkgs.duo-unix ];
security.wrappers.login_duo.source = "${pkgs.duo-unix.out}/bin/login_duo";
- environment.etc = loginCfgFile ++ pamCfgFile;
+ environment.etc = loginCfgFile // pamCfgFile;
/* If PAM *and* SSH are enabled, then don't do anything special.
If PAM isn't used, set the default SSH-only options. */
diff --git a/nixpkgs/nixos/modules/security/pam.nix b/nixpkgs/nixos/modules/security/pam.nix
index 11227354ad3..bfc2a881387 100644
--- a/nixpkgs/nixos/modules/security/pam.nix
+++ b/nixpkgs/nixos/modules/security/pam.nix
@@ -475,15 +475,19 @@ let
motd = pkgs.writeText "motd" config.users.motd;
- makePAMService = pamService:
- { source = pkgs.writeText "${pamService.name}.pam" pamService.text;
- target = "pam.d/${pamService.name}";
+ makePAMService = name: service:
+ { name = "pam.d/${name}";
+ value.source = pkgs.writeText "${name}.pam" service.text;
};
in
{
+ imports = [
+ (mkRenamedOptionModule [ "security" "pam" "enableU2F" ] [ "security" "pam" "u2f" "enable" ])
+ ];
+
###### interface
options = {
@@ -707,7 +711,7 @@ in
Use "challenge-response" for offline validation using YubiKeys with HMAC-SHA-1
Challenge-Response configurations. See the man-page ykpamcfg(1) for further
- details on how to configure offline Challenge-Response validation.
+ details on how to configure offline Challenge-Response validation.
More information can be found <link
xlink:href="https://developers.yubico.com/yubico-pam/Authentication_Using_Challenge-Response.html">here</link>.
@@ -756,8 +760,7 @@ in
};
};
- environment.etc =
- mapAttrsToList (n: v: makePAMService v) config.security.pam.services;
+ environment.etc = mapAttrs' makePAMService config.security.pam.services;
security.pam.services =
{ other.text =
@@ -773,11 +776,8 @@ in
'';
# Most of these should be moved to specific modules.
- cups = {};
- ftp = {};
i3lock = {};
i3lock-color = {};
- screen = {};
vlock = {};
xlock = {};
xscreensaver = {};
diff --git a/nixpkgs/nixos/modules/security/pam_mount.nix b/nixpkgs/nixos/modules/security/pam_mount.nix
index 75f58462d13..77e22a96b55 100644
--- a/nixpkgs/nixos/modules/security/pam_mount.nix
+++ b/nixpkgs/nixos/modules/security/pam_mount.nix
@@ -36,8 +36,7 @@ in
config = mkIf (cfg.enable || anyPamMount) {
environment.systemPackages = [ pkgs.pam_mount ];
- environment.etc = [{
- target = "security/pam_mount.conf.xml";
+ environment.etc."security/pam_mount.conf.xml" = {
source =
let
extraUserVolumes = filterAttrs (n: u: u.cryptHomeLuks != null) config.users.users;
@@ -66,7 +65,7 @@ in
${concatStringsSep "\n" cfg.extraVolumes}
</pam_mount>
'';
- }];
+ };
};
}
diff --git a/nixpkgs/nixos/modules/security/polkit.nix b/nixpkgs/nixos/modules/security/polkit.nix
index f2b2df4004c..a6724bd7583 100644
--- a/nixpkgs/nixos/modules/security/polkit.nix
+++ b/nixpkgs/nixos/modules/security/polkit.nix
@@ -42,15 +42,14 @@ in
security.polkit.adminIdentities = mkOption {
type = types.listOf types.str;
- default = [ "unix-user:0" "unix-group:wheel" ];
+ default = [ "unix-group:wheel" ];
example = [ "unix-user:alice" "unix-group:admin" ];
description =
''
Specifies which users are considered “administrators”, for those
actions that require the user to authenticate as an
administrator (i.e. have an <literal>auth_admin</literal>
- value). By default, this is the <literal>root</literal>
- user and all users in the <literal>wheel</literal> group.
+ value). By default, this is all users in the <literal>wheel</literal> group.
'';
};
diff --git a/nixpkgs/nixos/modules/security/rtkit.nix b/nixpkgs/nixos/modules/security/rtkit.nix
index f6dda21c600..a7b27cbcf21 100644
--- a/nixpkgs/nixos/modules/security/rtkit.nix
+++ b/nixpkgs/nixos/modules/security/rtkit.nix
@@ -34,9 +34,8 @@ with lib;
services.dbus.packages = [ pkgs.rtkit ];
- users.users = singleton
- { name = "rtkit";
- uid = config.ids.uids.rtkit;
+ users.users.rtkit =
+ { uid = config.ids.uids.rtkit;
description = "RealtimeKit daemon";
};
diff --git a/nixpkgs/nixos/modules/security/sudo.nix b/nixpkgs/nixos/modules/security/sudo.nix
index 10ee036be84..d899806ef05 100644
--- a/nixpkgs/nixos/modules/security/sudo.nix
+++ b/nixpkgs/nixos/modules/security/sudo.nix
@@ -212,7 +212,7 @@ in
security.pam.services.sudo = { sshAgentAuth = true; };
- environment.etc = singleton
+ environment.etc.sudoers =
{ source =
pkgs.runCommand "sudoers"
{
@@ -222,7 +222,6 @@ in
# Make sure that the sudoers file is syntactically valid.
# (currently disabled - NIXOS-66)
"${pkgs.buildPackages.sudo}/sbin/visudo -f $src -c && cp $src $out";
- target = "sudoers";
mode = "0440";
};
diff --git a/nixpkgs/nixos/modules/security/wrappers/default.nix b/nixpkgs/nixos/modules/security/wrappers/default.nix
index 47738e7962e..a0fadb018ec 100644
--- a/nixpkgs/nixos/modules/security/wrappers/default.nix
+++ b/nixpkgs/nixos/modules/security/wrappers/default.nix
@@ -94,6 +94,10 @@ let
) programs;
in
{
+ imports = [
+ (lib.mkRemovedOptionModule [ "security" "setuidOwners" ] "Use security.wrappers instead")
+ (lib.mkRemovedOptionModule [ "security" "setuidPrograms" ] "Use security.wrappers instead")
+ ];
###### interface
diff --git a/nixpkgs/nixos/modules/services/admin/oxidized.nix b/nixpkgs/nixos/modules/services/admin/oxidized.nix
index da81be3f23e..94b44630ba6 100644
--- a/nixpkgs/nixos/modules/services/admin/oxidized.nix
+++ b/nixpkgs/nixos/modules/services/admin/oxidized.nix
@@ -111,6 +111,7 @@ in
Restart = "always";
WorkingDirectory = cfg.dataDir;
KillSignal = "SIGKILL";
+ PIDFile = "${cfg.dataDir}/.config/oxidized/pid";
};
};
};
diff --git a/nixpkgs/nixos/modules/services/audio/alsa.nix b/nixpkgs/nixos/modules/services/audio/alsa.nix
index f632644af09..990398e6546 100644
--- a/nixpkgs/nixos/modules/services/audio/alsa.nix
+++ b/nixpkgs/nixos/modules/services/audio/alsa.nix
@@ -12,6 +12,9 @@ let
in
{
+ imports = [
+ (mkRenamedOptionModule [ "sound" "enableMediaKeys" ] [ "sound" "mediaKeys" "enable" ])
+ ];
###### interface
diff --git a/nixpkgs/nixos/modules/services/audio/mpd.nix b/nixpkgs/nixos/modules/services/audio/mpd.nix
index 7932d094197..e20591b5beb 100644
--- a/nixpkgs/nixos/modules/services/audio/mpd.nix
+++ b/nixpkgs/nixos/modules/services/audio/mpd.nix
@@ -184,19 +184,19 @@ in {
};
};
- users.users = optionalAttrs (cfg.user == name) (singleton {
- inherit uid;
- inherit name;
- group = cfg.group;
- extraGroups = [ "audio" ];
- description = "Music Player Daemon user";
- home = "${cfg.dataDir}";
- });
-
- users.groups = optionalAttrs (cfg.group == name) (singleton {
- inherit name;
- gid = gid;
- });
+ users.users = optionalAttrs (cfg.user == name) {
+ ${name} = {
+ inherit uid;
+ group = cfg.group;
+ extraGroups = [ "audio" ];
+ description = "Music Player Daemon user";
+ home = "${cfg.dataDir}";
+ };
+ };
+
+ users.groups = optionalAttrs (cfg.group == name) {
+ ${name}.gid = gid;
+ };
};
}
diff --git a/nixpkgs/nixos/modules/services/backup/bacula.nix b/nixpkgs/nixos/modules/services/backup/bacula.nix
index 41bda7893a7..cef304734ae 100644
--- a/nixpkgs/nixos/modules/services/backup/bacula.nix
+++ b/nixpkgs/nixos/modules/services/backup/bacula.nix
@@ -44,7 +44,17 @@ let
Pid Directory = "/run";
${sd_cfg.extraStorageConfig}
}
-
+
+ ${concatStringsSep "\n" (mapAttrsToList (name: value: ''
+ Autochanger {
+ Name = "${name}";
+ Device = ${concatStringsSep ", " (map (a: "\"${a}\"") value.devices)};
+ Changer Device = "${value.changerDevice}";
+ Changer Command = "${value.changerCommand}";
+ ${value.extraAutochangerConfig}
+ }
+ '') sd_cfg.autochanger)}
+
${concatStringsSep "\n" (mapAttrsToList (name: value: ''
Device {
Name = "${name}";
@@ -103,7 +113,19 @@ let
password = mkOption {
# TODO: required?
description = ''
- Specifies the password that must be supplied for a Director to b
+ Specifies the password that must be supplied for the default Bacula
+ Console to be authorized. The same password must appear in the
+ Director resource of the Console configuration file. For added
+ security, the password is never passed across the network but instead
+ a challenge response hash code created with the password. This
+ directive is required. If you have either /dev/random or bc on your
+ machine, Bacula will generate a random password during the
+ configuration process, otherwise it will be left blank and you must
+ manually supply it.
+
+ The password is plain text. It is not generated through any special
+ process but as noted above, it is better to use random text for
+ security reasons.
'';
};
@@ -111,26 +133,133 @@ let
default = "no";
example = "yes";
description = ''
- If Monitor is set to no (default), this director will have full
+ If Monitor is set to <literal>no</literal>, this director will have
+ full access to this Storage daemon. If Monitor is set to
+ <literal>yes</literal>, this director will only be able to fetch the
+ current status of this Storage daemon.
+
+ Please note that if this director is being used by a Monitor, we
+ highly recommend to set this directive to yes to avoid serious
+ security problems.
+ '';
+ };
+ };
+ };
+
+ autochangerOptions = {...}:
+ {
+ options = {
+ changerDevice = mkOption {
+ description = ''
+ The specified name-string must be the generic SCSI device name of the
+ autochanger that corresponds to the normal read/write Archive Device
+ specified in the Device resource. This generic SCSI device name
+ should be specified if you have an autochanger or if you have a
+ standard tape drive and want to use the Alert Command (see below).
+ For example, on Linux systems, for an Archive Device name of
+ <literal>/dev/nst0</literal>, you would specify
+ <literal>/dev/sg0</literal> for the Changer Device name. Depending
+ on your exact configuration, and the number of autochangers or the
+ type of autochanger, what you specify here can vary. This directive
+ is optional. See the Using AutochangersAutochangersChapter chapter of
+ this manual for more details of using this and the following
+ autochanger directives.
+ '';
+ };
+
+ changerCommand = mkOption {
+ description = ''
+ The name-string specifies an external program to be called that will
+ automatically change volumes as required by Bacula. Normally, this
+ directive will be specified only in the AutoChanger resource, which
+ is then used for all devices. However, you may also specify the
+ different Changer Command in each Device resource. Most frequently,
+ you will specify the Bacula supplied mtx-changer script as follows:
+
+ <literal>"/path/mtx-changer %c %o %S %a %d"</literal>
+
+ and you will install the mtx on your system (found in the depkgs
+ release). An example of this command is in the default bacula-sd.conf
+ file. For more details on the substitution characters that may be
+ specified to configure your autochanger please see the
+ AutochangersAutochangersChapter chapter of this manual. For FreeBSD
+ users, you might want to see one of the several chio scripts in
+ examples/autochangers.
+ '';
+ default = "/etc/bacula/mtx-changer %c %o %S %a %d";
+ };
+
+ devices = mkOption {
+ description = ''
+ '';
+ };
+
+ extraAutochangerConfig = mkOption {
+ default = "";
+ description = ''
+ Extra configuration to be passed in Autochanger directive.
+ '';
+ example = ''
+
'';
};
};
};
+
deviceOptions = {...}:
{
options = {
archiveDevice = mkOption {
# TODO: required?
description = ''
- The specified name-string gives the system file name of the storage device managed by this storage daemon. This will usually be the device file name of a removable storage device (tape drive), for example " /dev/nst0" or "/dev/rmt/0mbn". For a DVD-writer, it will be for example /dev/hdc. It may also be a directory name if you are archiving to disk storage.
+ The specified name-string gives the system file name of the storage
+ device managed by this storage daemon. This will usually be the
+ device file name of a removable storage device (tape drive), for
+ example <literal>/dev/nst0</literal> or
+ <literal>/dev/rmt/0mbn</literal>. For a DVD-writer, it will be for
+ example <literal>/dev/hdc</literal>. It may also be a directory name
+ if you are archiving to disk storage. In this case, you must supply
+ the full absolute path to the directory. When specifying a tape
+ device, it is preferable that the "non-rewind" variant of the device
+ file name be given.
'';
};
mediaType = mkOption {
# TODO: required?
description = ''
- The specified name-string names the type of media supported by this device, for example, "DLT7000". Media type names are arbitrary in that you set them to anything you want, but they must be known to the volume database to keep track of which storage daemons can read which volumes. In general, each different storage type should have a unique Media Type associated with it. The same name-string must appear in the appropriate Storage resource definition in the Director's configuration file.
+ The specified name-string names the type of media supported by this
+ device, for example, <literal>DLT7000</literal>. Media type names are
+ arbitrary in that you set them to anything you want, but they must be
+ known to the volume database to keep track of which storage daemons
+ can read which volumes. In general, each different storage type
+ should have a unique Media Type associated with it. The same
+ name-string must appear in the appropriate Storage resource
+ definition in the Director's configuration file.
+
+ Even though the names you assign are arbitrary (i.e. you choose the
+ name you want), you should take care in specifying them because the
+ Media Type is used to determine which storage device Bacula will
+ select during restore. Thus you should probably use the same Media
+ Type specification for all drives where the Media can be freely
+ interchanged. This is not generally an issue if you have a single
+ Storage daemon, but it is with multiple Storage daemons, especially
+ if they have incompatible media.
+
+ For example, if you specify a Media Type of <literal>DDS-4</literal>
+ then during the restore, Bacula will be able to choose any Storage
+ Daemon that handles <literal>DDS-4</literal>. If you have an
+ autochanger, you might want to name the Media Type in a way that is
+ unique to the autochanger, unless you wish to possibly use the
+ Volumes in other drives. You should also ensure to have unique Media
+ Type names if the Media is not compatible between drives. This
+ specification is required for all devices.
+
+ In addition, if you are using disk storage, each Device resource will
+ generally have a different mount point or directory. In order for
+ Bacula to select the correct Device resource, each one must have a
+ unique Media Type.
'';
};
@@ -166,8 +295,8 @@ in {
default = "${config.networking.hostName}-fd";
description = ''
The client name that must be used by the Director when connecting.
- Generally, it is a good idea to use a name related to the machine
- so that error messages can be easily identified if you have multiple
+ Generally, it is a good idea to use a name related to the machine so
+ that error messages can be easily identified if you have multiple
Clients. This directive is required.
'';
};
@@ -232,7 +361,8 @@ in {
default = 9103;
type = types.int;
description = ''
- Specifies port number on which the Storage daemon listens for Director connections. The default is 9103.
+ Specifies port number on which the Storage daemon listens for
+ Director connections.
'';
};
@@ -251,7 +381,15 @@ in {
'';
type = with types; attrsOf (submodule deviceOptions);
};
-
+
+ autochanger = mkOption {
+ default = {};
+ description = ''
+ This option defines Autochanger resources in Bacula Storage Daemon.
+ '';
+ type = with types; attrsOf (submodule autochangerOptions);
+ };
+
extraStorageConfig = mkOption {
default = "";
description = ''
@@ -287,7 +425,8 @@ in {
name = mkOption {
default = "${config.networking.hostName}-dir";
description = ''
- The director name used by the system administrator. This directive is required.
+ The director name used by the system administrator. This directive is
+ required.
'';
};
@@ -295,7 +434,12 @@ in {
default = 9101;
type = types.int;
description = ''
- Specify the port (a positive integer) on which the Director daemon will listen for Bacula Console connections. This same port number must be specified in the Director resource of the Console configuration file. The default is 9101, so normally this directive need not be specified. This directive should not be used if you specify DirAddresses (N.B plural) directive.
+ Specify the port (a positive integer) on which the Director daemon
+ will listen for Bacula Console connections. This same port number
+ must be specified in the Director resource of the Console
+ configuration file. The default is 9101, so normally this directive
+ need not be specified. This directive should not be used if you
+ specify DirAddresses (N.B plural) directive.
'';
};
diff --git a/nixpkgs/nixos/modules/services/backup/borgbackup.nix b/nixpkgs/nixos/modules/services/backup/borgbackup.nix
index 10d42325a6b..a2eb80c55a8 100644
--- a/nixpkgs/nixos/modules/services/backup/borgbackup.nix
+++ b/nixpkgs/nixos/modules/services/backup/borgbackup.nix
@@ -68,7 +68,7 @@ let
{ BORG_PASSPHRASE = passphrase; }
else { };
- mkBackupService = name: cfg:
+ mkBackupService = name: cfg:
let
userHome = config.users.users.${cfg.user}.home;
in nameValuePair "borgbackup-job-${name}" {
@@ -98,6 +98,23 @@ let
inherit (cfg) startAt;
};
+ # utility function around makeWrapper
+ mkWrapperDrv = {
+ original, name, set ? {}
+ }:
+ pkgs.runCommandNoCC "${name}-wrapper" {
+ buildInputs = [ pkgs.makeWrapper ];
+ } (with lib; ''
+ makeWrapper "${original}" "$out/bin/${name}" \
+ ${concatStringsSep " \\\n " (mapAttrsToList (name: value: ''--set ${name} "${value}"'') set)}
+ '');
+
+ mkBorgWrapper = name: cfg: mkWrapperDrv {
+ original = "${pkgs.borgbackup}/bin/borg";
+ name = "borg-job-${name}";
+ set = { BORG_REPO = cfg.repo; } // (mkPassEnv cfg) // cfg.environment;
+ };
+
# Paths listed in ReadWritePaths must exist before service is started
mkActivationScript = name: cfg:
let
@@ -176,7 +193,11 @@ in {
###### interface
options.services.borgbackup.jobs = mkOption {
- description = "Deduplicating backups using BorgBackup.";
+ description = ''
+ Deduplicating backups using BorgBackup.
+ Adding a job will cause a borg-job-NAME wrapper to be added
+ to your system path, so that you can perform maintenance easily.
+ '';
default = { };
example = literalExample ''
{
@@ -623,6 +644,6 @@ in {
users = mkMerge (mapAttrsToList mkUsersConfig repos);
- environment.systemPackages = with pkgs; [ borgbackup ];
+ environment.systemPackages = with pkgs; [ borgbackup ] ++ (mapAttrsToList mkBorgWrapper jobs);
});
}
diff --git a/nixpkgs/nixos/modules/services/backup/mysql-backup.nix b/nixpkgs/nixos/modules/services/backup/mysql-backup.nix
index dbd5605143f..f58af82773f 100644
--- a/nixpkgs/nixos/modules/services/backup/mysql-backup.nix
+++ b/nixpkgs/nixos/modules/services/backup/mysql-backup.nix
@@ -84,13 +84,14 @@ in
};
config = mkIf cfg.enable {
- users.users = optionalAttrs (cfg.user == defaultUser) (singleton
- { name = defaultUser;
+ users.users = optionalAttrs (cfg.user == defaultUser) {
+ ${defaultUser} = {
isSystemUser = true;
createHome = false;
home = cfg.location;
group = "nogroup";
- });
+ };
+ };
services.mysql.ensureUsers = [{
name = cfg.user;
diff --git a/nixpkgs/nixos/modules/services/backup/postgresql-backup.nix b/nixpkgs/nixos/modules/services/backup/postgresql-backup.nix
index 13a36ae32ac..580c7ce68f1 100644
--- a/nixpkgs/nixos/modules/services/backup/postgresql-backup.nix
+++ b/nixpkgs/nixos/modules/services/backup/postgresql-backup.nix
@@ -35,6 +35,13 @@ let
in {
+ imports = [
+ (mkRemovedOptionModule [ "services" "postgresqlBackup" "period" ] ''
+ A systemd timer is now used instead of cron.
+ The starting time can be configured via <literal>services.postgresqlBackup.startAt</literal>.
+ '')
+ ];
+
options = {
services.postgresqlBackup = {
enable = mkOption {
@@ -82,7 +89,7 @@ in {
pgdumpOptions = mkOption {
type = types.separatedString " ";
- default = "-Cbo";
+ default = "-C";
description = ''
Command line options for pg_dump. This options is not used
if <literal>config.services.postgresqlBackup.backupAll</literal> is enabled.
diff --git a/nixpkgs/nixos/modules/services/backup/tarsnap.nix b/nixpkgs/nixos/modules/services/backup/tarsnap.nix
index 4fc7c24813a..6d99a1efb61 100644
--- a/nixpkgs/nixos/modules/services/backup/tarsnap.nix
+++ b/nixpkgs/nixos/modules/services/backup/tarsnap.nix
@@ -23,6 +23,10 @@ let
'';
in
{
+ imports = [
+ (mkRemovedOptionModule [ "services" "tarsnap" "cachedir" ] "Use services.tarsnap.archives.<name>.cachedir")
+ ];
+
options = {
services.tarsnap = {
enable = mkOption {
diff --git a/nixpkgs/nixos/modules/services/cluster/kubernetes/addons/dashboard.nix b/nixpkgs/nixos/modules/services/cluster/kubernetes/addons/dashboard.nix
index 70f96d75a46..2ed7742eda0 100644
--- a/nixpkgs/nixos/modules/services/cluster/kubernetes/addons/dashboard.nix
+++ b/nixpkgs/nixos/modules/services/cluster/kubernetes/addons/dashboard.nix
@@ -5,6 +5,10 @@ with lib;
let
cfg = config.services.kubernetes.addons.dashboard;
in {
+ imports = [
+ (mkRenamedOptionModule [ "services" "kubernetes" "addons" "dashboard" "enableRBAC" ] [ "services" "kubernetes" "addons" "dashboard" "rbac" "enable" ])
+ ];
+
options.services.kubernetes.addons.dashboard = {
enable = mkEnableOption "kubernetes dashboard addon";
diff --git a/nixpkgs/nixos/modules/services/cluster/kubernetes/apiserver.nix b/nixpkgs/nixos/modules/services/cluster/kubernetes/apiserver.nix
index 33796bf2e08..95bdb4c0d14 100644
--- a/nixpkgs/nixos/modules/services/cluster/kubernetes/apiserver.nix
+++ b/nixpkgs/nixos/modules/services/cluster/kubernetes/apiserver.nix
@@ -13,6 +13,18 @@ let
)) + ".1");
in
{
+
+ imports = [
+ (mkRenamedOptionModule [ "services" "kubernetes" "apiserver" "admissionControl" ] [ "services" "kubernetes" "apiserver" "enableAdmissionPlugins" ])
+ (mkRenamedOptionModule [ "services" "kubernetes" "apiserver" "address" ] ["services" "kubernetes" "apiserver" "bindAddress"])
+ (mkRenamedOptionModule [ "services" "kubernetes" "apiserver" "port" ] ["services" "kubernetes" "apiserver" "insecurePort"])
+ (mkRemovedOptionModule [ "services" "kubernetes" "apiserver" "publicAddress" ] "")
+ (mkRenamedOptionModule [ "services" "kubernetes" "etcd" "servers" ] [ "services" "kubernetes" "apiserver" "etcd" "servers" ])
+ (mkRenamedOptionModule [ "services" "kubernetes" "etcd" "keyFile" ] [ "services" "kubernetes" "apiserver" "etcd" "keyFile" ])
+ (mkRenamedOptionModule [ "services" "kubernetes" "etcd" "certFile" ] [ "services" "kubernetes" "apiserver" "etcd" "certFile" ])
+ (mkRenamedOptionModule [ "services" "kubernetes" "etcd" "caFile" ] [ "services" "kubernetes" "apiserver" "etcd" "caFile" ])
+ ];
+
###### interface
options.services.kubernetes.apiserver = with lib.types; {
diff --git a/nixpkgs/nixos/modules/services/cluster/kubernetes/controller-manager.nix b/nixpkgs/nixos/modules/services/cluster/kubernetes/controller-manager.nix
index 0b73d090f24..a99ef6640e9 100644
--- a/nixpkgs/nixos/modules/services/cluster/kubernetes/controller-manager.nix
+++ b/nixpkgs/nixos/modules/services/cluster/kubernetes/controller-manager.nix
@@ -7,6 +7,11 @@ let
cfg = top.controllerManager;
in
{
+ imports = [
+ (mkRenamedOptionModule [ "services" "kubernetes" "controllerManager" "address" ] ["services" "kubernetes" "controllerManager" "bindAddress"])
+ (mkRenamedOptionModule [ "services" "kubernetes" "controllerManager" "port" ] ["services" "kubernetes" "controllerManager" "insecurePort"])
+ ];
+
###### interface
options.services.kubernetes.controllerManager = with lib.types; {
diff --git a/nixpkgs/nixos/modules/services/cluster/kubernetes/default.nix b/nixpkgs/nixos/modules/services/cluster/kubernetes/default.nix
index 3790ac9b691..3a11a6513a4 100644
--- a/nixpkgs/nixos/modules/services/cluster/kubernetes/default.nix
+++ b/nixpkgs/nixos/modules/services/cluster/kubernetes/default.nix
@@ -74,6 +74,10 @@ let
};
in {
+ imports = [
+ (mkRemovedOptionModule [ "services" "kubernetes" "verbose" ] "")
+ ];
+
###### interface
options.services.kubernetes = {
@@ -262,8 +266,7 @@ in {
"d /var/lib/kubernetes 0755 kubernetes kubernetes -"
];
- users.users = singleton {
- name = "kubernetes";
+ users.users.kubernetes = {
uid = config.ids.uids.kubernetes;
description = "Kubernetes user";
extraGroups = [ "docker" ];
diff --git a/nixpkgs/nixos/modules/services/cluster/kubernetes/kubelet.nix b/nixpkgs/nixos/modules/services/cluster/kubernetes/kubelet.nix
index 62d893dfefc..c3d67552cc8 100644
--- a/nixpkgs/nixos/modules/services/cluster/kubernetes/kubelet.nix
+++ b/nixpkgs/nixos/modules/services/cluster/kubernetes/kubelet.nix
@@ -52,6 +52,12 @@ let
taints = concatMapStringsSep "," (v: "${v.key}=${v.value}:${v.effect}") (mapAttrsToList (n: v: v) cfg.taints);
in
{
+ imports = [
+ (mkRemovedOptionModule [ "services" "kubernetes" "kubelet" "applyManifests" ] "")
+ (mkRemovedOptionModule [ "services" "kubernetes" "kubelet" "cadvisorPort" ] "")
+ (mkRemovedOptionModule [ "services" "kubernetes" "kubelet" "allowPrivileged" ] "")
+ ];
+
###### interface
options.services.kubernetes.kubelet = with lib.types; {
diff --git a/nixpkgs/nixos/modules/services/cluster/kubernetes/proxy.nix b/nixpkgs/nixos/modules/services/cluster/kubernetes/proxy.nix
index 3943c908840..86d1dc2439b 100644
--- a/nixpkgs/nixos/modules/services/cluster/kubernetes/proxy.nix
+++ b/nixpkgs/nixos/modules/services/cluster/kubernetes/proxy.nix
@@ -7,6 +7,9 @@ let
cfg = top.proxy;
in
{
+ imports = [
+ (mkRenamedOptionModule [ "services" "kubernetes" "proxy" "address" ] ["services" "kubernetes" "proxy" "bindAddress"])
+ ];
###### interface
options.services.kubernetes.proxy = with lib.types; {
diff --git a/nixpkgs/nixos/modules/services/continuous-integration/buildbot/master.nix b/nixpkgs/nixos/modules/services/continuous-integration/buildbot/master.nix
index 9c615fbe885..326d2cbd82c 100644
--- a/nixpkgs/nixos/modules/services/continuous-integration/buildbot/master.nix
+++ b/nixpkgs/nixos/modules/services/continuous-integration/buildbot/master.nix
@@ -223,18 +223,19 @@ in {
config = mkIf cfg.enable {
users.groups = optional (cfg.group == "buildbot") {
- name = "buildbot";
+ buildbot = { };
};
- users.users = optional (cfg.user == "buildbot") {
- name = "buildbot";
- description = "Buildbot User.";
- isNormalUser = true;
- createHome = true;
- home = cfg.home;
- group = cfg.group;
- extraGroups = cfg.extraGroups;
- useDefaultShell = true;
+ users.users = optionalAttrs (cfg.user == "buildbot") {
+ buildbot = {
+ description = "Buildbot User.";
+ isNormalUser = true;
+ createHome = true;
+ home = cfg.home;
+ group = cfg.group;
+ extraGroups = cfg.extraGroups;
+ useDefaultShell = true;
+ };
};
systemd.services.buildbot-master = {
diff --git a/nixpkgs/nixos/modules/services/continuous-integration/buildbot/worker.nix b/nixpkgs/nixos/modules/services/continuous-integration/buildbot/worker.nix
index 49e04ca3622..7613692f0a3 100644
--- a/nixpkgs/nixos/modules/services/continuous-integration/buildbot/worker.nix
+++ b/nixpkgs/nixos/modules/services/continuous-integration/buildbot/worker.nix
@@ -137,18 +137,19 @@ in {
services.buildbot-worker.workerPassFile = mkDefault (pkgs.writeText "buildbot-worker-password" cfg.workerPass);
users.groups = optional (cfg.group == "bbworker") {
- name = "bbworker";
+ bbworker = { };
};
- users.users = optional (cfg.user == "bbworker") {
- name = "bbworker";
- description = "Buildbot Worker User.";
- isNormalUser = true;
- createHome = true;
- home = cfg.home;
- group = cfg.group;
- extraGroups = cfg.extraGroups;
- useDefaultShell = true;
+ users.users = optionalAttrs (cfg.user == "bbworker") {
+ bbworker = {
+ description = "Buildbot Worker User.";
+ isNormalUser = true;
+ createHome = true;
+ home = cfg.home;
+ group = cfg.group;
+ extraGroups = cfg.extraGroups;
+ useDefaultShell = true;
+ };
};
systemd.services.buildbot-worker = {
diff --git a/nixpkgs/nixos/modules/services/continuous-integration/gocd-agent/default.nix b/nixpkgs/nixos/modules/services/continuous-integration/gocd-agent/default.nix
index 8126f27c2b0..2e9e1c94857 100644
--- a/nixpkgs/nixos/modules/services/continuous-integration/gocd-agent/default.nix
+++ b/nixpkgs/nixos/modules/services/continuous-integration/gocd-agent/default.nix
@@ -135,20 +135,20 @@ in {
};
config = mkIf cfg.enable {
- users.groups = optional (cfg.group == "gocd-agent") {
- name = "gocd-agent";
- gid = config.ids.gids.gocd-agent;
+ users.groups = optionalAttrs (cfg.group == "gocd-agent") {
+ gocd-agent.gid = config.ids.gids.gocd-agent;
};
- users.users = optional (cfg.user == "gocd-agent") {
- name = "gocd-agent";
- description = "gocd-agent user";
- createHome = true;
- home = cfg.workDir;
- group = cfg.group;
- extraGroups = cfg.extraGroups;
- useDefaultShell = true;
- uid = config.ids.uids.gocd-agent;
+ users.users = optionalAttrs (cfg.user == "gocd-agent") {
+ gocd-agent = {
+ description = "gocd-agent user";
+ createHome = true;
+ home = cfg.workDir;
+ group = cfg.group;
+ extraGroups = cfg.extraGroups;
+ useDefaultShell = true;
+ uid = config.ids.uids.gocd-agent;
+ };
};
systemd.services.gocd-agent = {
diff --git a/nixpkgs/nixos/modules/services/continuous-integration/gocd-server/default.nix b/nixpkgs/nixos/modules/services/continuous-integration/gocd-server/default.nix
index 8f177da129e..4fa41ac49ed 100644
--- a/nixpkgs/nixos/modules/services/continuous-integration/gocd-server/default.nix
+++ b/nixpkgs/nixos/modules/services/continuous-integration/gocd-server/default.nix
@@ -143,20 +143,20 @@ in {
};
config = mkIf cfg.enable {
- users.groups = optional (cfg.group == "gocd-server") {
- name = "gocd-server";
- gid = config.ids.gids.gocd-server;
+ users.groups = optionalAttrs (cfg.group == "gocd-server") {
+ gocd-server.gid = config.ids.gids.gocd-server;
};
- users.users = optional (cfg.user == "gocd-server") {
- name = "gocd-server";
- description = "gocd-server user";
- createHome = true;
- home = cfg.workDir;
- group = cfg.group;
- extraGroups = cfg.extraGroups;
- useDefaultShell = true;
- uid = config.ids.uids.gocd-server;
+ users.users = optionalAttrs (cfg.user == "gocd-server") {
+ gocd-server = {
+ description = "gocd-server user";
+ createHome = true;
+ home = cfg.workDir;
+ group = cfg.group;
+ extraGroups = cfg.extraGroups;
+ useDefaultShell = true;
+ uid = config.ids.uids.gocd-server;
+ };
};
systemd.services.gocd-server = {
diff --git a/nixpkgs/nixos/modules/services/continuous-integration/jenkins/default.nix b/nixpkgs/nixos/modules/services/continuous-integration/jenkins/default.nix
index 0ec90671388..1477c471f8a 100644
--- a/nixpkgs/nixos/modules/services/continuous-integration/jenkins/default.nix
+++ b/nixpkgs/nixos/modules/services/continuous-integration/jenkins/default.nix
@@ -150,20 +150,20 @@ in {
pkgs.dejavu_fonts
];
- users.groups = optional (cfg.group == "jenkins") {
- name = "jenkins";
- gid = config.ids.gids.jenkins;
+ users.groups = optionalAttrs (cfg.group == "jenkins") {
+ jenkins.gid = config.ids.gids.jenkins;
};
- users.users = optional (cfg.user == "jenkins") {
- name = "jenkins";
- description = "jenkins user";
- createHome = true;
- home = cfg.home;
- group = cfg.group;
- extraGroups = cfg.extraGroups;
- useDefaultShell = true;
- uid = config.ids.uids.jenkins;
+ users.users = optionalAttrs (cfg.user == "jenkins") {
+ jenkins = {
+ description = "jenkins user";
+ createHome = true;
+ home = cfg.home;
+ group = cfg.group;
+ extraGroups = cfg.extraGroups;
+ useDefaultShell = true;
+ uid = config.ids.uids.jenkins;
+ };
};
systemd.services.jenkins = {
diff --git a/nixpkgs/nixos/modules/services/continuous-integration/jenkins/slave.nix b/nixpkgs/nixos/modules/services/continuous-integration/jenkins/slave.nix
index 92deabc3dd3..26368cb94e4 100644
--- a/nixpkgs/nixos/modules/services/continuous-integration/jenkins/slave.nix
+++ b/nixpkgs/nixos/modules/services/continuous-integration/jenkins/slave.nix
@@ -51,18 +51,18 @@ in {
config = mkIf (cfg.enable && !masterCfg.enable) {
users.groups = optional (cfg.group == "jenkins") {
- name = "jenkins";
- gid = config.ids.gids.jenkins;
+ jenkins.gid = config.ids.gids.jenkins;
};
- users.users = optional (cfg.user == "jenkins") {
- name = "jenkins";
- description = "jenkins user";
- createHome = true;
- home = cfg.home;
- group = cfg.group;
- useDefaultShell = true;
- uid = config.ids.uids.jenkins;
+ users.users = optionalAttrs (cfg.user == "jenkins") {
+ jenkins = {
+ description = "jenkins user";
+ createHome = true;
+ home = cfg.home;
+ group = cfg.group;
+ useDefaultShell = true;
+ uid = config.ids.uids.jenkins;
+ };
};
};
}
diff --git a/nixpkgs/nixos/modules/services/databases/4store-endpoint.nix b/nixpkgs/nixos/modules/services/databases/4store-endpoint.nix
deleted file mode 100644
index 59ed0e5f0af..00000000000
--- a/nixpkgs/nixos/modules/services/databases/4store-endpoint.nix
+++ /dev/null
@@ -1,74 +0,0 @@
-{ config, lib, pkgs, ... }:
-let
- cfg = config.services.fourStoreEndpoint;
- endpointUser = "fourstorehttp";
- run = "${pkgs.su}/bin/su -s ${pkgs.runtimeShell} ${endpointUser} -c";
-in
-with lib;
-{
-
- ###### interface
-
- options = {
-
- services.fourStoreEndpoint = {
-
- enable = mkOption {
- default = false;
- description = "Whether to enable 4Store SPARQL endpoint.";
- };
-
- database = mkOption {
- default = config.services.fourStore.database;
- description = "RDF database name to expose via the endpoint. Defaults to local 4Store database name.";
- };
-
- listenAddress = mkOption {
- default = null;
- description = "IP address to listen on.";
- };
-
- port = mkOption {
- default = 8080;
- description = "port to listen on.";
- };
-
- options = mkOption {
- default = "";
- description = "Extra CLI options to pass to 4Store's 4s-httpd process.";
- };
-
- };
-
- };
-
-
- ###### implementation
-
- config = mkIf cfg.enable {
-
- assertions = singleton
- { assertion = cfg.enable -> cfg.database != "";
- message = "Must specify 4Store database name";
- };
-
- users.users = singleton
- { name = endpointUser;
- uid = config.ids.uids.fourstorehttp;
- description = "4Store SPARQL endpoint user";
- };
-
- services.avahi.enable = true;
-
- systemd.services."4store-endpoint" = {
- after = [ "network.target" ];
- wantedBy = [ "multi-user.target" ];
-
- script = ''
- ${run} '${pkgs.rdf4store}/bin/4s-httpd -D ${cfg.options} ${if cfg.listenAddress!=null then "-H ${cfg.listenAddress}" else "" } -p ${toString cfg.port} ${cfg.database}'
- '';
- };
-
- };
-
-}
diff --git a/nixpkgs/nixos/modules/services/databases/4store.nix b/nixpkgs/nixos/modules/services/databases/4store.nix
deleted file mode 100644
index be4351c1c38..00000000000
--- a/nixpkgs/nixos/modules/services/databases/4store.nix
+++ /dev/null
@@ -1,72 +0,0 @@
-{ config, lib, pkgs, ... }:
-let
- cfg = config.services.fourStore;
- stateDir = "/var/lib/4store";
- fourStoreUser = "fourstore";
- run = "${pkgs.su}/bin/su -s ${pkgs.runtimeShell} ${fourStoreUser}";
-in
-with lib;
-{
-
- ###### interface
-
- options = {
-
- services.fourStore = {
-
- enable = mkOption {
- default = false;
- description = "Whether to enable 4Store RDF database server.";
- };
-
- database = mkOption {
- default = "";
- description = "RDF database name. If it doesn't exist, it will be created. Databases are stored in ${stateDir}.";
- };
-
- options = mkOption {
- default = "";
- description = "Extra CLI options to pass to 4Store.";
- };
-
- };
-
- };
-
-
- ###### implementation
-
- config = mkIf cfg.enable {
-
- assertions = singleton
- { assertion = cfg.enable -> cfg.database != "";
- message = "Must specify 4Store database name.";
- };
-
- users.users = singleton
- { name = fourStoreUser;
- uid = config.ids.uids.fourstore;
- description = "4Store database user";
- home = stateDir;
- };
-
- services.avahi.enable = true;
-
- systemd.services."4store" = {
- after = [ "network.target" ];
- wantedBy = [ "multi-user.target" ];
-
- preStart = ''
- mkdir -p ${stateDir}/
- chown ${fourStoreUser} ${stateDir}
- if ! test -e "${stateDir}/${cfg.database}"; then
- ${run} -c '${pkgs.rdf4store}/bin/4s-backend-setup ${cfg.database}'
- fi
- '';
-
- script = ''
- ${run} -c '${pkgs.rdf4store}/bin/4s-backend -D ${cfg.options} ${cfg.database}'
- '';
- };
- };
-}
diff --git a/nixpkgs/nixos/modules/services/databases/cockroachdb.nix b/nixpkgs/nixos/modules/services/databases/cockroachdb.nix
index 268fdcc819f..b6f94a4881a 100644
--- a/nixpkgs/nixos/modules/services/databases/cockroachdb.nix
+++ b/nixpkgs/nixos/modules/services/databases/cockroachdb.nix
@@ -171,17 +171,17 @@ in
environment.systemPackages = [ crdb ];
- users.users = optionalAttrs (cfg.user == "cockroachdb") (singleton
- { name = "cockroachdb";
+ users.users = optionalAttrs (cfg.user == "cockroachdb") {
+ cockroachdb = {
description = "CockroachDB Server User";
uid = config.ids.uids.cockroachdb;
group = cfg.group;
- });
+ };
+ };
- users.groups = optionalAttrs (cfg.group == "cockroachdb") (singleton
- { name = "cockroachdb";
- gid = config.ids.gids.cockroachdb;
- });
+ users.groups = optionalAttrs (cfg.group == "cockroachdb") {
+ cockroachdb.gid = config.ids.gids.cockroachdb;
+ };
networking.firewall.allowedTCPPorts = lib.optionals cfg.openPorts
[ cfg.http.port cfg.listen.port ];
diff --git a/nixpkgs/nixos/modules/services/databases/foundationdb.nix b/nixpkgs/nixos/modules/services/databases/foundationdb.nix
index 8f8d0da7c8d..18727acc7c7 100644
--- a/nixpkgs/nixos/modules/services/databases/foundationdb.nix
+++ b/nixpkgs/nixos/modules/services/databases/foundationdb.nix
@@ -341,17 +341,17 @@ in
environment.systemPackages = [ pkg ];
- users.users = optionalAttrs (cfg.user == "foundationdb") (singleton
- { name = "foundationdb";
+ users.users = optionalAttrs (cfg.user == "foundationdb") {
+ foundationdb = {
description = "FoundationDB User";
uid = config.ids.uids.foundationdb;
group = cfg.group;
- });
+ };
+ };
- users.groups = optionalAttrs (cfg.group == "foundationdb") (singleton
- { name = "foundationdb";
- gid = config.ids.gids.foundationdb;
- });
+ users.groups = optionalAttrs (cfg.group == "foundationdb") {
+ foundationdb.gid = config.ids.gids.foundationdb;
+ };
networking.firewall.allowedTCPPortRanges = mkIf cfg.openFirewall
[ { from = cfg.listenPortStart;
diff --git a/nixpkgs/nixos/modules/services/databases/influxdb.nix b/nixpkgs/nixos/modules/services/databases/influxdb.nix
index 2f176a03872..dd5d69b1147 100644
--- a/nixpkgs/nixos/modules/services/databases/influxdb.nix
+++ b/nixpkgs/nixos/modules/services/databases/influxdb.nix
@@ -182,15 +182,15 @@ in
'';
};
- users.users = optional (cfg.user == "influxdb") {
- name = "influxdb";
- uid = config.ids.uids.influxdb;
- description = "Influxdb daemon user";
+ users.users = optionalAttrs (cfg.user == "influxdb") {
+ influxdb = {
+ uid = config.ids.uids.influxdb;
+ description = "Influxdb daemon user";
+ };
};
- users.groups = optional (cfg.group == "influxdb") {
- name = "influxdb";
- gid = config.ids.gids.influxdb;
+ users.groups = optionalAttrs (cfg.group == "influxdb") {
+ influxdb.gid = config.ids.gids.influxdb;
};
};
diff --git a/nixpkgs/nixos/modules/services/databases/memcached.nix b/nixpkgs/nixos/modules/services/databases/memcached.nix
index d1dfdb41bf4..89ff957babf 100644
--- a/nixpkgs/nixos/modules/services/databases/memcached.nix
+++ b/nixpkgs/nixos/modules/services/databases/memcached.nix
@@ -64,10 +64,9 @@ in
config = mkIf config.services.memcached.enable {
- users.users = optional (cfg.user == "memcached") {
- name = "memcached";
- description = "Memcached server user";
- isSystemUser = true;
+ users.users = optionalAttrs (cfg.user == "memcached") {
+ memcached.description = "Memcached server user";
+ memcached.isSystemUser = true;
};
environment.systemPackages = [ memcached ];
diff --git a/nixpkgs/nixos/modules/services/databases/mysql.nix b/nixpkgs/nixos/modules/services/databases/mysql.nix
index 5549cfa5cf4..8d520b82fb5 100644
--- a/nixpkgs/nixos/modules/services/databases/mysql.nix
+++ b/nixpkgs/nixos/modules/services/databases/mysql.nix
@@ -24,6 +24,10 @@ let
in
{
+ imports = [
+ (mkRemovedOptionModule [ "services" "mysql" "pidDir" ] "Don't wait for pidfiles, describe dependencies through systemd")
+ (mkRemovedOptionModule [ "services" "mysql" "rootPassword" ] "Use socket authentication or set the password outside of the nix store.")
+ ];
###### interface
@@ -316,6 +320,8 @@ in
Type = if hasNotify then "notify" else "simple";
RuntimeDirectory = "mysqld";
RuntimeDirectoryMode = "0755";
+ Restart = "on-abort";
+ RestartSec = "5s";
# The last two environment variables are used for starting Galera clusters
ExecStart = "${mysql}/bin/mysqld --defaults-file=/etc/my.cnf ${mysqldOptions} $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION";
ExecStartPost =
diff --git a/nixpkgs/nixos/modules/services/databases/neo4j.nix b/nixpkgs/nixos/modules/services/databases/neo4j.nix
index 5533182c311..09b453e7584 100644
--- a/nixpkgs/nixos/modules/services/databases/neo4j.nix
+++ b/nixpkgs/nixos/modules/services/databases/neo4j.nix
@@ -103,6 +103,18 @@ let
in {
+ imports = [
+ (mkRenamedOptionModule [ "services" "neo4j" "host" ] [ "services" "neo4j" "defaultListenAddress" ])
+ (mkRenamedOptionModule [ "services" "neo4j" "listenAddress" ] [ "services" "neo4j" "defaultListenAddress" ])
+ (mkRenamedOptionModule [ "services" "neo4j" "enableBolt" ] [ "services" "neo4j" "bolt" "enable" ])
+ (mkRenamedOptionModule [ "services" "neo4j" "enableHttps" ] [ "services" "neo4j" "https" "enable" ])
+ (mkRenamedOptionModule [ "services" "neo4j" "certDir" ] [ "services" "neo4j" "directories" "certificates" ])
+ (mkRenamedOptionModule [ "services" "neo4j" "dataDir" ] [ "services" "neo4j" "directories" "home" ])
+ (mkRemovedOptionModule [ "services" "neo4j" "port" ] "Use services.neo4j.http.listenAddress instead.")
+ (mkRemovedOptionModule [ "services" "neo4j" "boltPort" ] "Use services.neo4j.bolt.listenAddress instead.")
+ (mkRemovedOptionModule [ "services" "neo4j" "httpsPort" ] "Use services.neo4j.https.listenAddress instead.")
+ ];
+
###### interface
options.services.neo4j = {
@@ -638,8 +650,7 @@ in {
environment.systemPackages = [ cfg.package ];
- users.users = singleton {
- name = "neo4j";
+ users.users.neo4j = {
uid = config.ids.uids.neo4j;
description = "Neo4j daemon user";
home = cfg.directories.home;
diff --git a/nixpkgs/nixos/modules/services/databases/postgresql.nix b/nixpkgs/nixos/modules/services/databases/postgresql.nix
index 3bedfe96a18..c8fdd89d0d8 100644
--- a/nixpkgs/nixos/modules/services/databases/postgresql.nix
+++ b/nixpkgs/nixos/modules/services/databases/postgresql.nix
@@ -339,9 +339,9 @@ in
'') cfg.ensureDatabases}
'' + ''
${concatMapStrings (user: ''
- $PSQL -tAc "SELECT 1 FROM pg_roles WHERE rolname='${user.name}'" | grep -q 1 || $PSQL -tAc "CREATE USER ${user.name}"
+ $PSQL -tAc "SELECT 1 FROM pg_roles WHERE rolname='${user.name}'" | grep -q 1 || $PSQL -tAc 'CREATE USER "${user.name}"'
${concatStringsSep "\n" (mapAttrsToList (database: permission: ''
- $PSQL -tAc 'GRANT ${permission} ON ${database} TO ${user.name}'
+ $PSQL -tAc 'GRANT ${permission} ON ${database} TO "${user.name}"'
'') user.ensurePermissions)}
'') cfg.ensureUsers}
'';
diff --git a/nixpkgs/nixos/modules/services/databases/redis.nix b/nixpkgs/nixos/modules/services/databases/redis.nix
index 95128a641d9..70895fa53e4 100644
--- a/nixpkgs/nixos/modules/services/databases/redis.nix
+++ b/nixpkgs/nixos/modules/services/databases/redis.nix
@@ -32,6 +32,13 @@ let
'';
in
{
+ imports = [
+ (mkRemovedOptionModule [ "services" "redis" "user" ] "The redis module now is hardcoded to the redis user.")
+ (mkRemovedOptionModule [ "services" "redis" "dbpath" ] "The redis module now uses /var/lib/redis as data directory.")
+ (mkRemovedOptionModule [ "services" "redis" "dbFilename" ] "The redis module now uses /var/lib/redis/dump.rdb as database dump location.")
+ (mkRemovedOptionModule [ "services" "redis" "appendOnlyFilename" ] "This option was never used.")
+ (mkRemovedOptionModule [ "services" "redis" "pidFile" ] "This option was removed.")
+ ];
###### interface
diff --git a/nixpkgs/nixos/modules/services/databases/virtuoso.nix b/nixpkgs/nixos/modules/services/databases/virtuoso.nix
index 6ffc44a5274..0cc027cb1d7 100644
--- a/nixpkgs/nixos/modules/services/databases/virtuoso.nix
+++ b/nixpkgs/nixos/modules/services/databases/virtuoso.nix
@@ -54,9 +54,8 @@ with lib;
config = mkIf cfg.enable {
- users.users = singleton
- { name = virtuosoUser;
- uid = config.ids.uids.virtuoso;
+ users.users.${virtuosoUser} =
+ { uid = config.ids.uids.virtuoso;
description = "virtuoso user";
home = stateDir;
};
diff --git a/nixpkgs/nixos/modules/services/desktops/pantheon/contractor.nix b/nixpkgs/nixos/modules/services/desktops/pantheon/contractor.nix
index 2638a21df73..c76145191a7 100644
--- a/nixpkgs/nixos/modules/services/desktops/pantheon/contractor.nix
+++ b/nixpkgs/nixos/modules/services/desktops/pantheon/contractor.nix
@@ -6,35 +6,12 @@ with lib;
{
- meta.maintainers = pkgs.pantheon.maintainers;
-
- ###### interface
-
- options = {
-
- services.pantheon.contractor = {
-
- enable = mkEnableOption "contractor, a desktop-wide extension service used by pantheon";
-
- };
-
- };
-
###### implementation
config = mkIf config.services.pantheon.contractor.enable {
- environment.systemPackages = with pkgs.pantheon; [
- contractor
- extra-elementary-contracts
- ];
-
- services.dbus.packages = [ pkgs.pantheon.contractor ];
-
- environment.pathsToLink = [
- "/share/contractor"
- ];
+
};
diff --git a/nixpkgs/nixos/modules/services/desktops/pantheon/files.nix b/nixpkgs/nixos/modules/services/desktops/pantheon/files.nix
index 577aad6c298..8cee9f42b62 100644
--- a/nixpkgs/nixos/modules/services/desktops/pantheon/files.nix
+++ b/nixpkgs/nixos/modules/services/desktops/pantheon/files.nix
@@ -6,33 +6,8 @@ with lib;
{
- meta.maintainers = pkgs.pantheon.maintainers;
-
- ###### interface
-
- options = {
-
- services.pantheon.files = {
-
- enable = mkEnableOption "pantheon files daemon";
-
- };
-
- };
-
-
- ###### implementation
-
- config = mkIf config.services.pantheon.files.enable {
-
- environment.systemPackages = [
- pkgs.pantheon.elementary-files
- ];
-
- services.dbus.packages = [
- pkgs.pantheon.elementary-files
- ];
-
- };
+ imports = [
+ (mkRemovedOptionModule [ "services" "pantheon" "files" "enable" ] "Use `environment.systemPackages [ pkgs.pantheon.elementary-files ];`")
+ ];
}
diff --git a/nixpkgs/nixos/modules/services/development/lorri.nix b/nixpkgs/nixos/modules/services/development/lorri.nix
index 68264ee869d..c843aa56d13 100644
--- a/nixpkgs/nixos/modules/services/development/lorri.nix
+++ b/nixpkgs/nixos/modules/services/development/lorri.nix
@@ -32,7 +32,7 @@ in {
description = "Lorri Daemon";
requires = [ "lorri.socket" ];
after = [ "lorri.socket" ];
- path = with pkgs; [ config.nix.package gnutar gzip ];
+ path = with pkgs; [ config.nix.package git gnutar gzip ];
serviceConfig = {
ExecStart = "${pkgs.lorri}/bin/lorri daemon";
PrivateTmp = true;
diff --git a/nixpkgs/nixos/modules/services/editors/infinoted.nix b/nixpkgs/nixos/modules/services/editors/infinoted.nix
index be366761694..8b997ccbf66 100644
--- a/nixpkgs/nixos/modules/services/editors/infinoted.nix
+++ b/nixpkgs/nixos/modules/services/editors/infinoted.nix
@@ -111,14 +111,15 @@ in {
};
config = mkIf (cfg.enable) {
- users.users = optional (cfg.user == "infinoted")
- { name = "infinoted";
- description = "Infinoted user";
- group = cfg.group;
- isSystemUser = true;
+ users.users = optionalAttrs (cfg.user == "infinoted")
+ { infinoted = {
+ description = "Infinoted user";
+ group = cfg.group;
+ isSystemUser = true;
+ };
};
- users.groups = optional (cfg.group == "infinoted")
- { name = "infinoted";
+ users.groups = optionalAttrs (cfg.group == "infinoted")
+ { infinoted = { };
};
systemd.services.infinoted =
diff --git a/nixpkgs/nixos/modules/services/hardware/bluetooth.nix b/nixpkgs/nixos/modules/services/hardware/bluetooth.nix
index 7b13beea1ca..dfa39e7f602 100644
--- a/nixpkgs/nixos/modules/services/hardware/bluetooth.nix
+++ b/nixpkgs/nixos/modules/services/hardware/bluetooth.nix
@@ -72,11 +72,11 @@ in {
};
};
- environment.systemPackages = [ bluez-bluetooth pkgs.openobex pkgs.obexftp ];
+ environment.systemPackages = [ bluez-bluetooth ];
- environment.etc = singleton {
- source = pkgs.writeText "main.conf" (generators.toINI { } cfg.config + optionalString (cfg.extraConfig != null) cfg.extraConfig);
- target = "bluetooth/main.conf";
+ environment.etc."bluetooth/main.conf"= {
+ source = pkgs.writeText "main.conf"
+ (generators.toINI { } cfg.config + optionalString (cfg.extraConfig != null) cfg.extraConfig);
};
services.udev.packages = [ bluez-bluetooth ];
diff --git a/nixpkgs/nixos/modules/services/hardware/sane_extra_backends/brscan4.nix b/nixpkgs/nixos/modules/services/hardware/sane_extra_backends/brscan4.nix
index f6ed4e25e9c..6f49a1ab6d4 100644
--- a/nixpkgs/nixos/modules/services/hardware/sane_extra_backends/brscan4.nix
+++ b/nixpkgs/nixos/modules/services/hardware/sane_extra_backends/brscan4.nix
@@ -67,11 +67,11 @@ in
{
options = {
- hardware.sane.brscan4.enable =
+ hardware.sane.brscan4.enable =
mkEnableOption "Brother's brscan4 scan backend" // {
description = ''
When enabled, will automatically register the "brscan4" sane
- backend and bring configuration files to their expected location.
+ backend and bring configuration files to their expected location.
'';
};
@@ -95,14 +95,11 @@ in
pkgs.brscan4
];
- environment.etc = singleton {
- target = "opt/brother/scanner/brscan4";
- source = "${etcFiles}/etc/opt/brother/scanner/brscan4";
- };
+ environment.etc."opt/brother/scanner/brscan4" =
+ { source = "${etcFiles}/etc/opt/brother/scanner/brscan4"; };
assertions = [
{ assertion = all (x: !(null != x.ip && null != x.nodename)) netDeviceList;
-
message = ''
When describing a network device as part of the attribute list
`hardware.sane.brscan4.netDevices`, only one of its `ip` or `nodename`
diff --git a/nixpkgs/nixos/modules/services/hardware/tcsd.nix b/nixpkgs/nixos/modules/services/hardware/tcsd.nix
index 3876280ee6b..68cb5d791aa 100644
--- a/nixpkgs/nixos/modules/services/hardware/tcsd.nix
+++ b/nixpkgs/nixos/modules/services/hardware/tcsd.nix
@@ -137,15 +137,15 @@ in
serviceConfig.ExecStart = "${pkgs.trousers}/sbin/tcsd -f -c ${tcsdConf}";
};
- users.users = optionalAttrs (cfg.user == "tss") (singleton
- { name = "tss";
+ users.users = optionalAttrs (cfg.user == "tss") {
+ tss = {
group = "tss";
uid = config.ids.uids.tss;
- });
+ };
+ };
- users.groups = optionalAttrs (cfg.group == "tss") (singleton
- { name = "tss";
- gid = config.ids.gids.tss;
- });
+ users.groups = optionalAttrs (cfg.group == "tss") {
+ tss.gid = config.ids.gids.tss;
+ };
};
}
diff --git a/nixpkgs/nixos/modules/services/hardware/tlp.nix b/nixpkgs/nixos/modules/services/hardware/tlp.nix
index adc1881a525..955a6067799 100644
--- a/nixpkgs/nixos/modules/services/hardware/tlp.nix
+++ b/nixpkgs/nixos/modules/services/hardware/tlp.nix
@@ -103,13 +103,14 @@ in
services.udev.packages = [ tlp ];
- environment.etc = [{ source = confFile;
- target = "default/tlp";
- }
- ] ++ optional enableRDW {
- source = "${tlp}/etc/NetworkManager/dispatcher.d/99tlp-rdw-nm";
- target = "NetworkManager/dispatcher.d/99tlp-rdw-nm";
- };
+ environment.etc =
+ {
+ "default/tlp".source = confFile;
+ } // optionalAttrs enableRDW {
+ "NetworkManager/dispatcher.d/99tlp-rdw-nm" = {
+ source = "${tlp}/etc/NetworkManager/dispatcher.d/99tlp-rdw-nm";
+ };
+ };
environment.systemPackages = [ tlp ];
diff --git a/nixpkgs/nixos/modules/services/hardware/udev.nix b/nixpkgs/nixos/modules/services/hardware/udev.nix
index 83ab93bd7cf..168056a475e 100644
--- a/nixpkgs/nixos/modules/services/hardware/udev.nix
+++ b/nixpkgs/nixos/modules/services/hardware/udev.nix
@@ -221,8 +221,8 @@ in
type = types.lines;
description = ''
Additional <command>hwdb</command> files. They'll be written
- into file <filename>10-local.hwdb</filename>. Thus they are
- read before all other files.
+ into file <filename>99-local.hwdb</filename>. Thus they are
+ read after all other files.
'';
};
@@ -281,13 +281,10 @@ in
boot.kernelParams = mkIf (!config.networking.usePredictableInterfaceNames) [ "net.ifnames=0" ];
environment.etc =
- [ { source = udevRules;
- target = "udev/rules.d";
- }
- { source = hwdbBin;
- target = "udev/hwdb.bin";
- }
- ];
+ {
+ "udev/rules.d".source = udevRules;
+ "udev/hwdb.bin".source = hwdbBin;
+ };
system.requiredKernelConfig = with config.lib.kernelConfig; [
(isEnabled "UNIX")
diff --git a/nixpkgs/nixos/modules/services/hardware/upower.nix b/nixpkgs/nixos/modules/services/hardware/upower.nix
index 5e7ac7a6e65..449810b5315 100644
--- a/nixpkgs/nixos/modules/services/hardware/upower.nix
+++ b/nixpkgs/nixos/modules/services/hardware/upower.nix
@@ -37,6 +37,172 @@ in
'';
};
+ enableWattsUpPro = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Enable the Watts Up Pro device.
+
+ The Watts Up Pro contains a generic FTDI USB device without a specific
+ vendor and product ID. When we probe for WUP devices, we can cause
+ the user to get a perplexing "Device or resource busy" error when
+ attempting to use their non-WUP device.
+
+ The generic FTDI device is known to also be used on:
+
+ <itemizedlist>
+ <listitem><para>Sparkfun FT232 breakout board</para></listitem>
+ <listitem><para>Parallax Propeller</para></listitem>
+ </itemizedlist>
+ '';
+ };
+
+ noPollBatteries = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Don't poll the kernel for battery level changes.
+
+ Some hardware will send us battery level changes through
+ events, rather than us having to poll for it. This option
+ allows disabling polling for hardware that sends out events.
+ '';
+ };
+
+ ignoreLid = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Do we ignore the lid state
+
+ Some laptops are broken. The lid state is either inverted, or stuck
+ on or off. We can't do much to fix these problems, but this is a way
+ for users to make the laptop panel vanish, a state that might be used
+ by a couple of user-space daemons. On Linux systems, see also
+ logind.conf(5).
+ '';
+ };
+
+ usePercentageForPolicy = mkOption {
+ type = types.bool;
+ default = true;
+ description = ''
+ Policy for warnings and action based on battery levels
+
+ Whether battery percentage based policy should be used. The default
+ is to use the percentage, which
+ should work around broken firmwares. It is also more reliable than
+ the time left (frantically saving all your files is going to use more
+ battery than letting it rest for example).
+ '';
+ };
+
+ percentageLow = mkOption {
+ type = types.ints.unsigned;
+ default = 10;
+ description = ''
+ When <literal>usePercentageForPolicy</literal> is
+ <literal>true</literal>, the levels at which UPower will consider the
+ battery low.
+
+ This will also be used for batteries which don't have time information
+ such as that of peripherals.
+
+ If any value (of <literal>percentageLow</literal>,
+ <literal>percentageCritical</literal> and
+ <literal>percentageAction</literal>) is invalid, or not in descending
+ order, the defaults will be used.
+ '';
+ };
+
+ percentageCritical = mkOption {
+ type = types.ints.unsigned;
+ default = 3;
+ description = ''
+ When <literal>usePercentageForPolicy</literal> is
+ <literal>true</literal>, the levels at which UPower will consider the
+ battery critical.
+
+ This will also be used for batteries which don't have time information
+ such as that of peripherals.
+
+ If any value (of <literal>percentageLow</literal>,
+ <literal>percentageCritical</literal> and
+ <literal>percentageAction</literal>) is invalid, or not in descending
+ order, the defaults will be used.
+ '';
+ };
+
+ percentageAction = mkOption {
+ type = types.ints.unsigned;
+ default = 2;
+ description = ''
+ When <literal>usePercentageForPolicy</literal> is
+ <literal>true</literal>, the levels at which UPower will take action
+ for the critical battery level.
+
+ This will also be used for batteries which don't have time information
+ such as that of peripherals.
+
+ If any value (of <literal>percentageLow</literal>,
+ <literal>percentageCritical</literal> and
+ <literal>percentageAction</literal>) is invalid, or not in descending
+ order, the defaults will be used.
+ '';
+ };
+
+ timeLow = mkOption {
+ type = types.ints.unsigned;
+ default = 1200;
+ description = ''
+ When <literal>usePercentageForPolicy</literal> is
+ <literal>false</literal>, the time remaining at which UPower will
+ consider the battery low.
+
+ If any value (of <literal>timeLow</literal>,
+ <literal>timeCritical</literal> and <literal>timeAction</literal>) is
+ invalid, or not in descending order, the defaults will be used.
+ '';
+ };
+
+ timeCritical = mkOption {
+ type = types.ints.unsigned;
+ default = 300;
+ description = ''
+ When <literal>usePercentageForPolicy</literal> is
+ <literal>false</literal>, the time remaining at which UPower will
+ consider the battery critical.
+
+ If any value (of <literal>timeLow</literal>,
+ <literal>timeCritical</literal> and <literal>timeAction</literal>) is
+ invalid, or not in descending order, the defaults will be used.
+ '';
+ };
+
+ timeAction = mkOption {
+ type = types.ints.unsigned;
+ default = 120;
+ description = ''
+ When <literal>usePercentageForPolicy</literal> is
+ <literal>false</literal>, the time remaining at which UPower will
+ take action for the critical battery level.
+
+ If any value (of <literal>timeLow</literal>,
+ <literal>timeCritical</literal> and <literal>timeAction</literal>) is
+ invalid, or not in descending order, the defaults will be used.
+ '';
+ };
+
+ criticalPowerAction = mkOption {
+ type = types.enum [ "PowerOff" "Hibernate" "HybridSleep" ];
+ default = "HybridSleep";
+ description = ''
+ The action to take when <literal>timeAction</literal> or
+ <literal>percentageAction</literal> has been reached for the batteries
+ (UPS or laptop batteries) supplying the computer
+ '';
+ };
+
};
};
@@ -54,6 +220,21 @@ in
systemd.packages = [ cfg.package ];
+ environment.etc."UPower/UPower.conf".text = generators.toINI {} {
+ UPower = {
+ EnableWattsUpPro = cfg.enableWattsUpPro;
+ NoPollBatteries = cfg.noPollBatteries;
+ IgnoreLid = cfg.ignoreLid;
+ UsePercentageForPolicy = cfg.usePercentageForPolicy;
+ PercentageLow = cfg.percentageLow;
+ PercentageCritical = cfg.percentageCritical;
+ PercentageAction = cfg.percentageAction;
+ TimeLow = cfg.timeLow;
+ TimeCritical = cfg.timeCritical;
+ TimeAction = cfg.timeAction;
+ CriticalPowerAction = cfg.criticalPowerAction;
+ };
+ };
};
}
diff --git a/nixpkgs/nixos/modules/services/hardware/usbmuxd.nix b/nixpkgs/nixos/modules/services/hardware/usbmuxd.nix
index 39bbcaf4627..50b931dcb48 100644
--- a/nixpkgs/nixos/modules/services/hardware/usbmuxd.nix
+++ b/nixpkgs/nixos/modules/services/hardware/usbmuxd.nix
@@ -43,15 +43,16 @@ in
config = mkIf cfg.enable {
- users.users = optional (cfg.user == defaultUserGroup) {
- name = cfg.user;
- description = "usbmuxd user";
- group = cfg.group;
- isSystemUser = true;
+ users.users = optionalAttrs (cfg.user == defaultUserGroup) {
+ ${cfg.user} = {
+ description = "usbmuxd user";
+ group = cfg.group;
+ isSystemUser = true;
+ };
};
users.groups = optional (cfg.group == defaultUserGroup) {
- name = cfg.group;
+ ${cfg.group} = { };
};
# Give usbmuxd permission for Apple devices
diff --git a/nixpkgs/nixos/modules/services/logging/awstats.nix b/nixpkgs/nixos/modules/services/logging/awstats.nix
index a92ff3bee49..5939d7808f7 100644
--- a/nixpkgs/nixos/modules/services/logging/awstats.nix
+++ b/nixpkgs/nixos/modules/services/logging/awstats.nix
@@ -4,31 +4,117 @@ with lib;
let
cfg = config.services.awstats;
- httpd = config.services.httpd;
package = pkgs.awstats;
-in
+ configOpts = {name, config, ...}: {
+ options = {
+ type = mkOption{
+ type = types.enum [ "mail" "web" ];
+ default = "web";
+ example = "mail";
+ description = ''
+ The type of log being collected.
+ '';
+ };
+ domain = mkOption {
+ type = types.str;
+ default = name;
+ description = "The domain name to collect stats for.";
+ example = "example.com";
+ };
+
+ logFile = mkOption {
+ type = types.str;
+ example = "/var/spool/nginx/logs/access.log";
+ description = ''
+ The log file to be scanned.
+ For mail, set this to
+ <literal>
+ journalctl $OLD_CURSOR -u postfix.service | ''${pkgs.perl}/bin/perl ''${pkgs.awstats.out}/share/awstats/tools/maillogconvert.pl standard |
+ </literal>
+ '';
+ };
+
+ logFormat = mkOption {
+ type = types.str;
+ default = "1";
+ description = ''
+ The log format being used.
+
+ For mail, set this to
+ <literal>
+ %time2 %email %email_r %host %host_r %method %url %code %bytesd
+ </literal>
+ '';
+ };
+
+ hostAliases = mkOption {
+ type = types.listOf types.str;
+ default = [];
+ example = "[ \"www.example.org\" ]";
+ description = ''
+ List of aliases the site has.
+ '';
+ };
+
+ extraConfig = mkOption {
+ type = types.attrsOf types.str;
+ default = {};
+ example = literalExample ''
+ {
+ "ValidHTTPCodes" = "404";
+ }
+ '';
+ description = "Extra configuration to be appendend to awstats.\${name}.conf.";
+ };
+
+ webService = {
+ enable = mkEnableOption "awstats web service";
+
+ hostname = mkOption {
+ type = types.str;
+ default = config.domain;
+ description = "The hostname the web service appears under.";
+ };
+
+ urlPrefix = mkOption {
+ type = types.str;
+ default = "/awstats";
+ description = "The URL prefix under which the awstats pages appear.";
+ };
+ };
+ };
+ };
+ webServices = filterAttrs (name: value: value.webService.enable) cfg.configs;
+in
{
+ imports = [
+ (mkRemovedOptionModule [ "services" "awstats" "service" "enable" ] "Please enable per domain with `services.awstats.configs.<name>.webService.enable`")
+ (mkRemovedOptionModule [ "services" "awstats" "service" "urlPrefix" ] "Please set per domain with `services.awstats.configs.<name>.webService.urlPrefix`")
+ (mkRenamedOptionModule [ "services" "awstats" "vardir" ] [ "services" "awstats" "dataDir" ])
+ ];
+
options.services.awstats = {
- enable = mkOption {
- type = types.bool;
- default = cfg.service.enable;
- description = ''
- Enable the awstats program (but not service).
- Currently only simple httpd (Apache) configs are supported,
- and awstats plugins may not work correctly.
- '';
- };
- vardir = mkOption {
+ enable = mkEnableOption "awstats";
+
+ dataDir = mkOption {
type = types.path;
default = "/var/lib/awstats";
- description = "The directory where variable awstats data will be stored.";
+ description = "The directory where awstats data will be stored.";
};
- extraConfig = mkOption {
- type = types.lines;
- default = "";
- description = "Extra configuration to be appendend to awstats.conf.";
+ configs = mkOption {
+ type = types.attrsOf (types.submodule configOpts);
+ default = {};
+ example = literalExample ''
+ {
+ "mysite" = {
+ domain = "example.com";
+ logFile = "/var/spool/nginx/logs/access.log";
+ };
+ }
+ '';
+ description = "Attribute set of domains to collect stats for.";
};
updateAt = mkOption {
@@ -42,75 +128,129 @@ in
<manvolnum>7</manvolnum></citerefentry>)
'';
};
-
- service = {
- enable = mkOption {
- type = types.bool;
- default = false;
- description = ''Enable the awstats web service. This switches on httpd.'';
- };
- urlPrefix = mkOption {
- type = types.str;
- default = "/awstats";
- description = "The URL prefix under which the awstats service appears.";
- };
- };
};
config = mkIf cfg.enable {
environment.systemPackages = [ package.bin ];
- /* TODO:
- - heed config.services.httpd.logPerVirtualHost, etc.
- - Can't AllowToUpdateStatsFromBrowser, as CGI scripts don't have permission
- to read the logs, and our httpd config apparently doesn't an option for that.
- */
- environment.etc."awstats/awstats.conf".source = pkgs.runCommand "awstats.conf"
+
+ environment.etc = mapAttrs' (name: opts:
+ nameValuePair "awstats/awstats.${name}.conf" {
+ source = pkgs.runCommand "awstats.${name}.conf"
{ preferLocalBuild = true; }
- ( let
- logFormat =
- if httpd.logFormat == "combined" then "1" else
- if httpd.logFormat == "common" then "4" else
- throw "awstats service doesn't support Apache log format `${httpd.logFormat}`";
- in
- ''
- sed \
- -e 's|^\(DirData\)=.*$|\1="${cfg.vardir}"|' \
- -e 's|^\(DirIcons\)=.*$|\1="icons"|' \
- -e 's|^\(CreateDirDataIfNotExists\)=.*$|\1=1|' \
- -e 's|^\(SiteDomain\)=.*$|\1="${httpd.hostName}"|' \
- -e 's|^\(LogFile\)=.*$|\1="${httpd.logDir}/access_log"|' \
- -e 's|^\(LogFormat\)=.*$|\1=${logFormat}|' \
- < '${package.out}/wwwroot/cgi-bin/awstats.model.conf' > "$out"
- echo '${cfg.extraConfig}' >> "$out"
- '');
-
- systemd.tmpfiles.rules = optionals cfg.service.enable [
- "d '${cfg.vardir}' - ${httpd.user} ${httpd.group} - -"
- "Z '${cfg.vardir}' - ${httpd.user} ${httpd.group} - -"
- ];
-
- # The httpd sub-service showing awstats.
- services.httpd = optionalAttrs cfg.service.enable {
- enable = true;
- extraConfig = ''
- Alias ${cfg.service.urlPrefix}/classes "${package.out}/wwwroot/classes/"
- Alias ${cfg.service.urlPrefix}/css "${package.out}/wwwroot/css/"
- Alias ${cfg.service.urlPrefix}/icons "${package.out}/wwwroot/icon/"
- ScriptAlias ${cfg.service.urlPrefix}/ "${package.out}/wwwroot/cgi-bin/"
-
- <Directory "${package.out}/wwwroot">
- Options None
- Require all granted
- </Directory>
- '';
- };
+ (''
+ sed \
+ ''
+ # set up mail stats
+ + optionalString (opts.type == "mail")
+ ''
+ -e 's|^\(LogType\)=.*$|\1=M|' \
+ -e 's|^\(LevelForBrowsersDetection\)=.*$|\1=0|' \
+ -e 's|^\(LevelForOSDetection\)=.*$|\1=0|' \
+ -e 's|^\(LevelForRefererAnalyze\)=.*$|\1=0|' \
+ -e 's|^\(LevelForRobotsDetection\)=.*$|\1=0|' \
+ -e 's|^\(LevelForSearchEnginesDetection\)=.*$|\1=0|' \
+ -e 's|^\(LevelForFileTypesDetection\)=.*$|\1=0|' \
+ -e 's|^\(LevelForWormsDetection\)=.*$|\1=0|' \
+ -e 's|^\(ShowMenu\)=.*$|\1=1|' \
+ -e 's|^\(ShowSummary\)=.*$|\1=HB|' \
+ -e 's|^\(ShowMonthStats\)=.*$|\1=HB|' \
+ -e 's|^\(ShowDaysOfMonthStats\)=.*$|\1=HB|' \
+ -e 's|^\(ShowDaysOfWeekStats\)=.*$|\1=HB|' \
+ -e 's|^\(ShowHoursStats\)=.*$|\1=HB|' \
+ -e 's|^\(ShowDomainsStats\)=.*$|\1=0|' \
+ -e 's|^\(ShowHostsStats\)=.*$|\1=HB|' \
+ -e 's|^\(ShowAuthenticatedUsers\)=.*$|\1=0|' \
+ -e 's|^\(ShowRobotsStats\)=.*$|\1=0|' \
+ -e 's|^\(ShowEMailSenders\)=.*$|\1=HBML|' \
+ -e 's|^\(ShowEMailReceivers\)=.*$|\1=HBML|' \
+ -e 's|^\(ShowSessionsStats\)=.*$|\1=0|' \
+ -e 's|^\(ShowPagesStats\)=.*$|\1=0|' \
+ -e 's|^\(ShowFileTypesStats\)=.*$|\1=0|' \
+ -e 's|^\(ShowFileSizesStats\)=.*$|\1=0|' \
+ -e 's|^\(ShowBrowsersStats\)=.*$|\1=0|' \
+ -e 's|^\(ShowOSStats\)=.*$|\1=0|' \
+ -e 's|^\(ShowOriginStats\)=.*$|\1=0|' \
+ -e 's|^\(ShowKeyphrasesStats\)=.*$|\1=0|' \
+ -e 's|^\(ShowKeywordsStats\)=.*$|\1=0|' \
+ -e 's|^\(ShowMiscStats\)=.*$|\1=0|' \
+ -e 's|^\(ShowHTTPErrorsStats\)=.*$|\1=0|' \
+ -e 's|^\(ShowSMTPErrorsStats\)=.*$|\1=1|' \
+ ''
+ +
+ # common options
+ ''
+ -e 's|^\(DirData\)=.*$|\1="${cfg.dataDir}/${name}"|' \
+ -e 's|^\(DirIcons\)=.*$|\1="icons"|' \
+ -e 's|^\(CreateDirDataIfNotExists\)=.*$|\1=1|' \
+ -e 's|^\(SiteDomain\)=.*$|\1="${name}"|' \
+ -e 's|^\(LogFile\)=.*$|\1="${opts.logFile}"|' \
+ -e 's|^\(LogFormat\)=.*$|\1="${opts.logFormat}"|' \
+ ''
+ +
+ # extra config
+ concatStringsSep "\n" (mapAttrsToList (n: v: ''
+ -e 's|^\(${n}\)=.*$|\1="${v}"|' \
+ '') opts.extraConfig)
+ +
+ ''
+ < '${package.out}/wwwroot/cgi-bin/awstats.model.conf' > "$out"
+ '');
+ }) cfg.configs;
- systemd.services.awstats-update = mkIf (cfg.updateAt != null) {
- description = "awstats log collector";
- script = "exec '${package.bin}/bin/awstats' -update -config=awstats.conf";
- startAt = cfg.updateAt;
- };
+ # create data directory with the correct permissions
+ systemd.tmpfiles.rules =
+ [ "d '${cfg.dataDir}' 755 root root - -" ] ++
+ mapAttrsToList (name: opts: "d '${cfg.dataDir}/${name}' 755 root root - -") cfg.configs ++
+ [ "Z '${cfg.dataDir}' 755 root root - -" ];
+
+ # nginx options
+ services.nginx.virtualHosts = mapAttrs'(name: opts: {
+ name = opts.webService.hostname;
+ value = {
+ locations = {
+ "${opts.webService.urlPrefix}/css/" = {
+ alias = "${package.out}/wwwroot/css/";
+ };
+ "${opts.webService.urlPrefix}/icons/" = {
+ alias = "${package.out}/wwwroot/icon/";
+ };
+ "${opts.webService.urlPrefix}/" = {
+ alias = "${cfg.dataDir}/${name}/";
+ extraConfig = ''
+ autoindex on;
+ '';
+ };
+ };
+ };
+ }) webServices;
+
+ # update awstats
+ systemd.services = mkIf (cfg.updateAt != null) (mapAttrs' (name: opts:
+ nameValuePair "awstats-${name}-update" {
+ description = "update awstats for ${name}";
+ script = optionalString (opts.type == "mail")
+ ''
+ if [[ -f "${cfg.dataDir}/${name}-cursor" ]]; then
+ CURSOR="$(cat "${cfg.dataDir}/${name}-cursor" | tr -d '\n')"
+ if [[ -n "$CURSOR" ]]; then
+ echo "Using cursor: $CURSOR"
+ export OLD_CURSOR="--cursor $CURSOR"
+ fi
+ fi
+ NEW_CURSOR="$(journalctl $OLD_CURSOR -u postfix.service --show-cursor | tail -n 1 | tr -d '\n' | sed -e 's#^-- cursor: \(.*\)#\1#')"
+ echo "New cursor: $NEW_CURSOR"
+ ${package.bin}/bin/awstats -update -config=${name}
+ if [ -n "$NEW_CURSOR" ]; then
+ echo -n "$NEW_CURSOR" > ${cfg.dataDir}/${name}-cursor
+ fi
+ '' + ''
+ ${package.out}/share/awstats/tools/awstats_buildstaticpages.pl \
+ -config=${name} -update -dir=${cfg.dataDir}/${name} \
+ -awstatsprog=${package.bin}/bin/awstats
+ '';
+ startAt = cfg.updateAt;
+ }) cfg.configs);
};
}
diff --git a/nixpkgs/nixos/modules/services/logging/logcheck.nix b/nixpkgs/nixos/modules/services/logging/logcheck.nix
index 6d8be5b926d..4296b2270c2 100644
--- a/nixpkgs/nixos/modules/services/logging/logcheck.nix
+++ b/nixpkgs/nixos/modules/services/logging/logcheck.nix
@@ -213,13 +213,14 @@ in
mapAttrsToList writeIgnoreRule cfg.ignore
++ mapAttrsToList writeIgnoreCronRule cfg.ignoreCron;
- users.users = optionalAttrs (cfg.user == "logcheck") (singleton
- { name = "logcheck";
+ users.users = optionalAttrs (cfg.user == "logcheck") {
+ logcheck = {
uid = config.ids.uids.logcheck;
shell = "/bin/sh";
description = "Logcheck user account";
extraGroups = cfg.extraGroups;
- });
+ };
+ };
system.activationScripts.logcheck = ''
mkdir -m 700 -p /var/{lib,lock}/logcheck
diff --git a/nixpkgs/nixos/modules/services/logging/logstash.nix b/nixpkgs/nixos/modules/services/logging/logstash.nix
index 4943e8d7db3..21a83803fd8 100644
--- a/nixpkgs/nixos/modules/services/logging/logstash.nix
+++ b/nixpkgs/nixos/modules/services/logging/logstash.nix
@@ -37,6 +37,11 @@ let
in
{
+ imports = [
+ (mkRenamedOptionModule [ "services" "logstash" "address" ] [ "services" "logstash" "listenAddress" ])
+ (mkRemovedOptionModule [ "services" "logstash" "enableWeb" ] "The web interface was removed from logstash")
+ ];
+
###### interface
options = {
diff --git a/nixpkgs/nixos/modules/services/logging/syslog-ng.nix b/nixpkgs/nixos/modules/services/logging/syslog-ng.nix
index 65e103ac2ba..35055311680 100644
--- a/nixpkgs/nixos/modules/services/logging/syslog-ng.nix
+++ b/nixpkgs/nixos/modules/services/logging/syslog-ng.nix
@@ -25,6 +25,10 @@ let
];
in {
+ imports = [
+ (mkRemovedOptionModule [ "services" "syslog-ng" "serviceName" ] "")
+ (mkRemovedOptionModule [ "services" "syslog-ng" "listenToJournal" ] "")
+ ];
options = {
diff --git a/nixpkgs/nixos/modules/services/mail/dovecot.nix b/nixpkgs/nixos/modules/services/mail/dovecot.nix
index 3fd06812c67..b5ed2c594f7 100644
--- a/nixpkgs/nixos/modules/services/mail/dovecot.nix
+++ b/nixpkgs/nixos/modules/services/mail/dovecot.nix
@@ -86,7 +86,7 @@ let
}
plugin {
- quota_rule = *:storage=${cfg.quotaGlobalPerUser}
+ quota_rule = *:storage=${cfg.quotaGlobalPerUser}
quota = maildir:User quota # per virtual mail user quota # BUG/FIXME broken, we couldn't get this working
quota_status_success = DUNNO
quota_status_nouser = DUNNO
@@ -133,6 +133,9 @@ let
};
in
{
+ imports = [
+ (mkRemovedOptionModule [ "services" "dovecot2" "package" ] "")
+ ];
options.services.dovecot2 = {
enable = mkEnableOption "Dovecot 2.x POP3/IMAP server";
@@ -307,36 +310,32 @@ in
++ optional cfg.enablePop3 "pop3"
++ optional cfg.enableLmtp "lmtp";
- users.users = [
- { name = "dovenull";
- uid = config.ids.uids.dovenull2;
- description = "Dovecot user for untrusted logins";
- group = "dovenull";
- }
- ] ++ optional (cfg.user == "dovecot2")
- { name = "dovecot2";
- uid = config.ids.uids.dovecot2;
+ users.users = {
+ dovenull =
+ { uid = config.ids.uids.dovenull2;
+ description = "Dovecot user for untrusted logins";
+ group = "dovenull";
+ };
+ } // optionalAttrs (cfg.user == "dovecot2") {
+ dovecot2 =
+ { uid = config.ids.uids.dovecot2;
description = "Dovecot user";
group = cfg.group;
- }
- ++ optional (cfg.createMailUser && cfg.mailUser != null)
- ({ name = cfg.mailUser;
- description = "Virtual Mail User";
- } // optionalAttrs (cfg.mailGroup != null) {
- group = cfg.mailGroup;
- });
-
- users.groups = optional (cfg.group == "dovecot2")
- { name = "dovecot2";
- gid = config.ids.gids.dovecot2;
- }
- ++ optional (cfg.createMailUser && cfg.mailGroup != null)
- { name = cfg.mailGroup;
- }
- ++ singleton
- { name = "dovenull";
- gid = config.ids.gids.dovenull2;
- };
+ };
+ } // optionalAttrs (cfg.createMailUser && cfg.mailUser != null) {
+ ${cfg.mailUser} =
+ { description = "Virtual Mail User"; } //
+ optionalAttrs (cfg.mailGroup != null)
+ { group = cfg.mailGroup; };
+ };
+
+ users.groups = {
+ dovenull.gid = config.ids.gids.dovenull2;
+ } // optionalAttrs (cfg.group == "dovecot2") {
+ dovecot2.gid = config.ids.gids.dovecot2;
+ } // optionalAttrs (cfg.createMailUser && cfg.mailGroup != null) {
+ ${cfg.mailGroup} = { };
+ };
environment.etc."dovecot/modules".source = modulesDir;
environment.etc."dovecot/dovecot.conf".source = cfg.configFile;
diff --git a/nixpkgs/nixos/modules/services/mail/dspam.nix b/nixpkgs/nixos/modules/services/mail/dspam.nix
index 72b8c4c08b9..766ebc8095a 100644
--- a/nixpkgs/nixos/modules/services/mail/dspam.nix
+++ b/nixpkgs/nixos/modules/services/mail/dspam.nix
@@ -86,16 +86,16 @@ in {
config = mkIf cfg.enable (mkMerge [
{
- users.users = optionalAttrs (cfg.user == "dspam") (singleton
- { name = "dspam";
+ users.users = optionalAttrs (cfg.user == "dspam") {
+ dspam = {
group = cfg.group;
uid = config.ids.uids.dspam;
- });
+ };
+ };
- users.groups = optionalAttrs (cfg.group == "dspam") (singleton
- { name = "dspam";
- gid = config.ids.gids.dspam;
- });
+ users.groups = optionalAttrs (cfg.group == "dspam") {
+ dspam.gid = config.ids.gids.dspam;
+ };
environment.systemPackages = [ dspam ];
diff --git a/nixpkgs/nixos/modules/services/mail/exim.nix b/nixpkgs/nixos/modules/services/mail/exim.nix
index 47812dd1e40..892fbd33214 100644
--- a/nixpkgs/nixos/modules/services/mail/exim.nix
+++ b/nixpkgs/nixos/modules/services/mail/exim.nix
@@ -87,15 +87,13 @@ in
systemPackages = [ cfg.package ];
};
- users.users = singleton {
- name = cfg.user;
+ users.users.${cfg.user} = {
description = "Exim mail transfer agent user";
uid = config.ids.uids.exim;
group = cfg.group;
};
- users.groups = singleton {
- name = cfg.group;
+ users.groups.${cfg.group} = {
gid = config.ids.gids.exim;
};
diff --git a/nixpkgs/nixos/modules/services/mail/mlmmj.nix b/nixpkgs/nixos/modules/services/mail/mlmmj.nix
index 7ae00f3e501..d58d93c4214 100644
--- a/nixpkgs/nixos/modules/services/mail/mlmmj.nix
+++ b/nixpkgs/nixos/modules/services/mail/mlmmj.nix
@@ -94,8 +94,7 @@ in
config = mkIf cfg.enable {
- users.users = singleton {
- name = cfg.user;
+ users.users.${cfg.user} = {
description = "mlmmj user";
home = stateDir;
createHome = true;
@@ -104,8 +103,7 @@ in
useDefaultShell = true;
};
- users.groups = singleton {
- name = cfg.group;
+ users.groups.${cfg.group} = {
gid = config.ids.gids.mlmmj;
};
diff --git a/nixpkgs/nixos/modules/services/mail/nullmailer.nix b/nixpkgs/nixos/modules/services/mail/nullmailer.nix
index 2c2910e0aa9..fe3f8ef9b39 100644
--- a/nixpkgs/nixos/modules/services/mail/nullmailer.nix
+++ b/nixpkgs/nixos/modules/services/mail/nullmailer.nix
@@ -201,15 +201,12 @@ with lib;
};
users = {
- users = singleton {
- name = cfg.user;
+ users.${cfg.user} = {
description = "Nullmailer relay-only mta user";
group = cfg.group;
};
- groups = singleton {
- name = cfg.group;
- };
+ groups.${cfg.group} = { };
};
systemd.tmpfiles.rules = [
diff --git a/nixpkgs/nixos/modules/services/mail/opendkim.nix b/nixpkgs/nixos/modules/services/mail/opendkim.nix
index 253823cbaf9..eb6a426684d 100644
--- a/nixpkgs/nixos/modules/services/mail/opendkim.nix
+++ b/nixpkgs/nixos/modules/services/mail/opendkim.nix
@@ -18,6 +18,9 @@ let
] ++ optionals (cfg.configFile != null) [ "-x" cfg.configFile ];
in {
+ imports = [
+ (mkRenamedOptionModule [ "services" "opendkim" "keyFile" ] [ "services" "opendkim" "keyPath" ])
+ ];
###### interface
@@ -88,16 +91,16 @@ in {
config = mkIf cfg.enable {
- users.users = optionalAttrs (cfg.user == "opendkim") (singleton
- { name = "opendkim";
+ users.users = optionalAttrs (cfg.user == "opendkim") {
+ opendkim = {
group = cfg.group;
uid = config.ids.uids.opendkim;
- });
+ };
+ };
- users.groups = optionalAttrs (cfg.group == "opendkim") (singleton
- { name = "opendkim";
- gid = config.ids.gids.opendkim;
- });
+ users.groups = optionalAttrs (cfg.group == "opendkim") {
+ opendkim.gid = config.ids.gids.opendkim;
+ };
environment.systemPackages = [ pkgs.opendkim ];
diff --git a/nixpkgs/nixos/modules/services/mail/postfix.nix b/nixpkgs/nixos/modules/services/mail/postfix.nix
index df438a0c69d..d7378821440 100644
--- a/nixpkgs/nixos/modules/services/mail/postfix.nix
+++ b/nixpkgs/nixos/modules/services/mail/postfix.nix
@@ -655,21 +655,20 @@ in
setgid = true;
};
- users.users = optional (user == "postfix")
- { name = "postfix";
- description = "Postfix mail server user";
- uid = config.ids.uids.postfix;
- group = group;
+ users.users = optionalAttrs (user == "postfix")
+ { postfix = {
+ description = "Postfix mail server user";
+ uid = config.ids.uids.postfix;
+ group = group;
+ };
};
users.groups =
- optional (group == "postfix")
- { name = group;
- gid = config.ids.gids.postfix;
+ optionalAttrs (group == "postfix")
+ { ${group}.gid = config.ids.gids.postfix;
}
- ++ optional (setgidGroup == "postdrop")
- { name = setgidGroup;
- gid = config.ids.gids.postdrop;
+ // optionalAttrs (setgidGroup == "postdrop")
+ { ${setgidGroup}.gid = config.ids.gids.postdrop;
};
systemd.services.postfix =
diff --git a/nixpkgs/nixos/modules/services/mail/postgrey.nix b/nixpkgs/nixos/modules/services/mail/postgrey.nix
index 88fb7f0b4ad..709f6b21aa0 100644
--- a/nixpkgs/nixos/modules/services/mail/postgrey.nix
+++ b/nixpkgs/nixos/modules/services/mail/postgrey.nix
@@ -42,6 +42,17 @@ with lib; let
};
in {
+ imports = [
+ (mkMergedOptionModule [ [ "services" "postgrey" "inetAddr" ] [ "services" "postgrey" "inetPort" ] ] [ "services" "postgrey" "socket" ] (config: let
+ value = p: getAttrFromPath p config;
+ inetAddr = [ "services" "postgrey" "inetAddr" ];
+ inetPort = [ "services" "postgrey" "inetPort" ];
+ in
+ if value inetAddr == null
+ then { path = "/run/postgrey.sock"; }
+ else { addr = value inetAddr; port = value inetPort; }
+ ))
+ ];
options = {
services.postgrey = with types; {
diff --git a/nixpkgs/nixos/modules/services/mail/postsrsd.nix b/nixpkgs/nixos/modules/services/mail/postsrsd.nix
index 8f12a16906c..2ebc675ab10 100644
--- a/nixpkgs/nixos/modules/services/mail/postsrsd.nix
+++ b/nixpkgs/nixos/modules/services/mail/postsrsd.nix
@@ -90,16 +90,16 @@ in {
services.postsrsd.domain = mkDefault config.networking.hostName;
- users.users = optionalAttrs (cfg.user == "postsrsd") (singleton
- { name = "postsrsd";
+ users.users = optionalAttrs (cfg.user == "postsrsd") {
+ postsrsd = {
group = cfg.group;
uid = config.ids.uids.postsrsd;
- });
+ };
+ };
- users.groups = optionalAttrs (cfg.group == "postsrsd") (singleton
- { name = "postsrsd";
- gid = config.ids.gids.postsrsd;
- });
+ users.groups = optionalAttrs (cfg.group == "postsrsd") {
+ postsrsd.gid = config.ids.gids.postsrsd;
+ };
systemd.services.postsrsd = {
description = "PostSRSd SRS rewriting server";
diff --git a/nixpkgs/nixos/modules/services/mail/rspamd.nix b/nixpkgs/nixos/modules/services/mail/rspamd.nix
index 7ef23ad1726..aacdbe2aeed 100644
--- a/nixpkgs/nixos/modules/services/mail/rspamd.nix
+++ b/nixpkgs/nixos/modules/services/mail/rspamd.nix
@@ -220,7 +220,6 @@ let
in
{
-
###### interface
options = {
@@ -375,15 +374,13 @@ in
# Allow users to run 'rspamc' and 'rspamadm'.
environment.systemPackages = [ pkgs.rspamd ];
- users.users = singleton {
- name = cfg.user;
+ users.users.${cfg.user} = {
description = "rspamd daemon";
uid = config.ids.uids.rspamd;
group = cfg.group;
};
- users.groups = singleton {
- name = cfg.group;
+ users.groups.${cfg.group} = {
gid = config.ids.gids.rspamd;
};
@@ -414,5 +411,6 @@ in
"Socket activation never worked correctly and could at this time not be fixed and so was removed")
(mkRenamedOptionModule [ "services" "rspamd" "bindSocket" ] [ "services" "rspamd" "workers" "normal" "bindSockets" ])
(mkRenamedOptionModule [ "services" "rspamd" "bindUISocket" ] [ "services" "rspamd" "workers" "controller" "bindSockets" ])
+ (mkRemovedOptionModule [ "services" "rmilter" ] "Use services.rspamd.* instead to set up milter service")
];
}
diff --git a/nixpkgs/nixos/modules/services/mail/spamassassin.nix b/nixpkgs/nixos/modules/services/mail/spamassassin.nix
index 1fe77ce5a0c..107280f7c14 100644
--- a/nixpkgs/nixos/modules/services/mail/spamassassin.nix
+++ b/nixpkgs/nixos/modules/services/mail/spamassassin.nix
@@ -128,15 +128,13 @@ in
systemPackages = [ pkgs.spamassassin ];
};
- users.users = singleton {
- name = "spamd";
+ users.users.spamd = {
description = "Spam Assassin Daemon";
uid = config.ids.uids.spamd;
group = "spamd";
};
- users.groups = singleton {
- name = "spamd";
+ users.groups.spamd = {
gid = config.ids.gids.spamd;
};
diff --git a/nixpkgs/nixos/modules/services/misc/apache-kafka.nix b/nixpkgs/nixos/modules/services/misc/apache-kafka.nix
index 798e902ccae..f3a650a260f 100644
--- a/nixpkgs/nixos/modules/services/misc/apache-kafka.nix
+++ b/nixpkgs/nixos/modules/services/misc/apache-kafka.nix
@@ -124,14 +124,13 @@ in {
environment.systemPackages = [cfg.package];
- users.users = singleton {
- name = "apache-kafka";
+ users.users.apache-kafka = {
uid = config.ids.uids.apache-kafka;
description = "Apache Kafka daemon user";
home = head cfg.logDirs;
};
- systemd.tmpfiles.rules = map (logDir: "d '${logDir} 0700 apache-kafka - - -") cfg.logDirs;
+ systemd.tmpfiles.rules = map (logDir: "d '${logDir}' 0700 apache-kafka - - -") cfg.logDirs;
systemd.services.apache-kafka = {
description = "Apache Kafka Daemon";
diff --git a/nixpkgs/nixos/modules/services/misc/bepasty.nix b/nixpkgs/nixos/modules/services/misc/bepasty.nix
index 87d36068144..f69832e5b2b 100644
--- a/nixpkgs/nixos/modules/services/misc/bepasty.nix
+++ b/nixpkgs/nixos/modules/services/misc/bepasty.nix
@@ -168,16 +168,12 @@ in
})
) cfg.servers;
- users.users = [{
- uid = config.ids.uids.bepasty;
- name = user;
- group = group;
- home = default_home;
- }];
-
- users.groups = [{
- name = group;
- gid = config.ids.gids.bepasty;
- }];
+ users.users.${user} =
+ { uid = config.ids.uids.bepasty;
+ group = group;
+ home = default_home;
+ };
+
+ users.groups.${group}.gid = config.ids.gids.bepasty;
};
}
diff --git a/nixpkgs/nixos/modules/services/misc/cgminer.nix b/nixpkgs/nixos/modules/services/misc/cgminer.nix
index b1cf5a7d110..9fcae645269 100644
--- a/nixpkgs/nixos/modules/services/misc/cgminer.nix
+++ b/nixpkgs/nixos/modules/services/misc/cgminer.nix
@@ -110,11 +110,12 @@ in
config = mkIf config.services.cgminer.enable {
- users.users = optionalAttrs (cfg.user == "cgminer") (singleton
- { name = "cgminer";
+ users.users = optionalAttrs (cfg.user == "cgminer") {
+ cgminer = {
uid = config.ids.uids.cgminer;
description = "Cgminer user";
- });
+ };
+ };
environment.systemPackages = [ cfg.package ];
diff --git a/nixpkgs/nixos/modules/services/misc/couchpotato.nix b/nixpkgs/nixos/modules/services/misc/couchpotato.nix
index 528af486b41..f5163cf86cf 100644
--- a/nixpkgs/nixos/modules/services/misc/couchpotato.nix
+++ b/nixpkgs/nixos/modules/services/misc/couchpotato.nix
@@ -29,17 +29,14 @@ in
};
};
- users.users = singleton
- { name = "couchpotato";
- group = "couchpotato";
+ users.users.couchpotato =
+ { group = "couchpotato";
home = "/var/lib/couchpotato/";
description = "CouchPotato daemon user";
uid = config.ids.uids.couchpotato;
};
- users.groups = singleton
- { name = "couchpotato";
- gid = config.ids.gids.couchpotato;
- };
+ users.groups.couchpotato =
+ { gid = config.ids.gids.couchpotato; };
};
}
diff --git a/nixpkgs/nixos/modules/services/misc/dictd.nix b/nixpkgs/nixos/modules/services/misc/dictd.nix
index 8d3e294622d..d175854d2d1 100644
--- a/nixpkgs/nixos/modules/services/misc/dictd.nix
+++ b/nixpkgs/nixos/modules/services/misc/dictd.nix
@@ -45,18 +45,14 @@ in
# get the command line client on system path to make some use of the service
environment.systemPackages = [ pkgs.dict ];
- users.users = singleton
- { name = "dictd";
- group = "dictd";
+ users.users.dictd =
+ { group = "dictd";
description = "DICT.org dictd server";
home = "${dictdb}/share/dictd";
uid = config.ids.uids.dictd;
};
- users.groups = singleton
- { name = "dictd";
- gid = config.ids.gids.dictd;
- };
+ users.groups.dictd.gid = config.ids.gids.dictd;
systemd.services.dictd = {
description = "DICT.org Dictionary Server";
diff --git a/nixpkgs/nixos/modules/services/misc/etcd.nix b/nixpkgs/nixos/modules/services/misc/etcd.nix
index e4d5322f9b5..7322e1c080b 100644
--- a/nixpkgs/nixos/modules/services/misc/etcd.nix
+++ b/nixpkgs/nixos/modules/services/misc/etcd.nix
@@ -186,8 +186,7 @@ in {
environment.systemPackages = [ pkgs.etcdctl ];
- users.users = singleton {
- name = "etcd";
+ users.users.etcd = {
uid = config.ids.uids.etcd;
description = "Etcd daemon user";
home = cfg.dataDir;
diff --git a/nixpkgs/nixos/modules/services/misc/ethminer.nix b/nixpkgs/nixos/modules/services/misc/ethminer.nix
index 2958cf21447..95afb0460fb 100644
--- a/nixpkgs/nixos/modules/services/misc/ethminer.nix
+++ b/nixpkgs/nixos/modules/services/misc/ethminer.nix
@@ -71,7 +71,7 @@ in
maxPower = mkOption {
type = types.int;
- default = 115;
+ default = 113;
description = "Miner max watt usage.";
};
@@ -92,7 +92,9 @@ in
serviceConfig = {
DynamicUser = true;
+ ExecStartPre = "${pkgs.ethminer}/bin/.ethminer-wrapped --list-devices";
ExecStartPost = optional (cfg.toolkit == "cuda") "+${getBin config.boot.kernelPackages.nvidia_x11}/bin/nvidia-smi -pl ${toString cfg.maxPower}";
+ Restart = "always";
};
environment = {
diff --git a/nixpkgs/nixos/modules/services/misc/exhibitor.nix b/nixpkgs/nixos/modules/services/misc/exhibitor.nix
index 74f4f671f46..f8c79f892da 100644
--- a/nixpkgs/nixos/modules/services/misc/exhibitor.nix
+++ b/nixpkgs/nixos/modules/services/misc/exhibitor.nix
@@ -410,8 +410,7 @@ in
sed -i 's/'"$replace_what"'/'"$replace_with"'/g' ${cfg.baseDir}/zookeeper/bin/zk*.sh
'';
};
- users.users = singleton {
- name = "zookeeper";
+ users.users.zookeeper = {
uid = config.ids.uids.zookeeper;
description = "Zookeeper daemon user";
home = cfg.baseDir;
diff --git a/nixpkgs/nixos/modules/services/misc/felix.nix b/nixpkgs/nixos/modules/services/misc/felix.nix
index 1c5ece86825..188e45abc58 100644
--- a/nixpkgs/nixos/modules/services/misc/felix.nix
+++ b/nixpkgs/nixos/modules/services/misc/felix.nix
@@ -47,14 +47,10 @@ in
###### implementation
config = mkIf cfg.enable {
- users.groups = singleton
- { name = "osgi";
- gid = config.ids.gids.osgi;
- };
+ users.groups.osgi.gid = config.ids.gids.osgi;
- users.users = singleton
- { name = "osgi";
- uid = config.ids.uids.osgi;
+ users.users.osgi =
+ { uid = config.ids.uids.osgi;
description = "OSGi user";
home = "/homeless-shelter";
};
diff --git a/nixpkgs/nixos/modules/services/misc/folding-at-home.nix b/nixpkgs/nixos/modules/services/misc/folding-at-home.nix
index 122c89ce068..fd2ea3948f6 100644
--- a/nixpkgs/nixos/modules/services/misc/folding-at-home.nix
+++ b/nixpkgs/nixos/modules/services/misc/folding-at-home.nix
@@ -42,9 +42,8 @@ in {
config = mkIf cfg.enable {
- users.users = singleton
- { name = fahUser;
- uid = config.ids.uids.foldingathome;
+ users.users.${fahUser} =
+ { uid = config.ids.uids.foldingathome;
description = "Folding@Home user";
home = stateDir;
};
diff --git a/nixpkgs/nixos/modules/services/misc/gitea.nix b/nixpkgs/nixos/modules/services/misc/gitea.nix
index c8c59fb256e..258476dd9fe 100644
--- a/nixpkgs/nixos/modules/services/misc/gitea.nix
+++ b/nixpkgs/nixos/modules/services/misc/gitea.nix
@@ -394,6 +394,26 @@ in
WorkingDirectory = cfg.stateDir;
ExecStart = "${gitea.bin}/bin/gitea web";
Restart = "always";
+
+ # Filesystem
+ ProtectHome = true;
+ PrivateDevices = true;
+ ProtectKernelTunables = true;
+ ProtectKernelModules = true;
+ ProtectControlGroups = true;
+ ReadWritePaths = cfg.stateDir;
+ # Caps
+ CapabilityBoundingSet = "";
+ NoNewPrivileges = true;
+ # Misc.
+ LockPersonality = true;
+ RestrictRealtime = true;
+ PrivateMounts = true;
+ PrivateUsers = true;
+ MemoryDenyWriteExecute = true;
+ SystemCallFilter = "~@clock @cpu-emulation @debug @keyring @memlock @module @mount @obsolete @raw-io @reboot @resources @setuid @swap";
+ SystemCallArchitectures = "native";
+ RestrictAddressFamilies = "AF_UNIX AF_INET AF_INET6";
};
environment = {
@@ -453,4 +473,5 @@ in
timerConfig.OnCalendar = cfg.dump.interval;
};
};
+ meta.maintainers = with lib.maintainers; [ srhb ];
}
diff --git a/nixpkgs/nixos/modules/services/misc/gitlab.nix b/nixpkgs/nixos/modules/services/misc/gitlab.nix
index 07ea9c45843..aa958985379 100644
--- a/nixpkgs/nixos/modules/services/misc/gitlab.nix
+++ b/nixpkgs/nixos/modules/services/misc/gitlab.nix
@@ -189,6 +189,11 @@ let
in {
+ imports = [
+ (mkRenamedOptionModule [ "services" "gitlab" "stateDir" ] [ "services" "gitlab" "statePath" ])
+ (mkRemovedOptionModule [ "services" "gitlab" "satelliteDir" ] "")
+ ];
+
options = {
services.gitlab = {
enable = mkOption {
@@ -628,20 +633,14 @@ in {
# Use postfix to send out mails.
services.postfix.enable = mkDefault true;
- users.users = [
- { name = cfg.user;
- group = cfg.group;
+ users.users.${cfg.user} =
+ { group = cfg.group;
home = "${cfg.statePath}/home";
shell = "${pkgs.bash}/bin/bash";
uid = config.ids.uids.gitlab;
- }
- ];
+ };
- users.groups = [
- { name = cfg.group;
- gid = config.ids.gids.gitlab;
- }
- ];
+ users.groups.${cfg.group}.gid = config.ids.gids.gitlab;
systemd.tmpfiles.rules = [
"d /run/gitlab 0755 ${cfg.user} ${cfg.group} -"
diff --git a/nixpkgs/nixos/modules/services/misc/gpsd.nix b/nixpkgs/nixos/modules/services/misc/gpsd.nix
index 3bfcb636a3c..f954249942a 100644
--- a/nixpkgs/nixos/modules/services/misc/gpsd.nix
+++ b/nixpkgs/nixos/modules/services/misc/gpsd.nix
@@ -86,17 +86,13 @@ in
config = mkIf cfg.enable {
- users.users = singleton
- { name = "gpsd";
- inherit uid;
+ users.users.gpsd =
+ { inherit uid;
description = "gpsd daemon user";
home = "/var/empty";
};
- users.groups = singleton
- { name = "gpsd";
- inherit gid;
- };
+ users.groups.gpsd = { inherit gid; };
systemd.services.gpsd = {
description = "GPSD daemon";
diff --git a/nixpkgs/nixos/modules/services/misc/headphones.nix b/nixpkgs/nixos/modules/services/misc/headphones.nix
index 4a77045be28..3ee0a4458bd 100644
--- a/nixpkgs/nixos/modules/services/misc/headphones.nix
+++ b/nixpkgs/nixos/modules/services/misc/headphones.nix
@@ -59,19 +59,19 @@ in
config = mkIf cfg.enable {
- users.users = optionalAttrs (cfg.user == name) (singleton {
- name = name;
- uid = config.ids.uids.headphones;
- group = cfg.group;
- description = "headphones user";
- home = cfg.dataDir;
- createHome = true;
- });
+ users.users = optionalAttrs (cfg.user == name) {
+ ${name} = {
+ uid = config.ids.uids.headphones;
+ group = cfg.group;
+ description = "headphones user";
+ home = cfg.dataDir;
+ createHome = true;
+ };
+ };
- users.groups = optionalAttrs (cfg.group == name) (singleton {
- name = name;
- gid = config.ids.gids.headphones;
- });
+ users.groups = optionalAttrs (cfg.group == name) {
+ ${name}.gid = config.ids.gids.headphones;
+ };
systemd.services.headphones = {
description = "Headphones Server";
diff --git a/nixpkgs/nixos/modules/services/misc/home-assistant.nix b/nixpkgs/nixos/modules/services/misc/home-assistant.nix
index 74702c97f55..cc113ca2d0c 100644
--- a/nixpkgs/nixos/modules/services/misc/home-assistant.nix
+++ b/nixpkgs/nixos/modules/services/misc/home-assistant.nix
@@ -11,6 +11,9 @@ let
(recursiveUpdate defaultConfig cfg.config) else cfg.config));
configFile = pkgs.runCommand "configuration.yaml" { preferLocalBuild = true; } ''
${pkgs.remarshal}/bin/json2yaml -i ${configJSON} -o $out
+ # Hack to support secrets, that are encoded as custom yaml objects,
+ # https://www.home-assistant.io/docs/configuration/secrets/
+ sed -i -e "s/'\!secret \(.*\)'/\!secret \1/" $out
'';
lovelaceConfigJSON = pkgs.writeText "ui-lovelace.json"
@@ -98,6 +101,10 @@ in {
{
homeassistant = {
name = "Home";
+ latitude = "!secret latitude";
+ longitude = "!secret longitude";
+ elevation = "!secret elevation";
+ unit_system = "metric";
time_zone = "UTC";
};
frontend = { };
@@ -108,6 +115,8 @@ in {
description = ''
Your <filename>configuration.yaml</filename> as a Nix attribute set.
Beware that setting this option will delete your previous <filename>configuration.yaml</filename>.
+ <link xlink:href="https://www.home-assistant.io/docs/configuration/secrets/">Secrets</link>
+ are encoded as strings as shown in the example.
'';
};
diff --git a/nixpkgs/nixos/modules/services/misc/mame.nix b/nixpkgs/nixos/modules/services/misc/mame.nix
new file mode 100644
index 00000000000..c5d5e9e4837
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/misc/mame.nix
@@ -0,0 +1,67 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+ cfg = config.services.mame;
+ mame = "mame${lib.optionalString pkgs.stdenv.is64bit "64"}";
+in
+{
+ options = {
+ services.mame = {
+ enable = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Whether to setup TUN/TAP Ethernet interface for MAME emulator.
+ '';
+ };
+ user = mkOption {
+ type = types.str;
+ description = ''
+ User from which you run MAME binary.
+ '';
+ };
+ hostAddr = mkOption {
+ type = types.str;
+ description = ''
+ IP address of the host system. Usually an address of the main network
+ adapter or the adapter through which you get an internet connection.
+ '';
+ example = "192.168.31.156";
+ };
+ emuAddr = mkOption {
+ type = types.str;
+ description = ''
+ IP address of the guest system. The same you set inside guest OS under
+ MAME. Should be on the same subnet as <option>services.mame.hostAddr</option>.
+ '';
+ example = "192.168.31.155";
+ };
+ };
+ };
+
+ config = mkIf cfg.enable {
+ environment.systemPackages = [ pkgs.mame ];
+
+ security.wrappers."${mame}" = {
+ source = "${pkgs.mame}/bin/${mame}";
+ capabilities = "cap_net_admin,cap_net_raw+eip";
+ };
+
+ systemd.services.mame = {
+ description = "MAME TUN/TAP Ethernet interface";
+ after = [ "network.target" ];
+ wantedBy = [ "multi-user.target" ];
+ path = [ pkgs.iproute ];
+ serviceConfig = {
+ Type = "oneshot";
+ RemainAfterExit = true;
+ ExecStart = "${pkgs.mame}/bin/taputil.sh -c ${cfg.user} ${cfg.emuAddr} ${cfg.hostAddr} -";
+ ExecStop = "${pkgs.mame}/bin/taputil.sh -d ${cfg.user}";
+ };
+ };
+ };
+
+ meta.maintainers = with lib.maintainers; [ gnidorah ];
+}
diff --git a/nixpkgs/nixos/modules/services/misc/matrix-synapse.nix b/nixpkgs/nixos/modules/services/misc/matrix-synapse.nix
index 50661b873f6..750f4a292fb 100644
--- a/nixpkgs/nixos/modules/services/misc/matrix-synapse.nix
+++ b/nixpkgs/nixos/modules/services/misc/matrix-synapse.nix
@@ -657,57 +657,42 @@ in {
};
config = mkIf cfg.enable {
- users.users = [
- { name = "matrix-synapse";
+ users.users.matrix-synapse = {
group = "matrix-synapse";
home = cfg.dataDir;
createHome = true;
shell = "${pkgs.bash}/bin/bash";
uid = config.ids.uids.matrix-synapse;
- } ];
+ };
- users.groups = [
- { name = "matrix-synapse";
- gid = config.ids.gids.matrix-synapse;
- } ];
+ users.groups.matrix-synapse = {
+ gid = config.ids.gids.matrix-synapse;
+ };
- services.postgresql.enable = mkIf usePostgresql (mkDefault true);
+ services.postgresql = mkIf (usePostgresql && cfg.create_local_database) {
+ enable = mkDefault true;
+ ensureDatabases = [ cfg.database_name ];
+ ensureUsers = [{
+ name = cfg.database_user;
+ ensurePermissions = { "DATABASE \"${cfg.database_name}\"" = "ALL PRIVILEGES"; };
+ }];
+ };
systemd.services.matrix-synapse = {
description = "Synapse Matrix homeserver";
- after = [ "network.target" "postgresql.service" ];
+ after = [ "network.target" ] ++ lib.optional config.services.postgresql.enable "postgresql.service" ;
wantedBy = [ "multi-user.target" ];
preStart = ''
${cfg.package}/bin/homeserver \
--config-path ${configFile} \
--keys-directory ${cfg.dataDir} \
--generate-keys
- '' + optionalString (usePostgresql && cfg.create_local_database) ''
- if ! test -e "${cfg.dataDir}/db-created"; then
- ${pkgs.sudo}/bin/sudo -u ${pg.superUser} \
- ${pg.package}/bin/createuser \
- --login \
- --no-createdb \
- --no-createrole \
- --encrypted \
- ${cfg.database_user}
- ${pkgs.sudo}/bin/sudo -u ${pg.superUser} \
- ${pg.package}/bin/createdb \
- --owner=${cfg.database_user} \
- --encoding=UTF8 \
- --lc-collate=C \
- --lc-ctype=C \
- --template=template0 \
- ${cfg.database_name}
- touch "${cfg.dataDir}/db-created"
- fi
'';
serviceConfig = {
Type = "notify";
User = "matrix-synapse";
Group = "matrix-synapse";
WorkingDirectory = cfg.dataDir;
- PermissionsStartOnly = true;
ExecStart = ''
${cfg.package}/bin/homeserver \
${ concatMapStringsSep "\n " (x: "--config-path ${x} \\") ([ configFile ] ++ cfg.extraConfigFiles) }
diff --git a/nixpkgs/nixos/modules/services/misc/mediatomb.nix b/nixpkgs/nixos/modules/services/misc/mediatomb.nix
index 107fb57fe1c..529f584a201 100644
--- a/nixpkgs/nixos/modules/services/misc/mediatomb.nix
+++ b/nixpkgs/nixos/modules/services/misc/mediatomb.nix
@@ -266,19 +266,19 @@ in {
serviceConfig.User = "${cfg.user}";
};
- users.groups = optionalAttrs (cfg.group == "mediatomb") (singleton {
- name = "mediatomb";
- gid = gid;
- });
+ users.groups = optionalAttrs (cfg.group == "mediatomb") {
+ mediatomb.gid = gid;
+ };
- users.users = optionalAttrs (cfg.user == "mediatomb") (singleton {
- name = "mediatomb";
- isSystemUser = true;
- group = cfg.group;
- home = "${cfg.dataDir}";
- createHome = true;
- description = "Mediatomb DLNA Server User";
- });
+ users.users = optionalAttrs (cfg.user == "mediatomb") {
+ mediatomb = {
+ isSystemUser = true;
+ group = cfg.group;
+ home = "${cfg.dataDir}";
+ createHome = true;
+ description = "Mediatomb DLNA Server User";
+ };
+ };
networking.firewall = {
allowedUDPPorts = [ 1900 cfg.port ];
diff --git a/nixpkgs/nixos/modules/services/misc/nix-daemon.nix b/nixpkgs/nixos/modules/services/misc/nix-daemon.nix
index dcec4d4fc6c..17c3582db0f 100644
--- a/nixpkgs/nixos/modules/services/misc/nix-daemon.nix
+++ b/nixpkgs/nixos/modules/services/misc/nix-daemon.nix
@@ -12,8 +12,9 @@ let
isNix23 = versionAtLeast nixVersion "2.3pre";
- makeNixBuildUser = nr:
- { name = "nixbld${toString nr}";
+ makeNixBuildUser = nr: {
+ name = "nixbld${toString nr}";
+ value = {
description = "Nix build user ${toString nr}";
/* For consistency with the setgid(2), setuid(2), and setgroups(2)
@@ -23,8 +24,9 @@ let
group = "nixbld";
extraGroups = [ "nixbld" ];
};
+ };
- nixbldUsers = map makeNixBuildUser (range 1 cfg.nrBuildUsers);
+ nixbldUsers = listToAttrs (map makeNixBuildUser (range 1 cfg.nrBuildUsers));
nixConf =
assert versionAtLeast nixVersion "2.2";
@@ -68,6 +70,10 @@ let
in
{
+ imports = [
+ (mkRenamedOptionModule [ "nix" "useChroot" ] [ "nix" "useSandbox" ])
+ (mkRenamedOptionModule [ "nix" "chrootDirs" ] [ "nix" "sandboxPaths" ])
+ ];
###### interface
@@ -441,7 +447,7 @@ in
users.users = nixbldUsers;
- services.xserver.displayManager.hiddenUsers = map ({ name, ... }: name) nixbldUsers;
+ services.xserver.displayManager.hiddenUsers = attrNames nixbldUsers;
system.activationScripts.nix = stringAfter [ "etc" "users" ]
''
diff --git a/nixpkgs/nixos/modules/services/misc/nixos-manual.nix b/nixpkgs/nixos/modules/services/misc/nixos-manual.nix
index 20ba3d8ef0b..ab73f49d4be 100644
--- a/nixpkgs/nixos/modules/services/misc/nixos-manual.nix
+++ b/nixpkgs/nixos/modules/services/misc/nixos-manual.nix
@@ -52,7 +52,7 @@ in
};
})
(mkIf (cfg.showManual && cfgd.enable && cfgd.nixos.enable) {
- boot.extraTTYs = [ "tty${toString cfg.ttyNumber}" ];
+ console.extraTTYs = [ "tty${toString cfg.ttyNumber}" ];
systemd.services.nixos-manual = {
description = "NixOS Manual";
diff --git a/nixpkgs/nixos/modules/services/misc/nzbget.nix b/nixpkgs/nixos/modules/services/misc/nzbget.nix
index eb7b4c05d82..715ec891cd6 100644
--- a/nixpkgs/nixos/modules/services/misc/nzbget.nix
+++ b/nixpkgs/nixos/modules/services/misc/nzbget.nix
@@ -27,6 +27,12 @@ let
in
{
+ imports = [
+ (mkRemovedOptionModule [ "services" "misc" "nzbget" "configFile" ] "The configuration of nzbget is now managed by users through the web interface.")
+ (mkRemovedOptionModule [ "services" "misc" "nzbget" "dataDir" ] "The data directory for nzbget is now /var/lib/nzbget.")
+ (mkRemovedOptionModule [ "services" "misc" "nzbget" "openFirewall" ] "The port used by nzbget is managed through the web interface so you should adjust your firewall rules accordingly.")
+ ];
+
# interface
options = {
diff --git a/nixpkgs/nixos/modules/services/misc/octoprint.nix b/nixpkgs/nixos/modules/services/misc/octoprint.nix
index 8950010773c..651ed374388 100644
--- a/nixpkgs/nixos/modules/services/misc/octoprint.nix
+++ b/nixpkgs/nixos/modules/services/misc/octoprint.nix
@@ -86,16 +86,16 @@ in
config = mkIf cfg.enable {
- users.users = optionalAttrs (cfg.user == "octoprint") (singleton
- { name = "octoprint";
+ users.users = optionalAttrs (cfg.user == "octoprint") {
+ octoprint = {
group = cfg.group;
uid = config.ids.uids.octoprint;
- });
+ };
+ };
- users.groups = optionalAttrs (cfg.group == "octoprint") (singleton
- { name = "octoprint";
- gid = config.ids.gids.octoprint;
- });
+ users.groups = optionalAttrs (cfg.group == "octoprint") {
+ octoprint.gid = config.ids.gids.octoprint;
+ };
systemd.tmpfiles.rules = [
"d '${cfg.stateDir}' - ${cfg.user} ${cfg.group} - -"
diff --git a/nixpkgs/nixos/modules/services/misc/parsoid.nix b/nixpkgs/nixos/modules/services/misc/parsoid.nix
index c757093e5c1..61626e78f8b 100644
--- a/nixpkgs/nixos/modules/services/misc/parsoid.nix
+++ b/nixpkgs/nixos/modules/services/misc/parsoid.nix
@@ -26,6 +26,10 @@ let
in
{
+ imports = [
+ (mkRemovedOptionModule [ "services" "parsoid" "interwikis" ] "Use services.parsoid.wikis instead")
+ ];
+
##### interface
options = {
diff --git a/nixpkgs/nixos/modules/services/misc/pykms.nix b/nixpkgs/nixos/modules/services/misc/pykms.nix
index e2d1254602b..25aa27ae767 100644
--- a/nixpkgs/nixos/modules/services/misc/pykms.nix
+++ b/nixpkgs/nixos/modules/services/misc/pykms.nix
@@ -9,6 +9,10 @@ let
in {
meta.maintainers = with lib.maintainers; [ peterhoeg ];
+ imports = [
+ (mkRemovedOptionModule [ "services" "pykms" "verbose" ] "Use services.pykms.logLevel instead")
+ ];
+
options = {
services.pykms = {
enable = mkOption {
diff --git a/nixpkgs/nixos/modules/services/misc/redmine.nix b/nixpkgs/nixos/modules/services/misc/redmine.nix
index bf9a6914a48..3b8c14d196f 100644
--- a/nixpkgs/nixos/modules/services/misc/redmine.nix
+++ b/nixpkgs/nixos/modules/services/misc/redmine.nix
@@ -66,7 +66,7 @@ in
type = types.package;
default = pkgs.redmine;
description = "Which Redmine package to use.";
- example = "pkgs.redmine.override { ruby = pkgs.ruby_2_4; }";
+ example = "pkgs.redmine.override { ruby = pkgs.ruby_2_7; }";
};
user = mkOption {
@@ -367,17 +367,17 @@ in
};
- users.users = optionalAttrs (cfg.user == "redmine") (singleton
- { name = "redmine";
+ users.users = optionalAttrs (cfg.user == "redmine") {
+ redmine = {
group = cfg.group;
home = cfg.stateDir;
uid = config.ids.uids.redmine;
- });
+ };
+ };
- users.groups = optionalAttrs (cfg.group == "redmine") (singleton
- { name = "redmine";
- gid = config.ids.gids.redmine;
- });
+ users.groups = optionalAttrs (cfg.group == "redmine") {
+ redmine.gid = config.ids.gids.redmine;
+ };
warnings = optional (cfg.database.password != "")
''config.services.redmine.database.password will be stored as plaintext
diff --git a/nixpkgs/nixos/modules/services/misc/ripple-data-api.nix b/nixpkgs/nixos/modules/services/misc/ripple-data-api.nix
index 042b496d35e..9fab462f7e3 100644
--- a/nixpkgs/nixos/modules/services/misc/ripple-data-api.nix
+++ b/nixpkgs/nixos/modules/services/misc/ripple-data-api.nix
@@ -185,9 +185,8 @@ in {
];
};
- users.users = singleton
- { name = "ripple-data-api";
- description = "Ripple data api user";
+ users.users.ripple-data-api =
+ { description = "Ripple data api user";
uid = config.ids.uids.ripple-data-api;
};
};
diff --git a/nixpkgs/nixos/modules/services/misc/rippled.nix b/nixpkgs/nixos/modules/services/misc/rippled.nix
index cdf61730de3..ef34e3a779f 100644
--- a/nixpkgs/nixos/modules/services/misc/rippled.nix
+++ b/nixpkgs/nixos/modules/services/misc/rippled.nix
@@ -406,9 +406,8 @@ in
config = mkIf cfg.enable {
- users.users = singleton
- { name = "rippled";
- description = "Ripple server user";
+ users.users.rippled =
+ { description = "Ripple server user";
uid = config.ids.uids.rippled;
home = cfg.databasePath;
createHome = true;
diff --git a/nixpkgs/nixos/modules/services/misc/rogue.nix b/nixpkgs/nixos/modules/services/misc/rogue.nix
index aae02e384c9..d56d103b5f3 100644
--- a/nixpkgs/nixos/modules/services/misc/rogue.nix
+++ b/nixpkgs/nixos/modules/services/misc/rogue.nix
@@ -40,7 +40,7 @@ in
config = mkIf cfg.enable {
- boot.extraTTYs = [ cfg.tty ];
+ console.extraTTYs = [ cfg.tty ];
systemd.services.rogue =
{ description = "Rogue dungeon crawling game";
diff --git a/nixpkgs/nixos/modules/services/misc/serviio.nix b/nixpkgs/nixos/modules/services/misc/serviio.nix
index 9868192724b..0ead6a81691 100644
--- a/nixpkgs/nixos/modules/services/misc/serviio.nix
+++ b/nixpkgs/nixos/modules/services/misc/serviio.nix
@@ -63,20 +63,15 @@ in {
};
};
- users.users = [
- {
- name = "serviio";
- group = "serviio";
+ users.users.serviio =
+ { group = "serviio";
home = cfg.dataDir;
description = "Serviio Media Server User";
createHome = true;
isSystemUser = true;
- }
- ];
+ };
- users.groups = [
- { name = "serviio";}
- ];
+ users.groups.serviio = { };
networking.firewall = {
allowedTCPPorts = [
diff --git a/nixpkgs/nixos/modules/services/misc/sickbeard.nix b/nixpkgs/nixos/modules/services/misc/sickbeard.nix
index 5cfbbe516ae..a32dbfa3108 100644
--- a/nixpkgs/nixos/modules/services/misc/sickbeard.nix
+++ b/nixpkgs/nixos/modules/services/misc/sickbeard.nix
@@ -63,19 +63,19 @@ in
config = mkIf cfg.enable {
- users.users = optionalAttrs (cfg.user == name) (singleton {
- name = name;
- uid = config.ids.uids.sickbeard;
- group = cfg.group;
- description = "sickbeard user";
- home = cfg.dataDir;
- createHome = true;
- });
+ users.users = optionalAttrs (cfg.user == name) {
+ ${name} = {
+ uid = config.ids.uids.sickbeard;
+ group = cfg.group;
+ description = "sickbeard user";
+ home = cfg.dataDir;
+ createHome = true;
+ };
+ };
- users.groups = optionalAttrs (cfg.group == name) (singleton {
- name = name;
- gid = config.ids.gids.sickbeard;
- });
+ users.groups = optionalAttrs (cfg.group == name) {
+ ${name}.gid = config.ids.gids.sickbeard;
+ };
systemd.services.sickbeard = {
description = "Sickbeard Server";
diff --git a/nixpkgs/nixos/modules/services/misc/siproxd.nix b/nixpkgs/nixos/modules/services/misc/siproxd.nix
index dcaf73aca44..ae7b27de8e7 100644
--- a/nixpkgs/nixos/modules/services/misc/siproxd.nix
+++ b/nixpkgs/nixos/modules/services/misc/siproxd.nix
@@ -161,8 +161,7 @@ in
config = mkIf cfg.enable {
- users.users = singleton {
- name = "siproxyd";
+ users.users.siproxyd = {
uid = config.ids.uids.siproxd;
};
diff --git a/nixpkgs/nixos/modules/services/misc/taskserver/default.nix b/nixpkgs/nixos/modules/services/misc/taskserver/default.nix
index 8a57277fafe..a894caed1a3 100644
--- a/nixpkgs/nixos/modules/services/misc/taskserver/default.nix
+++ b/nixpkgs/nixos/modules/services/misc/taskserver/default.nix
@@ -368,16 +368,16 @@ in {
(mkIf cfg.enable {
environment.systemPackages = [ nixos-taskserver ];
- users.users = optional (cfg.user == "taskd") {
- name = "taskd";
- uid = config.ids.uids.taskd;
- description = "Taskserver user";
- group = cfg.group;
+ users.users = optionalAttrs (cfg.user == "taskd") {
+ taskd = {
+ uid = config.ids.uids.taskd;
+ description = "Taskserver user";
+ group = cfg.group;
+ };
};
- users.groups = optional (cfg.group == "taskd") {
- name = "taskd";
- gid = config.ids.gids.taskd;
+ users.groups = optionalAttrs (cfg.group == "taskd") {
+ taskd.gid = config.ids.gids.taskd;
};
services.taskserver.config = {
diff --git a/nixpkgs/nixos/modules/services/misc/tautulli.nix b/nixpkgs/nixos/modules/services/misc/tautulli.nix
index 50e45036647..aded33629f1 100644
--- a/nixpkgs/nixos/modules/services/misc/tautulli.nix
+++ b/nixpkgs/nixos/modules/services/misc/tautulli.nix
@@ -6,6 +6,10 @@ let
cfg = config.services.tautulli;
in
{
+ imports = [
+ (mkRenamedOptionModule [ "services" "plexpy" ] [ "services" "tautulli" ])
+ ];
+
options = {
services.tautulli = {
enable = mkEnableOption "Tautulli Plex Monitor";
diff --git a/nixpkgs/nixos/modules/services/misc/uhub.nix b/nixpkgs/nixos/modules/services/misc/uhub.nix
index 753580c3e40..d1b38831028 100644
--- a/nixpkgs/nixos/modules/services/misc/uhub.nix
+++ b/nixpkgs/nixos/modules/services/misc/uhub.nix
@@ -41,31 +41,31 @@ in
enable = mkOption {
type = types.bool;
default = false;
- description = "Whether to enable the uhub ADC hub.";
+ description = "Whether to enable the uhub ADC hub.";
};
port = mkOption {
type = types.int;
default = 1511;
- description = "TCP port to bind the hub to.";
+ description = "TCP port to bind the hub to.";
};
address = mkOption {
type = types.str;
default = "any";
- description = "Address to bind the hub to.";
+ description = "Address to bind the hub to.";
};
enableTLS = mkOption {
type = types.bool;
default = false;
- description = "Whether to enable TLS support.";
+ description = "Whether to enable TLS support.";
};
hubConfig = mkOption {
type = types.lines;
default = "";
- description = "Contents of uhub configuration file.";
+ description = "Contents of uhub configuration file.";
};
aclConfig = mkOption {
@@ -77,11 +77,11 @@ in
plugins = {
authSqlite = {
- enable = mkOption {
+ enable = mkOption {
type = types.bool;
default = false;
description = "Whether to enable the Sqlite authentication database plugin";
- };
+ };
file = mkOption {
type = types.path;
example = "/var/db/uhub-users";
@@ -161,14 +161,8 @@ in
config = mkIf cfg.enable {
users = {
- users = singleton {
- name = "uhub";
- uid = config.ids.uids.uhub;
- };
- groups = singleton {
- name = "uhub";
- gid = config.ids.gids.uhub;
- };
+ users.uhub.uid = config.ids.uids.uhub;
+ groups.uhub.gid = config.ids.gids.uhub;
};
systemd.services.uhub = {
diff --git a/nixpkgs/nixos/modules/services/misc/zookeeper.nix b/nixpkgs/nixos/modules/services/misc/zookeeper.nix
index 5d91e44a199..f6af7c75eba 100644
--- a/nixpkgs/nixos/modules/services/misc/zookeeper.nix
+++ b/nixpkgs/nixos/modules/services/misc/zookeeper.nix
@@ -146,8 +146,7 @@ in {
'';
};
- users.users = singleton {
- name = "zookeeper";
+ users.users.zookeeper = {
uid = config.ids.uids.zookeeper;
description = "Zookeeper daemon user";
home = cfg.dataDir;
diff --git a/nixpkgs/nixos/modules/services/monitoring/collectd.nix b/nixpkgs/nixos/modules/services/monitoring/collectd.nix
index 731ac743b7c..ef3663c62e0 100644
--- a/nixpkgs/nixos/modules/services/monitoring/collectd.nix
+++ b/nixpkgs/nixos/modules/services/monitoring/collectd.nix
@@ -129,9 +129,10 @@ in {
};
};
- users.users = optional (cfg.user == "collectd") {
- name = "collectd";
- isSystemUser = true;
+ users.users = optionalAttrs (cfg.user == "collectd") {
+ collectd = {
+ isSystemUser = true;
+ };
};
};
}
diff --git a/nixpkgs/nixos/modules/services/monitoring/datadog-agent.nix b/nixpkgs/nixos/modules/services/monitoring/datadog-agent.nix
index 02a9f316fc3..2c5fe47242e 100644
--- a/nixpkgs/nixos/modules/services/monitoring/datadog-agent.nix
+++ b/nixpkgs/nixos/modules/services/monitoring/datadog-agent.nix
@@ -22,9 +22,9 @@ let
# Generate Datadog configuration files for each configured checks.
# This works because check configurations have predictable paths,
# and because JSON is a valid subset of YAML.
- makeCheckConfigs = entries: mapAttrsToList (name: conf: {
- source = pkgs.writeText "${name}-check-conf.yaml" (builtins.toJSON conf);
- target = "datadog-agent/conf.d/${name}.d/conf.yaml";
+ makeCheckConfigs = entries: mapAttrs' (name: conf: {
+ name = "datadog-agent/conf.d/${name}.d/conf.yaml";
+ value.source = pkgs.writeText "${name}-check-conf.yaml" (builtins.toJSON conf);
}) entries;
defaultChecks = {
@@ -34,10 +34,11 @@ let
# Assemble all check configurations and the top-level agent
# configuration.
- etcfiles = with pkgs; with builtins; [{
- source = writeText "datadog.yaml" (toJSON ddConf);
- target = "datadog-agent/datadog.yaml";
- }] ++ makeCheckConfigs (cfg.checks // defaultChecks);
+ etcfiles = with pkgs; with builtins;
+ { "datadog-agent/datadog.yaml" = {
+ source = writeText "datadog.yaml" (toJSON ddConf);
+ };
+ } // makeCheckConfigs (cfg.checks // defaultChecks);
# Apply the configured extraIntegrations to the provided agent
# package. See the documentation of `dd-agent/integrations-core.nix`
@@ -204,7 +205,7 @@ in {
config = mkIf cfg.enable {
environment.systemPackages = [ datadogPkg pkgs.sysstat pkgs.procps pkgs.iproute ];
- users.extraUsers.datadog = {
+ users.users.datadog = {
description = "Datadog Agent User";
uid = config.ids.uids.datadog;
group = "datadog";
@@ -212,7 +213,7 @@ in {
createHome = true;
};
- users.extraGroups.datadog.gid = config.ids.gids.datadog;
+ users.groups.datadog.gid = config.ids.gids.datadog;
systemd.services = let
makeService = attrs: recursiveUpdate {
@@ -224,7 +225,7 @@ in {
Restart = "always";
RestartSec = 2;
};
- restartTriggers = [ datadogPkg ] ++ map (etc: etc.source) etcfiles;
+ restartTriggers = [ datadogPkg ] ++ attrNames etcfiles;
} attrs;
in {
datadog-agent = makeService {
diff --git a/nixpkgs/nixos/modules/services/monitoring/dd-agent/dd-agent.nix b/nixpkgs/nixos/modules/services/monitoring/dd-agent/dd-agent.nix
index 5ee6b092a6a..e91717fb205 100644
--- a/nixpkgs/nixos/modules/services/monitoring/dd-agent/dd-agent.nix
+++ b/nixpkgs/nixos/modules/services/monitoring/dd-agent/dd-agent.nix
@@ -78,37 +78,35 @@ let
etcfiles =
let
defaultConfd = import ./dd-agent-defaults.nix;
- in (map (f: { source = "${pkgs.dd-agent}/agent/conf.d-system/${f}";
- target = "dd-agent/conf.d/${f}";
- }) defaultConfd) ++ [
- { source = ddConf;
- target = "dd-agent/datadog.conf";
- }
- { source = diskConfig;
- target = "dd-agent/conf.d/disk.yaml";
- }
- { source = networkConfig;
- target = "dd-agent/conf.d/network.yaml";
- } ] ++
- (optional (cfg.postgresqlConfig != null)
- { source = postgresqlConfig;
- target = "dd-agent/conf.d/postgres.yaml";
- }) ++
- (optional (cfg.nginxConfig != null)
- { source = nginxConfig;
- target = "dd-agent/conf.d/nginx.yaml";
- }) ++
- (optional (cfg.mongoConfig != null)
- { source = mongoConfig;
- target = "dd-agent/conf.d/mongo.yaml";
- }) ++
- (optional (cfg.processConfig != null)
- { source = processConfig;
- target = "dd-agent/conf.d/process.yaml";
- }) ++
- (optional (cfg.jmxConfig != null)
- { source = jmxConfig;
- target = "dd-agent/conf.d/jmx.yaml";
+ in
+ listToAttrs (map (f: {
+ name = "dd-agent/conf.d/${f}";
+ value.source = "${pkgs.dd-agent}/agent/conf.d-system/${f}";
+ }) defaultConfd) //
+ {
+ "dd-agent/datadog.conf".source = ddConf;
+ "dd-agent/conf.d/disk.yaml".source = diskConfig;
+ "dd-agent/conf.d/network.yaml".source = networkConfig;
+ } //
+ (optionalAttrs (cfg.postgresqlConfig != null)
+ {
+ "dd-agent/conf.d/postgres.yaml".source = postgresqlConfig;
+ }) //
+ (optionalAttrs (cfg.nginxConfig != null)
+ {
+ "dd-agent/conf.d/nginx.yaml".source = nginxConfig;
+ }) //
+ (optionalAttrs (cfg.mongoConfig != null)
+ {
+ "dd-agent/conf.d/mongo.yaml".source = mongoConfig;
+ }) //
+ (optionalAttrs (cfg.processConfig != null)
+ {
+ "dd-agent/conf.d/process.yaml".source = processConfig;
+ }) //
+ (optionalAttrs (cfg.jmxConfig != null)
+ {
+ "dd-agent/conf.d/jmx.yaml".source = jmxConfig;
});
in {
diff --git a/nixpkgs/nixos/modules/services/monitoring/fusion-inventory.nix b/nixpkgs/nixos/modules/services/monitoring/fusion-inventory.nix
index fe19ed56195..9b65c76ce02 100644
--- a/nixpkgs/nixos/modules/services/monitoring/fusion-inventory.nix
+++ b/nixpkgs/nixos/modules/services/monitoring/fusion-inventory.nix
@@ -46,8 +46,7 @@ in {
config = mkIf cfg.enable {
- users.users = singleton {
- name = "fusion-inventory";
+ users.users.fusion-inventory = {
description = "FusionInventory user";
isSystemUser = true;
};
diff --git a/nixpkgs/nixos/modules/services/monitoring/graphite.nix b/nixpkgs/nixos/modules/services/monitoring/graphite.nix
index f7874af3df2..dd147bb3793 100644
--- a/nixpkgs/nixos/modules/services/monitoring/graphite.nix
+++ b/nixpkgs/nixos/modules/services/monitoring/graphite.nix
@@ -632,8 +632,7 @@ in {
cfg.web.enable || cfg.api.enable ||
cfg.seyren.enable || cfg.pager.enable || cfg.beacon.enable
) {
- users.users = singleton {
- name = "graphite";
+ users.users.graphite = {
uid = config.ids.uids.graphite;
description = "Graphite daemon user";
home = dataDir;
diff --git a/nixpkgs/nixos/modules/services/monitoring/heapster.nix b/nixpkgs/nixos/modules/services/monitoring/heapster.nix
index 6da0831b4c5..585632943fd 100644
--- a/nixpkgs/nixos/modules/services/monitoring/heapster.nix
+++ b/nixpkgs/nixos/modules/services/monitoring/heapster.nix
@@ -49,8 +49,7 @@ in {
};
};
- users.users = singleton {
- name = "heapster";
+ users.users.heapsterrs = {
uid = config.ids.uids.heapster;
description = "Heapster user";
};
diff --git a/nixpkgs/nixos/modules/services/monitoring/munin.nix b/nixpkgs/nixos/modules/services/monitoring/munin.nix
index 8af0650c738..1ebf7ee6a76 100644
--- a/nixpkgs/nixos/modules/services/monitoring/munin.nix
+++ b/nixpkgs/nixos/modules/services/monitoring/munin.nix
@@ -317,18 +317,16 @@ in
environment.systemPackages = [ pkgs.munin ];
- users.users = [{
- name = "munin";
+ users.users.munin = {
description = "Munin monitoring user";
group = "munin";
uid = config.ids.uids.munin;
home = "/var/lib/munin";
- }];
+ };
- users.groups = [{
- name = "munin";
+ users.groups.munin = {
gid = config.ids.gids.munin;
- }];
+ };
}) (mkIf nodeCfg.enable {
diff --git a/nixpkgs/nixos/modules/services/monitoring/nagios.nix b/nixpkgs/nixos/modules/services/monitoring/nagios.nix
index 6a3b9776946..3ca79dddaf5 100644
--- a/nixpkgs/nixos/modules/services/monitoring/nagios.nix
+++ b/nixpkgs/nixos/modules/services/monitoring/nagios.nix
@@ -8,6 +8,7 @@ let
nagiosState = "/var/lib/nagios";
nagiosLogDir = "/var/log/nagios";
+ urlPath = "/nagios";
nagiosObjectDefs = cfg.objectDefs;
@@ -16,32 +17,39 @@ let
preferLocalBuild = true;
} "mkdir -p $out; ln -s $nagiosObjectDefs $out/";
- nagiosCfgFile = pkgs.writeText "nagios.cfg"
- ''
- # Paths for state and logs.
- log_file=${nagiosLogDir}/current
- log_archive_path=${nagiosLogDir}/archive
- status_file=${nagiosState}/status.dat
- object_cache_file=${nagiosState}/objects.cache
- temp_file=${nagiosState}/nagios.tmp
- lock_file=/run/nagios.lock # Not used I think.
- state_retention_file=${nagiosState}/retention.dat
- query_socket=${nagiosState}/nagios.qh
- check_result_path=${nagiosState}
- command_file=${nagiosState}/nagios.cmd
-
- # Configuration files.
- #resource_file=resource.cfg
- cfg_dir=${nagiosObjectDefsDir}
-
- # Uid/gid that the daemon runs under.
- nagios_user=nagios
- nagios_group=nagios
-
- # Misc. options.
- illegal_macro_output_chars=`~$&|'"<>
- retain_state_information=1
- ''; # "
+ nagiosCfgFile = let
+ default = {
+ log_file="${nagiosLogDir}/current";
+ log_archive_path="${nagiosLogDir}/archive";
+ status_file="${nagiosState}/status.dat";
+ object_cache_file="${nagiosState}/objects.cache";
+ temp_file="${nagiosState}/nagios.tmp";
+ lock_file="/run/nagios.lock";
+ state_retention_file="${nagiosState}/retention.dat";
+ query_socket="${nagiosState}/nagios.qh";
+ check_result_path="${nagiosState}";
+ command_file="${nagiosState}/nagios.cmd";
+ cfg_dir="${nagiosObjectDefsDir}";
+ nagios_user="nagios";
+ nagios_group="nagios";
+ illegal_macro_output_chars="`~$&|'\"<>";
+ retain_state_information="1";
+ };
+ lines = mapAttrsToList (key: value: "${key}=${value}") (default // cfg.extraConfig);
+ content = concatStringsSep "\n" lines;
+ file = pkgs.writeText "nagios.cfg" content;
+ validated = pkgs.runCommand "nagios-checked.cfg" {preferLocalBuild=true;} ''
+ cp ${file} nagios.cfg
+ # nagios checks the existence of /var/lib/nagios, but
+ # it does not exists in the build sandbox, so we fake it
+ mkdir lib
+ lib=$(readlink -f lib)
+ sed -i s@=${nagiosState}@=$lib@ nagios.cfg
+ ${pkgs.nagios}/bin/nagios -v nagios.cfg && cp ${file} $out
+ '';
+ defaultCfgFile = if cfg.validateConfig then validated else file;
+ in
+ if cfg.mainConfigFile == null then defaultCfgFile else cfg.mainConfigFile;
# Plain configuration for the Nagios web-interface with no
# authentication.
@@ -49,12 +57,12 @@ let
''
main_config_file=${cfg.mainConfigFile}
use_authentication=0
- url_html_path=${cfg.urlPath}
+ url_html_path=${urlPath}
'';
extraHttpdConfig =
''
- ScriptAlias ${cfg.urlPath}/cgi-bin ${pkgs.nagios}/sbin
+ ScriptAlias ${urlPath}/cgi-bin ${pkgs.nagios}/sbin
<Directory "${pkgs.nagios}/sbin">
Options ExecCGI
@@ -62,7 +70,7 @@ let
SetEnv NAGIOS_CGI_CONFIG ${cfg.cgiConfigFile}
</Directory>
- Alias ${cfg.urlPath} ${pkgs.nagios}/share
+ Alias ${urlPath} ${pkgs.nagios}/share
<Directory "${pkgs.nagios}/share">
Options None
@@ -72,16 +80,15 @@ let
in
{
+ imports = [
+ (mkRemovedOptionModule [ "services" "nagios" "urlPath" ] "The urlPath option has been removed as it is hard coded to /nagios in the nagios package.")
+ ];
+
+ meta.maintainers = with lib.maintainers; [ symphorien ];
+
options = {
services.nagios = {
- enable = mkOption {
- default = false;
- description = "
- Whether to use <link
- xlink:href='http://www.nagios.org/'>Nagios</link> to monitor
- your system or network.
- ";
- };
+ enable = mkEnableOption "<link xlink:href='http://www.nagios.org/'>Nagios</link> to monitor your system or network.";
objectDefs = mkOption {
description = "
@@ -89,12 +96,14 @@ in
the hosts, host groups, services and contacts for the
network that you want Nagios to monitor.
";
+ type = types.listOf types.path;
+ example = literalExample "[ ./objects.cfg ]";
};
plugins = mkOption {
type = types.listOf types.package;
- default = [pkgs.nagiosPluginsOfficial pkgs.ssmtp];
- defaultText = "[pkgs.nagiosPluginsOfficial pkgs.ssmtp]";
+ default = with pkgs; [ nagiosPluginsOfficial ssmtp mailutils ];
+ defaultText = "[pkgs.nagiosPluginsOfficial pkgs.ssmtp pkgs.mailutils]";
description = "
Packages to be added to the Nagios <envar>PATH</envar>.
Typically used to add plugins, but can be anything.
@@ -102,14 +111,29 @@ in
};
mainConfigFile = mkOption {
- type = types.package;
- default = nagiosCfgFile;
- defaultText = "nagiosCfgFile";
+ type = types.nullOr types.package;
+ default = null;
description = "
- Derivation for the main configuration file of Nagios.
+ If non-null, overrides the main configuration file of Nagios.
";
};
+ extraConfig = mkOption {
+ type = types.attrsOf types.str;
+ example = {
+ debug_level = "-1";
+ debug_file = "/var/log/nagios/debug.log";
+ };
+ default = {};
+ description = "Configuration to add to /etc/nagios.cfg";
+ };
+
+ validateConfig = mkOption {
+ type = types.bool;
+ default = pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform;
+ description = "if true, the syntax of the nagios configuration file is checked at build time";
+ };
+
cgiConfigFile = mkOption {
type = types.package;
default = nagiosCGICfgFile;
@@ -121,6 +145,7 @@ in
};
enableWebInterface = mkOption {
+ type = types.bool;
default = false;
description = "
Whether to enable the Nagios web interface. You should also
@@ -128,13 +153,20 @@ in
";
};
- urlPath = mkOption {
- default = "/nagios";
- description = "
- The URL path under which the Nagios web interface appears.
- That is, you can access the Nagios web interface through
- <literal>http://<replaceable>server</replaceable>/<replaceable>urlPath</replaceable></literal>.
- ";
+ virtualHost = mkOption {
+ type = types.submodule (import ../web-servers/apache-httpd/per-server-options.nix);
+ example = literalExample ''
+ { hostName = "example.org";
+ adminAddr = "webmaster@example.org";
+ enableSSL = true;
+ sslServerCert = "/var/lib/acme/example.org/full.pem";
+ sslServerKey = "/var/lib/acme/example.org/key.pem";
+ }
+ '';
+ description = ''
+ Apache configuration can be done by adapting <option>services.httpd.virtualHosts</option>.
+ See <xref linkend="opt-services.httpd.virtualHosts"/> for further information.
+ '';
};
};
};
@@ -152,16 +184,12 @@ in
# This isn't needed, it's just so that the user can type "nagiostats
# -c /etc/nagios.cfg".
- environment.etc = [
- { source = cfg.mainConfigFile;
- target = "nagios.cfg";
- }
- ];
+ environment.etc."nagios.cfg".source = nagiosCfgFile;
environment.systemPackages = [ pkgs.nagios ];
systemd.services.nagios = {
description = "Nagios monitoring daemon";
- path = [ pkgs.nagios ];
+ path = [ pkgs.nagios ] ++ cfg.plugins;
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
@@ -172,16 +200,13 @@ in
RestartSec = 2;
LogsDirectory = "nagios";
StateDirectory = "nagios";
+ ExecStart = "${pkgs.nagios}/bin/nagios /etc/nagios.cfg";
+ X-ReloadIfChanged = nagiosCfgFile;
};
-
- script = ''
- for i in ${toString cfg.plugins}; do
- export PATH=$i/bin:$i/sbin:$i/libexec:$PATH
- done
- exec ${pkgs.nagios}/bin/nagios ${cfg.mainConfigFile}
- '';
};
- services.httpd.extraConfig = optionalString cfg.enableWebInterface extraHttpdConfig;
+ services.httpd.virtualHosts = optionalAttrs cfg.enableWebInterface {
+ ${cfg.virtualHost.hostName} = mkMerge [ cfg.virtualHost { extraConfig = extraHttpdConfig; } ];
+ };
};
}
diff --git a/nixpkgs/nixos/modules/services/monitoring/netdata.nix b/nixpkgs/nixos/modules/services/monitoring/netdata.nix
index 3ffde8e9bce..f8225af2042 100644
--- a/nixpkgs/nixos/modules/services/monitoring/netdata.nix
+++ b/nixpkgs/nixos/modules/services/monitoring/netdata.nix
@@ -179,13 +179,14 @@ in {
{ domain = "netdata"; type = "hard"; item = "nofile"; value = "30000"; }
];
- users.users = optional (cfg.user == defaultUser) {
- name = defaultUser;
- isSystemUser = true;
+ users.users = optionalAttrs (cfg.user == defaultUser) {
+ ${defaultUser} = {
+ isSystemUser = true;
+ };
};
- users.groups = optional (cfg.group == defaultUser) {
- name = defaultUser;
+ users.groups = optionalAttrs (cfg.group == defaultUser) {
+ ${defaultUser} = { };
};
};
diff --git a/nixpkgs/nixos/modules/services/monitoring/prometheus/alertmanager.nix b/nixpkgs/nixos/modules/services/monitoring/prometheus/alertmanager.nix
index 11d85e9c4fc..9af6b1d94f3 100644
--- a/nixpkgs/nixos/modules/services/monitoring/prometheus/alertmanager.nix
+++ b/nixpkgs/nixos/modules/services/monitoring/prometheus/alertmanager.nix
@@ -27,6 +27,15 @@ let
"--log.format ${cfg.logFormat}"
);
in {
+ imports = [
+ (mkRemovedOptionModule [ "services" "prometheus" "alertmanager" "user" ] "The alertmanager service is now using systemd's DynamicUser mechanism which obviates a user setting.")
+ (mkRemovedOptionModule [ "services" "prometheus" "alertmanager" "group" ] "The alertmanager service is now using systemd's DynamicUser mechanism which obviates a group setting.")
+ (mkRemovedOptionModule [ "services" "prometheus" "alertmanagerURL" ] ''
+ Due to incompatibility, the alertmanagerURL option has been removed,
+ please use 'services.prometheus2.alertmanagers' instead.
+ '')
+ ];
+
options = {
services.prometheus.alertmanager = {
enable = mkEnableOption "Prometheus Alertmanager";
diff --git a/nixpkgs/nixos/modules/services/monitoring/prometheus/default.nix b/nixpkgs/nixos/modules/services/monitoring/prometheus/default.nix
index 191c0bff9c8..b67f697ca0d 100644
--- a/nixpkgs/nixos/modules/services/monitoring/prometheus/default.nix
+++ b/nixpkgs/nixos/modules/services/monitoring/prometheus/default.nix
@@ -464,6 +464,11 @@ let
};
in {
+
+ imports = [
+ (mkRenamedOptionModule [ "services" "prometheus2" ] [ "services" "prometheus" ])
+ ];
+
options.services.prometheus = {
enable = mkOption {
diff --git a/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters.nix b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters.nix
index 53f32b8fadc..36ebffa4463 100644
--- a/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters.nix
+++ b/nixpkgs/nixos/modules/services/monitoring/prometheus/exporters.nix
@@ -160,6 +160,24 @@ let
};
in
{
+
+ imports = (lib.forEach [ "blackboxExporter" "collectdExporter" "fritzboxExporter"
+ "jsonExporter" "minioExporter" "nginxExporter" "nodeExporter"
+ "snmpExporter" "unifiExporter" "varnishExporter" ]
+ (opt: lib.mkRemovedOptionModule [ "services" "prometheus" "${opt}" ] ''
+ The prometheus exporters are now configured using `services.prometheus.exporters'.
+ See the 18.03 release notes for more information.
+ '' ))
+
+ ++ (lib.forEach [ "enable" "substitutions" "preset" ]
+ (opt: lib.mkRemovedOptionModule [ "fonts" "fontconfig" "ultimate" "${opt}" ] ''
+ The fonts.fontconfig.ultimate module and configuration is obsolete.
+ The repository has since been archived and activity has ceased.
+ https://github.com/bohoomil/fontconfig-ultimate/issues/171.
+ No action should be needed for font configuration, as the fonts.fontconfig
+ module is already used by default.
+ '' ));
+
options.services.prometheus.exporters = mkOption {
type = types.submodule {
options = (mkSubModules);
diff --git a/nixpkgs/nixos/modules/services/monitoring/statsd.nix b/nixpkgs/nixos/modules/services/monitoring/statsd.nix
index ea155821ecc..17836e95a6f 100644
--- a/nixpkgs/nixos/modules/services/monitoring/statsd.nix
+++ b/nixpkgs/nixos/modules/services/monitoring/statsd.nix
@@ -125,8 +125,7 @@ in
message = "Only builtin backends (graphite, console, repeater) or backends enumerated in `pkgs.nodePackages` are allowed!";
}) cfg.backends;
- users.users = singleton {
- name = "statsd";
+ users.use.statsdrs = {
uid = config.ids.uids.statsd;
description = "Statsd daemon user";
};
diff --git a/nixpkgs/nixos/modules/services/monitoring/sysstat.nix b/nixpkgs/nixos/modules/services/monitoring/sysstat.nix
index d668faa53cc..ca2cff82723 100644
--- a/nixpkgs/nixos/modules/services/monitoring/sysstat.nix
+++ b/nixpkgs/nixos/modules/services/monitoring/sysstat.nix
@@ -5,15 +5,10 @@ let
in {
options = {
services.sysstat = {
- enable = mkOption {
- type = types.bool;
- default = false;
- description = ''
- Whether to enable sar system activity collection.
- '';
- };
+ enable = mkEnableOption "sar system activity collection";
collect-frequency = mkOption {
+ type = types.str;
default = "*:00/10";
description = ''
OnCalendar specification for sysstat-collect
@@ -21,6 +16,7 @@ in {
};
collect-args = mkOption {
+ type = types.str;
default = "1 1";
description = ''
Arguments to pass sa1 when collecting statistics
@@ -33,13 +29,13 @@ in {
systemd.services.sysstat = {
description = "Resets System Activity Logs";
wantedBy = [ "multi-user.target" ];
- preStart = "test -d /var/log/sa || mkdir -p /var/log/sa";
serviceConfig = {
User = "root";
RemainAfterExit = true;
Type = "oneshot";
ExecStart = "${pkgs.sysstat}/lib/sa/sa1 --boot";
+ LogsDirectory = "sa";
};
};
diff --git a/nixpkgs/nixos/modules/services/monitoring/telegraf.nix b/nixpkgs/nixos/modules/services/monitoring/telegraf.nix
index d8786732668..5d131557e8b 100644
--- a/nixpkgs/nixos/modules/services/monitoring/telegraf.nix
+++ b/nixpkgs/nixos/modules/services/monitoring/telegraf.nix
@@ -63,10 +63,9 @@ in {
};
};
- users.users = [{
- name = "telegraf";
+ users.users.telegraf = {
uid = config.ids.uids.telegraf;
description = "telegraf daemon user";
- }];
+ };
};
}
diff --git a/nixpkgs/nixos/modules/services/monitoring/ups.nix b/nixpkgs/nixos/modules/services/monitoring/ups.nix
index 1bdc4e4410f..a45e806d4ad 100644
--- a/nixpkgs/nixos/modules/services/monitoring/ups.nix
+++ b/nixpkgs/nixos/modules/services/monitoring/ups.nix
@@ -214,14 +214,12 @@ in
environment.NUT_STATEPATH = "/var/lib/nut/";
};
- environment.etc = [
- { source = pkgs.writeText "nut.conf"
+ environment.etc = {
+ "nut/nut.conf".source = pkgs.writeText "nut.conf"
''
MODE = ${cfg.mode}
'';
- target = "nut/nut.conf";
- }
- { source = pkgs.writeText "ups.conf"
+ "nut/ups.conf".source = pkgs.writeText "ups.conf"
''
maxstartdelay = ${toString cfg.maxStartDelay}
@@ -229,25 +227,15 @@ in
"}
'';
- target = "nut/ups.conf";
- }
- { source = cfg.schedulerRules;
- target = "nut/upssched.conf";
- }
+ "nut/upssched.conf".source = cfg.schedulerRules;
# These file are containing private informations and thus should not
# be stored inside the Nix store.
/*
- { source = ;
- target = "nut/upsd.conf";
- }
- { source = ;
- target = "nut/upsd.users";
- }
- { source = ;
- target = "nut/upsmon.conf;
- }
+ "nut/upsd.conf".source = "";
+ "nut/upsd.users".source = "";
+ "nut/upsmon.conf".source = "";
*/
- ];
+ };
power.ups.schedulerRules = mkDefault "${pkgs.nut}/etc/upssched.conf.sample";
@@ -259,21 +247,16 @@ in
/*
- users.users = [
- { name = "nut";
- uid = 84;
+ users.users.nut =
+ { uid = 84;
home = "/var/lib/nut";
createHome = true;
group = "nut";
description = "UPnP A/V Media Server user";
- }
- ];
-
- users.groups = [
- { name = "nut";
- gid = 84;
- }
- ];
+ };
+
+ users.groups."nut" =
+ { gid = 84; };
*/
};
diff --git a/nixpkgs/nixos/modules/services/monitoring/zabbix-server.nix b/nixpkgs/nixos/modules/services/monitoring/zabbix-server.nix
index e9f1590760a..b4e4378ce1e 100644
--- a/nixpkgs/nixos/modules/services/monitoring/zabbix-server.nix
+++ b/nixpkgs/nixos/modules/services/monitoring/zabbix-server.nix
@@ -44,6 +44,11 @@ let
in
{
+ imports = [
+ (lib.mkRenamedOptionModule [ "services" "zabbixServer" "dbServer" ] [ "services" "zabbixServer" "database" "host" ])
+ (lib.mkRemovedOptionModule [ "services" "zabbixServer" "dbPassword" ] "Use services.zabbixServer.database.passwordFile instead.")
+ ];
+
# interface
options = {
diff --git a/nixpkgs/nixos/modules/services/network-filesystems/ceph.nix b/nixpkgs/nixos/modules/services/network-filesystems/ceph.nix
index 543a7b25d5d..d17959a6a30 100644
--- a/nixpkgs/nixos/modules/services/network-filesystems/ceph.nix
+++ b/nixpkgs/nixos/modules/services/network-filesystems/ceph.nix
@@ -371,15 +371,14 @@ in
in
generators.toINI {} totalConfig;
- users.users = singleton {
- name = "ceph";
+ users.users.ceph = {
uid = config.ids.uids.ceph;
description = "Ceph daemon user";
group = "ceph";
extraGroups = [ "disk" ];
};
- users.groups = singleton {
- name = "ceph";
+
+ users.groups.ceph = {
gid = config.ids.gids.ceph;
};
diff --git a/nixpkgs/nixos/modules/services/network-filesystems/davfs2.nix b/nixpkgs/nixos/modules/services/network-filesystems/davfs2.nix
index 100d458d536..4b6f85e4a2c 100644
--- a/nixpkgs/nixos/modules/services/network-filesystems/davfs2.nix
+++ b/nixpkgs/nixos/modules/services/network-filesystems/davfs2.nix
@@ -57,18 +57,19 @@ in
environment.systemPackages = [ pkgs.davfs2 ];
environment.etc."davfs2/davfs2.conf".source = cfgFile;
- users.groups = optionalAttrs (cfg.davGroup == "davfs2") (singleton {
- name = "davfs2";
- gid = config.ids.gids.davfs2;
- });
+ users.groups = optionalAttrs (cfg.davGroup == "davfs2") {
+ davfs2.gid = config.ids.gids.davfs2;
+ };
+
+ users.users = optionalAttrs (cfg.davUser == "davfs2") {
+ davfs2 = {
+ createHome = false;
+ group = cfg.davGroup;
+ uid = config.ids.uids.davfs2;
+ description = "davfs2 user";
+ };
+ };
- users.users = optionalAttrs (cfg.davUser == "davfs2") (singleton {
- name = "davfs2";
- createHome = false;
- group = cfg.davGroup;
- uid = config.ids.uids.davfs2;
- description = "davfs2 user";
- });
};
}
diff --git a/nixpkgs/nixos/modules/services/network-filesystems/drbd.nix b/nixpkgs/nixos/modules/services/network-filesystems/drbd.nix
index 4ab74ed8e1c..916e7eaaaa9 100644
--- a/nixpkgs/nixos/modules/services/network-filesystems/drbd.nix
+++ b/nixpkgs/nixos/modules/services/network-filesystems/drbd.nix
@@ -47,10 +47,8 @@ let cfg = config.services.drbd; in
options drbd usermode_helper=/run/current-system/sw/bin/drbdadm
'';
- environment.etc = singleton
- { source = pkgs.writeText "drbd.conf" cfg.config;
- target = "drbd.conf";
- };
+ environment.etc.drbd.conf =
+ { source = pkgs.writeText "drbd.conf" cfg.config; };
systemd.services.drbd = {
after = [ "systemd-udev.settle.service" "network.target" ];
diff --git a/nixpkgs/nixos/modules/services/network-filesystems/nfsd.nix b/nixpkgs/nixos/modules/services/network-filesystems/nfsd.nix
index 1a78f9a76a3..1b62bfa8203 100644
--- a/nixpkgs/nixos/modules/services/network-filesystems/nfsd.nix
+++ b/nixpkgs/nixos/modules/services/network-filesystems/nfsd.nix
@@ -11,6 +11,10 @@ let
in
{
+ imports = [
+ (mkRenamedOptionModule [ "services" "nfs" "lockdPort" ] [ "services" "nfs" "server" "lockdPort" ])
+ (mkRenamedOptionModule [ "services" "nfs" "statdPort" ] [ "services" "nfs" "server" "statdPort" ])
+ ];
###### interface
diff --git a/nixpkgs/nixos/modules/services/network-filesystems/samba.nix b/nixpkgs/nixos/modules/services/network-filesystems/samba.nix
index 875ab70bfc7..a3c22ce6948 100644
--- a/nixpkgs/nixos/modules/services/network-filesystems/samba.nix
+++ b/nixpkgs/nixos/modules/services/network-filesystems/samba.nix
@@ -65,6 +65,9 @@ let
in
{
+ imports = [
+ (mkRemovedOptionModule [ "services" "samba" "defaultShare" ] "")
+ ];
###### interface
diff --git a/nixpkgs/nixos/modules/services/networking/3proxy.nix b/nixpkgs/nixos/modules/services/networking/3proxy.nix
new file mode 100644
index 00000000000..26aa1667946
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/networking/3proxy.nix
@@ -0,0 +1,424 @@
+{ config, lib, pkgs, ... }:
+with lib;
+let
+ pkg = pkgs._3proxy;
+ cfg = config.services._3proxy;
+ optionalList = list: if list == [ ] then "*" else concatMapStringsSep "," toString list;
+in {
+ options.services._3proxy = {
+ enable = mkEnableOption "3proxy";
+ confFile = mkOption {
+ type = types.path;
+ example = "/var/lib/3proxy/3proxy.conf";
+ description = ''
+ Ignore all other 3proxy options and load configuration from this file.
+ '';
+ };
+ usersFile = mkOption {
+ type = types.nullOr types.path;
+ default = null;
+ example = "/var/lib/3proxy/3proxy.passwd";
+ description = ''
+ Load users and passwords from this file.
+
+ Example users file with plain-text passwords:
+
+ <literal>
+ test1:CL:password1
+ test2:CL:password2
+ </literal>
+
+ Example users file with md5-crypted passwords:
+
+ <literal>
+ test1:CR:$1$tFkisVd2$1GA8JXkRmTXdLDytM/i3a1
+ test2:CR:$1$rkpibm5J$Aq1.9VtYAn0JrqZ8M.1ME.
+ </literal>
+
+ You can generate md5-crypted passwords via https://unix4lyfe.org/crypt/
+ Note that htpasswd tool generates incompatible md5-crypted passwords.
+ Consult <link xlink:href="https://github.com/z3APA3A/3proxy/wiki/How-To-(incomplete)#USERS">documentation</link> for more information.
+ '';
+ };
+ services = mkOption {
+ type = types.listOf (types.submodule {
+ options = {
+ type = mkOption {
+ type = types.enum [
+ "proxy"
+ "socks"
+ "pop3p"
+ "ftppr"
+ "admin"
+ "dnspr"
+ "tcppm"
+ "udppm"
+ ];
+ example = "proxy";
+ description = ''
+ Service type. The following values are valid:
+
+ <itemizedlist>
+ <listitem><para>
+ <literal>"proxy"</literal>: HTTP/HTTPS proxy (default port 3128).
+ </para></listitem>
+ <listitem><para>
+ <literal>"socks"</literal>: SOCKS 4/4.5/5 proxy (default port 1080).
+ </para></listitem>
+ <listitem><para>
+ <literal>"pop3p"</literal>: POP3 proxy (default port 110).
+ </para></listitem>
+ <listitem><para>
+ <literal>"ftppr"</literal>: FTP proxy (default port 21).
+ </para></listitem>
+ <listitem><para>
+ <literal>"admin"</literal>: Web interface (default port 80).
+ </para></listitem>
+ <listitem><para>
+ <literal>"dnspr"</literal>: Caching DNS proxy (default port 53).
+ </para></listitem>
+ <listitem><para>
+ <literal>"tcppm"</literal>: TCP portmapper.
+ </para></listitem>
+ <listitem><para>
+ <literal>"udppm"</literal>: UDP portmapper.
+ </para></listitem>
+ </itemizedlist>
+ '';
+ };
+ bindAddress = mkOption {
+ type = types.str;
+ default = "[::]";
+ example = "127.0.0.1";
+ description = ''
+ Address used for service.
+ '';
+ };
+ bindPort = mkOption {
+ type = types.nullOr types.int;
+ default = null;
+ example = 3128;
+ description = ''
+ Override default port used for service.
+ '';
+ };
+ maxConnections = mkOption {
+ type = types.int;
+ default = 100;
+ example = 1000;
+ description = ''
+ Maximum number of simulationeous connections to this service.
+ '';
+ };
+ auth = mkOption {
+ type = types.listOf (types.enum [ "none" "iponly" "strong" ]);
+ example = [ "iponly" "strong" ];
+ description = ''
+ Authentication type. The following values are valid:
+
+ <itemizedlist>
+ <listitem><para>
+ <literal>"none"</literal>: disables both authentication and authorization. You can not use ACLs.
+ </para></listitem>
+ <listitem><para>
+ <literal>"iponly"</literal>: specifies no authentication. ACLs authorization is used.
+ </para></listitem>
+ <listitem><para>
+ <literal>"strong"</literal>: authentication by username/password. If user is not registered his access is denied regardless of ACLs.
+ </para></listitem>
+ </itemizedlist>
+
+ Double authentication is possible, e.g.
+
+ <literal>
+ {
+ auth = [ "iponly" "strong" ];
+ acl = [
+ {
+ rule = "allow";
+ targets = [ "192.168.0.0/16" ];
+ }
+ {
+ rule = "allow"
+ users = [ "user1" "user2" ];
+ }
+ ];
+ }
+ </literal>
+ In this example strong username authentication is not required to access 192.168.0.0/16.
+ '';
+ };
+ acl = mkOption {
+ type = types.listOf (types.submodule {
+ options = {
+ rule = mkOption {
+ type = types.enum [ "allow" "deny" ];
+ example = "allow";
+ description = ''
+ ACL rule. The following values are valid:
+
+ <itemizedlist>
+ <listitem><para>
+ <literal>"allow"</literal>: connections allowed.
+ </para></listitem>
+ <listitem><para>
+ <literal>"deny"</literal>: connections not allowed.
+ </para></listitem>
+ </itemizedlist>
+ '';
+ };
+ users = mkOption {
+ type = types.listOf types.str;
+ default = [ ];
+ example = [ "user1" "user2" "user3" ];
+ description = ''
+ List of users, use empty list for any.
+ '';
+ };
+ sources = mkOption {
+ type = types.listOf types.str;
+ default = [ ];
+ example = [ "127.0.0.1" "192.168.1.0/24" ];
+ description = ''
+ List of source IP range, use empty list for any.
+ '';
+ };
+ targets = mkOption {
+ type = types.listOf types.str;
+ default = [ ];
+ example = [ "127.0.0.1" "192.168.1.0/24" ];
+ description = ''
+ List of target IP ranges, use empty list for any.
+ May also contain host names instead of addresses.
+ It's possible to use wildmask in the begginning and in the the end of hostname, e.g. *badsite.com or *badcontent*.
+ Hostname is only checked if hostname presents in request.
+ '';
+ };
+ targetPorts = mkOption {
+ type = types.listOf types.int;
+ default = [ ];
+ example = [ 80 443 ];
+ description = ''
+ List of target ports, use empty list for any.
+ '';
+ };
+ };
+ });
+ default = [ ];
+ example = literalExample ''
+ [
+ {
+ rule = "allow";
+ users = [ "user1" ];
+ }
+ {
+ rule = "allow";
+ sources = [ "192.168.1.0/24" ];
+ }
+ {
+ rule = "deny";
+ }
+ ]
+ '';
+ description = ''
+ Use this option to limit user access to resources.
+ '';
+ };
+ extraArguments = mkOption {
+ type = types.nullOr types.str;
+ default = null;
+ example = "-46";
+ description = ''
+ Extra arguments for service.
+ Consult "Options" section in <link xlink:href="https://github.com/z3APA3A/3proxy/wiki/3proxy.cfg">documentation</link> for available arguments.
+ '';
+ };
+ extraConfig = mkOption {
+ type = types.nullOr types.lines;
+ default = null;
+ description = ''
+ Extra configuration for service. Use this to configure things like bandwidth limiter or ACL-based redirection.
+ Consult <link xlink:href="https://github.com/z3APA3A/3proxy/wiki/3proxy.cfg">documentation</link> for available options.
+ '';
+ };
+ };
+ });
+ default = [ ];
+ example = literalExample ''
+ [
+ {
+ type = "proxy";
+ bindAddress = "192.168.1.24";
+ bindPort = 3128;
+ auth = [ "none" ];
+ }
+ {
+ type = "proxy";
+ bindAddress = "10.10.1.20";
+ bindPort = 3128;
+ auth = [ "iponly" ];
+ }
+ {
+ type = "socks";
+ bindAddress = "172.17.0.1";
+ bindPort = 1080;
+ auth = [ "strong" ];
+ }
+ ]
+ '';
+ description = ''
+ Use this option to define 3proxy services.
+ '';
+ };
+ denyPrivate = mkOption {
+ type = types.bool;
+ default = true;
+ description = ''
+ Whether to deny access to private IP ranges including loopback.
+ '';
+ };
+ privateRanges = mkOption {
+ type = types.listOf types.str;
+ default = [
+ "0.0.0.0/8"
+ "127.0.0.0/8"
+ "10.0.0.0/8"
+ "100.64.0.0/10"
+ "172.16.0.0/12"
+ "192.168.0.0/16"
+ "::"
+ "::1"
+ "fc00::/7"
+ ];
+ example = [
+ "0.0.0.0/8"
+ "127.0.0.0/8"
+ "10.0.0.0/8"
+ "100.64.0.0/10"
+ "172.16.0.0/12"
+ "192.168.0.0/16"
+ "::"
+ "::1"
+ "fc00::/7"
+ ];
+ description = ''
+ What IP ranges to deny access when denyPrivate is set tu true.
+ '';
+ };
+ resolution = mkOption {
+ type = types.submodule {
+ options = {
+ nserver = mkOption {
+ type = types.listOf types.str;
+ default = [ ];
+ example = [ "127.0.0.53" "192.168.1.3:5353/tcp" ];
+ description = ''
+ List of nameservers to use.
+
+ Up to 5 nservers may be specified. If no nserver is configured,
+ default system name resolution functions are used.
+ '';
+ };
+ nscache = mkOption {
+ type = types.int;
+ default = 65535;
+ example = 65535;
+ description = "Set name cache size for IPv4.";
+ };
+ nscache6 = mkOption {
+ type = types.int;
+ default = 65535;
+ example = 65535;
+ description = "Set name cache size for IPv6.";
+ };
+ nsrecord = mkOption {
+ type = types.attrsOf types.str;
+ default = { };
+ example = {
+ "files.local" = "192.168.1.12";
+ "site.local" = "192.168.1.43";
+ };
+ description = "Adds static nsrecords.";
+ };
+ };
+ };
+ default = { };
+ description = ''
+ Use this option to configure name resolution and DNS caching.
+ '';
+ };
+ extraConfig = mkOption {
+ type = types.nullOr types.lines;
+ default = null;
+ description = ''
+ Extra configuration, appended to the 3proxy configuration file.
+ Consult <link xlink:href="https://github.com/z3APA3A/3proxy/wiki/3proxy.cfg">documentation</link> for available options.
+ '';
+ };
+ };
+
+ config = mkIf cfg.enable {
+ services._3proxy.confFile = mkDefault (pkgs.writeText "3proxy.conf" ''
+ # log to stdout
+ log
+
+ ${concatMapStringsSep "\n" (x: "nserver " + x) cfg.resolution.nserver}
+
+ nscache ${toString cfg.resolution.nscache}
+ nscache6 ${toString cfg.resolution.nscache6}
+
+ ${concatMapStringsSep "\n" (x: "nsrecord " + x)
+ (mapAttrsToList (name: value: "${name} ${value}")
+ cfg.resolution.nsrecord)}
+
+ ${optionalString (cfg.usersFile != null)
+ ''users $"${cfg.usersFile}"''
+ }
+
+ ${concatMapStringsSep "\n" (service: ''
+ auth ${concatStringsSep " " service.auth}
+
+ ${optionalString (cfg.denyPrivate)
+ "deny * * ${optionalList cfg.privateRanges}"}
+
+ ${concatMapStringsSep "\n" (acl:
+ "${acl.rule} ${
+ concatMapStringsSep " " optionalList [
+ acl.users
+ acl.sources
+ acl.targets
+ acl.targetPorts
+ ]
+ }") service.acl}
+
+ maxconn ${toString service.maxConnections}
+
+ ${optionalString (service.extraConfig != null) service.extraConfig}
+
+ ${service.type} -i${toString service.bindAddress} ${
+ optionalString (service.bindPort != null)
+ "-p${toString service.bindPort}"
+ } ${
+ optionalString (service.extraArguments != null) service.extraArguments
+ }
+
+ flush
+ '') cfg.services}
+ ${optionalString (cfg.extraConfig != null) cfg.extraConfig}
+ '');
+ systemd.services."3proxy" = {
+ description = "Tiny free proxy server";
+ documentation = [ "https://github.com/z3APA3A/3proxy/wiki" ];
+ after = [ "network.target" ];
+ wantedBy = [ "multi-user.target" ];
+ serviceConfig = {
+ DynamicUser = true;
+ StateDirectory = "3proxy";
+ ExecStart = "${pkg}/bin/3proxy ${cfg.confFile}";
+ Restart = "on-failure";
+ };
+ };
+ };
+
+ meta.maintainers = with maintainers; [ misuzu ];
+}
diff --git a/nixpkgs/nixos/modules/services/networking/bind.nix b/nixpkgs/nixos/modules/services/networking/bind.nix
index d09c6735e12..e3b95afb3d8 100644
--- a/nixpkgs/nixos/modules/services/networking/bind.nix
+++ b/nixpkgs/nixos/modules/services/networking/bind.nix
@@ -178,9 +178,8 @@ in
networking.resolvconf.useLocalResolver = mkDefault true;
- users.users = singleton
- { name = bindUser;
- uid = config.ids.uids.bind;
+ users.users.${bindUser} =
+ { uid = config.ids.uids.bind;
description = "BIND daemon user";
};
diff --git a/nixpkgs/nixos/modules/services/networking/bitlbee.nix b/nixpkgs/nixos/modules/services/networking/bitlbee.nix
index 274b3617160..54fe70f7ccc 100644
--- a/nixpkgs/nixos/modules/services/networking/bitlbee.nix
+++ b/nixpkgs/nixos/modules/services/networking/bitlbee.nix
@@ -161,8 +161,7 @@ in
config = mkMerge [
(mkIf config.services.bitlbee.enable {
- users.users = singleton {
- name = "bitlbee";
+ users.users.bitlbee = {
uid = bitlbeeUid;
description = "BitlBee user";
home = "/var/lib/bitlbee";
diff --git a/nixpkgs/nixos/modules/services/networking/charybdis.nix b/nixpkgs/nixos/modules/services/networking/charybdis.nix
index da26246e703..43829d36e41 100644
--- a/nixpkgs/nixos/modules/services/networking/charybdis.nix
+++ b/nixpkgs/nixos/modules/services/networking/charybdis.nix
@@ -71,15 +71,13 @@ in
config = mkIf cfg.enable (lib.mkMerge [
{
- users.users = singleton {
- name = cfg.user;
+ users.users.${cfg.user} = {
description = "Charybdis IRC daemon user";
uid = config.ids.uids.ircd;
group = cfg.group;
};
- users.groups = singleton {
- name = cfg.group;
+ users.groups.${cfg.group} = {
gid = config.ids.gids.ircd;
};
diff --git a/nixpkgs/nixos/modules/services/networking/connman.nix b/nixpkgs/nixos/modules/services/networking/connman.nix
index cac517f410e..e8eadc4e187 100644
--- a/nixpkgs/nixos/modules/services/networking/connman.nix
+++ b/nixpkgs/nixos/modules/services/networking/connman.nix
@@ -11,8 +11,13 @@ let
${cfg.extraConfig}
'';
+ enableIwd = cfg.wifi.backend == "iwd";
in {
+ imports = [
+ (mkRenamedOptionModule [ "networking" "connman" ] [ "services" "connman" ])
+ ];
+
###### interface
options = {
@@ -52,6 +57,17 @@ in {
'';
};
+ wifi = {
+ backend = mkOption {
+ type = types.enum [ "wpa_supplicant" "iwd" ];
+ default = "wpa_supplicant";
+ description = ''
+ Specify the Wi-Fi backend used.
+ Currently supported are <option>wpa_supplicant</option> or <option>iwd</option>.
+ '';
+ };
+ };
+
extraFlags = mkOption {
type = with types; listOf str;
default = [ ];
@@ -73,9 +89,6 @@ in {
assertion = !config.networking.useDHCP;
message = "You can not use services.connman with networking.useDHCP";
}{
- assertion = config.networking.wireless.enable;
- message = "You must use services.connman with networking.wireless";
- }{
assertion = !config.networking.networkmanager.enable;
message = "You can not use services.connman with networking.networkmanager";
}];
@@ -85,12 +98,18 @@ in {
systemd.services.connman = {
description = "Connection service";
wantedBy = [ "multi-user.target" ];
- after = [ "syslog.target" ];
+ after = [ "syslog.target" ] ++ optional enableIwd "iwd.service";
+ requires = optional enableIwd "iwd.service";
serviceConfig = {
Type = "dbus";
BusName = "net.connman";
Restart = "on-failure";
- ExecStart = "${pkgs.connman}/sbin/connmand --config=${configFile} --nodaemon ${toString cfg.extraFlags}";
+ ExecStart = toString ([
+ "${pkgs.connman}/sbin/connmand"
+ "--config=${configFile}"
+ "--nodaemon"
+ ] ++ optional enableIwd "--wifi=iwd_agent"
+ ++ cfg.extraFlags);
StandardOutput = "null";
};
};
@@ -121,7 +140,12 @@ in {
networking = {
useDHCP = false;
- wireless.enable = true;
+ wireless = {
+ enable = mkIf (!enableIwd) true;
+ iwd = mkIf enableIwd {
+ enable = true;
+ };
+ };
networkmanager.enable = false;
};
};
diff --git a/nixpkgs/nixos/modules/services/networking/coturn.nix b/nixpkgs/nixos/modules/services/networking/coturn.nix
index c430ce5af92..1bfbc307c59 100644
--- a/nixpkgs/nixos/modules/services/networking/coturn.nix
+++ b/nixpkgs/nixos/modules/services/networking/coturn.nix
@@ -294,16 +294,14 @@ in {
};
config = mkIf cfg.enable {
- users.users = [
- { name = "turnserver";
- uid = config.ids.uids.turnserver;
+ users.users.turnserver =
+ { uid = config.ids.uids.turnserver;
description = "coturn TURN server user";
- } ];
- users.groups = [
- { name = "turnserver";
- gid = config.ids.gids.turnserver;
+ };
+ users.groups.turnserver =
+ { gid = config.ids.gids.turnserver;
members = [ "turnserver" ];
- } ];
+ };
systemd.services.coturn = {
description = "coturn TURN server";
diff --git a/nixpkgs/nixos/modules/services/networking/ddclient.nix b/nixpkgs/nixos/modules/services/networking/ddclient.nix
index 04ce5ca3a87..053efe71270 100644
--- a/nixpkgs/nixos/modules/services/networking/ddclient.nix
+++ b/nixpkgs/nixos/modules/services/networking/ddclient.nix
@@ -30,6 +30,14 @@ with lib;
{
+ imports = [
+ (mkChangedOptionModule [ "services" "ddclient" "domain" ] [ "services" "ddclient" "domains" ]
+ (config:
+ let value = getAttrFromPath [ "services" "ddclient" "domain" ] config;
+ in if value != "" then [ value ] else []))
+ (mkRemovedOptionModule [ "services" "ddclient" "homeDir" ] "")
+ ];
+
###### interface
options = {
diff --git a/nixpkgs/nixos/modules/services/networking/dhcpcd.nix b/nixpkgs/nixos/modules/services/networking/dhcpcd.nix
index 7b278603455..6fbc014db71 100644
--- a/nixpkgs/nixos/modules/services/networking/dhcpcd.nix
+++ b/nixpkgs/nixos/modules/services/networking/dhcpcd.nix
@@ -185,11 +185,7 @@ in
environment.systemPackages = [ dhcpcd ];
- environment.etc =
- [ { source = exitHook;
- target = "dhcpcd.exit-hook";
- }
- ];
+ environment.etc."dhcpcd.exit-hook".source = exitHook;
powerManagement.resumeCommands = mkIf config.systemd.services.dhcpcd.enable
''
diff --git a/nixpkgs/nixos/modules/services/networking/dhcpd.nix b/nixpkgs/nixos/modules/services/networking/dhcpd.nix
index 0b2063bc424..67f7d811887 100644
--- a/nixpkgs/nixos/modules/services/networking/dhcpd.nix
+++ b/nixpkgs/nixos/modules/services/networking/dhcpd.nix
@@ -182,6 +182,10 @@ in
{
+ imports = [
+ (mkRenamedOptionModule [ "services" "dhcpd" ] [ "services" "dhcpd4" ])
+ ];
+
###### interface
options = {
diff --git a/nixpkgs/nixos/modules/services/networking/dnschain.nix b/nixpkgs/nixos/modules/services/networking/dnschain.nix
index b837bf816a1..003609ea705 100644
--- a/nixpkgs/nixos/modules/services/networking/dnschain.nix
+++ b/nixpkgs/nixos/modules/services/networking/dnschain.nix
@@ -147,8 +147,7 @@ in
'';
};
- users.users = singleton {
- name = username;
+ users.users.${username} = {
description = "DNSChain daemon user";
home = dataDir;
createHome = true;
@@ -180,4 +179,6 @@ in
};
+ meta.maintainers = with lib.maintainers; [ rnhmjoj ];
+
}
diff --git a/nixpkgs/nixos/modules/services/networking/dnscrypt-wrapper.nix b/nixpkgs/nixos/modules/services/networking/dnscrypt-wrapper.nix
index 79f9e1a4308..e53fb7a1578 100644
--- a/nixpkgs/nixos/modules/services/networking/dnscrypt-wrapper.nix
+++ b/nixpkgs/nixos/modules/services/networking/dnscrypt-wrapper.nix
@@ -197,4 +197,7 @@ in {
};
};
+
+ meta.maintainers = with lib.maintainers; [ rnhmjoj ];
+
}
diff --git a/nixpkgs/nixos/modules/services/networking/dnsmasq.nix b/nixpkgs/nixos/modules/services/networking/dnsmasq.nix
index 714a5903bff..377d7bc5705 100644
--- a/nixpkgs/nixos/modules/services/networking/dnsmasq.nix
+++ b/nixpkgs/nixos/modules/services/networking/dnsmasq.nix
@@ -86,8 +86,7 @@ in
services.dbus.packages = [ dnsmasq ];
- users.users = singleton {
- name = "dnsmasq";
+ users.users.dnsmasq = {
uid = config.ids.uids.dnsmasq;
description = "Dnsmasq daemon user";
};
diff --git a/nixpkgs/nixos/modules/services/networking/ejabberd.nix b/nixpkgs/nixos/modules/services/networking/ejabberd.nix
index 6a38f85c48a..a5af25b983b 100644
--- a/nixpkgs/nixos/modules/services/networking/ejabberd.nix
+++ b/nixpkgs/nixos/modules/services/networking/ejabberd.nix
@@ -94,18 +94,18 @@ in {
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
- users.users = optionalAttrs (cfg.user == "ejabberd") (singleton
- { name = "ejabberd";
+ users.users = optionalAttrs (cfg.user == "ejabberd") {
+ ejabberd = {
group = cfg.group;
home = cfg.spoolDir;
createHome = true;
uid = config.ids.uids.ejabberd;
- });
+ };
+ };
- users.groups = optionalAttrs (cfg.group == "ejabberd") (singleton
- { name = "ejabberd";
- gid = config.ids.gids.ejabberd;
- });
+ users.groups = optionalAttrs (cfg.group == "ejabberd") {
+ ejabberd.gid = config.ids.gids.ejabberd;
+ };
systemd.services.ejabberd = {
description = "ejabberd server";
diff --git a/nixpkgs/nixos/modules/services/networking/fakeroute.nix b/nixpkgs/nixos/modules/services/networking/fakeroute.nix
index 82a9fb729d8..7916ad4098a 100644
--- a/nixpkgs/nixos/modules/services/networking/fakeroute.nix
+++ b/nixpkgs/nixos/modules/services/networking/fakeroute.nix
@@ -60,4 +60,6 @@ in
};
+ meta.maintainers = with lib.maintainers; [ rnhmjoj ];
+
}
diff --git a/nixpkgs/nixos/modules/services/networking/firewall.nix b/nixpkgs/nixos/modules/services/networking/firewall.nix
index 5919962837a..15aaf741067 100644
--- a/nixpkgs/nixos/modules/services/networking/firewall.nix
+++ b/nixpkgs/nixos/modules/services/networking/firewall.nix
@@ -42,16 +42,7 @@ let
kernelHasRPFilter = ((kernel.config.isEnabled or (x: false)) "IP_NF_MATCH_RPFILTER") || (kernel.features.netfilterRPFilter or false);
- helpers =
- ''
- # Helper command to manipulate both the IPv4 and IPv6 tables.
- ip46tables() {
- iptables -w "$@"
- ${optionalString config.networking.enableIPv6 ''
- ip6tables -w "$@"
- ''}
- }
- '';
+ helpers = import ./helpers.nix { inherit config lib; };
writeShScript = name: text: let dir = pkgs.writeScriptBin name ''
#! ${pkgs.runtimeShell} -e
@@ -271,7 +262,7 @@ let
apply = canonicalizePortList;
example = [ 22 80 ];
description =
- ''
+ ''
List of TCP ports on which incoming connections are
accepted.
'';
@@ -282,7 +273,7 @@ let
default = [ ];
example = [ { from = 8999; to = 9003; } ];
description =
- ''
+ ''
A range of TCP ports on which incoming connections are
accepted.
'';
diff --git a/nixpkgs/nixos/modules/services/networking/gale.nix b/nixpkgs/nixos/modules/services/networking/gale.nix
index 7083d87c407..cb954fd836b 100644
--- a/nixpkgs/nixos/modules/services/networking/gale.nix
+++ b/nixpkgs/nixos/modules/services/networking/gale.nix
@@ -104,14 +104,13 @@ in
systemPackages = [ pkgs.gale ];
};
- users.users = [{
- name = cfg.user;
+ users.users.${cfg.user} = {
description = "Gale daemon";
uid = config.ids.uids.gale;
group = cfg.group;
home = home;
createHome = true;
- }];
+ };
users.groups = [{
name = cfg.group;
diff --git a/nixpkgs/nixos/modules/services/networking/git-daemon.nix b/nixpkgs/nixos/modules/services/networking/git-daemon.nix
index a638a3083fb..6f2e149433f 100644
--- a/nixpkgs/nixos/modules/services/networking/git-daemon.nix
+++ b/nixpkgs/nixos/modules/services/networking/git-daemon.nix
@@ -104,16 +104,16 @@ in
config = mkIf cfg.enable {
- users.users = if cfg.user != "git" then {} else singleton
- { name = "git";
+ users.users = optionalAttrs (cfg.user != "git") {
+ git = {
uid = config.ids.uids.git;
description = "Git daemon user";
};
+ };
- users.groups = if cfg.group != "git" then {} else singleton
- { name = "git";
- gid = config.ids.gids.git;
- };
+ users.groups = optionalAttrs (cfg.group != "git") {
+ git.gid = config.ids.gids.git;
+ };
systemd.services.git-daemon = {
after = [ "network.target" ];
diff --git a/nixpkgs/nixos/modules/services/networking/gnunet.nix b/nixpkgs/nixos/modules/services/networking/gnunet.nix
index 178a832c166..69d4ed04775 100644
--- a/nixpkgs/nixos/modules/services/networking/gnunet.nix
+++ b/nixpkgs/nixos/modules/services/networking/gnunet.nix
@@ -42,6 +42,7 @@ in
services.gnunet = {
enable = mkOption {
+ type = types.bool;
default = false;
description = ''
Whether to run the GNUnet daemon. GNUnet is GNU's anonymous
@@ -51,6 +52,7 @@ in
fileSharing = {
quota = mkOption {
+ type = types.int;
default = 1024;
description = ''
Maximum file system usage (in MiB) for file sharing.
@@ -60,6 +62,7 @@ in
udp = {
port = mkOption {
+ type = types.port;
default = 2086; # assigned by IANA
description = ''
The UDP port for use by GNUnet.
@@ -69,6 +72,7 @@ in
tcp = {
port = mkOption {
+ type = types.port;
default = 2086; # assigned by IANA
description = ''
The TCP port for use by GNUnet.
@@ -78,6 +82,7 @@ in
load = {
maxNetDownBandwidth = mkOption {
+ type = types.int;
default = 50000;
description = ''
Maximum bandwidth usage (in bits per second) for GNUnet
@@ -86,6 +91,7 @@ in
};
maxNetUpBandwidth = mkOption {
+ type = types.int;
default = 50000;
description = ''
Maximum bandwidth usage (in bits per second) for GNUnet
@@ -94,6 +100,7 @@ in
};
hardNetUpBandwidth = mkOption {
+ type = types.int;
default = 0;
description = ''
Hard bandwidth limit (in bits per second) when uploading
@@ -111,6 +118,7 @@ in
};
extraOptions = mkOption {
+ type = types.lines;
default = "";
description = ''
Additional options that will be copied verbatim in `gnunet.conf'.
diff --git a/nixpkgs/nixos/modules/services/networking/hans.nix b/nixpkgs/nixos/modules/services/networking/hans.nix
index 4f60300f5ff..8334dc68d62 100644
--- a/nixpkgs/nixos/modules/services/networking/hans.nix
+++ b/nixpkgs/nixos/modules/services/networking/hans.nix
@@ -135,8 +135,7 @@ in
};
};
- users.users = singleton {
- name = hansUser;
+ users.users.${hansUser} = {
description = "Hans daemon user";
isSystemUser = true;
};
diff --git a/nixpkgs/nixos/modules/services/networking/helpers.nix b/nixpkgs/nixos/modules/services/networking/helpers.nix
new file mode 100644
index 00000000000..d7d42de0e3a
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/networking/helpers.nix
@@ -0,0 +1,11 @@
+{ config, lib, ... }: ''
+ # Helper command to manipulate both the IPv4 and IPv6 tables.
+ ip46tables() {
+ iptables -w "$@"
+ ${
+ lib.optionalString config.networking.enableIPv6 ''
+ ip6tables -w "$@"
+ ''
+ }
+ }
+''
diff --git a/nixpkgs/nixos/modules/services/networking/i2pd.nix b/nixpkgs/nixos/modules/services/networking/i2pd.nix
index f2be417738e..326d34f6ca9 100644
--- a/nixpkgs/nixos/modules/services/networking/i2pd.nix
+++ b/nixpkgs/nixos/modules/services/networking/i2pd.nix
@@ -158,10 +158,10 @@ let
(sec "addressbook")
(strOpt "defaulturl" cfg.addressbook.defaulturl)
] ++ (optionalEmptyList "subscriptions" cfg.addressbook.subscriptions)
- ++ (flip map
- (collect (proto: proto ? port && proto ? address && proto ? name) cfg.proto)
+ ++ (flip mapAttrs
+ (collect (name: proto: proto ? port && proto ? address && proto ? name) cfg.proto)
(proto: let protoOpts = [
- (sec proto.name)
+ (sec name)
(boolOpt "enabled" proto.enable)
(strOpt "address" proto.address)
(intOpt "port" proto.port)
@@ -181,10 +181,10 @@ let
tunnelConf = let opts = [
notice
- (flip map
- (collect (tun: tun ? port && tun ? destination) cfg.outTunnels)
+ (flip mapAttrs
+ (collect (name: tun: tun ? port && tun ? destination) cfg.outTunnels)
(tun: let outTunOpts = [
- (sec tun.name)
+ (sec name)
"type = client"
(intOpt "port" tun.port)
(strOpt "destination" tun.destination)
@@ -204,10 +204,10 @@ let
++ (if tun ? crypto.tagsToSend then
optionalNullInt "crypto.tagstosend" tun.crypto.tagsToSend else []);
in concatStringsSep "\n" outTunOpts))
- (flip map
- (collect (tun: tun ? port && tun ? address) cfg.inTunnels)
+ (flip mapAttrs
+ (collect (name: tun: tun ? port && tun ? address) cfg.inTunnels)
(tun: let inTunOpts = [
- (sec tun.name)
+ (sec name)
"type = server"
(intOpt "port" tun.port)
(strOpt "host" tun.address)
@@ -235,6 +235,10 @@ in
{
+ imports = [
+ (mkRenamedOptionModule [ "services" "i2pd" "extIp" ] [ "services" "i2pd" "address" ])
+ ];
+
###### interface
options = {
diff --git a/nixpkgs/nixos/modules/services/networking/iodine.nix b/nixpkgs/nixos/modules/services/networking/iodine.nix
index 344f84374bb..f9ca26c2796 100644
--- a/nixpkgs/nixos/modules/services/networking/iodine.nix
+++ b/nixpkgs/nixos/modules/services/networking/iodine.nix
@@ -11,6 +11,13 @@ let
in
{
+ imports = [
+ (mkRenamedOptionModule [ "services" "iodined" "enable" ] [ "services" "iodine" "server" "enable" ])
+ (mkRenamedOptionModule [ "services" "iodined" "domain" ] [ "services" "iodine" "server" "domain" ])
+ (mkRenamedOptionModule [ "services" "iodined" "ip" ] [ "services" "iodine" "server" "ip" ])
+ (mkRenamedOptionModule [ "services" "iodined" "extraConfig" ] [ "services" "iodine" "server" "extraConfig" ])
+ (mkRemovedOptionModule [ "services" "iodined" "client" ] "")
+ ];
### configuration
@@ -140,8 +147,7 @@ in
};
};
- users.users = singleton {
- name = iodinedUser;
+ users.users.${iodinedUser} = {
uid = config.ids.uids.iodined;
description = "Iodine daemon user";
};
diff --git a/nixpkgs/nixos/modules/services/networking/ircd-hybrid/default.nix b/nixpkgs/nixos/modules/services/networking/ircd-hybrid/default.nix
index f5abe61a1ba..b236552eb65 100644
--- a/nixpkgs/nixos/modules/services/networking/ircd-hybrid/default.nix
+++ b/nixpkgs/nixos/modules/services/networking/ircd-hybrid/default.nix
@@ -112,9 +112,8 @@ in
config = mkIf config.services.ircdHybrid.enable {
- users.users = singleton
- { name = "ircd";
- description = "IRCD owner";
+ users.users.ircd =
+ { description = "IRCD owner";
group = "ircd";
uid = config.ids.uids.ircd;
};
diff --git a/nixpkgs/nixos/modules/services/networking/kippo.nix b/nixpkgs/nixos/modules/services/networking/kippo.nix
index bdea6a1d1ca..553415a2f32 100644
--- a/nixpkgs/nixos/modules/services/networking/kippo.nix
+++ b/nixpkgs/nixos/modules/services/networking/kippo.nix
@@ -73,12 +73,11 @@ in
${cfg.extraConfig}
'';
- users.users = singleton {
- name = "kippo";
+ users.users.kippo = {
description = "kippo web server privilege separation user";
uid = 108; # why does config.ids.uids.kippo give an error?
};
- users.groups = singleton { name = "kippo";gid=108; };
+ users.groups.kippo.gid = 108;
systemd.services.kippo = with pkgs; {
description = "Kippo Web Server";
diff --git a/nixpkgs/nixos/modules/services/networking/kresd.nix b/nixpkgs/nixos/modules/services/networking/kresd.nix
index fc516c01230..5eb50a13ca9 100644
--- a/nixpkgs/nixos/modules/services/networking/kresd.nix
+++ b/nixpkgs/nixos/modules/services/networking/kresd.nix
@@ -13,6 +13,17 @@ in
{
meta.maintainers = [ maintainers.vcunat /* upstream developer */ ];
+ imports = [
+ (mkChangedOptionModule [ "services" "kresd" "interfaces" ] [ "services" "kresd" "listenPlain" ]
+ (config:
+ let value = getAttrFromPath [ "services" "kresd" "interfaces" ] config;
+ in map
+ (iface: if elem ":" (stringToCharacters iface) then "[${iface}]:53" else "${iface}:53") # Syntax depends on being IPv6 or IPv4.
+ value
+ )
+ )
+ ];
+
###### interface
options.services.kresd = {
enable = mkOption {
@@ -39,11 +50,12 @@ in
Directory for caches. They are intended to survive reboots.
'';
};
- interfaces = mkOption {
+ listenPlain = mkOption {
type = with types; listOf str;
- default = [ "::1" "127.0.0.1" ];
+ default = [ "[::1]:53" "127.0.0.1:53" ];
description = ''
- What addresses the server should listen on. (UDP+TCP 53)
+ What addresses and ports the server should listen on.
+ For detailed syntax see ListenStream in man systemd.socket.
'';
};
listenTLS = mkOption {
@@ -51,7 +63,7 @@ in
default = [];
example = [ "198.51.100.1:853" "[2001:db8::1]:853" "853" ];
description = ''
- Addresses on which kresd should provide DNS over TLS (see RFC 7858).
+ Addresses and ports on which kresd should provide DNS over TLS (see RFC 7858).
For detailed syntax see ListenStream in man systemd.socket.
'';
};
@@ -62,24 +74,17 @@ in
config = mkIf cfg.enable {
environment.etc."kresd.conf".source = configFile; # not required
- users.users = singleton
- { name = "kresd";
- uid = config.ids.uids.kresd;
+ users.users.kresd =
+ { uid = config.ids.uids.kresd;
group = "kresd";
description = "Knot-resolver daemon user";
};
- users.groups = singleton
- { name = "kresd";
- gid = config.ids.gids.kresd;
- };
+ users.groups.kresd.gid = config.ids.gids.kresd;
systemd.sockets.kresd = rec {
wantedBy = [ "sockets.target" ];
before = wantedBy;
- listenStreams = map
- # Syntax depends on being IPv6 or IPv4.
- (iface: if elem ":" (stringToCharacters iface) then "[${iface}]:53" else "${iface}:53")
- cfg.interfaces;
+ listenStreams = cfg.listenPlain;
socketConfig = {
ListenDatagram = listenStreams;
FreeBind = true;
diff --git a/nixpkgs/nixos/modules/services/networking/matterbridge.nix b/nixpkgs/nixos/modules/services/networking/matterbridge.nix
index 682eaa6eb29..bad35133459 100644
--- a/nixpkgs/nixos/modules/services/networking/matterbridge.nix
+++ b/nixpkgs/nixos/modules/services/networking/matterbridge.nix
@@ -92,14 +92,15 @@ in
warnings = optional options.services.matterbridge.configFile.isDefined
"The option services.matterbridge.configFile is insecure and should be replaced with services.matterbridge.configPath";
- users.users = optional (cfg.user == "matterbridge")
- { name = "matterbridge";
- group = "matterbridge";
- isSystemUser = true;
+ users.users = optionalAttrs (cfg.user == "matterbridge")
+ { matterbridge = {
+ group = "matterbridge";
+ isSystemUser = true;
+ };
};
- users.groups = optional (cfg.group == "matterbridge")
- { name = "matterbridge";
+ users.groups = optionalAttrs (cfg.group == "matterbridge")
+ { matterbridge = { };
};
systemd.services.matterbridge = {
diff --git a/nixpkgs/nixos/modules/services/networking/mjpg-streamer.nix b/nixpkgs/nixos/modules/services/networking/mjpg-streamer.nix
index e0a6c112e3c..dbc35e2e71c 100644
--- a/nixpkgs/nixos/modules/services/networking/mjpg-streamer.nix
+++ b/nixpkgs/nixos/modules/services/networking/mjpg-streamer.nix
@@ -49,10 +49,11 @@ in {
config = mkIf cfg.enable {
- users.users = optional (cfg.user == "mjpg-streamer") {
- name = "mjpg-streamer";
- uid = config.ids.uids.mjpg-streamer;
- group = cfg.group;
+ users.users = optionalAttrs (cfg.user == "mjpg-streamer") {
+ mjpg-streamer = {
+ uid = config.ids.uids.mjpg-streamer;
+ group = cfg.group;
+ };
};
systemd.services.mjpg-streamer = {
diff --git a/nixpkgs/nixos/modules/services/networking/monero.nix b/nixpkgs/nixos/modules/services/networking/monero.nix
index 831e4d60d8d..b9536430868 100644
--- a/nixpkgs/nixos/modules/services/networking/monero.nix
+++ b/nixpkgs/nixos/modules/services/networking/monero.nix
@@ -197,17 +197,15 @@ in
config = mkIf cfg.enable {
- users.users = singleton {
- name = "monero";
+ users.users.monero = {
uid = config.ids.uids.monero;
description = "Monero daemon user";
home = dataDir;
createHome = true;
};
- users.groups = singleton {
- name = "monero";
- gid = config.ids.gids.monero;
+ users.groups.monero = {
+ gid = config.ids.gids.monero;
};
systemd.services.monero = {
@@ -224,15 +222,17 @@ in
};
};
- assertions = singleton {
- assertion = cfg.mining.enable -> cfg.mining.address != "";
- message = ''
+ assertions = singleton {
+ assertion = cfg.mining.enable -> cfg.mining.address != "";
+ message = ''
You need a Monero address to receive mining rewards:
specify one using option monero.mining.address.
- '';
- };
+ '';
+ };
};
+ meta.maintainers = with lib.maintainers; [ rnhmjoj ];
+
}
diff --git a/nixpkgs/nixos/modules/services/networking/murmur.nix b/nixpkgs/nixos/modules/services/networking/murmur.nix
index 082953d2f6a..3054ae1b201 100644
--- a/nixpkgs/nixos/modules/services/networking/murmur.nix
+++ b/nixpkgs/nixos/modules/services/networking/murmur.nix
@@ -46,6 +46,11 @@ let
'';
in
{
+ imports = [
+ (mkRenamedOptionModule [ "services" "murmur" "welcome" ] [ "services" "murmur" "welcometext" ])
+ (mkRemovedOptionModule [ "services" "murmur" "pidfile" ] "Hardcoded to /run/murmur/murmurd.pid now")
+ ];
+
options = {
services.murmur = {
enable = mkOption {
diff --git a/nixpkgs/nixos/modules/services/networking/mxisd.nix b/nixpkgs/nixos/modules/services/networking/mxisd.nix
index a3d61922e57..482d6ff456b 100644
--- a/nixpkgs/nixos/modules/services/networking/mxisd.nix
+++ b/nixpkgs/nixos/modules/services/networking/mxisd.nix
@@ -93,23 +93,19 @@ in {
};
config = mkIf cfg.enable {
- users.users = [
+ users.users.mxisd =
{
- name = "mxisd";
group = "mxisd";
home = cfg.dataDir;
createHome = true;
shell = "${pkgs.bash}/bin/bash";
uid = config.ids.uids.mxisd;
- }
- ];
+ };
- users.groups = [
+ users.groups.mxisd =
{
- name = "mxisd";
gid = config.ids.gids.mxisd;
- }
- ];
+ };
systemd.services.mxisd = {
description = "a federated identity server for the matrix ecosystem";
diff --git a/nixpkgs/nixos/modules/services/networking/namecoind.nix b/nixpkgs/nixos/modules/services/networking/namecoind.nix
index c8ee0a2f564..ead7f085943 100644
--- a/nixpkgs/nixos/modules/services/networking/namecoind.nix
+++ b/nixpkgs/nixos/modules/services/networking/namecoind.nix
@@ -154,16 +154,14 @@ in
config = ${configFile}
'';
- users.users = singleton {
- name = "namecoin";
+ users.users.namecoin = {
uid = config.ids.uids.namecoin;
description = "Namecoin daemon user";
home = dataDir;
createHome = true;
};
- users.groups = singleton {
- name = "namecoin";
+ users.groups.namecoin = {
gid = config.ids.gids.namecoin;
};
@@ -201,4 +199,6 @@ in
};
+ meta.maintainers = with lib.maintainers; [ rnhmjoj ];
+
}
diff --git a/nixpkgs/nixos/modules/services/networking/nat.nix b/nixpkgs/nixos/modules/services/networking/nat.nix
index 5681bda51cb..f1238bc6b16 100644
--- a/nixpkgs/nixos/modules/services/networking/nat.nix
+++ b/nixpkgs/nixos/modules/services/networking/nat.nix
@@ -7,26 +7,33 @@
with lib;
let
-
cfg = config.networking.nat;
dest = if cfg.externalIP == null then "-j MASQUERADE" else "-j SNAT --to-source ${cfg.externalIP}";
+ helpers = import ./helpers.nix { inherit config lib; };
+
flushNat = ''
- iptables -w -t nat -D PREROUTING -j nixos-nat-pre 2>/dev/null|| true
- iptables -w -t nat -F nixos-nat-pre 2>/dev/null || true
- iptables -w -t nat -X nixos-nat-pre 2>/dev/null || true
- iptables -w -t nat -D POSTROUTING -j nixos-nat-post 2>/dev/null || true
- iptables -w -t nat -F nixos-nat-post 2>/dev/null || true
- iptables -w -t nat -X nixos-nat-post 2>/dev/null || true
+ ${helpers}
+ ip46tables -w -t nat -D PREROUTING -j nixos-nat-pre 2>/dev/null|| true
+ ip46tables -w -t nat -F nixos-nat-pre 2>/dev/null || true
+ ip46tables -w -t nat -X nixos-nat-pre 2>/dev/null || true
+ ip46tables -w -t nat -D POSTROUTING -j nixos-nat-post 2>/dev/null || true
+ ip46tables -w -t nat -F nixos-nat-post 2>/dev/null || true
+ ip46tables -w -t nat -X nixos-nat-post 2>/dev/null || true
+ ip46tables -w -t nat -D OUTPUT -j nixos-nat-out 2>/dev/null || true
+ ip46tables -w -t nat -F nixos-nat-out 2>/dev/null || true
+ ip46tables -w -t nat -X nixos-nat-out 2>/dev/null || true
${cfg.extraStopCommands}
'';
setupNat = ''
+ ${helpers}
# Create subchain where we store rules
- iptables -w -t nat -N nixos-nat-pre
- iptables -w -t nat -N nixos-nat-post
+ ip46tables -w -t nat -N nixos-nat-pre
+ ip46tables -w -t nat -N nixos-nat-post
+ ip46tables -w -t nat -N nixos-nat-out
# We can't match on incoming interface in POSTROUTING, so
# mark packets coming from the internal interfaces.
@@ -88,8 +95,9 @@ let
${cfg.extraCommands}
# Append our chains to the nat tables
- iptables -w -t nat -A PREROUTING -j nixos-nat-pre
- iptables -w -t nat -A POSTROUTING -j nixos-nat-post
+ ip46tables -w -t nat -A PREROUTING -j nixos-nat-pre
+ ip46tables -w -t nat -A POSTROUTING -j nixos-nat-post
+ ip46tables -w -t nat -A OUTPUT -j nixos-nat-out
'';
in
diff --git a/nixpkgs/nixos/modules/services/networking/networkmanager.nix b/nixpkgs/nixos/modules/services/networking/networkmanager.nix
index 90d1032c41b..e817f295a44 100644
--- a/nixpkgs/nixos/modules/services/networking/networkmanager.nix
+++ b/nixpkgs/nixos/modules/services/networking/networkmanager.nix
@@ -308,6 +308,7 @@ in {
if [ "$2" != "up" ]; then
logger "exit: event $2 != up"
+ exit
fi
# coreutils and iproute are in PATH too
@@ -336,6 +337,7 @@ in {
};
imports = [
+ (mkRenamedOptionModule [ "networking" "networkmanager" "useDnsmasq" ] [ "networking" "networkmanager" "dns" ])
(mkRemovedOptionModule ["networking" "networkmanager" "dynamicHosts"] ''
This option was removed because allowing (multiple) regular users to
override host entries affecting the whole system opens up a huge attack
@@ -360,62 +362,59 @@ in {
}
];
- environment.etc = with pkgs; [
- { source = configFile;
- target = "NetworkManager/NetworkManager.conf";
- }
- { source = "${networkmanager-openvpn}/lib/NetworkManager/VPN/nm-openvpn-service.name";
- target = "NetworkManager/VPN/nm-openvpn-service.name";
- }
- { source = "${networkmanager-vpnc}/lib/NetworkManager/VPN/nm-vpnc-service.name";
- target = "NetworkManager/VPN/nm-vpnc-service.name";
- }
- { source = "${networkmanager-openconnect}/lib/NetworkManager/VPN/nm-openconnect-service.name";
- target = "NetworkManager/VPN/nm-openconnect-service.name";
- }
- { source = "${networkmanager-fortisslvpn}/lib/NetworkManager/VPN/nm-fortisslvpn-service.name";
- target = "NetworkManager/VPN/nm-fortisslvpn-service.name";
- }
- { source = "${networkmanager-l2tp}/lib/NetworkManager/VPN/nm-l2tp-service.name";
- target = "NetworkManager/VPN/nm-l2tp-service.name";
- }
- { source = "${networkmanager-iodine}/lib/NetworkManager/VPN/nm-iodine-service.name";
- target = "NetworkManager/VPN/nm-iodine-service.name";
+ environment.etc = with pkgs; {
+ "NetworkManager/NetworkManager.conf".source = configFile;
+
+ "NetworkManager/VPN/nm-openvpn-service.name".source =
+ "${networkmanager-openvpn}/lib/NetworkManager/VPN/nm-openvpn-service.name";
+
+ "NetworkManager/VPN/nm-vpnc-service.name".source =
+ "${networkmanager-vpnc}/lib/NetworkManager/VPN/nm-vpnc-service.name";
+
+ "NetworkManager/VPN/nm-openconnect-service.name".source =
+ "${networkmanager-openconnect}/lib/NetworkManager/VPN/nm-openconnect-service.name";
+
+ "NetworkManager/VPN/nm-fortisslvpn-service.name".source =
+ "${networkmanager-fortisslvpn}/lib/NetworkManager/VPN/nm-fortisslvpn-service.name";
+
+ "NetworkManager/VPN/nm-l2tp-service.name".source =
+ "${networkmanager-l2tp}/lib/NetworkManager/VPN/nm-l2tp-service.name";
+
+ "NetworkManager/VPN/nm-iodine-service.name".source =
+ "${networkmanager-iodine}/lib/NetworkManager/VPN/nm-iodine-service.name";
}
- ] ++ optional (cfg.appendNameservers != [] || cfg.insertNameservers != [])
- { source = overrideNameserversScript;
- target = "NetworkManager/dispatcher.d/02overridedns";
- }
- ++ lib.imap1 (i: s: {
- inherit (s) source;
- target = "NetworkManager/dispatcher.d/${dispatcherTypesSubdirMap.${s.type}}03userscript${lib.fixedWidthNumber 4 i}";
- mode = "0544";
- }) cfg.dispatcherScripts
- ++ optional cfg.enableStrongSwan
- { source = "${pkgs.networkmanager_strongswan}/lib/NetworkManager/VPN/nm-strongswan-service.name";
- target = "NetworkManager/VPN/nm-strongswan-service.name";
- };
+ // optionalAttrs (cfg.appendNameservers != [] || cfg.insertNameservers != [])
+ {
+ "NetworkManager/dispatcher.d/02overridedns".source = overrideNameserversScript;
+ }
+ // optionalAttrs cfg.enableStrongSwan
+ {
+ "NetworkManager/VPN/nm-strongswan-service.name".source =
+ "${pkgs.networkmanager_strongswan}/lib/NetworkManager/VPN/nm-strongswan-service.name";
+ }
+ // listToAttrs (lib.imap1 (i: s:
+ {
+ name = "NetworkManager/dispatcher.d/${dispatcherTypesSubdirMap.${s.type}}03userscript${lib.fixedWidthNumber 4 i}";
+ value = { mode = "0544"; inherit (s) source; };
+ }) cfg.dispatcherScripts);
environment.systemPackages = cfg.packages;
- users.groups = [{
- name = "networkmanager";
- gid = config.ids.gids.networkmanager;
- }
- {
- name = "nm-openvpn";
- gid = config.ids.gids.nm-openvpn;
- }];
- users.users = [{
- name = "nm-openvpn";
- uid = config.ids.uids.nm-openvpn;
- extraGroups = [ "networkmanager" ];
- }
- {
- name = "nm-iodine";
- isSystemUser = true;
- group = "networkmanager";
- }];
+ users.groups = {
+ networkmanager.gid = config.ids.gids.networkmanager;
+ nm-openvpn.gid = config.ids.gids.nm-openvpn;
+ };
+
+ users.users = {
+ nm-openvpn = {
+ uid = config.ids.uids.nm-openvpn;
+ extraGroups = [ "networkmanager" ];
+ };
+ nm-iodine = {
+ isSystemUser = true;
+ group = "networkmanager";
+ };
+ };
systemd.packages = cfg.packages;
diff --git a/nixpkgs/nixos/modules/services/networking/nntp-proxy.nix b/nixpkgs/nixos/modules/services/networking/nntp-proxy.nix
index d24d6f77a49..cc061bf6e3b 100644
--- a/nixpkgs/nixos/modules/services/networking/nntp-proxy.nix
+++ b/nixpkgs/nixos/modules/services/networking/nntp-proxy.nix
@@ -210,9 +210,8 @@ in
config = mkIf cfg.enable {
- users.users = singleton
- { name = proxyUser;
- uid = config.ids.uids.nntp-proxy;
+ users.users.${proxyUser} =
+ { uid = config.ids.uids.nntp-proxy;
description = "NNTP-Proxy daemon user";
};
diff --git a/nixpkgs/nixos/modules/services/networking/nsd.nix b/nixpkgs/nixos/modules/services/networking/nsd.nix
index bc0966e6b8e..344396638a6 100644
--- a/nixpkgs/nixos/modules/services/networking/nsd.nix
+++ b/nixpkgs/nixos/modules/services/networking/nsd.nix
@@ -899,13 +899,9 @@ in
environment.systemPackages = [ nsdPkg ];
- users.groups = singleton {
- name = username;
- gid = config.ids.gids.nsd;
- };
+ users.groups.${username}.gid = config.ids.gids.nsd;
- users.users = singleton {
- name = username;
+ users.users.${username} = {
description = "NSD service user";
home = stateDir;
createHome = true;
diff --git a/nixpkgs/nixos/modules/services/networking/ntp/chrony.nix b/nixpkgs/nixos/modules/services/networking/ntp/chrony.nix
index c74476c7a15..da9d960cc14 100644
--- a/nixpkgs/nixos/modules/services/networking/ntp/chrony.nix
+++ b/nixpkgs/nixos/modules/services/networking/ntp/chrony.nix
@@ -79,14 +79,10 @@ in
environment.systemPackages = [ pkgs.chrony ];
- users.groups = singleton
- { name = "chrony";
- gid = config.ids.gids.chrony;
- };
+ users.groups.chrony.gid = config.ids.gids.chrony;
- users.users = singleton
- { name = "chrony";
- uid = config.ids.uids.chrony;
+ users.users.chrony =
+ { uid = config.ids.uids.chrony;
group = "chrony";
description = "chrony daemon user";
home = stateDir;
diff --git a/nixpkgs/nixos/modules/services/networking/ntp/ntpd.nix b/nixpkgs/nixos/modules/services/networking/ntp/ntpd.nix
index 1197c84f045..b5403cb747d 100644
--- a/nixpkgs/nixos/modules/services/networking/ntp/ntpd.nix
+++ b/nixpkgs/nixos/modules/services/networking/ntp/ntpd.nix
@@ -104,9 +104,8 @@ in
systemd.services.systemd-timedated.environment = { SYSTEMD_TIMEDATED_NTP_SERVICES = "ntpd.service"; };
- users.users = singleton
- { name = ntpUser;
- uid = config.ids.uids.ntp;
+ users.users.${ntpUser} =
+ { uid = config.ids.uids.ntp;
description = "NTP daemon user";
home = stateDir;
};
diff --git a/nixpkgs/nixos/modules/services/networking/ntp/openntpd.nix b/nixpkgs/nixos/modules/services/networking/ntp/openntpd.nix
index 471d15b1687..67a04d48d30 100644
--- a/nixpkgs/nixos/modules/services/networking/ntp/openntpd.nix
+++ b/nixpkgs/nixos/modules/services/networking/ntp/openntpd.nix
@@ -60,8 +60,7 @@ in
environment.etc."ntpd.conf".text = configFile;
- users.users = singleton {
- name = "ntp";
+ users.users.ntp = {
uid = config.ids.uids.ntp;
description = "OpenNTP daemon user";
home = "/var/empty";
diff --git a/nixpkgs/nixos/modules/services/networking/openvpn.nix b/nixpkgs/nixos/modules/services/networking/openvpn.nix
index 05be97e66a3..dcd7e9e5fa4 100644
--- a/nixpkgs/nixos/modules/services/networking/openvpn.nix
+++ b/nixpkgs/nixos/modules/services/networking/openvpn.nix
@@ -73,6 +73,9 @@ let
in
{
+ imports = [
+ (mkRemovedOptionModule [ "services" "openvpn" "enable" ] "")
+ ];
###### interface
diff --git a/nixpkgs/nixos/modules/services/networking/owamp.nix b/nixpkgs/nixos/modules/services/networking/owamp.nix
index dbb2e3b4c40..637ed618b89 100644
--- a/nixpkgs/nixos/modules/services/networking/owamp.nix
+++ b/nixpkgs/nixos/modules/services/networking/owamp.nix
@@ -17,16 +17,13 @@ in
###### implementation
config = mkIf cfg.enable {
- users.users = singleton {
- name = "owamp";
+ users.users.owamp = {
group = "owamp";
description = "Owamp daemon";
isSystemUser = true;
};
- users.groups = singleton {
- name = "owamp";
- };
+ users.groups.owamp = { };
systemd.services.owamp = {
description = "Owamp server";
diff --git a/nixpkgs/nixos/modules/services/networking/pdns-recursor.nix b/nixpkgs/nixos/modules/services/networking/pdns-recursor.nix
index e55ea363378..6ff181377fc 100644
--- a/nixpkgs/nixos/modules/services/networking/pdns-recursor.nix
+++ b/nixpkgs/nixos/modules/services/networking/pdns-recursor.nix
@@ -219,4 +219,6 @@ in {
"To change extra Recursor settings use services.pdns-recursor.settings instead.")
];
+ meta.maintainers = with lib.maintainers; [ rnhmjoj ];
+
}
diff --git a/nixpkgs/nixos/modules/services/networking/pdnsd.nix b/nixpkgs/nixos/modules/services/networking/pdnsd.nix
index f5b174dd7b7..24b5bbc5104 100644
--- a/nixpkgs/nixos/modules/services/networking/pdnsd.nix
+++ b/nixpkgs/nixos/modules/services/networking/pdnsd.nix
@@ -62,15 +62,13 @@ in
};
config = mkIf cfg.enable {
- users.users = singleton {
- name = pdnsdUser;
+ users.users.${pdnsdUser} = {
uid = config.ids.uids.pdnsd;
group = pdnsdGroup;
description = "pdnsd user";
};
- users.groups = singleton {
- name = pdnsdGroup;
+ users.groups.${pdnsdGroup} = {
gid = config.ids.gids.pdnsd;
};
diff --git a/nixpkgs/nixos/modules/services/networking/polipo.nix b/nixpkgs/nixos/modules/services/networking/polipo.nix
index dbe3b738097..1ff9388346b 100644
--- a/nixpkgs/nixos/modules/services/networking/polipo.nix
+++ b/nixpkgs/nixos/modules/services/networking/polipo.nix
@@ -85,17 +85,15 @@ in
config = mkIf cfg.enable {
- users.users = singleton
- { name = "polipo";
- uid = config.ids.uids.polipo;
+ users.users.polipo =
+ { uid = config.ids.uids.polipo;
description = "Polipo caching proxy user";
home = "/var/cache/polipo";
createHome = true;
};
- users.groups = singleton
- { name = "polipo";
- gid = config.ids.gids.polipo;
+ users.groups.polipo =
+ { gid = config.ids.gids.polipo;
members = [ "polipo" ];
};
diff --git a/nixpkgs/nixos/modules/services/networking/pppd.nix b/nixpkgs/nixos/modules/services/networking/pppd.nix
index e96c27bd84b..b31bfa64235 100644
--- a/nixpkgs/nixos/modules/services/networking/pppd.nix
+++ b/nixpkgs/nixos/modules/services/networking/pppd.nix
@@ -64,11 +64,13 @@ in
enabledConfigs = filter (f: f.enable) (attrValues cfg.peers);
mkEtc = peerCfg: {
- "ppp/peers/${peerCfg.name}".text = peerCfg.config;
+ name = "ppp/peers/${peerCfg.name}";
+ value.text = peerCfg.config;
};
mkSystemd = peerCfg: {
- "pppd-${peerCfg.name}" = {
+ name = "pppd-${peerCfg.name}";
+ value = {
restartTriggers = [ config.environment.etc."ppp/peers/${peerCfg.name}".source ];
before = [ "network.target" ];
wants = [ "network.target" ];
@@ -124,8 +126,8 @@ in
};
};
- etcFiles = map mkEtc enabledConfigs;
- systemdConfigs = map mkSystemd enabledConfigs;
+ etcFiles = listToAttrs (map mkEtc enabledConfigs);
+ systemdConfigs = listToAttrs (map mkSystemd enabledConfigs);
in mkIf cfg.enable {
environment.etc = mkMerge etcFiles;
diff --git a/nixpkgs/nixos/modules/services/networking/prayer.nix b/nixpkgs/nixos/modules/services/networking/prayer.nix
index c936417e68c..9c9eeba23da 100644
--- a/nixpkgs/nixos/modules/services/networking/prayer.nix
+++ b/nixpkgs/nixos/modules/services/networking/prayer.nix
@@ -72,17 +72,14 @@ in
config = mkIf config.services.prayer.enable {
environment.systemPackages = [ prayer ];
- users.users = singleton
- { name = prayerUser;
- uid = config.ids.uids.prayer;
+ users.users.${prayerUser} =
+ { uid = config.ids.uids.prayer;
description = "Prayer daemon user";
home = stateDir;
};
- users.groups = singleton
- { name = prayerGroup;
- gid = config.ids.gids.prayer;
- };
+ users.groups.${prayerGroup} =
+ { gid = config.ids.gids.prayer; };
systemd.services.prayer = {
wantedBy = [ "multi-user.target" ];
diff --git a/nixpkgs/nixos/modules/services/networking/privoxy.nix b/nixpkgs/nixos/modules/services/networking/privoxy.nix
index 49ca839a2c3..1f41c720adf 100644
--- a/nixpkgs/nixos/modules/services/networking/privoxy.nix
+++ b/nixpkgs/nixos/modules/services/networking/privoxy.nix
@@ -109,4 +109,6 @@ in
};
+ meta.maintainers = with lib.maintainers; [ rnhmjoj ];
+
}
diff --git a/nixpkgs/nixos/modules/services/networking/quassel.nix b/nixpkgs/nixos/modules/services/networking/quassel.nix
index b495b3948fb..52ecd90b7c6 100644
--- a/nixpkgs/nixos/modules/services/networking/quassel.nix
+++ b/nixpkgs/nixos/modules/services/networking/quassel.nix
@@ -92,17 +92,21 @@ in
message = "Quassel needs a certificate file in order to require SSL";
}];
- users.users = mkIf (cfg.user == null) [
- { name = "quassel";
+ users.users = optionalAttrs (cfg.user == null) {
+ quassel = {
+ name = "quassel";
description = "Quassel IRC client daemon";
group = "quassel";
uid = config.ids.uids.quassel;
- }];
+ };
+ };
- users.groups = mkIf (cfg.user == null) [
- { name = "quassel";
+ users.groups = optionalAttrs (cfg.user == null) {
+ quassel = {
+ name = "quassel";
gid = config.ids.gids.quassel;
- }];
+ };
+ };
systemd.tmpfiles.rules = [
"d '${cfg.dataDir}' - ${user} - - -"
diff --git a/nixpkgs/nixos/modules/services/networking/radicale.nix b/nixpkgs/nixos/modules/services/networking/radicale.nix
index 1daced4a6c7..30bf22586f8 100644
--- a/nixpkgs/nixos/modules/services/networking/radicale.nix
+++ b/nixpkgs/nixos/modules/services/networking/radicale.nix
@@ -59,18 +59,15 @@ in
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
- users.users = singleton
- { name = "radicale";
- uid = config.ids.uids.radicale;
+ users.users.radicale =
+ { uid = config.ids.uids.radicale;
description = "radicale user";
home = "/var/lib/radicale";
createHome = true;
};
- users.groups = singleton
- { name = "radicale";
- gid = config.ids.gids.radicale;
- };
+ users.groups.radicale =
+ { gid = config.ids.gids.radicale; };
systemd.services.radicale = {
description = "A Simple Calendar and Contact Server";
diff --git a/nixpkgs/nixos/modules/services/networking/searx.nix b/nixpkgs/nixos/modules/services/networking/searx.nix
index 9412d0ef8a6..60fb3d5d6d4 100644
--- a/nixpkgs/nixos/modules/services/networking/searx.nix
+++ b/nixpkgs/nixos/modules/services/networking/searx.nix
@@ -75,4 +75,6 @@ in
};
+ meta.maintainers = with lib.maintainers; [ rnhmjoj ];
+
}
diff --git a/nixpkgs/nixos/modules/services/networking/shairport-sync.nix b/nixpkgs/nixos/modules/services/networking/shairport-sync.nix
index 68e005ab81d..2e988e0ca2e 100644
--- a/nixpkgs/nixos/modules/services/networking/shairport-sync.nix
+++ b/nixpkgs/nixos/modules/services/networking/shairport-sync.nix
@@ -55,9 +55,8 @@ in
services.avahi.publish.enable = true;
services.avahi.publish.userServices = true;
- users.users = singleton
- { name = cfg.user;
- description = "Shairport user";
+ users.users.${cfg.user} =
+ { description = "Shairport user";
isSystemUser = true;
createHome = true;
home = "/var/lib/shairport-sync";
diff --git a/nixpkgs/nixos/modules/services/networking/shorewall.nix b/nixpkgs/nixos/modules/services/networking/shorewall.nix
new file mode 100644
index 00000000000..0f94d414fcf
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/networking/shorewall.nix
@@ -0,0 +1,75 @@
+{ config, lib, pkgs, ... }:
+let
+ types = lib.types;
+ cfg = config.services.shorewall;
+in {
+ options = {
+ services.shorewall = {
+ enable = lib.mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Whether to enable Shorewall IPv4 Firewall.
+ <warning>
+ <para>
+ Enabling this service WILL disable the existing NixOS
+ firewall! Default firewall rules provided by packages are not
+ considered at the moment.
+ </para>
+ </warning>
+ '';
+ };
+ package = lib.mkOption {
+ type = types.package;
+ default = pkgs.shorewall;
+ defaultText = "pkgs.shorewall";
+ description = "The shorewall package to use.";
+ };
+ configs = lib.mkOption {
+ type = types.attrsOf types.str;
+ default = {};
+ description = ''
+ This option defines the Shorewall configs.
+ The attribute name defines the name of the config,
+ and the attribute value defines the content of the config.
+ '';
+ apply = lib.mapAttrs (name: text: pkgs.writeText "${name}" text);
+ };
+ };
+ };
+
+ config = lib.mkIf cfg.enable {
+ systemd.services.firewall.enable = false;
+ systemd.services.shorewall = {
+ description = "Shorewall IPv4 Firewall";
+ after = [ "ipset.target" ];
+ before = [ "network-pre.target" ];
+ wants = [ "network-pre.target" ];
+ wantedBy = [ "multi-user.target" ];
+ reloadIfChanged = true;
+ restartTriggers = lib.attrValues cfg.configs;
+ serviceConfig = {
+ Type = "oneshot";
+ RemainAfterExit = "yes";
+ ExecStart = "${cfg.package}/bin/shorewall start";
+ ExecReload = "${cfg.package}/bin/shorewall reload";
+ ExecStop = "${cfg.package}/bin/shorewall stop";
+ };
+ preStart = ''
+ install -D -d -m 750 /var/lib/shorewall
+ install -D -d -m 755 /var/lock/subsys
+ touch /var/log/shorewall.log
+ chown 750 /var/log/shorewall.log
+ '';
+ };
+ environment = {
+ etc = lib.mapAttrsToList
+ (name: file:
+ { source = file;
+ target = "shorewall/${name}";
+ })
+ cfg.configs;
+ systemPackages = [ cfg.package ];
+ };
+ };
+}
diff --git a/nixpkgs/nixos/modules/services/networking/shorewall6.nix b/nixpkgs/nixos/modules/services/networking/shorewall6.nix
new file mode 100644
index 00000000000..9c22a037c0b
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/networking/shorewall6.nix
@@ -0,0 +1,75 @@
+{ config, lib, pkgs, ... }:
+let
+ types = lib.types;
+ cfg = config.services.shorewall6;
+in {
+ options = {
+ services.shorewall6 = {
+ enable = lib.mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Whether to enable Shorewall IPv6 Firewall.
+ <warning>
+ <para>
+ Enabling this service WILL disable the existing NixOS
+ firewall! Default firewall rules provided by packages are not
+ considered at the moment.
+ </para>
+ </warning>
+ '';
+ };
+ package = lib.mkOption {
+ type = types.package;
+ default = pkgs.shorewall;
+ defaultText = "pkgs.shorewall";
+ description = "The shorewall package to use.";
+ };
+ configs = lib.mkOption {
+ type = types.attrsOf types.str;
+ default = {};
+ description = ''
+ This option defines the Shorewall configs.
+ The attribute name defines the name of the config,
+ and the attribute value defines the content of the config.
+ '';
+ apply = lib.mapAttrs (name: text: pkgs.writeText "${name}" text);
+ };
+ };
+ };
+
+ config = lib.mkIf cfg.enable {
+ systemd.services.firewall.enable = false;
+ systemd.services.shorewall6 = {
+ description = "Shorewall IPv6 Firewall";
+ after = [ "ipset.target" ];
+ before = [ "network-pre.target" ];
+ wants = [ "network-pre.target" ];
+ wantedBy = [ "multi-user.target" ];
+ reloadIfChanged = true;
+ restartTriggers = lib.attrValues cfg.configs;
+ serviceConfig = {
+ Type = "oneshot";
+ RemainAfterExit = "yes";
+ ExecStart = "${cfg.package}/bin/shorewall6 start";
+ ExecReload = "${cfg.package}/bin/shorewall6 reload";
+ ExecStop = "${cfg.package}/bin/shorewall6 stop";
+ };
+ preStart = ''
+ install -D -d -m 750 /var/lib/shorewall6
+ install -D -d -m 755 /var/lock/subsys
+ touch /var/log/shorewall6.log
+ chown 750 /var/log/shorewall6.log
+ '';
+ };
+ environment = {
+ etc = lib.mapAttrsToList
+ (name: file:
+ { source = file;
+ target = "shorewall6/${name}";
+ })
+ cfg.configs;
+ systemPackages = [ cfg.package ];
+ };
+ };
+}
diff --git a/nixpkgs/nixos/modules/services/networking/shout.nix b/nixpkgs/nixos/modules/services/networking/shout.nix
index e548ec66962..a808a7f39d0 100644
--- a/nixpkgs/nixos/modules/services/networking/shout.nix
+++ b/nixpkgs/nixos/modules/services/networking/shout.nix
@@ -82,8 +82,7 @@ in {
};
config = mkIf cfg.enable {
- users.users = singleton {
- name = "shout";
+ users.users.shout = {
uid = config.ids.uids.shout;
description = "Shout daemon user";
home = shoutHome;
diff --git a/nixpkgs/nixos/modules/services/networking/smokeping.nix b/nixpkgs/nixos/modules/services/networking/smokeping.nix
index b48b0b3a9d6..37ee2a80389 100644
--- a/nixpkgs/nixos/modules/services/networking/smokeping.nix
+++ b/nixpkgs/nixos/modules/services/networking/smokeping.nix
@@ -280,8 +280,7 @@ in
fping6.source = "${pkgs.fping}/bin/fping6";
};
environment.systemPackages = [ pkgs.fping ];
- users.users = singleton {
- name = cfg.user;
+ users.users.${cfg.user} = {
isNormalUser = false;
isSystemUser = true;
uid = config.ids.uids.smokeping;
diff --git a/nixpkgs/nixos/modules/services/networking/spacecookie.nix b/nixpkgs/nixos/modules/services/networking/spacecookie.nix
new file mode 100644
index 00000000000..c4d06df6ad4
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/networking/spacecookie.nix
@@ -0,0 +1,83 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+ cfg = config.services.spacecookie;
+ configFile = pkgs.writeText "spacecookie.json" (lib.generators.toJSON {} {
+ inherit (cfg) hostname port root;
+ });
+in {
+
+ options = {
+
+ services.spacecookie = {
+
+ enable = mkEnableOption "spacecookie";
+
+ hostname = mkOption {
+ type = types.str;
+ default = "localhost";
+ description = "The hostname the service is reachable via. Clients will use this hostname for further requests after loading the initial gopher menu.";
+ };
+
+ port = mkOption {
+ type = types.port;
+ default = 70;
+ description = "Port the gopher service should be exposed on.";
+ };
+
+ root = mkOption {
+ type = types.path;
+ default = "/srv/gopher";
+ description = "The root directory spacecookie serves via gopher.";
+ };
+ };
+ };
+
+ config = mkIf cfg.enable {
+
+ systemd.sockets.spacecookie = {
+ description = "Socket for the Spacecookie Gopher Server";
+ wantedBy = [ "sockets.target" ];
+ listenStreams = [ "[::]:${toString cfg.port}" ];
+ socketConfig = {
+ BindIPv6Only = "both";
+ };
+ };
+
+ systemd.services.spacecookie = {
+ description = "Spacecookie Gopher Server";
+ wantedBy = [ "multi-user.target" ];
+ requires = [ "spacecookie.socket" ];
+
+ serviceConfig = {
+ Type = "notify";
+ ExecStart = "${pkgs.haskellPackages.spacecookie}/bin/spacecookie ${configFile}";
+ FileDescriptorStoreMax = 1;
+
+ DynamicUser = true;
+
+ ProtectSystem = "strict";
+ ProtectHome = true;
+ PrivateTmp = true;
+ PrivateDevices = true;
+ PrivateMounts = true;
+ PrivateUsers = true;
+
+ ProtectKernelTunables = true;
+ ProtectKernelModules = true;
+ ProtectControlGroups = true;
+
+ CapabilityBoundingSet = "";
+ NoNewPrivileges = true;
+ LockPersonality = true;
+ RestrictRealtime = true;
+
+ # AF_UNIX for communication with systemd
+ # AF_INET replaced by BindIPv6Only=both
+ RestrictAddressFamilies = "AF_UNIX AF_INET6";
+ };
+ };
+ };
+}
diff --git a/nixpkgs/nixos/modules/services/networking/ssh/sshd.nix b/nixpkgs/nixos/modules/services/networking/ssh/sshd.nix
index 91fc7d72bc6..b0e2e303cbc 100644
--- a/nixpkgs/nixos/modules/services/networking/ssh/sshd.nix
+++ b/nixpkgs/nixos/modules/services/networking/ssh/sshd.nix
@@ -74,6 +74,10 @@ let
in
{
+ imports = [
+ (mkAliasOptionModule [ "services" "sshd" "enable" ] [ "services" "openssh" "enable" ])
+ (mkAliasOptionModule [ "services" "openssh" "knownHosts" ] [ "programs" "ssh" "knownHosts" ])
+ ];
###### interface
diff --git a/nixpkgs/nixos/modules/services/networking/supybot.nix b/nixpkgs/nixos/modules/services/networking/supybot.nix
index 64eb1106832..92c84bd0e1e 100644
--- a/nixpkgs/nixos/modules/services/networking/supybot.nix
+++ b/nixpkgs/nixos/modules/services/networking/supybot.nix
@@ -45,8 +45,7 @@ in
environment.systemPackages = [ pkgs.pythonPackages.limnoria ];
- users.users = singleton {
- name = "supybot";
+ users.users.supybotrs = {
uid = config.ids.uids.supybot;
group = "supybot";
description = "Supybot IRC bot user";
@@ -55,7 +54,6 @@ in
};
users.groups.supybot = {
- name = "supybot";
gid = config.ids.gids.supybot;
};
diff --git a/nixpkgs/nixos/modules/services/networking/syncthing.nix b/nixpkgs/nixos/modules/services/networking/syncthing.nix
index b3f2af5b179..47b10e408c0 100644
--- a/nixpkgs/nixos/modules/services/networking/syncthing.nix
+++ b/nixpkgs/nixos/modules/services/networking/syncthing.nix
@@ -112,12 +112,12 @@ in {
addresses = [ "tcp://192.168.0.10:51820" ];
};
};
- type = types.attrsOf (types.submodule ({ config, ... }: {
+ type = types.attrsOf (types.submodule ({ name, ... }: {
options = {
name = mkOption {
type = types.str;
- default = config._module.args.name;
+ default = name;
description = ''
Name of the device
'';
@@ -175,7 +175,7 @@ in {
devices = [ "bigbox" ];
};
};
- type = types.attrsOf (types.submodule ({ config, ... }: {
+ type = types.attrsOf (types.submodule ({ name, ... }: {
options = {
enable = mkOption {
@@ -190,7 +190,7 @@ in {
path = mkOption {
type = types.str;
- default = config._module.args.name;
+ default = name;
description = ''
The path to the folder which should be shared.
'';
@@ -198,7 +198,7 @@ in {
id = mkOption {
type = types.str;
- default = config._module.args.name;
+ default = name;
description = ''
The id of the folder. Must be the same on all devices.
'';
@@ -206,7 +206,7 @@ in {
label = mkOption {
type = types.str;
- default = config._module.args.name;
+ default = name;
description = ''
The label of the folder.
'';
diff --git a/nixpkgs/nixos/modules/services/networking/tcpcrypt.nix b/nixpkgs/nixos/modules/services/networking/tcpcrypt.nix
index a0ccb995009..18f2e135124 100644
--- a/nixpkgs/nixos/modules/services/networking/tcpcrypt.nix
+++ b/nixpkgs/nixos/modules/services/networking/tcpcrypt.nix
@@ -29,8 +29,7 @@ in
config = mkIf cfg.enable {
- users.users = singleton {
- name = "tcpcryptd";
+ users.users.tcpcryptd = {
uid = config.ids.uids.tcpcryptd;
description = "tcpcrypt daemon user";
};
diff --git a/nixpkgs/nixos/modules/services/networking/tox-bootstrapd.nix b/nixpkgs/nixos/modules/services/networking/tox-bootstrapd.nix
index 1d349215169..f88e34827d0 100644
--- a/nixpkgs/nixos/modules/services/networking/tox-bootstrapd.nix
+++ b/nixpkgs/nixos/modules/services/networking/tox-bootstrapd.nix
@@ -56,9 +56,8 @@ in
config = mkIf config.services.toxBootstrapd.enable {
- users.users = singleton
- { name = "tox-bootstrapd";
- uid = config.ids.uids.tox-bootstrapd;
+ users.users.tox-bootstrapd =
+ { uid = config.ids.uids.tox-bootstrapd;
description = "Tox bootstrap daemon user";
inherit home;
createHome = true;
diff --git a/nixpkgs/nixos/modules/services/networking/unbound.nix b/nixpkgs/nixos/modules/services/networking/unbound.nix
index 3cf82e8839b..baed83591e1 100644
--- a/nixpkgs/nixos/modules/services/networking/unbound.nix
+++ b/nixpkgs/nixos/modules/services/networking/unbound.nix
@@ -53,6 +53,13 @@ in
enable = mkEnableOption "Unbound domain name server";
+ package = mkOption {
+ type = types.package;
+ default = pkgs.unbound;
+ defaultText = "pkgs.unbound";
+ description = "The unbound package to use";
+ };
+
allowedAccess = mkOption {
default = [ "127.0.0.0/24" ];
type = types.listOf types.str;
@@ -94,7 +101,7 @@ in
config = mkIf cfg.enable {
- environment.systemPackages = [ pkgs.unbound ];
+ environment.systemPackages = [ cfg.package ];
users.users.unbound = {
description = "unbound daemon user";
@@ -114,7 +121,7 @@ in
mkdir -m 0755 -p ${stateDir}/dev/
cp ${confFile} ${stateDir}/unbound.conf
${optionalString cfg.enableRootTrustAnchor ''
- ${pkgs.unbound}/bin/unbound-anchor -a ${rootTrustAnchorFile} || echo "Root anchor updated!"
+ ${cfg.package}/bin/unbound-anchor -a ${rootTrustAnchorFile} || echo "Root anchor updated!"
chown unbound ${stateDir} ${rootTrustAnchorFile}
''}
touch ${stateDir}/dev/random
@@ -122,7 +129,7 @@ in
'';
serviceConfig = {
- ExecStart = "${pkgs.unbound}/bin/unbound -d -c ${stateDir}/unbound.conf";
+ ExecStart = "${cfg.package}/bin/unbound -d -c ${stateDir}/unbound.conf";
ExecStopPost="${pkgs.utillinux}/bin/umount ${stateDir}/dev/random";
ProtectSystem = true;
diff --git a/nixpkgs/nixos/modules/services/networking/v2ray.nix b/nixpkgs/nixos/modules/services/networking/v2ray.nix
new file mode 100644
index 00000000000..a1774cdffbb
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/networking/v2ray.nix
@@ -0,0 +1,81 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+{
+ options = {
+
+ services.v2ray = {
+ enable = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Whether to run v2ray server.
+
+ Either <literal>configFile</literal> or <literal>config</literal> must be specified.
+ '';
+ };
+
+ configFile = mkOption {
+ type = types.nullOr types.str;
+ default = null;
+ example = "/etc/v2ray/config.json";
+ description = ''
+ The absolute path to the configuration file.
+
+ Either <literal>configFile</literal> or <literal>config</literal> must be specified.
+
+ See <link xlink:href="https://v2ray.com/en/configuration/overview.html"/>.
+ '';
+ };
+
+ config = mkOption {
+ type = types.nullOr (types.attrsOf types.unspecified);
+ default = null;
+ example = {
+ inbounds = [{
+ port = 1080;
+ listen = "127.0.0.1";
+ protocol = "http";
+ }];
+ outbounds = [{
+ protocol = "freedom";
+ }];
+ };
+ description = ''
+ The configuration object.
+
+ Either `configFile` or `config` must be specified.
+
+ See <link xlink:href="https://v2ray.com/en/configuration/overview.html"/>.
+ '';
+ };
+ };
+
+ };
+
+ config = let
+ cfg = config.services.v2ray;
+ configFile = if cfg.configFile != null
+ then cfg.configFile
+ else (pkgs.writeText "v2ray.json" (builtins.toJSON cfg.config));
+
+ in mkIf cfg.enable {
+ assertions = [
+ {
+ assertion = (cfg.configFile == null) != (cfg.config == null);
+ message = "Either but not both `configFile` and `config` should be specified for v2ray.";
+ }
+ ];
+
+ systemd.services.v2ray = {
+ description = "v2ray Daemon";
+ after = [ "network.target" ];
+ wantedBy = [ "multi-user.target" ];
+ path = [ pkgs.v2ray ];
+ script = ''
+ exec v2ray -config ${configFile}
+ '';
+ };
+ };
+}
diff --git a/nixpkgs/nixos/modules/services/networking/vsftpd.nix b/nixpkgs/nixos/modules/services/networking/vsftpd.nix
index 90093d9a78d..47990dbb377 100644
--- a/nixpkgs/nixos/modules/services/networking/vsftpd.nix
+++ b/nixpkgs/nixos/modules/services/networking/vsftpd.nix
@@ -279,21 +279,22 @@ in
message = "vsftpd: If enableVirtualUsers is true, you need to setup both the userDbPath and localUsers options.";
}];
- users.users =
- [ { name = "vsftpd";
- uid = config.ids.uids.vsftpd;
- description = "VSFTPD user";
- home = if cfg.localRoot != null
- then cfg.localRoot # <= Necessary for virtual users.
- else "/homeless-shelter";
- }
- ] ++ optional cfg.anonymousUser
- { name = "ftp";
+ users.users = {
+ "vsftpd" = {
+ uid = config.ids.uids.vsftpd;
+ description = "VSFTPD user";
+ home = if cfg.localRoot != null
+ then cfg.localRoot # <= Necessary for virtual users.
+ else "/homeless-shelter";
+ };
+ } // optionalAttrs cfg.anonymousUser {
+ "ftp" = { name = "ftp";
uid = config.ids.uids.ftp;
group = "ftp";
description = "Anonymous FTP user";
home = cfg.anonymousUserHome;
};
+ };
users.groups.ftp.gid = config.ids.gids.ftp;
diff --git a/nixpkgs/nixos/modules/services/networking/yggdrasil.nix b/nixpkgs/nixos/modules/services/networking/yggdrasil.nix
index 5d65f8e3413..9e675ecd6f4 100644
--- a/nixpkgs/nixos/modules/services/networking/yggdrasil.nix
+++ b/nixpkgs/nixos/modules/services/networking/yggdrasil.nix
@@ -12,11 +12,11 @@ let
configFileProvided = (cfg.configFile != null);
generateConfig = (
if configProvided && configFileProvided then
- "${pkgs.jq}/bin/jq -s add /run/yggdrasil/configFile.json ${configAsFile}"
+ "${pkgs.jq}/bin/jq -s add ${configAsFile} ${cfg.configFile}"
else if configProvided then
"cat ${configAsFile}"
else if configFileProvided then
- "cat /run/yggdrasil/configFile.json"
+ "cat ${cfg.configFile}"
else
"${cfg.package}/bin/yggdrasil -genconf"
);
@@ -147,7 +147,7 @@ in {
RuntimeDirectory = "yggdrasil";
RuntimeDirectoryMode = "0700";
BindReadOnlyPaths = mkIf configFileProvided
- [ "${cfg.configFile}:/run/yggdrasil/configFile.json" ];
+ [ "${cfg.configFile}" ];
# TODO: as of yggdrasil 0.3.8 and systemd 243, yggdrasil fails
# to set up the network adapter when DynamicUser is set. See
diff --git a/nixpkgs/nixos/modules/services/networking/znc/default.nix b/nixpkgs/nixos/modules/services/networking/znc/default.nix
index 0a9848a4934..a7315896c50 100644
--- a/nixpkgs/nixos/modules/services/networking/znc/default.nix
+++ b/nixpkgs/nixos/modules/services/networking/znc/default.nix
@@ -287,20 +287,22 @@ in
'';
};
- users.users = optional (cfg.user == defaultUser)
- { name = defaultUser;
- description = "ZNC server daemon owner";
- group = defaultUser;
- uid = config.ids.uids.znc;
- home = cfg.dataDir;
- createHome = true;
+ users.users = optionalAttrs (cfg.user == defaultUser) {
+ ${defaultUser} =
+ { description = "ZNC server daemon owner";
+ group = defaultUser;
+ uid = config.ids.uids.znc;
+ home = cfg.dataDir;
+ createHome = true;
+ };
};
- users.groups = optional (cfg.user == defaultUser)
- { name = defaultUser;
- gid = config.ids.gids.znc;
- members = [ defaultUser ];
- };
+ users.groups = optionalAttrs (cfg.user == defaultUser) {
+ ${defaultUser} =
+ { gid = config.ids.gids.znc;
+ members = [ defaultUser ];
+ };
+ };
};
}
diff --git a/nixpkgs/nixos/modules/services/printing/cupsd.nix b/nixpkgs/nixos/modules/services/printing/cupsd.nix
index 1071c05d514..59306d625e6 100644
--- a/nixpkgs/nixos/modules/services/printing/cupsd.nix
+++ b/nixpkgs/nixos/modules/services/printing/cupsd.nix
@@ -112,6 +112,15 @@ in
{
+ imports = [
+ (mkChangedOptionModule [ "services" "printing" "gutenprint" ] [ "services" "printing" "drivers" ]
+ (config:
+ let enabled = getAttrFromPath [ "services" "printing" "gutenprint" ] config;
+ in if enabled then [ pkgs.gutenprint ] else [ ]))
+ (mkRemovedOptionModule [ "services" "printing" "cupsFilesConf" ] "")
+ (mkRemovedOptionModule [ "services" "printing" "cupsdConf" ] "")
+ ];
+
###### interface
options = {
@@ -279,9 +288,8 @@ in
config = mkIf config.services.printing.enable {
- users.users = singleton
- { name = "cups";
- uid = config.ids.uids.cups;
+ users.users.cups =
+ { uid = config.ids.uids.cups;
group = "lp";
description = "CUPS printing services";
};
diff --git a/nixpkgs/nixos/modules/services/scheduling/atd.nix b/nixpkgs/nixos/modules/services/scheduling/atd.nix
index a32907647a0..93ed9231d3c 100644
--- a/nixpkgs/nixos/modules/services/scheduling/atd.nix
+++ b/nixpkgs/nixos/modules/services/scheduling/atd.nix
@@ -57,17 +57,13 @@ in
security.pam.services.atd = {};
- users.users = singleton
- { name = "atd";
- uid = config.ids.uids.atd;
+ users.users.atd =
+ { uid = config.ids.uids.atd;
description = "atd user";
home = "/var/empty";
};
- users.groups = singleton
- { name = "atd";
- gid = config.ids.gids.atd;
- };
+ users.groups.atd.gid = config.ids.gids.atd;
systemd.services.atd = {
description = "Job Execution Daemon (atd)";
diff --git a/nixpkgs/nixos/modules/services/scheduling/fcron.nix b/nixpkgs/nixos/modules/services/scheduling/fcron.nix
index e43ca014e14..42bed21bf25 100644
--- a/nixpkgs/nixos/modules/services/scheduling/fcron.nix
+++ b/nixpkgs/nixos/modules/services/scheduling/fcron.nix
@@ -86,7 +86,8 @@ in
services.fcron.systab = systemCronJobs;
- environment.etc =
+ environment.etc = listToAttrs
+ (map (x: { name = x.target; value = x; })
[ (allowdeny "allow" (cfg.allow))
(allowdeny "deny" cfg.deny)
# see man 5 fcron.conf
@@ -112,7 +113,7 @@ in
gid = config.ids.gids.fcron;
mode = "0644";
}
- ];
+ ]);
environment.systemPackages = [ pkgs.fcron ];
users.users.fcron = {
diff --git a/nixpkgs/nixos/modules/services/search/hound.nix b/nixpkgs/nixos/modules/services/search/hound.nix
index 6740928db9a..7a44489efe6 100644
--- a/nixpkgs/nixos/modules/services/search/hound.nix
+++ b/nixpkgs/nixos/modules/services/search/hound.nix
@@ -88,19 +88,19 @@ in {
};
config = mkIf cfg.enable {
- users.groups = optional (cfg.group == "hound") {
- name = "hound";
- gid = config.ids.gids.hound;
+ users.groups = optionalAttrs (cfg.group == "hound") {
+ hound.gid = config.ids.gids.hound;
};
- users.users = optional (cfg.user == "hound") {
- name = "hound";
- description = "hound code search";
- createHome = true;
- home = cfg.home;
- group = cfg.group;
- extraGroups = cfg.extraGroups;
- uid = config.ids.uids.hound;
+ users.users = optionalAttrs (cfg.user == "hound") {
+ hound = {
+ description = "hound code search";
+ createHome = true;
+ home = cfg.home;
+ group = cfg.group;
+ extraGroups = cfg.extraGroups;
+ uid = config.ids.uids.hound;
+ };
};
systemd.services.hound = {
diff --git a/nixpkgs/nixos/modules/services/search/kibana.nix b/nixpkgs/nixos/modules/services/search/kibana.nix
index 43a63aa8fdc..2beb265ee5d 100644
--- a/nixpkgs/nixos/modules/services/search/kibana.nix
+++ b/nixpkgs/nixos/modules/services/search/kibana.nix
@@ -198,8 +198,7 @@ in {
environment.systemPackages = [ cfg.package ];
- users.users = singleton {
- name = "kibana";
+ users.users.kibana = {
uid = config.ids.uids.kibana;
description = "Kibana service user";
home = cfg.dataDir;
diff --git a/nixpkgs/nixos/modules/services/search/solr.nix b/nixpkgs/nixos/modules/services/search/solr.nix
index 5ef7d9893a4..b2176225493 100644
--- a/nixpkgs/nixos/modules/services/search/solr.nix
+++ b/nixpkgs/nixos/modules/services/search/solr.nix
@@ -100,18 +100,18 @@ in
};
};
- users.users = optionalAttrs (cfg.user == "solr") (singleton
- { name = "solr";
+ users.users = optionalAttrs (cfg.user == "solr") {
+ solr = {
group = cfg.group;
home = cfg.stateDir;
createHome = true;
uid = config.ids.uids.solr;
- });
+ };
+ };
- users.groups = optionalAttrs (cfg.group == "solr") (singleton
- { name = "solr";
- gid = config.ids.gids.solr;
- });
+ users.groups = optionalAttrs (cfg.group == "solr") {
+ solr.gid = config.ids.gids.solr;
+ };
};
diff --git a/nixpkgs/nixos/modules/services/security/clamav.nix b/nixpkgs/nixos/modules/services/security/clamav.nix
index 04b433f8f2b..aaf6fb0479b 100644
--- a/nixpkgs/nixos/modules/services/security/clamav.nix
+++ b/nixpkgs/nixos/modules/services/security/clamav.nix
@@ -30,6 +30,10 @@ let
'';
in
{
+ imports = [
+ (mkRenamedOptionModule [ "services" "clamav" "updater" "config" ] [ "services" "clamav" "updater" "extraConfig" ])
+ ];
+
options = {
services.clamav = {
daemon = {
@@ -79,18 +83,15 @@ in
config = mkIf (cfg.updater.enable || cfg.daemon.enable) {
environment.systemPackages = [ pkg ];
- users.users = singleton {
- name = clamavUser;
+ users.users.${clamavUser} = {
uid = config.ids.uids.clamav;
group = clamavGroup;
description = "ClamAV daemon user";
home = stateDir;
};
- users.groups = singleton {
- name = clamavGroup;
- gid = config.ids.gids.clamav;
- };
+ users.groups.${clamavGroup} =
+ { gid = config.ids.gids.clamav; };
environment.etc."clamav/freshclam.conf".source = freshclamConfigFile;
environment.etc."clamav/clamd.conf".source = clamdConfigFile;
diff --git a/nixpkgs/nixos/modules/services/security/fprot.nix b/nixpkgs/nixos/modules/services/security/fprot.nix
index 47449039146..f203f2abc03 100644
--- a/nixpkgs/nixos/modules/services/security/fprot.nix
+++ b/nixpkgs/nixos/modules/services/security/fprot.nix
@@ -48,22 +48,18 @@ in {
services.fprot.updater.licenseKeyfile = mkDefault "${pkgs.fprot}/opt/f-prot/license.key";
environment.systemPackages = [ pkgs.fprot ];
- environment.etc = singleton {
+ environment.etc."f-prot.conf" = {
source = "${pkgs.fprot}/opt/f-prot/f-prot.conf";
- target = "f-prot.conf";
};
- users.users = singleton
- { name = fprotUser;
- uid = config.ids.uids.fprot;
+ users.users.${fprotUser} =
+ { uid = config.ids.uids.fprot;
description = "F-Prot daemon user";
home = stateDir;
};
- users.groups = singleton
- { name = fprotGroup;
- gid = config.ids.gids.fprot;
- };
+ users.groups.${fprotGroup} =
+ { gid = config.ids.gids.fprot; };
services.cron.systemCronJobs = [ "*/${toString cfg.updater.frequency} * * * * root start fprot-updater" ];
diff --git a/nixpkgs/nixos/modules/services/security/tor.nix b/nixpkgs/nixos/modules/services/security/tor.nix
index ed862387cce..18c105b2f57 100644
--- a/nixpkgs/nixos/modules/services/security/tor.nix
+++ b/nixpkgs/nixos/modules/services/security/tor.nix
@@ -106,6 +106,12 @@ let
in
{
+ imports = [
+ (mkRenamedOptionModule [ "services" "tor" "relay" "portSpec" ] [ "services" "tor" "relay" "port" ])
+ (mkRemovedOptionModule [ "services" "tor" "relay" "isBridge" ] "Use services.tor.relay.role instead.")
+ (mkRemovedOptionModule [ "services" "tor" "relay" "isExit" ] "Use services.tor.relay.role instead.")
+ ];
+
options = {
services.tor = {
enable = mkOption {
diff --git a/nixpkgs/nixos/modules/services/security/torify.nix b/nixpkgs/nixos/modules/services/security/torify.nix
index 08da726437e..39551190dd3 100644
--- a/nixpkgs/nixos/modules/services/security/torify.nix
+++ b/nixpkgs/nixos/modules/services/security/torify.nix
@@ -25,6 +25,7 @@ in
services.tor.tsocks = {
enable = mkOption {
+ type = types.bool;
default = false;
description = ''
Whether to build tsocks wrapper script to relay application traffic via Tor.
@@ -40,6 +41,7 @@ in
};
server = mkOption {
+ type = types.str;
default = "localhost:9050";
example = "192.168.0.20";
description = ''
@@ -48,6 +50,7 @@ in
};
config = mkOption {
+ type = types.lines;
default = "";
description = ''
Extra configuration. Contents will be added verbatim to TSocks
diff --git a/nixpkgs/nixos/modules/services/security/torsocks.nix b/nixpkgs/nixos/modules/services/security/torsocks.nix
index c60c745443b..47ac95c4626 100644
--- a/nixpkgs/nixos/modules/services/security/torsocks.nix
+++ b/nixpkgs/nixos/modules/services/security/torsocks.nix
@@ -112,10 +112,9 @@ in
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.torsocks (wrapTorsocks "torsocks-faster" cfg.fasterServer) ];
- environment.etc =
- [ { source = pkgs.writeText "torsocks.conf" (configFile cfg.server);
- target = "tor/torsocks.conf";
- }
- ];
+ environment.etc."tor/torsocks.conf" =
+ {
+ source = pkgs.writeText "torsocks.conf" (configFile cfg.server);
+ };
};
}
diff --git a/nixpkgs/nixos/modules/services/system/dbus.nix b/nixpkgs/nixos/modules/services/system/dbus.nix
index 936646a5fd7..4a60fec1ca8 100644
--- a/nixpkgs/nixos/modules/services/system/dbus.nix
+++ b/nixpkgs/nixos/modules/services/system/dbus.nix
@@ -68,10 +68,7 @@ in
environment.systemPackages = [ pkgs.dbus.daemon pkgs.dbus ];
- environment.etc = singleton
- { source = configDir;
- target = "dbus-1";
- };
+ environment.etc."dbus-1".source = configDir;
users.users.messagebus = {
uid = config.ids.uids.messagebus;
diff --git a/nixpkgs/nixos/modules/services/system/localtime.nix b/nixpkgs/nixos/modules/services/system/localtime.nix
index c3c0b432b49..74925c5e2c4 100644
--- a/nixpkgs/nixos/modules/services/system/localtime.nix
+++ b/nixpkgs/nixos/modules/services/system/localtime.nix
@@ -35,6 +35,10 @@ in {
# Install the systemd unit.
systemd.packages = [ pkgs.localtime.out ];
+ users.users.localtimed = {
+ description = "Taskserver user";
+ };
+
systemd.services.localtime = {
wantedBy = [ "multi-user.target" ];
serviceConfig.Restart = "on-failure";
diff --git a/nixpkgs/nixos/modules/services/torrent/magnetico.nix b/nixpkgs/nixos/modules/services/torrent/magnetico.nix
index 719827713ff..7465c10e002 100644
--- a/nixpkgs/nixos/modules/services/torrent/magnetico.nix
+++ b/nixpkgs/nixos/modules/services/torrent/magnetico.nix
@@ -213,4 +213,6 @@ in {
};
+ meta.maintainers = with lib.maintainers; [ rnhmjoj ];
+
}
diff --git a/nixpkgs/nixos/modules/services/torrent/transmission.nix b/nixpkgs/nixos/modules/services/torrent/transmission.nix
index 7409eb8cdcb..aa1acdf7d20 100644
--- a/nixpkgs/nixos/modules/services/torrent/transmission.nix
+++ b/nixpkgs/nixos/modules/services/torrent/transmission.nix
@@ -7,6 +7,7 @@ let
apparmor = config.security.apparmor.enable;
homeDir = cfg.home;
+ downloadDirPermissions = cfg.downloadDirPermissions;
downloadDir = "${homeDir}/Downloads";
incompleteDir = "${homeDir}/.incomplete";
@@ -16,16 +17,14 @@ let
# for users in group "transmission" to have access to torrents
fullSettings = { umask = 2; download-dir = downloadDir; incomplete-dir = incompleteDir; } // cfg.settings;
- # Directories transmission expects to exist and be ug+rwx.
- directoriesToManage = [ homeDir settingsDir fullSettings.download-dir fullSettings.incomplete-dir ];
-
preStart = pkgs.writeScript "transmission-pre-start" ''
#!${pkgs.runtimeShell}
set -ex
- for DIR in ${escapeShellArgs directoriesToManage}; do
+ for DIR in "${homeDir}" "${settingsDir}" "${fullSettings.download-dir}" "${fullSettings.incomplete-dir}"; do
mkdir -p "$DIR"
- chmod 770 "$DIR"
done
+ chmod 700 "${homeDir}" "${settingsDir}"
+ chmod ${downloadDirPermissions} "${fullSettings.download-dir}" "${fullSettings.incomplete-dir}"
cp -f ${settingsFile} ${settingsDir}/settings.json
'';
in
@@ -71,6 +70,16 @@ in
'';
};
+ downloadDirPermissions = mkOption {
+ type = types.str;
+ default = "770";
+ example = "775";
+ description = ''
+ The permissions to set for download-dir and incomplete-dir.
+ They will be applied on every service start.
+ '';
+ };
+
port = mkOption {
type = types.int;
default = 9091;
@@ -109,7 +118,7 @@ in
# 1) Only the "transmission" user and group have access to torrents.
# 2) Optionally update/force specific fields into the configuration file.
serviceConfig.ExecStartPre = preStart;
- serviceConfig.ExecStart = "${pkgs.transmission}/bin/transmission-daemon -f --port ${toString config.services.transmission.port}";
+ serviceConfig.ExecStart = "${pkgs.transmission}/bin/transmission-daemon -f --port ${toString config.services.transmission.port} --config-dir ${settingsDir}";
serviceConfig.ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
serviceConfig.User = cfg.user;
serviceConfig.Group = cfg.group;
diff --git a/nixpkgs/nixos/modules/services/ttys/agetty.nix b/nixpkgs/nixos/modules/services/ttys/agetty.nix
index f127d8a0276..f3a629f7af7 100644
--- a/nixpkgs/nixos/modules/services/ttys/agetty.nix
+++ b/nixpkgs/nixos/modules/services/ttys/agetty.nix
@@ -102,7 +102,7 @@ in
enable = mkDefault config.boot.isContainer;
};
- environment.etc = singleton
+ environment.etc.issue =
{ # Friendly greeting on the virtual consoles.
source = pkgs.writeText "issue" ''
@@ -110,7 +110,6 @@ in
${config.services.mingetty.helpLine}
'';
- target = "issue";
};
};
diff --git a/nixpkgs/nixos/modules/services/web-apps/frab.nix b/nixpkgs/nixos/modules/services/web-apps/frab.nix
index a9a30b40922..1b5890d6b0c 100644
--- a/nixpkgs/nixos/modules/services/web-apps/frab.nix
+++ b/nixpkgs/nixos/modules/services/web-apps/frab.nix
@@ -173,15 +173,13 @@ in
config = mkIf cfg.enable {
environment.systemPackages = [ frab-rake ];
- users.users = [
- { name = cfg.user;
- group = cfg.group;
+ users.users.${cfg.user} =
+ { group = cfg.group;
home = "${cfg.statePath}";
isSystemUser = true;
- }
- ];
+ };
- users.groups = [ { name = cfg.group; } ];
+ users.groups.${cfg.group} = { };
systemd.tmpfiles.rules = [
"d '${cfg.statePath}/system/attachments' - ${cfg.user} ${cfg.group} - -"
diff --git a/nixpkgs/nixos/modules/services/web-apps/ihatemoney/default.nix b/nixpkgs/nixos/modules/services/web-apps/ihatemoney/default.nix
new file mode 100644
index 00000000000..68769ac8c03
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/web-apps/ihatemoney/default.nix
@@ -0,0 +1,141 @@
+{ config, pkgs, lib, ... }:
+with lib;
+let
+ cfg = config.services.ihatemoney;
+ user = "ihatemoney";
+ group = "ihatemoney";
+ db = "ihatemoney";
+ python3 = config.services.uwsgi.package.python3;
+ pkg = python3.pkgs.ihatemoney;
+ toBool = x: if x then "True" else "False";
+ configFile = pkgs.writeText "ihatemoney.cfg" ''
+ from secrets import token_hex
+ # load a persistent secret key
+ SECRET_KEY_FILE = "/var/lib/ihatemoney/secret_key"
+ SECRET_KEY = ""
+ try:
+ with open(SECRET_KEY_FILE) as f:
+ SECRET_KEY = f.read()
+ except FileNotFoundError:
+ pass
+ if not SECRET_KEY:
+ print("ihatemoney: generating a new secret key")
+ SECRET_KEY = token_hex(50)
+ with open(SECRET_KEY_FILE, "w") as f:
+ f.write(SECRET_KEY)
+ del token_hex
+ del SECRET_KEY_FILE
+
+ # "normal" configuration
+ DEBUG = False
+ SQLALCHEMY_DATABASE_URI = '${
+ if cfg.backend == "sqlite"
+ then "sqlite:////var/lib/ihatemoney/ihatemoney.sqlite"
+ else "postgresql:///${db}"}'
+ SQLALCHEMY_TRACK_MODIFICATIONS = False
+ MAIL_DEFAULT_SENDER = ("${cfg.defaultSender.name}", "${cfg.defaultSender.email}")
+ ACTIVATE_DEMO_PROJECT = ${toBool cfg.enableDemoProject}
+ ADMIN_PASSWORD = "${toString cfg.adminHashedPassword /*toString null == ""*/}"
+ ALLOW_PUBLIC_PROJECT_CREATION = ${toBool cfg.enablePublicProjectCreation}
+ ACTIVATE_ADMIN_DASHBOARD = ${toBool cfg.enableAdminDashboard}
+
+ ${cfg.extraConfig}
+ '';
+in
+ {
+ options.services.ihatemoney = {
+ enable = mkEnableOption "ihatemoney webapp. Note that this will set uwsgi to emperor mode running as root";
+ backend = mkOption {
+ type = types.enum [ "sqlite" "postgresql" ];
+ default = "sqlite";
+ description = ''
+ The database engine to use for ihatemoney.
+ If <literal>postgresql</literal> is selected, then a database called
+ <literal>${db}</literal> will be created. If you disable this option,
+ it will however not be removed.
+ '';
+ };
+ adminHashedPassword = mkOption {
+ type = types.nullOr types.str;
+ default = null;
+ description = "The hashed password of the administrator. To obtain it, run <literal>ihatemoney generate_password_hash</literal>";
+ };
+ uwsgiConfig = mkOption {
+ type = types.attrs;
+ example = {
+ http = ":8000";
+ };
+ description = "Additionnal configuration of the UWSGI vassal running ihatemoney. It should notably specify on which interfaces and ports the vassal should listen.";
+ };
+ defaultSender = {
+ name = mkOption {
+ type = types.str;
+ default = "Budget manager";
+ description = "The display name of the sender of ihatemoney emails";
+ };
+ email = mkOption {
+ type = types.str;
+ default = "ihatemoney@${config.networking.hostName}";
+ description = "The email of the sender of ihatemoney emails";
+ };
+ };
+ enableDemoProject = mkEnableOption "access to the demo project in ihatemoney";
+ enablePublicProjectCreation = mkEnableOption "permission to create projects in ihatemoney by anyone";
+ enableAdminDashboard = mkEnableOption "ihatemoney admin dashboard";
+ extraConfig = mkOption {
+ type = types.str;
+ default = "";
+ description = "Extra configuration appended to ihatemoney's configuration file. It is a python file, so pay attention to indentation.";
+ };
+ };
+ config = mkIf cfg.enable {
+ services.postgresql = mkIf (cfg.backend == "postgresql") {
+ enable = true;
+ ensureDatabases = [ db ];
+ ensureUsers = [ {
+ name = user;
+ ensurePermissions = {
+ "DATABASE ${db}" = "ALL PRIVILEGES";
+ };
+ } ];
+ };
+ systemd.services.postgresql = mkIf (cfg.backend == "postgresql") {
+ wantedBy = [ "uwsgi.service" ];
+ before = [ "uwsgi.service" ];
+ };
+ systemd.tmpfiles.rules = [
+ "d /var/lib/ihatemoney 770 ${user} ${group}"
+ ];
+ users = {
+ users.${user} = {
+ isSystemUser = true;
+ inherit group;
+ };
+ groups.${group} = {};
+ };
+ services.uwsgi = {
+ enable = true;
+ plugins = [ "python3" ];
+ # the vassal needs to be able to setuid
+ user = "root";
+ group = "root";
+ instance = {
+ type = "emperor";
+ vassals.ihatemoney = {
+ type = "normal";
+ strict = true;
+ uid = user;
+ gid = group;
+ # apparently flask uses threads: https://github.com/spiral-project/ihatemoney/commit/c7815e48781b6d3a457eaff1808d179402558f8c
+ enable-threads = true;
+ module = "wsgi:application";
+ chdir = "${pkg}/${pkg.pythonModule.sitePackages}/ihatemoney";
+ env = [ "IHATEMONEY_SETTINGS_FILE_PATH=${configFile}" ];
+ pythonPackages = self: [ self.ihatemoney ];
+ } // cfg.uwsgiConfig;
+ };
+ };
+ };
+ }
+
+
diff --git a/nixpkgs/nixos/modules/services/web-apps/limesurvey.nix b/nixpkgs/nixos/modules/services/web-apps/limesurvey.nix
index bd524524130..e00a47191c6 100644
--- a/nixpkgs/nixos/modules/services/web-apps/limesurvey.nix
+++ b/nixpkgs/nixos/modules/services/web-apps/limesurvey.nix
@@ -3,7 +3,7 @@
let
inherit (lib) mkDefault mkEnableOption mkForce mkIf mkMerge mkOption;
- inherit (lib) mapAttrs optional optionalString types;
+ inherit (lib) literalExample mapAttrs optional optionalString types;
cfg = config.services.limesurvey;
fpm = config.services.phpfpm.pools.limesurvey;
@@ -100,19 +100,15 @@ in
};
virtualHost = mkOption {
- type = types.submodule ({
- options = import ../web-servers/apache-httpd/per-server-options.nix {
- inherit lib;
- forMainServer = false;
- };
- });
- example = {
- hostName = "survey.example.org";
- enableSSL = true;
- adminAddr = "webmaster@example.org";
- sslServerCert = "/var/lib/acme/survey.example.org/full.pem";
- sslServerKey = "/var/lib/acme/survey.example.org/key.pem";
- };
+ type = types.submodule (import ../web-servers/apache-httpd/per-server-options.nix);
+ example = literalExample ''
+ {
+ hostName = "survey.example.org";
+ adminAddr = "webmaster@example.org";
+ forceSSL = true;
+ enableACME = true;
+ }
+ '';
description = ''
Apache configuration can be done by adapting <literal>services.httpd.virtualHosts.&lt;name&gt;</literal>.
See <xref linkend="opt-services.httpd.virtualHosts"/> for further information.
@@ -184,7 +180,7 @@ in
config = {
tempdir = "${stateDir}/tmp";
uploaddir = "${stateDir}/upload";
- force_ssl = mkIf cfg.virtualHost.enableSSL "on";
+ force_ssl = mkIf (cfg.virtualHost.addSSL || cfg.virtualHost.forceSSL || cfg.virtualHost.onlySSL) "on";
config.defaultlang = "en";
};
};
@@ -215,38 +211,36 @@ in
enable = true;
adminAddr = mkDefault cfg.virtualHost.adminAddr;
extraModules = [ "proxy_fcgi" ];
- virtualHosts = [ (mkMerge [
- cfg.virtualHost {
- documentRoot = mkForce "${pkg}/share/limesurvey";
- extraConfig = ''
- Alias "/tmp" "${stateDir}/tmp"
- <Directory "${stateDir}">
- AllowOverride all
- Require all granted
- Options -Indexes +FollowSymlinks
- </Directory>
-
- Alias "/upload" "${stateDir}/upload"
- <Directory "${stateDir}/upload">
- AllowOverride all
- Require all granted
- Options -Indexes
- </Directory>
-
- <Directory "${pkg}/share/limesurvey">
- <FilesMatch "\.php$">
- <If "-f %{REQUEST_FILENAME}">
- SetHandler "proxy:unix:${fpm.socket}|fcgi://localhost/"
- </If>
- </FilesMatch>
-
- AllowOverride all
- Options -Indexes
- DirectoryIndex index.php
- </Directory>
- '';
- }
- ]) ];
+ virtualHosts.${cfg.virtualHost.hostName} = mkMerge [ cfg.virtualHost {
+ documentRoot = mkForce "${pkg}/share/limesurvey";
+ extraConfig = ''
+ Alias "/tmp" "${stateDir}/tmp"
+ <Directory "${stateDir}">
+ AllowOverride all
+ Require all granted
+ Options -Indexes +FollowSymlinks
+ </Directory>
+
+ Alias "/upload" "${stateDir}/upload"
+ <Directory "${stateDir}/upload">
+ AllowOverride all
+ Require all granted
+ Options -Indexes
+ </Directory>
+
+ <Directory "${pkg}/share/limesurvey">
+ <FilesMatch "\.php$">
+ <If "-f %{REQUEST_FILENAME}">
+ SetHandler "proxy:unix:${fpm.socket}|fcgi://localhost/"
+ </If>
+ </FilesMatch>
+
+ AllowOverride all
+ Options -Indexes
+ DirectoryIndex index.php
+ </Directory>
+ '';
+ } ];
};
systemd.tmpfiles.rules = [
diff --git a/nixpkgs/nixos/modules/services/web-apps/matomo.nix b/nixpkgs/nixos/modules/services/web-apps/matomo.nix
index 352cc4c647b..75da474dc44 100644
--- a/nixpkgs/nixos/modules/services/web-apps/matomo.nix
+++ b/nixpkgs/nixos/modules/services/web-apps/matomo.nix
@@ -18,6 +18,14 @@ let
in join config.networking.hostName config.networking.domain;
in {
+ imports = [
+ (mkRenamedOptionModule [ "services" "piwik" "enable" ] [ "services" "matomo" "enable" ])
+ (mkRenamedOptionModule [ "services" "piwik" "webServerUser" ] [ "services" "matomo" "webServerUser" ])
+ (mkRemovedOptionModule [ "services" "piwik" "phpfpmProcessManagerConfig" ] "Use services.phpfpm.pools.<name>.settings")
+ (mkRemovedOptionModule [ "services" "matomo" "phpfpmProcessManagerConfig" ] "Use services.phpfpm.pools.<name>.settings")
+ (mkRenamedOptionModule [ "services" "piwik" "nginx" ] [ "services" "matomo" "nginx" ])
+ ];
+
options = {
services.matomo = {
# NixOS PR for database setup: https://github.com/NixOS/nixpkgs/pull/6963
diff --git a/nixpkgs/nixos/modules/services/web-apps/mattermost.nix b/nixpkgs/nixos/modules/services/web-apps/mattermost.nix
index 8c7fc4056ad..41c52b9653b 100644
--- a/nixpkgs/nixos/modules/services/web-apps/mattermost.nix
+++ b/nixpkgs/nixos/modules/services/web-apps/mattermost.nix
@@ -146,17 +146,17 @@ in
config = mkMerge [
(mkIf cfg.enable {
- users.users = optionalAttrs (cfg.user == "mattermost") (singleton {
- name = "mattermost";
- group = cfg.group;
- uid = config.ids.uids.mattermost;
- home = cfg.statePath;
- });
-
- users.groups = optionalAttrs (cfg.group == "mattermost") (singleton {
- name = "mattermost";
- gid = config.ids.gids.mattermost;
- });
+ users.users = optionalAttrs (cfg.user == "mattermost") {
+ mattermost = {
+ group = cfg.group;
+ uid = config.ids.uids.mattermost;
+ home = cfg.statePath;
+ };
+ };
+
+ users.groups = optionalAttrs (cfg.group == "mattermost") {
+ mattermost.gid = config.ids.gids.mattermost;
+ };
services.postgresql.enable = cfg.localDatabaseCreate;
diff --git a/nixpkgs/nixos/modules/services/web-apps/mediawiki.nix b/nixpkgs/nixos/modules/services/web-apps/mediawiki.nix
index 43edc04e1a4..8a109b39bb5 100644
--- a/nixpkgs/nixos/modules/services/web-apps/mediawiki.nix
+++ b/nixpkgs/nixos/modules/services/web-apps/mediawiki.nix
@@ -64,7 +64,7 @@ let
$wgScriptPath = "";
## The protocol and server name to use in fully-qualified URLs
- $wgServer = "${if cfg.virtualHost.enableSSL then "https" else "http"}://${cfg.virtualHost.hostName}";
+ $wgServer = "${if cfg.virtualHost.addSSL || cfg.virtualHost.forceSSL || cfg.virtualHost.onlySSL then "https" else "http"}://${cfg.virtualHost.hostName}";
## The URL path to static resources (images, scripts, etc.)
$wgResourceBasePath = $wgScriptPath;
@@ -290,19 +290,13 @@ in
};
virtualHost = mkOption {
- type = types.submodule ({
- options = import ../web-servers/apache-httpd/per-server-options.nix {
- inherit lib;
- forMainServer = false;
- };
- });
+ type = types.submodule (import ../web-servers/apache-httpd/per-server-options.nix);
example = literalExample ''
{
hostName = "mediawiki.example.org";
- enableSSL = true;
adminAddr = "webmaster@example.org";
- sslServerCert = "/var/lib/acme/mediawiki.example.org/full.pem";
- sslServerKey = "/var/lib/acme/mediawiki.example.org/key.pem";
+ forceSSL = true;
+ enableACME = true;
}
'';
description = ''
@@ -389,31 +383,28 @@ in
services.httpd = {
enable = true;
- adminAddr = mkDefault cfg.virtualHost.adminAddr;
extraModules = [ "proxy_fcgi" ];
- virtualHosts = [ (mkMerge [
- cfg.virtualHost {
- documentRoot = mkForce "${pkg}/share/mediawiki";
- extraConfig = ''
- <Directory "${pkg}/share/mediawiki">
- <FilesMatch "\.php$">
- <If "-f %{REQUEST_FILENAME}">
- SetHandler "proxy:unix:${fpm.socket}|fcgi://localhost/"
- </If>
- </FilesMatch>
-
- Require all granted
- DirectoryIndex index.php
- AllowOverride All
- </Directory>
- '' + optionalString (cfg.uploadsDir != null) ''
- Alias "/images" "${cfg.uploadsDir}"
- <Directory "${cfg.uploadsDir}">
- Require all granted
- </Directory>
- '';
- }
- ]) ];
+ virtualHosts.${cfg.virtualHost.hostName} = mkMerge [ cfg.virtualHost {
+ documentRoot = mkForce "${pkg}/share/mediawiki";
+ extraConfig = ''
+ <Directory "${pkg}/share/mediawiki">
+ <FilesMatch "\.php$">
+ <If "-f %{REQUEST_FILENAME}">
+ SetHandler "proxy:unix:${fpm.socket}|fcgi://localhost/"
+ </If>
+ </FilesMatch>
+
+ Require all granted
+ DirectoryIndex index.php
+ AllowOverride All
+ </Directory>
+ '' + optionalString (cfg.uploadsDir != null) ''
+ Alias "/images" "${cfg.uploadsDir}"
+ <Directory "${cfg.uploadsDir}">
+ Require all granted
+ </Directory>
+ '';
+ } ];
};
systemd.tmpfiles.rules = [
diff --git a/nixpkgs/nixos/modules/services/web-apps/moodle.nix b/nixpkgs/nixos/modules/services/web-apps/moodle.nix
index ac59f9e0012..595d070d940 100644
--- a/nixpkgs/nixos/modules/services/web-apps/moodle.nix
+++ b/nixpkgs/nixos/modules/services/web-apps/moodle.nix
@@ -32,7 +32,7 @@ let
'dbcollation' => 'utf8mb4_unicode_ci',
);
- $CFG->wwwroot = '${if cfg.virtualHost.enableSSL then "https" else "http"}://${cfg.virtualHost.hostName}';
+ $CFG->wwwroot = '${if cfg.virtualHost.addSSL || cfg.virtualHost.forceSSL || cfg.virtualHost.onlySSL then "https" else "http"}://${cfg.virtualHost.hostName}';
$CFG->dataroot = '${stateDir}';
$CFG->admin = 'admin';
@@ -140,19 +140,15 @@ in
};
virtualHost = mkOption {
- type = types.submodule ({
- options = import ../web-servers/apache-httpd/per-server-options.nix {
- inherit lib;
- forMainServer = false;
- };
- });
- example = {
- hostName = "moodle.example.org";
- enableSSL = true;
- adminAddr = "webmaster@example.org";
- sslServerCert = "/var/lib/acme/moodle.example.org/full.pem";
- sslServerKey = "/var/lib/acme/moodle.example.org/key.pem";
- };
+ type = types.submodule (import ../web-servers/apache-httpd/per-server-options.nix);
+ example = literalExample ''
+ {
+ hostName = "moodle.example.org";
+ adminAddr = "webmaster@example.org";
+ forceSSL = true;
+ enableACME = true;
+ }
+ '';
description = ''
Apache configuration can be done by adapting <option>services.httpd.virtualHosts</option>.
See <xref linkend="opt-services.httpd.virtualHosts"/> for further information.
@@ -241,22 +237,20 @@ in
enable = true;
adminAddr = mkDefault cfg.virtualHost.adminAddr;
extraModules = [ "proxy_fcgi" ];
- virtualHosts = [ (mkMerge [
- cfg.virtualHost {
- documentRoot = mkForce "${cfg.package}/share/moodle";
- extraConfig = ''
- <Directory "${cfg.package}/share/moodle">
- <FilesMatch "\.php$">
- <If "-f %{REQUEST_FILENAME}">
- SetHandler "proxy:unix:${fpm.socket}|fcgi://localhost/"
- </If>
- </FilesMatch>
- Options -Indexes
- DirectoryIndex index.php
- </Directory>
- '';
- }
- ]) ];
+ virtualHosts.${cfg.virtualHost.hostName} = mkMerge [ cfg.virtualHost {
+ documentRoot = mkForce "${cfg.package}/share/moodle";
+ extraConfig = ''
+ <Directory "${cfg.package}/share/moodle">
+ <FilesMatch "\.php$">
+ <If "-f %{REQUEST_FILENAME}">
+ SetHandler "proxy:unix:${fpm.socket}|fcgi://localhost/"
+ </If>
+ </FilesMatch>
+ Options -Indexes
+ DirectoryIndex index.php
+ </Directory>
+ '';
+ } ];
};
systemd.tmpfiles.rules = [
diff --git a/nixpkgs/nixos/modules/services/web-apps/nextcloud.nix b/nixpkgs/nixos/modules/services/web-apps/nextcloud.nix
index b67f0880878..f1dabadc119 100644
--- a/nixpkgs/nixos/modules/services/web-apps/nextcloud.nix
+++ b/nixpkgs/nixos/modules/services/web-apps/nextcloud.nix
@@ -31,8 +31,12 @@ let
occ = pkgs.writeScriptBin "nextcloud-occ" ''
#! ${pkgs.stdenv.shell}
cd ${pkgs.nextcloud}
- exec /run/wrappers/bin/sudo -u nextcloud \
- NEXTCLOUD_CONFIG_DIR="${cfg.home}/config" \
+ sudo=exec
+ if [[ "$USER" != nextcloud ]]; then
+ sudo='exec /run/wrappers/bin/sudo -u nextcloud --preserve-env=NEXTCLOUD_CONFIG_DIR'
+ fi
+ export NEXTCLOUD_CONFIG_DIR="${cfg.home}/config"
+ $sudo \
${phpPackage}/bin/php \
-c ${pkgs.writeText "php.ini" phpOptionsStr}\
occ $*
@@ -58,7 +62,7 @@ in {
https = mkOption {
type = types.bool;
default = false;
- description = "Enable if there is a TLS terminating proxy in front of nextcloud.";
+ description = "Use https for generated links.";
};
maxUploadSize = mkOption {
@@ -420,6 +424,7 @@ in {
nextcloud-update-plugins = mkIf cfg.autoUpdateApps.enable {
serviceConfig.Type = "oneshot";
serviceConfig.ExecStart = "${occ}/bin/nextcloud-occ app:update --all";
+ serviceConfig.User = "nextcloud";
startAt = cfg.autoUpdateApps.startAt;
};
};
diff --git a/nixpkgs/nixos/modules/services/web-apps/restya-board.nix b/nixpkgs/nixos/modules/services/web-apps/restya-board.nix
index 2c2f36ac598..9d0a3f65253 100644
--- a/nixpkgs/nixos/modules/services/web-apps/restya-board.nix
+++ b/nixpkgs/nixos/modules/services/web-apps/restya-board.nix
@@ -116,7 +116,7 @@ in
};
passwordFile = mkOption {
- type = types.nullOr types.str;
+ type = types.nullOr types.path;
default = null;
description = ''
The database user's password. 'null' if no password is set.
@@ -285,7 +285,7 @@ in
sed -i "s/^.*'R_DB_PASSWORD'.*$/define('R_DB_PASSWORD', 'restya');/g" "${runDir}/server/php/config.inc.php"
'' else ''
sed -i "s/^.*'R_DB_HOST'.*$/define('R_DB_HOST', '${cfg.database.host}');/g" "${runDir}/server/php/config.inc.php"
- sed -i "s/^.*'R_DB_PASSWORD'.*$/define('R_DB_PASSWORD', '$(<${cfg.database.dbPassFile})');/g" "${runDir}/server/php/config.inc.php"
+ sed -i "s/^.*'R_DB_PASSWORD'.*$/define('R_DB_PASSWORD', ${if cfg.database.passwordFile == null then "''" else "'file_get_contents(${cfg.database.passwordFile})'"});/g" "${runDir}/server/php/config.inc.php
''}
sed -i "s/^.*'R_DB_PORT'.*$/define('R_DB_PORT', '${toString cfg.database.port}');/g" "${runDir}/server/php/config.inc.php"
sed -i "s/^.*'R_DB_NAME'.*$/define('R_DB_NAME', '${cfg.database.name}');/g" "${runDir}/server/php/config.inc.php"
diff --git a/nixpkgs/nixos/modules/services/web-apps/trilium.nix b/nixpkgs/nixos/modules/services/web-apps/trilium.nix
new file mode 100644
index 00000000000..6f47193c62b
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/web-apps/trilium.nix
@@ -0,0 +1,137 @@
+{ config, lib, pkgs, ... }:
+
+let
+ cfg = config.services.trilium-server;
+ configIni = pkgs.writeText "trilium-config.ini" ''
+ [General]
+ # Instance name can be used to distinguish between different instances
+ instanceName=${cfg.instanceName}
+
+ # Disable automatically generating desktop icon
+ noDesktopIcon=true
+
+ [Network]
+ # host setting is relevant only for web deployments - set the host on which the server will listen
+ host=${cfg.host}
+ # port setting is relevant only for web deployments, desktop builds run on random free port
+ port=${toString cfg.port}
+ # true for TLS/SSL/HTTPS (secure), false for HTTP (unsecure).
+ https=false
+ '';
+in
+{
+
+ options.services.trilium-server = with lib; {
+ enable = mkEnableOption "trilium-server";
+
+ dataDir = mkOption {
+ type = types.str;
+ default = "/var/lib/trilium";
+ description = ''
+ The directory storing the nodes database and the configuration.
+ '';
+ };
+
+ instanceName = mkOption {
+ type = types.str;
+ default = "Trilium";
+ description = ''
+ Instance name used to distinguish between different instances
+ '';
+ };
+
+ host = mkOption {
+ type = types.str;
+ default = "127.0.0.1";
+ description = ''
+ The host address to bind to (defaults to localhost).
+ '';
+ };
+
+ port = mkOption {
+ type = types.int;
+ default = 8080;
+ description = ''
+ The port number to bind to.
+ '';
+ };
+
+ nginx = mkOption {
+ default = {};
+ description = ''
+ Configuration for nginx reverse proxy.
+ '';
+
+ type = types.submodule {
+ options = {
+ enable = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Configure the nginx reverse proxy settings.
+ '';
+ };
+
+ hostName = mkOption {
+ type = types.str;
+ description = ''
+ The hostname use to setup the virtualhost configuration
+ '';
+ };
+ };
+ };
+ };
+ };
+
+ config = lib.mkIf cfg.enable (lib.mkMerge [
+ {
+ meta.maintainers = with lib.maintainers; [ kampka ];
+
+ users.groups.trilium = {};
+ users.users.trilium = {
+ description = "Trilium User";
+ group = "trilium";
+ home = cfg.dataDir;
+ isSystemUser = true;
+ };
+
+ systemd.services.trilium-server = {
+ wantedBy = [ "multi-user.target" ];
+ environment.TRILIUM_DATA_DIR = cfg.dataDir;
+ serviceConfig = {
+ ExecStart = "${pkgs.trilium-server}/bin/trilium-server";
+ User = "trilium";
+ Group = "trilium";
+ PrivateTmp = "true";
+ };
+ };
+
+ systemd.tmpfiles.rules = [
+ "d ${cfg.dataDir} 0750 trilium trilium - -"
+ "L+ ${cfg.dataDir}/config.ini - - - - ${configIni}"
+ ];
+
+ }
+
+ (lib.mkIf cfg.nginx.enable {
+ services.nginx = {
+ enable = true;
+ virtualHosts."${cfg.nginx.hostName}" = {
+ locations."/" = {
+ proxyPass = "http://${cfg.host}:${toString cfg.port}/";
+ extraConfig = ''
+ proxy_http_version 1.1;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection 'upgrade';
+ proxy_set_header Host $host;
+ proxy_cache_bypass $http_upgrade;
+ '';
+ };
+ extraConfig = ''
+ client_max_body_size 0;
+ '';
+ };
+ };
+ })
+ ]);
+}
diff --git a/nixpkgs/nixos/modules/services/web-apps/wordpress.nix b/nixpkgs/nixos/modules/services/web-apps/wordpress.nix
index f1370c2854b..ad4f39fbf52 100644
--- a/nixpkgs/nixos/modules/services/web-apps/wordpress.nix
+++ b/nixpkgs/nixos/modules/services/web-apps/wordpress.nix
@@ -3,7 +3,7 @@
let
inherit (lib) mkDefault mkEnableOption mkForce mkIf mkMerge mkOption types;
inherit (lib) any attrValues concatMapStringsSep flatten literalExample;
- inherit (lib) mapAttrs' mapAttrsToList nameValuePair optional optionalAttrs optionalString;
+ inherit (lib) mapAttrs mapAttrs' mapAttrsToList nameValuePair optional optionalAttrs optionalString;
eachSite = config.services.wordpress;
user = "wordpress";
@@ -127,7 +127,7 @@ let
<note><para>These themes need to be packaged before use, see example.</para></note>
'';
example = ''
- # For shits and giggles, let's package the responsive theme
+ # Let's package the responsive theme
responsiveTheme = pkgs.stdenv.mkDerivation {
name = "responsive-theme";
# Download the theme from the wordpress site
@@ -209,18 +209,12 @@ let
};
virtualHost = mkOption {
- type = types.submodule ({
- options = import ../web-servers/apache-httpd/per-server-options.nix {
- inherit lib;
- forMainServer = false;
- };
- });
+ type = types.submodule (import ../web-servers/apache-httpd/per-server-options.nix);
example = literalExample ''
{
- enableSSL = true;
adminAddr = "webmaster@example.org";
- sslServerCert = "/var/lib/acme/wordpress.example.org/full.pem";
- sslServerKey = "/var/lib/acme/wordpress.example.org/key.pem";
+ forceSSL = true;
+ enableACME = true;
}
'';
description = ''
@@ -304,41 +298,37 @@ in
services.httpd = {
enable = true;
extraModules = [ "proxy_fcgi" ];
- virtualHosts = mapAttrsToList (hostName: cfg:
- (mkMerge [
- cfg.virtualHost {
- documentRoot = mkForce "${pkg hostName cfg}/share/wordpress";
- extraConfig = ''
- <Directory "${pkg hostName cfg}/share/wordpress">
- <FilesMatch "\.php$">
- <If "-f %{REQUEST_FILENAME}">
- SetHandler "proxy:unix:${config.services.phpfpm.pools."wordpress-${hostName}".socket}|fcgi://localhost/"
- </If>
- </FilesMatch>
-
- # standard wordpress .htaccess contents
- <IfModule mod_rewrite.c>
- RewriteEngine On
- RewriteBase /
- RewriteRule ^index\.php$ - [L]
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteRule . /index.php [L]
- </IfModule>
-
- DirectoryIndex index.php
- Require all granted
- Options +FollowSymLinks
- </Directory>
-
- # https://wordpress.org/support/article/hardening-wordpress/#securing-wp-config-php
- <Files wp-config.php>
- Require all denied
- </Files>
- '';
- }
- ])
- ) eachSite;
+ virtualHosts = mapAttrs (hostName: cfg: mkMerge [ cfg.virtualHost {
+ documentRoot = mkForce "${pkg hostName cfg}/share/wordpress";
+ extraConfig = ''
+ <Directory "${pkg hostName cfg}/share/wordpress">
+ <FilesMatch "\.php$">
+ <If "-f %{REQUEST_FILENAME}">
+ SetHandler "proxy:unix:${config.services.phpfpm.pools."wordpress-${hostName}".socket}|fcgi://localhost/"
+ </If>
+ </FilesMatch>
+
+ # standard wordpress .htaccess contents
+ <IfModule mod_rewrite.c>
+ RewriteEngine On
+ RewriteBase /
+ RewriteRule ^index\.php$ - [L]
+ RewriteCond %{REQUEST_FILENAME} !-f
+ RewriteCond %{REQUEST_FILENAME} !-d
+ RewriteRule . /index.php [L]
+ </IfModule>
+
+ DirectoryIndex index.php
+ Require all granted
+ Options +FollowSymLinks
+ </Directory>
+
+ # https://wordpress.org/support/article/hardening-wordpress/#securing-wp-config-php
+ <Files wp-config.php>
+ Require all denied
+ </Files>
+ '';
+ } ]) eachSite;
};
systemd.tmpfiles.rules = flatten (mapAttrsToList (hostName: cfg: [
diff --git a/nixpkgs/nixos/modules/services/web-apps/zabbix.nix b/nixpkgs/nixos/modules/services/web-apps/zabbix.nix
index 09538726b7c..ee8447810c6 100644
--- a/nixpkgs/nixos/modules/services/web-apps/zabbix.nix
+++ b/nixpkgs/nixos/modules/services/web-apps/zabbix.nix
@@ -113,19 +113,15 @@ in
};
virtualHost = mkOption {
- type = types.submodule ({
- options = import ../web-servers/apache-httpd/per-server-options.nix {
- inherit lib;
- forMainServer = false;
- };
- });
- example = {
- hostName = "zabbix.example.org";
- enableSSL = true;
- adminAddr = "webmaster@example.org";
- sslServerCert = "/var/lib/acme/zabbix.example.org/full.pem";
- sslServerKey = "/var/lib/acme/zabbix.example.org/key.pem";
- };
+ type = types.submodule (import ../web-servers/apache-httpd/per-server-options.nix);
+ example = literalExample ''
+ {
+ hostName = "zabbix.example.org";
+ adminAddr = "webmaster@example.org";
+ forceSSL = true;
+ enableACME = true;
+ }
+ '';
description = ''
Apache configuration can be done by adapting <literal>services.httpd.virtualHosts.&lt;name&gt;</literal>.
See <xref linkend="opt-services.httpd.virtualHosts"/> for further information.
@@ -190,23 +186,21 @@ in
enable = true;
adminAddr = mkDefault cfg.virtualHost.adminAddr;
extraModules = [ "proxy_fcgi" ];
- virtualHosts = [ (mkMerge [
- cfg.virtualHost {
- documentRoot = mkForce "${cfg.package}/share/zabbix";
- extraConfig = ''
- <Directory "${cfg.package}/share/zabbix">
- <FilesMatch "\.php$">
- <If "-f %{REQUEST_FILENAME}">
- SetHandler "proxy:unix:${fpm.socket}|fcgi://localhost/"
- </If>
- </FilesMatch>
- AllowOverride all
- Options -Indexes
- DirectoryIndex index.php
- </Directory>
- '';
- }
- ]) ];
+ virtualHosts.${cfg.virtualHost.hostName} = mkMerge [ cfg.virtualHost {
+ documentRoot = mkForce "${cfg.package}/share/zabbix";
+ extraConfig = ''
+ <Directory "${cfg.package}/share/zabbix">
+ <FilesMatch "\.php$">
+ <If "-f %{REQUEST_FILENAME}">
+ SetHandler "proxy:unix:${fpm.socket}|fcgi://localhost/"
+ </If>
+ </FilesMatch>
+ AllowOverride all
+ Options -Indexes
+ DirectoryIndex index.php
+ </Directory>
+ '';
+ } ];
};
users.users.${user} = mapAttrs (name: mkDefault) {
diff --git a/nixpkgs/nixos/modules/services/web-servers/apache-httpd/default.nix b/nixpkgs/nixos/modules/services/web-servers/apache-httpd/default.nix
index f5a6051b4b5..4460f89ec5c 100644
--- a/nixpkgs/nixos/modules/services/web-servers/apache-httpd/default.nix
+++ b/nixpkgs/nixos/modules/services/web-servers/apache-httpd/default.nix
@@ -18,22 +18,20 @@ let
mod_perl = pkgs.apacheHttpdPackages.mod_perl.override { apacheHttpd = httpd; };
- defaultListen = cfg: if cfg.enableSSL
- then [{ip = "*"; port = 443;}]
- else [{ip = "*"; port = 80;}];
+ vhosts = attrValues mainCfg.virtualHosts;
- getListen = cfg:
- if cfg.listen == []
- then defaultListen cfg
- else cfg.listen;
+ mkListenInfo = hostOpts:
+ if hostOpts.listen != [] then hostOpts.listen
+ else (
+ optional (hostOpts.onlySSL || hostOpts.addSSL || hostOpts.forceSSL) { ip = "*"; port = 443; ssl = true; } ++
+ optional (!hostOpts.onlySSL) { ip = "*"; port = 80; ssl = false; }
+ );
- listenToString = l: "${l.ip}:${toString l.port}";
+ listenInfo = unique (concatMap mkListenInfo vhosts);
- allHosts = [mainCfg] ++ mainCfg.virtualHosts;
+ enableSSL = any (listen: listen.ssl) listenInfo;
- enableSSL = any (vhost: vhost.enableSSL) allHosts;
-
- enableUserDir = any (vhost: vhost.enableUserDir) allHosts;
+ enableUserDir = any (vhost: vhost.enableUserDir) vhosts;
# NOTE: generally speaking order of modules is very important
modules =
@@ -115,122 +113,137 @@ let
</IfModule>
'';
-
- perServerConf = isMainServer: cfg: let
-
- # Canonical name must not include a trailing slash.
- canonicalNames =
- let defaultPort = (head (defaultListen cfg)).port; in
- map (port:
- (if cfg.enableSSL then "https" else "http") + "://" +
- cfg.hostName +
- (if port != defaultPort then ":${toString port}" else "")
- ) (map (x: x.port) (getListen cfg));
-
- maybeDocumentRoot = fold (svc: acc:
- if acc == null then svc.documentRoot else assert svc.documentRoot == null; acc
- ) null ([ cfg ]);
-
- documentRoot = if maybeDocumentRoot != null then maybeDocumentRoot else
- pkgs.runCommand "empty" { preferLocalBuild = true; } "mkdir -p $out";
-
- documentRootConf = ''
- DocumentRoot "${documentRoot}"
-
- <Directory "${documentRoot}">
- Options Indexes FollowSymLinks
- AllowOverride None
- ${allGranted}
- </Directory>
- '';
-
- # If this is a vhost, the include the entries for the main server as well.
- robotsTxt = concatStringsSep "\n" (filter (x: x != "") ([ cfg.robotsEntries ] ++ lib.optional (!isMainServer) mainCfg.robotsEntries));
-
- in ''
- ${concatStringsSep "\n" (map (n: "ServerName ${n}") canonicalNames)}
-
- ${concatMapStrings (alias: "ServerAlias ${alias}\n") cfg.serverAliases}
-
- ${if cfg.sslServerCert != null then ''
- SSLCertificateFile ${cfg.sslServerCert}
- SSLCertificateKeyFile ${cfg.sslServerKey}
- ${if cfg.sslServerChain != null then ''
- SSLCertificateChainFile ${cfg.sslServerChain}
- '' else ""}
- '' else ""}
-
- ${if cfg.enableSSL then ''
- SSLEngine on
- '' else if enableSSL then /* i.e., SSL is enabled for some host, but not this one */
- ''
- SSLEngine off
- '' else ""}
-
- ${if isMainServer || cfg.adminAddr != null then ''
- ServerAdmin ${cfg.adminAddr}
- '' else ""}
-
- ${if !isMainServer && mainCfg.logPerVirtualHost then ''
- ErrorLog ${mainCfg.logDir}/error-${cfg.hostName}.log
- CustomLog ${mainCfg.logDir}/access-${cfg.hostName}.log ${cfg.logFormat}
- '' else ""}
-
- ${optionalString (robotsTxt != "") ''
- Alias /robots.txt ${pkgs.writeText "robots.txt" robotsTxt}
- ''}
-
- ${if isMainServer || maybeDocumentRoot != null then documentRootConf else ""}
-
- ${if cfg.enableUserDir then ''
-
- UserDir public_html
- UserDir disabled root
-
- <Directory "/home/*/public_html">
- AllowOverride FileInfo AuthConfig Limit Indexes
- Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
- <Limit GET POST OPTIONS>
- ${allGranted}
- </Limit>
- <LimitExcept GET POST OPTIONS>
- ${allDenied}
- </LimitExcept>
- </Directory>
-
- '' else ""}
-
- ${if cfg.globalRedirect != null && cfg.globalRedirect != "" then ''
- RedirectPermanent / ${cfg.globalRedirect}
- '' else ""}
-
- ${
- let makeFileConf = elem: ''
- Alias ${elem.urlPath} ${elem.file}
- '';
- in concatMapStrings makeFileConf cfg.servedFiles
- }
-
- ${
- let makeDirConf = elem: ''
- Alias ${elem.urlPath} ${elem.dir}/
- <Directory ${elem.dir}>
- Options +Indexes
- ${allGranted}
- AllowOverride All
- </Directory>
- '';
- in concatMapStrings makeDirConf cfg.servedDirs
- }
-
- ${cfg.extraConfig}
- '';
+ mkVHostConf = hostOpts:
+ let
+ adminAddr = if hostOpts.adminAddr != null then hostOpts.adminAddr else mainCfg.adminAddr;
+ listen = filter (listen: !listen.ssl) (mkListenInfo hostOpts);
+ listenSSL = filter (listen: listen.ssl) (mkListenInfo hostOpts);
+
+ useACME = hostOpts.enableACME || hostOpts.useACMEHost != null;
+ sslCertDir =
+ if hostOpts.enableACME then config.security.acme.certs.${hostOpts.hostName}.directory
+ else if hostOpts.useACMEHost != null then config.security.acme.certs.${hostOpts.useACMEHost}.directory
+ else abort "This case should never happen.";
+
+ sslServerCert = if useACME then "${sslCertDir}/full.pem" else hostOpts.sslServerCert;
+ sslServerKey = if useACME then "${sslCertDir}/key.pem" else hostOpts.sslServerKey;
+ sslServerChain = if useACME then "${sslCertDir}/fullchain.pem" else hostOpts.sslServerChain;
+
+ acmeChallenge = optionalString useACME ''
+ Alias /.well-known/acme-challenge/ "${hostOpts.acmeRoot}/.well-known/acme-challenge/"
+ <Directory "${hostOpts.acmeRoot}">
+ AllowOverride None
+ Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
+ Require method GET POST OPTIONS
+ Require all granted
+ </Directory>
+ '';
+ in
+ optionalString (listen != []) ''
+ <VirtualHost ${concatMapStringsSep " " (listen: "${listen.ip}:${toString listen.port}") listen}>
+ ServerName ${hostOpts.hostName}
+ ${concatMapStrings (alias: "ServerAlias ${alias}\n") hostOpts.serverAliases}
+ ServerAdmin ${adminAddr}
+ <IfModule mod_ssl.c>
+ SSLEngine off
+ </IfModule>
+ ${acmeChallenge}
+ ${if hostOpts.forceSSL then ''
+ <IfModule mod_rewrite.c>
+ RewriteEngine on
+ RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge [NC]
+ RewriteCond %{HTTPS} off
+ RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
+ </IfModule>
+ '' else mkVHostCommonConf hostOpts}
+ </VirtualHost>
+ '' +
+ optionalString (listenSSL != []) ''
+ <VirtualHost ${concatMapStringsSep " " (listen: "${listen.ip}:${toString listen.port}") listenSSL}>
+ ServerName ${hostOpts.hostName}
+ ${concatMapStrings (alias: "ServerAlias ${alias}\n") hostOpts.serverAliases}
+ ServerAdmin ${adminAddr}
+ SSLEngine on
+ SSLCertificateFile ${sslServerCert}
+ SSLCertificateKeyFile ${sslServerKey}
+ ${optionalString (sslServerChain != null) "SSLCertificateChainFile ${sslServerChain}"}
+ ${acmeChallenge}
+ ${mkVHostCommonConf hostOpts}
+ </VirtualHost>
+ ''
+ ;
+
+ mkVHostCommonConf = hostOpts:
+ let
+ documentRoot = if hostOpts.documentRoot != null
+ then hostOpts.documentRoot
+ else pkgs.runCommand "empty" { preferLocalBuild = true; } "mkdir -p $out"
+ ;
+ in
+ ''
+ ${optionalString mainCfg.logPerVirtualHost ''
+ ErrorLog ${mainCfg.logDir}/error-${hostOpts.hostName}.log
+ CustomLog ${mainCfg.logDir}/access-${hostOpts.hostName}.log ${hostOpts.logFormat}
+ ''}
+
+ ${optionalString (hostOpts.robotsEntries != "") ''
+ Alias /robots.txt ${pkgs.writeText "robots.txt" hostOpts.robotsEntries}
+ ''}
+
+ DocumentRoot "${documentRoot}"
+
+ <Directory "${documentRoot}">
+ Options Indexes FollowSymLinks
+ AllowOverride None
+ ${allGranted}
+ </Directory>
+
+ ${optionalString hostOpts.enableUserDir ''
+ UserDir public_html
+ UserDir disabled root
+ <Directory "/home/*/public_html">
+ AllowOverride FileInfo AuthConfig Limit Indexes
+ Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
+ <Limit GET POST OPTIONS>
+ Require all granted
+ </Limit>
+ <LimitExcept GET POST OPTIONS>
+ Require all denied
+ </LimitExcept>
+ </Directory>
+ ''}
+
+ ${optionalString (hostOpts.globalRedirect != null && hostOpts.globalRedirect != "") ''
+ RedirectPermanent / ${hostOpts.globalRedirect}
+ ''}
+
+ ${
+ let makeFileConf = elem: ''
+ Alias ${elem.urlPath} ${elem.file}
+ '';
+ in concatMapStrings makeFileConf hostOpts.servedFiles
+ }
+ ${
+ let makeDirConf = elem: ''
+ Alias ${elem.urlPath} ${elem.dir}/
+ <Directory ${elem.dir}>
+ Options +Indexes
+ ${allGranted}
+ AllowOverride All
+ </Directory>
+ '';
+ in concatMapStrings makeDirConf hostOpts.servedDirs
+ }
+
+ ${hostOpts.extraConfig}
+ ''
+ ;
confFile = pkgs.writeText "httpd.conf" ''
ServerRoot ${httpd}
-
+ ServerName ${config.networking.hostName}
DefaultRuntimeDir ${runtimeDir}/runtime
PidFile ${runtimeDir}/httpd.pid
@@ -246,10 +259,9 @@ let
</IfModule>
${let
- listen = concatMap getListen allHosts;
- toStr = listen: "Listen ${listenToString listen}\n";
- uniqueListen = uniqList {inputList = map toStr listen;};
- in concatStrings uniqueListen
+ toStr = listen: "Listen ${listen.ip}:${toString listen.port} ${if listen.ssl then "https" else "http"}";
+ uniqueListen = uniqList {inputList = map toStr listenInfo;};
+ in concatStringsSep "\n" uniqueListen
}
User ${mainCfg.user}
@@ -297,17 +309,9 @@ let
${allGranted}
</Directory>
- # Generate directives for the main server.
- ${perServerConf true mainCfg}
+ ${mainCfg.extraConfig}
- ${let
- makeVirtualHost = vhost: ''
- <VirtualHost ${concatStringsSep " " (map listenToString (getListen vhost))}>
- ${perServerConf false vhost}
- </VirtualHost>
- '';
- in concatMapStrings makeVirtualHost mainCfg.virtualHosts
- }
+ ${concatMapStringsSep "\n" mkVHostConf vhosts}
'';
# Generate the PHP configuration file. Should probably be factored
@@ -329,6 +333,21 @@ in
imports = [
(mkRemovedOptionModule [ "services" "httpd" "extraSubservices" ] "Most existing subservices have been ported to the NixOS module system. Please update your configuration accordingly.")
(mkRemovedOptionModule [ "services" "httpd" "stateDir" ] "The httpd module now uses /run/httpd as a runtime directory.")
+
+ # virtualHosts options
+ (mkRemovedOptionModule [ "services" "httpd" "documentRoot" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
+ (mkRemovedOptionModule [ "services" "httpd" "enableSSL" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
+ (mkRemovedOptionModule [ "services" "httpd" "enableUserDir" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
+ (mkRemovedOptionModule [ "services" "httpd" "globalRedirect" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
+ (mkRemovedOptionModule [ "services" "httpd" "hostName" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
+ (mkRemovedOptionModule [ "services" "httpd" "listen" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
+ (mkRemovedOptionModule [ "services" "httpd" "robotsEntries" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
+ (mkRemovedOptionModule [ "services" "httpd" "servedDirs" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
+ (mkRemovedOptionModule [ "services" "httpd" "servedFiles" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
+ (mkRemovedOptionModule [ "services" "httpd" "serverAliases" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
+ (mkRemovedOptionModule [ "services" "httpd" "sslServerCert" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
+ (mkRemovedOptionModule [ "services" "httpd" "sslServerChain" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
+ (mkRemovedOptionModule [ "services" "httpd" "sslServerKey" ] "Please define a virtual host using `services.httpd.virtualHosts`.")
];
###### interface
@@ -367,7 +386,7 @@ in
type = types.lines;
default = "";
description = ''
- Cnfiguration lines appended to the generated Apache
+ Configuration lines appended to the generated Apache
configuration file. Note that this mechanism may not work
when <option>configFile</option> is overridden.
'';
@@ -391,9 +410,25 @@ in
'';
};
+ adminAddr = mkOption {
+ type = types.str;
+ example = "admin@example.org";
+ description = "E-mail address of the server administrator.";
+ };
+
+ logFormat = mkOption {
+ type = types.str;
+ default = "common";
+ example = "combined";
+ description = ''
+ Log format for log files. Possible values are: combined, common, referer, agent.
+ See <link xlink:href="https://httpd.apache.org/docs/2.4/logs.html"/> for more details.
+ '';
+ };
+
logPerVirtualHost = mkOption {
type = types.bool;
- default = false;
+ default = true;
description = ''
If enabled, each virtual host gets its own
<filename>access.log</filename> and
@@ -429,26 +464,28 @@ in
};
virtualHosts = mkOption {
- type = types.listOf (types.submodule (
- { options = import ./per-server-options.nix {
- inherit lib;
- forMainServer = false;
+ type = with types; attrsOf (submodule (import ./per-server-options.nix));
+ default = {
+ localhost = {
+ documentRoot = "${httpd}/htdocs";
+ };
+ };
+ example = literalExample ''
+ {
+ "foo.example.com" = {
+ forceSSL = true;
+ documentRoot = "/var/www/foo.example.com"
+ };
+ "bar.example.com" = {
+ addSSL = true;
+ documentRoot = "/var/www/bar.example.com";
};
- }));
- default = [];
- example = [
- { hostName = "foo";
- documentRoot = "/data/webroot-foo";
- }
- { hostName = "bar";
- documentRoot = "/data/webroot-bar";
}
- ];
+ '';
description = ''
- Specification of the virtual hosts served by Apache. Each
+ Specification of the virtual hosts served by Apache. Each
element should be an attribute set specifying the
- configuration of the virtual host. The available options
- are the non-global options permissible for the main host.
+ configuration of the virtual host.
'';
};
@@ -530,17 +567,11 @@ in
sslProtocols = mkOption {
type = types.str;
- default = "All -SSLv2 -SSLv3 -TLSv1";
+ default = "All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1";
example = "All -SSLv2 -SSLv3";
description = "Allowed SSL/TLS protocol versions.";
};
- }
-
- # Include the options shared between the main server and virtual hosts.
- // (import ./per-server-options.nix {
- inherit lib;
- forMainServer = true;
- });
+ };
};
@@ -549,23 +580,52 @@ in
config = mkIf config.services.httpd.enable {
- assertions = [ { assertion = mainCfg.enableSSL == true
- -> mainCfg.sslServerCert != null
- && mainCfg.sslServerKey != null;
- message = "SSL is enabled for httpd, but sslServerCert and/or sslServerKey haven't been specified."; }
- ];
+ assertions = [
+ {
+ assertion = all (hostOpts: !hostOpts.enableSSL) vhosts;
+ message = ''
+ The option `services.httpd.virtualHosts.<name>.enableSSL` no longer has any effect; please remove it.
+ Select one of `services.httpd.virtualHosts.<name>.addSSL`, `services.httpd.virtualHosts.<name>.forceSSL`,
+ or `services.httpd.virtualHosts.<name>.onlySSL`.
+ '';
+ }
+ {
+ assertion = all (hostOpts: with hostOpts; !(addSSL && onlySSL) && !(forceSSL && onlySSL) && !(addSSL && forceSSL)) vhosts;
+ message = ''
+ Options `services.httpd.virtualHosts.<name>.addSSL`,
+ `services.httpd.virtualHosts.<name>.onlySSL` and `services.httpd.virtualHosts.<name>.forceSSL`
+ are mutually exclusive.
+ '';
+ }
+ {
+ assertion = all (hostOpts: !(hostOpts.enableACME && hostOpts.useACMEHost != null)) vhosts;
+ message = ''
+ Options `services.httpd.virtualHosts.<name>.enableACME` and
+ `services.httpd.virtualHosts.<name>.useACMEHost` are mutually exclusive.
+ '';
+ }
+ ];
- users.users = optionalAttrs (mainCfg.user == "wwwrun") (singleton
- { name = "wwwrun";
+ users.users = optionalAttrs (mainCfg.user == "wwwrun") {
+ wwwrun = {
group = mainCfg.group;
description = "Apache httpd user";
uid = config.ids.uids.wwwrun;
- });
+ };
+ };
- users.groups = optionalAttrs (mainCfg.group == "wwwrun") (singleton
- { name = "wwwrun";
- gid = config.ids.gids.wwwrun;
- });
+ users.groups = optionalAttrs (mainCfg.group == "wwwrun") {
+ wwwrun.gid = config.ids.gids.wwwrun;
+ };
+
+ security.acme.certs = mapAttrs (name: hostOpts: {
+ user = mainCfg.user;
+ group = mkDefault mainCfg.group;
+ email = if hostOpts.adminAddr != null then hostOpts.adminAddr else mainCfg.adminAddr;
+ webroot = hostOpts.acmeRoot;
+ extraDomains = genAttrs hostOpts.serverAliases (alias: null);
+ postRun = "systemctl reload httpd.service";
+ }) (filterAttrs (name: hostOpts: hostOpts.enableACME) mainCfg.virtualHosts);
environment.systemPackages = [httpd];
@@ -605,10 +665,14 @@ in
];
systemd.services.httpd =
+ let
+ vhostsACME = filter (hostOpts: hostOpts.enableACME) vhosts;
+ in
{ description = "Apache HTTPD";
wantedBy = [ "multi-user.target" ];
- after = [ "network.target" "fs.target" ];
+ wants = concatLists (map (hostOpts: [ "acme-${hostOpts.hostName}.service" "acme-selfsigned-${hostOpts.hostName}.service" ]) vhostsACME);
+ after = [ "network.target" "fs.target" ] ++ map (hostOpts: "acme-selfsigned-${hostOpts.hostName}.service") vhostsACME;
path =
[ httpd pkgs.coreutils pkgs.gnugrep ]
diff --git a/nixpkgs/nixos/modules/services/web-servers/apache-httpd/per-server-options.nix b/nixpkgs/nixos/modules/services/web-servers/apache-httpd/per-server-options.nix
index c36207d5460..f2e92cda05f 100644
--- a/nixpkgs/nixos/modules/services/web-servers/apache-httpd/per-server-options.nix
+++ b/nixpkgs/nixos/modules/services/web-servers/apache-httpd/per-server-options.nix
@@ -1,174 +1,235 @@
-# This file defines the options that can be used both for the Apache
-# main server configuration, and for the virtual hosts. (The latter
-# has additional options that affect the web server as a whole, like
-# the user/group to run under.)
-
-{ forMainServer, lib }:
-
-with lib;
-
+{ config, lib, name, ... }:
+let
+ inherit (lib) mkOption types;
+in
{
+ options = {
+
+ hostName = mkOption {
+ type = types.str;
+ default = name;
+ description = "Canonical hostname for the server.";
+ };
+
+ serverAliases = mkOption {
+ type = types.listOf types.str;
+ default = [];
+ example = ["www.example.org" "www.example.org:8080" "example.org"];
+ description = ''
+ Additional names of virtual hosts served by this virtual host configuration.
+ '';
+ };
+
+ listen = mkOption {
+ type = with types; listOf (submodule ({
+ options = {
+ port = mkOption {
+ type = types.port;
+ description = "Port to listen on";
+ };
+ ip = mkOption {
+ type = types.str;
+ default = "*";
+ description = "IP to listen on. 0.0.0.0 for IPv4 only, * for all.";
+ };
+ ssl = mkOption {
+ type = types.bool;
+ default = false;
+ description = "Whether to enable SSL (https) support.";
+ };
+ };
+ }));
+ default = [];
+ example = [
+ { ip = "195.154.1.1"; port = 443; ssl = true;}
+ { ip = "192.154.1.1"; port = 80; }
+ { ip = "*"; port = 8080; }
+ ];
+ description = ''
+ Listen addresses and ports for this virtual host.
+ <note><para>
+ This option overrides <literal>addSSL</literal>, <literal>forceSSL</literal> and <literal>onlySSL</literal>.
+ </para></note>
+ '';
+ };
+
+ enableSSL = mkOption {
+ type = types.bool;
+ visible = false;
+ default = false;
+ };
+
+ addSSL = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Whether to enable HTTPS in addition to plain HTTP. This will set defaults for
+ <literal>listen</literal> to listen on all interfaces on the respective default
+ ports (80, 443).
+ '';
+ };
+
+ onlySSL = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Whether to enable HTTPS and reject plain HTTP connections. This will set
+ defaults for <literal>listen</literal> to listen on all interfaces on port 443.
+ '';
+ };
+
+ forceSSL = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Whether to add a separate nginx server block that permanently redirects (301)
+ all plain HTTP traffic to HTTPS. This will set defaults for
+ <literal>listen</literal> to listen on all interfaces on the respective default
+ ports (80, 443), where the non-SSL listens are used for the redirect vhosts.
+ '';
+ };
+
+ enableACME = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Whether to ask Let's Encrypt to sign a certificate for this vhost.
+ Alternately, you can use an existing certificate through <option>useACMEHost</option>.
+ '';
+ };
+
+ useACMEHost = mkOption {
+ type = types.nullOr types.str;
+ default = null;
+ description = ''
+ A host of an existing Let's Encrypt certificate to use.
+ This is useful if you have many subdomains and want to avoid hitting the
+ <link xlink:href="https://letsencrypt.org/docs/rate-limits/">rate limit</link>.
+ Alternately, you can generate a certificate through <option>enableACME</option>.
+ <emphasis>Note that this option does not create any certificates, nor it does add subdomains to existing ones – you will need to create them manually using <xref linkend="opt-security.acme.certs"/>.</emphasis>
+ '';
+ };
+
+ acmeRoot = mkOption {
+ type = types.str;
+ default = "/var/lib/acme/acme-challenges";
+ description = "Directory for the acme challenge which is PUBLIC, don't put certs or keys in here";
+ };
+
+ sslServerCert = mkOption {
+ type = types.path;
+ example = "/var/host.cert";
+ description = "Path to server SSL certificate.";
+ };
+
+ sslServerKey = mkOption {
+ type = types.path;
+ example = "/var/host.key";
+ description = "Path to server SSL certificate key.";
+ };
+
+ sslServerChain = mkOption {
+ type = types.nullOr types.path;
+ default = null;
+ example = "/var/ca.pem";
+ description = "Path to server SSL chain file.";
+ };
+
+ adminAddr = mkOption {
+ type = types.nullOr types.str;
+ default = null;
+ example = "admin@example.org";
+ description = "E-mail address of the server administrator.";
+ };
+
+ documentRoot = mkOption {
+ type = types.nullOr types.path;
+ default = null;
+ example = "/data/webserver/docs";
+ description = ''
+ The path of Apache's document root directory. If left undefined,
+ an empty directory in the Nix store will be used as root.
+ '';
+ };
+
+ servedDirs = mkOption {
+ type = types.listOf types.attrs;
+ default = [];
+ example = [
+ { urlPath = "/nix";
+ dir = "/home/eelco/Dev/nix-homepage";
+ }
+ ];
+ description = ''
+ This option provides a simple way to serve static directories.
+ '';
+ };
+
+ servedFiles = mkOption {
+ type = types.listOf types.attrs;
+ default = [];
+ example = [
+ { urlPath = "/foo/bar.png";
+ file = "/home/eelco/some-file.png";
+ }
+ ];
+ description = ''
+ This option provides a simple way to serve individual, static files.
+ '';
+ };
+
+ extraConfig = mkOption {
+ type = types.lines;
+ default = "";
+ example = ''
+ <Directory /home>
+ Options FollowSymlinks
+ AllowOverride All
+ </Directory>
+ '';
+ description = ''
+ These lines go to httpd.conf verbatim. They will go after
+ directories and directory aliases defined by default.
+ '';
+ };
+
+ enableUserDir = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Whether to enable serving <filename>~/public_html</filename> as
+ <literal>/~<replaceable>username</replaceable></literal>.
+ '';
+ };
+
+ globalRedirect = mkOption {
+ type = types.nullOr types.str;
+ default = null;
+ example = http://newserver.example.org/;
+ description = ''
+ If set, all requests for this host are redirected permanently to
+ the given URL.
+ '';
+ };
+
+ logFormat = mkOption {
+ type = types.str;
+ default = "common";
+ example = "combined";
+ description = ''
+ Log format for Apache's log files. Possible values are: combined, common, referer, agent.
+ '';
+ };
+
+ robotsEntries = mkOption {
+ type = types.lines;
+ default = "";
+ example = "Disallow: /foo/";
+ description = ''
+ Specification of pages to be ignored by web crawlers. See <link
+ xlink:href='http://www.robotstxt.org/'/> for details.
+ '';
+ };
- hostName = mkOption {
- type = types.str;
- default = "localhost";
- description = "Canonical hostname for the server.";
- };
-
- serverAliases = mkOption {
- type = types.listOf types.str;
- default = [];
- example = ["www.example.org" "www.example.org:8080" "example.org"];
- description = ''
- Additional names of virtual hosts served by this virtual host configuration.
- '';
- };
-
- listen = mkOption {
- type = types.listOf (types.submodule (
- {
- options = {
- port = mkOption {
- type = types.int;
- description = "port to listen on";
- };
- ip = mkOption {
- type = types.str;
- default = "*";
- description = "Ip to listen on. 0.0.0.0 for ipv4 only, * for all.";
- };
- };
- } ));
- description = ''
- List of { /* ip: "*"; */ port = 80;} to listen on
- '';
-
- default = [];
- };
-
- enableSSL = mkOption {
- type = types.bool;
- default = false;
- description = "Whether to enable SSL (https) support.";
};
-
- # Note: sslServerCert and sslServerKey can be left empty, but this
- # only makes sense for virtual hosts (they will inherit from the
- # main server).
-
- sslServerCert = mkOption {
- type = types.nullOr types.path;
- default = null;
- example = "/var/host.cert";
- description = "Path to server SSL certificate.";
- };
-
- sslServerKey = mkOption {
- type = types.path;
- example = "/var/host.key";
- description = "Path to server SSL certificate key.";
- };
-
- sslServerChain = mkOption {
- type = types.nullOr types.path;
- default = null;
- example = "/var/ca.pem";
- description = "Path to server SSL chain file.";
- };
-
- adminAddr = mkOption ({
- type = types.nullOr types.str;
- example = "admin@example.org";
- description = "E-mail address of the server administrator.";
- } // (if forMainServer then {} else {default = null;}));
-
- documentRoot = mkOption {
- type = types.nullOr types.path;
- default = null;
- example = "/data/webserver/docs";
- description = ''
- The path of Apache's document root directory. If left undefined,
- an empty directory in the Nix store will be used as root.
- '';
- };
-
- servedDirs = mkOption {
- type = types.listOf types.attrs;
- default = [];
- example = [
- { urlPath = "/nix";
- dir = "/home/eelco/Dev/nix-homepage";
- }
- ];
- description = ''
- This option provides a simple way to serve static directories.
- '';
- };
-
- servedFiles = mkOption {
- type = types.listOf types.attrs;
- default = [];
- example = [
- { urlPath = "/foo/bar.png";
- file = "/home/eelco/some-file.png";
- }
- ];
- description = ''
- This option provides a simple way to serve individual, static files.
- '';
- };
-
- extraConfig = mkOption {
- type = types.lines;
- default = "";
- example = ''
- <Directory /home>
- Options FollowSymlinks
- AllowOverride All
- </Directory>
- '';
- description = ''
- These lines go to httpd.conf verbatim. They will go after
- directories and directory aliases defined by default.
- '';
- };
-
- enableUserDir = mkOption {
- type = types.bool;
- default = false;
- description = ''
- Whether to enable serving <filename>~/public_html</filename> as
- <literal>/~<replaceable>username</replaceable></literal>.
- '';
- };
-
- globalRedirect = mkOption {
- type = types.nullOr types.str;
- default = null;
- example = http://newserver.example.org/;
- description = ''
- If set, all requests for this host are redirected permanently to
- the given URL.
- '';
- };
-
- logFormat = mkOption {
- type = types.str;
- default = "common";
- example = "combined";
- description = ''
- Log format for Apache's log files. Possible values are: combined, common, referer, agent.
- '';
- };
-
- robotsEntries = mkOption {
- type = types.lines;
- default = "";
- example = "Disallow: /foo/";
- description = ''
- Specification of pages to be ignored by web crawlers. See <link
- xlink:href='http://www.robotstxt.org/'/> for details.
- '';
- };
-
}
diff --git a/nixpkgs/nixos/modules/services/web-servers/nginx/default.nix b/nixpkgs/nixos/modules/services/web-servers/nginx/default.nix
index eb90dae94df..c8602e5975b 100644
--- a/nixpkgs/nixos/modules/services/web-servers/nginx/default.nix
+++ b/nixpkgs/nixos/modules/services/web-servers/nginx/default.nix
@@ -47,7 +47,7 @@ let
''));
configFile = pkgs.writers.writeNginxConfig "nginx.conf" ''
- user ${cfg.user} ${cfg.group};
+ pid /run/nginx/nginx.pid;
error_log ${cfg.logError};
daemon off;
@@ -178,6 +178,8 @@ let
then "/etc/nginx/nginx.conf"
else configFile;
+ execCommand = "${cfg.package}/bin/nginx -c '${configPath}' -p '${cfg.stateDir}'";
+
vhosts = concatStringsSep "\n" (mapAttrsToList (vhostName: vhost:
let
onlySSL = vhost.onlySSL || vhost.enableSSL;
@@ -366,12 +368,7 @@ in
preStart = mkOption {
type = types.lines;
- default = ''
- test -d ${cfg.stateDir}/logs || mkdir -m 750 -p ${cfg.stateDir}/logs
- test `stat -c %a ${cfg.stateDir}` = "750" || chmod 750 ${cfg.stateDir}
- test `stat -c %a ${cfg.stateDir}/logs` = "750" || chmod 750 ${cfg.stateDir}/logs
- chown -R ${cfg.user}:${cfg.group} ${cfg.stateDir}
- '';
+ default = "";
description = "
Shell commands executed before the service's nginx is started.
";
@@ -673,23 +670,36 @@ in
}
];
+ systemd.tmpfiles.rules = [
+ "d '${cfg.stateDir}' 0750 ${cfg.user} ${cfg.group} - -"
+ "d '${cfg.stateDir}/logs' 0750 ${cfg.user} ${cfg.group} - -"
+ "Z '${cfg.stateDir}' - ${cfg.user} ${cfg.group} - -"
+ ];
+
systemd.services.nginx = {
description = "Nginx Web Server";
wantedBy = [ "multi-user.target" ];
wants = concatLists (map (vhostConfig: ["acme-${vhostConfig.serverName}.service" "acme-selfsigned-${vhostConfig.serverName}.service"]) acmeEnabledVhosts);
after = [ "network.target" ] ++ map (vhostConfig: "acme-selfsigned-${vhostConfig.serverName}.service") acmeEnabledVhosts;
stopIfChanged = false;
- preStart =
- ''
+ preStart = ''
${cfg.preStart}
- ${cfg.package}/bin/nginx -c ${configPath} -p ${cfg.stateDir} -t
- '';
+ ${execCommand} -t
+ '';
serviceConfig = {
- ExecStart = "${cfg.package}/bin/nginx -c ${configPath} -p ${cfg.stateDir}";
+ ExecStart = execCommand;
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
Restart = "always";
RestartSec = "10s";
StartLimitInterval = "1min";
+ # User and group
+ User = cfg.user;
+ Group = cfg.group;
+ # Runtime directory and mode
+ RuntimeDirectory = "nginx";
+ RuntimeDirectoryMode = "0750";
+ # Capabilities
+ AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" "CAP_SYS_RESOURCE" ];
};
};
@@ -698,11 +708,18 @@ in
};
systemd.services.nginx-config-reload = mkIf cfg.enableReload {
- wantedBy = [ "nginx.service" ];
+ wants = [ "nginx.service" ];
+ wantedBy = [ "multi-user.target" ];
restartTriggers = [ configFile ];
+ # commented, because can cause extra delays during activate for this config:
+ # services.nginx.virtualHosts."_".locations."/".proxyPass = "http://blabla:3000";
+ # stopIfChanged = false;
+ serviceConfig.Type = "oneshot";
+ serviceConfig.TimeoutSec = 60;
script = ''
if ${pkgs.systemd}/bin/systemctl -q is-active nginx.service ; then
- ${pkgs.systemd}/bin/systemctl reload nginx.service
+ ${execCommand} -t && \
+ ${pkgs.systemd}/bin/systemctl reload nginx.service
fi
'';
serviceConfig.RemainAfterExit = true;
@@ -723,15 +740,16 @@ in
listToAttrs acmePairs
);
- users.users = optionalAttrs (cfg.user == "nginx") (singleton
- { name = "nginx";
+ users.users = optionalAttrs (cfg.user == "nginx") {
+ nginx = {
group = cfg.group;
uid = config.ids.uids.nginx;
- });
+ };
+ };
+
+ users.groups = optionalAttrs (cfg.group == "nginx") {
+ nginx.gid = config.ids.gids.nginx;
+ };
- users.groups = optionalAttrs (cfg.group == "nginx") (singleton
- { name = "nginx";
- gid = config.ids.gids.nginx;
- });
};
}
diff --git a/nixpkgs/nixos/modules/services/web-servers/nginx/location-options.nix b/nixpkgs/nixos/modules/services/web-servers/nginx/location-options.nix
index 2b3749d8a74..3d9e391ecf2 100644
--- a/nixpkgs/nixos/modules/services/web-servers/nginx/location-options.nix
+++ b/nixpkgs/nixos/modules/services/web-servers/nginx/location-options.nix
@@ -67,7 +67,7 @@ with lib;
return = mkOption {
type = types.nullOr types.str;
default = null;
- example = "301 http://example.com$request_uri;";
+ example = "301 http://example.com$request_uri";
description = ''
Adds a return directive, for e.g. redirections.
'';
diff --git a/nixpkgs/nixos/modules/services/web-servers/nginx/vhost-options.nix b/nixpkgs/nixos/modules/services/web-servers/nginx/vhost-options.nix
index 7e488f33a41..455854e2a96 100644
--- a/nixpkgs/nixos/modules/services/web-servers/nginx/vhost-options.nix
+++ b/nixpkgs/nixos/modules/services/web-servers/nginx/vhost-options.nix
@@ -207,6 +207,7 @@ with lib;
default = null;
description = ''
Basic Auth password file for a vhost.
+ Can be created via: <command>htpasswd -c &lt;filename&gt; &lt;username&gt;</command>
'';
};
diff --git a/nixpkgs/nixos/modules/services/web-servers/phpfpm/default.nix b/nixpkgs/nixos/modules/services/web-servers/phpfpm/default.nix
index 7698f8c3a26..2c73da10394 100644
--- a/nixpkgs/nixos/modules/services/web-servers/phpfpm/default.nix
+++ b/nixpkgs/nixos/modules/services/web-servers/phpfpm/default.nix
@@ -146,6 +146,10 @@ let
};
in {
+ imports = [
+ (mkRemovedOptionModule [ "services" "phpfpm" "poolConfigs" ] "Use services.phpfpm.pools instead.")
+ (mkRemovedOptionModule [ "services" "phpfpm" "phpIni" ] "")
+ ];
options = {
services.phpfpm = {
diff --git a/nixpkgs/nixos/modules/services/web-servers/tomcat.nix b/nixpkgs/nixos/modules/services/web-servers/tomcat.nix
index 68261c50324..6d12925829f 100644
--- a/nixpkgs/nixos/modules/services/web-servers/tomcat.nix
+++ b/nixpkgs/nixos/modules/services/web-servers/tomcat.nix
@@ -194,14 +194,10 @@ in
config = mkIf config.services.tomcat.enable {
- users.groups = singleton
- { name = "tomcat";
- gid = config.ids.gids.tomcat;
- };
+ users.groups.tomcat.gid = config.ids.gids.tomcat;
- users.users = singleton
- { name = "tomcat";
- uid = config.ids.uids.tomcat;
+ users.users.tomcat =
+ { uid = config.ids.uids.tomcat;
description = "Tomcat user";
home = "/homeless-shelter";
extraGroups = cfg.extraGroups;
diff --git a/nixpkgs/nixos/modules/services/web-servers/unit/default.nix b/nixpkgs/nixos/modules/services/web-servers/unit/default.nix
index 32f6d475b34..2303dfa9540 100644
--- a/nixpkgs/nixos/modules/services/web-servers/unit/default.nix
+++ b/nixpkgs/nixos/modules/services/web-servers/unit/default.nix
@@ -85,7 +85,7 @@ in {
systemd.tmpfiles.rules = [
"d '${cfg.stateDir}' 0750 ${cfg.user} ${cfg.group} - -"
"d '${cfg.logDir}' 0750 ${cfg.user} ${cfg.group} - -"
- ];
+ ];
systemd.services.unit = {
description = "Unit App Server";
@@ -93,34 +93,50 @@ in {
wantedBy = [ "multi-user.target" ];
path = with pkgs; [ curl ];
preStart = ''
- test -f '/run/unit/control.unit.sock' || rm -f '/run/unit/control.unit.sock'
+ test -f '${cfg.stateDir}/conf.json' || rm -f '${cfg.stateDir}/conf.json'
'';
postStart = ''
curl -X PUT --data-binary '@${configFile}' --unix-socket '/run/unit/control.unit.sock' 'http://localhost/config'
'';
serviceConfig = {
- User = cfg.user;
- Group = cfg.group;
- AmbientCapabilities = "CAP_NET_BIND_SERVICE CAP_SETGID CAP_SETUID";
- CapabilityBoundingSet = "CAP_NET_BIND_SERVICE CAP_SETGID CAP_SETUID";
ExecStart = ''
${cfg.package}/bin/unitd --control 'unix:/run/unit/control.unit.sock' --pid '/run/unit/unit.pid' \
--log '${cfg.logDir}/unit.log' --state '${cfg.stateDir}' --no-daemon \
--user ${cfg.user} --group ${cfg.group}
'';
+ # User and group
+ User = cfg.user;
+ Group = cfg.group;
+ # Capabilities
+ AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" "CAP_SETGID" "CAP_SETUID" ];
+ # Security
+ NoNewPrivileges = true;
+ # Sanboxing
+ ProtectSystem = "full";
+ ProtectHome = true;
RuntimeDirectory = "unit";
RuntimeDirectoryMode = "0750";
+ PrivateTmp = true;
+ PrivateDevices = true;
+ ProtectHostname = true;
+ ProtectKernelTunables = true;
+ ProtectKernelModules = true;
+ ProtectControlGroups = true;
+ LockPersonality = true;
+ MemoryDenyWriteExecute = true;
+ RestrictRealtime = true;
+ PrivateMounts = true;
};
};
- users.users = optionalAttrs (cfg.user == "unit") (singleton {
- name = "unit";
- group = cfg.group;
+ users.users = optionalAttrs (cfg.user == "unit") {
+ unit.group = cfg.group;
isSystemUser = true;
- });
+ };
+
+ users.groups = optionalAttrs (cfg.group == "unit") {
+ unit = { };
+ };
- users.groups = optionalAttrs (cfg.group == "unit") (singleton {
- name = "unit";
- });
};
}
diff --git a/nixpkgs/nixos/modules/services/web-servers/uwsgi.nix b/nixpkgs/nixos/modules/services/web-servers/uwsgi.nix
index af70f32f32d..3481b5e6040 100644
--- a/nixpkgs/nixos/modules/services/web-servers/uwsgi.nix
+++ b/nixpkgs/nixos/modules/services/web-servers/uwsgi.nix
@@ -5,10 +5,6 @@ with lib;
let
cfg = config.services.uwsgi;
- uwsgi = pkgs.uwsgi.override {
- plugins = cfg.plugins;
- };
-
buildCfg = name: c:
let
plugins =
@@ -23,8 +19,8 @@ let
python =
if hasPython2 && hasPython3 then
throw "`plugins` attribute in UWSGI configuration shouldn't contain both python2 and python3"
- else if hasPython2 then uwsgi.python2
- else if hasPython3 then uwsgi.python3
+ else if hasPython2 then cfg.package.python2
+ else if hasPython3 then cfg.package.python3
else null;
pythonEnv = python.withPackages (c.pythonPackages or (self: []));
@@ -77,6 +73,11 @@ in {
description = "Where uWSGI communication sockets can live";
};
+ package = mkOption {
+ type = types.package;
+ internal = true;
+ };
+
instance = mkOption {
type = types.attrs;
default = {
@@ -138,7 +139,7 @@ in {
'';
serviceConfig = {
Type = "notify";
- ExecStart = "${uwsgi}/bin/uwsgi --uid ${cfg.user} --gid ${cfg.group} --json ${buildCfg "server" cfg.instance}/server.json";
+ ExecStart = "${cfg.package}/bin/uwsgi --uid ${cfg.user} --gid ${cfg.group} --json ${buildCfg "server" cfg.instance}/server.json";
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
ExecStop = "${pkgs.coreutils}/bin/kill -INT $MAINPID";
NotifyAccess = "main";
@@ -146,15 +147,19 @@ in {
};
};
- users.users = optionalAttrs (cfg.user == "uwsgi") (singleton
- { name = "uwsgi";
+ users.users = optionalAttrs (cfg.user == "uwsgi") {
+ uwsgi = {
group = cfg.group;
uid = config.ids.uids.uwsgi;
- });
+ };
+ };
+
+ users.groups = optionalAttrs (cfg.group == "uwsgi") {
+ uwsgi.gid = config.ids.gids.uwsgi;
+ };
- users.groups = optionalAttrs (cfg.group == "uwsgi") (singleton
- { name = "uwsgi";
- gid = config.ids.gids.uwsgi;
- });
+ services.uwsgi.package = pkgs.uwsgi.override {
+ inherit (cfg) plugins;
+ };
};
}
diff --git a/nixpkgs/nixos/modules/services/x11/desktop-managers/cde.nix b/nixpkgs/nixos/modules/services/x11/desktop-managers/cde.nix
new file mode 100644
index 00000000000..c1b6d3bf064
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/x11/desktop-managers/cde.nix
@@ -0,0 +1,55 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+ xcfg = config.services.xserver;
+ cfg = xcfg.desktopManager.cde;
+in {
+ options.services.xserver.desktopManager.cde = {
+ enable = mkEnableOption "Common Desktop Environment";
+ };
+
+ config = mkIf (xcfg.enable && cfg.enable) {
+ services.rpcbind.enable = true;
+
+ services.xinetd.enable = true;
+ services.xinetd.services = [
+ {
+ name = "cmsd";
+ protocol = "udp";
+ user = "root";
+ server = "${pkgs.cdesktopenv}/opt/dt/bin/rpc.cmsd";
+ extraConfig = ''
+ type = RPC UNLISTED
+ rpc_number = 100068
+ rpc_version = 2-5
+ only_from = 127.0.0.1/0
+ '';
+ }
+ ];
+
+ users.groups.mail = {};
+ security.wrappers = {
+ dtmail = {
+ source = "${pkgs.cdesktopenv}/bin/dtmail";
+ group = "mail";
+ setgid = true;
+ };
+ };
+
+ system.activationScripts.setup-cde = ''
+ mkdir -p /var/dt/{tmp,appconfig/appmanager}
+ chmod a+w+t /var/dt/{tmp,appconfig/appmanager}
+ '';
+
+ services.xserver.desktopManager.session = [
+ { name = "CDE";
+ start = ''
+ exec ${pkgs.cdesktopenv}/opt/dt/bin/Xsession
+ '';
+ }];
+ };
+
+ meta.maintainers = [ maintainers.gnidorah ];
+}
diff --git a/nixpkgs/nixos/modules/services/x11/desktop-managers/default.nix b/nixpkgs/nixos/modules/services/x11/desktop-managers/default.nix
index 671a959cdde..970fa620c6b 100644
--- a/nixpkgs/nixos/modules/services/x11/desktop-managers/default.nix
+++ b/nixpkgs/nixos/modules/services/x11/desktop-managers/default.nix
@@ -20,7 +20,7 @@ in
imports = [
./none.nix ./xterm.nix ./xfce.nix ./plasma5.nix ./lumina.nix
./lxqt.nix ./enlightenment.nix ./gnome3.nix ./kodi.nix ./maxx.nix
- ./mate.nix ./pantheon.nix ./surf-display.nix
+ ./mate.nix ./pantheon.nix ./surf-display.nix ./cde.nix
];
options = {
@@ -86,23 +86,14 @@ in
};
default = mkOption {
- type = types.str;
- default = "";
+ type = types.nullOr types.str;
+ default = null;
example = "none";
- description = "Default desktop manager loaded if none have been chosen.";
- apply = defaultDM:
- if defaultDM == "" && cfg.session.list != [] then
- (head cfg.session.list).name
- else if any (w: w.name == defaultDM) cfg.session.list then
- defaultDM
- else
- builtins.trace ''
- Default desktop manager (${defaultDM}) not found at evaluation time.
- These are the known valid session names:
- ${concatMapStringsSep "\n " (w: "services.xserver.desktopManager.default = \"${w.name}\";") cfg.session.list}
- It's also possible the default can be found in one of these packages:
- ${concatMapStringsSep "\n " (p: p.name) config.services.xserver.displayManager.extraSessionFilePackages}
- '' defaultDM;
+ description = ''
+ <emphasis role="strong">Deprecated</emphasis>, please use <xref linkend="opt-services.xserver.displayManager.defaultSession"/> instead.
+
+ Default desktop manager loaded if none have been chosen.
+ '';
};
};
diff --git a/nixpkgs/nixos/modules/services/x11/desktop-managers/enlightenment.nix b/nixpkgs/nixos/modules/services/x11/desktop-managers/enlightenment.nix
index 3745069f6ea..26b662a2a64 100644
--- a/nixpkgs/nixos/modules/services/x11/desktop-managers/enlightenment.nix
+++ b/nixpkgs/nixos/modules/services/x11/desktop-managers/enlightenment.nix
@@ -16,6 +16,10 @@ let
in
{
+ imports = [
+ (mkRenamedOptionModule [ "services" "xserver" "desktopManager" "e19" "enable" ] [ "services" "xserver" "desktopManager" "enlightenment" "enable" ])
+ ];
+
options = {
services.xserver.desktopManager.enlightenment.enable = mkOption {
@@ -64,10 +68,7 @@ in
security.wrappers = (import "${e.enlightenment}/e-wrappers.nix").security.wrappers;
- environment.etc = singleton
- { source = xcfg.xkbDir;
- target = "X11/xkb";
- };
+ environment.etc."X11/xkb".source = xcfg.xkbDir;
fonts.fonts = [ pkgs.dejavu_fonts pkgs.ubuntu_font_family ];
diff --git a/nixpkgs/nixos/modules/services/x11/desktop-managers/gnome3.nix b/nixpkgs/nixos/modules/services/x11/desktop-managers/gnome3.nix
index 6725595e1cf..6d9bd284bc7 100644
--- a/nixpkgs/nixos/modules/services/x11/desktop-managers/gnome3.nix
+++ b/nixpkgs/nixos/modules/services/x11/desktop-managers/gnome3.nix
@@ -144,7 +144,7 @@ in
services.gnome3.core-shell.enable = true;
services.gnome3.core-utilities.enable = mkDefault true;
- services.xserver.displayManager.extraSessionFilePackages = [ pkgs.gnome3.gnome-session ];
+ services.xserver.displayManager.sessionPackages = [ pkgs.gnome3.gnome-session ];
environment.extraInit = ''
${concatMapStrings (p: ''
@@ -171,7 +171,7 @@ in
})
(mkIf flashbackEnabled {
- services.xserver.displayManager.extraSessionFilePackages = map
+ services.xserver.displayManager.sessionPackages = map
(wm: pkgs.gnome3.gnome-flashback.mkSessionForWm {
inherit (wm) wmName wmLabel wmCommand;
}) (optional cfg.flashback.enableMetacity {
diff --git a/nixpkgs/nixos/modules/services/x11/desktop-managers/mate.nix b/nixpkgs/nixos/modules/services/x11/desktop-managers/mate.nix
index fe63f36cf96..4a6f2ca727d 100644
--- a/nixpkgs/nixos/modules/services/x11/desktop-managers/mate.nix
+++ b/nixpkgs/nixos/modules/services/x11/desktop-managers/mate.nix
@@ -98,7 +98,6 @@ in
services.gnome3.at-spi2-core.enable = true;
services.gnome3.gnome-keyring.enable = true;
- services.gnome3.gnome-settings-daemon.enable = true;
services.udev.packages = [ pkgs.mate.mate-settings-daemon ];
services.gvfs.enable = true;
services.upower.enable = config.powerManagement.enable;
diff --git a/nixpkgs/nixos/modules/services/x11/desktop-managers/pantheon.nix b/nixpkgs/nixos/modules/services/x11/desktop-managers/pantheon.nix
index 80dab135ee2..b46a2d189ef 100644
--- a/nixpkgs/nixos/modules/services/x11/desktop-managers/pantheon.nix
+++ b/nixpkgs/nixos/modules/services/x11/desktop-managers/pantheon.nix
@@ -5,6 +5,7 @@ with lib;
let
cfg = config.services.xserver.desktopManager.pantheon;
+ serviceCfg = config.services.pantheon;
nixos-gsettings-desktop-schemas = pkgs.pantheon.elementary-gsettings-schemas.override {
extraGSettingsOverridePackages = cfg.extraGSettingsOverridePackages;
@@ -19,6 +20,16 @@ in
options = {
+ services.pantheon = {
+
+ contractor = {
+ enable = mkEnableOption "contractor, a desktop-wide extension service used by Pantheon";
+ };
+
+ apps.enable = mkEnableOption "Pantheon default applications";
+
+ };
+
services.xserver.desktopManager.pantheon = {
enable = mkOption {
type = types.bool;
@@ -41,6 +52,18 @@ in
];
};
+ extraWingpanelIndicators = mkOption {
+ default = null;
+ type = with types; nullOr (listOf package);
+ description = "Indicators to add to Wingpanel.";
+ };
+
+ extraSwitchboardPlugs = mkOption {
+ default = null;
+ type = with types; nullOr (listOf package);
+ description = "Plugs to add to Switchboard.";
+ };
+
extraGSettingsOverrides = mkOption {
default = "";
type = types.lines;
@@ -67,124 +90,88 @@ in
};
- config = mkIf cfg.enable {
+ config = mkMerge [
+ (mkIf cfg.enable {
- services.xserver.displayManager.extraSessionFilePackages = [ pkgs.pantheon.elementary-session-settings ];
+ services.xserver.displayManager.sessionPackages = [ pkgs.pantheon.elementary-session-settings ];
- # Ensure lightdm is used when Pantheon is enabled
- # Without it screen locking will be nonfunctional because of the use of lightlocker
+ # Ensure lightdm is used when Pantheon is enabled
+ # Without it screen locking will be nonfunctional because of the use of lightlocker
+ warnings = optional (config.services.xserver.displayManager.lightdm.enable != true)
+ ''
+ Using Pantheon without LightDM as a displayManager will break screenlocking from the UI.
+ '';
- warnings = optional (config.services.xserver.displayManager.lightdm.enable != true)
- ''
- Using Pantheon without LightDM as a displayManager will break screenlocking from the UI.
+ services.xserver.displayManager.lightdm.greeters.pantheon.enable = mkDefault true;
+
+ # Without this, elementary LightDM greeter will pre-select non-existent `default` session
+ # https://github.com/elementary/greeter/issues/368
+ services.xserver.displayManager.defaultSession = "pantheon";
+
+ services.xserver.displayManager.sessionCommands = ''
+ if test "$XDG_CURRENT_DESKTOP" = "Pantheon"; then
+ ${concatMapStrings (p: ''
+ if [ -d "${p}/share/gsettings-schemas/${p.name}" ]; then
+ export XDG_DATA_DIRS=$XDG_DATA_DIRS''${XDG_DATA_DIRS:+:}${p}/share/gsettings-schemas/${p.name}
+ fi
+
+ if [ -d "${p}/lib/girepository-1.0" ]; then
+ export GI_TYPELIB_PATH=$GI_TYPELIB_PATH''${GI_TYPELIB_PATH:+:}${p}/lib/girepository-1.0
+ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}${p}/lib
+ fi
+ '') cfg.sessionPath}
+ fi
'';
- services.xserver.displayManager.lightdm.greeters.pantheon.enable = mkDefault true;
-
- # If not set manually Pantheon session cannot be started
- # Known issue of https://github.com/NixOS/nixpkgs/pull/43992
- services.xserver.desktopManager.default = mkForce "pantheon";
-
- services.xserver.displayManager.sessionCommands = ''
- if test "$XDG_CURRENT_DESKTOP" = "Pantheon"; then
- ${concatMapStrings (p: ''
- if [ -d "${p}/share/gsettings-schemas/${p.name}" ]; then
- export XDG_DATA_DIRS=$XDG_DATA_DIRS''${XDG_DATA_DIRS:+:}${p}/share/gsettings-schemas/${p.name}
- fi
-
- if [ -d "${p}/lib/girepository-1.0" ]; then
- export GI_TYPELIB_PATH=$GI_TYPELIB_PATH''${GI_TYPELIB_PATH:+:}${p}/lib/girepository-1.0
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}${p}/lib
- fi
- '') cfg.sessionPath}
- fi
- '';
-
- hardware.bluetooth.enable = mkDefault true;
- hardware.pulseaudio.enable = mkDefault true;
- security.polkit.enable = true;
- services.accounts-daemon.enable = true;
- services.bamf.enable = true;
- services.colord.enable = mkDefault true;
- services.pantheon.files.enable = mkDefault true;
- services.tumbler.enable = mkDefault true;
- services.system-config-printer.enable = (mkIf config.services.printing.enable (mkDefault true));
- services.dbus.packages = with pkgs.pantheon; [
- switchboard-plug-power
- elementary-default-settings
- ];
- services.pantheon.contractor.enable = mkDefault true;
- services.gnome3.at-spi2-core.enable = true;
- services.gnome3.evolution-data-server.enable = true;
- services.gnome3.glib-networking.enable = true;
- # TODO: gnome-keyring's xdg autostarts will still be in the environment (from elementary-session-settings) if disabled forcefully
- services.gnome3.gnome-keyring.enable = true;
- services.gnome3.gnome-settings-daemon.enable = true;
- services.udev.packages = [ pkgs.pantheon.elementary-settings-daemon ];
- services.gvfs.enable = true;
- services.gnome3.rygel.enable = mkDefault true;
- services.gsignond.enable = mkDefault true;
- services.gsignond.plugins = with pkgs.gsignondPlugins; [ lastfm mail oauth ];
- services.udisks2.enable = true;
- services.upower.enable = config.powerManagement.enable;
- services.xserver.libinput.enable = mkDefault true;
- services.xserver.updateDbusEnvironment = true;
- services.zeitgeist.enable = mkDefault true;
- services.geoclue2.enable = mkDefault true;
- # pantheon has pantheon-agent-geoclue2
- services.geoclue2.enableDemoAgent = false;
- services.geoclue2.appConfig."io.elementary.desktop.agent-geoclue2" = {
- isAllowed = true;
- isSystem = true;
- };
-
- programs.dconf.enable = true;
- programs.evince.enable = mkDefault true;
- programs.file-roller.enable = mkDefault true;
- # Otherwise you can't store NetworkManager Secrets with
- # "Store the password only for this user"
- programs.nm-applet.enable = true;
-
- # Shell integration for VTE terminals
- programs.bash.vteIntegration = mkDefault true;
- programs.zsh.vteIntegration = mkDefault true;
-
- # Harmonize Qt5 applications under Pantheon
- qt5.enable = true;
- qt5.platformTheme = "gnome";
- qt5.style = "adwaita";
-
- networking.networkmanager.enable = mkDefault true;
-
- # Override GSettings schemas
- environment.sessionVariables.NIX_GSETTINGS_OVERRIDES_DIR = "${nixos-gsettings-desktop-schemas}/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas";
-
- environment.sessionVariables.GNOME_SESSION_DEBUG = optionalString cfg.debug "1";
-
- # Settings from elementary-default-settings
- environment.sessionVariables.GTK_CSD = "1";
- environment.sessionVariables.GTK_MODULES = "pantheon-filechooser-module";
- environment.etc."gtk-3.0/settings.ini".source = "${pkgs.pantheon.elementary-default-settings}/etc/gtk-3.0/settings.ini";
-
- environment.pathsToLink = [
- # FIXME: modules should link subdirs of `/share` rather than relying on this
- "/share"
- ];
-
- environment.systemPackages =
- pkgs.pantheon.artwork ++ pkgs.pantheon.desktop ++ pkgs.pantheon.services ++ cfg.sessionPath
- ++ (with pkgs; gnome3.removePackagesByName
- ([
- gnome3.geary
- gnome3.epiphany
- gnome3.gnome-font-viewer
- ] ++ pantheon.apps) config.environment.pantheon.excludePackages)
- ++ (with pkgs;
- [
- adwaita-qt
+ # Default services
+ hardware.bluetooth.enable = mkDefault true;
+ hardware.pulseaudio.enable = mkDefault true;
+ security.polkit.enable = true;
+ services.accounts-daemon.enable = true;
+ services.bamf.enable = true;
+ services.colord.enable = mkDefault true;
+ services.tumbler.enable = mkDefault true;
+ services.system-config-printer.enable = (mkIf config.services.printing.enable (mkDefault true));
+ services.dbus.packages = with pkgs.pantheon; [
+ switchboard-plug-power
+ elementary-default-settings # accountsservice extensions
+ ];
+ services.pantheon.apps.enable = mkDefault true;
+ services.pantheon.contractor.enable = mkDefault true;
+ services.gnome3.at-spi2-core.enable = true;
+ services.gnome3.evolution-data-server.enable = true;
+ services.gnome3.glib-networking.enable = true;
+ services.gnome3.gnome-keyring.enable = true;
+ services.gvfs.enable = true;
+ services.gnome3.rygel.enable = mkDefault true;
+ services.gsignond.enable = mkDefault true;
+ services.gsignond.plugins = with pkgs.gsignondPlugins; [ lastfm mail oauth ];
+ services.udisks2.enable = true;
+ services.upower.enable = config.powerManagement.enable;
+ services.xserver.libinput.enable = mkDefault true;
+ services.xserver.updateDbusEnvironment = true;
+ services.zeitgeist.enable = mkDefault true;
+ services.geoclue2.enable = mkDefault true;
+ # pantheon has pantheon-agent-geoclue2
+ services.geoclue2.enableDemoAgent = false;
+ services.geoclue2.appConfig."io.elementary.desktop.agent-geoclue2" = {
+ isAllowed = true;
+ isSystem = true;
+ };
+ # Use gnome-settings-daemon fork
+ services.udev.packages = [
+ pkgs.pantheon.elementary-settings-daemon
+ ];
+ systemd.packages = [
+ pkgs.pantheon.elementary-settings-daemon
+ ];
+ programs.dconf.enable = true;
+ networking.networkmanager.enable = mkDefault true;
+
+ # Global environment
+ environment.systemPackages = with pkgs; [
desktop-file-utils
glib
- glib-networking
gnome-menus
gnome3.adwaita-icon-theme
gtk3.out
@@ -196,19 +183,111 @@ in
shared-mime-info
sound-theme-freedesktop
xdg-user-dirs
- ]);
+ ] ++ (with pkgs.pantheon; [
+ # Artwork
+ elementary-gtk-theme
+ elementary-icon-theme
+ elementary-sound-theme
+ elementary-wallpapers
+
+ # Desktop
+ elementary-default-settings
+ elementary-session-settings
+ elementary-shortcut-overlay
+ gala
+ (switchboard-with-plugs.override {
+ plugs = cfg.extraSwitchboardPlugs;
+ })
+ (wingpanel-with-indicators.override {
+ indicators = cfg.extraWingpanelIndicators;
+ })
+
+ # Services
+ cerbere
+ elementary-capnet-assist
+ elementary-dpms-helper
+ elementary-settings-daemon
+ pantheon-agent-geoclue2
+ pantheon-agent-polkit
+ ]) ++ (gnome3.removePackagesByName [
+ gnome3.geary
+ gnome3.epiphany
+ gnome3.gnome-font-viewer
+ ] config.environment.pantheon.excludePackages);
- fonts.fonts = with pkgs; [
- open-sans
- roboto-mono
- pantheon.elementary-redacted-script # needed by screenshot-tool
- ];
+ programs.evince.enable = mkDefault true;
+ programs.file-roller.enable = mkDefault true;
- fonts.fontconfig.defaultFonts = {
- monospace = [ "Roboto Mono" ];
- sansSerif = [ "Open Sans" ];
- };
+ # Settings from elementary-default-settings
+ environment.sessionVariables.GTK_CSD = "1";
+ environment.sessionVariables.GTK3_MODULES = [ "pantheon-filechooser-module" ];
+ environment.etc."gtk-3.0/settings.ini".source = "${pkgs.pantheon.elementary-default-settings}/etc/gtk-3.0/settings.ini";
- };
+ # Override GSettings schemas
+ environment.sessionVariables.NIX_GSETTINGS_OVERRIDES_DIR = "${nixos-gsettings-desktop-schemas}/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas";
+
+ environment.sessionVariables.GNOME_SESSION_DEBUG = mkIf cfg.debug "1";
+
+ environment.pathsToLink = [
+ # FIXME: modules should link subdirs of `/share` rather than relying on this
+ "/share"
+ ];
+
+ # Otherwise you can't store NetworkManager Secrets with
+ # "Store the password only for this user"
+ programs.nm-applet.enable = true;
+ # Shell integration for VTE terminals
+ programs.bash.vteIntegration = mkDefault true;
+ programs.zsh.vteIntegration = mkDefault true;
+
+ # Harmonize Qt5 applications under Pantheon
+ qt5.enable = true;
+ qt5.platformTheme = "gnome";
+ qt5.style = "adwaita";
+
+ # Default Fonts
+ fonts.fonts = with pkgs; [
+ open-sans
+ roboto-mono
+ ];
+
+ fonts.fontconfig.defaultFonts = {
+ monospace = [ "Roboto Mono" ];
+ sansSerif = [ "Open Sans" ];
+ };
+ })
+
+ (mkIf serviceCfg.apps.enable {
+ environment.systemPackages = (with pkgs.pantheon; pkgs.gnome3.removePackagesByName [
+ elementary-calculator
+ elementary-calendar
+ elementary-camera
+ elementary-code
+ elementary-files
+ elementary-music
+ elementary-photos
+ elementary-screenshot-tool
+ elementary-terminal
+ elementary-videos
+ ] config.environment.pantheon.excludePackages);
+
+ # needed by screenshot-tool
+ fonts.fonts = [
+ pkgs.pantheon.elementary-redacted-script
+ ];
+ })
+
+ (mkIf serviceCfg.contractor.enable {
+ environment.systemPackages = with pkgs.pantheon; [
+ contractor
+ extra-elementary-contracts
+ ];
+
+ environment.pathsToLink = [
+ "/share/contractor"
+ ];
+ })
+
+ ];
}
diff --git a/nixpkgs/nixos/modules/services/x11/desktop-managers/plasma5.nix b/nixpkgs/nixos/modules/services/x11/desktop-managers/plasma5.nix
index da8bdcb78c4..2538858ac0f 100644
--- a/nixpkgs/nixos/modules/services/x11/desktop-managers/plasma5.nix
+++ b/nixpkgs/nixos/modules/services/x11/desktop-managers/plasma5.nix
@@ -33,6 +33,7 @@ in
imports = [
(mkRemovedOptionModule [ "services" "xserver" "desktopManager" "plasma5" "enableQt4Support" ] "Phonon no longer supports Qt 4.")
+ (mkRenamedOptionModule [ "services" "xserver" "desktopManager" "kde5" ] [ "services" "xserver" "desktopManager" "plasma5" ])
];
config = mkMerge [
@@ -169,7 +170,7 @@ in
++ lib.optional (cfg.phononBackend == "vlc") libsForQt5.phonon-backend-vlc
# Optional hardware support features
- ++ lib.optionals config.hardware.bluetooth.enable [ bluedevil bluez-qt ]
+ ++ lib.optionals config.hardware.bluetooth.enable [ bluedevil bluez-qt openobex obexftp ]
++ lib.optional config.networking.networkmanager.enable plasma-nm
++ lib.optional config.hardware.pulseaudio.enable plasma-pa
++ lib.optional config.powerManagement.enable powerdevil
@@ -182,10 +183,7 @@ in
"/share"
];
- environment.etc = singleton {
- source = xcfg.xkbDir;
- target = "X11/xkb";
- };
+ environment.etc."X11/xkb".source = xcfg.xkbDir;
# Enable GTK applications to load SVG icons
services.xserver.gdk-pixbuf.modulePackages = [ pkgs.librsvg ];
diff --git a/nixpkgs/nixos/modules/services/x11/desktop-managers/surf-display.nix b/nixpkgs/nixos/modules/services/x11/desktop-managers/surf-display.nix
index 140dde828da..9aeb0bbd2a8 100644
--- a/nixpkgs/nixos/modules/services/x11/desktop-managers/surf-display.nix
+++ b/nixpkgs/nixos/modules/services/x11/desktop-managers/surf-display.nix
@@ -118,7 +118,7 @@ in {
};
config = mkIf cfg.enable {
- services.xserver.displayManager.extraSessionFilePackages = [
+ services.xserver.displayManager.sessionPackages = [
pkgs.surf-display
];
diff --git a/nixpkgs/nixos/modules/services/x11/desktop-managers/xfce.nix b/nixpkgs/nixos/modules/services/x11/desktop-managers/xfce.nix
index 0b70ad5f29c..a08b1947f65 100644
--- a/nixpkgs/nixos/modules/services/x11/desktop-managers/xfce.nix
+++ b/nixpkgs/nixos/modules/services/x11/desktop-managers/xfce.nix
@@ -31,6 +31,7 @@ in
(mkRenamedOptionModule
[ "services" "xserver" "desktopManager" "xfce" "extraSessionCommands" ]
[ "services" "xserver" "displayManager" "sessionCommands" ])
+ (mkRemovedOptionModule [ "services" "xserver" "desktopManager" "xfce" "screenLock" ] "")
];
options = {
diff --git a/nixpkgs/nixos/modules/services/x11/display-managers/account-service-util.nix b/nixpkgs/nixos/modules/services/x11/display-managers/account-service-util.nix
new file mode 100644
index 00000000000..1dbe703b566
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/x11/display-managers/account-service-util.nix
@@ -0,0 +1,39 @@
+{ accountsservice
+, glib
+, gobject-introspection
+, python3
+, wrapGAppsHook
+}:
+
+python3.pkgs.buildPythonApplication {
+ name = "set-session";
+
+ format = "other";
+
+ src = ./set-session.py;
+
+ dontUnpack = true;
+
+ strictDeps = false;
+
+ nativeBuildInputs = [
+ wrapGAppsHook
+ gobject-introspection
+ ];
+
+ buildInputs = [
+ accountsservice
+ glib
+ ];
+
+ propagatedBuildInputs = with python3.pkgs; [
+ pygobject3
+ ordered-set
+ ];
+
+ installPhase = ''
+ mkdir -p $out/bin
+ cp $src $out/bin/set-session
+ chmod +x $out/bin/set-session
+ '';
+}
diff --git a/nixpkgs/nixos/modules/services/x11/display-managers/default.nix b/nixpkgs/nixos/modules/services/x11/display-managers/default.nix
index b66856fd4d4..1efd0739376 100644
--- a/nixpkgs/nixos/modules/services/x11/display-managers/default.nix
+++ b/nixpkgs/nixos/modules/services/x11/display-managers/default.nix
@@ -27,16 +27,7 @@ let
Xft.hintstyle: hintslight
'';
- mkCases = session:
- concatStrings (
- mapAttrsToList (name: starts: ''
- (${name})
- ${concatMapStringsSep "\n " (n: n.start) starts}
- ;;
- '') (lib.groupBy (n: n.name) session)
- );
-
- # file provided by services.xserver.displayManager.session.wrapper
+ # file provided by services.xserver.displayManager.sessionData.wrapper
xsessionWrapper = pkgs.writeScript "xsession-wrapper"
''
#! ${pkgs.bash}/bin/bash
@@ -116,98 +107,47 @@ let
# Run the supplied session command. Remove any double quotes with eval.
eval exec "$@"
else
- # Fall back to the default window/desktopManager
- exec ${cfg.displayManager.session.script}
+ # TODO: Do we need this? Should not the session always exist?
+ echo "error: unknown session $1" 1>&2
+ exit 1
fi
'';
- # file provided by services.xserver.displayManager.session.script
- xsession = wm: dm: pkgs.writeScript "xsession"
- ''
- #! ${pkgs.bash}/bin/bash
-
- # Legacy session script used to construct .desktop files from
- # `services.xserver.displayManager.session` entries. Called from
- # `sessionWrapper`.
-
- # Expected parameters:
- # $1 = <desktop-manager>+<window-manager>
-
- # The first argument of this script is the session type.
- sessionType="$1"
- if [ "$sessionType" = default ]; then sessionType=""; fi
-
- # The session type is "<desktop-manager>+<window-manager>", so
- # extract those (see:
- # http://wiki.bash-hackers.org/syntax/pe#substring_removal).
- windowManager="''${sessionType##*+}"
- : ''${windowManager:=${cfg.windowManager.default}}
- desktopManager="''${sessionType%%+*}"
- : ''${desktopManager:=${cfg.desktopManager.default}}
-
- # Start the window manager.
- case "$windowManager" in
- ${mkCases wm}
- (*) echo "$0: Window manager '$windowManager' not found.";;
- esac
-
- # Start the desktop manager.
- case "$desktopManager" in
- ${mkCases dm}
- (*) echo "$0: Desktop manager '$desktopManager' not found.";;
- esac
-
- ${optionalString cfg.updateDbusEnvironment ''
- ${lib.getBin pkgs.dbus}/bin/dbus-update-activation-environment --systemd --all
- ''}
-
- test -n "$waitPID" && wait "$waitPID"
-
- ${config.systemd.package}/bin/systemctl --user stop graphical-session.target
-
- exit 0
- '';
-
- # Desktop Entry Specification:
- # - https://standards.freedesktop.org/desktop-entry-spec/latest/
- # - https://standards.freedesktop.org/desktop-entry-spec/latest/ar01s06.html
- mkDesktops = names: pkgs.runCommand "desktops"
+ installedSessions = pkgs.runCommand "desktops"
{ # trivial derivation
preferLocalBuild = true;
allowSubstitutes = false;
}
''
- mkdir -p "$out/share/xsessions"
- ${concatMapStrings (n: ''
- cat - > "$out/share/xsessions/${n}.desktop" << EODESKTOP
- [Desktop Entry]
- Version=1.0
- Type=XSession
- TryExec=${cfg.displayManager.session.script}
- Exec=${cfg.displayManager.session.script} "${n}"
- Name=${n}
- Comment=
- EODESKTOP
- '') names}
+ mkdir -p "$out/share/"{xsessions,wayland-sessions}
${concatMapStrings (pkg: ''
+ for n in ${concatStringsSep " " pkg.providedSessions}; do
+ if ! test -f ${pkg}/share/wayland-sessions/$n.desktop -o \
+ -f ${pkg}/share/xsessions/$n.desktop; then
+ echo "Couldn't find provided session name, $n.desktop, in session package ${pkg.name}:"
+ echo " ${pkg}"
+ return 1
+ fi
+ done
+
if test -d ${pkg}/share/xsessions; then
${xorg.lndir}/bin/lndir ${pkg}/share/xsessions $out/share/xsessions
fi
- '') cfg.displayManager.extraSessionFilePackages}
-
- ${concatMapStrings (pkg: ''
if test -d ${pkg}/share/wayland-sessions; then
- mkdir -p "$out/share/wayland-sessions"
${xorg.lndir}/bin/lndir ${pkg}/share/wayland-sessions $out/share/wayland-sessions
fi
- '') cfg.displayManager.extraSessionFilePackages}
+ '') cfg.displayManager.sessionPackages}
'';
+ dmDefault = cfg.desktopManager.default;
+ wmDefault = cfg.windowManager.default;
+
+ defaultSessionFromLegacyOptions = concatStringsSep "+" (filter (s: s != null) ([ dmDefault ] ++ optional (wmDefault != "none") wmDefault));
+
in
{
-
options = {
services.xserver.displayManager = {
@@ -262,11 +202,24 @@ in
'';
};
- extraSessionFilePackages = mkOption {
- type = types.listOf types.package;
+ sessionPackages = mkOption {
+ type = with types; listOf (package // {
+ description = "package with provided sessions";
+ check = p: assertMsg
+ (package.check p && p ? providedSessions
+ && p.providedSessions != [] && all isString p.providedSessions)
+ ''
+ Package, '${p.name}', did not specify any session names, as strings, in
+ 'passthru.providedSessions'. This is required when used as a session package.
+
+ The session names can be looked up in:
+ ${p}/share/xsessions
+ ${p}/share/wayland-sessions
+ '';
+ });
default = [];
description = ''
- A list of packages containing xsession files to be passed to the display manager.
+ A list of packages containing x11 or wayland session files to be passed to the display manager.
'';
};
@@ -297,18 +250,50 @@ in
inside the display manager with the desktop manager name
followed by the window manager name.
'';
- apply = list: rec {
- wm = filter (s: s.manage == "window") list;
- dm = filter (s: s.manage == "desktop") list;
- names = flip concatMap dm
- (d: map (w: d.name + optionalString (w.name != "none") ("+" + w.name))
- (filter (w: d.name != "none" || w.name != "none") wm));
- desktops = mkDesktops names;
- script = xsession wm dm;
+ };
+
+ sessionData = mkOption {
+ description = "Data exported for display managers’ convenience";
+ internal = true;
+ default = {};
+ apply = val: {
wrapper = xsessionWrapper;
+ desktops = installedSessions;
+ sessionNames = concatMap (p: p.providedSessions) cfg.displayManager.sessionPackages;
+ # We do not want to force users to set defaultSession when they have only single DE.
+ autologinSession =
+ if cfg.displayManager.defaultSession != null then
+ cfg.displayManager.defaultSession
+ else if cfg.displayManager.sessionData.sessionNames != [] then
+ head cfg.displayManager.sessionData.sessionNames
+ else
+ null;
};
};
+ defaultSession = mkOption {
+ type = with types; nullOr str // {
+ description = "session name";
+ check = d:
+ assertMsg (d != null -> (str.check d && elem d cfg.displayManager.sessionData.sessionNames)) ''
+ Default graphical session, '${d}', not found.
+ Valid names for 'services.xserver.displayManager.defaultSession' are:
+ ${concatStringsSep "\n " cfg.displayManager.sessionData.sessionNames}
+ '';
+ };
+ default =
+ if dmDefault != null || wmDefault != null then
+ defaultSessionFromLegacyOptions
+ else
+ null;
+ example = "gnome";
+ description = ''
+ Graphical session to pre-select in the session chooser (only effective for GDM and LightDM).
+
+ On GDM, LightDM and SDDM, it will also be used as a session for auto-login.
+ '';
+ };
+
job = {
preStart = mkOption {
@@ -357,6 +342,27 @@ in
};
config = {
+ assertions = [
+ {
+ assertion = cfg.desktopManager.default != null || cfg.windowManager.default != null -> cfg.displayManager.defaultSession == defaultSessionFromLegacyOptions;
+ message = "You cannot use both services.xserver.displayManager.defaultSession option and legacy options (services.xserver.desktopManager.default and services.xserver.windowManager.default).";
+ }
+ ];
+
+ warnings =
+ mkIf (dmDefault != null || wmDefault != null) [
+ ''
+ The following options are deprecated:
+ ${concatStringsSep "\n " (map ({c, t}: t) (filter ({c, t}: c != null) [
+ { c = dmDefault; t = "- services.xserver.desktopManager.default"; }
+ { c = wmDefault; t = "- services.xserver.windowManager.default"; }
+ ]))}
+ Please use
+ services.xserver.displayManager.defaultSession = "${concatStringsSep "+" (filter (s: s != null) [ dmDefault wmDefault ])}";
+ instead.
+ ''
+ ];
+
services.xserver.displayManager.xserverBin = "${xorg.xorgserver.out}/bin/X";
systemd.user.targets.graphical-session = {
@@ -365,11 +371,75 @@ in
StopWhenUnneeded = false;
};
};
+
+ # Create desktop files and scripts for starting sessions for WMs/DMs
+ # that do not have upstream session files (those defined using services.{display,desktop,window}Manager.session options).
+ services.xserver.displayManager.sessionPackages =
+ let
+ dms = filter (s: s.manage == "desktop") cfg.displayManager.session;
+ wms = filter (s: s.manage == "window") cfg.displayManager.session;
+
+ # Script responsible for starting the window manager and the desktop manager.
+ xsession = dm: wm: pkgs.writeScript "xsession" ''
+ #! ${pkgs.bash}/bin/bash
+
+ # Legacy session script used to construct .desktop files from
+ # `services.xserver.displayManager.session` entries. Called from
+ # `sessionWrapper`.
+
+ # Start the window manager.
+ ${wm.start}
+
+ # Start the desktop manager.
+ ${dm.start}
+
+ ${optionalString cfg.updateDbusEnvironment ''
+ ${lib.getBin pkgs.dbus}/bin/dbus-update-activation-environment --systemd --all
+ ''}
+
+ test -n "$waitPID" && wait "$waitPID"
+
+ ${config.systemd.package}/bin/systemctl --user stop graphical-session.target
+
+ exit 0
+ '';
+ in
+ # We will generate every possible pair of WM and DM.
+ concatLists (
+ crossLists
+ (dm: wm: let
+ sessionName = "${dm.name}${optionalString (wm.name != "none") ("+" + wm.name)}";
+ script = xsession dm wm;
+ in
+ optional (dm.name != "none" || wm.name != "none")
+ (pkgs.writeTextFile {
+ name = "${sessionName}-xsession";
+ destination = "/share/xsessions/${sessionName}.desktop";
+ # Desktop Entry Specification:
+ # - https://standards.freedesktop.org/desktop-entry-spec/latest/
+ # - https://standards.freedesktop.org/desktop-entry-spec/latest/ar01s06.html
+ text = ''
+ [Desktop Entry]
+ Version=1.0
+ Type=XSession
+ TryExec=${script}
+ Exec=${script}
+ Name=${sessionName}
+ '';
+ } // {
+ providedSessions = [ sessionName ];
+ })
+ )
+ [dms wms]
+ );
};
imports = [
- (mkRemovedOptionModule [ "services" "xserver" "displayManager" "desktopManagerHandlesLidAndPower" ]
+ (mkRemovedOptionModule [ "services" "xserver" "displayManager" "desktopManagerHandlesLidAndPower" ]
"The option is no longer necessary because all display managers have already delegated lid management to systemd.")
+ (mkRenamedOptionModule [ "services" "xserver" "displayManager" "job" "logsXsession" ] [ "services" "xserver" "displayManager" "job" "logToFile" ])
+ (mkRenamedOptionModule [ "services" "xserver" "displayManager" "logToJournal" ] [ "services" "xserver" "displayManager" "job" "logToJournal" ])
+ (mkRenamedOptionModule [ "services" "xserver" "displayManager" "extraSessionFilesPackages" ] [ "services" "xserver" "displayManager" "sessionPackages" ])
];
}
diff --git a/nixpkgs/nixos/modules/services/x11/display-managers/gdm.nix b/nixpkgs/nixos/modules/services/x11/display-managers/gdm.nix
index 912ec5bd38e..2f8c8cc9013 100644
--- a/nixpkgs/nixos/modules/services/x11/display-managers/gdm.nix
+++ b/nixpkgs/nixos/modules/services/x11/display-managers/gdm.nix
@@ -31,44 +31,9 @@ let
load-module module-position-event-sounds
'';
- dmDefault = config.services.xserver.desktopManager.default;
- wmDefault = config.services.xserver.windowManager.default;
- hasDefaultUserSession = dmDefault != "none" || wmDefault != "none";
- defaultSessionName = dmDefault + optionalString (wmDefault != "none") ("+" + wmDefault);
-
- setSessionScript = pkgs.python3.pkgs.buildPythonApplication {
- name = "set-session";
-
- format = "other";
-
- src = ./set-session.py;
-
- dontUnpack = true;
-
- strictDeps = false;
-
- nativeBuildInputs = with pkgs; [
- wrapGAppsHook
- gobject-introspection
- ];
-
- buildInputs = with pkgs; [
- accountsservice
- glib
- ];
-
- propagatedBuildInputs = with pkgs.python3.pkgs; [
- pygobject3
- ordered-set
- ];
-
- installPhase = ''
- mkdir -p $out/bin
- cp $src $out/bin/set-session
- chmod +x $out/bin/set-session
- '';
- };
+ defaultSessionName = config.services.xserver.displayManager.defaultSession;
+ setSessionScript = pkgs.callPackage ./account-service-util.nix { };
in
{
@@ -186,7 +151,7 @@ in
environment = {
GDM_X_SERVER_EXTRA_ARGS = toString
(filter (arg: arg != "-terminate") cfg.xserverArgs);
- XDG_DATA_DIRS = "${cfg.session.desktops}/share/";
+ XDG_DATA_DIRS = "${cfg.sessionData.desktops}/share/";
} // optionalAttrs (xSessionWrapper != null) {
# Make GDM use this wrapper before running the session, which runs the
# configured setupCommands. This relies on a patched GDM which supports
@@ -194,23 +159,28 @@ in
GDM_X_SESSION_WRAPPER = "${xSessionWrapper}";
};
execCmd = "exec ${gdm}/bin/gdm";
- preStart = optionalString config.hardware.pulseaudio.enable ''
- mkdir -p /run/gdm/.config/pulse
- ln -sf ${pulseConfig} /run/gdm/.config/pulse/default.pa
- chown -R gdm:gdm /run/gdm/.config
- '' + optionalString config.services.gnome3.gnome-initial-setup.enable ''
- # Create stamp file for gnome-initial-setup to prevent run.
- mkdir -p /run/gdm/.config
- cat - > /run/gdm/.config/gnome-initial-setup-done <<- EOF
- yes
- EOF
- '' + optionalString hasDefaultUserSession ''
- ${setSessionScript}/bin/set-session ${defaultSessionName}
+ preStart = optionalString (defaultSessionName != null) ''
+ # Set default session in session chooser to a specified values – basically ignore session history.
+ ${setSessionScript}/bin/set-session ${cfg.sessionData.autologinSession}
'';
};
- # Because sd_login_monitor_new requires /run/systemd/machines
- systemd.services.display-manager.wants = [ "systemd-machined.service" ];
+ systemd.tmpfiles.rules = [
+ "d /run/gdm/.config 0711 gdm gdm -"
+ ] ++ optionals config.hardware.pulseaudio.enable [
+ "L+ /run/gdm/.config/pulse - - - - ${pulseConfig}"
+ ] ++ optionals config.services.gnome3.gnome-initial-setup.enable [
+ # Create stamp file for gnome-initial-setup to prevent it starting in GDM.
+ "f /run/gdm/.config/gnome-initial-setup-done 0711 gdm gdm - yes"
+ ];
+
+ systemd.services.display-manager.wants = [
+ # Because sd_login_monitor_new requires /run/systemd/machines
+ "systemd-machined.service"
+ # setSessionScript wants AccountsService
+ "accounts-daemon.service"
+ ];
+
systemd.services.display-manager.after = [
"rc-local.service"
"systemd-machined.service"
@@ -281,7 +251,7 @@ in
customDconfDb = pkgs.stdenv.mkDerivation {
name = "gdm-dconf-db";
buildCommand = ''
- ${pkgs.gnome3.dconf}/bin/dconf compile $out ${customDconf}/dconf
+ ${pkgs.dconf}/bin/dconf compile $out ${customDconf}/dconf
'';
};
in pkgs.stdenv.mkDerivation {
@@ -326,7 +296,7 @@ in
${optionalString cfg.gdm.debug "Enable=true"}
'';
- environment.etc."gdm/Xsession".source = config.services.xserver.displayManager.session.wrapper;
+ environment.etc."gdm/Xsession".source = config.services.xserver.displayManager.sessionData.wrapper;
# GDM LFS PAM modules, adapted somehow to NixOS
security.pam.services = {
diff --git a/nixpkgs/nixos/modules/services/x11/display-managers/lightdm-greeters/mini.nix b/nixpkgs/nixos/modules/services/x11/display-managers/lightdm-greeters/mini.nix
index fa9445af32e..0025f9b3603 100644
--- a/nixpkgs/nixos/modules/services/x11/display-managers/lightdm-greeters/mini.nix
+++ b/nixpkgs/nixos/modules/services/x11/display-managers/lightdm-greeters/mini.nix
@@ -53,9 +53,8 @@ in
Whether to enable lightdm-mini-greeter as the lightdm greeter.
Note that this greeter starts only the default X session.
- You can configure the default X session by
- <option>services.xserver.desktopManager.default</option> and
- <option>services.xserver.windowManager.default</option>.
+ You can configure the default X session using
+ <xref linkend="opt-services.xserver.displayManager.defaultSession"/>.
'';
};
diff --git a/nixpkgs/nixos/modules/services/x11/display-managers/lightdm-greeters/pantheon.nix b/nixpkgs/nixos/modules/services/x11/display-managers/lightdm-greeters/pantheon.nix
index 29cb6ccbc06..77c94114e6d 100644
--- a/nixpkgs/nixos/modules/services/x11/display-managers/lightdm-greeters/pantheon.nix
+++ b/nixpkgs/nixos/modules/services/x11/display-managers/lightdm-greeters/pantheon.nix
@@ -35,6 +35,9 @@ in
name = "io.elementary.greeter";
};
+ # Show manual login card.
+ services.xserver.displayManager.lightdm.extraSeatDefaults = "greeter-show-manual-login=true";
+
environment.etc."lightdm/io.elementary.greeter.conf".source = "${pkgs.pantheon.elementary-greeter}/etc/lightdm/io.elementary.greeter.conf";
environment.etc."wingpanel.d/io.elementary.greeter.whitelist".source = "${pkgs.pantheon.elementary-default-settings}/etc/wingpanel.d/io.elementary.greeter.whitelist";
diff --git a/nixpkgs/nixos/modules/services/x11/display-managers/lightdm.nix b/nixpkgs/nixos/modules/services/x11/display-managers/lightdm.nix
index cf4c05acbcc..f7face0adb7 100644
--- a/nixpkgs/nixos/modules/services/x11/display-managers/lightdm.nix
+++ b/nixpkgs/nixos/modules/services/x11/display-managers/lightdm.nix
@@ -8,10 +8,9 @@ let
dmcfg = xcfg.displayManager;
xEnv = config.systemd.services.display-manager.environment;
cfg = dmcfg.lightdm;
+ sessionData = dmcfg.sessionData;
- dmDefault = xcfg.desktopManager.default;
- wmDefault = xcfg.windowManager.default;
- hasDefaultUserSession = dmDefault != "none" || wmDefault != "none";
+ setSessionScript = pkgs.callPackage ./account-service-util.nix { };
inherit (pkgs) lightdm writeScript writeText;
@@ -45,22 +44,19 @@ let
greeter-user = ${config.users.users.lightdm.name}
greeters-directory = ${cfg.greeter.package}
''}
- sessions-directory = ${dmcfg.session.desktops}/share/xsessions
+ sessions-directory = ${dmcfg.sessionData.desktops}/share/xsessions:${dmcfg.sessionData.desktops}/share/wayland-sessions
${cfg.extraConfig}
[Seat:*]
xserver-command = ${xserverWrapper}
- session-wrapper = ${dmcfg.session.wrapper}
+ session-wrapper = ${dmcfg.sessionData.wrapper}
${optionalString cfg.greeter.enable ''
greeter-session = ${cfg.greeter.name}
''}
${optionalString cfg.autoLogin.enable ''
autologin-user = ${cfg.autoLogin.user}
autologin-user-timeout = ${toString cfg.autoLogin.timeout}
- autologin-session = ${defaultSessionName}
- ''}
- ${optionalString hasDefaultUserSession ''
- user-session=${defaultSessionName}
+ autologin-session = ${sessionData.autologinSession}
''}
${optionalString (dmcfg.setupCommands != "") ''
display-setup-script=${pkgs.writeScript "lightdm-display-setup" ''
@@ -71,7 +67,6 @@ let
${cfg.extraSeatDefaults}
'';
- defaultSessionName = dmDefault + optionalString (wmDefault != "none") ("+" + wmDefault);
in
{
# Note: the order in which lightdm greeter modules are imported
@@ -199,11 +194,9 @@ in
LightDM auto-login requires services.xserver.displayManager.lightdm.autoLogin.user to be set
'';
}
- { assertion = cfg.autoLogin.enable -> dmDefault != "none" || wmDefault != "none";
+ { assertion = cfg.autoLogin.enable -> sessionData.autologinSession != null;
message = ''
- LightDM auto-login requires that services.xserver.desktopManager.default and
- services.xserver.windowManager.default are set to valid values. The current
- default session: ${defaultSessionName} is not valid.
+ LightDM auto-login requires that services.xserver.displayManager.defaultSession is set.
'';
}
{ assertion = !cfg.greeter.enable -> (cfg.autoLogin.enable && cfg.autoLogin.timeout == 0);
@@ -214,6 +207,20 @@ in
}
];
+ # Set default session in session chooser to a specified values – basically ignore session history.
+ # Auto-login is already covered by a config value.
+ services.xserver.displayManager.job.preStart = optionalString (!cfg.autoLogin.enable && dmcfg.defaultSession != null) ''
+ ${setSessionScript}/bin/set-session ${dmcfg.defaultSession}
+ '';
+
+ # setSessionScript needs session-files in XDG_DATA_DIRS
+ services.xserver.displayManager.job.environment.XDG_DATA_DIRS = "${dmcfg.sessionData.desktops}/share/";
+
+ # setSessionScript wants AccountsService
+ systemd.services.display-manager.wants = [
+ "accounts-daemon.service"
+ ];
+
# lightdm relaunches itself via just `lightdm`, so needs to be on the PATH
services.xserver.displayManager.job.execCmd = ''
export PATH=${lightdm}/sbin:$PATH
diff --git a/nixpkgs/nixos/modules/services/x11/display-managers/sddm.nix b/nixpkgs/nixos/modules/services/x11/display-managers/sddm.nix
index 899dd8665a2..4224c557ed6 100644
--- a/nixpkgs/nixos/modules/services/x11/display-managers/sddm.nix
+++ b/nixpkgs/nixos/modules/services/x11/display-managers/sddm.nix
@@ -50,8 +50,8 @@ let
MinimumVT=${toString (if xcfg.tty != null then xcfg.tty else 7)}
ServerPath=${xserverWrapper}
XephyrPath=${pkgs.xorg.xorgserver.out}/bin/Xephyr
- SessionCommand=${dmcfg.session.wrapper}
- SessionDir=${dmcfg.session.desktops}/share/xsessions
+ SessionCommand=${dmcfg.sessionData.wrapper}
+ SessionDir=${dmcfg.sessionData.desktops}/share/xsessions
XauthPath=${pkgs.xorg.xauth}/bin/xauth
DisplayCommand=${Xsetup}
DisplayStopCommand=${Xstop}
@@ -59,26 +59,27 @@ let
[Wayland]
EnableHidpi=${if cfg.enableHidpi then "true" else "false"}
- SessionDir=${dmcfg.session.desktops}/share/wayland-sessions
+ SessionDir=${dmcfg.sessionData.desktops}/share/wayland-sessions
${optionalString cfg.autoLogin.enable ''
[Autologin]
User=${cfg.autoLogin.user}
- Session=${defaultSessionName}.desktop
+ Session=${autoLoginSessionName}.desktop
Relogin=${boolToString cfg.autoLogin.relogin}
''}
${cfg.extraConfig}
'';
- defaultSessionName =
- let
- dm = xcfg.desktopManager.default;
- wm = xcfg.windowManager.default;
- in dm + optionalString (wm != "none") ("+" + wm);
+ autoLoginSessionName = dmcfg.sessionData.autologinSession;
in
{
+ imports = [
+ (mkRemovedOptionModule [ "services" "xserver" "displayManager" "sddm" "themes" ]
+ "Set the option `services.xserver.displayManager.sddm.package' instead.")
+ ];
+
options = {
services.xserver.displayManager.sddm = {
@@ -205,11 +206,9 @@ in
SDDM auto-login requires services.xserver.displayManager.sddm.autoLogin.user to be set
'';
}
- { assertion = cfg.autoLogin.enable -> elem defaultSessionName dmcfg.session.names;
+ { assertion = cfg.autoLogin.enable -> autoLoginSessionName != null;
message = ''
- SDDM auto-login requires that services.xserver.desktopManager.default and
- services.xserver.windowManager.default are set to valid values. The current
- default session: ${defaultSessionName} is not valid.
+ SDDM auto-login requires that services.xserver.displayManager.defaultSession is set.
'';
}
];
diff --git a/nixpkgs/nixos/modules/services/x11/extra-layouts.nix b/nixpkgs/nixos/modules/services/x11/extra-layouts.nix
index 1af98a1318b..f48216ff446 100644
--- a/nixpkgs/nixos/modules/services/x11/extra-layouts.nix
+++ b/nixpkgs/nixos/modules/services/x11/extra-layouts.nix
@@ -141,7 +141,7 @@ in
});
xkbcomp = super.xorg.xkbcomp.overrideAttrs (old: {
- configureFlags = "--with-xkb-config-root=${self.xkb_patched}/share/X11/xkb";
+ configureFlags = [ "--with-xkb-config-root=${self.xkb_patched}/share/X11/xkb" ];
});
};
@@ -158,6 +158,12 @@ in
});
+ environment.sessionVariables = {
+ # runtime override supported by multiple libraries e. g. libxkbcommon
+ # https://xkbcommon.org/doc/current/group__include-path.html
+ XKB_CONFIG_ROOT = "${pkgs.xkb_patched}/etc/X11/xkb";
+ };
+
services.xserver = {
xkbDir = "${pkgs.xkb_patched}/etc/X11/xkb";
exportConfiguration = config.services.xserver.displayManager.startx.enable;
diff --git a/nixpkgs/nixos/modules/services/x11/hardware/libinput.nix b/nixpkgs/nixos/modules/services/x11/hardware/libinput.nix
index 71065dfc26b..f6b0e7c09f5 100644
--- a/nixpkgs/nixos/modules/services/x11/hardware/libinput.nix
+++ b/nixpkgs/nixos/modules/services/x11/hardware/libinput.nix
@@ -198,12 +198,13 @@ in {
environment.systemPackages = [ pkgs.xorg.xf86inputlibinput ];
- environment.etc = [
- (let cfgPath = "X11/xorg.conf.d/40-libinput.conf"; in {
- source = pkgs.xorg.xf86inputlibinput.out + "/share/" + cfgPath;
- target = cfgPath;
- })
- ];
+ environment.etc =
+ let cfgPath = "X11/xorg.conf.d/40-libinput.conf";
+ in {
+ ${cfgPath} = {
+ source = pkgs.xorg.xf86inputlibinput.out + "/share/" + cfgPath;
+ };
+ };
services.udev.packages = [ pkgs.libinput.out ];
diff --git a/nixpkgs/nixos/modules/services/x11/imwheel.nix b/nixpkgs/nixos/modules/services/x11/imwheel.nix
new file mode 100644
index 00000000000..3923df498e7
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/x11/imwheel.nix
@@ -0,0 +1,68 @@
+{ config, lib, pkgs, ... }:
+with lib;
+let
+ cfg = config.services.xserver.imwheel;
+in
+ {
+ options = {
+ services.xserver.imwheel = {
+ enable = mkEnableOption "IMWheel service";
+
+ extraOptions = mkOption {
+ type = types.listOf types.str;
+ default = [ "--buttons=45" ];
+ example = [ "--debug" ];
+ description = ''
+ Additional command-line arguments to pass to
+ <command>imwheel</command>.
+ '';
+ };
+
+ rules = mkOption {
+ type = types.attrsOf types.str;
+ default = {};
+ example = literalExample ''
+ ".*" = '''
+ None, Up, Button4, 8
+ None, Down, Button5, 8
+ Shift_L, Up, Shift_L|Button4, 4
+ Shift_L, Down, Shift_L|Button5, 4
+ Control_L, Up, Control_L|Button4
+ Control_L, Down, Control_L|Button5
+ ''';
+ '';
+ description = ''
+ Window class translation rules.
+ /etc/X11/imwheelrc is generated based on this config
+ which means this config is global for all users.
+ See <link xlink:href="http://imwheel.sourceforge.net/imwheel.1.html">offical man pages</link>
+ for more informations.
+ '';
+ };
+ };
+ };
+
+ config = mkIf cfg.enable {
+ environment.systemPackages = [ pkgs.imwheel ];
+
+ environment.etc."X11/imwheel/imwheelrc".source =
+ pkgs.writeText "imwheelrc" (concatStringsSep "\n\n"
+ (mapAttrsToList
+ (rule: conf: "\"${rule}\"\n${conf}") cfg.rules
+ ));
+
+ systemd.user.services.imwheel = {
+ description = "imwheel service";
+ wantedBy = [ "graphical-session.target" ];
+ partOf = [ "graphical-session.target" ];
+ serviceConfig = {
+ ExecStart = "${pkgs.imwheel}/bin/imwheel " + escapeShellArgs ([
+ "--detach"
+ "--kill"
+ ] ++ cfg.extraOptions);
+ ExecStop = "${pkgs.procps}/bin/pkill imwheel";
+ Restart = "on-failure";
+ };
+ };
+ };
+ }
diff --git a/nixpkgs/nixos/modules/services/x11/compton.nix b/nixpkgs/nixos/modules/services/x11/picom.nix
index a94a76ff0c0..e3bd21be73e 100644
--- a/nixpkgs/nixos/modules/services/x11/compton.nix
+++ b/nixpkgs/nixos/modules/services/x11/picom.nix
@@ -5,7 +5,7 @@ with builtins;
let
- cfg = config.services.compton;
+ cfg = config.services.picom;
pairOf = x: with types; addCheck (listOf x) (y: length y == 2);
@@ -31,20 +31,24 @@ let
(key: value: "${toString key}=${mkValueString value};")
v)
+ " }"
- else abort "compton.mkValueString: unexpected type (v = ${v})";
+ else abort "picom.mkValueString: unexpected type (v = ${v})";
in "${escape [ sep ] k}${sep}${mkValueString v};")
attrs);
- configFile = pkgs.writeText "compton.conf" (toConf cfg.settings);
+ configFile = pkgs.writeText "picom.conf" (toConf cfg.settings);
in {
- options.services.compton = {
+ imports = [
+ (mkAliasOptionModule [ "services" "compton" ] [ "services" "picom" ])
+ ];
+
+ options.services.picom = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
- Whether of not to enable Compton as the X.org composite manager.
+ Whether of not to enable Picom as the X.org composite manager.
'';
};
@@ -85,7 +89,7 @@ in {
];
description = ''
List of conditions of windows that should not be faded.
- See <literal>compton(1)</literal> man page for more examples.
+ See <literal>picom(1)</literal> man page for more examples.
'';
};
@@ -125,7 +129,7 @@ in {
];
description = ''
List of conditions of windows that should have no shadow.
- See <literal>compton(1)</literal> man page for more examples.
+ See <literal>picom(1)</literal> man page for more examples.
'';
};
@@ -192,7 +196,7 @@ in {
apply = x:
let
res = x != "none";
- msg = "The type of services.compton.vSync has changed to bool:"
+ msg = "The type of services.picom.vSync has changed to bool:"
+ " interpreting ${x} as ${boolToString res}";
in
if isBool x then x
@@ -222,13 +226,13 @@ in {
type = loaOf (types.either configTypes (loaOf (types.either configTypes (loaOf configTypes))));
default = {};
description = ''
- Additional Compton configuration.
+ Additional Picom configuration.
'';
};
};
config = mkIf cfg.enable {
- services.compton.settings = let
+ services.picom.settings = let
# Hard conversion to float, literally lib.toInt but toFloat
toFloat = str: let
may_be_float = builtins.fromJSON str;
@@ -264,8 +268,8 @@ in {
refresh-rate = mkDefault cfg.refreshRate;
};
- systemd.user.services.compton = {
- description = "Compton composite manager";
+ systemd.user.services.picom = {
+ description = "Picom composite manager";
wantedBy = [ "graphical-session.target" ];
partOf = [ "graphical-session.target" ];
@@ -275,13 +279,15 @@ in {
};
serviceConfig = {
- ExecStart = "${pkgs.compton}/bin/compton --config ${configFile}";
+ ExecStart = "${pkgs.picom}/bin/picom --config ${configFile}";
RestartSec = 3;
Restart = "always";
};
};
- environment.systemPackages = [ pkgs.compton ];
+ environment.systemPackages = [ pkgs.picom ];
};
+ meta.maintainers = with lib.maintainers; [ rnhmjoj ];
+
}
diff --git a/nixpkgs/nixos/modules/services/x11/unclutter.nix b/nixpkgs/nixos/modules/services/x11/unclutter.nix
index 5f16a680050..2478aaabb79 100644
--- a/nixpkgs/nixos/modules/services/x11/unclutter.nix
+++ b/nixpkgs/nixos/modules/services/x11/unclutter.nix
@@ -71,4 +71,7 @@ in {
serviceConfig.Restart = "always";
};
};
+
+ meta.maintainers = with lib.maintainers; [ rnhmjoj ];
+
}
diff --git a/nixpkgs/nixos/modules/services/x11/urxvtd.nix b/nixpkgs/nixos/modules/services/x11/urxvtd.nix
index d916fa5bb39..9bfcfa9b065 100644
--- a/nixpkgs/nixos/modules/services/x11/urxvtd.nix
+++ b/nixpkgs/nixos/modules/services/x11/urxvtd.nix
@@ -45,4 +45,6 @@ in {
environment.variables.RXVT_SOCKET = "/run/user/$(id -u)/urxvtd-socket";
};
+ meta.maintainers = with lib.maintainers; [ rnhmjoj ];
+
}
diff --git a/nixpkgs/nixos/modules/services/x11/window-managers/default.nix b/nixpkgs/nixos/modules/services/x11/window-managers/default.nix
index c17f3830d0e..04a9fc46628 100644
--- a/nixpkgs/nixos/modules/services/x11/window-managers/default.nix
+++ b/nixpkgs/nixos/modules/services/x11/window-managers/default.nix
@@ -59,15 +59,14 @@ in
};
default = mkOption {
- type = types.str;
- default = "none";
+ type = types.nullOr types.str;
+ default = null;
example = "wmii";
- description = "Default window manager loaded if none have been chosen.";
- apply = defaultWM:
- if any (w: w.name == defaultWM) cfg.session then
- defaultWM
- else
- throw "Default window manager (${defaultWM}) not found.";
+ description = ''
+ <emphasis role="strong">Deprecated</emphasis>, please use <xref linkend="opt-services.xserver.displayManager.defaultSession"/> instead.
+
+ Default window manager loaded if none have been chosen.
+ '';
};
};
diff --git a/nixpkgs/nixos/modules/services/x11/xserver.nix b/nixpkgs/nixos/modules/services/x11/xserver.nix
index 70f01dbdbf5..7029919170a 100644
--- a/nixpkgs/nixos/modules/services/x11/xserver.nix
+++ b/nixpkgs/nixos/modules/services/x11/xserver.nix
@@ -149,6 +149,8 @@ in
[ ./display-managers/default.nix
./window-managers/default.nix
./desktop-managers/default.nix
+ (mkRemovedOptionModule [ "services" "xserver" "startGnuPGAgent" ]
+ "See the 16.09 release notes for more information.")
];
@@ -329,9 +331,9 @@ in
};
xkbOptions = mkOption {
- type = types.str;
+ type = types.commas;
default = "terminate:ctrl_alt_bksp";
- example = "grp:caps_toggle, grp_led:scroll";
+ example = "grp:caps_toggle,grp_led:scroll";
description = ''
X keyboard options; layout switching goes here.
'';
@@ -588,19 +590,15 @@ in
];
environment.etc =
- (optionals cfg.exportConfiguration
- [ { source = "${configFile}";
- target = "X11/xorg.conf";
- }
+ (optionalAttrs cfg.exportConfiguration
+ {
+ "X11/xorg.conf".source = "${configFile}";
# -xkbdir command line option does not seems to be passed to xkbcomp.
- { source = "${cfg.xkbDir}";
- target = "X11/xkb";
- }
- ])
+ "X11/xkb".source = "${cfg.xkbDir}";
+ })
# localectl looks into 00-keyboard.conf
- ++ [
- {
- text = ''
+ //{
+ "X11/xorg.conf.d/00-keyboard.conf".text = ''
Section "InputClass"
Identifier "Keyboard catchall"
MatchIsKeyboard "on"
@@ -610,16 +608,12 @@ in
Option "XkbVariant" "${cfg.xkbVariant}"
EndSection
'';
- target = "X11/xorg.conf.d/00-keyboard.conf";
}
- ]
# Needed since 1.18; see https://bugs.freedesktop.org/show_bug.cgi?id=89023#c5
- ++ (let cfgPath = "/X11/xorg.conf.d/10-evdev.conf"; in
- [{
- source = xorg.xf86inputevdev.out + "/share" + cfgPath;
- target = cfgPath;
- }]
- );
+ // (let cfgPath = "/X11/xorg.conf.d/10-evdev.conf"; in
+ {
+ ${cfgPath}.source = xorg.xf86inputevdev.out + "/share" + cfgPath;
+ });
environment.systemPackages =
[ xorg.xorgserver.out
diff --git a/nixpkgs/nixos/modules/system/activation/switch-to-configuration.pl b/nixpkgs/nixos/modules/system/activation/switch-to-configuration.pl
index 12a80a12d19..641cf9faadc 100644
--- a/nixpkgs/nixos/modules/system/activation/switch-to-configuration.pl
+++ b/nixpkgs/nixos/modules/system/activation/switch-to-configuration.pl
@@ -214,17 +214,7 @@ while (my ($unit, $state) = each %{$activePrev}) {
# Reload the changed mount unit to force a remount.
$unitsToReload{$unit} = 1;
recordUnit($reloadListFile, $unit);
- } elsif ($unit =~ /\.socket$/) {
- my $unitInfo = parseUnit($newUnitFile);
- # If a socket unit has been changed, the corresponding
- # service unit has to be stopped before the socket can
- # be restarted. The service will be started again on demand.
- my $serviceUnit = $unitInfo->{'Unit'} // "$baseName.service";
- $unitsToStop{$serviceUnit} = 1;
- $unitsToStop{$unit} = 1;
- $unitsToStart{$unit} = 1;
- recordUnit($startListFile, $unit);
- } elsif ($unit =~ /\.path$/ || $unit =~ /\.slice$/) {
+ } elsif ($unit =~ /\.socket$/ || $unit =~ /\.path$/ || $unit =~ /\.slice$/) {
# FIXME: do something?
} else {
my $unitInfo = parseUnit($newUnitFile);
diff --git a/nixpkgs/nixos/modules/system/boot/binfmt.nix b/nixpkgs/nixos/modules/system/boot/binfmt.nix
index a32c9dc1f2b..a677ab4cb71 100644
--- a/nixpkgs/nixos/modules/system/boot/binfmt.nix
+++ b/nixpkgs/nixos/modules/system/boot/binfmt.nix
@@ -134,6 +134,10 @@ let
};
in {
+ imports = [
+ (lib.mkRenamedOptionModule [ "boot" "binfmtMiscRegistrations" ] [ "boot" "binfmt" "registrations" ])
+ ];
+
options = {
boot.binfmt = {
registrations = mkOption {
diff --git a/nixpkgs/nixos/modules/system/boot/grow-partition.nix b/nixpkgs/nixos/modules/system/boot/grow-partition.nix
index 8c9b1502558..71a86c74772 100644
--- a/nixpkgs/nixos/modules/system/boot/grow-partition.nix
+++ b/nixpkgs/nixos/modules/system/boot/grow-partition.nix
@@ -7,6 +7,9 @@
with lib;
{
+ imports = [
+ (mkRenamedOptionModule [ "virtualisation" "growPartition" ] [ "boot" "growPartition" ])
+ ];
options = {
boot.growPartition = mkEnableOption "grow the root partition on boot";
diff --git a/nixpkgs/nixos/modules/system/boot/kernel.nix b/nixpkgs/nixos/modules/system/boot/kernel.nix
index 8a309f3bc5f..6edb9082e75 100644
--- a/nixpkgs/nixos/modules/system/boot/kernel.nix
+++ b/nixpkgs/nixos/modules/system/boot/kernel.nix
@@ -256,9 +256,8 @@ in
# Create /etc/modules-load.d/nixos.conf, which is read by
# systemd-modules-load.service to load required kernel modules.
- environment.etc = singleton
- { target = "modules-load.d/nixos.conf";
- source = kernelModulesConf;
+ environment.etc =
+ { "modules-load.d/nixos.conf".source = kernelModulesConf;
};
systemd.services.systemd-modules-load =
diff --git a/nixpkgs/nixos/modules/system/boot/loader/loader.nix b/nixpkgs/nixos/modules/system/boot/loader/loader.nix
index 7fbda9ef0f5..01475f79b9c 100644
--- a/nixpkgs/nixos/modules/system/boot/loader/loader.nix
+++ b/nixpkgs/nixos/modules/system/boot/loader/loader.nix
@@ -3,6 +3,11 @@
with lib;
{
+ imports = [
+ (mkRenamedOptionModule [ "boot" "loader" "grub" "timeout" ] [ "boot" "loader" "timeout" ])
+ (mkRenamedOptionModule [ "boot" "loader" "gummiboot" "timeout" ] [ "boot" "loader" "timeout" ])
+ ];
+
options = {
boot.loader.timeout = mkOption {
default = 5;
@@ -12,4 +17,4 @@ with lib;
'';
};
};
-} \ No newline at end of file
+}
diff --git a/nixpkgs/nixos/modules/system/boot/luksroot.nix b/nixpkgs/nixos/modules/system/boot/luksroot.nix
index a4029d766b0..0bb8396a44f 100644
--- a/nixpkgs/nixos/modules/system/boot/luksroot.nix
+++ b/nixpkgs/nixos/modules/system/boot/luksroot.nix
@@ -126,7 +126,7 @@ let
gpg-agent --daemon --scdaemon-program $out/bin/scdaemon > /dev/null 2> /dev/null
''}
-
+
# Disable all input echo for the whole stage. We could use read -s
# instead but that would ocasionally leak characters between read
# invocations.
@@ -417,6 +417,9 @@ let
in
{
+ imports = [
+ (mkRemovedOptionModule [ "boot" "initrd" "luks" "enable" ] "")
+ ];
options = {
diff --git a/nixpkgs/nixos/modules/system/boot/networkd.nix b/nixpkgs/nixos/modules/system/boot/networkd.nix
index 226769f1059..3e289a63139 100644
--- a/nixpkgs/nixos/modules/system/boot/networkd.nix
+++ b/nixpkgs/nixos/modules/system/boot/networkd.nix
@@ -11,7 +11,7 @@ let
checkLink = checkUnitConfig "Link" [
(assertOnlyFields [
"Description" "Alias" "MACAddressPolicy" "MACAddress" "NamePolicy" "Name" "OriginalName"
- "MTUBytes" "BitsPerSecond" "Duplex" "AutoNegotiation" "WakeOnLan" "Port"
+ "MTUBytes" "BitsPerSecond" "Duplex" "AutoNegotiation" "WakeOnLan" "Port" "Advertise"
"TCPSegmentationOffload" "TCP6SegmentationOffload" "GenericSegmentationOffload"
"GenericReceiveOffload" "LargeReceiveOffload" "RxChannels" "TxChannels"
"OtherChannels" "CombinedChannels"
@@ -276,7 +276,7 @@ let
(assertValueOneOf "ARP" boolValues)
(assertValueOneOf "Multicast" boolValues)
(assertValueOneOf "Unmanaged" boolValues)
- (assertValueOneOf "RequiredForOnline" boolValues)
+ (assertValueOneOf "RequiredForOnline" (boolValues ++ ["off" "no-carrier" "dormant" "degraded-carrier" "carrier" "degraded" "enslaved" "routable"]))
];
@@ -872,10 +872,10 @@ let
'';
};
- unitFiles = map (name: {
- target = "systemd/network/${name}";
- source = "${cfg.units.${name}.unit}/${name}";
- }) (attrNames cfg.units);
+ unitFiles = listToAttrs (map (name: {
+ name = "systemd/network/${name}";
+ value.source = "${cfg.units.${name}.unit}/${name}";
+ }) (attrNames cfg.units));
in
{
@@ -938,7 +938,7 @@ in
systemd.services.systemd-networkd = {
wantedBy = [ "multi-user.target" ];
- restartTriggers = map (f: f.source) (unitFiles);
+ restartTriggers = attrNames unitFiles;
# prevent race condition with interface renaming (#39069)
requires = [ "systemd-udev-settle.service" ];
after = [ "systemd-udev-settle.service" ];
diff --git a/nixpkgs/nixos/modules/system/boot/systemd-nspawn.nix b/nixpkgs/nixos/modules/system/boot/systemd-nspawn.nix
index 3ddd45b1348..1e2435e36f0 100644
--- a/nixpkgs/nixos/modules/system/boot/systemd-nspawn.nix
+++ b/nixpkgs/nixos/modules/system/boot/systemd-nspawn.nix
@@ -126,7 +126,7 @@ in {
systemd.services."systemd-nspawn@".serviceConfig.ExecStart = [
"" # deliberately empty. signals systemd to override the ExecStart
# Only difference between upstream is that we do not pass the -U flag
- "${pkgs.systemd}/bin/systemd-nspawn --quiet --keep-unit --boot --link-journal=try-guest --network-veth --settings=override --machine=%i"
+ "${config.systemd.package}/bin/systemd-nspawn --quiet --keep-unit --boot --link-journal=try-guest --network-veth --settings=override --machine=%i"
];
}
];
diff --git a/nixpkgs/nixos/modules/system/boot/systemd.nix b/nixpkgs/nixos/modules/system/boot/systemd.nix
index 9e3c6149f92..c438bb216e7 100644
--- a/nixpkgs/nixos/modules/system/boot/systemd.nix
+++ b/nixpkgs/nixos/modules/system/boot/systemd.nix
@@ -240,7 +240,7 @@ let
serviceConfig = { name, config, ... }: {
config = mkMerge
[ { # Default path for systemd services. Should be quite minimal.
- path =
+ path = mkAfter
[ pkgs.coreutils
pkgs.findutils
pkgs.gnugrep
@@ -408,7 +408,6 @@ let
in
{
-
###### interface
options = {
@@ -1006,5 +1005,7 @@ in
[ (mkRenamedOptionModule [ "boot" "systemd" "sockets" ] [ "systemd" "sockets" ])
(mkRenamedOptionModule [ "boot" "systemd" "targets" ] [ "systemd" "targets" ])
(mkRenamedOptionModule [ "boot" "systemd" "services" ] [ "systemd" "services" ])
+ (mkRenamedOptionModule [ "jobs" ] [ "systemd" "services" ])
+ (mkRemovedOptionModule [ "systemd" "generator-packages" ] "Use systemd.packages instead.")
];
}
diff --git a/nixpkgs/nixos/modules/tasks/filesystems/nfs.nix b/nixpkgs/nixos/modules/tasks/filesystems/nfs.nix
index e0e8bb1f03d..ddcc0ed8f5a 100644
--- a/nixpkgs/nixos/modules/tasks/filesystems/nfs.nix
+++ b/nixpkgs/nixos/modules/tasks/filesystems/nfs.nix
@@ -25,6 +25,9 @@ let
'';
nfsConfFile = pkgs.writeText "nfs.conf" cfg.extraConfig;
+ requestKeyConfFile = pkgs.writeText "request-key.conf" ''
+ create id_resolver * * ${pkgs.nfs-utils}/bin/nfsidmap -t 600 %k %d
+ '';
cfg = config.services.nfs;
@@ -57,9 +60,12 @@ in
systemd.packages = [ pkgs.nfs-utils ];
+ environment.systemPackages = [ pkgs.keyutils ];
+
environment.etc = {
"idmapd.conf".source = idmapdConfFile;
"nfs.conf".source = nfsConfFile;
+ "request-key.conf".source = requestKeyConfFile;
};
systemd.services.nfs-blkmap =
diff --git a/nixpkgs/nixos/modules/tasks/filesystems/zfs.nix b/nixpkgs/nixos/modules/tasks/filesystems/zfs.nix
index fe11917c609..d14ba98ec48 100644
--- a/nixpkgs/nixos/modules/tasks/filesystems/zfs.nix
+++ b/nixpkgs/nixos/modules/tasks/filesystems/zfs.nix
@@ -12,6 +12,7 @@ let
cfgSnapFlags = cfgSnapshots.flags;
cfgScrub = config.services.zfs.autoScrub;
cfgTrim = config.services.zfs.trim;
+ cfgZED = config.services.zfs.zed;
inInitrd = any (fs: fs == "zfs") config.boot.initrd.supportedFilesystems;
inSystem = any (fs: fs == "zfs") config.boot.supportedFilesystems;
@@ -87,10 +88,25 @@ let
}
'';
+ zedConf = generators.toKeyValue {
+ mkKeyValue = generators.mkKeyValueDefault {
+ mkValueString = v:
+ if isInt v then toString v
+ else if isString v then "\"${v}\""
+ else if true == v then "1"
+ else if false == v then "0"
+ else if isList v then "\"" + (concatStringsSep " " v) + "\""
+ else err "this value is" (toString v);
+ } "=";
+ } cfgZED.settings;
in
{
+ imports = [
+ (mkRemovedOptionModule [ "boot" "zfs" "enableLegacyCrypto" ] "The corresponding package was removed from nixpkgs.")
+ ];
+
###### interface
options = {
@@ -312,6 +328,32 @@ in
'';
};
};
+
+ services.zfs.zed.settings = mkOption {
+ type = with types; attrsOf (oneOf [ str int bool (listOf str) ]);
+ example = literalExample ''
+ {
+ ZED_DEBUG_LOG = "/tmp/zed.debug.log";
+
+ ZED_EMAIL_ADDR = [ "root" ];
+ ZED_EMAIL_PROG = "mail";
+ ZED_EMAIL_OPTS = "-s '@SUBJECT@' @ADDRESS@";
+
+ ZED_NOTIFY_INTERVAL_SECS = 3600;
+ ZED_NOTIFY_VERBOSE = false;
+
+ ZED_USE_ENCLOSURE_LEDS = true;
+ ZED_SCRUB_AFTER_RESILVER = false;
+ }
+ '';
+ description = ''
+ ZFS Event Daemon /etc/zfs/zed.d/zed.rc content
+
+ See
+ <citerefentry><refentrytitle>zed</refentrytitle><manvolnum>8</manvolnum></citerefentry>
+ for details on ZED and the scripts in /etc/zfs/zed.d to find the possible variables
+ '';
+ };
};
###### implementation
@@ -389,8 +431,32 @@ in
zfsSupport = true;
};
- environment.etc."zfs/zed.d".source = "${packages.zfsUser}/etc/zfs/zed.d/";
- environment.etc."zfs/zpool.d".source = "${packages.zfsUser}/etc/zfs/zpool.d/";
+ services.zfs.zed.settings = {
+ ZED_EMAIL_PROG = mkDefault "${pkgs.mailutils}/bin/mail";
+ };
+
+ environment.etc = genAttrs
+ (map
+ (file: "zfs/zed.d/${file}")
+ [
+ "all-syslog.sh"
+ "pool_import-led.sh"
+ "resilver_finish-start-scrub.sh"
+ "statechange-led.sh"
+ "vdev_attach-led.sh"
+ "zed-functions.sh"
+ "data-notify.sh"
+ "resilver_finish-notify.sh"
+ "scrub_finish-notify.sh"
+ "statechange-notify.sh"
+ "vdev_clear-led.sh"
+ ]
+ )
+ (file: { source = "${packages.zfsUser}/etc/${file}"; })
+ // {
+ "zfs/zed.d/zed.rc".text = zedConf;
+ "zfs/zpool.d".source = "${packages.zfsUser}/etc/zfs/zpool.d/";
+ };
system.fsPackages = [ packages.zfsUser ]; # XXX: needed? zfs doesn't have (need) a fsck
environment.systemPackages = [ packages.zfsUser ]
diff --git a/nixpkgs/nixos/modules/tasks/kbd.nix b/nixpkgs/nixos/modules/tasks/kbd.nix
deleted file mode 100644
index c6ba998b19e..00000000000
--- a/nixpkgs/nixos/modules/tasks/kbd.nix
+++ /dev/null
@@ -1,127 +0,0 @@
-{ config, lib, pkgs, ... }:
-
-with lib;
-
-let
-
- makeColor = n: value: "COLOR_${toString n}=${value}";
- makeColorCS =
- let positions = [ "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F" ];
- in n: value: "\\033]P${elemAt positions (n - 1)}${value}";
- colors = concatImapStringsSep "\n" makeColor config.i18n.consoleColors;
-
- isUnicode = hasSuffix "UTF-8" (toUpper config.i18n.defaultLocale);
-
- optimizedKeymap = pkgs.runCommand "keymap" {
- nativeBuildInputs = [ pkgs.buildPackages.kbd ];
- LOADKEYS_KEYMAP_PATH = "${kbdEnv}/share/keymaps/**";
- preferLocalBuild = true;
- } ''
- loadkeys -b ${optionalString isUnicode "-u"} "${config.i18n.consoleKeyMap}" > $out
- '';
-
- # Sadly, systemd-vconsole-setup doesn't support binary keymaps.
- vconsoleConf = pkgs.writeText "vconsole.conf" ''
- KEYMAP=${config.i18n.consoleKeyMap}
- FONT=${config.i18n.consoleFont}
- ${colors}
- '';
-
- kbdEnv = pkgs.buildEnv {
- name = "kbd-env";
- paths = [ pkgs.kbd ] ++ config.i18n.consolePackages;
- pathsToLink = [ "/share/consolefonts" "/share/consoletrans" "/share/keymaps" "/share/unimaps" ];
- };
-
- setVconsole = !config.boot.isContainer;
-in
-
-{
- ###### interface
-
- options = {
-
- # most options are defined in i18n.nix
-
- # FIXME: still needed?
- boot.extraTTYs = mkOption {
- default = [];
- type = types.listOf types.str;
- example = ["tty8" "tty9"];
- description = ''
- Tty (virtual console) devices, in addition to the consoles on
- which mingetty and syslogd run, that must be initialised.
- Only useful if you have some program that you want to run on
- some fixed console. For example, the NixOS installation CD
- opens the manual in a web browser on console 7, so it sets
- <option>boot.extraTTYs</option> to <literal>["tty7"]</literal>.
- '';
- };
-
- boot.earlyVconsoleSetup = mkOption {
- default = false;
- type = types.bool;
- description = ''
- Enable setting font as early as possible (in initrd).
- '';
- };
-
- };
-
-
- ###### implementation
-
- config = mkMerge [
- (mkIf (!setVconsole) {
- systemd.services.systemd-vconsole-setup.enable = false;
- })
-
- (mkIf setVconsole (mkMerge [
- { environment.systemPackages = [ pkgs.kbd ];
-
- # Let systemd-vconsole-setup.service do the work of setting up the
- # virtual consoles.
- environment.etc."vconsole.conf".source = vconsoleConf;
- # Provide kbd with additional packages.
- environment.etc.kbd.source = "${kbdEnv}/share";
-
- boot.initrd.preLVMCommands = mkBefore ''
- kbd_mode ${if isUnicode then "-u" else "-a"} -C /dev/console
- printf "\033%%${if isUnicode then "G" else "@"}" >> /dev/console
- loadkmap < ${optimizedKeymap}
-
- ${optionalString config.boot.earlyVconsoleSetup ''
- setfont -C /dev/console $extraUtils/share/consolefonts/font.psf
- ''}
-
- ${concatImapStringsSep "\n" (n: color: ''
- printf "${makeColorCS n color}" >> /dev/console
- '') config.i18n.consoleColors}
- '';
-
- systemd.services.systemd-vconsole-setup =
- { before = [ "display-manager.service" ];
- after = [ "systemd-udev-settle.service" ];
- restartTriggers = [ vconsoleConf kbdEnv ];
- };
- }
-
- (mkIf config.boot.earlyVconsoleSetup {
- boot.initrd.extraUtilsCommands = ''
- mkdir -p $out/share/consolefonts
- ${if substring 0 1 config.i18n.consoleFont == "/" then ''
- font="${config.i18n.consoleFont}"
- '' else ''
- font="$(echo ${kbdEnv}/share/consolefonts/${config.i18n.consoleFont}.*)"
- ''}
- if [[ $font == *.gz ]]; then
- gzip -cd $font > $out/share/consolefonts/font.psf
- else
- cp -L $font $out/share/consolefonts/font.psf
- fi
- '';
- })
- ]))
- ];
-
-}
diff --git a/nixpkgs/nixos/modules/tasks/network-interfaces-systemd.nix b/nixpkgs/nixos/modules/tasks/network-interfaces-systemd.nix
index 9ffa1089ee6..e25dc0c0b39 100644
--- a/nixpkgs/nixos/modules/tasks/network-interfaces-systemd.nix
+++ b/nixpkgs/nixos/modules/tasks/network-interfaces-systemd.nix
@@ -60,8 +60,8 @@ in
let
domains = cfg.search ++ (optional (cfg.domain != null) cfg.domain);
genericNetwork = override:
- let gateway = optional (cfg.defaultGateway != null) cfg.defaultGateway.address
- ++ optional (cfg.defaultGateway6 != null) cfg.defaultGateway6.address;
+ let gateway = optional (cfg.defaultGateway != null && (cfg.defaultGateway.address or "") != "") cfg.defaultGateway.address
+ ++ optional (cfg.defaultGateway6 != null && (cfg.defaultGateway6.address or "") != "") cfg.defaultGateway6.address;
in optionalAttrs (gateway != [ ]) {
routes = override [
{
diff --git a/nixpkgs/nixos/modules/virtualisation/container-config.nix b/nixpkgs/nixos/modules/virtualisation/container-config.nix
index f7a37d8c9f3..6ff6bdd30c2 100644
--- a/nixpkgs/nixos/modules/virtualisation/container-config.nix
+++ b/nixpkgs/nixos/modules/virtualisation/container-config.nix
@@ -10,6 +10,7 @@ with lib;
nix.optimise.automatic = mkDefault false; # the store is host managed
services.udisks2.enable = mkDefault false;
powerManagement.enable = mkDefault false;
+ documentation.nixos.enable = mkDefault false;
networking.useHostResolvConf = mkDefault true;
diff --git a/nixpkgs/nixos/modules/virtualisation/containers.nix b/nixpkgs/nixos/modules/virtualisation/containers.nix
index 09678ce9ea7..02de5801da2 100644
--- a/nixpkgs/nixos/modules/virtualisation/containers.nix
+++ b/nixpkgs/nixos/modules/virtualisation/containers.nix
@@ -225,12 +225,6 @@ let
fi
${concatStringsSep "\n" (mapAttrsToList renderExtraVeth cfg.extraVeths)}
fi
-
- # Get the leader PID so that we can signal it in
- # preStop. We can't use machinectl there because D-Bus
- # might be shutting down. FIXME: in systemd 219 we can
- # just signal systemd-nspawn to do a clean shutdown.
- machinectl show "$INSTANCE" | sed 's/Leader=\(.*\)/\1/;t;d' > "/run/containers/$INSTANCE.pid"
''
);
@@ -715,14 +709,7 @@ in
postStart = postStartScript dummyConfig;
- preStop =
- ''
- pid="$(cat /run/containers/$INSTANCE.pid)"
- if [ -n "$pid" ]; then
- kill -RTMIN+4 "$pid"
- fi
- rm -f "/run/containers/$INSTANCE.pid"
- '';
+ preStop = "machinectl poweroff $INSTANCE";
restartIfChanged = false;
diff --git a/nixpkgs/nixos/modules/virtualisation/docker-containers.nix b/nixpkgs/nixos/modules/virtualisation/docker-containers.nix
index 59b0943f591..760cb9122a2 100644
--- a/nixpkgs/nixos/modules/virtualisation/docker-containers.nix
+++ b/nixpkgs/nixos/modules/virtualisation/docker-containers.nix
@@ -186,7 +186,7 @@ let
++ map escapeShellArg container.cmd
);
ExecStartPre = "-${pkgs.docker}/bin/docker rm -f %n";
- ExecStop = "${pkgs.docker}/bin/docker stop %n";
+ ExecStop = ''${pkgs.bash}/bin/sh -c "[ $SERVICE_RESULT = success ] || ${pkgs.docker}/bin/docker stop %n"'';
ExecStopPost = "-${pkgs.docker}/bin/docker rm -f %n";
### There is no generalized way of supporting `reload` for docker
diff --git a/nixpkgs/nixos/modules/virtualisation/ec2-data.nix b/nixpkgs/nixos/modules/virtualisation/ec2-data.nix
index 82451787e8a..62912535018 100644
--- a/nixpkgs/nixos/modules/virtualisation/ec2-data.nix
+++ b/nixpkgs/nixos/modules/virtualisation/ec2-data.nix
@@ -7,6 +7,10 @@
with lib;
{
+ imports = [
+ (mkRemovedOptionModule [ "ec2" "metadata" ] "")
+ ];
+
config = {
systemd.services.apply-ec2-data =
diff --git a/nixpkgs/nixos/modules/virtualisation/libvirtd.nix b/nixpkgs/nixos/modules/virtualisation/libvirtd.nix
index 9bdea78296f..52d852894ce 100644
--- a/nixpkgs/nixos/modules/virtualisation/libvirtd.nix
+++ b/nixpkgs/nixos/modules/virtualisation/libvirtd.nix
@@ -28,6 +28,11 @@ let
in {
+ imports = [
+ (mkRemovedOptionModule [ "virtualisation" "libvirtd" "enableKVM" ]
+ "Set the option `virtualisation.libvirtd.qemuPackage' instead.")
+ ];
+
###### interface
options.virtualisation.libvirtd = {
diff --git a/nixpkgs/nixos/modules/virtualisation/lxc.nix b/nixpkgs/nixos/modules/virtualisation/lxc.nix
index 9b5adaf0824..f484d5ee59a 100644
--- a/nixpkgs/nixos/modules/virtualisation/lxc.nix
+++ b/nixpkgs/nixos/modules/virtualisation/lxc.nix
@@ -58,7 +58,7 @@ in
''
This is the config file for managing unprivileged user network
administration access in LXC. See <citerefentry>
- <refentrytitle>lxc-user-net</refentrytitle><manvolnum>5</manvolnum>
+ <refentrytitle>lxc-usernet</refentrytitle><manvolnum>5</manvolnum>
</citerefentry>.
'';
};
diff --git a/nixpkgs/nixos/modules/virtualisation/lxd.nix b/nixpkgs/nixos/modules/virtualisation/lxd.nix
index 505c11abd20..b4934a86cf5 100644
--- a/nixpkgs/nixos/modules/virtualisation/lxd.nix
+++ b/nixpkgs/nixos/modules/virtualisation/lxd.nix
@@ -35,6 +35,18 @@ in
with nixos.
'';
};
+ recommendedSysctlSettings = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ enables various settings to avoid common pitfalls when
+ running containers requiring many file operations.
+ Fixes errors like "Too many open files" or
+ "neighbour: ndisc_cache: neighbor table overflow!".
+ See https://lxd.readthedocs.io/en/latest/production-setup/
+ for details.
+ '';
+ };
};
};
@@ -69,8 +81,11 @@ in
ExecStart = "@${pkgs.lxd.bin}/bin/lxd lxd --group lxd";
Type = "simple";
KillMode = "process"; # when stopping, leave the containers alone
+ LimitMEMLOCK = "infinity";
+ LimitNOFILE = "1048576";
+ LimitNPROC = "infinity";
+ TasksMax = "infinity";
};
-
};
users.groups.lxd.gid = config.ids.gids.lxd;
@@ -79,5 +94,16 @@ in
subUidRanges = [ { startUid = 1000000; count = 65536; } ];
subGidRanges = [ { startGid = 1000000; count = 65536; } ];
};
+
+ boot.kernel.sysctl = mkIf cfg.recommendedSysctlSettings {
+ "fs.inotify.max_queued_events" = 1048576;
+ "fs.inotify.max_user_instances" = 1048576;
+ "fs.inotify.max_user_watches" = 1048576;
+ "vm.max_map_count" = 262144;
+ "kernel.dmesg_restrict" = 1;
+ "net.ipv4.neigh.default.gc_thresh3" = 8192;
+ "net.ipv6.neigh.default.gc_thresh3" = 8192;
+ "kernel.keys.maxkeys" = 2000;
+ };
};
}
diff --git a/nixpkgs/nixos/modules/virtualisation/vmware-guest.nix b/nixpkgs/nixos/modules/virtualisation/vmware-guest.nix
index f418f849759..962a9059ea4 100644
--- a/nixpkgs/nixos/modules/virtualisation/vmware-guest.nix
+++ b/nixpkgs/nixos/modules/virtualisation/vmware-guest.nix
@@ -8,6 +8,10 @@ let
xf86inputvmmouse = pkgs.xorg.xf86inputvmmouse;
in
{
+ imports = [
+ (mkRenamedOptionModule [ "services" "vmwareGuest" ] [ "virtualisation" "vmware" "guest" ])
+ ];
+
options.virtualisation.vmware.guest = {
enable = mkEnableOption "VMWare Guest Support";
headless = mkOption {
diff --git a/nixpkgs/nixos/modules/virtualisation/xen-dom0.nix b/nixpkgs/nixos/modules/virtualisation/xen-dom0.nix
index 06d5c63476f..7f0af9901b9 100644
--- a/nixpkgs/nixos/modules/virtualisation/xen-dom0.nix
+++ b/nixpkgs/nixos/modules/virtualisation/xen-dom0.nix
@@ -9,6 +9,11 @@ let
in
{
+ imports = [
+ (mkRemovedOptionModule [ "virtualisation" "xen" "qemu" ] "You don't need this option anymore, it will work without it.")
+ (mkRenamedOptionModule [ "virtualisation" "xen" "qemu-package" ] [ "virtualisation" "xen" "package-qemu" ])
+ ];
+
###### interface
options = {
@@ -228,26 +233,19 @@ in
environment.etc =
- [ { source = "${cfg.package}/etc/xen/xl.conf";
- target = "xen/xl.conf";
- }
- { source = "${cfg.package}/etc/xen/scripts";
- target = "xen/scripts";
- }
- { text = ''
- source ${cfg.package}/etc/default/xendomains
-
- ${cfg.domains.extraConfig}
- '';
- target = "default/xendomains";
- }
- ]
- ++ lib.optionals (builtins.compareVersions cfg.package.version "4.10" >= 0) [
+ {
+ "xen/xl.conf".source = "${cfg.package}/etc/xen/xl.conf";
+ "xen/scripts".source = "${cfg.package}/etc/xen/scripts";
+ "default/xendomains".text = ''
+ source ${cfg.package}/etc/default/xendomains
+
+ ${cfg.domains.extraConfig}
+ '';
+ }
+ // optionalAttrs (builtins.compareVersions cfg.package.version "4.10" >= 0) {
# in V 4.10 oxenstored requires /etc/xen/oxenstored.conf to start
- { source = "${cfg.package}/etc/xen/oxenstored.conf";
- target = "xen/oxenstored.conf";
- }
- ];
+ "xen/oxenstored.conf".source = "${cfg.package}/etc/xen/oxenstored.conf";
+ };
# Xen provides udev rules.
services.udev.packages = [ cfg.package ];
diff --git a/nixpkgs/nixos/release-combined.nix b/nixpkgs/nixos/release-combined.nix
index 678ce3c2880..ca9c6f9a7f9 100644
--- a/nixpkgs/nixos/release-combined.nix
+++ b/nixpkgs/nixos/release-combined.nix
@@ -120,8 +120,8 @@ in rec {
(all nixos.tests.networking.scripted.macvlan)
(all nixos.tests.networking.scripted.sit)
(all nixos.tests.networking.scripted.vlan)
- (all nixos.tests.nfs3)
- (all nixos.tests.nfs4)
+ (all nixos.tests.nfs3.simple)
+ (all nixos.tests.nfs4.simple)
(all nixos.tests.openssh)
(all nixos.tests.php-pcre)
(all nixos.tests.predictable-interface-names.predictable)
diff --git a/nixpkgs/nixos/tests/3proxy.nix b/nixpkgs/nixos/tests/3proxy.nix
new file mode 100644
index 00000000000..3e2061d7e42
--- /dev/null
+++ b/nixpkgs/nixos/tests/3proxy.nix
@@ -0,0 +1,185 @@
+import ./make-test-python.nix ({ pkgs, ...} : {
+ name = "3proxy";
+ meta = with pkgs.stdenv.lib.maintainers; {
+ maintainers = [ misuzu ];
+ };
+
+ nodes = {
+ peer0 = { lib, ... }: {
+ networking.useDHCP = false;
+ networking.interfaces.eth1 = {
+ ipv4.addresses = [
+ {
+ address = "192.168.0.1";
+ prefixLength = 24;
+ }
+ {
+ address = "216.58.211.111";
+ prefixLength = 24;
+ }
+ ];
+ };
+ };
+
+ peer1 = { lib, ... }: {
+ networking.useDHCP = false;
+ networking.interfaces.eth1 = {
+ ipv4.addresses = [
+ {
+ address = "192.168.0.2";
+ prefixLength = 24;
+ }
+ {
+ address = "216.58.211.112";
+ prefixLength = 24;
+ }
+ ];
+ };
+ # test that binding to [::] is working when ipv6 is disabled
+ networking.enableIPv6 = false;
+ services._3proxy = {
+ enable = true;
+ services = [
+ {
+ type = "admin";
+ bindPort = 9999;
+ auth = [ "none" ];
+ }
+ {
+ type = "proxy";
+ bindPort = 3128;
+ auth = [ "none" ];
+ }
+ ];
+ };
+ networking.firewall.allowedTCPPorts = [ 3128 9999 ];
+ };
+
+ peer2 = { lib, ... }: {
+ networking.useDHCP = false;
+ networking.interfaces.eth1 = {
+ ipv4.addresses = [
+ {
+ address = "192.168.0.3";
+ prefixLength = 24;
+ }
+ {
+ address = "216.58.211.113";
+ prefixLength = 24;
+ }
+ ];
+ };
+ services._3proxy = {
+ enable = true;
+ services = [
+ {
+ type = "admin";
+ bindPort = 9999;
+ auth = [ "none" ];
+ }
+ {
+ type = "proxy";
+ bindPort = 3128;
+ auth = [ "iponly" ];
+ acl = [
+ {
+ rule = "allow";
+ }
+ ];
+ }
+ ];
+ };
+ networking.firewall.allowedTCPPorts = [ 3128 9999 ];
+ };
+
+ peer3 = { lib, ... }: {
+ networking.useDHCP = false;
+ networking.interfaces.eth1 = {
+ ipv4.addresses = [
+ {
+ address = "192.168.0.4";
+ prefixLength = 24;
+ }
+ {
+ address = "216.58.211.114";
+ prefixLength = 24;
+ }
+ ];
+ };
+ services._3proxy = {
+ enable = true;
+ usersFile = pkgs.writeText "3proxy.passwd" ''
+ admin:CR:$1$.GUV4Wvk$WnEVQtaqutD9.beO5ar1W/
+ '';
+ services = [
+ {
+ type = "admin";
+ bindPort = 9999;
+ auth = [ "none" ];
+ }
+ {
+ type = "proxy";
+ bindPort = 3128;
+ auth = [ "strong" ];
+ acl = [
+ {
+ rule = "allow";
+ }
+ ];
+ }
+ ];
+ };
+ networking.firewall.allowedTCPPorts = [ 3128 9999 ];
+ };
+ };
+
+ testScript = ''
+ peer1.wait_for_unit("3proxy.service")
+ peer1.wait_for_open_port("9999")
+
+ # test none auth
+ peer0.succeed(
+ "${pkgs.wget}/bin/wget -e use_proxy=yes -e http_proxy=http://192.168.0.2:3128 -S -O /dev/null http://216.58.211.112:9999"
+ )
+ peer0.succeed(
+ "${pkgs.wget}/bin/wget -e use_proxy=yes -e http_proxy=http://192.168.0.2:3128 -S -O /dev/null http://192.168.0.2:9999"
+ )
+ peer0.succeed(
+ "${pkgs.wget}/bin/wget -e use_proxy=yes -e http_proxy=http://192.168.0.2:3128 -S -O /dev/null http://127.0.0.1:9999"
+ )
+
+ peer2.wait_for_unit("3proxy.service")
+ peer2.wait_for_open_port("9999")
+
+ # test iponly auth
+ peer0.succeed(
+ "${pkgs.wget}/bin/wget -e use_proxy=yes -e http_proxy=http://192.168.0.3:3128 -S -O /dev/null http://216.58.211.113:9999"
+ )
+ peer0.fail(
+ "${pkgs.wget}/bin/wget -e use_proxy=yes -e http_proxy=http://192.168.0.3:3128 -S -O /dev/null http://192.168.0.3:9999"
+ )
+ peer0.fail(
+ "${pkgs.wget}/bin/wget -e use_proxy=yes -e http_proxy=http://192.168.0.3:3128 -S -O /dev/null http://127.0.0.1:9999"
+ )
+
+ peer3.wait_for_unit("3proxy.service")
+ peer3.wait_for_open_port("9999")
+
+ # test strong auth
+ peer0.succeed(
+ "${pkgs.wget}/bin/wget -e use_proxy=yes -e http_proxy=http://admin:bigsecret\@192.168.0.4:3128 -S -O /dev/null http://216.58.211.114:9999"
+ )
+ peer0.fail(
+ "${pkgs.wget}/bin/wget -e use_proxy=yes -e http_proxy=http://admin:bigsecret\@192.168.0.4:3128 -S -O /dev/null http://192.168.0.4:9999"
+ )
+ peer0.fail(
+ "${pkgs.wget}/bin/wget -e use_proxy=yes -e http_proxy=http://192.168.0.4:3128 -S -O /dev/null http://216.58.211.114:9999"
+ )
+ peer0.fail(
+ "${pkgs.wget}/bin/wget -e use_proxy=yes -e http_proxy=http://192.168.0.4:3128 -S -O /dev/null http://192.168.0.4:9999"
+ )
+ peer0.fail(
+ "${pkgs.wget}/bin/wget -e use_proxy=yes -e http_proxy=http://192.168.0.4:3128 -S -O /dev/null http://127.0.0.1:9999"
+ )
+ '';
+})
diff --git a/nixpkgs/nixos/tests/all-tests.nix b/nixpkgs/nixos/tests/all-tests.nix
index df65ef249e8..fe9c4df1416 100644
--- a/nixpkgs/nixos/tests/all-tests.nix
+++ b/nixpkgs/nixos/tests/all-tests.nix
@@ -21,6 +21,7 @@ let
else {};
in
{
+ _3proxy = handleTest ./3proxy.nix {};
acme = handleTestOn ["x86_64-linux"] ./acme.nix {};
atd = handleTest ./atd.nix {};
automysqlbackup = handleTest ./automysqlbackup.nix {};
@@ -48,6 +49,7 @@ in
clickhouse = handleTest ./clickhouse.nix {};
cloud-init = handleTest ./cloud-init.nix {};
codimd = handleTest ./codimd.nix {};
+ consul = handleTest ./consul.nix {};
containers-bridge = handleTest ./containers-bridge.nix {};
containers-ephemeral = handleTest ./containers-ephemeral.nix {};
containers-extra_veth = handleTest ./containers-extra_veth.nix {};
@@ -56,6 +58,7 @@ in
containers-ip = handleTest ./containers-ip.nix {};
containers-macvlans = handleTest ./containers-macvlans.nix {};
containers-physical_interfaces = handleTest ./containers-physical_interfaces.nix {};
+ containers-portforward = handleTest ./containers-portforward.nix {};
containers-restart_networking = handleTest ./containers-restart_networking.nix {};
containers-tmpfs = handleTest ./containers-tmpfs.nix {};
couchdb = handleTest ./couchdb.nix {};
@@ -93,6 +96,7 @@ in
gitea = handleTest ./gitea.nix {};
gitlab = handleTest ./gitlab.nix {};
gitolite = handleTest ./gitolite.nix {};
+ gitolite-fcgiwrap = handleTest ./gitolite-fcgiwrap.nix {};
glusterfs = handleTest ./glusterfs.nix {};
gnome3-xorg = handleTest ./gnome3-xorg.nix {};
gnome3 = handleTest ./gnome3.nix {};
@@ -103,6 +107,7 @@ in
grafana = handleTest ./grafana.nix {};
graphite = handleTest ./graphite.nix {};
graylog = handleTest ./graylog.nix {};
+ gvisor = handleTest ./gvisor.nix {};
hadoop.hdfs = handleTestOn [ "x86_64-linux" ] ./hadoop/hdfs.nix {};
hadoop.yarn = handleTestOn [ "x86_64-linux" ] ./hadoop/yarn.nix {};
handbrake = handleTestOn ["x86_64-linux"] ./handbrake.nix {};
@@ -117,6 +122,7 @@ in
i3wm = handleTest ./i3wm.nix {};
icingaweb2 = handleTest ./icingaweb2.nix {};
iftop = handleTest ./iftop.nix {};
+ ihatemoney = handleTest ./ihatemoney.nix {};
incron = handleTest ./incron.nix {};
influxdb = handleTest ./influxdb.nix {};
initrd-network-ssh = handleTest ./initrd-network-ssh {};
@@ -127,6 +133,7 @@ in
jellyfin = handleTest ./jellyfin.nix {};
jenkins = handleTest ./jenkins.nix {};
kafka = handleTest ./kafka.nix {};
+ keepalived = handleTest ./keepalived.nix {};
kerberos = handleTest ./kerberos/default.nix {};
kernel-latest = handleTest ./kernel-latest.nix {};
kernel-lts = handleTest ./kernel-lts.nix {};
@@ -173,6 +180,7 @@ in
mysql = handleTest ./mysql.nix {};
mysqlBackup = handleTest ./mysql-backup.nix {};
mysqlReplication = handleTest ./mysql-replication.nix {};
+ nagios = handleTest ./nagios.nix {};
nat.firewall = handleTest ./nat.nix { withFirewall = true; };
nat.firewall-conntrack = handleTest ./nat.nix { withFirewall = true; withConntrackHelpers = true; };
nat.standalone = handleTest ./nat.nix { withFirewall = false; };
@@ -186,10 +194,12 @@ in
networkingProxy = handleTest ./networking-proxy.nix {};
nextcloud = handleTest ./nextcloud {};
nexus = handleTest ./nexus.nix {};
- nfs3 = handleTest ./nfs.nix { version = 3; };
- nfs4 = handleTest ./nfs.nix { version = 4; };
+ # TODO: Test nfsv3 + Kerberos
+ nfs3 = handleTest ./nfs { version = 3; };
+ nfs4 = handleTest ./nfs { version = 4; };
nghttpx = handleTest ./nghttpx.nix {};
nginx = handleTest ./nginx.nix {};
+ nginx-etag = handleTest ./nginx-etag.nix {};
nginx-sso = handleTest ./nginx-sso.nix {};
nix-ssh-serve = handleTest ./nix-ssh-serve.nix {};
nixos-generate-config = handleTest ./nixos-generate-config.nix {};
@@ -251,6 +261,7 @@ in
smokeping = handleTest ./smokeping.nix {};
snapper = handleTest ./snapper.nix {};
solr = handleTest ./solr.nix {};
+ spacecookie = handleTest ./spacecookie.nix {};
sonarr = handleTest ./sonarr.nix {};
strongswan-swanctl = handleTest ./strongswan-swanctl.nix {};
sudo = handleTest ./sudo.nix {};
@@ -258,6 +269,7 @@ in
syncthing-init = handleTest ./syncthing-init.nix {};
syncthing-relay = handleTest ./syncthing-relay.nix {};
systemd = handleTest ./systemd.nix {};
+ systemd-analyze = handleTest ./systemd-analyze.nix {};
systemd-confinement = handleTest ./systemd-confinement.nix {};
systemd-timesyncd = handleTest ./systemd-timesyncd.nix {};
systemd-networkd-wireguard = handleTest ./systemd-networkd-wireguard.nix {};
@@ -266,10 +278,12 @@ in
taskserver = handleTest ./taskserver.nix {};
telegraf = handleTest ./telegraf.nix {};
tiddlywiki = handleTest ./tiddlywiki.nix {};
+ timezone = handleTest ./timezone.nix {};
tinydns = handleTest ./tinydns.nix {};
tor = handleTest ./tor.nix {};
transmission = handleTest ./transmission.nix {};
trac = handleTest ./trac.nix {};
+ trilium-server = handleTestOn ["x86_64-linux"] ./trilium-server.nix {};
trezord = handleTest ./trezord.nix {};
trickster = handleTest ./trickster.nix {};
udisks2 = handleTest ./udisks2.nix {};
@@ -288,5 +302,6 @@ in
xss-lock = handleTest ./xss-lock.nix {};
yabar = handleTest ./yabar.nix {};
yggdrasil = handleTest ./yggdrasil.nix {};
+ zsh-history = handleTest ./zsh-history.nix {};
zookeeper = handleTest ./zookeeper.nix {};
}
diff --git a/nixpkgs/nixos/tests/ceph-multi-node.nix b/nixpkgs/nixos/tests/ceph-multi-node.nix
index 52a0b5caf23..90dd747525d 100644
--- a/nixpkgs/nixos/tests/ceph-multi-node.nix
+++ b/nixpkgs/nixos/tests/ceph-multi-node.nix
@@ -19,6 +19,12 @@ let
key = "AQBEEJNac00kExAAXEgy943BGyOpVH1LLlHafQ==";
uuid = "5e97a838-85b6-43b0-8950-cb56d554d1e5";
};
+ osd2 = {
+ name = "2";
+ ip = "192.168.1.4";
+ key = "AQAdyhZeIaUlARAAGRoidDAmS6Vkp546UFEf5w==";
+ uuid = "ea999274-13d0-4dd5-9af9-ad25a324f72f";
+ };
};
generateCephConfig = { daemonConfig }: {
enable = true;
@@ -72,35 +78,20 @@ let
};
}; };
- networkOsd0 = {
+ networkOsd = osd: {
dhcpcd.enable = false;
interfaces.eth1.ipv4.addresses = pkgs.lib.mkOverride 0 [
- { address = cfg.osd0.ip; prefixLength = 24; }
+ { address = osd.ip; prefixLength = 24; }
];
firewall = {
allowedTCPPortRanges = [ { from = 6800; to = 7300; } ];
};
};
- cephConfigOsd0 = generateCephConfig { daemonConfig = {
- osd = {
- enable = true;
- daemons = [ cfg.osd0.name ];
- };
- }; };
- networkOsd1 = {
- dhcpcd.enable = false;
- interfaces.eth1.ipv4.addresses = pkgs.lib.mkOverride 0 [
- { address = cfg.osd1.ip; prefixLength = 24; }
- ];
- firewall = {
- allowedTCPPortRanges = [ { from = 6800; to = 7300; } ];
- };
- };
- cephConfigOsd1 = generateCephConfig { daemonConfig = {
+ cephConfigOsd = osd: generateCephConfig { daemonConfig = {
osd = {
enable = true;
- daemons = [ cfg.osd1.name ];
+ daemons = [ osd.name ];
};
}; };
@@ -114,6 +105,7 @@ let
monA.wait_for_unit("network.target")
osd0.wait_for_unit("network.target")
osd1.wait_for_unit("network.target")
+ osd2.wait_for_unit("network.target")
# Bootstrap ceph-mon daemon
monA.succeed(
@@ -145,8 +137,9 @@ let
monA.succeed("cp /etc/ceph/ceph.client.admin.keyring /tmp/shared")
osd0.succeed("cp /tmp/shared/ceph.client.admin.keyring /etc/ceph")
osd1.succeed("cp /tmp/shared/ceph.client.admin.keyring /etc/ceph")
+ osd2.succeed("cp /tmp/shared/ceph.client.admin.keyring /etc/ceph")
- # Bootstrap both OSDs
+ # Bootstrap OSDs
osd0.succeed(
"mkfs.xfs /dev/vdb",
"mkdir -p /var/lib/ceph/osd/ceph-${cfg.osd0.name}",
@@ -161,6 +154,13 @@ let
"ceph-authtool --create-keyring /var/lib/ceph/osd/ceph-${cfg.osd1.name}/keyring --name osd.${cfg.osd1.name} --add-key ${cfg.osd1.key}",
'echo \'{"cephx_secret": "${cfg.osd1.key}"}\' | ceph osd new ${cfg.osd1.uuid} -i -',
)
+ osd2.succeed(
+ "mkfs.xfs /dev/vdb",
+ "mkdir -p /var/lib/ceph/osd/ceph-${cfg.osd2.name}",
+ "mount /dev/vdb /var/lib/ceph/osd/ceph-${cfg.osd2.name}",
+ "ceph-authtool --create-keyring /var/lib/ceph/osd/ceph-${cfg.osd2.name}/keyring --name osd.${cfg.osd2.name} --add-key ${cfg.osd2.key}",
+ 'echo \'{"cephx_secret": "${cfg.osd2.key}"}\' | ceph osd new ${cfg.osd2.uuid} -i -',
+ )
# Initialize the OSDs with regular filestore
osd0.succeed(
@@ -173,7 +173,12 @@ let
"chown -R ceph:ceph /var/lib/ceph/osd",
"systemctl start ceph-osd-${cfg.osd1.name}",
)
- monA.wait_until_succeeds("ceph osd stat | grep -e '2 osds: 2 up[^,]*, 2 in'")
+ osd2.succeed(
+ "ceph-osd -i ${cfg.osd2.name} --mkfs --osd-uuid ${cfg.osd2.uuid}",
+ "chown -R ceph:ceph /var/lib/ceph/osd",
+ "systemctl start ceph-osd-${cfg.osd2.name}",
+ )
+ monA.wait_until_succeeds("ceph osd stat | grep -e '3 osds: 3 up[^,]*, 3 in'")
monA.wait_until_succeeds("ceph -s | grep 'mgr: ${cfg.monA.name}(active,'")
monA.wait_until_succeeds("ceph -s | grep 'HEALTH_OK'")
@@ -196,16 +201,18 @@ let
monA.crash()
osd0.crash()
osd1.crash()
+ osd2.crash()
# Start it up
osd0.start()
osd1.start()
+ osd2.start()
monA.start()
# Ensure the cluster comes back up again
monA.succeed("ceph -s | grep 'mon: 1 daemons'")
monA.wait_until_succeeds("ceph -s | grep 'quorum ${cfg.monA.name}'")
- monA.wait_until_succeeds("ceph osd stat | grep -e '2 osds: 2 up[^,]*, 2 in'")
+ monA.wait_until_succeeds("ceph osd stat | grep -e '3 osds: 3 up[^,]*, 3 in'")
monA.wait_until_succeeds("ceph -s | grep 'mgr: ${cfg.monA.name}(active,'")
monA.wait_until_succeeds("ceph -s | grep 'HEALTH_OK'")
'';
@@ -217,8 +224,9 @@ in {
nodes = {
monA = generateHost { pkgs = pkgs; cephConfig = cephConfigMonA; networkConfig = networkMonA; };
- osd0 = generateHost { pkgs = pkgs; cephConfig = cephConfigOsd0; networkConfig = networkOsd0; };
- osd1 = generateHost { pkgs = pkgs; cephConfig = cephConfigOsd1; networkConfig = networkOsd1; };
+ osd0 = generateHost { pkgs = pkgs; cephConfig = cephConfigOsd cfg.osd0; networkConfig = networkOsd cfg.osd0; };
+ osd1 = generateHost { pkgs = pkgs; cephConfig = cephConfigOsd cfg.osd1; networkConfig = networkOsd cfg.osd1; };
+ osd2 = generateHost { pkgs = pkgs; cephConfig = cephConfigOsd cfg.osd2; networkConfig = networkOsd cfg.osd2; };
};
testScript = testscript;
diff --git a/nixpkgs/nixos/tests/ceph-single-node.nix b/nixpkgs/nixos/tests/ceph-single-node.nix
index da92a73e14d..1a027e17836 100644
--- a/nixpkgs/nixos/tests/ceph-single-node.nix
+++ b/nixpkgs/nixos/tests/ceph-single-node.nix
@@ -17,6 +17,11 @@ let
key = "AQBEEJNac00kExAAXEgy943BGyOpVH1LLlHafQ==";
uuid = "5e97a838-85b6-43b0-8950-cb56d554d1e5";
};
+ osd2 = {
+ name = "2";
+ key = "AQAdyhZeIaUlARAAGRoidDAmS6Vkp546UFEf5w==";
+ uuid = "ea999274-13d0-4dd5-9af9-ad25a324f72f";
+ };
};
generateCephConfig = { daemonConfig }: {
enable = true;
@@ -30,7 +35,7 @@ let
generateHost = { pkgs, cephConfig, networkConfig, ... }: {
virtualisation = {
memorySize = 512;
- emptyDiskImages = [ 20480 20480 ];
+ emptyDiskImages = [ 20480 20480 20480 ];
vlans = [ 1 ];
};
@@ -65,7 +70,7 @@ let
};
osd = {
enable = true;
- daemons = [ cfg.osd0.name cfg.osd1.name ];
+ daemons = [ cfg.osd0.name cfg.osd1.name cfg.osd2.name ];
};
}; };
@@ -104,29 +109,36 @@ let
monA.wait_until_succeeds("ceph -s | grep 'quorum ${cfg.monA.name}'")
monA.wait_until_succeeds("ceph -s | grep 'mgr: ${cfg.monA.name}(active,'")
- # Bootstrap both OSDs
+ # Bootstrap OSDs
monA.succeed(
"mkfs.xfs /dev/vdb",
"mkfs.xfs /dev/vdc",
+ "mkfs.xfs /dev/vdd",
"mkdir -p /var/lib/ceph/osd/ceph-${cfg.osd0.name}",
"mount /dev/vdb /var/lib/ceph/osd/ceph-${cfg.osd0.name}",
"mkdir -p /var/lib/ceph/osd/ceph-${cfg.osd1.name}",
"mount /dev/vdc /var/lib/ceph/osd/ceph-${cfg.osd1.name}",
+ "mkdir -p /var/lib/ceph/osd/ceph-${cfg.osd2.name}",
+ "mount /dev/vdd /var/lib/ceph/osd/ceph-${cfg.osd2.name}",
"ceph-authtool --create-keyring /var/lib/ceph/osd/ceph-${cfg.osd0.name}/keyring --name osd.${cfg.osd0.name} --add-key ${cfg.osd0.key}",
"ceph-authtool --create-keyring /var/lib/ceph/osd/ceph-${cfg.osd1.name}/keyring --name osd.${cfg.osd1.name} --add-key ${cfg.osd1.key}",
+ "ceph-authtool --create-keyring /var/lib/ceph/osd/ceph-${cfg.osd2.name}/keyring --name osd.${cfg.osd2.name} --add-key ${cfg.osd2.key}",
'echo \'{"cephx_secret": "${cfg.osd0.key}"}\' | ceph osd new ${cfg.osd0.uuid} -i -',
'echo \'{"cephx_secret": "${cfg.osd1.key}"}\' | ceph osd new ${cfg.osd1.uuid} -i -',
+ 'echo \'{"cephx_secret": "${cfg.osd2.key}"}\' | ceph osd new ${cfg.osd2.uuid} -i -',
)
# Initialize the OSDs with regular filestore
monA.succeed(
"ceph-osd -i ${cfg.osd0.name} --mkfs --osd-uuid ${cfg.osd0.uuid}",
"ceph-osd -i ${cfg.osd1.name} --mkfs --osd-uuid ${cfg.osd1.uuid}",
+ "ceph-osd -i ${cfg.osd2.name} --mkfs --osd-uuid ${cfg.osd2.uuid}",
"chown -R ceph:ceph /var/lib/ceph/osd",
"systemctl start ceph-osd-${cfg.osd0.name}",
"systemctl start ceph-osd-${cfg.osd1.name}",
+ "systemctl start ceph-osd-${cfg.osd2.name}",
)
- monA.wait_until_succeeds("ceph osd stat | grep -e '2 osds: 2 up[^,]*, 2 in'")
+ monA.wait_until_succeeds("ceph osd stat | grep -e '3 osds: 3 up[^,]*, 3 in'")
monA.wait_until_succeeds("ceph -s | grep 'mgr: ${cfg.monA.name}(active,'")
monA.wait_until_succeeds("ceph -s | grep 'HEALTH_OK'")
@@ -161,11 +173,12 @@ let
monA.wait_for_unit("ceph-mgr-${cfg.monA.name}")
monA.wait_for_unit("ceph-osd-${cfg.osd0.name}")
monA.wait_for_unit("ceph-osd-${cfg.osd1.name}")
+ monA.wait_for_unit("ceph-osd-${cfg.osd2.name}")
# Ensure the cluster comes back up again
monA.succeed("ceph -s | grep 'mon: 1 daemons'")
monA.wait_until_succeeds("ceph -s | grep 'quorum ${cfg.monA.name}'")
- monA.wait_until_succeeds("ceph osd stat | grep -e '2 osds: 2 up[^,]*, 2 in'")
+ monA.wait_until_succeeds("ceph osd stat | grep -e '3 osds: 3 up[^,]*, 3 in'")
monA.wait_until_succeeds("ceph -s | grep 'mgr: ${cfg.monA.name}(active,'")
monA.wait_until_succeeds("ceph -s | grep 'HEALTH_OK'")
'';
diff --git a/nixpkgs/nixos/tests/chromium.nix b/nixpkgs/nixos/tests/chromium.nix
index af5db2a3dbe..a5531d112e3 100644
--- a/nixpkgs/nixos/tests/chromium.nix
+++ b/nixpkgs/nixos/tests/chromium.nix
@@ -36,7 +36,7 @@ mapAttrs (channel: chromiumPkg: makeTest rec {
<body onload="javascript:document.title='startup done'">
<img src="file://${pkgs.fetchurl {
url = "http://nixos.org/logo/nixos-hex.svg";
- sha256 = "0wxpp65npdw2cg8m0cxc9qff1sb3b478cxpg1741d8951g948rg8";
+ sha256 = "07ymq6nw8kc22m7kzxjxldhiq8gzmc7f45kq2bvhbdm0w5s112s4";
}}" />
</body>
</html>
diff --git a/nixpkgs/nixos/tests/common/user-account.nix b/nixpkgs/nixos/tests/common/user-account.nix
index 9cd531a1f96..a57ee2d59ae 100644
--- a/nixpkgs/nixos/tests/common/user-account.nix
+++ b/nixpkgs/nixos/tests/common/user-account.nix
@@ -4,6 +4,7 @@
{ isNormalUser = true;
description = "Alice Foobar";
password = "foobar";
+ uid = 1000;
};
users.users.bob =
diff --git a/nixpkgs/nixos/tests/common/x11.nix b/nixpkgs/nixos/tests/common/x11.nix
index c5a7c165d12..5ad0ac20fac 100644
--- a/nixpkgs/nixos/tests/common/x11.nix
+++ b/nixpkgs/nixos/tests/common/x11.nix
@@ -1,12 +1,12 @@
+{ lib, ... }:
+
{ services.xserver.enable = true;
# Automatically log in.
services.xserver.displayManager.auto.enable = true;
# Use IceWM as the window manager.
- services.xserver.windowManager.default = "icewm";
- services.xserver.windowManager.icewm.enable = true;
-
# Don't use a desktop manager.
- services.xserver.desktopManager.default = "none";
+ services.xserver.displayManager.defaultSession = lib.mkDefault "none+icewm";
+ services.xserver.windowManager.icewm.enable = true;
}
diff --git a/nixpkgs/nixos/tests/consul.nix b/nixpkgs/nixos/tests/consul.nix
new file mode 100644
index 00000000000..6600dae4770
--- /dev/null
+++ b/nixpkgs/nixos/tests/consul.nix
@@ -0,0 +1,143 @@
+import ./make-test-python.nix ({pkgs, lib, ...}:
+
+let
+ # Settings for both servers and agents
+ webUi = true;
+ retry_interval = "1s";
+ raft_multiplier = 1;
+
+ defaultExtraConfig = {
+ inherit retry_interval;
+ performance = {
+ inherit raft_multiplier;
+ };
+ };
+
+ allConsensusServerHosts = [
+ "192.168.1.1"
+ "192.168.1.2"
+ "192.168.1.3"
+ ];
+
+ allConsensusClientHosts = [
+ "192.168.2.1"
+ "192.168.2.2"
+ ];
+
+ firewallSettings = {
+ # See https://www.consul.io/docs/install/ports.html
+ allowedTCPPorts = [ 8301 8302 8600 8500 8300 ];
+ allowedUDPPorts = [ 8301 8302 8600 ];
+ };
+
+ client = index: { pkgs, ... }:
+ let
+ ip = builtins.elemAt allConsensusClientHosts index;
+ in
+ {
+ environment.systemPackages = [ pkgs.consul ];
+
+ networking.interfaces.eth1.ipv4.addresses = pkgs.lib.mkOverride 0 [
+ { address = ip; prefixLength = 16; }
+ ];
+ networking.firewall = firewallSettings;
+
+ services.consul = {
+ enable = true;
+ inherit webUi;
+ extraConfig = defaultExtraConfig // {
+ server = false;
+ retry_join = allConsensusServerHosts;
+ bind_addr = ip;
+ };
+ };
+ };
+
+ server = index: { pkgs, ... }:
+ let
+ ip = builtins.elemAt allConsensusServerHosts index;
+ in
+ {
+ networking.interfaces.eth1.ipv4.addresses = pkgs.lib.mkOverride 0 [
+ { address = builtins.elemAt allConsensusServerHosts index; prefixLength = 16; }
+ ];
+ networking.firewall = firewallSettings;
+
+ services.consul =
+ let
+ thisConsensusServerHost = builtins.elemAt allConsensusServerHosts index;
+ in
+ assert builtins.elem thisConsensusServerHost allConsensusServerHosts;
+ {
+ enable = true;
+ inherit webUi;
+ extraConfig = defaultExtraConfig // {
+ server = true;
+ bootstrap_expect = builtins.length allConsensusServerHosts;
+ retry_join =
+ # If there's only 1 node in the network, we allow self-join;
+ # otherwise, the node must not try to join itself, and join only the other servers.
+ # See https://github.com/hashicorp/consul/issues/2868
+ if builtins.length allConsensusServerHosts == 1
+ then allConsensusServerHosts
+ else builtins.filter (h: h != thisConsensusServerHost) allConsensusServerHosts;
+ bind_addr = ip;
+ };
+ };
+ };
+in {
+ name = "consul";
+
+ nodes = {
+ server1 = server 0;
+ server2 = server 1;
+ server3 = server 2;
+
+ client1 = client 0;
+ client2 = client 1;
+ };
+
+ testScript = ''
+ servers = [server1, server2, server3]
+ machines = [server1, server2, server3, client1, client2]
+
+ for m in machines:
+ m.wait_for_unit("consul.service")
+
+ for m in machines:
+ m.wait_until_succeeds("[ $(consul members | grep -o alive | wc -l) == 5 ]")
+
+ client1.succeed("consul kv put testkey 42")
+ client2.succeed("[ $(consul kv get testkey) == 42 ]")
+
+ # Test that the cluster can tolearate failures of any single server:
+ for server in servers:
+ server.crash()
+
+ # For each client, wait until they have connection again
+ # using `kv get -recurse` before issuing commands.
+ client1.wait_until_succeeds("consul kv get -recurse")
+ client2.wait_until_succeeds("consul kv get -recurse")
+
+ # Do some consul actions while one server is down.
+ client1.succeed("consul kv put testkey 43")
+ client2.succeed("[ $(consul kv get testkey) == 43 ]")
+ client2.succeed("consul kv delete testkey")
+
+ # Restart crashed machine.
+ server.start()
+
+ # Wait for recovery.
+ for m in machines:
+ m.wait_until_succeeds("[ $(consul members | grep -o alive | wc -l) == 5 ]")
+
+ # Wait for client connections.
+ client1.wait_until_succeeds("consul kv get -recurse")
+ client2.wait_until_succeeds("consul kv get -recurse")
+
+ # Do some consul actions with server back up.
+ client1.succeed("consul kv put testkey 44")
+ client2.succeed("[ $(consul kv get testkey) == 44 ]")
+ client2.succeed("consul kv delete testkey")
+ '';
+})
diff --git a/nixpkgs/nixos/tests/containers-extra_veth.nix b/nixpkgs/nixos/tests/containers-extra_veth.nix
index b3d3bce8757..7d30b3f76cd 100644
--- a/nixpkgs/nixos/tests/containers-extra_veth.nix
+++ b/nixpkgs/nixos/tests/containers-extra_veth.nix
@@ -1,7 +1,7 @@
# Test for NixOS' container support.
-import ./make-test.nix ({ pkgs, ...} : {
- name = "containers-bridge";
+import ./make-test-python.nix ({ pkgs, ...} : {
+ name = "containers-extra_veth";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ kampfschlaefer ];
};
@@ -52,52 +52,43 @@ import ./make-test.nix ({ pkgs, ...} : {
testScript =
''
- $machine->waitForUnit("default.target");
- $machine->succeed("nixos-container list") =~ /webserver/ or die;
+ machine.wait_for_unit("default.target")
+ assert "webserver" in machine.succeed("nixos-container list")
- # Status of the webserver container.
- $machine->succeed("nixos-container status webserver") =~ /up/ or die;
+ with subtest("Status of the webserver container is up"):
+ assert "up" in machine.succeed("nixos-container status webserver")
- # Debug
- #$machine->succeed("nixos-container run webserver -- ip link >&2");
+ with subtest("Ensure that the veths are inside the container"):
+ assert "state UP" in machine.succeed(
+ "nixos-container run webserver -- ip link show veth1"
+ )
+ assert "state UP" in machine.succeed(
+ "nixos-container run webserver -- ip link show veth2"
+ )
- # Ensure that the veths are inside the container
- $machine->succeed("nixos-container run webserver -- ip link show veth1") =~ /state UP/ or die;
- $machine->succeed("nixos-container run webserver -- ip link show veth2") =~ /state UP/ or die;
+ with subtest("Ensure the presence of the extra veths"):
+ assert "state UP" in machine.succeed("ip link show veth1")
+ assert "state UP" in machine.succeed("ip link show veth2")
- # Debug
- #$machine->succeed("ip link >&2");
+ with subtest("Ensure the veth1 is part of br1 on the host"):
+ assert "master br1" in machine.succeed("ip link show veth1")
- # Ensure the presence of the extra veths
- $machine->succeed("ip link show veth1") =~ /state UP/ or die;
- $machine->succeed("ip link show veth2") =~ /state UP/ or die;
+ with subtest("Ping on main veth"):
+ machine.succeed("ping -n -c 1 192.168.0.100")
+ machine.succeed("ping -n -c 1 fc00::2")
- # Ensure the veth1 is part of br1 on the host
- $machine->succeed("ip link show veth1") =~ /master br1/ or die;
+ with subtest("Ping on the first extra veth"):
+ machine.succeed("ping -n -c 1 192.168.1.100 >&2")
- # Debug
- #$machine->succeed("ip -4 a >&2");
- #$machine->succeed("ip -4 r >&2");
- #$machine->succeed("nixos-container run webserver -- ip link >&2");
- #$machine->succeed("nixos-container run webserver -- ip -4 a >&2");
- #$machine->succeed("nixos-container run webserver -- ip -4 r >&2");
+ with subtest("Ping on the second extra veth"):
+ machine.succeed("ping -n -c 1 192.168.2.100 >&2")
- # Ping on main veth
- $machine->succeed("ping -n -c 1 192.168.0.100");
- $machine->succeed("ping -n -c 1 fc00::2");
+ with subtest("Container can be stopped"):
+ machine.succeed("nixos-container stop webserver")
+ machine.fail("ping -n -c 1 192.168.1.100 >&2")
+ machine.fail("ping -n -c 1 192.168.2.100 >&2")
- # Ping on the first extra veth
- $machine->succeed("ping -n -c 1 192.168.1.100 >&2");
-
- # Ping on the second extra veth
- $machine->succeed("ping -n -c 1 192.168.2.100 >&2");
-
- # Stop the container.
- $machine->succeed("nixos-container stop webserver");
- $machine->fail("ping -n -c 1 192.168.1.100 >&2");
- $machine->fail("ping -n -c 1 192.168.2.100 >&2");
-
- # Destroying a declarative container should fail.
- $machine->fail("nixos-container destroy webserver");
+ with subtest("Destroying a declarative container should fail"):
+ machine.fail("nixos-container destroy webserver")
'';
})
diff --git a/nixpkgs/nixos/tests/containers-macvlans.nix b/nixpkgs/nixos/tests/containers-macvlans.nix
index 2bdb926a8e2..0e8f67bc76f 100644
--- a/nixpkgs/nixos/tests/containers-macvlans.nix
+++ b/nixpkgs/nixos/tests/containers-macvlans.nix
@@ -6,7 +6,7 @@ let
containerIp2 = "192.168.1.254";
in
-import ./make-test.nix ({ pkgs, ...} : {
+import ./make-test-python.nix ({ pkgs, ...} : {
name = "containers-macvlans";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ montag451 ];
@@ -64,19 +64,23 @@ import ./make-test.nix ({ pkgs, ...} : {
};
testScript = ''
- startAll;
- $machine1->waitForUnit("default.target");
- $machine2->waitForUnit("default.target");
+ start_all()
+ machine1.wait_for_unit("default.target")
+ machine2.wait_for_unit("default.target")
- # Ping between containers to check that macvlans are created in bridge mode
- $machine1->succeed("nixos-container run test1 -- ping -n -c 1 ${containerIp2}");
+ with subtest(
+ "Ping between containers to check that macvlans are created in bridge mode"
+ ):
+ machine1.succeed("nixos-container run test1 -- ping -n -c 1 ${containerIp2}")
- # Ping containers from the host (machine1)
- $machine1->succeed("ping -n -c 1 ${containerIp1}");
- $machine1->succeed("ping -n -c 1 ${containerIp2}");
+ with subtest("Ping containers from the host (machine1)"):
+ machine1.succeed("ping -n -c 1 ${containerIp1}")
+ machine1.succeed("ping -n -c 1 ${containerIp2}")
- # Ping containers from the second machine to check that containers are reachable from the outside
- $machine2->succeed("ping -n -c 1 ${containerIp1}");
- $machine2->succeed("ping -n -c 1 ${containerIp2}");
+ with subtest(
+ "Ping containers from the second machine to check that containers are reachable from the outside"
+ ):
+ machine2.succeed("ping -n -c 1 ${containerIp1}")
+ machine2.succeed("ping -n -c 1 ${containerIp2}")
'';
})
diff --git a/nixpkgs/nixos/tests/containers-physical_interfaces.nix b/nixpkgs/nixos/tests/containers-physical_interfaces.nix
index 1e312f59f43..e800751a23c 100644
--- a/nixpkgs/nixos/tests/containers-physical_interfaces.nix
+++ b/nixpkgs/nixos/tests/containers-physical_interfaces.nix
@@ -1,5 +1,5 @@
-import ./make-test.nix ({ pkgs, ...} : {
+import ./make-test-python.nix ({ pkgs, ...} : {
name = "containers-physical_interfaces";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ kampfschlaefer ];
@@ -86,48 +86,51 @@ import ./make-test.nix ({ pkgs, ...} : {
};
testScript = ''
- startAll;
-
- subtest "prepare server", sub {
- $server->waitForUnit("default.target");
- $server->succeed("ip link show dev eth1 >&2");
- };
-
- subtest "simple physical interface", sub {
- $server->succeed("nixos-container start server");
- $server->waitForUnit("container\@server");
- $server->succeed("systemctl -M server list-dependencies network-addresses-eth1.service >&2");
-
- # The other tests will ping this container on its ip. Here we just check
- # that the device is present in the container.
- $server->succeed("nixos-container run server -- ip a show dev eth1 >&2");
- };
-
- subtest "physical device in bridge in container", sub {
- $bridged->waitForUnit("default.target");
- $bridged->succeed("nixos-container start bridged");
- $bridged->waitForUnit("container\@bridged");
- $bridged->succeed("systemctl -M bridged list-dependencies network-addresses-br0.service >&2");
- $bridged->succeed("systemctl -M bridged status -n 30 -l network-addresses-br0.service");
- $bridged->succeed("nixos-container run bridged -- ping -w 10 -c 1 -n 10.10.0.1");
- };
-
- subtest "physical device in bond in container", sub {
- $bonded->waitForUnit("default.target");
- $bonded->succeed("nixos-container start bonded");
- $bonded->waitForUnit("container\@bonded");
- $bonded->succeed("systemctl -M bonded list-dependencies network-addresses-bond0 >&2");
- $bonded->succeed("systemctl -M bonded status -n 30 -l network-addresses-bond0 >&2");
- $bonded->succeed("nixos-container run bonded -- ping -w 10 -c 1 -n 10.10.0.1");
- };
-
- subtest "physical device in bond in bridge in container", sub {
- $bridgedbond->waitForUnit("default.target");
- $bridgedbond->succeed("nixos-container start bridgedbond");
- $bridgedbond->waitForUnit("container\@bridgedbond");
- $bridgedbond->succeed("systemctl -M bridgedbond list-dependencies network-addresses-br0.service >&2");
- $bridgedbond->succeed("systemctl -M bridgedbond status -n 30 -l network-addresses-br0.service");
- $bridgedbond->succeed("nixos-container run bridgedbond -- ping -w 10 -c 1 -n 10.10.0.1");
- };
+ start_all()
+
+ with subtest("Prepare server"):
+ server.wait_for_unit("default.target")
+ server.succeed("ip link show dev eth1 >&2")
+
+ with subtest("Simple physical interface is up"):
+ server.succeed("nixos-container start server")
+ server.wait_for_unit("container@server")
+ server.succeed(
+ "systemctl -M server list-dependencies network-addresses-eth1.service >&2"
+ )
+
+ # The other tests will ping this container on its ip. Here we just check
+ # that the device is present in the container.
+ server.succeed("nixos-container run server -- ip a show dev eth1 >&2")
+
+ with subtest("Physical device in bridge in container can ping server"):
+ bridged.wait_for_unit("default.target")
+ bridged.succeed("nixos-container start bridged")
+ bridged.wait_for_unit("container@bridged")
+ bridged.succeed(
+ "systemctl -M bridged list-dependencies network-addresses-br0.service >&2",
+ "systemctl -M bridged status -n 30 -l network-addresses-br0.service",
+ "nixos-container run bridged -- ping -w 10 -c 1 -n 10.10.0.1",
+ )
+
+ with subtest("Physical device in bond in container can ping server"):
+ bonded.wait_for_unit("default.target")
+ bonded.succeed("nixos-container start bonded")
+ bonded.wait_for_unit("container@bonded")
+ bonded.succeed(
+ "systemctl -M bonded list-dependencies network-addresses-bond0 >&2",
+ "systemctl -M bonded status -n 30 -l network-addresses-bond0 >&2",
+ "nixos-container run bonded -- ping -w 10 -c 1 -n 10.10.0.1",
+ )
+
+ with subtest("Physical device in bond in bridge in container can ping server"):
+ bridgedbond.wait_for_unit("default.target")
+ bridgedbond.succeed("nixos-container start bridgedbond")
+ bridgedbond.wait_for_unit("container@bridgedbond")
+ bridgedbond.succeed(
+ "systemctl -M bridgedbond list-dependencies network-addresses-br0.service >&2",
+ "systemctl -M bridgedbond status -n 30 -l network-addresses-br0.service",
+ "nixos-container run bridgedbond -- ping -w 10 -c 1 -n 10.10.0.1",
+ )
'';
})
diff --git a/nixpkgs/nixos/tests/containers-portforward.nix b/nixpkgs/nixos/tests/containers-portforward.nix
index ec8e9629c21..fc90e151bd9 100644
--- a/nixpkgs/nixos/tests/containers-portforward.nix
+++ b/nixpkgs/nixos/tests/containers-portforward.nix
@@ -7,7 +7,7 @@ let
containerPort = 80;
in
-import ./make-test.nix ({ pkgs, ...} : {
+import ./make-test-python.nix ({ pkgs, ...} : {
name = "containers-portforward";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ aristid aszlig eelco kampfschlaefer ianwookim ];
@@ -36,27 +36,27 @@ import ./make-test.nix ({ pkgs, ...} : {
testScript =
''
- $machine->succeed("nixos-container list") =~ /webserver/ or die;
+ container_list = machine.succeed("nixos-container list")
+ assert "webserver" in container_list
# Start the webserver container.
- $machine->succeed("nixos-container start webserver");
+ machine.succeed("nixos-container start webserver")
# wait two seconds for the container to start and the network to be up
- sleep 2;
+ machine.sleep(2)
# Since "start" returns after the container has reached
# multi-user.target, we should now be able to access it.
- #my $ip = $machine->succeed("nixos-container show-ip webserver");
- #chomp $ip;
- $machine->succeed("ping -n -c1 ${hostIp}");
- $machine->succeed("curl --fail http://${hostIp}:${toString hostPort}/ > /dev/null");
+ # ip = machine.succeed("nixos-container show-ip webserver").strip()
+ machine.succeed("ping -n -c1 ${hostIp}")
+ machine.succeed("curl --fail http://${hostIp}:${toString hostPort}/ > /dev/null")
# Stop the container.
- $machine->succeed("nixos-container stop webserver");
- $machine->fail("curl --fail --connect-timeout 2 http://${hostIp}:${toString hostPort}/ > /dev/null");
+ machine.succeed("nixos-container stop webserver")
+ machine.fail("curl --fail --connect-timeout 2 http://${hostIp}:${toString hostPort}/ > /dev/null")
# Destroying a declarative container should fail.
- $machine->fail("nixos-container destroy webserver");
+ machine.fail("nixos-container destroy webserver")
'';
})
diff --git a/nixpkgs/nixos/tests/containers-restart_networking.nix b/nixpkgs/nixos/tests/containers-restart_networking.nix
index df15f5b2f45..b50dadd13e4 100644
--- a/nixpkgs/nixos/tests/containers-restart_networking.nix
+++ b/nixpkgs/nixos/tests/containers-restart_networking.nix
@@ -16,7 +16,7 @@ let
};
};
};
-in import ./make-test.nix ({ pkgs, ...} :
+in import ./make-test-python.nix ({ pkgs, ...} :
{
name = "containers-restart_networking";
meta = with pkgs.stdenv.lib.maintainers; {
@@ -64,50 +64,52 @@ in import ./make-test.nix ({ pkgs, ...} :
eth1_bridged = nodes.client_eth1.config.system.build.toplevel;
eth1_rstp = nodes.client_eth1_rstp.config.system.build.toplevel;
in ''
- $client->start();
-
- $client->waitForUnit("default.target");
-
- subtest "initial state", sub {
- $client->succeed("ping 192.168.1.122 -c 1 -n >&2");
- $client->succeed("nixos-container run webserver -- ping -c 1 -n 192.168.1.1 >&2");
-
- $client->fail("ip l show eth1 |grep \"master br0\" >&2");
- $client->fail("grep eth1 /run/br0.interfaces >&2");
- };
-
- subtest "interfaces without stp", sub {
- $client->succeed("${eth1_bridged}/bin/switch-to-configuration test >&2");
-
- $client->succeed("ping 192.168.1.122 -c 1 -n >&2");
- $client->succeed("nixos-container run webserver -- ping -c 1 -n 192.168.1.2 >&2");
-
- $client->succeed("ip l show eth1 |grep \"master br0\" >&2");
- $client->succeed("grep eth1 /run/br0.interfaces >&2");
- };
-
- # activating rstp needs another service, therefor the bridge will restart and the container will loose its connectivity
- #subtest "interfaces with rstp", sub {
- # $client->succeed("${eth1_rstp}/bin/switch-to-configuration test >&2");
- # $client->execute("ip -4 a >&2");
- # $client->execute("ip l >&2");
+ client.start()
+
+ client.wait_for_unit("default.target")
+
+ with subtest("Initial configuration connectivity check"):
+ client.succeed("ping 192.168.1.122 -c 1 -n >&2")
+ client.succeed("nixos-container run webserver -- ping -c 1 -n 192.168.1.1 >&2")
+
+ client.fail("ip l show eth1 |grep 'master br0' >&2")
+ client.fail("grep eth1 /run/br0.interfaces >&2")
+
+ with subtest("Bridged configuration without STP preserves connectivity"):
+ client.succeed(
+ "${eth1_bridged}/bin/switch-to-configuration test >&2"
+ )
+
+ client.succeed(
+ "ping 192.168.1.122 -c 1 -n >&2",
+ "nixos-container run webserver -- ping -c 1 -n 192.168.1.2 >&2",
+ "ip l show eth1 |grep 'master br0' >&2",
+ "grep eth1 /run/br0.interfaces >&2",
+ )
+
+ # activating rstp needs another service, therefore the bridge will restart and the container will lose its connectivity
+ # with subtest("Bridged configuration with STP"):
+ # client.succeed("${eth1_rstp}/bin/switch-to-configuration test >&2")
+ # client.execute("ip -4 a >&2")
+ # client.execute("ip l >&2")
#
- # $client->succeed("ping 192.168.1.122 -c 1 -n >&2");
- # $client->succeed("nixos-container run webserver -- ping -c 1 -n 192.168.1.2 >&2");
- #
- # $client->succeed("ip l show eth1 |grep \"master br0\" >&2");
- # $client->succeed("grep eth1 /run/br0.interfaces >&2");
- #};
-
- subtest "back to no interfaces and no stp", sub {
- $client->succeed("${originalSystem}/bin/switch-to-configuration test >&2");
-
- $client->succeed("ping 192.168.1.122 -c 1 -n >&2");
- $client->succeed("nixos-container run webserver -- ping -c 1 -n 192.168.1.1 >&2");
-
- $client->fail("ip l show eth1 |grep \"master br0\" >&2");
- $client->fail("grep eth1 /run/br0.interfaces >&2");
- };
+ # client.succeed(
+ # "ping 192.168.1.122 -c 1 -n >&2",
+ # "nixos-container run webserver -- ping -c 1 -n 192.168.1.2 >&2",
+ # "ip l show eth1 |grep 'master br0' >&2",
+ # "grep eth1 /run/br0.interfaces >&2",
+ # )
+
+ with subtest("Reverting to initial configuration preserves connectivity"):
+ client.succeed(
+ "${originalSystem}/bin/switch-to-configuration test >&2"
+ )
+
+ client.succeed("ping 192.168.1.122 -c 1 -n >&2")
+ client.succeed("nixos-container run webserver -- ping -c 1 -n 192.168.1.1 >&2")
+
+ client.fail("ip l show eth1 |grep 'master br0' >&2")
+ client.fail("grep eth1 /run/br0.interfaces >&2")
'';
})
diff --git a/nixpkgs/nixos/tests/dhparams.nix b/nixpkgs/nixos/tests/dhparams.nix
index d11dfeec5d0..a0de2911777 100644
--- a/nixpkgs/nixos/tests/dhparams.nix
+++ b/nixpkgs/nixos/tests/dhparams.nix
@@ -4,7 +4,7 @@ let
environment.systemPackages = [ pkgs.openssl ];
};
-in import ./make-test.nix {
+in import ./make-test-python.nix {
name = "dhparams";
nodes.generation1 = { pkgs, config, ... }: {
@@ -66,79 +66,77 @@ in import ./make-test.nix {
node = "generation${toString gen}";
in nodes.${node}.config.security.dhparams.params.${name}.path;
- assertParamBits = gen: name: bits: let
- path = getParamPath gen name;
- in ''
- $machine->nest('check bit size of ${path}', sub {
- my $out = $machine->succeed('openssl dhparam -in ${path} -text');
- $out =~ /^\s*DH Parameters:\s+\((\d+)\s+bit\)\s*$/m;
- die "bit size should be ${toString bits} but it is $1 instead."
- if $1 != ${toString bits};
- });
- '';
-
switchToGeneration = gen: let
node = "generation${toString gen}";
inherit (nodes.${node}.config.system.build) toplevel;
switchCmd = "${toplevel}/bin/switch-to-configuration test";
in ''
- $machine->nest('switch to generation ${toString gen}', sub {
- $machine->succeed('${switchCmd}');
- $main::machine = ''$${node};
- });
+ with machine.nested("switch to generation ${toString gen}"):
+ machine.succeed(
+ "${switchCmd}"
+ )
+ machine = ${node}
'';
in ''
- my $machine = $generation1;
+ import re
- $machine->waitForUnit('multi-user.target');
- subtest "verify startup order", sub {
- $machine->succeed('systemctl is-active foo.service');
- };
+ def assert_param_bits(path, bits):
+ with machine.nested(f"check bit size of {path}"):
+ output = machine.succeed(f"openssl dhparam -in {path} -text")
+ pattern = re.compile(r"^\s*DH Parameters:\s+\((\d+)\s+bit\)\s*$", re.M)
+ match = pattern.match(output)
+ if match is None:
+ raise Exception("bla")
+ if match[1] != str(bits):
+ raise Exception(f"bit size should be {bits} but it is {match[1]} instead.")
- subtest "check bit sizes of dhparam files", sub {
- ${assertParamBits 1 "foo" 16}
- ${assertParamBits 1 "bar" 17}
- };
+
+ machine = generation1
+
+ machine.wait_for_unit("multi-user.target")
+
+ with subtest("verify startup order"):
+ machine.succeed("systemctl is-active foo.service")
+
+ with subtest("check bit sizes of dhparam files"):
+ assert_param_bits("${getParamPath 1 "foo"}", 16)
+ assert_param_bits("${getParamPath 1 "bar"}", 17)
${switchToGeneration 2}
- subtest "check whether bit size has changed", sub {
- ${assertParamBits 2 "foo" 18}
- };
+ with subtest("check whether bit size has changed"):
+ assert_param_bits("${getParamPath 2 "foo"}", 18)
- subtest "ensure that dhparams file for 'bar' was deleted", sub {
- $machine->fail('test -e ${getParamPath 1 "bar"}');
- };
+ with subtest("ensure that dhparams file for 'bar' was deleted"):
+ machine.fail("test -e ${getParamPath 1 "bar"}")
${switchToGeneration 3}
- subtest "ensure that 'security.dhparams.path' has been deleted", sub {
- $machine->fail(
- 'test -e ${nodes.generation3.config.security.dhparams.path}'
- );
- };
+ with subtest("ensure that 'security.dhparams.path' has been deleted"):
+ machine.fail("test -e ${nodes.generation3.config.security.dhparams.path}")
${switchToGeneration 4}
- subtest "check bit sizes dhparam files", sub {
- ${assertParamBits 4 "foo2" 18}
- ${assertParamBits 4 "bar2" 19}
- };
+ with subtest("check bit sizes dhparam files"):
+ assert_param_bits(
+ "${getParamPath 4 "foo2"}", 18
+ )
+ assert_param_bits(
+ "${getParamPath 4 "bar2"}", 19
+ )
- subtest "check whether dhparam files are in the Nix store", sub {
- $machine->succeed(
- 'expr match ${getParamPath 4 "foo2"} ${builtins.storeDir}',
- 'expr match ${getParamPath 4 "bar2"} ${builtins.storeDir}',
- );
- };
+ with subtest("check whether dhparam files are in the Nix store"):
+ machine.succeed(
+ "expr match ${getParamPath 4 "foo2"} ${builtins.storeDir}",
+ "expr match ${getParamPath 4 "bar2"} ${builtins.storeDir}",
+ )
${switchToGeneration 5}
- subtest "check whether defaultBitSize works as intended", sub {
- ${assertParamBits 5 "foo3" 30}
- ${assertParamBits 5 "bar3" 30}
- };
+ with subtest("check whether defaultBitSize works as intended"):
+ assert_param_bits("${getParamPath 5 "foo3"}", 30)
+ assert_param_bits("${getParamPath 5 "bar3"}", 30)
'';
}
diff --git a/nixpkgs/nixos/tests/docker-tools-overlay.nix b/nixpkgs/nixos/tests/docker-tools-overlay.nix
index 637957bd3e8..1a0e0ea6775 100644
--- a/nixpkgs/nixos/tests/docker-tools-overlay.nix
+++ b/nixpkgs/nixos/tests/docker-tools-overlay.nix
@@ -1,6 +1,6 @@
# this test creates a simple GNU image with docker tools and sees if it executes
-import ./make-test.nix ({ pkgs, ... }:
+import ./make-test-python.nix ({ pkgs, ... }:
{
name = "docker-tools-overlay";
meta = with pkgs.stdenv.lib.maintainers; {
@@ -16,17 +16,18 @@ import ./make-test.nix ({ pkgs, ... }:
};
};
- testScript =
- ''
- $docker->waitForUnit("sockets.target");
+ testScript = ''
+ docker.wait_for_unit("sockets.target")
- $docker->succeed("docker load --input='${pkgs.dockerTools.examples.bash}'");
- $docker->succeed("docker run --rm ${pkgs.dockerTools.examples.bash.imageName} bash --version");
+ docker.succeed(
+ "docker load --input='${pkgs.dockerTools.examples.bash}'",
+ "docker run --rm ${pkgs.dockerTools.examples.bash.imageName} bash --version",
+ )
# Check if the nix store has correct user permissions depending on what
# storage driver is used, incorrectly built images can show up as readonly.
# drw------- 3 0 0 3 Apr 14 11:36 /nix
# drw------- 99 0 0 100 Apr 14 11:36 /nix/store
- $docker->succeed("docker run --rm -u 1000:1000 ${pkgs.dockerTools.examples.bash.imageName} bash --version");
+ docker.succeed("docker run --rm -u 1000:1000 ${pkgs.dockerTools.examples.bash.imageName} bash --version")
'';
})
diff --git a/nixpkgs/nixos/tests/ec2.nix b/nixpkgs/nixos/tests/ec2.nix
index 384fce67c22..c649ce852da 100644
--- a/nixpkgs/nixos/tests/ec2.nix
+++ b/nixpkgs/nixos/tests/ec2.nix
@@ -113,7 +113,7 @@ in {
services.httpd = {
enable = true;
adminAddr = "test@example.org";
- documentRoot = "${pkgs.valgrind.doc}/share/doc/valgrind/html";
+ virtualHosts.localhost.documentRoot = "${pkgs.valgrind.doc}/share/doc/valgrind/html";
};
networking.firewall.allowedTCPPorts = [ 80 ];
}
diff --git a/nixpkgs/nixos/tests/ecryptfs.nix b/nixpkgs/nixos/tests/ecryptfs.nix
index 3f02cecb866..ef7bd13eb92 100644
--- a/nixpkgs/nixos/tests/ecryptfs.nix
+++ b/nixpkgs/nixos/tests/ecryptfs.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ ... }:
+import ./make-test-python.nix ({ ... }:
{
name = "ecryptfs";
@@ -10,75 +10,76 @@ import ./make-test.nix ({ ... }:
};
testScript = ''
- $machine->waitForUnit("default.target");
+ def login_as_alice():
+ machine.wait_until_tty_matches(1, "login: ")
+ machine.send_chars("alice\n")
+ machine.wait_until_tty_matches(1, "Password: ")
+ machine.send_chars("foobar\n")
+ machine.wait_until_tty_matches(1, "alice\@machine")
- # Set alice up with a password and a home
- $machine->succeed("(echo foobar; echo foobar) | passwd alice");
- $machine->succeed("chown -R alice.users ~alice");
- # Migrate alice's home
- my $out = $machine->succeed("echo foobar | ecryptfs-migrate-home -u alice");
- $machine->log("ecryptfs-migrate-home said: $out");
+ def logout():
+ machine.send_chars("logout\n")
+ machine.wait_until_tty_matches(1, "login: ")
- # Log alice in (ecryptfs passwhrase is wrapped during first login)
- $machine->waitUntilTTYMatches(1, "login: ");
- $machine->sendChars("alice\n");
- $machine->waitUntilTTYMatches(1, "Password: ");
- $machine->sendChars("foobar\n");
- $machine->waitUntilTTYMatches(1, "alice\@machine");
- $machine->sendChars("logout\n");
- $machine->waitUntilTTYMatches(1, "login: ");
+
+ machine.wait_for_unit("default.target")
+
+ with subtest("Set alice up with a password and a home"):
+ machine.succeed("(echo foobar; echo foobar) | passwd alice")
+ machine.succeed("chown -R alice.users ~alice")
+
+ with subtest("Migrate alice's home"):
+ out = machine.succeed("echo foobar | ecryptfs-migrate-home -u alice")
+ machine.log(f"ecryptfs-migrate-home said: {out}")
+
+ with subtest("Log alice in (ecryptfs passwhrase is wrapped during first login)"):
+ login_as_alice()
+ machine.send_chars("logout\n")
+ machine.wait_until_tty_matches(1, "login: ")
# Why do I need to do this??
- $machine->succeed("su alice -c ecryptfs-umount-private || true");
- $machine->sleep(1);
- $machine->fail("mount | grep ecryptfs"); # check that encrypted home is not mounted
+ machine.succeed("su alice -c ecryptfs-umount-private || true")
+ machine.sleep(1)
+
+ with subtest("check that encrypted home is not mounted"):
+ machine.fail("mount | grep ecryptfs")
- # Show contents of the user keyring
- my $out = $machine->succeed("su - alice -c 'keyctl list \@u'");
- $machine->log("keyctl unlink said: " . $out);
+ with subtest("Show contents of the user keyring"):
+ out = machine.succeed("su - alice -c 'keyctl list \@u'")
+ machine.log(f"keyctl unlink said: {out}")
- # Log alice again
- $machine->waitUntilTTYMatches(1, "login: ");
- $machine->sendChars("alice\n");
- $machine->waitUntilTTYMatches(1, "Password: ");
- $machine->sendChars("foobar\n");
- $machine->waitUntilTTYMatches(1, "alice\@machine");
+ with subtest("Log alice again"):
+ login_as_alice()
- # Create some files in encrypted home
- $machine->succeed("su alice -c 'touch ~alice/a'");
- $machine->succeed("su alice -c 'echo c > ~alice/b'");
+ with subtest("Create some files in encrypted home"):
+ machine.succeed("su alice -c 'touch ~alice/a'")
+ machine.succeed("su alice -c 'echo c > ~alice/b'")
- # Logout
- $machine->sendChars("logout\n");
- $machine->waitUntilTTYMatches(1, "login: ");
+ with subtest("Logout"):
+ logout()
# Why do I need to do this??
- $machine->succeed("su alice -c ecryptfs-umount-private || true");
- $machine->sleep(1);
-
- # Check that the filesystem is not accessible
- $machine->fail("mount | grep ecryptfs");
- $machine->succeed("su alice -c 'test \! -f ~alice/a'");
- $machine->succeed("su alice -c 'test \! -f ~alice/b'");
-
- # Log alice once more
- $machine->waitUntilTTYMatches(1, "login: ");
- $machine->sendChars("alice\n");
- $machine->waitUntilTTYMatches(1, "Password: ");
- $machine->sendChars("foobar\n");
- $machine->waitUntilTTYMatches(1, "alice\@machine");
-
- # Check that the files are there
- $machine->sleep(1);
- $machine->succeed("su alice -c 'test -f ~alice/a'");
- $machine->succeed("su alice -c 'test -f ~alice/b'");
- $machine->succeed(qq%test "\$(cat ~alice/b)" = "c"%);
-
- # Catch https://github.com/NixOS/nixpkgs/issues/16766
- $machine->succeed("su alice -c 'ls -lh ~alice/'");
-
- $machine->sendChars("logout\n");
- $machine->waitUntilTTYMatches(1, "login: ");
+ machine.succeed("su alice -c ecryptfs-umount-private || true")
+ machine.sleep(1)
+
+ with subtest("Check that the filesystem is not accessible"):
+ machine.fail("mount | grep ecryptfs")
+ machine.succeed("su alice -c 'test \! -f ~alice/a'")
+ machine.succeed("su alice -c 'test \! -f ~alice/b'")
+
+ with subtest("Log alice once more"):
+ login_as_alice()
+
+ with subtest("Check that the files are there"):
+ machine.sleep(1)
+ machine.succeed("su alice -c 'test -f ~alice/a'")
+ machine.succeed("su alice -c 'test -f ~alice/b'")
+ machine.succeed('test "$(cat ~alice/b)" = "c"')
+
+ with subtest("Catch https://github.com/NixOS/nixpkgs/issues/16766"):
+ machine.succeed("su alice -c 'ls -lh ~alice/'")
+
+ logout()
'';
})
diff --git a/nixpkgs/nixos/tests/env.nix b/nixpkgs/nixos/tests/env.nix
index 6c681905b19..e603338e489 100644
--- a/nixpkgs/nixos/tests/env.nix
+++ b/nixpkgs/nixos/tests/env.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ pkgs, ...} : {
+import ./make-test-python.nix ({ pkgs, ...} : {
name = "environment";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ nequissimus ];
@@ -20,16 +20,17 @@ import ./make-test.nix ({ pkgs, ...} : {
};
};
- testScript =
- ''
- $machine->succeed('[ -L "/etc/plainFile" ]');
- $machine->succeed('cat "/etc/plainFile" | grep "Hello World"');
- $machine->succeed('[ -d "/etc/folder" ]');
- $machine->succeed('[ -d "/etc/folder/with" ]');
- $machine->succeed('[ -L "/etc/folder/with/file" ]');
- $machine->succeed('cat "/etc/plainFile" | grep "Hello World"');
+ testScript = ''
+ machine.succeed('[ -L "/etc/plainFile" ]')
+ assert "Hello World" in machine.succeed('cat "/etc/plainFile"')
+ machine.succeed('[ -d "/etc/folder" ]')
+ machine.succeed('[ -d "/etc/folder/with" ]')
+ machine.succeed('[ -L "/etc/folder/with/file" ]')
+ assert "Hello World" in machine.succeed('cat "/etc/plainFile"')
- $machine->succeed('echo ''${TERMINFO_DIRS} | grep "/run/current-system/sw/share/terminfo"');
- $machine->succeed('echo ''${NIXCON} | grep "awesome"');
- '';
+ assert "/run/current-system/sw/share/terminfo" in machine.succeed(
+ "echo ''${TERMINFO_DIRS}"
+ )
+ assert "awesome" in machine.succeed("echo ''${NIXCON}")
+ '';
})
diff --git a/nixpkgs/nixos/tests/ferm.nix b/nixpkgs/nixos/tests/ferm.nix
index edf9c8036ac..a73c9ce739c 100644
--- a/nixpkgs/nixos/tests/ferm.nix
+++ b/nixpkgs/nixos/tests/ferm.nix
@@ -1,5 +1,5 @@
-import ./make-test.nix ({ pkgs, ...} : {
+import ./make-test-python.nix ({ pkgs, ...} : {
name = "ferm";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ mic92 ];
@@ -53,24 +53,22 @@ import ./make-test.nix ({ pkgs, ...} : {
testScript =
''
- startAll;
+ start_all()
- $client->waitForUnit("network-online.target");
- $server->waitForUnit("ferm.service");
- $server->waitForUnit("nginx.service");
- $server->waitUntilSucceeds("ss -ntl | grep -q 80");
+ client.wait_for_unit("network-online.target")
+ server.wait_for_unit("ferm.service")
+ server.wait_for_unit("nginx.service")
+ server.wait_until_succeeds("ss -ntl | grep -q 80")
- subtest "port 80 is allowed", sub {
- $client->succeed("curl --fail -g http://192.168.1.1:80/status");
- $client->succeed("curl --fail -g http://[fd00::1]:80/status");
- };
+ with subtest("port 80 is allowed"):
+ client.succeed("curl --fail -g http://192.168.1.1:80/status")
+ client.succeed("curl --fail -g http://[fd00::1]:80/status")
- subtest "port 8080 is not allowed", sub {
- $server->succeed("curl --fail -g http://192.168.1.1:8080/status");
- $server->succeed("curl --fail -g http://[fd00::1]:8080/status");
+ with subtest("port 8080 is not allowed"):
+ server.succeed("curl --fail -g http://192.168.1.1:8080/status")
+ server.succeed("curl --fail -g http://[fd00::1]:8080/status")
- $client->fail("curl --fail -g http://192.168.1.1:8080/status");
- $client->fail("curl --fail -g http://[fd00::1]:8080/status");
- };
+ client.fail("curl --fail -g http://192.168.1.1:8080/status")
+ client.fail("curl --fail -g http://[fd00::1]:8080/status")
'';
})
diff --git a/nixpkgs/nixos/tests/gitea.nix b/nixpkgs/nixos/tests/gitea.nix
index ffbc07cfbb2..aaed2486421 100644
--- a/nixpkgs/nixos/tests/gitea.nix
+++ b/nixpkgs/nixos/tests/gitea.nix
@@ -6,64 +6,104 @@
with import ../lib/testing-python.nix { inherit system pkgs; };
with pkgs.lib;
-{
- mysql = makeTest {
- name = "gitea-mysql";
- meta.maintainers = with maintainers; [ aanderse kolaente ];
-
- machine =
- { config, pkgs, ... }:
- { services.gitea.enable = true;
- services.gitea.database.type = "mysql";
+let
+ supportedDbTypes = [ "mysql" "postgres" "sqlite3" ];
+ makeGiteaTest = type: nameValuePair type (makeTest {
+ name = "gitea-${type}";
+ meta.maintainers = with maintainers; [ aanderse kolaente ma27 ];
+
+ nodes = {
+ server = { config, pkgs, ... }: {
+ services.gitea = {
+ enable = true;
+ database = { inherit type; };
+ disableRegistration = true;
+ };
+ environment.systemPackages = [ pkgs.gitea pkgs.jq ];
+ services.openssh.enable = true;
+ };
+ client1 = { config, pkgs, ... }: {
+ environment.systemPackages = [ pkgs.git ];
+ };
+ client2 = { config, pkgs, ... }: {
+ environment.systemPackages = [ pkgs.git ];
};
+ };
+
+ testScript = let
+ inherit (import ./ssh-keys.nix pkgs) snakeOilPrivateKey snakeOilPublicKey;
+ in ''
+ GIT_SSH_COMMAND = "ssh -i $HOME/.ssh/privk -o StrictHostKeyChecking=no"
+ REPO = "gitea@server:test/repo"
+ PRIVK = "${snakeOilPrivateKey}"
- testScript = ''
start_all()
- machine.wait_for_unit("gitea.service")
- machine.wait_for_open_port(3000)
- machine.succeed("curl --fail http://localhost:3000/")
- '';
- };
+ client1.succeed("mkdir /tmp/repo")
+ client1.succeed("mkdir -p $HOME/.ssh")
+ client1.succeed(f"cat {PRIVK} > $HOME/.ssh/privk")
+ client1.succeed("chmod 0400 $HOME/.ssh/privk")
+ client1.succeed("git -C /tmp/repo init")
+ client1.succeed("echo hello world > /tmp/repo/testfile")
+ client1.succeed("git -C /tmp/repo add .")
+ client1.succeed("git config --global user.email test@localhost")
+ client1.succeed("git config --global user.name test")
+ client1.succeed("git -C /tmp/repo commit -m 'Initial import'")
+ client1.succeed(f"git -C /tmp/repo remote add origin {REPO}")
- postgres = makeTest {
- name = "gitea-postgres";
- meta.maintainers = [ maintainers.aanderse ];
+ server.wait_for_unit("gitea.service")
+ server.wait_for_open_port(3000)
+ server.succeed("curl --fail http://localhost:3000/")
- machine =
- { config, pkgs, ... }:
- { services.gitea.enable = true;
- services.gitea.database.type = "postgres";
- };
+ server.succeed(
+ "curl --fail http://localhost:3000/user/sign_up | grep 'Registration is disabled. "
+ + "Please contact your site administrator.'"
+ )
+ server.succeed(
+ "su -l gitea -c 'GITEA_WORK_DIR=/var/lib/gitea gitea admin create-user "
+ + "--username test --password totallysafe --email test@localhost'"
+ )
- testScript = ''
- start_all()
+ api_token = server.succeed(
+ "curl --fail -X POST http://test:totallysafe@localhost:3000/api/v1/users/test/tokens "
+ + "-H 'Accept: application/json' -H 'Content-Type: application/json' -d "
+ + "'{\"name\":\"token\"}' | jq '.sha1' | xargs echo -n"
+ )
- machine.wait_for_unit("gitea.service")
- machine.wait_for_open_port(3000)
- machine.succeed("curl --fail http://localhost:3000/")
- '';
- };
+ server.succeed(
+ "curl --fail -X POST http://localhost:3000/api/v1/user/repos "
+ + "-H 'Accept: application/json' -H 'Content-Type: application/json' "
+ + f"-H 'Authorization: token {api_token}'"
+ + ' -d \'{"auto_init":false, "description":"string", "license":"mit", "name":"repo", "private":false}\'''
+ )
- sqlite = makeTest {
- name = "gitea-sqlite";
- meta.maintainers = [ maintainers.aanderse ];
+ server.succeed(
+ "curl --fail -X POST http://localhost:3000/api/v1/user/keys "
+ + "-H 'Accept: application/json' -H 'Content-Type: application/json' "
+ + f"-H 'Authorization: token {api_token}'"
+ + ' -d \'{"key":"${snakeOilPublicKey}","read_only":true,"title":"SSH"}\'''
+ )
- machine =
- { config, pkgs, ... }:
- { services.gitea.enable = true;
- services.gitea.disableRegistration = true;
- };
+ client1.succeed(
+ f"GIT_SSH_COMMAND='{GIT_SSH_COMMAND}' git -C /tmp/repo push origin master"
+ )
- testScript = ''
- start_all()
+ client2.succeed("mkdir -p $HOME/.ssh")
+ client2.succeed(f"cat {PRIVK} > $HOME/.ssh/privk")
+ client2.succeed("chmod 0400 $HOME/.ssh/privk")
+ client2.succeed(f"GIT_SSH_COMMAND='{GIT_SSH_COMMAND}' git clone {REPO}")
+ client2.succeed('test "$(cat repo/testfile | xargs echo -n)" = "hello world"')
- machine.wait_for_unit("gitea.service")
- machine.wait_for_open_port(3000)
- machine.succeed("curl --fail http://localhost:3000/")
- machine.succeed(
- "curl --fail http://localhost:3000/user/sign_up | grep 'Registration is disabled. Please contact your site administrator.'"
+ server.succeed(
+ 'test "$(curl http://localhost:3000/api/v1/repos/test/repo/commits '
+ + '-H "Accept: application/json" | jq length)" = "1"'
)
+
+ client1.shutdown()
+ client2.shutdown()
+ server.shutdown()
'';
- };
-}
+ });
+in
+
+listToAttrs (map makeGiteaTest supportedDbTypes)
diff --git a/nixpkgs/nixos/tests/gitolite-fcgiwrap.nix b/nixpkgs/nixos/tests/gitolite-fcgiwrap.nix
new file mode 100644
index 00000000000..414b7d6fe7e
--- /dev/null
+++ b/nixpkgs/nixos/tests/gitolite-fcgiwrap.nix
@@ -0,0 +1,93 @@
+import ./make-test-python.nix (
+ { pkgs, ... }:
+
+ let
+ user = "gitolite-admin";
+ password = "some_password";
+
+ # not used but needed to setup gitolite
+ adminPublicKey = ''
+ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO7urFhAA90BTpGuEHeWWTY3W/g9PBxXNxfWhfbrm4Le root@client
+ '';
+ in
+ {
+ name = "gitolite-fcgiwrap";
+
+ meta = with pkgs.stdenv.lib.maintainers; {
+ maintainers = [ bbigras ];
+ };
+
+ nodes = {
+
+ server =
+ { ... }:
+ {
+ networking.firewall.allowedTCPPorts = [ 80 ];
+
+ services.fcgiwrap.enable = true;
+ services.gitolite = {
+ enable = true;
+ adminPubkey = adminPublicKey;
+ };
+
+ services.nginx = {
+ enable = true;
+ recommendedProxySettings = true;
+ virtualHosts."server".locations."/git".extraConfig = ''
+ # turn off gzip as git objects are already well compressed
+ gzip off;
+
+ # use file based basic authentication
+ auth_basic "Git Repository Authentication";
+ auth_basic_user_file /etc/gitolite/htpasswd;
+
+ # common FastCGI parameters are required
+ include ${pkgs.nginx}/conf/fastcgi_params;
+
+ # strip the CGI program prefix
+ fastcgi_split_path_info ^(/git)(.*)$;
+ fastcgi_param PATH_INFO $fastcgi_path_info;
+
+ # pass authenticated user login(mandatory) to Gitolite
+ fastcgi_param REMOTE_USER $remote_user;
+
+ # pass git repository root directory and hosting user directory
+ # these env variables can be set in a wrapper script
+ fastcgi_param GIT_HTTP_EXPORT_ALL "";
+ fastcgi_param GIT_PROJECT_ROOT /var/lib/gitolite/repositories;
+ fastcgi_param GITOLITE_HTTP_HOME /var/lib/gitolite;
+ fastcgi_param SCRIPT_FILENAME ${pkgs.gitolite}/bin/gitolite-shell;
+
+ # use Unix domain socket or inet socket
+ fastcgi_pass unix:/run/fcgiwrap.sock;
+ '';
+ };
+
+ # WARNING: DON'T DO THIS IN PRODUCTION!
+ # This puts unhashed secrets directly into the Nix store for ease of testing.
+ environment.etc."gitolite/htpasswd".source = pkgs.runCommand "htpasswd" {} ''
+ ${pkgs.apacheHttpd}/bin/htpasswd -bc "$out" ${user} ${password}
+ '';
+ };
+
+ client =
+ { pkgs, ... }:
+ {
+ environment.systemPackages = [ pkgs.git ];
+ };
+ };
+
+ testScript = ''
+ start_all()
+
+ server.wait_for_unit("gitolite-init.service")
+ server.wait_for_unit("nginx.service")
+ server.wait_for_file("/run/fcgiwrap.sock")
+
+ client.wait_for_unit("multi-user.target")
+ client.succeed(
+ "git clone http://${user}:${password}@server/git/gitolite-admin.git"
+ )
+ '';
+ }
+)
diff --git a/nixpkgs/nixos/tests/gnome3-xorg.nix b/nixpkgs/nixos/tests/gnome3-xorg.nix
index eb4c376319b..f793bb922ad 100644
--- a/nixpkgs/nixos/tests/gnome3-xorg.nix
+++ b/nixpkgs/nixos/tests/gnome3-xorg.nix
@@ -1,41 +1,79 @@
-import ./make-test.nix ({ pkgs, ...} : {
+import ./make-test-python.nix ({ pkgs, ...} : {
name = "gnome3-xorg";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = pkgs.gnome3.maintainers;
};
- machine =
- { ... }:
+ machine = { nodes, ... }: let
+ user = nodes.machine.config.users.users.alice;
+ in
{ imports = [ ./common/user-account.nix ];
services.xserver.enable = true;
- services.xserver.displayManager.gdm.enable = false;
- services.xserver.displayManager.lightdm.enable = true;
- services.xserver.displayManager.lightdm.autoLogin.enable = true;
- services.xserver.displayManager.lightdm.autoLogin.user = "alice";
+ services.xserver.displayManager.gdm = {
+ enable = true;
+ autoLogin = {
+ enable = true;
+ user = user.name;
+ };
+ };
+
services.xserver.desktopManager.gnome3.enable = true;
- services.xserver.desktopManager.default = "gnome-xorg";
+ services.xserver.displayManager.defaultSession = "gnome-xorg";
virtualisation.memorySize = 1024;
};
- testScript =
- ''
- $machine->waitForX;
+ testScript = { nodes, ... }: let
+ user = nodes.machine.config.users.users.alice;
+ uid = toString user.uid;
+ bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${uid}/bus";
+ xauthority = "/run/user/${uid}/gdm/Xauthority";
+ display = "DISPLAY=:0.0";
+ env = "${bus} XAUTHORITY=${xauthority} ${display}";
+ gdbus = "${env} gdbus";
+ su = command: "su - ${user.name} -c '${env} ${command}'";
+
+ # Call javascript in gnome shell, returns a tuple (success, output), where
+ # `success` is true if the dbus call was successful and output is what the
+ # javascript evaluates to.
+ eval = "call --session -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval";
+
+ # False when startup is done
+ startingUp = su "${gdbus} ${eval} Main.layoutManager._startingUp";
+
+ # Start gnome-terminal
+ gnomeTerminalCommand = su "gnome-terminal";
- # wait for alice to be logged in
- $machine->waitForUnit("default.target","alice");
+ # Hopefully gnome-terminal's wm class
+ wmClass = su "${gdbus} ${eval} global.display.focus_window.wm_class";
+ in ''
+ with subtest("Login to GNOME Xorg with GDM"):
+ machine.wait_for_x()
+ # Wait for alice to be logged in"
+ machine.wait_for_unit("default.target", "${user.name}")
+ machine.wait_for_file("${xauthority}")
+ machine.succeed("xauth merge ${xauthority}")
+ # Check that logging in has given the user ownership of devices
+ assert "alice" in machine.succeed("getfacl -p /dev/snd/timer")
- # Check that logging in has given the user ownership of devices.
- $machine->succeed("getfacl -p /dev/snd/timer | grep -q alice");
+ with subtest("Wait for GNOME Shell"):
+ # correct output should be (true, 'false')
+ machine.wait_until_succeeds(
+ "${startingUp} | grep -q 'true,..false'"
+ )
- $machine->succeed("su - alice -c 'DISPLAY=:0.0 gnome-terminal &'");
- $machine->succeed("xauth merge ~alice/.Xauthority");
- $machine->waitForWindow(qr/alice.*machine/);
- $machine->succeed("timeout 900 bash -c 'while read msg; do if [[ \$msg =~ \"GNOME Shell started\" ]]; then break; fi; done < <(journalctl -f)'");
- $machine->sleep(10);
- $machine->screenshot("screen");
+ with subtest("Open Gnome Terminal"):
+ machine.succeed(
+ "${gnomeTerminalCommand}"
+ )
+ # correct output should be (true, '"Gnome-terminal"')
+ machine.wait_until_succeeds(
+ "${wmClass} | grep -q 'true,...Gnome-terminal'"
+ )
+ machine.sleep(20)
+ machine.screenshot("screen")
'';
})
diff --git a/nixpkgs/nixos/tests/gocd-agent.nix b/nixpkgs/nixos/tests/gocd-agent.nix
index 50470379576..5b630a40736 100644
--- a/nixpkgs/nixos/tests/gocd-agent.nix
+++ b/nixpkgs/nixos/tests/gocd-agent.nix
@@ -9,14 +9,18 @@ let
header = "Accept: application/vnd.go.cd.v2+json";
in
-import ./make-test.nix ({ pkgs, ...} : {
+import ./make-test-python.nix ({ pkgs, ...} : {
name = "gocd-agent";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ grahamc swarren83 ];
+
+ # gocd agent needs to register with the autoregister key created on first server startup,
+ # but NixOS module doesn't seem to allow to pass during runtime currently
+ broken = true;
};
nodes = {
- gocd_agent =
+ agent =
{ ... }:
{
virtualisation.memorySize = 2046;
@@ -30,11 +34,15 @@ import ./make-test.nix ({ pkgs, ...} : {
};
testScript = ''
- startAll;
- $gocd_agent->waitForUnit("gocd-server");
- $gocd_agent->waitForOpenPort("8153");
- $gocd_agent->waitForUnit("gocd-agent");
- $gocd_agent->waitUntilSucceeds("curl ${serverUrl} -H '${header}' | ${pkgs.jq}/bin/jq -e ._embedded.agents[0].uuid");
- $gocd_agent->succeed("curl ${serverUrl} -H '${header}' | ${pkgs.jq}/bin/jq -e ._embedded.agents[0].agent_state | grep -q Idle");
+ start_all()
+ agent.wait_for_unit("gocd-server")
+ agent.wait_for_open_port("8153")
+ agent.wait_for_unit("gocd-agent")
+ agent.wait_until_succeeds(
+ "curl ${serverUrl} -H '${header}' | ${pkgs.jq}/bin/jq -e ._embedded.agents[0].uuid"
+ )
+ agent.succeed(
+ "curl ${serverUrl} -H '${header}' | ${pkgs.jq}/bin/jq -e ._embedded.agents[0].agent_state | grep -q Idle"
+ )
'';
})
diff --git a/nixpkgs/nixos/tests/gocd-server.nix b/nixpkgs/nixos/tests/gocd-server.nix
index 80cf04ed640..20faf85a1cc 100644
--- a/nixpkgs/nixos/tests/gocd-server.nix
+++ b/nixpkgs/nixos/tests/gocd-server.nix
@@ -2,7 +2,7 @@
# 1. GoCD server starts
# 2. GoCD server responds
-import ./make-test.nix ({ pkgs, ...} :
+import ./make-test-python.nix ({ pkgs, ...} :
{
name = "gocd-server";
@@ -10,19 +10,19 @@ import ./make-test.nix ({ pkgs, ...} :
maintainers = [ swarren83 ];
};
-nodes = {
- gocd_server =
- { ... }:
- {
- virtualisation.memorySize = 2046;
- services.gocd-server.enable = true;
- };
-};
+ nodes = {
+ server =
+ { ... }:
+ {
+ virtualisation.memorySize = 2046;
+ services.gocd-server.enable = true;
+ };
+ };
testScript = ''
- $gocd_server->start;
- $gocd_server->waitForUnit("gocd-server");
- $gocd_server->waitForOpenPort("8153");
- $gocd_server->waitUntilSucceeds("curl -s -f localhost:8153/go");
+ server.start()
+ server.wait_for_unit("gocd-server")
+ server.wait_for_open_port(8153)
+ server.wait_until_succeeds("curl -s -f localhost:8153/go")
'';
})
diff --git a/nixpkgs/nixos/tests/gvisor.nix b/nixpkgs/nixos/tests/gvisor.nix
new file mode 100644
index 00000000000..4d68a1d8a5f
--- /dev/null
+++ b/nixpkgs/nixos/tests/gvisor.nix
@@ -0,0 +1,49 @@
+# This test runs a container through gvisor and checks if simple container starts
+
+import ./make-test-python.nix ({ pkgs, ...} : {
+ name = "gvisor";
+ meta = with pkgs.stdenv.lib.maintainers; {
+ maintainers = [ andrew-d ];
+ };
+
+ nodes = {
+ gvisor =
+ { pkgs, ... }:
+ {
+ virtualisation.docker = {
+ enable = true;
+ extraOptions = "--add-runtime runsc=${pkgs.gvisor}/bin/runsc";
+ };
+
+ networking = {
+ dhcpcd.enable = false;
+ defaultGateway = "192.168.1.1";
+ interfaces.eth1.ipv4.addresses = pkgs.lib.mkOverride 0 [
+ { address = "192.168.1.2"; prefixLength = 24; }
+ ];
+ };
+ };
+ };
+
+ testScript = ''
+ start_all()
+
+ gvisor.wait_for_unit("network.target")
+ gvisor.wait_for_unit("sockets.target")
+
+ # Start by verifying that gvisor itself works
+ output = gvisor.succeed(
+ "${pkgs.gvisor}/bin/runsc -alsologtostderr do ${pkgs.coreutils}/bin/echo hello world"
+ )
+ assert output.strip() == "hello world"
+
+ # Also test the Docker runtime
+ gvisor.succeed("tar cv --files-from /dev/null | docker import - scratchimg")
+ gvisor.succeed(
+ "docker run -d --name=sleeping --runtime=runsc -v /nix/store:/nix/store -v /run/current-system/sw/bin:/bin scratchimg /bin/sleep 10"
+ )
+ gvisor.succeed("docker ps | grep sleeping")
+ gvisor.succeed("docker stop sleeping")
+ '';
+})
+
diff --git a/nixpkgs/nixos/tests/hadoop/hdfs.nix b/nixpkgs/nixos/tests/hadoop/hdfs.nix
index e7d72a56e1e..85aaab34b15 100644
--- a/nixpkgs/nixos/tests/hadoop/hdfs.nix
+++ b/nixpkgs/nixos/tests/hadoop/hdfs.nix
@@ -1,4 +1,4 @@
-import ../make-test.nix ({...}: {
+import ../make-test-python.nix ({...}: {
nodes = {
namenode = {pkgs, ...}: {
services.hadoop = {
@@ -35,20 +35,20 @@ import ../make-test.nix ({...}: {
};
testScript = ''
- startAll
+ start_all()
- $namenode->waitForUnit("hdfs-namenode");
- $namenode->waitForUnit("network.target");
- $namenode->waitForOpenPort(8020);
- $namenode->waitForOpenPort(9870);
+ namenode.wait_for_unit("hdfs-namenode")
+ namenode.wait_for_unit("network.target")
+ namenode.wait_for_open_port(8020)
+ namenode.wait_for_open_port(9870)
- $datanode->waitForUnit("hdfs-datanode");
- $datanode->waitForUnit("network.target");
- $datanode->waitForOpenPort(9864);
- $datanode->waitForOpenPort(9866);
- $datanode->waitForOpenPort(9867);
+ datanode.wait_for_unit("hdfs-datanode")
+ datanode.wait_for_unit("network.target")
+ datanode.wait_for_open_port(9864)
+ datanode.wait_for_open_port(9866)
+ datanode.wait_for_open_port(9867)
- $namenode->succeed("curl http://namenode:9870");
- $datanode->succeed("curl http://datanode:9864");
+ namenode.succeed("curl http://namenode:9870")
+ datanode.succeed("curl http://datanode:9864")
'';
})
diff --git a/nixpkgs/nixos/tests/hadoop/yarn.nix b/nixpkgs/nixos/tests/hadoop/yarn.nix
index 031592301f1..2264ecaff15 100644
--- a/nixpkgs/nixos/tests/hadoop/yarn.nix
+++ b/nixpkgs/nixos/tests/hadoop/yarn.nix
@@ -1,4 +1,4 @@
-import ../make-test.nix ({...}: {
+import ../make-test-python.nix ({...}: {
nodes = {
resourcemanager = {pkgs, ...}: {
services.hadoop.package = pkgs.hadoop_3_1;
@@ -28,19 +28,19 @@ import ../make-test.nix ({...}: {
};
testScript = ''
- startAll;
+ start_all()
- $resourcemanager->waitForUnit("yarn-resourcemanager");
- $resourcemanager->waitForUnit("network.target");
- $resourcemanager->waitForOpenPort(8031);
- $resourcemanager->waitForOpenPort(8088);
+ resourcemanager.wait_for_unit("yarn-resourcemanager")
+ resourcemanager.wait_for_unit("network.target")
+ resourcemanager.wait_for_open_port(8031)
+ resourcemanager.wait_for_open_port(8088)
- $nodemanager->waitForUnit("yarn-nodemanager");
- $nodemanager->waitForUnit("network.target");
- $nodemanager->waitForOpenPort(8042);
- $nodemanager->waitForOpenPort(8041);
+ nodemanager.wait_for_unit("yarn-nodemanager")
+ nodemanager.wait_for_unit("network.target")
+ nodemanager.wait_for_open_port(8042)
+ nodemanager.wait_for_open_port(8041)
- $resourcemanager->succeed("curl http://localhost:8088");
- $nodemanager->succeed("curl http://localhost:8042");
+ resourcemanager.succeed("curl http://localhost:8088")
+ nodemanager.succeed("curl http://localhost:8042")
'';
})
diff --git a/nixpkgs/nixos/tests/haka.nix b/nixpkgs/nixos/tests/haka.nix
index 6277ebb4933..3ca19cb0971 100644
--- a/nixpkgs/nixos/tests/haka.nix
+++ b/nixpkgs/nixos/tests/haka.nix
@@ -1,6 +1,6 @@
# This test runs haka and probes it with hakactl
-import ./make-test.nix ({ pkgs, ...} : {
+import ./make-test-python.nix ({ pkgs, ...} : {
name = "haka";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ tvestelind ];
@@ -15,10 +15,10 @@ import ./make-test.nix ({ pkgs, ...} : {
};
testScript = ''
- startAll;
+ start_all()
- $haka->waitForUnit("haka.service");
- $haka->succeed("hakactl status");
- $haka->succeed("hakactl stop");
+ haka.wait_for_unit("haka.service")
+ haka.succeed("hakactl status")
+ haka.succeed("hakactl stop")
'';
})
diff --git a/nixpkgs/nixos/tests/haproxy.nix b/nixpkgs/nixos/tests/haproxy.nix
index 72e77a68193..79f34b07faf 100644
--- a/nixpkgs/nixos/tests/haproxy.nix
+++ b/nixpkgs/nixos/tests/haproxy.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ pkgs, ...}: {
+import ./make-test-python.nix ({ pkgs, ...}: {
name = "haproxy";
nodes = {
machine = { ... }: {
@@ -23,21 +23,25 @@ import ./make-test.nix ({ pkgs, ...}: {
};
services.httpd = {
enable = true;
- documentRoot = pkgs.writeTextDir "index.txt" "We are all good!";
- adminAddr = "notme@yourhost.local";
- listen = [{
- ip = "::1";
- port = 8000;
- }];
+ virtualHosts.localhost = {
+ documentRoot = pkgs.writeTextDir "index.txt" "We are all good!";
+ adminAddr = "notme@yourhost.local";
+ listen = [{
+ ip = "::1";
+ port = 8000;
+ }];
+ };
};
};
};
testScript = ''
- startAll;
- $machine->waitForUnit('multi-user.target');
- $machine->waitForUnit('haproxy.service');
- $machine->waitForUnit('httpd.service');
- $machine->succeed('curl -k http://localhost:80/index.txt | grep "We are all good!"');
- $machine->succeed('curl -k http://localhost:80/metrics | grep haproxy_process_pool_allocated_bytes');
+ start_all()
+ machine.wait_for_unit("multi-user.target")
+ machine.wait_for_unit("haproxy.service")
+ machine.wait_for_unit("httpd.service")
+ assert "We are all good!" in machine.succeed("curl -k http://localhost:80/index.txt")
+ assert "haproxy_process_pool_allocated_bytes" in machine.succeed(
+ "curl -k http://localhost:80/metrics"
+ )
'';
})
diff --git a/nixpkgs/nixos/tests/hitch/default.nix b/nixpkgs/nixos/tests/hitch/default.nix
index cb24c4dcffc..904d12619d7 100644
--- a/nixpkgs/nixos/tests/hitch/default.nix
+++ b/nixpkgs/nixos/tests/hitch/default.nix
@@ -1,4 +1,4 @@
-import ../make-test.nix ({ pkgs, ... }:
+import ../make-test-python.nix ({ pkgs, ... }:
{
name = "hitch";
meta = with pkgs.stdenv.lib.maintainers; {
@@ -16,18 +16,18 @@ import ../make-test.nix ({ pkgs, ... }:
services.httpd = {
enable = true;
- documentRoot = ./example;
+ virtualHosts.localhost.documentRoot = ./example;
adminAddr = "noone@testing.nowhere";
};
};
testScript =
''
- startAll;
+ start_all()
- $machine->waitForUnit('multi-user.target');
- $machine->waitForUnit('hitch.service');
- $machine->waitForOpenPort(443);
- $machine->succeed('curl -k https://localhost:443/index.txt | grep "We are all good!"');
+ machine.wait_for_unit("multi-user.target")
+ machine.wait_for_unit("hitch.service")
+ machine.wait_for_open_port(443)
+ assert "We are all good!" in machine.succeed("curl -k https://localhost:443/index.txt")
'';
})
diff --git a/nixpkgs/nixos/tests/home-assistant.nix b/nixpkgs/nixos/tests/home-assistant.nix
index 6b53914fd85..80dca43f1f3 100644
--- a/nixpkgs/nixos/tests/home-assistant.nix
+++ b/nixpkgs/nixos/tests/home-assistant.nix
@@ -1,11 +1,10 @@
-import ./make-test.nix ({ pkgs, ... }:
+import ./make-test-python.nix ({ pkgs, ... }:
let
configDir = "/var/lib/foobar";
apiPassword = "some_secret";
mqttPassword = "another_secret";
hassCli = "hass-cli --server http://hass:8123 --password '${apiPassword}'";
-
in {
name = "home-assistant";
meta = with pkgs.stdenv.lib; {
@@ -69,36 +68,44 @@ in {
};
testScript = ''
- startAll;
- $hass->waitForUnit("home-assistant.service");
-
- # The config is specified using a Nix attribute set,
- # converted from JSON to YAML, and linked to the config dir
- $hass->succeed("test -L ${configDir}/configuration.yaml");
- # The lovelace config is copied because lovelaceConfigWritable = true
- $hass->succeed("test -f ${configDir}/ui-lovelace.yaml");
-
- # Check that Home Assistant's web interface and API can be reached
- $hass->waitForOpenPort(8123);
- $hass->succeed("curl --fail http://localhost:8123/states");
- $hass->succeed("curl --fail -H 'x-ha-access: ${apiPassword}' http://localhost:8123/api/ | grep -qF 'API running'");
-
- # Toggle a binary sensor using MQTT
- $hass->succeed("curl http://localhost:8123/api/states/binary_sensor.mqtt_binary_sensor -H 'x-ha-access: ${apiPassword}' | grep -qF '\"state\": \"off\"'");
- $hass->waitUntilSucceeds("mosquitto_pub -V mqttv311 -t home-assistant/test -u homeassistant -P '${mqttPassword}' -m let_there_be_light");
- $hass->succeed("curl http://localhost:8123/api/states/binary_sensor.mqtt_binary_sensor -H 'x-ha-access: ${apiPassword}' | grep -qF '\"state\": \"on\"'");
-
- # Toggle a binary sensor using hass-cli
- $hass->succeed("${hassCli} --output json state get binary_sensor.mqtt_binary_sensor | grep -qF '\"state\": \"on\"'");
- $hass->succeed("${hassCli} state edit binary_sensor.mqtt_binary_sensor --json='{\"state\": \"off\"}'");
- $hass->succeed("curl http://localhost:8123/api/states/binary_sensor.mqtt_binary_sensor -H 'x-ha-access: ${apiPassword}' | grep -qF '\"state\": \"off\"'");
-
- # Print log to ease debugging
- my $log = $hass->succeed("cat ${configDir}/home-assistant.log");
- print "\n### home-assistant.log ###\n";
- print "$log\n";
+ start_all()
+ hass.wait_for_unit("home-assistant.service")
+ with subtest("Check that YAML configuration file is in place"):
+ hass.succeed("test -L ${configDir}/configuration.yaml")
+ with subtest("lovelace config is copied because lovelaceConfigWritable = true"):
+ hass.succeed("test -f ${configDir}/ui-lovelace.yaml")
+ with subtest("Check that Home Assistant's web interface and API can be reached"):
+ hass.wait_for_open_port(8123)
+ hass.succeed("curl --fail http://localhost:8123/states")
+ assert "API running" in hass.succeed(
+ "curl --fail -H 'x-ha-access: ${apiPassword}' http://localhost:8123/api/"
+ )
+ with subtest("Toggle a binary sensor using MQTT"):
+ assert '"state": "off"' in hass.succeed(
+ "curl http://localhost:8123/api/states/binary_sensor.mqtt_binary_sensor -H 'x-ha-access: ${apiPassword}'"
+ )
+ hass.wait_until_succeeds(
+ "mosquitto_pub -V mqttv311 -t home-assistant/test -u homeassistant -P '${mqttPassword}' -m let_there_be_light"
+ )
+ assert '"state": "on"' in hass.succeed(
+ "curl http://localhost:8123/api/states/binary_sensor.mqtt_binary_sensor -H 'x-ha-access: ${apiPassword}'"
+ )
+ with subtest("Toggle a binary sensor using hass-cli"):
+ assert '"state": "on"' in hass.succeed(
+ "${hassCli} --output json state get binary_sensor.mqtt_binary_sensor"
+ )
+ hass.succeed(
+ "${hassCli} state edit binary_sensor.mqtt_binary_sensor --json='{\"state\": \"off\"}'"
+ )
+ assert '"state": "off"' in hass.succeed(
+ "curl http://localhost:8123/api/states/binary_sensor.mqtt_binary_sensor -H 'x-ha-access: ${apiPassword}'"
+ )
+ with subtest("Print log to ease debugging"):
+ output_log = hass.succeed("cat ${configDir}/home-assistant.log")
+ print("\n### home-assistant.log ###\n")
+ print(output_log + "\n")
- # Check that no errors were logged
- $hass->fail("cat ${configDir}/home-assistant.log | grep -qF ERROR");
+ with subtest("Check that no errors were logged"):
+ assert "ERROR" not in output_log
'';
})
diff --git a/nixpkgs/nixos/tests/hydra/default.nix b/nixpkgs/nixos/tests/hydra/default.nix
index 6ca05a2c779..1c0ed3369b1 100644
--- a/nixpkgs/nixos/tests/hydra/default.nix
+++ b/nixpkgs/nixos/tests/hydra/default.nix
@@ -30,11 +30,11 @@ let
callTest = f: f { inherit system pkgs; };
hydraPkgs = {
- inherit (pkgs) nixStable nixUnstable;
+ inherit (pkgs) nixStable nixUnstable nixFlakes;
};
tests = pkgs.lib.flip pkgs.lib.mapAttrs hydraPkgs (name: nix:
- callTest (import ../make-test.nix ({ pkgs, lib, ... }:
+ callTest (import ../make-test-python.nix ({ pkgs, lib, ... }:
{
name = "hydra-with-${name}";
meta = with pkgs.stdenv.lib.maintainers; {
@@ -73,26 +73,30 @@ let
testScript = ''
# let the system boot up
- $machine->waitForUnit("multi-user.target");
+ machine.wait_for_unit("multi-user.target")
# test whether the database is running
- $machine->waitForUnit("postgresql.service");
+ machine.wait_for_unit("postgresql.service")
# test whether the actual hydra daemons are running
- $machine->waitForUnit("hydra-init.service");
- $machine->requireActiveUnit("hydra-queue-runner.service");
- $machine->requireActiveUnit("hydra-evaluator.service");
- $machine->requireActiveUnit("hydra-notify.service");
+ machine.wait_for_unit("hydra-init.service")
+ machine.require_unit_state("hydra-queue-runner.service")
+ machine.require_unit_state("hydra-evaluator.service")
+ machine.require_unit_state("hydra-notify.service")
- $machine->succeed("hydra-create-user admin --role admin --password admin");
+ machine.succeed("hydra-create-user admin --role admin --password admin")
# create a project with a trivial job
- $machine->waitForOpenPort(3000);
+ machine.wait_for_open_port(3000)
# make sure the build as been successfully built
- $machine->succeed("create-trivial-project.sh");
+ machine.succeed("create-trivial-project.sh")
- $machine->waitUntilSucceeds('curl -L -s http://localhost:3000/build/1 -H "Accept: application/json" | jq .buildstatus | xargs test 0 -eq');
+ machine.wait_until_succeeds(
+ 'curl -L -s http://localhost:3000/build/1 -H "Accept: application/json" | jq .buildstatus | xargs test 0 -eq'
+ )
- $machine->waitUntilSucceeds('journalctl -eu hydra-notify.service -o cat | grep -q "sending mail notification to hydra@localhost"');
+ machine.wait_until_succeeds(
+ 'journalctl -eu hydra-notify.service -o cat | grep -q "sending mail notification to hydra@localhost"'
+ )
'';
})));
diff --git a/nixpkgs/nixos/tests/i3wm.nix b/nixpkgs/nixos/tests/i3wm.nix
index d309f19a0b4..126178d1187 100644
--- a/nixpkgs/nixos/tests/i3wm.nix
+++ b/nixpkgs/nixos/tests/i3wm.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ pkgs, ...} : {
+import ./make-test-python.nix ({ pkgs, ...} : {
name = "i3wm";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ aszlig ];
@@ -7,29 +7,40 @@ import ./make-test.nix ({ pkgs, ...} : {
machine = { lib, ... }: {
imports = [ ./common/x11.nix ./common/user-account.nix ];
services.xserver.displayManager.auto.user = "alice";
- services.xserver.windowManager.default = lib.mkForce "i3";
+ services.xserver.displayManager.defaultSession = lib.mkForce "none+i3";
services.xserver.windowManager.i3.enable = true;
};
testScript = { ... }: ''
- $machine->waitForX;
- $machine->waitForFile("/home/alice/.Xauthority");
- $machine->succeed("xauth merge ~alice/.Xauthority");
- $machine->waitForWindow(qr/first configuration/);
- $machine->sleep(2);
- $machine->screenshot("started");
- $machine->sendKeys("ret");
- $machine->sleep(2);
- $machine->sendKeys("alt");
- $machine->sleep(2);
- $machine->screenshot("configured");
- $machine->sendKeys("ret");
- # make sure the config file is created before we continue
- $machine->waitForFile("/home/alice/.config/i3/config");
- $machine->sleep(2);
- $machine->sendKeys("alt-ret");
- $machine->waitForWindow(qr/alice.*machine/);
- $machine->sleep(2);
- $machine->screenshot("terminal");
+ with subtest("ensure x starts"):
+ machine.wait_for_x()
+ machine.wait_for_file("/home/alice/.Xauthority")
+ machine.succeed("xauth merge ~alice/.Xauthority")
+
+ with subtest("ensure we get first configuration window"):
+ machine.wait_for_window(r".*?first configuration.*?")
+ machine.sleep(2)
+ machine.screenshot("started")
+
+ with subtest("ensure we generate and save a config"):
+ # press return to indicate we want to gen a new config
+ machine.send_key("\n")
+ machine.sleep(2)
+ machine.screenshot("preconfig")
+ # press alt then return to indicate we want to use alt as our Mod key
+ machine.send_key("alt")
+ machine.send_key("\n")
+ machine.sleep(2)
+ # make sure the config file is created before we continue
+ machine.wait_for_file("/home/alice/.config/i3/config")
+ machine.screenshot("postconfig")
+ machine.sleep(2)
+
+ with subtest("ensure we can open a new terminal"):
+ machine.send_key("alt-ret")
+ machine.sleep(2)
+ machine.wait_for_window(r"alice.*?machine")
+ machine.sleep(2)
+ machine.screenshot("terminal")
'';
})
diff --git a/nixpkgs/nixos/tests/ihatemoney.nix b/nixpkgs/nixos/tests/ihatemoney.nix
new file mode 100644
index 00000000000..14db17fe5e6
--- /dev/null
+++ b/nixpkgs/nixos/tests/ihatemoney.nix
@@ -0,0 +1,52 @@
+{ system ? builtins.currentSystem
+, config ? {}
+, pkgs ? import ../.. { inherit system config; }
+}:
+
+let
+ inherit (import ../lib/testing.nix { inherit system pkgs; }) makeTest;
+in
+map (
+ backend: makeTest {
+ name = "ihatemoney-${backend}";
+ machine = { lib, ... }: {
+ services.ihatemoney = {
+ enable = true;
+ enablePublicProjectCreation = true;
+ inherit backend;
+ uwsgiConfig = {
+ http = ":8000";
+ };
+ };
+ boot.cleanTmpDir = true;
+ # ihatemoney needs a local smtp server otherwise project creation just crashes
+ services.opensmtpd = {
+ enable = true;
+ serverConfiguration = ''
+ listen on lo
+ action foo relay
+ match from any for any action foo
+ '';
+ };
+ };
+ testScript = ''
+ $machine->waitForOpenPort(8000);
+ $machine->waitForUnit("uwsgi.service");
+ my $return = $machine->succeed("curl -X POST http://localhost:8000/api/projects -d 'name=yay&id=yay&password=yay&contact_email=yay\@example.com'");
+ die "wrong project id $return" unless "\"yay\"\n" eq $return;
+ my $timestamp = $machine->succeed("stat --printf %Y /var/lib/ihatemoney/secret_key");
+ my $owner = $machine->succeed("stat --printf %U:%G /var/lib/ihatemoney/secret_key");
+ die "wrong ownership for the secret key: $owner, is uwsgi running as the right user ?" unless $owner eq "ihatemoney:ihatemoney";
+ $machine->shutdown();
+ $machine->start();
+ $machine->waitForOpenPort(8000);
+ $machine->waitForUnit("uwsgi.service");
+ # check that the database is really persistent
+ print $machine->succeed("curl --basic -u yay:yay http://localhost:8000/api/projects/yay");
+ # check that the secret key is really persistent
+ my $timestamp2 = $machine->succeed("stat --printf %Y /var/lib/ihatemoney/secret_key");
+ die unless $timestamp eq $timestamp2;
+ $machine->succeed("curl http://localhost:8000 | grep ihatemoney");
+ '';
+ }
+) [ "sqlite" "postgresql" ]
diff --git a/nixpkgs/nixos/tests/initrd-network.nix b/nixpkgs/nixos/tests/initrd-network.nix
index ed9b82e2da7..4796ff9b7c8 100644
--- a/nixpkgs/nixos/tests/initrd-network.nix
+++ b/nixpkgs/nixos/tests/initrd-network.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ pkgs, ...} : {
+import ./make-test-python.nix ({ pkgs, ...} : {
name = "initrd-network";
meta.maintainers = [ pkgs.stdenv.lib.maintainers.eelco ];
@@ -15,8 +15,8 @@ import ./make-test.nix ({ pkgs, ...} : {
testScript =
''
- startAll;
- $machine->waitForUnit("multi-user.target");
- $machine->succeed("ip link >&2");
+ start_all()
+ machine.wait_for_unit("multi-user.target")
+ machine.succeed("ip link >&2")
'';
})
diff --git a/nixpkgs/nixos/tests/installed-tests/default.nix b/nixpkgs/nixos/tests/installed-tests/default.nix
index f4780bdcfc9..8e997ee4aeb 100644
--- a/nixpkgs/nixos/tests/installed-tests/default.nix
+++ b/nixpkgs/nixos/tests/installed-tests/default.nix
@@ -29,36 +29,51 @@ let
# Extra flags to pass to gnome-desktop-testing-runner.
, testRunnerFlags ? ""
- }:
- makeTest rec {
- name = tested.name;
-
- meta = {
- maintainers = tested.meta.maintainers;
- };
-
- machine = { ... }: {
- imports = [
- testConfig
- ] ++ optional withX11 ../common/x11.nix;
-
- environment.systemPackages = with pkgs; [ gnome-desktop-testing ];
-
- };
-
- testScript =
- optionalString withX11 ''
- machine.wait_for_x()
- '' +
- optionalString (preTestScript != "") ''
- ${preTestScript}
- '' +
- ''
- machine.succeed(
- "gnome-desktop-testing-runner ${testRunnerFlags} -d '${tested.installedTests}/share'"
- )
- '';
- };
+
+ # Extra attributes to pass to makeTest.
+ # They will be recursively merged into the attrset created by this function.
+ , ...
+ }@args:
+ makeTest
+ (recursiveUpdate
+ rec {
+ name = tested.name;
+
+ meta = {
+ maintainers = tested.meta.maintainers;
+ };
+
+ machine = { ... }: {
+ imports = [
+ testConfig
+ ] ++ optional withX11 ../common/x11.nix;
+
+ environment.systemPackages = with pkgs; [ gnome-desktop-testing ];
+
+ };
+
+ testScript =
+ optionalString withX11 ''
+ machine.wait_for_x()
+ '' +
+ optionalString (preTestScript != "") ''
+ ${preTestScript}
+ '' +
+ ''
+ machine.succeed(
+ "gnome-desktop-testing-runner ${testRunnerFlags} -d '${tested.installedTests}/share'"
+ )
+ '';
+ }
+
+ (removeAttrs args [
+ "tested"
+ "testConfig"
+ "preTestScript"
+ "withX11"
+ "testRunnerFlags"
+ ])
+ );
in
@@ -73,6 +88,7 @@ in
glib-networking = callInstalledTest ./glib-networking.nix {};
gnome-photos = callInstalledTest ./gnome-photos.nix {};
graphene = callInstalledTest ./graphene.nix {};
+ ibus = callInstalledTest ./ibus.nix {};
libgdata = callInstalledTest ./libgdata.nix {};
libxmlb = callInstalledTest ./libxmlb.nix {};
ostree = callInstalledTest ./ostree.nix {};
diff --git a/nixpkgs/nixos/tests/installed-tests/ibus.nix b/nixpkgs/nixos/tests/installed-tests/ibus.nix
new file mode 100644
index 00000000000..af54b612b50
--- /dev/null
+++ b/nixpkgs/nixos/tests/installed-tests/ibus.nix
@@ -0,0 +1,20 @@
+{ pkgs, makeInstalledTest, ... }:
+
+makeInstalledTest {
+ tested = pkgs.ibus;
+
+ testConfig = {
+ i18n.inputMethod.enabled = "ibus";
+ };
+
+ preTestScript = ''
+ # ibus has ibus-desktop-testing-runner but it tries to manage desktop session so we just spawn ibus-daemon ourselves
+ machine.succeed("ibus-daemon --daemonize --verbose")
+ '';
+
+ withX11 = true;
+
+ # TODO: ibus-daemon is currently crashing or something
+ # maybe make ibus systemd service that auto-restarts?
+ meta.broken = true;
+}
diff --git a/nixpkgs/nixos/tests/ipv6.nix b/nixpkgs/nixos/tests/ipv6.nix
index d11eba764da..ba464b57447 100644
--- a/nixpkgs/nixos/tests/ipv6.nix
+++ b/nixpkgs/nixos/tests/ipv6.nix
@@ -1,7 +1,7 @@
# Test of IPv6 functionality in NixOS, including whether router
# solicication/advertisement using radvd works.
-import ./make-test.nix ({ pkgs, lib, ...} : {
+import ./make-test-python.nix ({ pkgs, lib, ...} : {
name = "ipv6";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ eelco ];
@@ -35,51 +35,56 @@ import ./make-test.nix ({ pkgs, lib, ...} : {
testScript =
''
+ import re
+
# Start the router first so that it respond to router solicitations.
- $router->waitForUnit("radvd");
+ router.wait_for_unit("radvd")
- startAll;
+ start_all()
- $client->waitForUnit("network.target");
- $server->waitForUnit("network.target");
- $server->waitForUnit("httpd.service");
+ client.wait_for_unit("network.target")
+ server.wait_for_unit("network.target")
+ server.wait_for_unit("httpd.service")
# Wait until the given interface has a non-tentative address of
# the desired scope (i.e. has completed Duplicate Address
# Detection).
- sub waitForAddress {
- my ($machine, $iface, $scope) = @_;
- $machine->waitUntilSucceeds("[ `ip -o -6 addr show dev $iface scope $scope | grep -v tentative | wc -l` -ge 1 ]");
- my $ip = (split /[ \/]+/, $machine->succeed("ip -o -6 addr show dev $iface scope $scope"))[3];
- $machine->log("$scope address on $iface is $ip");
- return $ip;
- }
-
- subtest "loopback address", sub {
- $client->succeed("ping -c 1 ::1 >&2");
- $client->fail("ping -c 1 ::2 >&2");
- };
-
- subtest "local link addressing", sub {
- my $clientIp = waitForAddress $client, "eth1", "link";
- my $serverIp = waitForAddress $server, "eth1", "link";
- $client->succeed("ping -c 1 $clientIp%eth1 >&2");
- $client->succeed("ping -c 1 $serverIp%eth1 >&2");
- };
-
- subtest "global addressing", sub {
- my $clientIp = waitForAddress $client, "eth1", "global";
- my $serverIp = waitForAddress $server, "eth1", "global";
- $client->succeed("ping -c 1 $clientIp >&2");
- $client->succeed("ping -c 1 $serverIp >&2");
- $client->succeed("curl --fail -g http://[$serverIp]");
- $client->fail("curl --fail -g http://[$clientIp]");
- };
- subtest "privacy extensions", sub {
- my $ip = waitForAddress $client, "eth1", "global temporary";
+ def wait_for_address(machine, iface, scope, temporary=False):
+ temporary_flag = "temporary" if temporary else "-temporary"
+ cmd = f"ip -o -6 addr show dev {iface} scope {scope} -tentative {temporary_flag}"
+
+ machine.wait_until_succeeds(f"[ `{cmd} | wc -l` -eq 1 ]")
+ output = machine.succeed(cmd)
+ ip = re.search(r"inet6 ([0-9a-f:]{2,})/", output).group(1)
+
+ if temporary:
+ scope = scope + " temporary"
+ machine.log(f"{scope} address on {iface} is {ip}")
+ return ip
+
+
+ with subtest("Loopback address can be pinged"):
+ client.succeed("ping -c 1 ::1 >&2")
+ client.fail("ping -c 1 ::2 >&2")
+
+ with subtest("Local link addresses can be obtained and pinged"):
+ client_ip = wait_for_address(client, "eth1", "link")
+ server_ip = wait_for_address(server, "eth1", "link")
+ client.succeed(f"ping -c 1 {client_ip}%eth1 >&2")
+ client.succeed(f"ping -c 1 {server_ip}%eth1 >&2")
+
+ with subtest("Global addresses can be obtained, pinged, and reached via http"):
+ client_ip = wait_for_address(client, "eth1", "global")
+ server_ip = wait_for_address(server, "eth1", "global")
+ client.succeed(f"ping -c 1 {client_ip} >&2")
+ client.succeed(f"ping -c 1 {server_ip} >&2")
+ client.succeed(f"curl --fail -g http://[{server_ip}]")
+ client.fail(f"curl --fail -g http://[{client_ip}]")
+
+ with subtest("Privacy extensions: Global temporary address can be obtained and pinged"):
+ ip = wait_for_address(client, "eth1", "global", temporary=True)
# Default route should have "src <temporary address>" in it
- $client->succeed("ip r g ::2 | grep $ip");
- };
+ client.succeed(f"ip r g ::2 | grep {ip}")
# TODO: test reachability of a machine on another network.
'';
diff --git a/nixpkgs/nixos/tests/keepalived.nix b/nixpkgs/nixos/tests/keepalived.nix
new file mode 100644
index 00000000000..d0bf9d46520
--- /dev/null
+++ b/nixpkgs/nixos/tests/keepalived.nix
@@ -0,0 +1,42 @@
+import ./make-test-python.nix ({ pkgs, ... }: {
+ name = "keepalived";
+
+ nodes = {
+ node1 = { pkgs, ... }: {
+ networking.firewall.extraCommands = "iptables -A INPUT -p vrrp -j ACCEPT";
+ services.keepalived.enable = true;
+ services.keepalived.vrrpInstances.test = {
+ interface = "eth1";
+ state = "MASTER";
+ priority = 50;
+ virtualIps = [{ addr = "192.168.1.200"; }];
+ virtualRouterId = 1;
+ };
+ environment.systemPackages = [ pkgs.tcpdump ];
+ };
+ node2 = { pkgs, ... }: {
+ networking.firewall.extraCommands = "iptables -A INPUT -p vrrp -j ACCEPT";
+ services.keepalived.enable = true;
+ services.keepalived.vrrpInstances.test = {
+ interface = "eth1";
+ state = "MASTER";
+ priority = 100;
+ virtualIps = [{ addr = "192.168.1.200"; }];
+ virtualRouterId = 1;
+ };
+ environment.systemPackages = [ pkgs.tcpdump ];
+ };
+ };
+
+ testScript = ''
+ # wait for boot time delay to pass
+ for node in [node1, node2]:
+ node.wait_until_succeeds(
+ "systemctl show -p LastTriggerUSecMonotonic keepalived-boot-delay.timer | grep -vq 'LastTriggerUSecMonotonic=0'"
+ )
+ node.wait_for_unit("keepalived")
+ node2.wait_until_succeeds("ip addr show dev eth1 | grep -q 192.168.1.200")
+ node1.fail("ip addr show dev eth1 | grep -q 192.168.1.200")
+ node1.succeed("ping -c1 192.168.1.200")
+ '';
+})
diff --git a/nixpkgs/nixos/tests/kexec.nix b/nixpkgs/nixos/tests/kexec.nix
index b13b4131091..ec0cd9796b0 100644
--- a/nixpkgs/nixos/tests/kexec.nix
+++ b/nixpkgs/nixos/tests/kexec.nix
@@ -1,9 +1,15 @@
# Test whether fast reboots via kexec work.
-import ./make-test.nix ({ pkgs, ...} : {
+import ./make-test-python.nix ({ pkgs, lib, ...} : {
name = "kexec";
- meta = with pkgs.stdenv.lib.maintainers; {
+ meta = with lib.maintainers; {
maintainers = [ eelco ];
+ # Currently hangs forever; last output is:
+ # machine # [ 10.239914] dhcpcd[707]: eth0: adding default route via fe80::2
+ # machine: waiting for the VM to finish booting
+ # machine # Cannot find the ESP partition mount point.
+ # machine # [ 28.681197] nscd[692]: 692 checking for monitored file `/etc/netgroup': No such file or directory
+ broken = true;
};
machine = { ... }:
@@ -11,9 +17,9 @@ import ./make-test.nix ({ pkgs, ...} : {
testScript =
''
- $machine->waitForUnit("multi-user.target");
- $machine->execute("systemctl kexec &");
- $machine->{connected} = 0;
- $machine->waitForUnit("multi-user.target");
+ machine.wait_for_unit("multi-user.target")
+ machine.execute("systemctl kexec &")
+ machine.connected = False
+ machine.wait_for_unit("multi-user.target")
'';
})
diff --git a/nixpkgs/nixos/tests/ldap.nix b/nixpkgs/nixos/tests/ldap.nix
index 665b9ee09b5..74b002fc00e 100644
--- a/nixpkgs/nixos/tests/ldap.nix
+++ b/nixpkgs/nixos/tests/ldap.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ pkgs, lib, ...} :
+import ./make-test-python.nix ({ pkgs, lib, ...} :
let
unlines = lib.concatStringsSep "\n";
@@ -288,108 +288,118 @@ in
client1 = mkClient true; # use nss_pam_ldapd
client2 = mkClient false; # use nss_ldap and pam_ldap
-
};
testScript = ''
- $server->start;
- $server->waitForUnit("default.target");
-
- subtest "slapd", sub {
- subtest "auth as database admin with SASL and check a POSIX account", sub {
- $server->succeed(join ' ', 'test',
- '"$(ldapsearch -LLL -H ldapi:// -Y EXTERNAL',
- '-b \'uid=${ldapUser},ou=accounts,ou=posix,${dbSuffix}\' ',
- '-s base uidNumber |',
- 'sed -ne \'s/^uidNumber: \\(.*\\)/\\1/p\' ',
- ')" -eq ${toString ldapUserId}');
- };
- subtest "auth as database admin with password and check a POSIX account", sub {
- $server->succeed(join ' ', 'test',
- '"$(ldapsearch -LLL -H ldap://server',
- '-D \'cn=admin,${dbSuffix}\' -w \'${dbAdminPwd}\' ',
- '-b \'uid=${ldapUser},ou=accounts,ou=posix,${dbSuffix}\' ',
- '-s base uidNumber |',
- 'sed -ne \'s/^uidNumber: \\(.*\\)/\\1/p\' ',
- ')" -eq ${toString ldapUserId}');
- };
- };
-
- $client1->start;
- $client1->waitForUnit("default.target");
-
- subtest "password", sub {
- subtest "su with password to a POSIX account", sub {
- $client1->succeed("${pkgs.expect}/bin/expect -c '" . join ';',
- 'spawn su "${ldapUser}"',
- 'expect "Password:"',
- 'send "${ldapUserPwd}\n"',
- 'expect "*"',
- 'send "whoami\n"',
- 'expect -ex "${ldapUser}" {exit}',
- 'exit 1' . "'");
- };
- subtest "change password of a POSIX account as root", sub {
- $client1->succeed("chpasswd <<<'${ldapUser}:new-password'");
- $client1->succeed("${pkgs.expect}/bin/expect -c '" . join ';',
- 'spawn su "${ldapUser}"',
- 'expect "Password:"',
- 'send "new-password\n"',
- 'expect "*"',
- 'send "whoami\n"',
- 'expect -ex "${ldapUser}" {exit}',
- 'exit 1' . "'");
- $client1->succeed('chpasswd <<<\'${ldapUser}:${ldapUserPwd}\' ');
- };
- subtest "change password of a POSIX account from itself", sub {
- $client1->succeed('chpasswd <<<\'${ldapUser}:${ldapUserPwd}\' ');
- $client1->succeed("${pkgs.expect}/bin/expect -c '" . join ';',
- 'spawn su --login ${ldapUser} -c passwd',
- 'expect "Password: "',
- 'send "${ldapUserPwd}\n"',
- 'expect "(current) UNIX password: "',
- 'send "${ldapUserPwd}\n"',
- 'expect "New password: "',
- 'send "new-password\n"',
- 'expect "Retype new password: "',
- 'send "new-password\n"',
- 'expect "passwd: password updated successfully" {exit}',
- 'exit 1' . "'");
- $client1->succeed("${pkgs.expect}/bin/expect -c '" . join ';',
- 'spawn su "${ldapUser}"',
- 'expect "Password:"',
- 'send "${ldapUserPwd}\n"',
- 'expect "su: Authentication failure" {exit}',
- 'exit 1' . "'");
- $client1->succeed("${pkgs.expect}/bin/expect -c '" . join ';',
- 'spawn su "${ldapUser}"',
- 'expect "Password:"',
- 'send "new-password\n"',
- 'expect "*"',
- 'send "whoami\n"',
- 'expect -ex "${ldapUser}" {exit}',
- 'exit 1' . "'");
- $client1->succeed('chpasswd <<<\'${ldapUser}:${ldapUserPwd}\' ');
- };
- };
-
- $client2->start;
- $client2->waitForUnit("default.target");
-
- subtest "NSS", sub {
- $client1->succeed("test \"\$(id -u '${ldapUser}')\" -eq ${toString ldapUserId}");
- $client1->succeed("test \"\$(id -u -n '${ldapUser}')\" = '${ldapUser}'");
- $client1->succeed("test \"\$(id -g '${ldapUser}')\" -eq ${toString ldapGroupId}");
- $client1->succeed("test \"\$(id -g -n '${ldapUser}')\" = '${ldapGroup}'");
- $client2->succeed("test \"\$(id -u '${ldapUser}')\" -eq ${toString ldapUserId}");
- $client2->succeed("test \"\$(id -u -n '${ldapUser}')\" = '${ldapUser}'");
- $client2->succeed("test \"\$(id -g '${ldapUser}')\" -eq ${toString ldapGroupId}");
- $client2->succeed("test \"\$(id -g -n '${ldapUser}')\" = '${ldapGroup}'");
- };
-
- subtest "PAM", sub {
- $client1->succeed("echo ${ldapUserPwd} | su -l '${ldapUser}' -c true");
- $client2->succeed("echo ${ldapUserPwd} | su -l '${ldapUser}' -c true");
- };
+ def expect_script(*commands):
+ script = ";".join(commands)
+ return f"${pkgs.expect}/bin/expect -c '{script}'"
+
+
+ server.start()
+ server.wait_for_unit("default.target")
+
+ with subtest("slapd: auth as database admin with SASL and check a POSIX account"):
+ server.succeed(
+ 'test "$(ldapsearch -LLL -H ldapi:// -Y EXTERNAL '
+ + "-b 'uid=${ldapUser},ou=accounts,ou=posix,${dbSuffix}' "
+ + "-s base uidNumber | "
+ + "sed -ne 's/^uidNumber: \\(.*\\)/\\1/p')\" -eq ${toString ldapUserId}"
+ )
+
+ with subtest("slapd: auth as database admin with password and check a POSIX account"):
+ server.succeed(
+ "test \"$(ldapsearch -LLL -H ldap://server -D 'cn=admin,${dbSuffix}' "
+ + "-w '${dbAdminPwd}' -b 'uid=${ldapUser},ou=accounts,ou=posix,${dbSuffix}' "
+ + "-s base uidNumber | "
+ + "sed -ne 's/^uidNumber: \\(.*\\)/\\1/p')\" -eq ${toString ldapUserId}"
+ )
+
+ client1.start()
+ client1.wait_for_unit("default.target")
+
+ with subtest("password: su with password to a POSIX account"):
+ client1.succeed(
+ expect_script(
+ 'spawn su "${ldapUser}"',
+ 'expect "Password:"',
+ 'send "${ldapUserPwd}\n"',
+ 'expect "*"',
+ 'send "whoami\n"',
+ 'expect -ex "${ldapUser}" {exit}',
+ "exit 1",
+ )
+ )
+
+ with subtest("password: change password of a POSIX account as root"):
+ client1.succeed(
+ "chpasswd <<<'${ldapUser}:new-password'",
+ expect_script(
+ 'spawn su "${ldapUser}"',
+ 'expect "Password:"',
+ 'send "new-password\n"',
+ 'expect "*"',
+ 'send "whoami\n"',
+ 'expect -ex "${ldapUser}" {exit}',
+ "exit 1",
+ ),
+ "chpasswd <<<'${ldapUser}:${ldapUserPwd}'",
+ )
+
+ with subtest("password: change password of a POSIX account from itself"):
+ client1.succeed(
+ "chpasswd <<<'${ldapUser}:${ldapUserPwd}' ",
+ expect_script(
+ "spawn su --login ${ldapUser} -c passwd",
+ 'expect "Password: "',
+ 'send "${ldapUserPwd}\n"',
+ 'expect "(current) UNIX password: "',
+ 'send "${ldapUserPwd}\n"',
+ 'expect "New password: "',
+ 'send "new-password\n"',
+ 'expect "Retype new password: "',
+ 'send "new-password\n"',
+ 'expect "passwd: password updated successfully" {exit}',
+ "exit 1",
+ ),
+ expect_script(
+ 'spawn su "${ldapUser}"',
+ 'expect "Password:"',
+ 'send "${ldapUserPwd}\n"',
+ 'expect "su: Authentication failure" {exit}',
+ "exit 1",
+ ),
+ expect_script(
+ 'spawn su "${ldapUser}"',
+ 'expect "Password:"',
+ 'send "new-password\n"',
+ 'expect "*"',
+ 'send "whoami\n"',
+ 'expect -ex "${ldapUser}" {exit}',
+ "exit 1",
+ ),
+ "chpasswd <<<'${ldapUser}:${ldapUserPwd}'",
+ )
+
+ client2.start()
+ client2.wait_for_unit("default.target")
+
+ with subtest("NSS"):
+ client1.succeed(
+ "test \"$(id -u '${ldapUser}')\" -eq ${toString ldapUserId}",
+ "test \"$(id -u -n '${ldapUser}')\" = '${ldapUser}'",
+ "test \"$(id -g '${ldapUser}')\" -eq ${toString ldapGroupId}",
+ "test \"$(id -g -n '${ldapUser}')\" = '${ldapGroup}'",
+ "test \"$(id -u '${ldapUser}')\" -eq ${toString ldapUserId}",
+ "test \"$(id -u -n '${ldapUser}')\" = '${ldapUser}'",
+ "test \"$(id -g '${ldapUser}')\" -eq ${toString ldapGroupId}",
+ "test \"$(id -g -n '${ldapUser}')\" = '${ldapGroup}'",
+ )
+
+ with subtest("PAM"):
+ client1.succeed(
+ "echo ${ldapUserPwd} | su -l '${ldapUser}' -c true",
+ "echo ${ldapUserPwd} | su -l '${ldapUser}' -c true",
+ )
'';
})
diff --git a/nixpkgs/nixos/tests/leaps.nix b/nixpkgs/nixos/tests/leaps.nix
index 6163fed56b6..65b475d734e 100644
--- a/nixpkgs/nixos/tests/leaps.nix
+++ b/nixpkgs/nixos/tests/leaps.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ pkgs, ... }:
+import ./make-test-python.nix ({ pkgs, ... }:
{
name = "leaps";
@@ -22,9 +22,11 @@ import ./make-test.nix ({ pkgs, ... }:
testScript =
''
- startAll;
- $server->waitForOpenPort(6666);
- $client->waitForUnit("network.target");
- $client->succeed("${pkgs.curl}/bin/curl http://server:6666/leaps/ | grep -i 'leaps'");
+ start_all()
+ server.wait_for_open_port(6666)
+ client.wait_for_unit("network.target")
+ assert "leaps" in client.succeed(
+ "${pkgs.curl}/bin/curl http://server:6666/leaps/"
+ )
'';
})
diff --git a/nixpkgs/nixos/tests/lidarr.nix b/nixpkgs/nixos/tests/lidarr.nix
index 85fcbd21d8c..d3f83e5d914 100644
--- a/nixpkgs/nixos/tests/lidarr.nix
+++ b/nixpkgs/nixos/tests/lidarr.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ lib, ... }:
+import ./make-test-python.nix ({ lib, ... }:
with lib;
@@ -11,8 +11,10 @@ with lib;
{ services.lidarr.enable = true; };
testScript = ''
- $machine->waitForUnit('lidarr.service');
- $machine->waitForOpenPort('8686');
- $machine->succeed("curl --fail http://localhost:8686/");
+ start_all()
+
+ machine.wait_for_unit("lidarr.service")
+ machine.wait_for_open_port("8686")
+ machine.succeed("curl --fail http://localhost:8686/")
'';
})
diff --git a/nixpkgs/nixos/tests/lightdm.nix b/nixpkgs/nixos/tests/lightdm.nix
index ef30f7741e2..46c2ed7ccc5 100644
--- a/nixpkgs/nixos/tests/lightdm.nix
+++ b/nixpkgs/nixos/tests/lightdm.nix
@@ -8,9 +8,8 @@ import ./make-test-python.nix ({ pkgs, ...} : {
imports = [ ./common/user-account.nix ];
services.xserver.enable = true;
services.xserver.displayManager.lightdm.enable = true;
- services.xserver.windowManager.default = "icewm";
+ services.xserver.displayManager.defaultSession = "none+icewm";
services.xserver.windowManager.icewm.enable = true;
- services.xserver.desktopManager.default = "none";
};
enableOCR = true;
diff --git a/nixpkgs/nixos/tests/mailcatcher.nix b/nixpkgs/nixos/tests/mailcatcher.nix
index eb5b606ecc8..2ef38544fe0 100644
--- a/nixpkgs/nixos/tests/mailcatcher.nix
+++ b/nixpkgs/nixos/tests/mailcatcher.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ lib, ... }:
+import ./make-test-python.nix ({ lib, ... }:
{
name = "mailcatcher";
@@ -16,11 +16,15 @@ import ./make-test.nix ({ lib, ... }:
};
testScript = ''
- startAll;
+ start_all()
- $machine->waitForUnit('mailcatcher.service');
- $machine->waitForOpenPort('1025');
- $machine->succeed('echo "this is the body of the email" | mail -s "subject" root@example.org');
- $machine->succeed('curl http://localhost:1080/messages/1.source') =~ /this is the body of the email/ or die;
+ machine.wait_for_unit("mailcatcher.service")
+ machine.wait_for_open_port("1025")
+ machine.succeed(
+ 'echo "this is the body of the email" | mail -s "subject" root@example.org'
+ )
+ assert "this is the body of the email" in machine.succeed(
+ "curl http://localhost:1080/messages/1.source"
+ )
'';
})
diff --git a/nixpkgs/nixos/tests/matomo.nix b/nixpkgs/nixos/tests/matomo.nix
index 4efa65a7b6d..2bea237c8bd 100644
--- a/nixpkgs/nixos/tests/matomo.nix
+++ b/nixpkgs/nixos/tests/matomo.nix
@@ -1,7 +1,7 @@
{ system ? builtins.currentSystem, config ? { }
, pkgs ? import ../.. { inherit system config; } }:
-with import ../lib/testing.nix { inherit system pkgs; };
+with import ../lib/testing-python.nix { inherit system pkgs; };
with pkgs.lib;
let
@@ -24,11 +24,16 @@ let
};
testScript = ''
- startAll;
- $machine->waitForUnit("mysql.service");
- $machine->waitForUnit("phpfpm-matomo.service");
- $machine->waitForUnit("nginx.service");
- $machine->succeed("curl -sSfL http://localhost/ | grep '<title>Matomo[^<]*Installation'");
+ start_all()
+ machine.wait_for_unit("mysql.service")
+ machine.wait_for_unit("phpfpm-matomo.service")
+ machine.wait_for_unit("nginx.service")
+
+ # without the grep the command does not produce valid utf-8 for some reason
+ with subtest("welcome screen loads"):
+ machine.succeed(
+ "curl -sSfL http://localhost/ | grep '<title>Matomo[^<]*Installation'"
+ )
'';
};
in {
diff --git a/nixpkgs/nixos/tests/mediawiki.nix b/nixpkgs/nixos/tests/mediawiki.nix
index 6293e8a2f46..9468c1de8cc 100644
--- a/nixpkgs/nixos/tests/mediawiki.nix
+++ b/nixpkgs/nixos/tests/mediawiki.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ pkgs, lib, ... }: {
+import ./make-test-python.nix ({ pkgs, lib, ... }: {
name = "mediawiki";
meta.maintainers = [ lib.maintainers.aanderse ];
@@ -11,9 +11,11 @@ import ./make-test.nix ({ pkgs, lib, ... }: {
};
testScript = ''
- startAll;
+ start_all()
- $machine->waitForUnit('phpfpm-mediawiki.service');
- $machine->succeed('curl -L http://localhost/') =~ /MediaWiki has been installed/ or die;
+ machine.wait_for_unit("phpfpm-mediawiki.service")
+
+ page = machine.succeed("curl -L http://localhost/")
+ assert "MediaWiki has been installed" in page
'';
})
diff --git a/nixpkgs/nixos/tests/moinmoin.nix b/nixpkgs/nixos/tests/moinmoin.nix
index 2662b79aa09..ac327498eba 100644
--- a/nixpkgs/nixos/tests/moinmoin.nix
+++ b/nixpkgs/nixos/tests/moinmoin.nix
@@ -1,6 +1,6 @@
-import ./make-test.nix ({ pkgs, lib, ... }: {
+import ./make-test-python.nix ({ pkgs, lib, ... }: {
name = "moinmoin";
- meta.maintainers = [ ]; # waiting for https://github.com/NixOS/nixpkgs/pull/65397
+ meta.maintainers = with lib.maintainers; [ mmilata ];
machine =
{ ... }:
@@ -13,12 +13,16 @@ import ./make-test.nix ({ pkgs, lib, ... }: {
};
testScript = ''
- startAll;
+ start_all()
- $machine->waitForUnit('moin-ExampleWiki.service');
- $machine->waitForUnit('nginx.service');
- $machine->waitForFile('/run/moin/ExampleWiki/gunicorn.sock');
- $machine->succeed('curl -L http://localhost/') =~ /If you have just installed/ or die;
- $machine->succeed('moin-ExampleWiki account create --name=admin --email=admin@example.com --password=foo 2>&1') =~ /status success/ or die;
+ machine.wait_for_unit("moin-ExampleWiki.service")
+ machine.wait_for_unit("nginx.service")
+ machine.wait_for_file("/run/moin/ExampleWiki/gunicorn.sock")
+
+ assert "If you have just installed" in machine.succeed("curl -L http://localhost/")
+
+ assert "status success" in machine.succeed(
+ "moin-ExampleWiki account create --name=admin --email=admin@example.com --password=foo 2>&1"
+ )
'';
})
diff --git a/nixpkgs/nixos/tests/mumble.nix b/nixpkgs/nixos/tests/mumble.nix
index 652d49a24b1..e9b6d14c6a1 100644
--- a/nixpkgs/nixos/tests/mumble.nix
+++ b/nixpkgs/nixos/tests/mumble.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ pkgs, ...} :
+import ./make-test-python.nix ({ pkgs, ...} :
let
client = { pkgs, ... }: {
@@ -24,50 +24,50 @@ in
};
testScript = ''
- startAll;
+ start_all()
- $server->waitForUnit("murmur.service");
- $client1->waitForX;
- $client2->waitForX;
+ server.wait_for_unit("murmur.service")
+ client1.wait_for_x()
+ client2.wait_for_x()
- $client1->execute("mumble mumble://client1\@server/test &");
- $client2->execute("mumble mumble://client2\@server/test &");
+ client1.execute("mumble mumble://client1\@server/test &")
+ client2.execute("mumble mumble://client2\@server/test &")
# cancel client audio configuration
- $client1->waitForWindow(qr/Audio Tuning Wizard/);
- $client2->waitForWindow(qr/Audio Tuning Wizard/);
- $server->sleep(5); # wait because mumble is slow to register event handlers
- $client1->sendKeys("esc");
- $client2->sendKeys("esc");
+ client1.wait_for_window(r"Audio Tuning Wizard")
+ client2.wait_for_window(r"Audio Tuning Wizard")
+ server.sleep(5) # wait because mumble is slow to register event handlers
+ client1.send_key("esc")
+ client2.send_key("esc")
# cancel client cert configuration
- $client1->waitForWindow(qr/Certificate Management/);
- $client2->waitForWindow(qr/Certificate Management/);
- $server->sleep(5); # wait because mumble is slow to register event handlers
- $client1->sendKeys("esc");
- $client2->sendKeys("esc");
+ client1.wait_for_window(r"Certificate Management")
+ client2.wait_for_window(r"Certificate Management")
+ server.sleep(5) # wait because mumble is slow to register event handlers
+ client1.send_key("esc")
+ client2.send_key("esc")
# accept server certificate
- $client1->waitForWindow(qr/^Mumble$/);
- $client2->waitForWindow(qr/^Mumble$/);
- $server->sleep(5); # wait because mumble is slow to register event handlers
- $client1->sendChars("y");
- $client2->sendChars("y");
- $server->sleep(5); # wait because mumble is slow to register event handlers
+ client1.wait_for_window(r"^Mumble$")
+ client2.wait_for_window(r"^Mumble$")
+ server.sleep(5) # wait because mumble is slow to register event handlers
+ client1.send_chars("y")
+ client2.send_chars("y")
+ server.sleep(5) # wait because mumble is slow to register event handlers
# sometimes the wrong of the 2 windows is focused, we switch focus and try pressing "y" again
- $client1->sendKeys("alt-tab");
- $client2->sendKeys("alt-tab");
- $server->sleep(5); # wait because mumble is slow to register event handlers
- $client1->sendChars("y");
- $client2->sendChars("y");
+ client1.send_key("alt-tab")
+ client2.send_key("alt-tab")
+ server.sleep(5) # wait because mumble is slow to register event handlers
+ client1.send_chars("y")
+ client2.send_chars("y")
# Find clients in logs
- $server->waitUntilSucceeds("journalctl -eu murmur -o cat | grep -q client1");
- $server->waitUntilSucceeds("journalctl -eu murmur -o cat | grep -q client2");
+ server.wait_until_succeeds("journalctl -eu murmur -o cat | grep -q client1")
+ server.wait_until_succeeds("journalctl -eu murmur -o cat | grep -q client2")
- $server->sleep(5); # wait to get screenshot
- $client1->screenshot("screen1");
- $client2->screenshot("screen2");
+ server.sleep(5) # wait to get screenshot
+ client1.screenshot("screen1")
+ client2.screenshot("screen2")
'';
})
diff --git a/nixpkgs/nixos/tests/munin.nix b/nixpkgs/nixos/tests/munin.nix
index 31374aaf77e..7b674db7768 100644
--- a/nixpkgs/nixos/tests/munin.nix
+++ b/nixpkgs/nixos/tests/munin.nix
@@ -1,7 +1,7 @@
# This test runs basic munin setup with node and cron job running on the same
# machine.
-import ./make-test.nix ({ pkgs, ...} : {
+import ./make-test-python.nix ({ pkgs, ...} : {
name = "munin";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ domenkozar eelco ];
@@ -12,33 +12,33 @@ import ./make-test.nix ({ pkgs, ...} : {
{ config, ... }:
{
services = {
- munin-node = {
+ munin-node = {
+ enable = true;
+ # disable a failing plugin to prevent irrelevant error message, see #23049
+ disabledPlugins = [ "apc_nis" ];
+ };
+ munin-cron = {
enable = true;
- # disable a failing plugin to prevent irrelevant error message, see #23049
- disabledPlugins = [ "apc_nis" ];
- };
- munin-cron = {
- enable = true;
- hosts = ''
- [${config.networking.hostName}]
- address localhost
- '';
- };
+ hosts = ''
+ [${config.networking.hostName}]
+ address localhost
+ '';
+ };
};
- # long timeout to prevent hydra failure on high load
- systemd.services.munin-node.serviceConfig.TimeoutStartSec = "10min";
+
+ # increase the systemd timer interval so it fires more often
+ systemd.timers.munin-cron.timerConfig.OnCalendar = pkgs.stdenv.lib.mkForce "*:*:0/10";
};
};
testScript = ''
- startAll;
+ start_all()
- $one->waitForUnit("munin-node.service");
- # make sure the node is actually listening
- $one->waitForOpenPort(4949);
- $one->succeed('systemctl start munin-cron');
- # wait for munin-cron output
- $one->waitForFile("/var/lib/munin/one/one-uptime-uptime-g.rrd");
- $one->waitForFile("/var/www/munin/one/index.html");
+ with subtest("ensure munin-node starts and listens on 4949"):
+ one.wait_for_unit("munin-node.service")
+ one.wait_for_open_port(4949)
+ with subtest("ensure munin-cron output is correct"):
+ one.wait_for_file("/var/lib/munin/one/one-uptime-uptime-g.rrd")
+ one.wait_for_file("/var/www/munin/one/index.html")
'';
})
diff --git a/nixpkgs/nixos/tests/mutable-users.nix b/nixpkgs/nixos/tests/mutable-users.nix
index e590703ab2f..49c7f78b82e 100644
--- a/nixpkgs/nixos/tests/mutable-users.nix
+++ b/nixpkgs/nixos/tests/mutable-users.nix
@@ -1,6 +1,6 @@
# Mutable users tests.
-import ./make-test.nix ({ pkgs, ...} : {
+import ./make-test-python.nix ({ pkgs, ...} : {
name = "mutable-users";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ gleber ];
@@ -19,21 +19,27 @@ import ./make-test.nix ({ pkgs, ...} : {
immutableSystem = nodes.machine.config.system.build.toplevel;
mutableSystem = nodes.mutable.config.system.build.toplevel;
in ''
- $machine->start();
- $machine->waitForUnit("default.target");
+ machine.start()
+ machine.wait_for_unit("default.target")
# Machine starts in immutable mode. Add a user and test if reactivating
# configuration removes the user.
- $machine->fail("cat /etc/passwd | grep ^foobar:");
- $machine->succeed("sudo useradd foobar");
- $machine->succeed("cat /etc/passwd | grep ^foobar:");
- $machine->succeed("${immutableSystem}/bin/switch-to-configuration test");
- $machine->fail("cat /etc/passwd | grep ^foobar:");
+ with subtest("Machine in immutable mode"):
+ assert "foobar" not in machine.succeed("cat /etc/passwd")
+ machine.succeed("sudo useradd foobar")
+ assert "foobar" in machine.succeed("cat /etc/passwd")
+ machine.succeed(
+ "${immutableSystem}/bin/switch-to-configuration test"
+ )
+ assert "foobar" not in machine.succeed("cat /etc/passwd")
# In immutable mode passwd is not wrapped, while in mutable mode it is
# wrapped.
- $machine->succeed('which passwd | grep /run/current-system/');
- $machine->succeed("${mutableSystem}/bin/switch-to-configuration test");
- $machine->succeed('which passwd | grep /run/wrappers/');
+ with subtest("Password is wrapped in mutable mode"):
+ assert "/run/current-system/" in machine.succeed("which passwd")
+ machine.succeed(
+ "${mutableSystem}/bin/switch-to-configuration test"
+ )
+ assert "/run/wrappers/" in machine.succeed("which passwd")
'';
})
diff --git a/nixpkgs/nixos/tests/mxisd.nix b/nixpkgs/nixos/tests/mxisd.nix
index 0039256f586..b2b60db4d82 100644
--- a/nixpkgs/nixos/tests/mxisd.nix
+++ b/nixpkgs/nixos/tests/mxisd.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ pkgs, ... } : {
+import ./make-test-python.nix ({ pkgs, ... } : {
name = "mxisd";
meta = with pkgs.stdenv.lib.maintainers; {
@@ -19,13 +19,12 @@ import ./make-test.nix ({ pkgs, ... } : {
};
testScript = ''
- startAll;
- $server_mxisd->waitForUnit("mxisd.service");
- $server_mxisd->waitForOpenPort(8090);
- $server_mxisd->succeed("curl -Ssf \"http://127.0.0.1:8090/_matrix/identity/api/v1\"");
- $server_ma1sd->waitForUnit("mxisd.service");
- $server_ma1sd->waitForOpenPort(8090);
- $server_ma1sd->succeed("curl -Ssf \"http://127.0.0.1:8090/_matrix/identity/api/v1\"")
-
+ start_all()
+ server_mxisd.wait_for_unit("mxisd.service")
+ server_mxisd.wait_for_open_port(8090)
+ server_mxisd.succeed("curl -Ssf 'http://127.0.0.1:8090/_matrix/identity/api/v1'")
+ server_ma1sd.wait_for_unit("mxisd.service")
+ server_ma1sd.wait_for_open_port(8090)
+ server_ma1sd.succeed("curl -Ssf 'http://127.0.0.1:8090/_matrix/identity/api/v1'")
'';
})
diff --git a/nixpkgs/nixos/tests/mysql.nix b/nixpkgs/nixos/tests/mysql.nix
index 2c0d212c2f1..924bac84e26 100644
--- a/nixpkgs/nixos/tests/mysql.nix
+++ b/nixpkgs/nixos/tests/mysql.nix
@@ -27,6 +27,7 @@ import ./make-test-python.nix ({ pkgs, ...} : {
{
users.users.testuser = { };
+ users.users.testuser2 = { };
services.mysql.enable = true;
services.mysql.initialScript = pkgs.writeText "mariadb-init.sql" ''
ALTER USER root@localhost IDENTIFIED WITH unix_socket;
@@ -34,12 +35,17 @@ import ./make-test-python.nix ({ pkgs, ...} : {
DELETE FROM mysql.user WHERE user = ''';
FLUSH PRIVILEGES;
'';
- services.mysql.ensureDatabases = [ "testdb" ];
+ services.mysql.ensureDatabases = [ "testdb" "testdb2" ];
services.mysql.ensureUsers = [{
name = "testuser";
ensurePermissions = {
"testdb.*" = "ALL PRIVILEGES";
};
+ } {
+ name = "testuser2";
+ ensurePermissions = {
+ "testdb2.*" = "ALL PRIVILEGES";
+ };
}];
services.mysql.package = pkgs.mariadb;
};
@@ -47,7 +53,7 @@ import ./make-test-python.nix ({ pkgs, ...} : {
};
testScript = ''
- start_all
+ start_all()
mysql.wait_for_unit("mysql")
mysql.succeed("echo 'use empty_testdb;' | mysql -u root")
@@ -62,6 +68,14 @@ import ./make-test-python.nix ({ pkgs, ...} : {
mariadb.succeed(
"echo 'use testdb; insert into tests values (42);' | sudo -u testuser mysql -u testuser"
)
+ # Ensure testuser2 is not able to insert into testdb as mysql testuser2
+ mariadb.fail(
+ "echo 'use testdb; insert into tests values (23);' | sudo -u testuser2 mysql -u testuser2"
+ )
+ # Ensure testuser2 is not able to authenticate as mysql testuser
+ mariadb.fail(
+ "echo 'use testdb; insert into tests values (23);' | sudo -u testuser2 mysql -u testuser"
+ )
mariadb.succeed(
"echo 'use testdb; select test_id from tests;' | sudo -u testuser mysql -u testuser -N | grep 42"
)
diff --git a/nixpkgs/nixos/tests/nagios.nix b/nixpkgs/nixos/tests/nagios.nix
new file mode 100644
index 00000000000..6f5d4447287
--- /dev/null
+++ b/nixpkgs/nixos/tests/nagios.nix
@@ -0,0 +1,116 @@
+import ./make-test-python.nix (
+ { pkgs, ... }: {
+ name = "nagios";
+ meta = with pkgs.stdenv.lib.maintainers; {
+ maintainers = [ symphorien ];
+ };
+
+ machine = { lib, ... }: let
+ writer = pkgs.writeShellScript "write" ''
+ set -x
+ echo "$@" >> /tmp/notifications
+ '';
+ in
+ {
+ # tested service
+ services.sshd.enable = true;
+ # nagios
+ services.nagios = {
+ enable = true;
+ # make state transitions faster
+ extraConfig.interval_length = "5";
+ objectDefs =
+ (map (x: "${pkgs.nagios}/etc/objects/${x}.cfg") [ "templates" "timeperiods" "commands" ]) ++ [
+ (
+ pkgs.writeText "objects.cfg" ''
+ # notifications are written to /tmp/notifications
+ define command {
+ command_name notify-host-by-file
+ command_line ${writer} "$HOSTNAME is $HOSTSTATE$"
+ }
+ define command {
+ command_name notify-service-by-file
+ command_line ${writer} "$SERVICEDESC$ is $SERVICESTATE$"
+ }
+
+ # nagios boilerplate
+ define contact {
+ contact_name alice
+ alias alice
+ host_notifications_enabled 1
+ service_notifications_enabled 1
+ service_notification_period 24x7
+ host_notification_period 24x7
+ service_notification_options w,u,c,r,f,s
+ host_notification_options d,u,r,f,s
+ service_notification_commands notify-service-by-file
+ host_notification_commands notify-host-by-file
+ email foo@example.com
+ }
+ define contactgroup {
+ contactgroup_name admins
+ alias Admins
+ members alice
+ }
+ define hostgroup{
+ hostgroup_name allhosts
+ alias All hosts
+ }
+
+ # monitored objects
+ define host {
+ use generic-host
+ host_name localhost
+ alias localhost
+ address localhost
+ hostgroups allhosts
+ contact_groups admins
+ # make state transitions faster.
+ max_check_attempts 2
+ check_interval 1
+ retry_interval 1
+ }
+ define service {
+ use generic-service
+ host_name localhost
+ service_description ssh
+ check_command check_ssh
+ # make state transitions faster.
+ max_check_attempts 2
+ check_interval 1
+ retry_interval 1
+ }
+ ''
+ )
+ ];
+ };
+ };
+
+ testScript = { ... }: ''
+ with subtest("ensure sshd starts"):
+ machine.wait_for_unit("sshd.service")
+
+
+ with subtest("ensure nagios starts"):
+ machine.wait_for_file("/var/log/nagios/current")
+
+
+ def assert_notify(text):
+ machine.wait_for_file("/tmp/notifications")
+ real = machine.succeed("cat /tmp/notifications").strip()
+ print(f"got {real!r}, expected {text!r}")
+ assert text == real
+
+
+ with subtest("ensure we get a notification when sshd is down"):
+ machine.succeed("systemctl stop sshd")
+ assert_notify("ssh is CRITICAL")
+
+
+ with subtest("ensure tests can succeed"):
+ machine.succeed("systemctl start sshd")
+ machine.succeed("rm /tmp/notifications")
+ assert_notify("ssh is OK")
+ '';
+ }
+)
diff --git a/nixpkgs/nixos/tests/nat.nix b/nixpkgs/nixos/tests/nat.nix
index 51d9cf166bb..0d1f7aaedfa 100644
--- a/nixpkgs/nixos/tests/nat.nix
+++ b/nixpkgs/nixos/tests/nat.nix
@@ -3,7 +3,7 @@
# client on the inside network, a server on the outside network, and a
# router connected to both that performs Network Address Translation
# for the client.
-import ./make-test.nix ({ pkgs, lib, withFirewall, withConntrackHelpers ? false, ... }:
+import ./make-test-python.nix ({ pkgs, lib, withFirewall, withConntrackHelpers ? false, ... }:
let
unit = if withFirewall then "firewall" else "nat";
@@ -69,49 +69,52 @@ import ./make-test.nix ({ pkgs, lib, withFirewall, withConntrackHelpers ? false,
routerDummyNoNatClosure = nodes.routerDummyNoNat.config.system.build.toplevel;
routerClosure = nodes.router.config.system.build.toplevel;
in ''
- $client->start;
- $router->start;
- $server->start;
+ client.start()
+ router.start()
+ server.start()
# The router should have access to the server.
- $server->waitForUnit("network.target");
- $server->waitForUnit("httpd");
- $router->waitForUnit("network.target");
- $router->succeed("curl --fail http://server/ >&2");
+ server.wait_for_unit("network.target")
+ server.wait_for_unit("httpd")
+ router.wait_for_unit("network.target")
+ router.succeed("curl --fail http://server/ >&2")
# The client should be also able to connect via the NAT router.
- $router->waitForUnit("${unit}");
- $client->waitForUnit("network.target");
- $client->succeed("curl --fail http://server/ >&2");
- $client->succeed("ping -c 1 server >&2");
+ router.wait_for_unit("${unit}")
+ client.wait_for_unit("network.target")
+ client.succeed("curl --fail http://server/ >&2")
+ client.succeed("ping -c 1 server >&2")
# Test whether passive FTP works.
- $server->waitForUnit("vsftpd");
- $server->succeed("echo Hello World > /home/ftp/foo.txt");
- $client->succeed("curl -v ftp://server/foo.txt >&2");
+ server.wait_for_unit("vsftpd")
+ server.succeed("echo Hello World > /home/ftp/foo.txt")
+ client.succeed("curl -v ftp://server/foo.txt >&2")
# Test whether active FTP works.
- $client->${if withConntrackHelpers then "succeed" else "fail"}(
- "curl -v -P - ftp://server/foo.txt >&2");
+ client.${if withConntrackHelpers then "succeed" else "fail"}("curl -v -P - ftp://server/foo.txt >&2")
# Test ICMP.
- $client->succeed("ping -c 1 router >&2");
- $router->succeed("ping -c 1 client >&2");
+ client.succeed("ping -c 1 router >&2")
+ router.succeed("ping -c 1 client >&2")
# If we turn off NAT, the client shouldn't be able to reach the server.
- $router->succeed("${routerDummyNoNatClosure}/bin/switch-to-configuration test 2>&1");
- $client->fail("curl --fail --connect-timeout 5 http://server/ >&2");
- $client->fail("ping -c 1 server >&2");
+ router.succeed(
+ "${routerDummyNoNatClosure}/bin/switch-to-configuration test 2>&1"
+ )
+ client.fail("curl --fail --connect-timeout 5 http://server/ >&2")
+ client.fail("ping -c 1 server >&2")
# And make sure that reloading the NAT job works.
- $router->succeed("${routerClosure}/bin/switch-to-configuration test 2>&1");
+ router.succeed(
+ "${routerClosure}/bin/switch-to-configuration test 2>&1"
+ )
# FIXME: this should not be necessary, but nat.service is not started because
# network.target is not triggered
# (https://github.com/NixOS/nixpkgs/issues/16230#issuecomment-226408359)
${lib.optionalString (!withFirewall) ''
- $router->succeed("systemctl start nat.service");
+ router.succeed("systemctl start nat.service")
''}
- $client->succeed("curl --fail http://server/ >&2");
- $client->succeed("ping -c 1 server >&2");
+ client.succeed("curl --fail http://server/ >&2")
+ client.succeed("ping -c 1 server >&2")
'';
})
diff --git a/nixpkgs/nixos/tests/nesting.nix b/nixpkgs/nixos/tests/nesting.nix
index 1306d6f8e0c..6388b67a6e4 100644
--- a/nixpkgs/nixos/tests/nesting.nix
+++ b/nixpkgs/nixos/tests/nesting.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix {
+import ./make-test-python.nix {
name = "nesting";
nodes = {
clone = { pkgs, ... }: {
@@ -19,24 +19,26 @@ import ./make-test.nix {
};
};
testScript = ''
- $clone->waitForUnit("default.target");
- $clone->succeed("cowsay hey");
- $clone->fail("hello");
+ clone.wait_for_unit("default.target")
+ clone.succeed("cowsay hey")
+ clone.fail("hello")
- # Nested clones do inherit from parent
- $clone->succeed("/run/current-system/fine-tune/child-1/bin/switch-to-configuration test");
- $clone->succeed("cowsay hey");
- $clone->succeed("hello");
+ with subtest("Nested clones do inherit from parent"):
+ clone.succeed(
+ "/run/current-system/fine-tune/child-1/bin/switch-to-configuration test"
+ )
+ clone.succeed("cowsay hey")
+ clone.succeed("hello")
+ children.wait_for_unit("default.target")
+ children.succeed("cowsay hey")
+ children.fail("hello")
- $children->waitForUnit("default.target");
- $children->succeed("cowsay hey");
- $children->fail("hello");
-
- # Nested children do not inherit from parent
- $children->succeed("/run/current-system/fine-tune/child-1/bin/switch-to-configuration test");
- $children->fail("cowsay hey");
- $children->succeed("hello");
-
+ with subtest("Nested children do not inherit from parent"):
+ children.succeed(
+ "/run/current-system/fine-tune/child-1/bin/switch-to-configuration test"
+ )
+ children.fail("cowsay hey")
+ children.succeed("hello")
'';
}
diff --git a/nixpkgs/nixos/tests/netdata.nix b/nixpkgs/nixos/tests/netdata.nix
index 8dd5eafb097..4ddc96e8bc2 100644
--- a/nixpkgs/nixos/tests/netdata.nix
+++ b/nixpkgs/nixos/tests/netdata.nix
@@ -25,6 +25,7 @@ import ./make-test-python.nix ({ pkgs, ...} : {
# check if the netdata main page loads.
netdata.succeed("curl --fail http://localhost:19999/")
+ netdata.succeed("sleep 4")
# check if netdata can read disk ops for root owned processes.
# if > 0, successful. verifies both netdata working and
diff --git a/nixpkgs/nixos/tests/networking.nix b/nixpkgs/nixos/tests/networking.nix
index e0585d8f1bb..9448a104073 100644
--- a/nixpkgs/nixos/tests/networking.nix
+++ b/nixpkgs/nixos/tests/networking.nix
@@ -4,7 +4,7 @@
# bool: whether to use networkd in the tests
, networkd }:
-with import ../lib/testing.nix { inherit system pkgs; };
+with import ../lib/testing-python.nix { inherit system pkgs; };
with pkgs.lib;
let
@@ -75,10 +75,11 @@ let
machine.networking.useDHCP = false;
machine.networking.useNetworkd = networkd;
testScript = ''
- startAll;
- $machine->waitForUnit("network.target");
- $machine->succeed("ip addr show lo | grep -q 'inet 127.0.0.1/8 '");
- $machine->succeed("ip addr show lo | grep -q 'inet6 ::1/128 '");
+ start_all()
+ machine.wait_for_unit("network.target")
+ loopback_addresses = machine.succeed("ip addr show lo")
+ assert "inet 127.0.0.1/8" in loopback_addresses
+ assert "inet6 ::1/128" in loopback_addresses
'';
};
static = {
@@ -102,35 +103,35 @@ let
};
testScript = { ... }:
''
- startAll;
+ start_all()
- $client->waitForUnit("network.target");
- $router->waitForUnit("network-online.target");
+ client.wait_for_unit("network.target")
+ router.wait_for_unit("network-online.target")
- # Make sure dhcpcd is not started
- $client->fail("systemctl status dhcpcd.service");
+ with subtest("Make sure dhcpcd is not started"):
+ client.fail("systemctl status dhcpcd.service")
- # Test vlan 1
- $client->waitUntilSucceeds("ping -c 1 192.168.1.1");
- $client->waitUntilSucceeds("ping -c 1 192.168.1.2");
- $client->waitUntilSucceeds("ping -c 1 192.168.1.3");
- $client->waitUntilSucceeds("ping -c 1 192.168.1.10");
+ with subtest("Test vlan 1"):
+ client.wait_until_succeeds("ping -c 1 192.168.1.1")
+ client.wait_until_succeeds("ping -c 1 192.168.1.2")
+ client.wait_until_succeeds("ping -c 1 192.168.1.3")
+ client.wait_until_succeeds("ping -c 1 192.168.1.10")
- $router->waitUntilSucceeds("ping -c 1 192.168.1.1");
- $router->waitUntilSucceeds("ping -c 1 192.168.1.2");
- $router->waitUntilSucceeds("ping -c 1 192.168.1.3");
- $router->waitUntilSucceeds("ping -c 1 192.168.1.10");
+ router.wait_until_succeeds("ping -c 1 192.168.1.1")
+ router.wait_until_succeeds("ping -c 1 192.168.1.2")
+ router.wait_until_succeeds("ping -c 1 192.168.1.3")
+ router.wait_until_succeeds("ping -c 1 192.168.1.10")
- # Test vlan 2
- $client->waitUntilSucceeds("ping -c 1 192.168.2.1");
- $client->waitUntilSucceeds("ping -c 1 192.168.2.2");
+ with subtest("Test vlan 2"):
+ client.wait_until_succeeds("ping -c 1 192.168.2.1")
+ client.wait_until_succeeds("ping -c 1 192.168.2.2")
- $router->waitUntilSucceeds("ping -c 1 192.168.2.1");
- $router->waitUntilSucceeds("ping -c 1 192.168.2.2");
+ router.wait_until_succeeds("ping -c 1 192.168.2.1")
+ router.wait_until_succeeds("ping -c 1 192.168.2.2")
- # Test default gateway
- $router->waitUntilSucceeds("ping -c 1 192.168.3.1");
- $client->waitUntilSucceeds("ping -c 1 192.168.3.1");
+ with subtest("Test default gateway"):
+ router.wait_until_succeeds("ping -c 1 192.168.3.1")
+ client.wait_until_succeeds("ping -c 1 192.168.3.1")
'';
};
dhcpSimple = {
@@ -155,38 +156,38 @@ let
};
testScript = { ... }:
''
- startAll;
-
- $client->waitForUnit("network.target");
- $router->waitForUnit("network-online.target");
-
- # Wait until we have an ip address on each interface
- $client->waitUntilSucceeds("ip addr show dev eth1 | grep -q '192.168.1'");
- $client->waitUntilSucceeds("ip addr show dev eth1 | grep -q 'fd00:1234:5678:1:'");
- $client->waitUntilSucceeds("ip addr show dev eth2 | grep -q '192.168.2'");
- $client->waitUntilSucceeds("ip addr show dev eth2 | grep -q 'fd00:1234:5678:2:'");
-
- # Test vlan 1
- $client->waitUntilSucceeds("ping -c 1 192.168.1.1");
- $client->waitUntilSucceeds("ping -c 1 192.168.1.2");
- $client->waitUntilSucceeds("ping -c 1 fd00:1234:5678:1::1");
- $client->waitUntilSucceeds("ping -c 1 fd00:1234:5678:1::2");
-
- $router->waitUntilSucceeds("ping -c 1 192.168.1.1");
- $router->waitUntilSucceeds("ping -c 1 192.168.1.2");
- $router->waitUntilSucceeds("ping -c 1 fd00:1234:5678:1::1");
- $router->waitUntilSucceeds("ping -c 1 fd00:1234:5678:1::2");
-
- # Test vlan 2
- $client->waitUntilSucceeds("ping -c 1 192.168.2.1");
- $client->waitUntilSucceeds("ping -c 1 192.168.2.2");
- $client->waitUntilSucceeds("ping -c 1 fd00:1234:5678:2::1");
- $client->waitUntilSucceeds("ping -c 1 fd00:1234:5678:2::2");
-
- $router->waitUntilSucceeds("ping -c 1 192.168.2.1");
- $router->waitUntilSucceeds("ping -c 1 192.168.2.2");
- $router->waitUntilSucceeds("ping -c 1 fd00:1234:5678:2::1");
- $router->waitUntilSucceeds("ping -c 1 fd00:1234:5678:2::2");
+ start_all()
+
+ client.wait_for_unit("network.target")
+ router.wait_for_unit("network-online.target")
+
+ with subtest("Wait until we have an ip address on each interface"):
+ client.wait_until_succeeds("ip addr show dev eth1 | grep -q '192.168.1'")
+ client.wait_until_succeeds("ip addr show dev eth1 | grep -q 'fd00:1234:5678:1:'")
+ client.wait_until_succeeds("ip addr show dev eth2 | grep -q '192.168.2'")
+ client.wait_until_succeeds("ip addr show dev eth2 | grep -q 'fd00:1234:5678:2:'")
+
+ with subtest("Test vlan 1"):
+ client.wait_until_succeeds("ping -c 1 192.168.1.1")
+ client.wait_until_succeeds("ping -c 1 192.168.1.2")
+ client.wait_until_succeeds("ping -c 1 fd00:1234:5678:1::1")
+ client.wait_until_succeeds("ping -c 1 fd00:1234:5678:1::2")
+
+ router.wait_until_succeeds("ping -c 1 192.168.1.1")
+ router.wait_until_succeeds("ping -c 1 192.168.1.2")
+ router.wait_until_succeeds("ping -c 1 fd00:1234:5678:1::1")
+ router.wait_until_succeeds("ping -c 1 fd00:1234:5678:1::2")
+
+ with subtest("Test vlan 2"):
+ client.wait_until_succeeds("ping -c 1 192.168.2.1")
+ client.wait_until_succeeds("ping -c 1 192.168.2.2")
+ client.wait_until_succeeds("ping -c 1 fd00:1234:5678:2::1")
+ client.wait_until_succeeds("ping -c 1 fd00:1234:5678:2::2")
+
+ router.wait_until_succeeds("ping -c 1 192.168.2.1")
+ router.wait_until_succeeds("ping -c 1 192.168.2.2")
+ router.wait_until_succeeds("ping -c 1 fd00:1234:5678:2::1")
+ router.wait_until_succeeds("ping -c 1 fd00:1234:5678:2::2")
'';
};
dhcpOneIf = {
@@ -206,28 +207,28 @@ let
};
testScript = { ... }:
''
- startAll;
+ start_all()
- # Wait for networking to come up
- $client->waitForUnit("network.target");
- $router->waitForUnit("network.target");
+ with subtest("Wait for networking to come up"):
+ client.wait_for_unit("network.target")
+ router.wait_for_unit("network.target")
- # Wait until we have an ip address on each interface
- $client->waitUntilSucceeds("ip addr show dev eth1 | grep -q '192.168.1'");
+ with subtest("Wait until we have an ip address on each interface"):
+ client.wait_until_succeeds("ip addr show dev eth1 | grep -q '192.168.1'")
- # Test vlan 1
- $client->waitUntilSucceeds("ping -c 1 192.168.1.1");
- $client->waitUntilSucceeds("ping -c 1 192.168.1.2");
+ with subtest("Test vlan 1"):
+ client.wait_until_succeeds("ping -c 1 192.168.1.1")
+ client.wait_until_succeeds("ping -c 1 192.168.1.2")
- $router->waitUntilSucceeds("ping -c 1 192.168.1.1");
- $router->waitUntilSucceeds("ping -c 1 192.168.1.2");
+ router.wait_until_succeeds("ping -c 1 192.168.1.1")
+ router.wait_until_succeeds("ping -c 1 192.168.1.2")
- # Test vlan 2
- $client->waitUntilSucceeds("ping -c 1 192.168.2.1");
- $client->fail("ping -c 1 192.168.2.2");
+ with subtest("Test vlan 2"):
+ client.wait_until_succeeds("ping -c 1 192.168.2.1")
+ client.fail("ping -c 1 192.168.2.2")
- $router->waitUntilSucceeds("ping -c 1 192.168.2.1");
- $router->fail("ping -c 1 192.168.2.2");
+ router.wait_until_succeeds("ping -c 1 192.168.2.1")
+ router.fail("ping -c 1 192.168.2.2")
'';
};
bond = let
@@ -252,18 +253,18 @@ let
nodes.client2 = node "192.168.1.2";
testScript = { ... }:
''
- startAll;
+ start_all()
- # Wait for networking to come up
- $client1->waitForUnit("network.target");
- $client2->waitForUnit("network.target");
+ with subtest("Wait for networking to come up"):
+ client1.wait_for_unit("network.target")
+ client2.wait_for_unit("network.target")
- # Test bonding
- $client1->waitUntilSucceeds("ping -c 2 192.168.1.1");
- $client1->waitUntilSucceeds("ping -c 2 192.168.1.2");
+ with subtest("Test bonding"):
+ client1.wait_until_succeeds("ping -c 2 192.168.1.1")
+ client1.wait_until_succeeds("ping -c 2 192.168.1.2")
- $client2->waitUntilSucceeds("ping -c 2 192.168.1.1");
- $client2->waitUntilSucceeds("ping -c 2 192.168.1.2");
+ client2.wait_until_succeeds("ping -c 2 192.168.1.1")
+ client2.wait_until_succeeds("ping -c 2 192.168.1.2")
'';
};
bridge = let
@@ -294,25 +295,24 @@ let
};
testScript = { ... }:
''
- startAll;
+ start_all()
- # Wait for networking to come up
- $client1->waitForUnit("network.target");
- $client2->waitForUnit("network.target");
- $router->waitForUnit("network.target");
+ with subtest("Wait for networking to come up"):
+ for machine in client1, client2, router:
+ machine.wait_for_unit("network.target")
- # Test bridging
- $client1->waitUntilSucceeds("ping -c 1 192.168.1.1");
- $client1->waitUntilSucceeds("ping -c 1 192.168.1.2");
- $client1->waitUntilSucceeds("ping -c 1 192.168.1.3");
+ with subtest("Test bridging"):
+ client1.wait_until_succeeds("ping -c 1 192.168.1.1")
+ client1.wait_until_succeeds("ping -c 1 192.168.1.2")
+ client1.wait_until_succeeds("ping -c 1 192.168.1.3")
- $client2->waitUntilSucceeds("ping -c 1 192.168.1.1");
- $client2->waitUntilSucceeds("ping -c 1 192.168.1.2");
- $client2->waitUntilSucceeds("ping -c 1 192.168.1.3");
+ client2.wait_until_succeeds("ping -c 1 192.168.1.1")
+ client2.wait_until_succeeds("ping -c 1 192.168.1.2")
+ client2.wait_until_succeeds("ping -c 1 192.168.1.3")
- $router->waitUntilSucceeds("ping -c 1 192.168.1.1");
- $router->waitUntilSucceeds("ping -c 1 192.168.1.2");
- $router->waitUntilSucceeds("ping -c 1 192.168.1.3");
+ router.wait_until_succeeds("ping -c 1 192.168.1.1")
+ router.wait_until_succeeds("ping -c 1 192.168.1.2")
+ router.wait_until_succeeds("ping -c 1 192.168.1.3")
'';
};
macvlan = {
@@ -340,35 +340,35 @@ let
};
testScript = { ... }:
''
- startAll;
-
- # Wait for networking to come up
- $client->waitForUnit("network.target");
- $router->waitForUnit("network.target");
-
- # Wait until we have an ip address on each interface
- $client->waitUntilSucceeds("ip addr show dev eth1 | grep -q '192.168.1'");
- $client->waitUntilSucceeds("ip addr show dev macvlan | grep -q '192.168.1'");
-
- # Print lots of diagnostic information
- $router->log('**********************************************');
- $router->succeed("ip addr >&2");
- $router->succeed("ip route >&2");
- $router->execute("iptables-save >&2");
- $client->log('==============================================');
- $client->succeed("ip addr >&2");
- $client->succeed("ip route >&2");
- $client->execute("iptables-save >&2");
- $client->log('##############################################');
-
- # Test macvlan creates routable ips
- $client->waitUntilSucceeds("ping -c 1 192.168.1.1");
- $client->waitUntilSucceeds("ping -c 1 192.168.1.2");
- $client->waitUntilSucceeds("ping -c 1 192.168.1.3");
-
- $router->waitUntilSucceeds("ping -c 1 192.168.1.1");
- $router->waitUntilSucceeds("ping -c 1 192.168.1.2");
- $router->waitUntilSucceeds("ping -c 1 192.168.1.3");
+ start_all()
+
+ with subtest("Wait for networking to come up"):
+ client.wait_for_unit("network.target")
+ router.wait_for_unit("network.target")
+
+ with subtest("Wait until we have an ip address on each interface"):
+ client.wait_until_succeeds("ip addr show dev eth1 | grep -q '192.168.1'")
+ client.wait_until_succeeds("ip addr show dev macvlan | grep -q '192.168.1'")
+
+ with subtest("Print lots of diagnostic information"):
+ router.log("**********************************************")
+ router.succeed("ip addr >&2")
+ router.succeed("ip route >&2")
+ router.execute("iptables-save >&2")
+ client.log("==============================================")
+ client.succeed("ip addr >&2")
+ client.succeed("ip route >&2")
+ client.execute("iptables-save >&2")
+ client.log("##############################################")
+
+ with subtest("Test macvlan creates routable ips"):
+ client.wait_until_succeeds("ping -c 1 192.168.1.1")
+ client.wait_until_succeeds("ping -c 1 192.168.1.2")
+ client.wait_until_succeeds("ping -c 1 192.168.1.3")
+
+ router.wait_until_succeeds("ping -c 1 192.168.1.1")
+ router.wait_until_succeeds("ping -c 1 192.168.1.2")
+ router.wait_until_succeeds("ping -c 1 192.168.1.3")
'';
};
sit = let
@@ -395,22 +395,22 @@ let
nodes.client2 = node { address4 = "192.168.1.2"; remote = "192.168.1.1"; address6 = "fc00::2"; };
testScript = { ... }:
''
- startAll;
+ start_all()
- # Wait for networking to be configured
- $client1->waitForUnit("network.target");
- $client2->waitForUnit("network.target");
+ with subtest("Wait for networking to be configured"):
+ client1.wait_for_unit("network.target")
+ client2.wait_for_unit("network.target")
- # Print diagnostic information
- $client1->succeed("ip addr >&2");
- $client2->succeed("ip addr >&2");
+ # Print diagnostic information
+ client1.succeed("ip addr >&2")
+ client2.succeed("ip addr >&2")
- # Test ipv6
- $client1->waitUntilSucceeds("ping -c 1 fc00::1");
- $client1->waitUntilSucceeds("ping -c 1 fc00::2");
+ with subtest("Test ipv6"):
+ client1.wait_until_succeeds("ping -c 1 fc00::1")
+ client1.wait_until_succeeds("ping -c 1 fc00::2")
- $client2->waitUntilSucceeds("ping -c 1 fc00::1");
- $client2->waitUntilSucceeds("ping -c 1 fc00::2");
+ client2.wait_until_succeeds("ping -c 1 fc00::1")
+ client2.wait_until_succeeds("ping -c 1 fc00::2")
'';
};
vlan = let
@@ -435,15 +435,15 @@ let
nodes.client2 = node "192.168.1.2";
testScript = { ... }:
''
- startAll;
+ start_all()
- # Wait for networking to be configured
- $client1->waitForUnit("network.target");
- $client2->waitForUnit("network.target");
+ with subtest("Wait for networking to be configured"):
+ client1.wait_for_unit("network.target")
+ client2.wait_for_unit("network.target")
- # Test vlan is setup
- $client1->succeed("ip addr show dev vlan >&2");
- $client2->succeed("ip addr show dev vlan >&2");
+ with subtest("Test vlan is setup"):
+ client1.succeed("ip addr show dev vlan >&2")
+ client2.succeed("ip addr show dev vlan >&2")
'';
};
virtual = {
@@ -464,33 +464,38 @@ let
};
testScript = ''
- my $targetList = <<'END';
+ targetList = """
tap0: tap persist user 0
tun0: tun persist user 0
- END
-
- # Wait for networking to come up
- $machine->start;
- $machine->waitForUnit("network-online.target");
-
- # Test interfaces set up
- my $list = $machine->succeed("ip tuntap list | sort");
- "$list" eq "$targetList" or die(
- "The list of virtual interfaces does not match the expected one:\n",
- "Result:\n", "$list\n",
- "Expected:\n", "$targetList\n"
- );
-
- # Test interfaces clean up
- $machine->succeed("systemctl stop network-addresses-tap0");
- $machine->sleep(10);
- $machine->succeed("systemctl stop network-addresses-tun0");
- $machine->sleep(10);
- my $residue = $machine->succeed("ip tuntap list");
- $residue eq "" or die(
- "Some virtual interface has not been properly cleaned:\n",
- "$residue\n"
- );
+ """.strip()
+
+ with subtest("Wait for networking to come up"):
+ machine.start()
+ machine.wait_for_unit("network-online.target")
+
+ with subtest("Test interfaces set up"):
+ list = machine.succeed("ip tuntap list | sort").strip()
+ assert (
+ list == targetList
+ ), """
+ The list of virtual interfaces does not match the expected one:
+ Result:
+ {}
+ Expected:
+ {}
+ """.format(
+ list, targetList
+ )
+
+ with subtest("Test interfaces clean up"):
+ machine.succeed("systemctl stop network-addresses-tap0")
+ machine.sleep(10)
+ machine.succeed("systemctl stop network-addresses-tun0")
+ machine.sleep(10)
+ residue = machine.succeed("ip tuntap list")
+ assert (
+ residue is ""
+ ), "Some virtual interface has not been properly cleaned:\n{}".format(residue)
'';
};
privacy = {
@@ -522,7 +527,7 @@ let
'';
};
};
- nodes.clientWithPrivacy = { pkgs, ... }: with pkgs.lib; {
+ nodes.client_with_privacy = { pkgs, ... }: with pkgs.lib; {
virtualisation.vlans = [ 1 ];
networking = {
useNetworkd = networkd;
@@ -550,25 +555,31 @@ let
};
testScript = { ... }:
''
- startAll;
-
- $client->waitForUnit("network.target");
- $clientWithPrivacy->waitForUnit("network.target");
- $router->waitForUnit("network-online.target");
-
- # Wait until we have an ip address
- $clientWithPrivacy->waitUntilSucceeds("ip addr show dev eth1 | grep -q 'fd00:1234:5678:1:'");
- $client->waitUntilSucceeds("ip addr show dev eth1 | grep -q 'fd00:1234:5678:1:'");
-
- # Test vlan 1
- $clientWithPrivacy->waitUntilSucceeds("ping -c 1 fd00:1234:5678:1::1");
- $client->waitUntilSucceeds("ping -c 1 fd00:1234:5678:1::1");
-
- # Test address used is temporary
- $clientWithPrivacy->waitUntilSucceeds("! ip route get fd00:1234:5678:1::1 | grep -q ':[a-f0-9]*ff:fe[a-f0-9]*:'");
-
- # Test address used is EUI-64
- $client->waitUntilSucceeds("ip route get fd00:1234:5678:1::1 | grep -q ':[a-f0-9]*ff:fe[a-f0-9]*:'");
+ start_all()
+
+ client.wait_for_unit("network.target")
+ client_with_privacy.wait_for_unit("network.target")
+ router.wait_for_unit("network-online.target")
+
+ with subtest("Wait until we have an ip address"):
+ client_with_privacy.wait_until_succeeds(
+ "ip addr show dev eth1 | grep -q 'fd00:1234:5678:1:'"
+ )
+ client.wait_until_succeeds("ip addr show dev eth1 | grep -q 'fd00:1234:5678:1:'")
+
+ with subtest("Test vlan 1"):
+ client_with_privacy.wait_until_succeeds("ping -c 1 fd00:1234:5678:1::1")
+ client.wait_until_succeeds("ping -c 1 fd00:1234:5678:1::1")
+
+ with subtest("Test address used is temporary"):
+ client_with_privacy.wait_until_succeeds(
+ "! ip route get fd00:1234:5678:1::1 | grep -q ':[a-f0-9]*ff:fe[a-f0-9]*:'"
+ )
+
+ with subtest("Test address used is EUI-64"):
+ client.wait_until_succeeds(
+ "ip route get fd00:1234:5678:1::1 | grep -q ':[a-f0-9]*ff:fe[a-f0-9]*:'"
+ )
'';
};
routes = {
@@ -591,47 +602,57 @@ let
};
testScript = ''
- my $targetIPv4Table = <<'END';
+ targetIPv4Table = """
10.0.0.0/16 proto static scope link mtu 1500
192.168.1.0/24 proto kernel scope link src 192.168.1.2
192.168.2.0/24 via 192.168.1.1 proto static
- END
+ """.strip()
- my $targetIPv6Table = <<'END';
+ targetIPv6Table = """
2001:1470:fffd:2097::/64 proto kernel metric 256 pref medium
2001:1470:fffd:2098::/64 via fdfd:b3f0::1 proto static metric 1024 pref medium
fdfd:b3f0::/48 proto static metric 1024 pref medium
- END
-
- $machine->start;
- $machine->waitForUnit("network.target");
-
- # test routing tables
- my $ipv4Table = $machine->succeed("ip -4 route list dev eth0 | head -n3");
- my $ipv6Table = $machine->succeed("ip -6 route list dev eth0 | head -n3");
- "$ipv4Table" eq "$targetIPv4Table" or die(
- "The IPv4 routing table does not match the expected one:\n",
- "Result:\n", "$ipv4Table\n",
- "Expected:\n", "$targetIPv4Table\n"
- );
- "$ipv6Table" eq "$targetIPv6Table" or die(
- "The IPv6 routing table does not match the expected one:\n",
- "Result:\n", "$ipv6Table\n",
- "Expected:\n", "$targetIPv6Table\n"
- );
-
- # test clean-up of the tables
- $machine->succeed("systemctl stop network-addresses-eth0");
- my $ipv4Residue = $machine->succeed("ip -4 route list dev eth0 | head -n-3");
- my $ipv6Residue = $machine->succeed("ip -6 route list dev eth0 | head -n-3");
- $ipv4Residue eq "" or die(
- "The IPv4 routing table has not been properly cleaned:\n",
- "$ipv4Residue\n"
- );
- $ipv6Residue eq "" or die(
- "The IPv6 routing table has not been properly cleaned:\n",
- "$ipv6Residue\n"
- );
+ """.strip()
+
+ machine.start()
+ machine.wait_for_unit("network.target")
+
+ with subtest("test routing tables"):
+ ipv4Table = machine.succeed("ip -4 route list dev eth0 | head -n3").strip()
+ ipv6Table = machine.succeed("ip -6 route list dev eth0 | head -n3").strip()
+ assert (
+ ipv4Table == targetIPv4Table
+ ), """
+ The IPv4 routing table does not match the expected one:
+ Result:
+ {}
+ Expected:
+ {}
+ """.format(
+ ipv4Table, targetIPv4Table
+ )
+ assert (
+ ipv6Table == targetIPv6Table
+ ), """
+ The IPv6 routing table does not match the expected one:
+ Result:
+ {}
+ Expected:
+ {}
+ """.format(
+ ipv6Table, targetIPv6Table
+ )
+
+ with subtest("test clean-up of the tables"):
+ machine.succeed("systemctl stop network-addresses-eth0")
+ ipv4Residue = machine.succeed("ip -4 route list dev eth0 | head -n-3").strip()
+ ipv6Residue = machine.succeed("ip -6 route list dev eth0 | head -n-3").strip()
+ assert (
+ ipv4Residue is ""
+ ), "The IPv4 routing table has not been properly cleaned:\n{}".format(ipv4Residue)
+ assert (
+ ipv6Residue is ""
+ ), "The IPv6 routing table has not been properly cleaned:\n{}".format(ipv6Residue)
'';
};
};
diff --git a/nixpkgs/nixos/tests/nfs.nix b/nixpkgs/nixos/tests/nfs.nix
deleted file mode 100644
index 2f655336e75..00000000000
--- a/nixpkgs/nixos/tests/nfs.nix
+++ /dev/null
@@ -1,90 +0,0 @@
-import ./make-test.nix ({ pkgs, version ? 4, ... }:
-
-let
-
- client =
- { pkgs, ... }:
- { fileSystems = pkgs.lib.mkVMOverride
- [ { mountPoint = "/data";
- # nfs4 exports the export with fsid=0 as a virtual root directory
- device = if (version == 4) then "server:/" else "server:/data";
- fsType = "nfs";
- options = [ "vers=${toString version}" ];
- }
- ];
- networking.firewall.enable = false; # FIXME: only open statd
- };
-
-in
-
-{
- name = "nfs";
- meta = with pkgs.stdenv.lib.maintainers; {
- maintainers = [ eelco ];
- };
-
- nodes =
- { client1 = client;
- client2 = client;
-
- server =
- { ... }:
- { services.nfs.server.enable = true;
- services.nfs.server.exports =
- ''
- /data 192.168.1.0/255.255.255.0(rw,no_root_squash,no_subtree_check,fsid=0)
- '';
- services.nfs.server.createMountPoints = true;
- networking.firewall.enable = false; # FIXME: figure out what ports need to be allowed
- };
- };
-
- testScript =
- ''
- $server->waitForUnit("nfs-server");
- $server->succeed("systemctl start network-online.target");
- $server->waitForUnit("network-online.target");
-
- startAll;
-
- $client1->waitForUnit("data.mount");
- $client1->succeed("echo bla > /data/foo");
- $server->succeed("test -e /data/foo");
-
- $client2->waitForUnit("data.mount");
- $client2->succeed("echo bla > /data/bar");
- $server->succeed("test -e /data/bar");
-
- # Test whether restarting ‘nfs-server’ works correctly.
- $server->succeed("systemctl restart nfs-server");
- $client2->succeed("echo bla >> /data/bar"); # will take 90 seconds due to the NFS grace period
-
- # Test whether we can get a lock.
- $client2->succeed("time flock -n -s /data/lock true");
-
- # Test locking: client 1 acquires an exclusive lock, so client 2
- # should then fail to acquire a shared lock.
- $client1->succeed("flock -x /data/lock -c 'touch locked; sleep 100000' &");
- $client1->waitForFile("locked");
- $client2->fail("flock -n -s /data/lock true");
-
- # Test whether client 2 obtains the lock if we reset client 1.
- $client2->succeed("flock -x /data/lock -c 'echo acquired; touch locked; sleep 100000' >&2 &");
- $client1->crash;
- $client1->start;
- $client2->waitForFile("locked");
-
- # Test whether locks survive a reboot of the server.
- $client1->waitForUnit("data.mount");
- $server->shutdown;
- $server->start;
- $client1->succeed("touch /data/xyzzy");
- $client1->fail("time flock -n -s /data/lock true");
-
- # Test whether unmounting during shutdown happens quickly.
- my $t1 = time;
- $client1->shutdown;
- my $duration = time - $t1;
- die "shutdown took too long ($duration seconds)" if $duration > 30;
- '';
-})
diff --git a/nixpkgs/nixos/tests/nfs/default.nix b/nixpkgs/nixos/tests/nfs/default.nix
new file mode 100644
index 00000000000..6bc803c91b4
--- /dev/null
+++ b/nixpkgs/nixos/tests/nfs/default.nix
@@ -0,0 +1,9 @@
+{ version ? 4
+, system ? builtins.currentSystem
+, pkgs ? import ../../.. { inherit system; }
+}: {
+ simple = import ./simple.nix { inherit version system pkgs; };
+} // pkgs.lib.optionalAttrs (version == 4) {
+ # TODO: Test kerberos + nfsv3
+ kerberos = import ./kerberos.nix { inherit version system pkgs; };
+}
diff --git a/nixpkgs/nixos/tests/nfs/kerberos.nix b/nixpkgs/nixos/tests/nfs/kerberos.nix
new file mode 100644
index 00000000000..1f2d0d453ea
--- /dev/null
+++ b/nixpkgs/nixos/tests/nfs/kerberos.nix
@@ -0,0 +1,133 @@
+import ../make-test-python.nix ({ pkgs, lib, ... }:
+
+with lib;
+
+let
+ krb5 =
+ { enable = true;
+ domain_realm."nfs.test" = "NFS.TEST";
+ libdefaults.default_realm = "NFS.TEST";
+ realms."NFS.TEST" =
+ { admin_server = "server.nfs.test";
+ kdc = "server.nfs.test";
+ };
+ };
+
+ hosts =
+ ''
+ 192.168.1.1 client.nfs.test
+ 192.168.1.2 server.nfs.test
+ '';
+
+ users = {
+ users.alice = {
+ isNormalUser = true;
+ name = "alice";
+ uid = 1000;
+ };
+ };
+
+in
+
+{
+ name = "nfsv4-with-kerberos";
+
+ nodes = {
+ client = { lib, ... }:
+ { inherit krb5 users;
+
+ networking.extraHosts = hosts;
+ networking.domain = "nfs.test";
+ networking.hostName = "client";
+
+ fileSystems = lib.mkVMOverride
+ { "/data" = {
+ device = "server.nfs.test:/";
+ fsType = "nfs";
+ options = [ "nfsvers=4" "sec=krb5p" "noauto" ];
+ };
+ };
+ };
+
+ server = { lib, ...}:
+ { inherit krb5 users;
+
+ networking.extraHosts = hosts;
+ networking.domain = "nfs.test";
+ networking.hostName = "server";
+
+ networking.firewall.allowedTCPPorts = [
+ 111 # rpc
+ 2049 # nfs
+ 88 # kerberos
+ 749 # kerberos admin
+ ];
+
+ services.kerberos_server.enable = true;
+ services.kerberos_server.realms =
+ { "NFS.TEST".acl =
+ [ { access = "all"; principal = "admin/admin"; } ];
+ };
+
+ services.nfs.server.enable = true;
+ services.nfs.server.createMountPoints = true;
+ services.nfs.server.exports =
+ ''
+ /data *(rw,no_root_squash,fsid=0,sec=krb5p)
+ '';
+ };
+ };
+
+ testScript =
+ ''
+ server.succeed("mkdir -p /data/alice")
+ server.succeed("chown alice:users /data/alice")
+
+ # set up kerberos database
+ server.succeed(
+ "kdb5_util create -s -r NFS.TEST -P master_key",
+ "systemctl restart kadmind.service kdc.service",
+ )
+ server.wait_for_unit(f"kadmind.service")
+ server.wait_for_unit(f"kdc.service")
+
+ # create principals
+ server.succeed(
+ "kadmin.local add_principal -randkey nfs/server.nfs.test",
+ "kadmin.local add_principal -randkey nfs/client.nfs.test",
+ "kadmin.local add_principal -pw admin_pw admin/admin",
+ "kadmin.local add_principal -pw alice_pw alice",
+ )
+
+ # add principals to server keytab
+ server.succeed("kadmin.local ktadd nfs/server.nfs.test")
+ server.succeed("systemctl start rpc-gssd.service rpc-svcgssd.service")
+ server.wait_for_unit(f"rpc-gssd.service")
+ server.wait_for_unit(f"rpc-svcgssd.service")
+
+ client.wait_for_unit("network-online.target")
+
+ # add principals to client keytab
+ client.succeed("echo admin_pw | kadmin -p admin/admin ktadd nfs/client.nfs.test")
+ client.succeed("systemctl start rpc-gssd.service")
+ client.wait_for_unit("rpc-gssd.service")
+
+ with subtest("nfs share mounts"):
+ client.succeed("systemctl restart data.mount")
+ client.wait_for_unit("data.mount")
+
+ with subtest("permissions on nfs share are enforced"):
+ client.fail("su alice -c 'ls /data'")
+ client.succeed("su alice -c 'echo alice_pw | kinit'")
+ client.succeed("su alice -c 'ls /data'")
+
+ client.fail("su alice -c 'echo bla >> /data/foo'")
+ client.succeed("su alice -c 'echo bla >> /data/alice/foo'")
+ server.succeed("test -e /data/alice/foo")
+
+ with subtest("uids/gids are mapped correctly on nfs share"):
+ ids = client.succeed("stat -c '%U %G' /data/alice").split()
+ expected = ["alice", "users"]
+ assert ids == expected, f"ids incorrect: got {ids} expected {expected}"
+ '';
+})
diff --git a/nixpkgs/nixos/tests/nfs/simple.nix b/nixpkgs/nixos/tests/nfs/simple.nix
new file mode 100644
index 00000000000..a1a09ee0f45
--- /dev/null
+++ b/nixpkgs/nixos/tests/nfs/simple.nix
@@ -0,0 +1,94 @@
+import ../make-test-python.nix ({ pkgs, version ? 4, ... }:
+
+let
+
+ client =
+ { pkgs, ... }:
+ { fileSystems = pkgs.lib.mkVMOverride
+ [ { mountPoint = "/data";
+ # nfs4 exports the export with fsid=0 as a virtual root directory
+ device = if (version == 4) then "server:/" else "server:/data";
+ fsType = "nfs";
+ options = [ "vers=${toString version}" ];
+ }
+ ];
+ networking.firewall.enable = false; # FIXME: only open statd
+ };
+
+in
+
+{
+ name = "nfs";
+ meta = with pkgs.stdenv.lib.maintainers; {
+ maintainers = [ eelco ];
+ };
+
+ nodes =
+ { client1 = client;
+ client2 = client;
+
+ server =
+ { ... }:
+ { services.nfs.server.enable = true;
+ services.nfs.server.exports =
+ ''
+ /data 192.168.1.0/255.255.255.0(rw,no_root_squash,no_subtree_check,fsid=0)
+ '';
+ services.nfs.server.createMountPoints = true;
+ networking.firewall.enable = false; # FIXME: figure out what ports need to be allowed
+ };
+ };
+
+ testScript =
+ ''
+ import time
+
+ server.wait_for_unit("nfs-server")
+ server.succeed("systemctl start network-online.target")
+ server.wait_for_unit("network-online.target")
+
+ start_all()
+
+ client1.wait_for_unit("data.mount")
+ client1.succeed("echo bla > /data/foo")
+ server.succeed("test -e /data/foo")
+
+ client2.wait_for_unit("data.mount")
+ client2.succeed("echo bla > /data/bar")
+ server.succeed("test -e /data/bar")
+
+ with subtest("restarting 'nfs-server' works correctly"):
+ server.succeed("systemctl restart nfs-server")
+ # will take 90 seconds due to the NFS grace period
+ client2.succeed("echo bla >> /data/bar")
+
+ with subtest("can get a lock"):
+ client2.succeed("time flock -n -s /data/lock true")
+
+ with subtest("client 2 fails to acquire lock held by client 1"):
+ client1.succeed("flock -x /data/lock -c 'touch locked; sleep 100000' &")
+ client1.wait_for_file("locked")
+ client2.fail("flock -n -s /data/lock true")
+
+ with subtest("client 2 obtains lock after resetting client 1"):
+ client2.succeed(
+ "flock -x /data/lock -c 'echo acquired; touch locked; sleep 100000' >&2 &"
+ )
+ client1.crash()
+ client1.start()
+ client2.wait_for_file("locked")
+
+ with subtest("locks survive server reboot"):
+ client1.wait_for_unit("data.mount")
+ server.shutdown()
+ server.start()
+ client1.succeed("touch /data/xyzzy")
+ client1.fail("time flock -n -s /data/lock true")
+
+ with subtest("unmounting during shutdown happens quickly"):
+ t1 = time.monotonic()
+ client1.shutdown()
+ duration = time.monotonic() - t1
+ assert duration < 30, f"shutdown took too long ({duration} seconds)"
+ '';
+})
diff --git a/nixpkgs/nixos/tests/nghttpx.nix b/nixpkgs/nixos/tests/nghttpx.nix
index 11611bfe106..d83c1c4cae6 100644
--- a/nixpkgs/nixos/tests/nghttpx.nix
+++ b/nixpkgs/nixos/tests/nghttpx.nix
@@ -1,7 +1,7 @@
let
nginxRoot = "/run/nginx";
in
- import ./make-test.nix ({...}: {
+ import ./make-test-python.nix ({...}: {
name = "nghttpx";
nodes = {
webserver = {
@@ -52,10 +52,10 @@ in
};
testScript = ''
- startAll;
+ start_all()
- $webserver->waitForOpenPort("80");
- $proxy->waitForOpenPort("80");
- $client->waitUntilSucceeds("curl -s --fail http://proxy/hello-world.txt");
+ webserver.wait_for_open_port("80")
+ proxy.wait_for_open_port("80")
+ client.wait_until_succeeds("curl -s --fail http://proxy/hello-world.txt")
'';
})
diff --git a/nixpkgs/nixos/tests/nginx-etag.nix b/nixpkgs/nixos/tests/nginx-etag.nix
new file mode 100644
index 00000000000..e357309d166
--- /dev/null
+++ b/nixpkgs/nixos/tests/nginx-etag.nix
@@ -0,0 +1,89 @@
+import ./make-test-python.nix {
+ name = "nginx-etag";
+
+ nodes = {
+ server = { pkgs, lib, ... }: {
+ networking.firewall.enable = false;
+ services.nginx.enable = true;
+ services.nginx.virtualHosts.server = {
+ root = pkgs.runCommandLocal "testdir" {} ''
+ mkdir "$out"
+ cat > "$out/test.js" <<EOF
+ document.getElementById('foobar').setAttribute('foo', 'bar');
+ EOF
+ cat > "$out/index.html" <<EOF
+ <!DOCTYPE html>
+ <div id="foobar">test</div>
+ <script src="test.js"></script>
+ EOF
+ '';
+ };
+
+ nesting.clone = lib.singleton {
+ services.nginx.virtualHosts.server = {
+ root = lib.mkForce (pkgs.runCommandLocal "testdir2" {} ''
+ mkdir "$out"
+ cat > "$out/test.js" <<EOF
+ document.getElementById('foobar').setAttribute('foo', 'yay');
+ EOF
+ cat > "$out/index.html" <<EOF
+ <!DOCTYPE html>
+ <div id="foobar">test</div>
+ <script src="test.js"></script>
+ EOF
+ '');
+ };
+ };
+ };
+
+ client = { pkgs, lib, ... }: {
+ virtualisation.memorySize = 512;
+ environment.systemPackages = let
+ testRunner = pkgs.writers.writePython3Bin "test-runner" {
+ libraries = [ pkgs.python3Packages.selenium ];
+ } ''
+ import os
+ import time
+
+ from selenium.webdriver import Firefox
+ from selenium.webdriver.firefox.options import Options
+
+ options = Options()
+ options.add_argument('--headless')
+ driver = Firefox(options=options)
+
+ driver.implicitly_wait(20)
+ driver.get('http://server/')
+ driver.find_element_by_xpath('//div[@foo="bar"]')
+ open('/tmp/passed_stage1', 'w')
+
+ while not os.path.exists('/tmp/proceed'):
+ time.sleep(0.5)
+
+ driver.get('http://server/')
+ driver.find_element_by_xpath('//div[@foo="yay"]')
+ open('/tmp/passed', 'w')
+ '';
+ in [ pkgs.firefox-unwrapped pkgs.geckodriver testRunner ];
+ };
+ };
+
+ testScript = { nodes, ... }: let
+ inherit (nodes.server.config.system.build) toplevel;
+ newSystem = "${toplevel}/fine-tune/child-1";
+ in ''
+ start_all()
+
+ server.wait_for_unit("nginx.service")
+ client.wait_for_unit("multi-user.target")
+ client.execute("test-runner &")
+ client.wait_for_file("/tmp/passed_stage1")
+
+ server.succeed(
+ "${newSystem}/bin/switch-to-configuration test >&2"
+ )
+ client.succeed("touch /tmp/proceed")
+
+ client.wait_for_file("/tmp/passed")
+ '';
+}
diff --git a/nixpkgs/nixos/tests/nginx-sso.nix b/nixpkgs/nixos/tests/nginx-sso.nix
index e19992cb6bf..8834fc31c38 100644
--- a/nixpkgs/nixos/tests/nginx-sso.nix
+++ b/nixpkgs/nixos/tests/nginx-sso.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ pkgs, ... }: {
+import ./make-test-python.nix ({ pkgs, ... }: {
name = "nginx-sso";
meta = {
maintainers = with pkgs.stdenv.lib.maintainers; [ delroth ];
@@ -27,18 +27,22 @@ import ./make-test.nix ({ pkgs, ... }: {
};
testScript = ''
- startAll;
+ start_all()
- $machine->waitForUnit("nginx-sso.service");
- $machine->waitForOpenPort(8080);
+ machine.wait_for_unit("nginx-sso.service")
+ machine.wait_for_open_port(8080)
- # No valid user -> 401.
- $machine->fail("curl -sSf http://localhost:8080/auth");
+ with subtest("No valid user -> 401"):
+ machine.fail("curl -sSf http://localhost:8080/auth")
- # Valid user but no matching ACL -> 403.
- $machine->fail("curl -sSf -H 'Authorization: Token MyToken' http://localhost:8080/auth");
+ with subtest("Valid user but no matching ACL -> 403"):
+ machine.fail(
+ "curl -sSf -H 'Authorization: Token MyToken' http://localhost:8080/auth"
+ )
- # Valid user and matching ACL -> 200.
- $machine->succeed("curl -sSf -H 'Authorization: Token MyToken' -H 'X-Application: MyApp' http://localhost:8080/auth");
+ with subtest("Valid user and matching ACL -> 200"):
+ machine.succeed(
+ "curl -sSf -H 'Authorization: Token MyToken' -H 'X-Application: MyApp' http://localhost:8080/auth"
+ )
'';
})
diff --git a/nixpkgs/nixos/tests/nginx.nix b/nixpkgs/nixos/tests/nginx.nix
index d0b7306ae83..7358800a676 100644
--- a/nixpkgs/nixos/tests/nginx.nix
+++ b/nixpkgs/nixos/tests/nginx.nix
@@ -4,10 +4,10 @@
# 2. whether the ETag header is properly generated whenever we're serving
# files in Nix store paths
# 3. nginx doesn't restart on configuration changes (only reloads)
-import ./make-test.nix ({ pkgs, ... }: {
+import ./make-test-python.nix ({ pkgs, ... }: {
name = "nginx";
meta = with pkgs.stdenv.lib.maintainers; {
- maintainers = [ mbbx6spp ];
+ maintainers = [ mbbx6spp danbst ];
};
nodes = {
@@ -59,6 +59,11 @@ import ./make-test.nix ({ pkgs, ... }: {
{
services.nginx.package = pkgs.nginxUnstable;
}
+
+ {
+ services.nginx.package = pkgs.nginxUnstable;
+ services.nginx.virtualHosts."!@$$(#*%".locations."~@#*$*!)".proxyPass = ";;;";
+ }
];
};
@@ -68,44 +73,60 @@ import ./make-test.nix ({ pkgs, ... }: {
etagSystem = "${nodes.webserver.config.system.build.toplevel}/fine-tune/child-1";
justReloadSystem = "${nodes.webserver.config.system.build.toplevel}/fine-tune/child-2";
reloadRestartSystem = "${nodes.webserver.config.system.build.toplevel}/fine-tune/child-3";
+ reloadWithErrorsSystem = "${nodes.webserver.config.system.build.toplevel}/fine-tune/child-4";
in ''
- my $url = 'http://localhost/index.html';
-
- sub checkEtag {
- my $etag = $webserver->succeed(
- 'curl -v '.$url.' 2>&1 | sed -n -e "s/^< [Ee][Tt][Aa][Gg]: *//p"'
- );
- $etag =~ s/\r?\n$//;
- my $httpCode = $webserver->succeed(
- 'curl -w "%{http_code}" -X HEAD -H \'If-None-Match: '.$etag.'\' '.$url
- );
- chomp $httpCode;
- die "HTTP code is not 304" unless $httpCode == 304;
- return $etag;
- }
-
- $webserver->waitForUnit("nginx");
- $webserver->waitForOpenPort("80");
-
- subtest "check ETag if serving Nix store paths", sub {
- my $oldEtag = checkEtag;
- $webserver->succeed("${etagSystem}/bin/switch-to-configuration test >&2");
- $webserver->sleep(1); # race condition
- my $newEtag = checkEtag;
- die "Old ETag $oldEtag is the same as $newEtag" if $oldEtag eq $newEtag;
- };
+ url = "http://localhost/index.html"
- subtest "config is reloaded on nixos-rebuild switch", sub {
- $webserver->succeed("${justReloadSystem}/bin/switch-to-configuration test >&2");
- $webserver->waitForOpenPort("8080");
- $webserver->fail("journalctl -u nginx | grep -q -i stopped");
- $webserver->succeed("journalctl -u nginx | grep -q -i reloaded");
- };
- subtest "restart when nginx package changes", sub {
- $webserver->succeed("${reloadRestartSystem}/bin/switch-to-configuration test >&2");
- $webserver->waitForUnit("nginx");
- $webserver->succeed("journalctl -u nginx | grep -q -i stopped");
- };
+ def check_etag():
+ etag = webserver.succeed(
+ f'curl -v {url} 2>&1 | sed -n -e "s/^< etag: *//ip"'
+ ).rstrip()
+ http_code = webserver.succeed(
+ f"curl -w '%{{http_code}}' --head --fail -H 'If-None-Match: {etag}' {url}"
+ )
+ assert http_code.split("\n")[-1] == "304"
+
+ return etag
+
+
+ webserver.wait_for_unit("nginx")
+ webserver.wait_for_open_port(80)
+
+ with subtest("check ETag if serving Nix store paths"):
+ old_etag = check_etag()
+ webserver.succeed(
+ "${etagSystem}/bin/switch-to-configuration test >&2"
+ )
+ webserver.sleep(1)
+ new_etag = check_etag()
+ assert old_etag != new_etag
+
+ with subtest("config is reloaded on nixos-rebuild switch"):
+ webserver.succeed(
+ "${justReloadSystem}/bin/switch-to-configuration test >&2"
+ )
+ webserver.wait_for_open_port(8080)
+ webserver.fail("journalctl -u nginx | grep -q -i stopped")
+ webserver.succeed("journalctl -u nginx | grep -q -i reloaded")
+
+ with subtest("restart when nginx package changes"):
+ webserver.succeed(
+ "${reloadRestartSystem}/bin/switch-to-configuration test >&2"
+ )
+ webserver.wait_for_unit("nginx")
+ webserver.succeed("journalctl -u nginx | grep -q -i stopped")
+
+ with subtest("nixos-rebuild --switch should fail when there are configuration errors"):
+ webserver.fail(
+ "${reloadWithErrorsSystem}/bin/switch-to-configuration test >&2"
+ )
+ webserver.succeed("[[ $(systemctl is-failed nginx-config-reload) == failed ]]")
+ webserver.succeed("[[ $(systemctl is-failed nginx) == active ]]")
+ # just to make sure operation is idempotent. During development I had a situation
+ # when first time it shows error, but stops showing it on subsequent rebuilds
+ webserver.fail(
+ "${reloadWithErrorsSystem}/bin/switch-to-configuration test >&2"
+ )
'';
})
diff --git a/nixpkgs/nixos/tests/novacomd.nix b/nixpkgs/nixos/tests/novacomd.nix
index 4eb60c0feb5..940210dee23 100644
--- a/nixpkgs/nixos/tests/novacomd.nix
+++ b/nixpkgs/nixos/tests/novacomd.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ pkgs, ...} : {
+import ./make-test-python.nix ({ pkgs, ...} : {
name = "novacomd";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ dtzWill ];
@@ -9,26 +9,20 @@ import ./make-test.nix ({ pkgs, ...} : {
};
testScript = ''
- $machine->waitForUnit("multi-user.target");
+ machine.wait_for_unit("novacomd.service")
- # multi-user.target wants novacomd.service, but let's make sure
- $machine->waitForUnit("novacomd.service");
+ with subtest("Make sure the daemon is really listening"):
+ machine.wait_for_open_port(6968)
+ machine.succeed("novacom -l")
- # Check status and try connecting with novacom
- $machine->succeed("systemctl status novacomd.service >&2");
- # to prevent non-deterministic failure,
- # make sure the daemon is really listening
- $machine->waitForOpenPort(6968);
- $machine->succeed("novacom -l");
+ with subtest("Stop the daemon, double-check novacom fails if daemon isn't working"):
+ machine.stop_job("novacomd")
+ machine.fail("novacom -l")
- # Stop the daemon, double-check novacom fails if daemon isn't working
- $machine->stopJob("novacomd");
- $machine->fail("novacom -l");
-
- # And back again for good measure
- $machine->startJob("novacomd");
- # make sure the daemon is really listening
- $machine->waitForOpenPort(6968);
- $machine->succeed("novacom -l");
+ with subtest("Make sure the daemon starts back up again"):
+ machine.start_job("novacomd")
+ # make sure the daemon is really listening
+ machine.wait_for_open_port(6968)
+ machine.succeed("novacom -l")
'';
})
diff --git a/nixpkgs/nixos/tests/nzbget.nix b/nixpkgs/nixos/tests/nzbget.nix
index 042ccec98cf..12d8ed6ea8d 100644
--- a/nixpkgs/nixos/tests/nzbget.nix
+++ b/nixpkgs/nixos/tests/nzbget.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ pkgs, ...} : {
+import ./make-test-python.nix ({ pkgs, ...} : {
name = "nzbget";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ aanderse flokli ];
@@ -15,12 +15,16 @@ import ./make-test.nix ({ pkgs, ...} : {
};
testScript = ''
- startAll;
+ start_all()
- $server->waitForUnit("nzbget.service");
- $server->waitForUnit("network.target");
- $server->waitForOpenPort(6789);
- $server->succeed("curl -s -u nzbget:tegbzn6789 http://127.0.0.1:6789 | grep -q 'This file is part of nzbget'");
- $server->succeed("${pkgs.nzbget}/bin/nzbget -n -o ControlIP=127.0.0.1 -o ControlPort=6789 -o ControlPassword=tegbzn6789 -V");
+ server.wait_for_unit("nzbget.service")
+ server.wait_for_unit("network.target")
+ server.wait_for_open_port(6789)
+ assert "This file is part of nzbget" in server.succeed(
+ "curl -s -u nzbget:tegbzn6789 http://127.0.0.1:6789"
+ )
+ server.succeed(
+ "${pkgs.nzbget}/bin/nzbget -n -o Control_iP=127.0.0.1 -o Control_port=6789 -o Control_password=tegbzn6789 -V"
+ )
'';
})
diff --git a/nixpkgs/nixos/tests/openarena.nix b/nixpkgs/nixos/tests/openarena.nix
index 4cc4db22963..b315426532b 100644
--- a/nixpkgs/nixos/tests/openarena.nix
+++ b/nixpkgs/nixos/tests/openarena.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ pkgs, ...} : {
+import ./make-test-python.nix ({ pkgs, ...} : {
name = "openarena";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ tomfitzhenry ];
@@ -23,14 +23,19 @@ import ./make-test.nix ({ pkgs, ...} : {
testScript =
''
- $machine->waitForUnit("openarena.service");
- $machine->waitUntilSucceeds("ss --numeric --udp --listening | grep -q 27960");
+ machine.wait_for_unit("openarena.service")
+ machine.wait_until_succeeds("ss --numeric --udp --listening | grep -q 27960")
# The log line containing 'resolve address' is last and only message that occurs after
# the server starts accepting clients.
- $machine->waitUntilSucceeds("journalctl -u openarena.service | grep 'resolve address: dpmaster.deathmask.net'");
+ machine.wait_until_succeeds(
+ "journalctl -u openarena.service | grep 'resolve address: dpmaster.deathmask.net'"
+ )
# Check it's possible to join the server.
- $machine->succeed("echo -n -e '\\xff\\xff\\xff\\xffgetchallenge' | socat - UDP4-DATAGRAM:127.0.0.1:27960 | grep -q challengeResponse");
+ # Can't use substring match instead of grep because the output is not utf-8
+ machine.succeed(
+ "echo -n -e '\\xff\\xff\\xff\\xffgetchallenge' | socat - UDP4-DATAGRAM:127.0.0.1:27960 | grep -q challengeResponse"
+ )
'';
})
diff --git a/nixpkgs/nixos/tests/openldap.nix b/nixpkgs/nixos/tests/openldap.nix
index 3ef90e18347..f8321a2c522 100644
--- a/nixpkgs/nixos/tests/openldap.nix
+++ b/nixpkgs/nixos/tests/openldap.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix {
+import ./make-test-python.nix {
name = "openldap";
machine = { pkgs, ... }: {
@@ -24,8 +24,10 @@ import ./make-test.nix {
};
testScript = ''
- $machine->waitForUnit('openldap.service');
- $machine->succeed('systemctl status openldap.service');
- $machine->succeed('ldapsearch -LLL -D "cn=root,dc=example" -w notapassword -b "dc=example"');
+ machine.wait_for_unit("openldap.service")
+ machine.succeed(
+ "systemctl status openldap.service",
+ 'ldapsearch -LLL -D "cn=root,dc=example" -w notapassword -b "dc=example"',
+ )
'';
}
diff --git a/nixpkgs/nixos/tests/orangefs.nix b/nixpkgs/nixos/tests/orangefs.nix
index bdf4fc10c44..46d7a6a72f8 100644
--- a/nixpkgs/nixos/tests/orangefs.nix
+++ b/nixpkgs/nixos/tests/orangefs.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ ... } :
+import ./make-test-python.nix ({ ... } :
let
server = { pkgs, ... } : {
@@ -52,37 +52,31 @@ in {
testScript = ''
# format storage
- foreach my $server (($server1,$server2))
- {
- $server->start();
- $server->waitForUnit("multi-user.target");
- $server->succeed("mkdir -p /data/storage /data/meta");
- $server->succeed("chown orangefs:orangefs /data/storage /data/meta");
- $server->succeed("chmod 0770 /data/storage /data/meta");
- $server->succeed("sudo -g orangefs -u orangefs pvfs2-server -f /etc/orangefs/server.conf");
- }
+ for server in server1, server2:
+ server.start()
+ server.wait_for_unit("multi-user.target")
+ server.succeed("mkdir -p /data/storage /data/meta")
+ server.succeed("chown orangefs:orangefs /data/storage /data/meta")
+ server.succeed("chmod 0770 /data/storage /data/meta")
+ server.succeed(
+ "sudo -g orangefs -u orangefs pvfs2-server -f /etc/orangefs/server.conf"
+ )
# start services after storage is formated on all machines
- foreach my $server (($server1,$server2))
- {
- $server->succeed("systemctl start orangefs-server.service");
- }
+ for server in server1, server2:
+ server.succeed("systemctl start orangefs-server.service")
- # Check if clients can reach and mount the FS
- foreach my $client (($client1,$client2))
- {
- $client->start();
- $client->waitForUnit("orangefs-client.service");
- # Both servers need to be reachable
- $client->succeed("pvfs2-check-server -h server1 -f orangefs -n tcp -p 3334");
- $client->succeed("pvfs2-check-server -h server2 -f orangefs -n tcp -p 3334");
- $client->waitForUnit("orangefs.mount");
-
- }
-
- # R/W test between clients
- $client1->succeed("echo test > /orangefs/file1");
- $client2->succeed("grep test /orangefs/file1");
+ with subtest("clients can reach and mount the FS"):
+ for client in client1, client2:
+ client.start()
+ client.wait_for_unit("orangefs-client.service")
+ # Both servers need to be reachable
+ client.succeed("pvfs2-check-server -h server1 -f orangefs -n tcp -p 3334")
+ client.succeed("pvfs2-check-server -h server2 -f orangefs -n tcp -p 3334")
+ client.wait_for_unit("orangefs.mount")
+ with subtest("R/W test between clients"):
+ client1.succeed("echo test > /orangefs/file1")
+ client2.succeed("grep test /orangefs/file1")
'';
})
diff --git a/nixpkgs/nixos/tests/osrm-backend.nix b/nixpkgs/nixos/tests/osrm-backend.nix
index 6e2d098d4ad..db67a5a589f 100644
--- a/nixpkgs/nixos/tests/osrm-backend.nix
+++ b/nixpkgs/nixos/tests/osrm-backend.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ pkgs, lib, ... }:
+import ./make-test-python.nix ({ pkgs, lib, ... }:
let
port = 5000;
in {
@@ -45,9 +45,13 @@ in {
testScript = let
query = "http://localhost:${toString port}/route/v1/driving/7.41720,43.73304;7.42463,43.73886?steps=true";
in ''
- $machine->waitForUnit("osrm.service");
- $machine->waitForOpenPort(${toString port});
- $machine->succeed("curl --silent '${query}' | jq .waypoints[0].name | grep -F 'Boulevard Rainier III'");
- $machine->succeed("curl --silent '${query}' | jq .waypoints[1].name | grep -F 'Avenue de la Costa'");
+ machine.wait_for_unit("osrm.service")
+ machine.wait_for_open_port(${toString port})
+ assert "Boulevard Rainier III" in machine.succeed(
+ "curl --silent '${query}' | jq .waypoints[0].name"
+ )
+ assert "Avenue de la Costa" in machine.succeed(
+ "curl --silent '${query}' | jq .waypoints[1].name"
+ )
'';
})
diff --git a/nixpkgs/nixos/tests/overlayfs.nix b/nixpkgs/nixos/tests/overlayfs.nix
index 99bb6b0f553..33794deb9ed 100644
--- a/nixpkgs/nixos/tests/overlayfs.nix
+++ b/nixpkgs/nixos/tests/overlayfs.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ pkgs, ... }: {
+import ./make-test-python.nix ({ pkgs, ... }: {
name = "overlayfs";
meta.maintainers = with pkgs.stdenv.lib.maintainers; [ bachp ];
@@ -9,49 +9,42 @@ import ./make-test.nix ({ pkgs, ... }: {
};
testScript = ''
- $machine->succeed("ls /dev");
+ machine.succeed("ls /dev")
- $machine->succeed("mkdir -p /tmp/mnt");
+ machine.succeed("mkdir -p /tmp/mnt")
# Test ext4 + overlayfs
- $machine->succeed(
-
- "mkfs.ext4 -F -L overlay-ext4 /dev/vdb",
- "mount -t ext4 /dev/vdb /tmp/mnt",
-
- "mkdir -p /tmp/mnt/upper /tmp/mnt/lower /tmp/mnt/work /tmp/mnt/merged",
-
- # Setup some existing files
- "echo 'Replace' > /tmp/mnt/lower/replace.txt",
- "echo 'Append' > /tmp/mnt/lower/append.txt",
- "echo 'Overwrite' > /tmp/mnt/lower/overwrite.txt",
-
- "mount -t overlay overlay -o lowerdir=/tmp/mnt/lower,upperdir=/tmp/mnt/upper,workdir=/tmp/mnt/work /tmp/mnt/merged",
-
- # Test new
- "echo 'New' > /tmp/mnt/merged/new.txt",
- "[[ \"\$(cat /tmp/mnt/merged/new.txt)\" == \"New\" ]]",
-
- # Test replace
- "[[ \"\$(cat /tmp/mnt/merged/replace.txt)\" == \"Replace\" ]]",
- "echo 'Replaced' > /tmp/mnt/merged/replace-tmp.txt",
- "mv /tmp/mnt/merged/replace-tmp.txt /tmp/mnt/merged/replace.txt",
- "[[ \"\$(cat /tmp/mnt/merged/replace.txt)\" == \"Replaced\" ]]",
-
- # Overwrite
- "[[ \"\$(cat /tmp/mnt/merged/overwrite.txt)\" == \"Overwrite\" ]]",
- "echo 'Overwritten' > /tmp/mnt/merged/overwrite.txt",
- "[[ \"\$(cat /tmp/mnt/merged/overwrite.txt)\" == \"Overwritten\" ]]",
-
- # Test append
- "[[ \"\$(cat /tmp/mnt/merged/append.txt)\" == \"Append\" ]]",
- "echo 'ed' >> /tmp/mnt/merged/append.txt",
- #"cat /tmp/mnt/merged/append.txt && exit 1",
- "[[ \"\$(cat /tmp/mnt/merged/append.txt)\" == \"Append\ned\" ]]",
-
- "umount /tmp/mnt/merged",
- "umount /tmp/mnt",
- "udevadm settle"
- );
+ machine.succeed(
+ """
+ mkfs.ext4 -F -L overlay-ext4 /dev/vdb
+ mount -t ext4 /dev/vdb /tmp/mnt
+ mkdir -p /tmp/mnt/upper /tmp/mnt/lower /tmp/mnt/work /tmp/mnt/merged
+ # Setup some existing files
+ echo 'Replace' > /tmp/mnt/lower/replace.txt
+ echo 'Append' > /tmp/mnt/lower/append.txt
+ echo 'Overwrite' > /tmp/mnt/lower/overwrite.txt
+ mount -t overlay overlay -o lowerdir=/tmp/mnt/lower,upperdir=/tmp/mnt/upper,workdir=/tmp/mnt/work /tmp/mnt/merged
+ # Test new
+ echo 'New' > /tmp/mnt/merged/new.txt
+ [[ "\$(cat /tmp/mnt/merged/new.txt)" == "New" ]]
+ # Test replace
+ [[ "\$(cat /tmp/mnt/merged/replace.txt)" == "Replace" ]]
+ echo 'Replaced' > /tmp/mnt/merged/replace-tmp.txt
+ mv /tmp/mnt/merged/replace-tmp.txt /tmp/mnt/merged/replace.txt
+ [[ "\$(cat /tmp/mnt/merged/replace.txt)" == "Replaced" ]]
+ # Overwrite
+ [[ "\$(cat /tmp/mnt/merged/overwrite.txt)" == "Overwrite" ]]
+ echo 'Overwritten' > /tmp/mnt/merged/overwrite.txt
+ [[ "\$(cat /tmp/mnt/merged/overwrite.txt)" == "Overwritten" ]]
+ # Test append
+ [[ "\$(cat /tmp/mnt/merged/append.txt)" == "Append" ]]
+ echo 'ed' >> /tmp/mnt/merged/append.txt
+ #"cat /tmp/mnt/merged/append.txt && exit 1
+ [[ "\$(cat /tmp/mnt/merged/append.txt)" == "Append\ned" ]]
+ umount /tmp/mnt/merged
+ umount /tmp/mnt
+ udevadm settle
+ """
+ )
'';
})
diff --git a/nixpkgs/nixos/tests/pam-oath-login.nix b/nixpkgs/nixos/tests/pam-oath-login.nix
index b9d489950e7..6d48199eda9 100644
--- a/nixpkgs/nixos/tests/pam-oath-login.nix
+++ b/nixpkgs/nixos/tests/pam-oath-login.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ ... }:
+import ./make-test-python.nix ({ ... }:
let
oathSnakeoilSecret = "cdd4083ef8ff1fa9178c6d46bfb1a3";
@@ -55,70 +55,54 @@ in
};
};
- testScript =
- ''
- $machine->waitForUnit('multi-user.target');
- $machine->waitUntilSucceeds("pgrep -f 'agetty.*tty1'");
- $machine->screenshot("postboot");
-
-
- subtest "Invalid password", sub {
- $machine->fail("pgrep -f 'agetty.*tty2'");
- $machine->sendKeys("alt-f2");
- $machine->waitUntilSucceeds("[ \$(fgconsole) = 2 ]");
- $machine->waitForUnit('getty@tty2.service');
- $machine->waitUntilSucceeds("pgrep -f 'agetty.*tty2'");
-
- $machine->waitUntilTTYMatches(2, "login: ");
- $machine->sendChars("alice\n");
- $machine->waitUntilTTYMatches(2, "login: alice");
- $machine->waitUntilSucceeds("pgrep login");
-
- $machine->waitUntilTTYMatches(2, "One-time password");
- $machine->sendChars("${oathSnakeOilPassword1}\n");
- $machine->waitUntilTTYMatches(2, "Password: ");
- $machine->sendChars("blorg\n");
- $machine->waitUntilTTYMatches(2, "Login incorrect");
- };
+ testScript = ''
+ def switch_to_tty(tty_number):
+ machine.fail(f"pgrep -f 'agetty.*tty{tty_number}'")
+ machine.send_key(f"alt-f{tty_number}")
+ machine.wait_until_succeeds(f"[ $(fgconsole) = {tty_number} ]")
+ machine.wait_for_unit(f"getty@tty{tty_number}.service")
+ machine.wait_until_succeeds(f"pgrep -f 'agetty.*tty{tty_number}'")
- subtest "Invalid oath token", sub {
- $machine->fail("pgrep -f 'agetty.*tty3'");
- $machine->sendKeys("alt-f3");
- $machine->waitUntilSucceeds("[ \$(fgconsole) = 3 ]");
- $machine->waitForUnit('getty@tty3.service');
- $machine->waitUntilSucceeds("pgrep -f 'agetty.*tty3'");
-
- $machine->waitUntilTTYMatches(3, "login: ");
- $machine->sendChars("alice\n");
- $machine->waitUntilTTYMatches(3, "login: alice");
- $machine->waitUntilSucceeds("pgrep login");
- $machine->waitUntilTTYMatches(3, "One-time password");
- $machine->sendChars("000000\n");
- $machine->waitUntilTTYMatches(3, "Login incorrect");
- $machine->waitUntilTTYMatches(3, "login:");
- };
- subtest "Happy path (both passwords are mandatory to get us in)", sub {
- $machine->fail("pgrep -f 'agetty.*tty4'");
- $machine->sendKeys("alt-f4");
- $machine->waitUntilSucceeds("[ \$(fgconsole) = 4 ]");
- $machine->waitForUnit('getty@tty4.service');
- $machine->waitUntilSucceeds("pgrep -f 'agetty.*tty4'");
-
- $machine->waitUntilTTYMatches(4, "login: ");
- $machine->sendChars("alice\n");
- $machine->waitUntilTTYMatches(4, "login: alice");
- $machine->waitUntilSucceeds("pgrep login");
- $machine->waitUntilTTYMatches(4, "One-time password");
- $machine->sendChars("${oathSnakeOilPassword2}\n");
- $machine->waitUntilTTYMatches(4, "Password: ");
- $machine->sendChars("${alicePassword}\n");
-
- $machine->waitUntilSucceeds("pgrep -u alice bash");
- $machine->sendChars("touch done4\n");
- $machine->waitForFile("/home/alice/done4");
- };
+ def enter_user_alice(tty_number):
+ machine.wait_until_tty_matches(tty_number, "login: ")
+ machine.send_chars("alice\n")
+ machine.wait_until_tty_matches(tty_number, "login: alice")
+ machine.wait_until_succeeds("pgrep login")
+ machine.wait_until_tty_matches(tty_number, "One-time password")
- '';
+ machine.wait_for_unit("multi-user.target")
+ machine.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
+ machine.screenshot("postboot")
+
+ with subtest("Invalid password"):
+ switch_to_tty(2)
+ enter_user_alice(2)
+
+ machine.send_chars("${oathSnakeOilPassword1}\n")
+ machine.wait_until_tty_matches(2, "Password: ")
+ machine.send_chars("blorg\n")
+ machine.wait_until_tty_matches(2, "Login incorrect")
+
+ with subtest("Invalid oath token"):
+ switch_to_tty(3)
+ enter_user_alice(3)
+
+ machine.send_chars("000000\n")
+ machine.wait_until_tty_matches(3, "Login incorrect")
+ machine.wait_until_tty_matches(3, "login:")
+
+ with subtest("Happy path: Both passwords are mandatory to get us in"):
+ switch_to_tty(4)
+ enter_user_alice(4)
+
+ machine.send_chars("${oathSnakeOilPassword2}\n")
+ machine.wait_until_tty_matches(4, "Password: ")
+ machine.send_chars("${alicePassword}\n")
+
+ machine.wait_until_succeeds("pgrep -u alice bash")
+ machine.send_chars("touch done4\n")
+ machine.wait_for_file("/home/alice/done4")
+ '';
})
diff --git a/nixpkgs/nixos/tests/pam-u2f.nix b/nixpkgs/nixos/tests/pam-u2f.nix
index 1052a2f3b91..f492baa9e13 100644
--- a/nixpkgs/nixos/tests/pam-u2f.nix
+++ b/nixpkgs/nixos/tests/pam-u2f.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ ... }:
+import ./make-test-python.nix ({ ... }:
{
name = "pam-u2f";
@@ -17,7 +17,9 @@ import ./make-test.nix ({ ... }:
testScript =
''
- $machine->waitForUnit('multi-user.target');
- $machine->succeed('egrep "auth required .*/lib/security/pam_u2f.so.*debug.*interactive.*cue" /etc/pam.d/ -R');
+ machine.wait_for_unit("multi-user.target")
+ machine.succeed(
+ 'egrep "auth required .*/lib/security/pam_u2f.so.*debug.*interactive.*cue" /etc/pam.d/ -R'
+ )
'';
})
diff --git a/nixpkgs/nixos/tests/paperless.nix b/nixpkgs/nixos/tests/paperless.nix
index 860ad0a6218..355e7041d3f 100644
--- a/nixpkgs/nixos/tests/paperless.nix
+++ b/nixpkgs/nixos/tests/paperless.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ lib, ... } : {
+import ./make-test-python.nix ({ lib, ... } : {
name = "paperless";
meta = with lib.maintainers; {
maintainers = [ earvstedt ];
@@ -13,17 +13,24 @@ import ./make-test.nix ({ lib, ... } : {
};
testScript = ''
- $machine->waitForUnit("paperless-consumer.service");
+ machine.wait_for_unit("paperless-consumer.service")
+
# Create test doc
- $machine->succeed('convert -size 400x40 xc:white -font "DejaVu-Sans" -pointsize 20 -fill black \
- -annotate +5+20 "hello world 16-10-2005" /var/lib/paperless/consume/doc.png');
+ machine.succeed(
+ "convert -size 400x40 xc:white -font 'DejaVu-Sans' -pointsize 20 -fill black -annotate +5+20 'hello world 16-10-2005' /var/lib/paperless/consume/doc.png"
+ )
+
+ with subtest("Service gets ready"):
+ machine.wait_for_unit("paperless-server.service")
+ # Wait until server accepts connections
+ machine.wait_until_succeeds("curl -s localhost:28981")
- $machine->waitForUnit("paperless-server.service");
- # Wait until server accepts connections
- $machine->waitUntilSucceeds("curl -s localhost:28981");
- # Wait until document is consumed
- $machine->waitUntilSucceeds('(($(curl -s localhost:28981/api/documents/ | jq .count) == 1))');
- $machine->succeed("curl -s localhost:28981/api/documents/ | jq '.results | .[0] | .created'")
- =~ /2005-10-16/ or die;
+ with subtest("Test document is consumed"):
+ machine.wait_until_succeeds(
+ "(($(curl -s localhost:28981/api/documents/ | jq .count) == 1))"
+ )
+ assert "2005-10-16" in machine.succeed(
+ "curl -s localhost:28981/api/documents/ | jq '.results | .[0] | .created'"
+ )
'';
})
diff --git a/nixpkgs/nixos/tests/pdns-recursor.nix b/nixpkgs/nixos/tests/pdns-recursor.nix
index bf6e6093d69..de1b60e0b1c 100644
--- a/nixpkgs/nixos/tests/pdns-recursor.nix
+++ b/nixpkgs/nixos/tests/pdns-recursor.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ pkgs, ... }: {
+import ./make-test-python.nix ({ pkgs, ... }: {
name = "powerdns";
nodes.server = { ... }: {
@@ -6,7 +6,7 @@ import ./make-test.nix ({ pkgs, ... }: {
};
testScript = ''
- $server->waitForUnit("pdns-recursor");
- $server->waitForOpenPort("53");
+ server.wait_for_unit("pdns-recursor")
+ server.wait_for_open_port("53")
'';
})
diff --git a/nixpkgs/nixos/tests/peerflix.nix b/nixpkgs/nixos/tests/peerflix.nix
index fae37fedaac..37628604d49 100644
--- a/nixpkgs/nixos/tests/peerflix.nix
+++ b/nixpkgs/nixos/tests/peerflix.nix
@@ -1,6 +1,6 @@
# This test runs peerflix and checks if peerflix starts
-import ./make-test.nix ({ pkgs, ...} : {
+import ./make-test-python.nix ({ pkgs, ...} : {
name = "peerflix";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ offline ];
@@ -15,9 +15,9 @@ import ./make-test.nix ({ pkgs, ...} : {
};
testScript = ''
- startAll;
+ start_all()
- $peerflix->waitForUnit("peerflix.service");
- $peerflix->waitUntilSucceeds("curl localhost:9000");
+ peerflix.wait_for_unit("peerflix.service")
+ peerflix.wait_until_succeeds("curl localhost:9000")
'';
})
diff --git a/nixpkgs/nixos/tests/pgmanage.nix b/nixpkgs/nixos/tests/pgmanage.nix
index bacaf3f4158..4f5dbed24a9 100644
--- a/nixpkgs/nixos/tests/pgmanage.nix
+++ b/nixpkgs/nixos/tests/pgmanage.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ pkgs, ... } :
+import ./make-test-python.nix ({ pkgs, ... } :
let
role = "test";
password = "secret";
@@ -29,11 +29,13 @@ in
};
testScript = ''
- startAll;
- $one->waitForUnit("default.target");
- $one->requireActiveUnit("pgmanage.service");
+ start_all()
+ one.wait_for_unit("default.target")
+ one.require_unit_state("pgmanage.service", "active")
# Test if we can log in.
- $one->waitUntilSucceeds("curl 'http://localhost:8080/pgmanage/auth' --data 'action=login&connname=${conn}&username=${role}&password=${password}' --fail");
+ one.wait_until_succeeds(
+ "curl 'http://localhost:8080/pgmanage/auth' --data 'action=login&connname=${conn}&username=${role}&password=${password}' --fail"
+ )
'';
})
diff --git a/nixpkgs/nixos/tests/php-pcre.nix b/nixpkgs/nixos/tests/php-pcre.nix
index ae44aec7944..d5c22e0582a 100644
--- a/nixpkgs/nixos/tests/php-pcre.nix
+++ b/nixpkgs/nixos/tests/php-pcre.nix
@@ -1,7 +1,7 @@
let testString = "can-use-subgroups"; in
-import ./make-test.nix ({ ...}: {
+import ./make-test-python.nix ({ ...}: {
name = "php-httpd-pcre-jit-test";
machine = { lib, pkgs, ... }: {
time.timeZone = "UTC";
@@ -31,9 +31,10 @@ import ./make-test.nix ({ ...}: {
};
testScript = { ... }:
''
- $machine->waitForUnit('httpd.service');
+ machine.wait_for_unit("httpd.service")
# Ensure php evaluation by matching on the var_dump syntax
- $machine->succeed('curl -vvv -s http://127.0.0.1:80/index.php \
- | grep "string(${toString (builtins.stringLength testString)}) \"${testString}\""');
+ assert 'string(${toString (builtins.stringLength testString)}) "${testString}"' in machine.succeed(
+ "curl -vvv -s http://127.0.0.1:80/index.php"
+ )
'';
})
diff --git a/nixpkgs/nixos/tests/plasma5.nix b/nixpkgs/nixos/tests/plasma5.nix
index 6884f17aabb..2eccfdf47f5 100644
--- a/nixpkgs/nixos/tests/plasma5.nix
+++ b/nixpkgs/nixos/tests/plasma5.nix
@@ -12,8 +12,8 @@ import ./make-test-python.nix ({ pkgs, ...} :
imports = [ ./common/user-account.nix ];
services.xserver.enable = true;
services.xserver.displayManager.sddm.enable = true;
+ services.xserver.displayManager.defaultSession = "plasma5";
services.xserver.desktopManager.plasma5.enable = true;
- services.xserver.desktopManager.default = "plasma5";
services.xserver.displayManager.sddm.autoLogin = {
enable = true;
user = "alice";
diff --git a/nixpkgs/nixos/tests/postgis.nix b/nixpkgs/nixos/tests/postgis.nix
index 294eb50b5fe..84bbb0bc8ec 100644
--- a/nixpkgs/nixos/tests/postgis.nix
+++ b/nixpkgs/nixos/tests/postgis.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ pkgs, ...} : {
+import ./make-test-python.nix ({ pkgs, ...} : {
name = "postgis";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ lsix ];
@@ -20,10 +20,10 @@ import ./make-test.nix ({ pkgs, ...} : {
};
testScript = ''
- startAll;
- $master->waitForUnit("postgresql");
- $master->sleep(10); # Hopefully this is long enough!!
- $master->succeed("sudo -u postgres psql -c 'CREATE EXTENSION postgis;'");
- $master->succeed("sudo -u postgres psql -c 'CREATE EXTENSION postgis_topology;'");
+ start_all()
+ master.wait_for_unit("postgresql")
+ master.sleep(10) # Hopefully this is long enough!!
+ master.succeed("sudo -u postgres psql -c 'CREATE EXTENSION postgis;'")
+ master.succeed("sudo -u postgres psql -c 'CREATE EXTENSION postgis_topology;'")
'';
})
diff --git a/nixpkgs/nixos/tests/predictable-interface-names.nix b/nixpkgs/nixos/tests/predictable-interface-names.nix
index 194b4dafa77..83883477a5c 100644
--- a/nixpkgs/nixos/tests/predictable-interface-names.nix
+++ b/nixpkgs/nixos/tests/predictable-interface-names.nix
@@ -4,7 +4,7 @@
}:
let
- inherit (import ../lib/testing.nix { inherit system pkgs; }) makeTest;
+ inherit (import ../lib/testing-python.nix { inherit system pkgs; }) makeTest;
in pkgs.lib.listToAttrs (pkgs.lib.crossLists (predictable: withNetworkd: {
name = pkgs.lib.optionalString (!predictable) "un" + "predictable"
+ pkgs.lib.optionalString withNetworkd "Networkd";
@@ -20,8 +20,8 @@ in pkgs.lib.listToAttrs (pkgs.lib.crossLists (predictable: withNetworkd: {
};
testScript = ''
- print $machine->succeed("ip link");
- $machine->${if predictable then "fail" else "succeed"}("ip link show eth0 ");
+ print(machine.succeed("ip link"))
+ machine.${if predictable then "fail" else "succeed"}("ip link show eth0")
'';
};
}) [[true false] [true false]])
diff --git a/nixpkgs/nixos/tests/proxy.nix b/nixpkgs/nixos/tests/proxy.nix
index 1f39e903cdd..3859d429c21 100644
--- a/nixpkgs/nixos/tests/proxy.nix
+++ b/nixpkgs/nixos/tests/proxy.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ pkgs, ...} :
+import ./make-test.nix ({ pkgs, ...} :
let
@@ -7,7 +7,7 @@ let
{ services.httpd.enable = true;
services.httpd.adminAddr = "foo@example.org";
- services.httpd.documentRoot = "${pkgs.valgrind.doc}/share/doc/valgrind/html";
+ services.httpd.virtualHosts.localhost.documentRoot = "${pkgs.valgrind.doc}/share/doc/valgrind/html";
networking.firewall.allowedTCPPorts = [ 80 ];
};
@@ -26,11 +26,11 @@ in
{ services.httpd.enable = true;
services.httpd.adminAddr = "bar@example.org";
services.httpd.extraModules = [ "proxy_balancer" "lbmethod_byrequests" ];
-
- services.httpd.extraConfig =
- ''
- ExtendedStatus on
-
+ services.httpd.extraConfig = ''
+ ExtendedStatus on
+ '';
+ services.httpd.virtualHosts.localhost = {
+ extraConfig = ''
<Location /server-status>
Require all granted
SetHandler server-status
@@ -50,6 +50,7 @@ in
# For testing; don't want to wait forever for dead backend servers.
ProxyTimeout 5
'';
+ };
networking.firewall.allowedTCPPorts = [ 80 ];
};
diff --git a/nixpkgs/nixos/tests/quagga.nix b/nixpkgs/nixos/tests/quagga.nix
index 6aee7ea57f0..04590aa0eb3 100644
--- a/nixpkgs/nixos/tests/quagga.nix
+++ b/nixpkgs/nixos/tests/quagga.nix
@@ -5,7 +5,7 @@
#
# All interfaces are in OSPF Area 0.
-import ./make-test.nix ({ pkgs, ... }:
+import ./make-test-python.nix ({ pkgs, ... }:
let
ifAddr = node: iface: (pkgs.lib.head node.config.networking.interfaces.${iface}.ipv4.addresses).address;
@@ -74,23 +74,23 @@ import ./make-test.nix ({ pkgs, ... }:
testScript =
{ ... }:
''
- startAll;
+ start_all()
# Wait for the networking to start on all machines
- $_->waitForUnit("network.target") foreach values %vms;
+ for machine in client, router1, router2, server:
+ machine.wait_for_unit("network.target")
- # Wait for OSPF to form adjacencies
- for my $gw ($router1, $router2) {
- $gw->waitForUnit("ospfd");
- $gw->waitUntilSucceeds("vtysh -c 'show ip ospf neighbor' | grep Full");
- $gw->waitUntilSucceeds("vtysh -c 'show ip route' | grep '^O>'");
- }
+ with subtest("Wait for OSPF to form adjacencies"):
+ for gw in router1, router2:
+ gw.wait_for_unit("ospfd")
+ gw.wait_until_succeeds("vtysh -c 'show ip ospf neighbor' | grep Full")
+ gw.wait_until_succeeds("vtysh -c 'show ip route' | grep '^O>'")
- # Test ICMP.
- $client->succeed("ping -c 3 server >&2");
+ with subtest("Test ICMP"):
+ client.wait_until_succeeds("ping -c 3 server >&2")
- # Test whether HTTP works.
- $server->waitForUnit("httpd");
- $client->succeed("curl --fail http://server/ >&2");
+ with subtest("Test whether HTTP works"):
+ server.wait_for_unit("httpd")
+ client.succeed("curl --fail http://server/ >&2")
'';
})
diff --git a/nixpkgs/nixos/tests/radicale.nix b/nixpkgs/nixos/tests/radicale.nix
index 60796425564..c81e78a8f99 100644
--- a/nixpkgs/nixos/tests/radicale.nix
+++ b/nixpkgs/nixos/tests/radicale.nix
@@ -28,7 +28,7 @@ let
in
- import ./make-test.nix ({ lib, ... }@args: {
+ import ./make-test-python.nix ({ lib, ... }@args: {
name = "radicale";
meta.maintainers = with lib.maintainers; [ aneeshusa infinisil ];
@@ -64,43 +64,59 @@ in
newSystem = nodes.${nodeName}.config.system.build.toplevel;
in "${newSystem}/bin/switch-to-configuration test";
in ''
- # Check Radicale 1 functionality
- $radicale->succeed('${switchToConfig "radicale1"} >&2');
- $radicale->waitForUnit('radicale.service');
- $radicale->waitForOpenPort(${port});
- $radicale->succeed('curl --fail http://${user}:${password}@localhost:${port}/someuser/calendar.ics/');
+ with subtest("Check Radicale 1 functionality"):
+ radicale.succeed(
+ "${switchToConfig "radicale1"} >&2"
+ )
+ radicale.wait_for_unit("radicale.service")
+ radicale.wait_for_open_port(${port})
+ radicale.succeed(
+ "curl --fail http://${user}:${password}@localhost:${port}/someuser/calendar.ics/"
+ )
- # Export data in Radicale 2 format
- $radicale->succeed('systemctl stop radicale');
- $radicale->succeed('ls -al /tmp/collections');
- $radicale->fail('ls -al /tmp/collections-new');
- # Radicale exits immediately after exporting storage
- $radicale->succeed('${switchToConfig "radicale1_export"} >&2');
- $radicale->waitUntilFails('systemctl status radicale');
- $radicale->succeed('ls -al /tmp/collections');
- $radicale->succeed('ls -al /tmp/collections-new');
+ with subtest("Export data in Radicale 2 format"):
+ radicale.succeed("systemctl stop radicale")
+ radicale.succeed("ls -al /tmp/collections")
+ radicale.fail("ls -al /tmp/collections-new")
- # Verify data in Radicale 2 format
- $radicale->succeed('rm -r /tmp/collections/${user}');
- $radicale->succeed('mv /tmp/collections-new/collection-root /tmp/collections');
- $radicale->succeed('${switchToConfig "radicale2_verify"} >&2');
- $radicale->waitUntilFails('systemctl status radicale');
- my ($retcode, $logs) = $radicale->execute('journalctl -u radicale -n 10');
- if ($retcode != 0 || index($logs, 'Verifying storage') == -1) {
- die "Radicale 2 didn't verify storage"
- }
- if (index($logs, 'failed') != -1 || index($logs, 'exception') != -1) {
- die "storage verification failed"
- }
+ with subtest("Radicale exits immediately after exporting storage"):
+ radicale.succeed(
+ "${switchToConfig "radicale1_export"} >&2"
+ )
+ radicale.wait_until_fails("systemctl status radicale")
+ radicale.succeed("ls -al /tmp/collections")
+ radicale.succeed("ls -al /tmp/collections-new")
- # Check Radicale 2 functionality
- $radicale->succeed('${switchToConfig "radicale2"} >&2');
- $radicale->waitForUnit('radicale.service');
- $radicale->waitForOpenPort(${port});
- my ($retcode, $output) = $radicale->execute('curl --fail http://${user}:${password}@localhost:${port}/someuser/calendar.ics/');
- if ($retcode != 0 || index($output, 'VCALENDAR') == -1) {
- die "Could not read calendar from Radicale 2"
- }
- $radicale->succeed('curl --fail http://${user}:${password}@localhost:${port}/.web/');
+ with subtest("Verify data in Radicale 2 format"):
+ radicale.succeed("rm -r /tmp/collections/${user}")
+ radicale.succeed("mv /tmp/collections-new/collection-root /tmp/collections")
+ radicale.succeed(
+ "${switchToConfig "radicale2_verify"} >&2"
+ )
+ radicale.wait_until_fails("systemctl status radicale")
+
+ (retcode, logs) = radicale.execute("journalctl -u radicale -n 10")
+ assert (
+ retcode == 0 and "Verifying storage" in logs
+ ), "Radicale 2 didn't verify storage"
+ assert (
+ "failed" not in logs and "exception" not in logs
+ ), "storage verification failed"
+
+ with subtest("Check Radicale 2 functionality"):
+ radicale.succeed(
+ "${switchToConfig "radicale2"} >&2"
+ )
+ radicale.wait_for_unit("radicale.service")
+ radicale.wait_for_open_port(${port})
+
+ (retcode, output) = radicale.execute(
+ "curl --fail http://${user}:${password}@localhost:${port}/someuser/calendar.ics/"
+ )
+ assert (
+ retcode == 0 and "VCALENDAR" in output
+ ), "Could not read calendar from Radicale 2"
+
+ radicale.succeed("curl --fail http://${user}:${password}@localhost:${port}/.web/")
'';
})
diff --git a/nixpkgs/nixos/tests/resolv.nix b/nixpkgs/nixos/tests/resolv.nix
new file mode 100644
index 00000000000..b506f87451e
--- /dev/null
+++ b/nixpkgs/nixos/tests/resolv.nix
@@ -0,0 +1,46 @@
+# Test whether DNS resolving returns multiple records and all address families.
+import ./make-test-python.nix ({ pkgs, ... } : {
+ name = "resolv";
+ meta = with pkgs.stdenv.lib.maintainers; {
+ maintainers = [ ckauhaus ];
+ };
+
+ nodes.resolv = { ... }: {
+ networking.extraHosts = ''
+ # IPv4 only
+ 192.0.2.1 host-ipv4.example.net
+ 192.0.2.2 host-ipv4.example.net
+ # IP6 only
+ 2001:db8::2:1 host-ipv6.example.net
+ 2001:db8::2:2 host-ipv6.example.net
+ # dual stack
+ 192.0.2.1 host-dual.example.net
+ 192.0.2.2 host-dual.example.net
+ 2001:db8::2:1 host-dual.example.net
+ 2001:db8::2:2 host-dual.example.net
+ '';
+ };
+
+ testScript = ''
+ def addrs_in(hostname, addrs):
+ res = resolv.succeed("getent ahosts {}".format(hostname))
+ for addr in addrs:
+ assert addr in res, "Expected output '{}' not found in\n{}".format(addr, res)
+
+
+ start_all()
+ resolv.wait_for_unit("nscd")
+
+ ipv4 = ["192.0.2.1", "192.0.2.2"]
+ ipv6 = ["2001:db8::2:1", "2001:db8::2:2"]
+
+ with subtest("IPv4 resolves"):
+ addrs_in("host-ipv4.example.net", ipv4)
+
+ with subtest("IPv6 resolves"):
+ addrs_in("host-ipv6.example.net", ipv6)
+
+ with subtest("Dual stack resolves"):
+ addrs_in("host-dual.example.net", ipv4 + ipv6)
+ '';
+})
diff --git a/nixpkgs/nixos/tests/rspamd.nix b/nixpkgs/nixos/tests/rspamd.nix
index 0cc94728f80..bf3f0de6204 100644
--- a/nixpkgs/nixos/tests/rspamd.nix
+++ b/nixpkgs/nixos/tests/rspamd.nix
@@ -3,20 +3,20 @@
pkgs ? import ../.. { inherit system config; }
}:
-with import ../lib/testing.nix { inherit system pkgs; };
+with import ../lib/testing-python.nix { inherit system pkgs; };
with pkgs.lib;
let
initMachine = ''
- startAll
- $machine->waitForUnit("rspamd.service");
- $machine->succeed("id \"rspamd\" >/dev/null");
+ start_all()
+ machine.wait_for_unit("rspamd.service")
+ machine.succeed("id rspamd >/dev/null")
'';
checkSocket = socket: user: group: mode: ''
- $machine->succeed("ls ${socket} >/dev/null");
- $machine->succeed("[[ \"\$(stat -c %U ${socket})\" == \"${user}\" ]]");
- $machine->succeed("[[ \"\$(stat -c %G ${socket})\" == \"${group}\" ]]");
- $machine->succeed("[[ \"\$(stat -c %a ${socket})\" == \"${mode}\" ]]");
+ machine.succeed("ls ${socket} >/dev/null")
+ machine.succeed('[[ "$(stat -c %U ${socket})" == "${user}" ]]')
+ machine.succeed('[[ "$(stat -c %G ${socket})" == "${group}" ]]')
+ machine.succeed('[[ "$(stat -c %a ${socket})" == "${mode}" ]]')
'';
simple = name: enableIPv6: makeTest {
name = "rspamd-${name}";
@@ -25,22 +25,23 @@ let
networking.enableIPv6 = enableIPv6;
};
testScript = ''
- startAll
- $machine->waitForUnit("multi-user.target");
- $machine->waitForOpenPort(11334);
- $machine->waitForUnit("rspamd.service");
- $machine->succeed("id \"rspamd\" >/dev/null");
+ start_all()
+ machine.wait_for_unit("multi-user.target")
+ machine.wait_for_open_port(11334)
+ machine.wait_for_unit("rspamd.service")
+ machine.succeed("id rspamd >/dev/null")
${checkSocket "/run/rspamd/rspamd.sock" "rspamd" "rspamd" "660" }
- sleep 10;
- $machine->log($machine->succeed("cat /etc/rspamd/rspamd.conf"));
- $machine->log($machine->succeed("grep 'CONFDIR/worker-controller.inc' /etc/rspamd/rspamd.conf"));
- $machine->log($machine->succeed("grep 'CONFDIR/worker-normal.inc' /etc/rspamd/rspamd.conf"));
- $machine->log($machine->succeed("systemctl cat rspamd.service"));
- $machine->log($machine->succeed("curl http://localhost:11334/auth"));
- $machine->log($machine->succeed("curl http://127.0.0.1:11334/auth"));
- ${optionalString enableIPv6 ''
- $machine->log($machine->succeed("curl http://[::1]:11334/auth"));
- ''}
+ machine.sleep(10)
+ machine.log(machine.succeed("cat /etc/rspamd/rspamd.conf"))
+ machine.log(
+ machine.succeed("grep 'CONFDIR/worker-controller.inc' /etc/rspamd/rspamd.conf")
+ )
+ machine.log(machine.succeed("grep 'CONFDIR/worker-normal.inc' /etc/rspamd/rspamd.conf"))
+ machine.log(machine.succeed("systemctl cat rspamd.service"))
+ machine.log(machine.succeed("curl http://localhost:11334/auth"))
+ machine.log(machine.succeed("curl http://127.0.0.1:11334/auth"))
+ ${optionalString enableIPv6 ''machine.log(machine.succeed("curl http://[::1]:11334/auth"))''}
+ # would not reformat
'';
};
in
@@ -69,14 +70,18 @@ in
testScript = ''
${initMachine}
- $machine->waitForFile("/run/rspamd.sock");
+ machine.wait_for_file("/run/rspamd.sock")
${checkSocket "/run/rspamd.sock" "root" "root" "600" }
${checkSocket "/run/rspamd-worker.sock" "root" "root" "666" }
- $machine->log($machine->succeed("cat /etc/rspamd/rspamd.conf"));
- $machine->log($machine->succeed("grep 'CONFDIR/worker-controller.inc' /etc/rspamd/rspamd.conf"));
- $machine->log($machine->succeed("grep 'CONFDIR/worker-normal.inc' /etc/rspamd/rspamd.conf"));
- $machine->log($machine->succeed("rspamc -h /run/rspamd-worker.sock stat"));
- $machine->log($machine->succeed("curl --unix-socket /run/rspamd-worker.sock http://localhost/ping"));
+ machine.log(machine.succeed("cat /etc/rspamd/rspamd.conf"))
+ machine.log(
+ machine.succeed("grep 'CONFDIR/worker-controller.inc' /etc/rspamd/rspamd.conf")
+ )
+ machine.log(machine.succeed("grep 'CONFDIR/worker-normal.inc' /etc/rspamd/rspamd.conf"))
+ machine.log(machine.succeed("rspamc -h /run/rspamd-worker.sock stat"))
+ machine.log(
+ machine.succeed("curl --unix-socket /run/rspamd-worker.sock http://localhost/ping")
+ )
'';
};
@@ -111,18 +116,32 @@ in
testScript = ''
${initMachine}
- $machine->waitForFile("/run/rspamd.sock");
+ machine.wait_for_file("/run/rspamd.sock")
${checkSocket "/run/rspamd.sock" "root" "root" "600" }
${checkSocket "/run/rspamd-worker.sock" "root" "root" "666" }
- $machine->log($machine->succeed("cat /etc/rspamd/rspamd.conf"));
- $machine->log($machine->succeed("grep 'CONFDIR/worker-controller.inc' /etc/rspamd/rspamd.conf"));
- $machine->log($machine->succeed("grep 'CONFDIR/worker-normal.inc' /etc/rspamd/rspamd.conf"));
- $machine->log($machine->succeed("grep 'LOCAL_CONFDIR/override.d/worker-controller2.inc' /etc/rspamd/rspamd.conf"));
- $machine->log($machine->succeed("grep 'verysecretpassword' /etc/rspamd/override.d/worker-controller2.inc"));
- $machine->waitUntilSucceeds("journalctl -u rspamd | grep -i 'starting controller process' >&2");
- $machine->log($machine->succeed("rspamc -h /run/rspamd-worker.sock stat"));
- $machine->log($machine->succeed("curl --unix-socket /run/rspamd-worker.sock http://localhost/ping"));
- $machine->log($machine->succeed("curl http://localhost:11335/ping"));
+ machine.log(machine.succeed("cat /etc/rspamd/rspamd.conf"))
+ machine.log(
+ machine.succeed("grep 'CONFDIR/worker-controller.inc' /etc/rspamd/rspamd.conf")
+ )
+ machine.log(machine.succeed("grep 'CONFDIR/worker-normal.inc' /etc/rspamd/rspamd.conf"))
+ machine.log(
+ machine.succeed(
+ "grep 'LOCAL_CONFDIR/override.d/worker-controller2.inc' /etc/rspamd/rspamd.conf"
+ )
+ )
+ machine.log(
+ machine.succeed(
+ "grep 'verysecretpassword' /etc/rspamd/override.d/worker-controller2.inc"
+ )
+ )
+ machine.wait_until_succeeds(
+ "journalctl -u rspamd | grep -i 'starting controller process' >&2"
+ )
+ machine.log(machine.succeed("rspamc -h /run/rspamd-worker.sock stat"))
+ machine.log(
+ machine.succeed("curl --unix-socket /run/rspamd-worker.sock http://localhost/ping")
+ )
+ machine.log(machine.succeed("curl http://localhost:11335/ping"))
'';
};
customLuaRules = makeTest {
@@ -199,22 +218,34 @@ in
};
testScript = ''
${initMachine}
- $machine->waitForOpenPort(11334);
- $machine->log($machine->succeed("cat /etc/rspamd/rspamd.conf"));
- $machine->log($machine->succeed("cat /etc/rspamd/rspamd.local.lua"));
- $machine->log($machine->succeed("cat /etc/rspamd/local.d/groups.conf"));
+ machine.wait_for_open_port(11334)
+ machine.log(machine.succeed("cat /etc/rspamd/rspamd.conf"))
+ machine.log(machine.succeed("cat /etc/rspamd/rspamd.local.lua"))
+ machine.log(machine.succeed("cat /etc/rspamd/local.d/groups.conf"))
# Verify that redis.conf was not written
- $machine->fail("cat /etc/rspamd/local.d/redis.conf >&2");
+ machine.fail("cat /etc/rspamd/local.d/redis.conf >&2")
# Verify that antivirus.conf was not written
- $machine->fail("cat /etc/rspamd/local.d/antivirus.conf >&2");
+ machine.fail("cat /etc/rspamd/local.d/antivirus.conf >&2")
${checkSocket "/run/rspamd/rspamd.sock" "rspamd" "rspamd" "660" }
- $machine->log($machine->succeed("curl --unix-socket /run/rspamd/rspamd.sock http://localhost/ping"));
- $machine->log($machine->succeed("rspamc -h 127.0.0.1:11334 stat"));
- $machine->log($machine->succeed("cat /etc/tests/no-muh.eml | rspamc -h 127.0.0.1:11334"));
- $machine->log($machine->succeed("cat /etc/tests/muh.eml | rspamc -h 127.0.0.1:11334 symbols"));
- $machine->waitUntilSucceeds("journalctl -u rspamd | grep -i muh >&2");
- $machine->log($machine->fail("cat /etc/tests/no-muh.eml | rspamc -h 127.0.0.1:11334 symbols | grep NO_MUH"));
- $machine->log($machine->succeed("cat /etc/tests/muh.eml | rspamc -h 127.0.0.1:11334 symbols | grep NO_MUH"));
+ machine.log(
+ machine.succeed("curl --unix-socket /run/rspamd/rspamd.sock http://localhost/ping")
+ )
+ machine.log(machine.succeed("rspamc -h 127.0.0.1:11334 stat"))
+ machine.log(machine.succeed("cat /etc/tests/no-muh.eml | rspamc -h 127.0.0.1:11334"))
+ machine.log(
+ machine.succeed("cat /etc/tests/muh.eml | rspamc -h 127.0.0.1:11334 symbols")
+ )
+ machine.wait_until_succeeds("journalctl -u rspamd | grep -i muh >&2")
+ machine.log(
+ machine.fail(
+ "cat /etc/tests/no-muh.eml | rspamc -h 127.0.0.1:11334 symbols | grep NO_MUH"
+ )
+ )
+ machine.log(
+ machine.succeed(
+ "cat /etc/tests/muh.eml | rspamc -h 127.0.0.1:11334 symbols | grep NO_MUH"
+ )
+ )
'';
};
postfixIntegration = makeTest {
@@ -250,16 +281,24 @@ in
};
testScript = ''
${initMachine}
- $machine->waitForOpenPort(11334);
- $machine->waitForOpenPort(25);
+ machine.wait_for_open_port(11334)
+ machine.wait_for_open_port(25)
${checkSocket "/run/rspamd/rspamd-milter.sock" "rspamd" "postfix" "660" }
- $machine->log($machine->succeed("rspamc -h 127.0.0.1:11334 stat"));
- $machine->log($machine->succeed("msmtp --host=localhost -t --read-envelope-from < /etc/tests/example.eml"));
- $machine->log($machine->fail("msmtp --host=localhost -t --read-envelope-from < /etc/tests/gtube.eml"));
+ machine.log(machine.succeed("rspamc -h 127.0.0.1:11334 stat"))
+ machine.log(
+ machine.succeed(
+ "msmtp --host=localhost -t --read-envelope-from < /etc/tests/example.eml"
+ )
+ )
+ machine.log(
+ machine.fail(
+ "msmtp --host=localhost -t --read-envelope-from < /etc/tests/gtube.eml"
+ )
+ )
- $machine->waitUntilFails('[ "$(postqueue -p)" != "Mail queue is empty" ]');
- $machine->fail("journalctl -u postfix | grep -i error >&2");
- $machine->fail("journalctl -u postfix | grep -i warning >&2");
+ machine.wait_until_fails('[ "$(postqueue -p)" != "Mail queue is empty" ]')
+ machine.fail("journalctl -u postfix | grep -i error >&2")
+ machine.fail("journalctl -u postfix | grep -i warning >&2")
'';
};
}
diff --git a/nixpkgs/nixos/tests/sddm.nix b/nixpkgs/nixos/tests/sddm.nix
index 4bdcd701dcf..a145705250f 100644
--- a/nixpkgs/nixos/tests/sddm.nix
+++ b/nixpkgs/nixos/tests/sddm.nix
@@ -16,9 +16,8 @@ let
imports = [ ./common/user-account.nix ];
services.xserver.enable = true;
services.xserver.displayManager.sddm.enable = true;
- services.xserver.windowManager.default = "icewm";
+ services.xserver.displayManager.defaultSession = "none+icewm";
services.xserver.windowManager.icewm.enable = true;
- services.xserver.desktopManager.default = "none";
};
enableOCR = true;
@@ -52,9 +51,8 @@ let
user = "alice";
};
};
- services.xserver.windowManager.default = "icewm";
+ services.xserver.displayManager.defaultSession = "none+icewm";
services.xserver.windowManager.icewm.enable = true;
- services.xserver.desktopManager.default = "none";
};
testScript = { nodes, ... }: let
diff --git a/nixpkgs/nixos/tests/slurm.nix b/nixpkgs/nixos/tests/slurm.nix
index 17527378cf0..d0e62d15437 100644
--- a/nixpkgs/nixos/tests/slurm.nix
+++ b/nixpkgs/nixos/tests/slurm.nix
@@ -119,7 +119,7 @@ in {
with subtest("can_start_slurmctld"):
control.succeed("systemctl restart slurmctld")
- control.waitForUnit("slurmctld.service")
+ control.wait_for_unit("slurmctld.service")
with subtest("can_start_slurmd"):
for node in [node1, node2, node3]:
diff --git a/nixpkgs/nixos/tests/sonarr.nix b/nixpkgs/nixos/tests/sonarr.nix
index 3e84445099a..764a4d05b38 100644
--- a/nixpkgs/nixos/tests/sonarr.nix
+++ b/nixpkgs/nixos/tests/sonarr.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ lib, ... }:
+import ./make-test-python.nix ({ lib, ... }:
with lib;
@@ -11,8 +11,8 @@ with lib;
{ services.sonarr.enable = true; };
testScript = ''
- $machine->waitForUnit('sonarr.service');
- $machine->waitForOpenPort('8989');
- $machine->succeed("curl --fail http://localhost:8989/");
+ machine.wait_for_unit("sonarr.service")
+ machine.wait_for_open_port("8989")
+ machine.succeed("curl --fail http://localhost:8989/")
'';
})
diff --git a/nixpkgs/nixos/tests/spacecookie.nix b/nixpkgs/nixos/tests/spacecookie.nix
new file mode 100644
index 00000000000..6eff32a2e75
--- /dev/null
+++ b/nixpkgs/nixos/tests/spacecookie.nix
@@ -0,0 +1,51 @@
+let
+ gopherRoot = "/tmp/gopher";
+ gopherHost = "gopherd";
+ fileContent = "Hello Gopher!";
+ fileName = "file.txt";
+in
+ import ./make-test-python.nix ({...}: {
+ name = "spacecookie";
+ nodes = {
+ ${gopherHost} = {
+ networking.firewall.allowedTCPPorts = [ 70 ];
+ systemd.services.spacecookie = {
+ preStart = ''
+ mkdir -p ${gopherRoot}/directory
+ echo "${fileContent}" > ${gopherRoot}/${fileName}
+ '';
+ };
+
+ services.spacecookie = {
+ enable = true;
+ root = gopherRoot;
+ hostname = gopherHost;
+ };
+ };
+
+ client = {};
+ };
+
+ testScript = ''
+ start_all()
+ ${gopherHost}.wait_for_open_port(70)
+ ${gopherHost}.wait_for_unit("spacecookie.service")
+ client.wait_for_unit("network.target")
+
+ fileResponse = client.succeed("curl -s gopher://${gopherHost}//${fileName}")
+
+ # the file response should return our created file exactly
+ if not (fileResponse == "${fileContent}\n"):
+ raise Exception("Unexpected file response")
+
+ # sanity check on the directory listing: we serve a directory and a file
+ # via gopher, so the directory listing should have exactly two entries,
+ # one with gopher file type 0 (file) and one with file type 1 (directory).
+ dirResponse = client.succeed("curl -s gopher://${gopherHost}")
+ dirEntries = [l[0] for l in dirResponse.split("\n") if len(l) > 0]
+ dirEntries.sort()
+
+ if not (["0", "1"] == dirEntries):
+ raise Exception("Unexpected directory response")
+ '';
+ })
diff --git a/nixpkgs/nixos/tests/switch-test.nix b/nixpkgs/nixos/tests/switch-test.nix
index 0dba3697980..7076bd77b77 100644
--- a/nixpkgs/nixos/tests/switch-test.nix
+++ b/nixpkgs/nixos/tests/switch-test.nix
@@ -1,6 +1,6 @@
# Test configuration switching.
-import ./make-test.nix ({ pkgs, ...} : {
+import ./make-test-python.nix ({ pkgs, ...} : {
name = "switch-test";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ gleber ];
@@ -28,7 +28,11 @@ import ./make-test.nix ({ pkgs, ...} : {
exec env -i "$@" | tee /dev/stderr
'';
in ''
- $machine->succeed("${stderrRunner} ${originalSystem}/bin/switch-to-configuration test");
- $machine->succeed("${stderrRunner} ${otherSystem}/bin/switch-to-configuration test");
+ machine.succeed(
+ "${stderrRunner} ${originalSystem}/bin/switch-to-configuration test"
+ )
+ machine.succeed(
+ "${stderrRunner} ${otherSystem}/bin/switch-to-configuration test"
+ )
'';
})
diff --git a/nixpkgs/nixos/tests/systemd-analyze.nix b/nixpkgs/nixos/tests/systemd-analyze.nix
new file mode 100644
index 00000000000..a78ba08cd55
--- /dev/null
+++ b/nixpkgs/nixos/tests/systemd-analyze.nix
@@ -0,0 +1,46 @@
+import ./make-test-python.nix ({ pkgs, latestKernel ? false, ... }:
+
+{
+ name = "systemd-analyze";
+ meta = with pkgs.stdenv.lib.maintainers; {
+ maintainers = [ raskin ];
+ };
+
+ machine =
+ { pkgs, lib, ... }:
+ { boot.kernelPackages = lib.mkIf latestKernel pkgs.linuxPackages_latest;
+ sound.enable = true; # needed for the factl test, /dev/snd/* exists without them but udev doesn't care then
+ };
+
+ testScript = ''
+ machine.wait_for_unit("multi-user.target")
+
+ # We create a special output directory to copy it as a whole
+ with subtest("Prepare output dir"):
+ machine.succeed("mkdir systemd-analyze")
+
+
+ # Save the output into a file with given name inside the common
+ # output directory
+ def run_systemd_analyze(args, name):
+ tgt_dir = "systemd-analyze"
+ machine.succeed(
+ "systemd-analyze {} > {}/{} 2> {}/{}.err".format(
+ " ".join(args), tgt_dir, name, tgt_dir, name
+ )
+ )
+
+
+ with subtest("Print statistics"):
+ run_systemd_analyze(["blame"], "blame.txt")
+ run_systemd_analyze(["critical-chain"], "critical-chain.txt")
+ run_systemd_analyze(["dot"], "dependencies.dot")
+ run_systemd_analyze(["plot"], "systemd-analyze.svg")
+
+ # We copy the main graph into the $out (toplevel), and we also copy
+ # the entire output directory with additional data
+ with subtest("Copying the resulting data into $out"):
+ machine.copy_from_vm("systemd-analyze/", "")
+ machine.copy_from_vm("systemd-analyze/systemd-analyze.svg", "")
+ '';
+})
diff --git a/nixpkgs/nixos/tests/systemd-timesyncd.nix b/nixpkgs/nixos/tests/systemd-timesyncd.nix
index d12b8eb2bf7..ad5b9a47383 100644
--- a/nixpkgs/nixos/tests/systemd-timesyncd.nix
+++ b/nixpkgs/nixos/tests/systemd-timesyncd.nix
@@ -1,7 +1,7 @@
# Regression test for systemd-timesync having moved the state directory without
# upstream providing a migration path. https://github.com/systemd/systemd/issues/12131
-import ./make-test.nix (let
+import ./make-test-python.nix (let
common = { lib, ... }: {
# override the `false` value from the qemu-vm base profile
services.timesyncd.enable = lib.mkForce true;
@@ -25,28 +25,28 @@ in {
};
testScript = ''
- startAll;
- $current->succeed('systemctl status systemd-timesyncd.service');
+ start_all()
+ current.succeed("systemctl status systemd-timesyncd.service")
# on a new install with a recent systemd there should not be any
# leftovers from the dynamic user mess
- $current->succeed('test -e /var/lib/systemd/timesync');
- $current->succeed('test ! -L /var/lib/systemd/timesync');
+ current.succeed("test -e /var/lib/systemd/timesync")
+ current.succeed("test ! -L /var/lib/systemd/timesync")
# timesyncd should be running on the upgrading system since we fixed the
# file bits in the activation script
- $pre1909->succeed('systemctl status systemd-timesyncd.service');
+ pre1909.succeed("systemctl status systemd-timesyncd.service")
# the path should be gone after the migration
- $pre1909->succeed('test ! -e /var/lib/private/systemd/timesync');
+ pre1909.succeed("test ! -e /var/lib/private/systemd/timesync")
# and the new path should no longer be a symlink
- $pre1909->succeed('test -e /var/lib/systemd/timesync');
- $pre1909->succeed('test ! -L /var/lib/systemd/timesync');
+ pre1909.succeed("test -e /var/lib/systemd/timesync")
+ pre1909.succeed("test ! -L /var/lib/systemd/timesync")
# after a restart things should still work and not fail in the activation
# scripts and cause the boot to fail..
- $pre1909->shutdown;
- $pre1909->start;
- $pre1909->succeed('systemctl status systemd-timesyncd.service');
+ pre1909.shutdown()
+ pre1909.start()
+ pre1909.succeed("systemctl status systemd-timesyncd.service")
'';
})
diff --git a/nixpkgs/nixos/tests/tiddlywiki.nix b/nixpkgs/nixos/tests/tiddlywiki.nix
index 4a2014a4ec9..cf45578b0f9 100644
--- a/nixpkgs/nixos/tests/tiddlywiki.nix
+++ b/nixpkgs/nixos/tests/tiddlywiki.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ ... }: {
+import ./make-test-python.nix ({ ... }: {
name = "tiddlywiki";
nodes = {
default = {
@@ -20,48 +20,50 @@ import ./make-test.nix ({ ... }: {
};
};
- testScript = ''
- startAll;
+ testScript =
+ ''
+ start_all()
- subtest "by default works without configuration", sub {
- $default->waitForUnit("tiddlywiki.service");
- };
-
- subtest "by default available on port 8080 without auth", sub {
- $default->waitForUnit("tiddlywiki.service");
- $default->waitForOpenPort(8080);
- $default->succeed("curl --fail 127.0.0.1:8080");
- };
-
- subtest "by default creates empty wiki", sub {
- $default->succeed("test -f /var/lib/tiddlywiki/tiddlywiki.info");
- };
+ with subtest("by default works without configuration"):
+ default.wait_for_unit("tiddlywiki.service")
- subtest "configured on port 3000 with basic auth", sub {
- $configured->waitForUnit("tiddlywiki.service");
- $configured->waitForOpenPort(3000);
- $configured->fail("curl --fail 127.0.0.1:3000");
- $configured->succeed("curl --fail 127.0.0.1:3000 --user somelogin:somesecret");
- };
+ with subtest("by default available on port 8080 without auth"):
+ default.wait_for_unit("tiddlywiki.service")
+ default.wait_for_open_port(8080)
+ # we output to /dev/null here to avoid a python UTF-8 decode error
+ # but the check will still fail if the service doesn't respond
+ default.succeed("curl --fail -o /dev/null 127.0.0.1:8080")
- subtest "configured with different wikifolder", sub {
- $configured->succeed("test -f /var/lib/tiddlywiki/tiddlywiki.info");
- };
+ with subtest("by default creates empty wiki"):
+ default.succeed("test -f /var/lib/tiddlywiki/tiddlywiki.info")
- subtest "restart preserves changes", sub {
- # given running wiki
- $default->waitForUnit("tiddlywiki.service");
- # with some changes
- $default->succeed("curl --fail --request PUT --header 'X-Requested-With:TiddlyWiki' --data '{ \"title\": \"title\", \"text\": \"content\" }' --url 127.0.0.1:8080/recipes/default/tiddlers/somepage ");
- $default->succeed("sleep 2"); # server syncs to filesystem on timer
+ with subtest("configured on port 3000 with basic auth"):
+ configured.wait_for_unit("tiddlywiki.service")
+ configured.wait_for_open_port(3000)
+ configured.fail("curl --fail -o /dev/null 127.0.0.1:3000")
+ configured.succeed(
+ "curl --fail -o /dev/null 127.0.0.1:3000 --user somelogin:somesecret"
+ )
+
+ with subtest("restart preserves changes"):
+ # given running wiki
+ default.wait_for_unit("tiddlywiki.service")
+ # with some changes
+ default.succeed(
+ 'curl --fail --request PUT --header \'X-Requested-With:TiddlyWiki\' \
+ --data \'{ "title": "title", "text": "content" }\' \
+ --url 127.0.0.1:8080/recipes/default/tiddlers/somepage '
+ )
+ default.succeed("sleep 2")
- # when wiki is cycled
- $default->systemctl("restart tiddlywiki.service");
- $default->waitForUnit("tiddlywiki.service");
- $default->waitForOpenPort(8080);
+ # when wiki is cycled
+ default.systemctl("restart tiddlywiki.service")
+ default.wait_for_unit("tiddlywiki.service")
+ default.wait_for_open_port(8080)
- # the change is preserved
- $default->succeed("curl --fail 127.0.0.1:8080/recipes/default/tiddlers/somepage");
- };
- '';
+ # the change is preserved
+ default.succeed(
+ "curl --fail -o /dev/null 127.0.0.1:8080/recipes/default/tiddlers/somepage"
+ )
+ '';
})
diff --git a/nixpkgs/nixos/tests/timezone.nix b/nixpkgs/nixos/tests/timezone.nix
index 2204649a3fc..7fc9a5058ee 100644
--- a/nixpkgs/nixos/tests/timezone.nix
+++ b/nixpkgs/nixos/tests/timezone.nix
@@ -1,45 +1,50 @@
-{
- timezone-static = import ./make-test.nix ({ pkgs, ... }: {
- name = "timezone-static";
- meta.maintainers = with pkgs.lib.maintainers; [ lheckemann ];
-
- machine.time.timeZone = "Europe/Amsterdam";
-
- testScript = ''
- $machine->waitForUnit("dbus.socket");
- $machine->fail("timedatectl set-timezone Asia/Tokyo");
- my @dateResult = $machine->execute('date -d @0 "+%Y-%m-%d %H:%M:%S"');
- $dateResult[1] eq "1970-01-01 01:00:00\n" or die "Timezone seems to be wrong";
- '';
- });
-
- timezone-imperative = import ./make-test.nix ({ pkgs, ... }: {
- name = "timezone-imperative";
- meta.maintainers = with pkgs.lib.maintainers; [ lheckemann ];
-
- machine.time.timeZone = null;
-
- testScript = ''
- $machine->waitForUnit("dbus.socket");
-
- # Should default to UTC
- my @dateResult = $machine->execute('date -d @0 "+%Y-%m-%d %H:%M:%S"');
- print $dateResult[1];
- $dateResult[1] eq "1970-01-01 00:00:00\n" or die "Timezone seems to be wrong";
-
- $machine->succeed("timedatectl set-timezone Asia/Tokyo");
-
- # Adjustment should be taken into account
- my @dateResult = $machine->execute('date -d @0 "+%Y-%m-%d %H:%M:%S"');
- print $dateResult[1];
- $dateResult[1] eq "1970-01-01 09:00:00\n" or die "Timezone was not adjusted";
-
- # Adjustment should persist across a reboot
- $machine->shutdown;
- $machine->waitForUnit("dbus.socket");
- my @dateResult = $machine->execute('date -d @0 "+%Y-%m-%d %H:%M:%S"');
- print $dateResult[1];
- $dateResult[1] eq "1970-01-01 09:00:00\n" or die "Timezone adjustment was not persisted";
- '';
- });
-}
+import ./make-test-python.nix ({ pkgs, ...} : {
+ name = "timezone";
+ meta.maintainers = with pkgs.lib.maintainers; [ lheckemann ];
+
+ nodes = {
+ node_eutz = { pkgs, ... }: {
+ time.timeZone = "Europe/Amsterdam";
+ };
+
+ node_nulltz = { pkgs, ... }: {
+ time.timeZone = null;
+ };
+ };
+
+ testScript = { nodes, ... }: ''
+ node_eutz.wait_for_unit("dbus.socket")
+
+ with subtest("static - Ensure timezone change gives the correct result"):
+ node_eutz.fail("timedatectl set-timezone Asia/Tokyo")
+ date_result = node_eutz.succeed('date -d @0 "+%Y-%m-%d %H:%M:%S"')
+ assert date_result == "1970-01-01 01:00:00\n", "Timezone seems to be wrong"
+
+ node_nulltz.wait_for_unit("dbus.socket")
+
+ with subtest("imperative - Ensure timezone defaults to UTC"):
+ date_result = node_nulltz.succeed('date -d @0 "+%Y-%m-%d %H:%M:%S"')
+ print(date_result)
+ assert (
+ date_result == "1970-01-01 00:00:00\n"
+ ), "Timezone seems to be wrong (not UTC)"
+
+ with subtest("imperative - Ensure timezone adjustment produces expected result"):
+ node_nulltz.succeed("timedatectl set-timezone Asia/Tokyo")
+
+ # Adjustment should be taken into account
+ date_result = node_nulltz.succeed('date -d @0 "+%Y-%m-%d %H:%M:%S"')
+ print(date_result)
+ assert date_result == "1970-01-01 09:00:00\n", "Timezone was not adjusted"
+
+ with subtest("imperative - Ensure timezone adjustment persists across reboot"):
+ # Adjustment should persist across a reboot
+ node_nulltz.shutdown()
+ node_nulltz.wait_for_unit("dbus.socket")
+ date_result = node_nulltz.succeed('date -d @0 "+%Y-%m-%d %H:%M:%S"')
+ print(date_result)
+ assert (
+ date_result == "1970-01-01 09:00:00\n"
+ ), "Timezone adjustment was not persisted"
+ '';
+})
diff --git a/nixpkgs/nixos/tests/trilium-server.nix b/nixpkgs/nixos/tests/trilium-server.nix
new file mode 100644
index 00000000000..6346575b33d
--- /dev/null
+++ b/nixpkgs/nixos/tests/trilium-server.nix
@@ -0,0 +1,53 @@
+import ./make-test-python.nix ({ ... }: {
+ name = "trilium-server";
+ nodes = {
+ default = {
+ services.trilium-server.enable = true;
+ };
+ configured = {
+ services.trilium-server = {
+ enable = true;
+ dataDir = "/data/trilium";
+ };
+ };
+
+ nginx = {
+ services.trilium-server = {
+ enable = true;
+ nginx.enable = true;
+ nginx.hostName = "trilium.example.com";
+ };
+ };
+ };
+
+ testScript =
+ ''
+ start_all()
+
+ with subtest("by default works without configuration"):
+ default.wait_for_unit("trilium-server.service")
+
+ with subtest("by default available on port 8080"):
+ default.wait_for_unit("trilium-server.service")
+ default.wait_for_open_port(8080)
+ # we output to /dev/null here to avoid a python UTF-8 decode error
+ # but the check will still fail if the service doesn't respond
+ default.succeed("curl --fail -o /dev/null 127.0.0.1:8080")
+
+ with subtest("by default creates empty document"):
+ default.wait_for_unit("trilium-server.service")
+ default.succeed("test -f /var/lib/trilium/document.db")
+
+ with subtest("configured with custom data store"):
+ configured.wait_for_unit("trilium-server.service")
+ configured.succeed("test -f /data/trilium/document.db")
+
+ with subtest("nginx with custom host name"):
+ nginx.wait_for_unit("trilium-server.service")
+ nginx.wait_for_unit("nginx.service")
+
+ nginx.succeed(
+ "curl --resolve 'trilium.example.com:80:127.0.0.1' http://trilium.example.com/"
+ )
+ '';
+})
diff --git a/nixpkgs/nixos/tests/upnp.nix b/nixpkgs/nixos/tests/upnp.nix
index d2e7fdd4fbe..a7d837ea070 100644
--- a/nixpkgs/nixos/tests/upnp.nix
+++ b/nixpkgs/nixos/tests/upnp.nix
@@ -56,9 +56,11 @@ in
networking.firewall.enable = false;
services.httpd.enable = true;
- services.httpd.listen = [{ ip = "*"; port = 9000; }];
- services.httpd.adminAddr = "foo@example.org";
- services.httpd.documentRoot = "/tmp";
+ services.httpd.virtualHosts.localhost = {
+ listen = [{ ip = "*"; port = 9000; }];
+ adminAddr = "foo@example.org";
+ documentRoot = "/tmp";
+ };
};
client2 =
diff --git a/nixpkgs/nixos/tests/wireguard/namespaces.nix b/nixpkgs/nixos/tests/wireguard/namespaces.nix
index 94f993d9475..c8a4e3bb52a 100644
--- a/nixpkgs/nixos/tests/wireguard/namespaces.nix
+++ b/nixpkgs/nixos/tests/wireguard/namespaces.nix
@@ -13,7 +13,7 @@ let
in
-import ../make-test.nix ({ pkgs, ...} : {
+import ../make-test-python.nix ({ pkgs, ...} : {
name = "wireguard-with-namespaces";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ asymmetric ];
@@ -65,16 +65,14 @@ import ../make-test.nix ({ pkgs, ...} : {
};
testScript = ''
- startAll();
+ start_all()
- $peer0->waitForUnit("wireguard-wg0.service");
- $peer1->waitForUnit("wireguard-wg0.service");
- $peer2->waitForUnit("wireguard-wg0.service");
- $peer3->waitForUnit("wireguard-wg0.service");
+ for machine in peer0, peer1, peer2, peer3:
+ machine.wait_for_unit("wireguard-wg0.service")
- $peer0->succeed("ip -n ${socketNamespace} link show wg0");
- $peer1->succeed("ip -n ${interfaceNamespace} link show wg0");
- $peer2->succeed("ip -n ${interfaceNamespace} link show wg0");
- $peer3->succeed("ip link show wg0");
+ peer0.succeed("ip -n ${socketNamespace} link show wg0")
+ peer1.succeed("ip -n ${interfaceNamespace} link show wg0")
+ peer2.succeed("ip -n ${interfaceNamespace} link show wg0")
+ peer3.succeed("ip link show wg0")
'';
})
diff --git a/nixpkgs/nixos/tests/xmonad.nix b/nixpkgs/nixos/tests/xmonad.nix
index c2e5ba60d7b..ef711f8dcf6 100644
--- a/nixpkgs/nixos/tests/xmonad.nix
+++ b/nixpkgs/nixos/tests/xmonad.nix
@@ -4,10 +4,10 @@ import ./make-test-python.nix ({ pkgs, ...} : {
maintainers = [ nequissimus ];
};
- machine = { lib, pkgs, ... }: {
+ machine = { pkgs, ... }: {
imports = [ ./common/x11.nix ./common/user-account.nix ];
services.xserver.displayManager.auto.user = "alice";
- services.xserver.windowManager.default = lib.mkForce "xmonad";
+ services.xserver.displayManager.defaultSession = "none+xmonad";
services.xserver.windowManager.xmonad = {
enable = true;
enableContribAndExtras = true;
@@ -27,13 +27,13 @@ import ./make-test-python.nix ({ pkgs, ...} : {
machine.wait_for_x()
machine.wait_for_file("${user.home}/.Xauthority")
machine.succeed("xauth merge ${user.home}/.Xauthority")
- machine.send_chars("alt-ctrl-x")
+ machine.send_key("alt-ctrl-x")
machine.wait_for_window("${user.name}.*machine")
machine.sleep(1)
machine.screenshot("terminal")
machine.wait_until_succeeds("xmonad --restart")
machine.sleep(3)
- machine.send_chars("alt-shift-ret")
+ machine.send_key("alt-shift-ret")
machine.wait_for_window("${user.name}.*machine")
machine.sleep(1)
machine.screenshot("terminal")
diff --git a/nixpkgs/nixos/tests/xrdp.nix b/nixpkgs/nixos/tests/xrdp.nix
index 0106aefe831..1aceeffb955 100644
--- a/nixpkgs/nixos/tests/xrdp.nix
+++ b/nixpkgs/nixos/tests/xrdp.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ pkgs, ...} : {
+import ./make-test-python.nix ({ pkgs, ...} : {
name = "xrdp";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ volth ];
@@ -21,25 +21,27 @@ import ./make-test.nix ({ pkgs, ...} : {
};
};
- testScript = { ... }: ''
- startAll;
+ testScript = { nodes, ... }: let
+ user = nodes.client.config.users.users.alice;
+ in ''
+ start_all()
- $client->waitForX;
- $client->waitForFile("/home/alice/.Xauthority");
- $client->succeed("xauth merge ~alice/.Xauthority");
+ client.wait_for_x()
+ client.wait_for_file("${user.home}/.Xauthority")
+ client.succeed("xauth merge ${user.home}/.Xauthority")
- $client->sleep(5);
+ client.sleep(5)
- $client->execute("xterm &");
- $client->sleep(1);
- $client->sendChars("xfreerdp /cert-tofu /w:640 /h:480 /v:127.0.0.1 /u:alice /p:foobar\n");
- $client->sleep(5);
- $client->screenshot("localrdp");
+ client.execute("xterm &")
+ client.sleep(1)
+ client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:127.0.0.1 /u:${user.name} /p:${user.password}\n")
+ client.sleep(5)
+ client.screenshot("localrdp")
- $client->execute("xterm &");
- $client->sleep(1);
- $client->sendChars("xfreerdp /cert-tofu /w:640 /h:480 /v:server /u:alice /p:foobar\n");
- $client->sleep(5);
- $client->screenshot("remoterdp");
+ client.execute("xterm &")
+ client.sleep(1)
+ client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:server /u:${user.name} /p:${user.password}\n")
+ client.sleep(5)
+ client.screenshot("remoterdp")
'';
})
diff --git a/nixpkgs/nixos/tests/zsh-history.nix b/nixpkgs/nixos/tests/zsh-history.nix
new file mode 100644
index 00000000000..4380ec9adfd
--- /dev/null
+++ b/nixpkgs/nixos/tests/zsh-history.nix
@@ -0,0 +1,35 @@
+import ./make-test-python.nix ({ pkgs, ...} : {
+ name = "zsh-history";
+ meta = with pkgs.stdenv.lib.maintainers; {
+ maintainers = [ kampka ];
+ };
+
+ nodes.default = { ... }: {
+ programs = {
+ zsh.enable = true;
+ };
+ environment.systemPackages = [ pkgs.zsh-history ];
+ programs.zsh.interactiveShellInit = ''
+ source ${pkgs.zsh-history.out}/share/zsh/init.zsh
+ '';
+ users.users.root.shell = "${pkgs.zsh}/bin/zsh";
+ };
+
+ testScript = ''
+ start_all()
+ default.wait_for_unit("multi-user.target")
+ default.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
+
+ # Login
+ default.wait_until_tty_matches(1, "login: ")
+ default.send_chars("root\n")
+ default.wait_until_tty_matches(1, "root@default>")
+
+ # Generate some history
+ default.send_chars("echo foobar\n")
+ default.wait_until_tty_matches(1, "foobar")
+
+ # Ensure that command was recorded in history
+ default.succeed("/run/current-system/sw/bin/history list | grep -q foobar")
+ '';
+})