59 lines
1.4 KiB
Nix
59 lines
1.4 KiB
Nix
{
|
|
inputs,
|
|
pkgs,
|
|
...
|
|
}:
|
|
inputs.nixpkgs.lib.extend (
|
|
final: prev:
|
|
let
|
|
lib = prev;
|
|
in
|
|
{
|
|
|
|
serviceMountDeps =
|
|
serviceName: dirs:
|
|
{ pkgs, ... }:
|
|
{
|
|
systemd.services."${serviceName}_mounts" = {
|
|
wants = [ "zfs.target" ];
|
|
before = [ "${serviceName}.service" ];
|
|
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
RemainAfterExit = true;
|
|
ExecStart = "${lib.getExe pkgs.ensureZfsMounts} ${lib.strings.concatStringsSep " " dirs}";
|
|
};
|
|
};
|
|
|
|
systemd.services.${serviceName} = {
|
|
wants = [ "${serviceName}_mounts.service" ];
|
|
after = [ "${serviceName}_mounts.service" ];
|
|
requires = [ "${serviceName}_mounts.service" ];
|
|
};
|
|
};
|
|
|
|
# stolen from: https://stackoverflow.com/a/42398526
|
|
optimizeWithFlags =
|
|
pkg: flags:
|
|
lib.overrideDerivation pkg (
|
|
old:
|
|
let
|
|
newflags = lib.foldl' (acc: x: "${acc} ${x}") "" flags;
|
|
oldflags = if (lib.hasAttr "NIX_CFLAGS_COMPILE" old) then "${old.NIX_CFLAGS_COMPILE}" else "";
|
|
in
|
|
{
|
|
NIX_CFLAGS_COMPILE = "${oldflags} ${newflags}";
|
|
# stdenv = pkgs.clang19Stdenv;
|
|
}
|
|
);
|
|
|
|
optimizePackage =
|
|
pkg:
|
|
final.optimizeWithFlags pkg [
|
|
"-O3"
|
|
"-march=znver3"
|
|
"-mtune=znver3"
|
|
];
|
|
}
|
|
)
|