extend nixpkgs's lib instead
This commit is contained in:
59
flake.nix
59
flake.nix
@@ -135,37 +135,8 @@
|
||||
};
|
||||
};
|
||||
|
||||
serviceMountDeps = serviceName: dirs: pkgs: {
|
||||
systemd.services."${serviceName}_mounts" =
|
||||
let
|
||||
lib = nixpkgs.lib;
|
||||
zfslistmounted = pkgs.writeShellApplication {
|
||||
name = "zfslistmounted";
|
||||
runtimeInputs = with pkgs; [
|
||||
zfs
|
||||
gnugrep
|
||||
gawk
|
||||
coreutils
|
||||
];
|
||||
text = ''
|
||||
#!/bin/sh
|
||||
zfs list -o mountpoint,mounted -H | awk '$2 == "yes" {print $1}' | grep -c '${lib.strings.concatStringsSep "\|" dirs}' | grep -Fq ${toString (lib.length dirs)}
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
unitConfig.Wants = "zfs.target";
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
ExecStart = nixpkgs.lib.getExe zfslistmounted;
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.${serviceName} = {
|
||||
wants = [ "${serviceName}_mounts.service" ];
|
||||
};
|
||||
};
|
||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||
lib = import ./lib.nix { inherit inputs pkgs; };
|
||||
in
|
||||
{
|
||||
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style;
|
||||
@@ -177,32 +148,8 @@
|
||||
eth_interface
|
||||
service_configs
|
||||
inputs
|
||||
serviceMountDeps
|
||||
lib
|
||||
;
|
||||
|
||||
# stolen from: https://stackoverflow.com/a/42398526
|
||||
optimizeWithFlags =
|
||||
pkg: flags:
|
||||
nixpkgs.lib.overrideDerivation pkg (
|
||||
old:
|
||||
let
|
||||
newflags = nixpkgs.lib.foldl' (acc: x: "${acc} ${x}") "" flags;
|
||||
oldflags =
|
||||
if (nixpkgs.lib.hasAttr "NIX_CFLAGS_COMPILE" old) then "${old.NIX_CFLAGS_COMPILE}" else "";
|
||||
in
|
||||
{
|
||||
NIX_CFLAGS_COMPILE = "${oldflags} ${newflags}";
|
||||
# stdenv = pkgs.clang19Stdenv;
|
||||
}
|
||||
);
|
||||
|
||||
optimizePackage =
|
||||
pkg:
|
||||
optimizeWithFlags pkg [
|
||||
"-O3"
|
||||
"-march=znver3"
|
||||
"-mtune=znver3"
|
||||
];
|
||||
};
|
||||
modules =
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user