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

Swapspace: dynamically manage swapspace on NixOS #88093

Open
wants to merge 2 commits into
base: master
from

Conversation

@wmertens
Copy link
Contributor

wmertens commented May 18, 2020

Motivation for this change

Using NixOS with dynamic swap size management, the way macOS does it.

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.
type = types.path;
default = "/var/lib/swap";
description = ''
Location of the swap files. This directory will be restrticted to root.

This comment has been minimized.

Copy link
@langston-barrett

langston-barrett May 18, 2020

Contributor
Suggested change
Location of the swap files. This directory will be restrticted to root.
Location of the swap files. This directory will be restricted to root.
Restart = "always";
RestartSec = 30;
};
after = [ "local-fs.target" "systemd-udev-settle.service" ];

This comment has been minimized.

Copy link
@flokli

flokli May 21, 2020

Contributor

local-fs.target is part of sysinit.target, which is in the set of default dependencies. No need to specify it here.

What's the systemd-udev-settle.service about?

fetchSubmodules = false;
};

# TODO patch runcommands to include path to mkswap, swapon/off, btrfs (optional)

This comment has been minimized.

Copy link
@flokli

flokli May 21, 2020

Contributor

That TODO is leftover from the patchPhase below?

sed tends to silently break and not apply anymore.

To make this more robust, we usually provide a patch that replaces sources with placeholders, and then do a substituteAll on the patch file with the actual occurences - see the bazel derivation for an example.

version = "1.16.1";
name = "swapspace-${version}";

src = fetchgit {

This comment has been minimized.

Copy link
@flokli

flokli May 21, 2020

Contributor

This can probably be fetchFromGitHub.


src = fetchgit {
url = "https://github.com/Tookmund/Swapspace.git";
rev = "refs/tags/v${version}";

This comment has been minimized.

Copy link
@flokli

flokli May 21, 2020

Contributor

rev can be the tag directly. rev = "v${version}";.

url = "https://github.com/Tookmund/Swapspace.git";
rev = "refs/tags/v${version}";
sha256 = "1hbxaq05zdfhw5c8lypnl1qvh7n9ng0nawlizs9g6l77z8sn0ji8";
fetchSubmodules = false;

This comment has been minimized.

Copy link
@flokli

flokli May 21, 2020

Contributor

Why do you explicitly set this to false here? Does it provide submodules, but they're wrong?

AFAIK, fetchSubmodules is the default anyways.


enableParallelBuilding = true;

buildInputs = [ autoconf automake ];

This comment has been minimized.

Copy link
@flokli

flokli May 21, 2020

Contributor

these are nativeBuildInputs.

autoreconf -i
'';

makeFlags = [ "PREFIX=$(out)" ];

This comment has been minimized.

Copy link
@flokli

flokli May 21, 2020

Contributor

might be the setup hook already provides some sane defaults here.

Also, while at it, any way to convince the build system to put the swapspace into $out/bin, not $out/sbin?

###### implementation

config = mkIf cfg.enable {
systemd.services.swapspace = with pkgs; {

This comment has been minimized.

Copy link
@flokli

flokli May 21, 2020

Contributor
Suggested change
systemd.services.swapspace = with pkgs; {
systemd.services.swapspace = {

you don't refer to things inside pkgs anywhere.

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

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.