Commit graph

76 commits

Author SHA1 Message Date
benaryorg 27323e52cc
nixos/systemd: CPUAccounting is deprecated
systemd 258 has the following changes noted in systemd.resource-control(5):

> `CPUAccounting=` setting is deprecated, because it is always available on the unified cgroup hierarchy and such setting has no effect.

This commit removes it from the three services using it directly, as well as one instance of example text.

Signed-off-by: benaryorg <binary@benary.org>
2025-10-23 18:54:30 +00:00
eljamm 6316b883f1 nixos/scx: support temporarily overriding scheduler
One of the nicest perks of using scx is the ability to easily switch
between schedulers at run-time, but this is currently not possible in
NixOS, given that the scx service only uses the scheduler from the
config file.

It's possible, however, to override the scheduler and its flags using
the `SCX_SCHEDULER_OVERRIDE` and `SCX_FLAGS_OVERRIDE` environment
variables, respectively (see [more
details](https://en.opensuse.org/Pluggable_CPU_schedulers#Temporarily_switch_to_a_different_scheduler)).

So the solution here is to change the scx service executable and pass
those env vars to the service at run-time falling back to the values
from the module config as defaults.

After this change, it would be possible to override schedulers like so:

```shellSession
$ sudo systemctl set-environment SCX_SCHEDULER_OVERRIDE='scx_lavd'
$ sudo systemctl set-environment SCX_FLAGS_OVERRIDE='--performance'
$ sudo systemctl restart scx.service
```
```shellSession
$ journalctl -u scx.service -b 0 -e
Oct 18 13:09:25 nixos systemd[1]: Started SCX scheduler daemon.
Oct 18 13:09:25 nixos bash[1829848]: 13:09:25 [INFO] Performance mode is
enabled.
Oct 18 13:09:25 nixos bash[1829848]: 13:09:25 [INFO] Energy model won't
be used for CPU preference order.
Oct 18 13:09:26 nixos bash[1829848]: 13:09:26 [WARN] libbpf: map
'lavd_ops': BPF map skeleton link is uninitialized
Oct 18 13:09:26 nixos bash[1829848]: 13:09:26 [INFO] scx_lavd scheduler
is initialized (build ID: 1.0.16 x86_64-unknown-linux-gnu)
Oct 18 13:09:26 nixos bash[1829848]: 13:09:26 [INFO] scx_lavd scheduler
starts running.
```

And also restore to the module defaults:

```shellSession
$ sudo systemctl unset-environment SCX_SCHEDULER_OVERRIDE
$ sudo systemctl unset-environment SCX_FLAGS_OVERRIDE
$ sudo systemctl restart scx.service
```
```shellSession
$ journalctl -u scx.service -b 0 -e
Oct 18 13:12:56 nixos systemd[1]: Stopped SCX scheduler daemon.
Oct 18 13:12:56 nixos systemd[1]: Started SCX scheduler daemon.
Oct 18 13:12:56 nixos bash[1833220]: 13:12:56 [INFO] NUMA nodes: 1
Oct 18 13:12:56 nixos bash[1833220]: 13:12:56 [INFO] Disabling NUMA
optimizations
Oct 18 13:12:56 nixos bash[1833220]: 13:12:56 [INFO] scx_bpfland 1.0.16
x86_64-unknown-linux-gnu SMT on
```
2025-10-18 13:22:49 +02:00
Gliczy f14f77b5e6 nixos/scx: inherit pkgs.scx.full.meta maintainers 2025-08-28 13:51:20 +05:30
Gliczy 14c8785cb8 nixos/scx: add missing schedulers 2025-08-28 13:51:20 +05:30
dish 970dcca69c
treewide: Fix links in module documentation 2025-08-25 12:55:11 -04:00
Wolfgang Walther 5a0711127c
treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Yt a72f22d0d8
Prefect init module (#386895) 2025-03-19 08:52:19 -04:00
happysalada ef12e14cb7 nixos/prefect: init module
prefect: add dburl to worker

prefect: use same state directory

prefect: fix worker environment

prefect: create user

prefect: use datadir for sqlite url

prefect: make datadir writable

prefect: don't protect home

prefect fix sqlite url

prefect: fix state directory

prefect: user should not be systemuser

prefect: set to normal user

add prefect to systempackages

try user with same name

prefect use prefect_home

do not set database url

revert to dynamic user

prefect: add tests

prefect: fix port to string
2025-03-16 11:09:50 -04:00
h7x4 ab0564bd10
treewide: add documentation for nixos systemd units 2025-03-12 18:00:38 +01:00
Victor Engmark 361c7f79b7
nixos/cron: Fix ShellCheck issue in preStart script
Fixes the following warning when setting
`systemd.enableStrictShellChecks = true`:

> SC2174 (warning): When used with -p, -m only applies to the deepest
> directory.

Since it could conceivably be possible for `/var` to not exist when
running this script, the fix also explicitly tries to create /var with
the normal 0755 permissions.
2025-01-04 18:07:52 +01:00
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

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

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

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00
John Titor b4aacf5ab5
nixos/scx: add new schedulers 2024-12-08 23:32:45 +05:30
John Titor fc8f58848e
nixos/scx: cleanup
- use utils.escapeSystemdExecArgs in systemd service

- remove StandardError="journal" as it's already default
2024-11-23 13:17:36 +05:30
John Titor 9480c8be07
nixos/scx: remove dead reference to scx.rustland 2024-11-23 01:17:54 +05:30
John Titor 3e710e6d15
nixos/scx: init
This adds a `services.scx.enable` option to enable sched-ext schedulers.

Requires a kernel with sched-ext enabled (6.12+) or a kernel with the patchset.

requiredKernelConfigs are taken from https://cateee.net/lkddb/web-lkddb/SCHED_CLASS_EXT.html
2024-11-19 23:09:53 +05:30
stuebinm 6afb255d97 nixos: remove all uses of lib.mdDoc
these changes were generated with nixq 0.0.2, by running

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

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

Since lib.mdDoc is already defined as just id, this commit is a no-op as
far as Nix (and the built manual) is concerned.
2024-04-13 10:07:35 -07:00
Felix Buehler f3719756b5 treewide: use optionalString instead of 'then ""' 2023-06-24 20:19:19 +02:00
pennae 2e751c0772 treewide: automatically md-convert option descriptions
the conversion procedure is simple:

 - find all things that look like options, ie calls to either `mkOption`
   or `lib.mkOption` that take an attrset. remember the attrset as the
   option
 - for all options, find a `description` attribute who's value is not a
   call to `mdDoc` or `lib.mdDoc`
 - textually convert the entire value of the attribute to MD with a few
   simple regexes (the set from mdize-module.sh)
 - if the change produced a change in the manual output, discard
 - if the change kept the manual unchanged, add some text to the
   description to make sure we've actually found an option. if the
   manual changes this time, keep the converted description

this procedure converts 80% of nixos options to markdown. around 2000
options remain to be inspected, but most of those fail the "does not
change the manual output check": currently the MD conversion process
does not faithfully convert docbook tags like <code> and <package>, so
any option using such tags will not be converted at all.
2022-07-30 15:16:34 +02:00
Naïm Favier 2ddc335e6f
nixos/doc: clean up defaults and examples 2021-10-04 12:47:20 +02:00
Guillaume Girol ceb2e6667b
Merge pull request #126289 from rnhmjoj/wrappers
nixos/security/wrappers: make well-typed
2021-09-18 15:28:49 +00:00
rnhmjoj fedd7cd690
nixos: explicitely set security.wrappers ownership
This is slightly more verbose and inconvenient, but it forces you
to think about what the wrapper ownership and permissions will be.
2021-09-13 13:48:13 +02:00
rnhmjoj 8f76a6eefc
nixos: add implict security.wrappers options
This is to keep the same permissions/setuid/setgid as before the change
in security.wrappers defaults.
2021-09-13 13:48:13 +02:00
Guillaume Girol bc3bca822a nixos: define the primary group of users where needed 2021-09-12 14:59:30 +02:00
Bjørn Forsman 225d915e5c nixos/atd: prefer 'install' over 'mkdir/chmod/chown'
I don't think there was a security issue here, but using 'install' is
preferred.

Ref #121293.
2021-05-01 15:16:19 +02:00
Florian Klink 645ea787c9 nixos/marathon: remove module
The corresponding package failed to build for >9 months.
2020-08-15 16:59:58 +02:00
Florian Klink a90b929020 nixos/chronos: remove module
The chronos package has been broken for > 9 months due to the breakage
of the mesos package.
2020-08-15 16:59:38 +02:00
Peter Hoeg 53a51f212a atd: systemd-udev-settle serves no purpose 2020-03-21 11:15:06 +08:00
rnhmjoj 1d61efb7f1 treewide: use attrs instead of list for types.loaOf options 2020-01-06 10:39:18 -05:00
Janne Heß d6c08776ba treewide: Switch to system users 2019-10-12 22:25:28 +02:00
Florian Klink f74735c9d7 nixos: remove dependencies on local-fs.target
Since https://github.com/NixOS/nixpkgs/pull/61321, local-fs.target is
part of sysinit.target again, meaning units without
DefaultDependencies=no will automatically depend on it, and the manual
set dependencies can be dropped.
2019-09-01 19:06:38 +02:00
Florian Klink 2457510db4
Merge pull request #51918 from bobvanderlinden/var-run
tree-wide: nixos: /var/run -> /run
2019-04-07 20:09:46 +02:00
Benjamin Hipple 8b3500c650 nixos.cron: fix docstring sentence 2019-03-26 23:22:20 -04:00
Bob van der Linden 798931135e
nixos/fcron: /var/run -> /run 2019-03-24 21:15:30 +01:00
Florian Klink fff5923686 nixos/modules: users.(extraUsers|extraGroup->users|group) 2018-06-30 03:02:58 +02:00
Alex Brandt fdebbce726 nixos/modules/services/scheduling/fcron: add setuid to fcrontab
Without fcrontab being setuid, every attempt by an user in the fcron
group to edit their own crontab (via `fcrontab -e`) results in the
following error:

```
2018-05-06 11:29:07 ERROR could not change euid to 273: Operation not permitted
2018-05-06 11:29:07 ERROR fcron child aborted: this does not affect the main fcron daemon, but this may prevent a job from being run or an email from being sent.
```

Adding setuid by hand has resolved this issue and aligns with the way
fcrontab is installed on other distributions.
2018-05-06 11:24:09 -07:00
Léo Gaspard 341583b2d2
fcron module: be compatible with non-wrapped sendmail's, like opensmtpd's 2017-12-31 03:34:11 +01:00
Bjørn Forsman 497108b456 nixos/atd: remove "batch" from setuid wrappers
"batch" is a shell script so invoking it via setuid wrapper never worked
anyway. (The kernel drops perms on executables with shebang.) A previous
nixpkgs commit made "batch" invoke the NixOS setuid "at" wrapper to gain
needed privileges.

Thanks to @yesbox for noticing.
2017-10-16 19:08:19 +02:00
Léo Gaspard 1afd97aa8f
fcron module: fix use with hardlink-optimized store 2017-10-09 23:44:28 +02:00
Joerg Thalheim e34e28e573 nixos/fcron: service needs fcron in PATH
otherwise fcronsighup is not found.
Set PATH to /run/current-system/sw/bin does not seems to be used by service file anyway.
2017-10-09 11:43:24 +01:00
Linus Heckemann 46e41da543 cron service: fix reliance on etc.timezone
This does not fully address the issue, as cron will not restart when
the timezone is changed imperatively as it presumably needs to.
2017-08-30 21:35:17 +02:00
Jörg Thalheim 44c3726dca
fcron: install systab
fixes #25072
2017-04-23 11:44:04 +02:00
Jörg Thalheim 5ca7e8a69a
fcron: do not chmod at all
fcron does handle permissions on its own correctly
2017-04-13 12:28:19 +02:00
Franz Pletz 9536169074
nixos/treewide: remove boolean examples for options
They contain no useful information and increase the length of the
autogenerated options documentation.

See discussion in #18816.
2017-03-17 23:36:19 +01:00
Jörg Thalheim 947815f59f
fcron: 3.1.2 -> 3.2.1
fixes #23320 #23413
2017-03-05 22:41:11 +01:00
Bjørn Forsman a45821e7a8 nixos/cron: unbreak since new security.wrapper 2017-02-15 08:30:58 +01:00
Bjørn Forsman aaac02f6c4 nixos/atd: unbreak after new security.wrappers
* convert list -> attrset
* 'atd' doesn't exist, 'at' does
2017-02-15 08:25:59 +01:00
Parnell Springmeyer 628e6a83d0
More derp 2017-01-29 05:33:56 -06:00
Parnell Springmeyer 4aa0923009
Getting rid of the var indirection and using a bin path instead 2017-01-29 04:11:01 -06:00
Parnell Springmeyer a8cb2afa98
Fixing a bunch of issues 2017-01-29 01:58:12 -06:00
Parnell Springmeyer e92b8402b0
Addressing PR feedback 2017-01-28 20:48:03 -08:00