Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/tmp: fix reboots after 56d7e7492cbf2d61bd570f5b0a8015040e80aae9 #108881

Closed
wants to merge 1 commit into from

Conversation

ajs124
Copy link
Member

@ajs124 ajs124 commented Jan 9, 2021

Motivation for this change

Alternative to #108860

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@endocrimes
Copy link
Member

This would break right now - because there's a conflict between the upstream unit and the local one

@ajs124
Copy link
Member Author

ajs124 commented Jan 9, 2021

How so? I'm quite sure I'm running that config. Although that's on 20.09.

@endocrimes
Copy link
Member

@ajs124 Ah I misunderstood how nix processes these (my issue isn't with the upstream unit but by defining tmp.mount twice).

We should avoid having needless override confs tho bc they're somewhat non-obvious when debugging a system for most people I think.

@ajs124 ajs124 force-pushed the fix/tmpOnTmpfs branch 3 times, most recently from 47f6c94 to 2677c30 Compare January 13, 2021 15:31
Copy link
Member

@endocrimes endocrimes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@flokli
Copy link
Contributor

flokli commented Jan 13, 2021

did someone try rebooting into this?

Copy link
Member

@cole-h cole-h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the what is also required (for NixOS, at least):

error: --- ThrownError ------------------------------------------------------------------------- nix
The option `systemd.mounts.[definition 1-entry 1].what' is used but not defined.

Copy link
Member

@cole-h cole-h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just booted into this change. Works as expected.

$ systemctl cat tmp.mount
# /nix/store/4i7s80g57bqha7nna9yqcr50my0fva80-systemd-247.2/example/systemd/system/tmp.mount
#  SPDX-License-Identifier: LGPL-2.1-or-later
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=Temporary Directory (/tmp)
Documentation=https://systemd.io/TEMPORARY_DIRECTORIES
Documentation=man:file-hierarchy(7)
Documentation=https://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
ConditionPathIsSymbolicLink=!/tmp
DefaultDependencies=no
Conflicts=umount.target
Before=local-fs.target umount.target
After=swap.target

[Mount]
What=tmpfs
Where=/tmp
Type=tmpfs
Options=mode=1777,strictatime,nosuid,nodev,size=50%,nr_inodes=400k

# /nix/store/2x81582q36h2g1ar9qkpc3sz4j76h3xs-system-units/tmp.mount.d/overrides.conf
[Unit]

[Mount]
Options=mode=1777
Options=strictatime
Options=rw
Options=nosuid
Options=nodev
Options=size=50%
What=tmpfs
Where=/tmp

$ mount | rg /tmp
tmpfs on /tmp type tmpfs (rw,relatime,size=16416428k)

$ df -h | rg /tmp
tmpfs                                16G   16K   16G   1% /tmp

$ df -i | rg /tmp
tmpfs                                 4104106     35    4104071    1% /tmp

@ajs124
Copy link
Member Author

ajs124 commented Jan 13, 2021

Those separate Options lines look wrong. Are we sure this should be a list?

@cole-h
Copy link
Member

cole-h commented Jan 13, 2021

You could try changing mountConfig.Options to options and then change the options to be all in a line separated by commas.

However, I'm pretty sure it's just aesthetic. It works fine as-is.

diff --git a/nixos/modules/system/boot/tmp.nix b/nixos/modules/system/boot/tmp.nix
index c1442311280..66845af2d1f 100644
--- a/nixos/modules/system/boot/tmp.nix
+++ b/nixos/modules/system/boot/tmp.nix
@@ -40,7 +40,7 @@ with lib;
       {
         what = "tmpfs";
         where = "/tmp";
-        mountConfig.Options = [ "mode=1777" "strictatime" "rw" "nosuid" "nodev" "size=50%" ];
+        options = "mode=1777,strictatime,rw,nosuid,nodev,size=50%";
       }
     ];
 

EDIT: That works.

$ cat result/etc/systemd/system/tmp.mount.d/overrides.conf
[Unit]

[Mount]
Options=mode=1777,strictatime,rw,nosuid,nodev,size=50%
What=tmpfs
Where=/tmp

EDIT2: Is the rw option necessary?

@ajs124 ajs124 closed this Jan 15, 2021
@ajs124 ajs124 deleted the fix/tmpOnTmpfs branch January 15, 2021 00:28
@vcunat
Copy link
Member

vcunat commented Feb 17, 2022

Apparently it didn't: #157512

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants