1
0
Fork 0

refactor systemd-unit derivation

This commit is contained in:
ibizaman 2022-05-19 20:00:12 -07:00
parent a35170e3bb
commit 776265ddac
2 changed files with 5 additions and 8 deletions

View file

@ -1,6 +1,7 @@
{ stdenv { stdenv
, pkgs , pkgs
, lib , lib
, utils
}: }:
{ readOnlyPaths ? [] { readOnlyPaths ? []
, readWritePaths ? [] , readWritePaths ? []
@ -22,9 +23,9 @@ let
fullPath = "${TtrssService.documentRoot}/${TtrssService.documentName}"; fullPath = "${TtrssService.documentRoot}/${TtrssService.documentName}";
roPaths = [fullPath] ++ readOnlyPaths; roPaths = [fullPath] ++ readOnlyPaths;
in in
stdenv.mkDerivation rec { utils.systemd-service-derivation rec {
name = "ttrss-update"; name = "ttrss-update";
src = pkgs.writeTextDir "${name}.service" '' content = ''
[Unit] [Unit]
Description=${name} Description=${name}
After=network.target ${TtrssPostgresDB.postgresServiceName} After=network.target ${TtrssPostgresDB.postgresServiceName}
@ -60,9 +61,4 @@ stdenv.mkDerivation rec {
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
''; '';
installPhase = ''
mkdir -p $out/etc/systemd/system
cp $src/*.service $out/etc/systemd/system
'';
} }

View file

@ -2,6 +2,7 @@
, services ? null , services ? null
, system ? builtins.currentSystem , system ? builtins.currentSystem
, pkgs ? import <nixpkgs> { inherit system; } , pkgs ? import <nixpkgs> { inherit system; }
, utils ? null
}: }:
let let
@ -11,7 +12,7 @@ let
PostgresDB = callPackage ./PostgresDB {}; PostgresDB = callPackage ./PostgresDB {};
TtrssService = callPackage ./Ttrss {}; TtrssService = callPackage ./Ttrss {};
TtrssUpdateService = callPackage ./Ttrss/update.nix {}; TtrssUpdateService = callPackage ./Ttrss/update.nix {inherit utils;};
TtrssUpgradeDBService = callPackage ./Ttrss/dbupgrade.nix {}; TtrssUpgradeDBService = callPackage ./Ttrss/dbupgrade.nix {};
}; };
in in