Added a module to flake

This commit is contained in:
Sebastian 2023-11-11 16:48:39 +01:00
parent fc6c3f9157
commit 724a862647
5 changed files with 74 additions and 2 deletions

1
.gitignore vendored
View file

@ -13,3 +13,4 @@ faup1090
package-wheezy
oneoff/convert_benchmark
oneoff/decode_comm_b
result

View file

@ -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
'';

View file

@ -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
View 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;
};
};
};
}

1
result
View file

@ -1 +0,0 @@
/nix/store/6czbzhsdidalrmwmxqh5xdvd6ma8ynp2-dump1090-afg-armv6l-unknown-linux-gnueabihf-1.0