Compare commits

..

2 Commits

Author SHA1 Message Date
d4a5eb5694 update 2025-07-13 02:54:45 -07:00
786a2d4132 improve zfs mounted script EVEN MORE (EVEN MORE MORE MORE) 2025-07-13 02:53:35 -07:00
2 changed files with 30 additions and 13 deletions

24
flake.lock generated
View File

@@ -191,11 +191,11 @@
]
},
"locked": {
"lastModified": 1752208517,
"narHash": "sha256-aRY1cYOdVdXdNjcL/Twpa27CknO7pVHxooPsBizDraE=",
"lastModified": 1752391422,
"narHash": "sha256-ReX0NG6nIAEtQQjLqeu1vUU2jjZuMlpymNtb4VQYeus=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "c6a01e54af81b381695db796a43360bf6db5702f",
"rev": "c26266790678863cce8e7460fdbf0d80991b1906",
"type": "github"
},
"original": {
@@ -238,11 +238,11 @@
]
},
"locked": {
"lastModified": 1752258421,
"narHash": "sha256-NBKcNtJv78fv6HJp1peu3HRwdITUCgZoqKNMpiEnpR0=",
"lastModified": 1752399196,
"narHash": "sha256-6g8BFnit2vPB4kPSio2WDqoIX5q799fOOw3Pn7pAXFw=",
"owner": "ggml-org",
"repo": "llama.cpp",
"rev": "f5e96b368f1acc7f53c390001b936517c4d18999",
"rev": "e743cddb60dc3a8815b9de7dd7d5c491e61b2259",
"type": "github"
},
"original": {
@@ -260,11 +260,11 @@
]
},
"locked": {
"lastModified": 1752286765,
"narHash": "sha256-GtbDWVpILwZY1UDrDvdn06Q5W0CXkcJ0kEcOxT8cObk=",
"lastModified": 1752373696,
"narHash": "sha256-xdjUzHG3sPAs3U1wVnx5hf1NrspCN+qtaBmAks+wnsM=",
"owner": "Infinidoge",
"repo": "nix-minecraft",
"rev": "c1f8c5755d2107cdab536b5dff33239ce8df7e18",
"rev": "93ca1ac26dc85d8c34f838a5afb7138ff445d2bc",
"type": "github"
},
"original": {
@@ -402,11 +402,11 @@
]
},
"locked": {
"lastModified": 1751564530,
"narHash": "sha256-DybnqQMmkMEbNQhrbMGFijZCa9g5mtYIMPACVNMJ5u8=",
"lastModified": 1752305350,
"narHash": "sha256-5sUt2hme7ReKCTUgcspIMnkZg80//zy8S6Yd27fKZJQ=",
"owner": "nix-community",
"repo": "srvos",
"rev": "6bb452f0b31058ffe64241bcf092ebf1c7758be1",
"rev": "c1229575cfc15ae7ad5d9f9bfa90c8a996a23d72",
"type": "github"
},
"original": {

19
lib.nix
View File

@@ -19,15 +19,30 @@ inputs.nixpkgs.lib.extend (
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)}
TARGETS=$(echo "${lib.strings.concatStringsSep "\n" dirs}" | sort | uniq)
MOUNTED=$(zfs list -o mountpoint,mounted -H | awk '$2 == "yes" {print $1}' | sort | uniq)
NUM_MATCHED=$(echo "$MOUNTED" | grep -Ec '${lib.strings.concatStringsSep "\|" dirs}')
if [[ "$NUM_MATCHED" -eq "${toString (lib.length dirs)}" ]]; then
exit 0
fi
FOUND=$(printf "%s\n%s" "$TARGETS" "$MOUNTED" | sort | uniq -c | awk '$1 == "2" {print $2}' | sort)
MISSING=$(printf "%s\n%s" "$FOUND" "$TARGETS" | sort | uniq -u | sort)
echo "FAILURE, missing: $MISSING" 1>&2
exit 1
'';
};
serviceMountDeps = serviceName: dirs: {
systemd.services."${serviceName}_mounts" = {
wants = [ "zfs.target" ];
before = [ "${serviceName}.service" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
@@ -37,6 +52,8 @@ inputs.nixpkgs.lib.extend (
systemd.services.${serviceName} = {
wants = [ "${serviceName}_mounts.service" ];
after = [ "${serviceName}_mounts.service" ];
requires = [ "${serviceName}_mounts.service" ];
};
};