Skip to content

Commit b721076

Browse files
authored
autotier: init at 1.2.0, lib45d: init at 0.3.6, nixos/autotierfs: init module (NixOS#335846)
2 parents c57c7c1 + eb40871 commit b721076

File tree

5 files changed

+230
-0
lines changed

5 files changed

+230
-0
lines changed

nixos/doc/manual/release-notes/rl-2505.section.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@
9797

9898
- [Bat](https://github.com/sharkdp/bat), a {manpage}`cat(1)` clone with wings. Available as [programs.bat](options.html#opt-programs.bat).
9999

100+
- [Autotier](https://github.com/45Drives/autotier), a passthrough FUSE filesystem. Available as [services.autotierfs](options.html#opt-services.autotierfs.enable).
101+
100102
- [µStreamer](https://github.com/pikvm/ustreamer), a lightweight MJPEG-HTTP streamer. Available as [services.ustreamer](options.html#opt-services.ustreamer).
101103

102104
- [Whoogle Search](https://github.com/benbusby/whoogle-search), a self-hosted, ad-free, privacy-respecting metasearch engine. Available as [services.whoogle-search](options.html#opt-services.whoogle-search.enable).

nixos/modules/module-list.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@
417417
./services/audio/squeezelite.nix
418418
./services/audio/tts.nix
419419
./services/audio/ympd.nix
420+
./services/autotierfs.nix
420421
./services/backup/automysqlbackup.nix
421422
./services/backup/bacula.nix
422423
./services/backup/borgbackup.nix
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
...
6+
}:
7+
let
8+
cfg = config.services.autotierfs;
9+
ini = pkgs.formats.ini { };
10+
format = lib.types.attrsOf ini.type;
11+
stateDir = "/var/lib/autotier";
12+
13+
generateConfigName =
14+
name: builtins.replaceStrings [ "/" ] [ "-" ] (lib.strings.removePrefix "/" name);
15+
configFiles = builtins.mapAttrs (
16+
name: val: ini.generate "${generateConfigName name}.conf" val
17+
) cfg.settings;
18+
19+
getMountDeps =
20+
settings: builtins.concatStringsSep " " (builtins.catAttrs "Path" (builtins.attrValues settings));
21+
22+
mountPaths = builtins.attrNames cfg.settings;
23+
in
24+
{
25+
options.services.autotierfs = {
26+
enable = lib.mkEnableOption "the autotier passthrough tiering filesystem";
27+
package = lib.mkPackageOption pkgs "autotier" { };
28+
settings = lib.mkOption {
29+
type = lib.types.submodule {
30+
freeformType = format;
31+
};
32+
default = { };
33+
description = ''
34+
The contents of the configuration file for autotier.
35+
See the [autotier repo](https://github.com/45Drives/autotier#configuration) for supported values.
36+
'';
37+
example = lib.literalExpression ''
38+
{
39+
"/mnt/autotier" = {
40+
Global = {
41+
"Log Level" = 1;
42+
"Tier Period" = 1000;
43+
"Copy Buffer Size" = "1 MiB";
44+
};
45+
"Tier 1" = {
46+
Path = "/mnt/tier1";
47+
Quota = "30GiB";
48+
};
49+
"Tier 2" = {
50+
Path = "/mnt/tier2";
51+
Quota = "200GiB";
52+
};
53+
};
54+
}
55+
'';
56+
};
57+
};
58+
59+
config = lib.mkIf cfg.enable {
60+
assertions = [
61+
{
62+
assertion = cfg.settings != { };
63+
message = "`services.autotierfs.settings` must be configured.";
64+
}
65+
];
66+
67+
system.fsPackages = [ cfg.package ];
68+
69+
# Not necessary for module to work but makes it easier to pass config into cli
70+
environment.etc = lib.attrsets.mapAttrs' (
71+
name: value:
72+
lib.attrsets.nameValuePair "autotier/${(generateConfigName name)}.conf" { source = value; }
73+
) configFiles;
74+
75+
systemd.tmpfiles.rules = (map (path: "d ${path} 0770 - autotier - -") mountPaths) ++ [
76+
"d ${stateDir} 0774 - autotier - -"
77+
];
78+
79+
users.groups.autotier = { };
80+
81+
systemd.services = lib.attrsets.mapAttrs' (
82+
path: values:
83+
lib.attrsets.nameValuePair (generateConfigName path) {
84+
description = "Mount autotierfs virtual path ${path}";
85+
unitConfig.RequiresMountsFor = getMountDeps values;
86+
wantedBy = [ "local-fs.target" ];
87+
serviceConfig = {
88+
Type = "forking";
89+
ExecStart = "${lib.getExe' cfg.package "autotierfs"} -c /etc/autotier/${generateConfigName path}.conf ${path} -o allow_other,default_permissions";
90+
ExecStop = "umount ${path}";
91+
};
92+
}
93+
) cfg.settings;
94+
};
95+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
stdenv,
3+
lib,
4+
fetchFromGitHub,
5+
fetchpatch,
6+
pkg-config,
7+
rocksdb,
8+
boost,
9+
fuse3,
10+
lib45d,
11+
tbb_2021_11,
12+
liburing,
13+
installShellFiles,
14+
}:
15+
stdenv.mkDerivation (finalAttrs: {
16+
name = "autotier";
17+
version = "1.2.0";
18+
src = fetchFromGitHub {
19+
owner = "45Drives";
20+
repo = "autotier";
21+
tag = "v${finalAttrs.version}";
22+
hash = "sha256-Pf1baDJsyt0ScASWrrgMu8+X5eZPGJSu0/LDQNHe1Ok=";
23+
};
24+
25+
patches = [
26+
# https://github.com/45Drives/autotier/pull/70
27+
# fix "error: 'uintmax_t' has not been declared" build failure until next release
28+
(fetchpatch {
29+
url = "https://github.com/45Drives/autotier/commit/d447929dc4262f607d87cbc8ad40a54d64f5011a.patch";
30+
hash = "sha256-0ab8YBgdJMxBHfOgUsgPpyUE1GyhAU3+WCYjYA2pjqo=";
31+
})
32+
# Unvendor rocksdb (nixpkgs already applies RTTI and PORTABLE flags) and use pkg-config for flags
33+
(fetchpatch {
34+
url = "https://github.com/45Drives/autotier/commit/fa282f5079ff17c144a7303d64dad0e44681b87f.patch";
35+
hash = "sha256-+W3RwSe8zJKgZIXOaawHuI6xRzedYIcZundPC8eHuwM=";
36+
})
37+
# Add missing list import to src/incl/config.hpp
38+
(fetchpatch {
39+
url = "https://github.com/45Drives/autotier/commit/1f97703f4dfbfe093f5c18c4ee01dcc1c8fe04f3.patch";
40+
hash = "sha256-3+KOh7JvbujCMbMqnZ5SGopAuOKHitKq6XV6a/jkcog=";
41+
})
42+
];
43+
44+
buildInputs = [
45+
rocksdb
46+
boost
47+
fuse3
48+
lib45d
49+
tbb_2021_11
50+
liburing
51+
];
52+
53+
nativeBuildInputs = [
54+
pkg-config
55+
installShellFiles
56+
];
57+
58+
installPhase = ''
59+
runHook preInstall
60+
61+
# binaries
62+
installBin dist/from_source/*
63+
64+
# docs
65+
installManPage doc/man/autotier.8
66+
67+
# Completions
68+
installShellCompletion --bash doc/completion/autotier.bash-completion
69+
installShellCompletion --bash doc/completion/autotierfs.bash-completion
70+
71+
# Scripts
72+
installBin script/autotier-init-dirs
73+
74+
# Default config
75+
install -Dm755 -t $out/etc/autotier.conf doc/autotier.conf.template
76+
77+
runHook postInstall
78+
'';
79+
80+
meta = {
81+
homepage = "https://github.com/45Drives/autotier";
82+
description = "Passthrough FUSE filesystem that intelligently moves files between storage tiers based on frequency of use, file age, and tier fullness";
83+
license = lib.licenses.gpl3;
84+
maintainers = with lib.maintainers; [ philipwilk ];
85+
mainProgram = "autotier"; # cli, for file system use autotierfs
86+
platforms = lib.platforms.linux; # uses io_uring so only available on linux not unix
87+
};
88+
})

pkgs/by-name/li/lib45d/package.nix

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
stdenv,
3+
fetchFromGitHub,
4+
fetchpatch,
5+
lib,
6+
}:
7+
stdenv.mkDerivation (finalAttrs: {
8+
name = "lib45d";
9+
version = "0.3.6";
10+
src = fetchFromGitHub {
11+
owner = "45Drives";
12+
repo = "lib45d";
13+
tag = "v${finalAttrs.version}";
14+
hash = "sha256-42xB30Iu2WxNrBxomVBKd/uyIRt27y/Y1ah5mckOrc0=";
15+
};
16+
17+
patches = [
18+
# https://github.com/45Drives/lib45d/issues/3
19+
# fix "error: 'uintmax_t' has not been declared" build failure until next release
20+
(fetchpatch {
21+
url = "https://github.com/45Drives/lib45d/commit/a607e278182a3184c004c45c215aa22c15d6941d.patch";
22+
hash = "sha256-sMAvOp4EjBXGHa9PGuuEqJvpEvUlMuzRKCfq9oqQLgY=";
23+
})
24+
];
25+
26+
installPhase = ''
27+
runHook preInstall
28+
29+
install -Dm755 -t $out/lib dist/shared/lib45d.so
30+
31+
mkdir -p $out/include/45d
32+
cp -f -r src/incl/45d/* $out/include/45d/
33+
34+
runHook postInstall
35+
'';
36+
37+
meta = {
38+
homepage = "https://github.com/45Drives/lib45d";
39+
description = "45Drives C++ Library";
40+
license = lib.licenses.gpl3;
41+
maintainers = with lib.maintainers; [ philipwilk ];
42+
platforms = lib.platforms.linux;
43+
};
44+
})

0 commit comments

Comments
 (0)