mirror of
https://github.com/TeamPiped/Piped-Docker.git
synced 2024-12-13 22:00:40 +05:30
Add nix files
This commit is contained in:
parent
e0a45cbbc8
commit
1b39427600
7
flake.nix
Normal file
7
flake.nix
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; };
|
||||
|
||||
outputs = { nixpkgs, ... }@inputs: {
|
||||
nixosModules = { default = import ./nix; };
|
||||
};
|
||||
}
|
1
nix/default.nix
Normal file
1
nix/default.nix
Normal file
@ -0,0 +1 @@
|
||||
{ ... }: { imports = [ ./options.nix ./piped.nix ]; }
|
48
nix/options.nix
Normal file
48
nix/options.nix
Normal file
@ -0,0 +1,48 @@
|
||||
{ lib, ... }:
|
||||
|
||||
{
|
||||
options = with lib; {
|
||||
piped = {
|
||||
enable = mkOption {
|
||||
description = "Enable the piped service";
|
||||
type = types.bool;
|
||||
default = false;
|
||||
};
|
||||
|
||||
# Config for configure-instance.sh
|
||||
frontend = mkOption {
|
||||
description = "Hostname for the Frontend (eg: piped.kavin.rocks)";
|
||||
type = types.str;
|
||||
};
|
||||
backend = mkOption {
|
||||
description = "Hostname for the Backend (eg: pipedapi.kavin.rocks)";
|
||||
type = types.str;
|
||||
};
|
||||
proxy = mkOption {
|
||||
description = "Hostname for the Proxy (eg: pipedproxy.kavin.rocks)";
|
||||
type = types.str;
|
||||
};
|
||||
reverseproxy = mkOption {
|
||||
description = "Reverse proxy you would like to use (either caddy or nginx)";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
# Additional Config
|
||||
dataDir = mkOption {
|
||||
description = "The path for data storage";
|
||||
type = types.str;
|
||||
default = "/var/lib/piped";
|
||||
};
|
||||
httpPort = mkOption {
|
||||
description = "The port to listen for HTTP conenctions";
|
||||
type = types.int;
|
||||
default = 80;
|
||||
};
|
||||
httpsPort = mkOption {
|
||||
description = "The port to listen for HTTPS conenctions";
|
||||
type = types.int;
|
||||
default = 443;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
27
nix/piped-package.nix
Normal file
27
nix/piped-package.nix
Normal file
@ -0,0 +1,27 @@
|
||||
{ stdenvNoCC, bash, pipedConfig }:
|
||||
|
||||
stdenvNoCC.mkDerivation rec {
|
||||
name = "piped";
|
||||
|
||||
src = ../template;
|
||||
installer = ../configure-instance.sh;
|
||||
|
||||
preferLocalBuild = true;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p "$out/template"
|
||||
cp -r . "$out/template"
|
||||
cd "$out"
|
||||
${bash}/bin/bash ${installer} <<<$(
|
||||
echo ${pipedConfig.frontend}
|
||||
echo ${pipedConfig.backend}
|
||||
echo ${pipedConfig.proxy}
|
||||
echo ${pipedConfig.reverseproxy}
|
||||
)
|
||||
rm -rf $out/template
|
||||
|
||||
sed "s|80:|${builtins.toString pipedConfig.httpPort}:|g" -i docker-compose.yml
|
||||
sed "s|443:|${builtins.toString pipedConfig.httpsPort}:|g" -i docker-compose.yml
|
||||
sed "s|\./data|${pipedConfig.dataDir}|g" -i docker-compose.yml
|
||||
'';
|
||||
}
|
19
nix/piped.nix
Normal file
19
nix/piped.nix
Normal file
@ -0,0 +1,19 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
pipedPackage = pkgs.callPackage ./piped-package.nix { pipedConfig = config.piped; };
|
||||
in lib.mkIf config.piped.enable {
|
||||
virtualisation.docker.enable = true;
|
||||
systemd.services.piped = {
|
||||
enable = true;
|
||||
serviceConfig = {
|
||||
WorkingDirectory = pipedPackage;
|
||||
preStart = "${pkgs.docker-compose}/bin/docker-compose pull";
|
||||
ExecStart = "${pkgs.docker-compose}/bin/docker-compose up";
|
||||
ExecStop = "${pkgs.docker-compose}/bin/docker-compose down";
|
||||
};
|
||||
environment.COMPOSE_PROJECT_NAME = "piped-flake";
|
||||
after = [ "docker.service" "docker.socket" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user