Added a module to flake
This commit is contained in:
parent
fc6c3f9157
commit
724a862647
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -13,3 +13,4 @@ faup1090
|
|||
package-wheezy
|
||||
oneoff/convert_benchmark
|
||||
oneoff/decode_comm_b
|
||||
result
|
|
@ -36,7 +36,7 @@ stdenv.mkDerivation rec {
|
|||
|
||||
mkdir -p $out/bin $out/share
|
||||
cp -v dump1090 $out/bin/dump1090-afg
|
||||
cp -vr public_html $out/share/dump1090
|
||||
cp -vr public_html $out/share/dump1090-afg
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
|
|
@ -33,5 +33,10 @@
|
|||
aarch64-linux.default = nixpkgs.legacyPackages.aarch64-linux.callPackage ./default.nix { };
|
||||
armv6l-linux.default = nixpkgs.legacyPackages.armv6l-linux.callPackage ./default.nix { };
|
||||
};
|
||||
|
||||
nixosModules.default = { config, pkgs, ... }: {
|
||||
imports = [ ./module.nix ];
|
||||
_module.args.dump1090afg = self.packages;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
67
module.nix
Normal file
67
module.nix
Normal file
|
@ -0,0 +1,67 @@
|
|||
{ lib, config, pkgs, dump1090afg, ... }:
|
||||
with lib;
|
||||
let
|
||||
# Shorter name to access final settings a
|
||||
# user of hello.nix module HAS ACTUALLY SET.
|
||||
# cfg is a typical convention.
|
||||
cfg = config.services.dump1090afg;
|
||||
in
|
||||
{
|
||||
|
||||
options.services.dump1090afg = {
|
||||
enable = mkEnableOption "dump1090afg service";
|
||||
package = mkOption {
|
||||
default = dump1090afg.x86_64-linux.cross-armv6l-linux;
|
||||
type = types.package;
|
||||
};
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
default = "afg";
|
||||
};
|
||||
domain = mkOption {
|
||||
type = types.str;
|
||||
default = "localhost";
|
||||
};
|
||||
enableSSL = mkEnableOption "use let's encrypt SSL certs for dump1090afg";
|
||||
};
|
||||
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
# List packages installed in system profile. To search, run:
|
||||
# $ nix search wget
|
||||
environment.systemPackages = [
|
||||
cfg.package
|
||||
];
|
||||
|
||||
hardware.rtl-sdr.enable = true;
|
||||
|
||||
systemd.services.dump1090afg = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
wants = [ "network.target" ];
|
||||
after = [ "network.target" ];
|
||||
description = "dump1090afg service";
|
||||
serviceConfig = {
|
||||
Type = "exec";
|
||||
User = cfg.user;
|
||||
Restart = "always";
|
||||
RestartSec = "3s";
|
||||
StartLimitIntervalSec = "0";
|
||||
RuntimeDirectory = "dump1090-afg";
|
||||
};
|
||||
script = ''
|
||||
exec ${cfg.package}/bin/dump1090-afg --write-json /var/run/dump1090-afg --quiet
|
||||
'';
|
||||
};
|
||||
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
virtualHosts."${cfg.domain}" = {
|
||||
root = "${cfg.package}/share/dump1090-afg";
|
||||
locations."/data/".alias = "/var/run/dump1090-afg/";
|
||||
enableACME = cfg.enableSSL;
|
||||
forceSSL = cfg.enableSSL;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in a new issue