new git-hooks based deployment
This commit is contained in:
parent
e65718178e
commit
a8e9884c3c
5 changed files with 85 additions and 80 deletions
58
module.nix
Normal file
58
module.nix
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
{
|
||||
options.services.fooud = {
|
||||
enable = lib.mkEnableOption config.description;
|
||||
repos = lib.mkOption {
|
||||
type = lib.listOf {
|
||||
path = lib.mkOption {
|
||||
description = "fullpath to the repositiory on your server";
|
||||
type = lib.types.string;
|
||||
};
|
||||
hooks = lib.mkOption {
|
||||
type = lib.listOf lib.types.path;
|
||||
example = [
|
||||
pkgs.writeScriptBin "post-recieve" ''
|
||||
git clone . /var/www/your/deployed/location
|
||||
''
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "fooud-deploy";
|
||||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
cfg = config.services.fooud;
|
||||
in lib.mkIf cfg.enable {
|
||||
users.users."${cfg.user}" = {
|
||||
group = "${cfg.user}";
|
||||
isSystemUser = true;
|
||||
createHome = true;
|
||||
home = "/var/lib/${cfg.user}";
|
||||
shell = "${pkgs.git}/bin/git-shell";
|
||||
};
|
||||
users.groups."${cfg.user}" = {};
|
||||
|
||||
systemd = {
|
||||
services."fooud" = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
User = cfg.user;
|
||||
ExecStart = pkgs.writeScriptBin "fooud-deploy"
|
||||
(lib.concatMapStrings
|
||||
(repo: ''
|
||||
if [ -d ${repo.path} ]; then
|
||||
rm -f ${repo.path}/hooks/*
|
||||
cp ${repo.hooks}/bin/* ${repo.name}/hooks/
|
||||
fi
|
||||
'')
|
||||
cfg.repos);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue