This commit is contained in:
zuckerberg 2021-08-22 23:21:05 -04:00
parent 5a0711839d
commit 1e0fabf9a0
5 changed files with 149 additions and 9 deletions

View File

@ -19,6 +19,7 @@
./server/gitea.nix ./server/gitea.nix
./server/privatebin/privatebin.nix ./server/privatebin/privatebin.nix
./server/drastikbot.nix ./server/drastikbot.nix
./server/radio.nix
./pc/de.nix ./pc/de.nix
]; ];

73
common/server/radio.nix Normal file
View File

@ -0,0 +1,73 @@
{ config, pkgs, lib, inputs, system, ... }:
let
cfg = config.services.radio;
radioPackage = inputs.radio.packages.${system}.radio;
in {
options.services.radio = {
enable = lib.mkEnableOption "enable radio";
user = lib.mkOption {
type = lib.types.str;
default = "radio";
description = ''
The user radio should run as
'';
};
group = lib.mkOption {
type = lib.types.str;
default = "radio";
description = ''
The group radio should run as
'';
};
dataDir = lib.mkOption {
type = lib.types.str;
default = "/var/lib/radio";
description = ''
Path to the radio data directory
'';
};
host = lib.mkOption {
type = lib.types.str;
description = ''
Domain radio is hosted on
'';
};
};
config = lib.mkIf cfg.enable {
services.icecast = {
enable = true;
hostname = cfg.host;
mount = "stream.mp3";
fallback = "fallback.mp3";
};
services.nginx.virtualHosts.${cfg.host} = {
enableACME = true;
forceSSL = true;
locations."/".root = inputs.radio-web;
};
users.users.${cfg.user} = {
isSystemUser = true;
group = cfg.group;
home = cfg.dataDir;
createHome = true;
};
users.groups.${cfg.group} = {};
systemd.services.radio = {
enable = true;
after = ["network.target"];
wantedBy = ["multi-user.target"];
serviceConfig.ExecStart = "${radioPackage}/bin/radio";
serviceConfig.User = cfg.user;
serviceConfig.Group = cfg.group;
serviceConfig.WorkingDirectory = cfg.dataDir;
preStart = ''
mkdir -p ${cfg.dataDir}
chown ${cfg.user} ${cfg.dataDir}
'';
};
};
}

69
flake.lock generated
View File

@ -18,6 +18,21 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils": {
"locked": {
"lastModified": 1620759905,
"narHash": "sha256-WiyWawrgmyN0EdmiHyG2V+fqReiVi8bM9cRdMaKQOFg=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b543720b25df6ffdfcf9227afafc5b8c1fabfae8",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1618628710, "lastModified": 1618628710,
@ -64,6 +79,20 @@
} }
}, },
"nixpkgs_3": { "nixpkgs_3": {
"locked": {
"lastModified": 1621784194,
"narHash": "sha256-CQWN/QvVHG8qCn7UhGGwoT3jAPvnJHQUvzBlIt48FGs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c5265c01a944b1cecfcfab392d5204d73d65d4ec",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_4": {
"locked": { "locked": {
"lastModified": 1607522989, "lastModified": 1607522989,
"narHash": "sha256-o/jWhOSAlaK7y2M57OIriRt6whuVVocS/T0mG7fd1TI=", "narHash": "sha256-o/jWhOSAlaK7y2M57OIriRt6whuVVocS/T0mG7fd1TI=",
@ -78,17 +107,55 @@
"type": "indirect" "type": "indirect"
} }
}, },
"radio": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1623978466,
"narHash": "sha256-uwVzyiHrlVxtQ2HsnWEfkdRY7i5GEEj3/M27Ht/3gjg=",
"ref": "main",
"rev": "71a1443301540a70930d8edc4528a93ec9745e21",
"revCount": 21,
"type": "git",
"url": "https://git.neet.dev/zuckerberg/radio.git"
},
"original": {
"ref": "main",
"type": "git",
"url": "https://git.neet.dev/zuckerberg/radio.git"
}
},
"radio-web": {
"flake": false,
"locked": {
"lastModified": 1629688573,
"narHash": "sha256-ORZ8bc3aWUnvkDDkhyVfGBLWr3fO5LmmiJLdLWGoV80=",
"ref": "master",
"rev": "57322a3c213713371604ecc82a448451d636b0b4",
"revCount": 3,
"type": "git",
"url": "https://git.neet.dev/zuckerberg/radio-web.git"
},
"original": {
"type": "git",
"url": "https://git.neet.dev/zuckerberg/radio-web.git"
}
},
"root": { "root": {
"inputs": { "inputs": {
"agenix": "agenix", "agenix": "agenix",
"nixpkgs": "nixpkgs_2", "nixpkgs": "nixpkgs_2",
"nixpkgs-peertube": "nixpkgs-peertube", "nixpkgs-peertube": "nixpkgs-peertube",
"radio": "radio",
"radio-web": "radio-web",
"simple-nixos-mailserver": "simple-nixos-mailserver" "simple-nixos-mailserver": "simple-nixos-mailserver"
} }
}, },
"simple-nixos-mailserver": { "simple-nixos-mailserver": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs_3", "nixpkgs": "nixpkgs_4",
"utils": "utils" "utils": "utils"
}, },
"locked": { "locked": {

View File

@ -4,6 +4,9 @@
nixpkgs-peertube.url = "github:GoogleBot42/nixpkgs/add-peertube-service"; nixpkgs-peertube.url = "github:GoogleBot42/nixpkgs/add-peertube-service";
simple-nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver/nixos-21.05"; simple-nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver/nixos-21.05";
agenix.url = "github:ryantm/agenix"; agenix.url = "github:ryantm/agenix";
radio.url = "git+https://git.neet.dev/zuckerberg/radio.git?ref=main";
radio-web.url = "git+https://git.neet.dev/zuckerberg/radio-web.git";
radio-web.flake = false;
}; };
outputs = inputs: { outputs = inputs: {
@ -24,7 +27,7 @@
environment.systemPackages = [ inputs.agenix.defaultPackage.${system} ]; environment.systemPackages = [ inputs.agenix.defaultPackage.${system} ];
} }
]; ];
specialArgs = { inherit inputs; }; specialArgs = { inherit inputs; inherit system; };
}; };
in in
{ {

View File

@ -110,13 +110,9 @@
}); });
}; };
services.nginx.virtualHosts."radio.neet.space" = { services.radio = {
enableACME = true; enable = true;
forceSSL = true; host = "radio.neet.space";
locations."/".root = builtins.fetchTarball {
url = "https://git.neet.dev/zuckerberg/radio-web/archive/a69e0e27b70694a8fffe8834d7e5f0e67db83dfa.tar.gz";
sha256 = "076q540my5ssbhwlc8v8vafcddcq7ydxnzagw4qqr1ii6ikfn80w";
};
}; };
services.nginx.virtualHosts."paradigminteractive.agency" = { services.nginx.virtualHosts."paradigminteractive.agency" = {