global/general: replace ensure with systemd tmpfiles

This commit is contained in:
Infinidoge 2024-01-31 14:21:18 -05:00
parent 6cfbf62470
commit d09fc8a2b2
Signed by: Infinidoge
SSH key fingerprint: SHA256:oAMyvotlNFraMmZmr+p6AxnNfW/GioTs1pOn3V4tQ7A
3 changed files with 5 additions and 25 deletions

View file

@ -1,21 +0,0 @@
{ config, lib, pkgs, ... }:
with lib;
with lib.our;
let
cfg = config.services.ensure;
in
{
options.services.ensure = with types; {
enable = mkBoolOpt true;
directories = mkOpt (listOf str) [ ];
};
config.systemd.services = {
"ensure-directories" = mkIf (cfg.enable && (length cfg.directories > 0)) {
description = "Ensures certain directories exist (${concatStringsSep "," cfg.directories})";
wantedBy = [ "multi-user.target" ];
serviceConfig.Type = "oneshot";
script = "mkdir -p ${concatStringsSep " " cfg.directories}";
};
};
}

View file

@ -13,13 +13,15 @@
# Enable Early Out of Memory service # Enable Early Out of Memory service
earlyoom.enable = true; earlyoom.enable = true;
# Ensure certain necessary directories always exist
ensure.directories = [ "/mnt" ];
# Accept EULA for all minecraft servers # Accept EULA for all minecraft servers
minecraft-servers.eula = true; minecraft-servers.eula = true;
}; };
# Ensure certain necessary directories always exist
systemd.tmpfiles.rules = [
"d /mnt 0777 root root - -"
];
system.activationScripts = { system.activationScripts = {
# FIX: command-not-found database doesn't exist normally # FIX: command-not-found database doesn't exist normally
# FIXME: activation script doesn't work properly, and frequently errors # FIXME: activation script doesn't work properly, and frequently errors

View file

@ -43,7 +43,6 @@ The real meat of the configuration, defines a bunch of NixOS modules that all ge
Modules that create some sort of new functionality. Modules that create some sort of new functionality.
- `ensure.nix`: Takes a list of directories, and ensures they exist after boot.
- `soft-serve.nix`: Runs the `soft-serve` git server. - `soft-serve.nix`: Runs the `soft-serve` git server.
- `ssh-tunnel.nix`: Runs an SSH session for opening ports. - `ssh-tunnel.nix`: Runs an SSH session for opening ports.