From 433b3f6218cb1960c61c9077445093a23ff5dd66 Mon Sep 17 00:00:00 2001 From: Skarlett Date: Sun, 23 Jul 2023 05:18:27 -0500 Subject: [PATCH] fix: airsonic --- .github/workflows/airsonic-advanced-war.yaml | 20 ++++++++++++++ machines/charmander.nix | 9 +++--- modules/airsonic-advanced.nix | 29 ++++++++++++++++---- packages/default.nix | 2 +- 4 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/airsonic-advanced-war.yaml diff --git a/.github/workflows/airsonic-advanced-war.yaml b/.github/workflows/airsonic-advanced-war.yaml new file mode 100644 index 0000000..3c59260 --- /dev/null +++ b/.github/workflows/airsonic-advanced-war.yaml @@ -0,0 +1,20 @@ +VERSION: 5 +env: {} +jobs: + airsonic-advanced-war: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/install-nix-action@v20 + with: + github_access_token: ${{ secrets.GITHUB_TOKEN }} + nix_path: nixpkgs=channel:nixos-unstable + - run: nix build .#airsonic-advanced-war +name: airsonic-advanced-war +on: + pull_request: + branches: + - master + push: + branches: + - master diff --git a/machines/charmander.nix b/machines/charmander.nix index b466c87..11b7272 100644 --- a/machines/charmander.nix +++ b/machines/charmander.nix @@ -2,6 +2,11 @@ { remote-access.lunarix = true; nixpkgs.config.allowUnfree = true; + + services.airsonic-advanced.enable = true; + services.airsonic-advanced.openFirewall = true; + + # boot.kernelPackages = pkgs.linuxPackages_4_19; boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/sde"; @@ -24,10 +29,6 @@ # ''; }; - - - self.packages.${pkgs.system}.airsonic-advanced-war; - boot.kernel.sysctl."net.ipv6.conf.luna.ip_forward" = 1; boot.kernel.sysctl."net.ipv4.conf.luna.ip_forward" = 1; diff --git a/modules/airsonic-advanced.nix b/modules/airsonic-advanced.nix index c7d1f00..d53a450 100644 --- a/modules/airsonic-advanced.nix +++ b/modules/airsonic-advanced.nix @@ -4,19 +4,38 @@ let cfg = config.services.airsonic-advanced; in { - options.services.airsonic-advanced.enable = mkEnableOption "Enable airsonic-advanced"; + options.services.airsonic-advanced = { + enable = mkEnableOption "Enable airsonic-advanced"; + port = mkOption { + type = types.int; + default = 4040; + description = "Port to listen on"; + }; + + openFirewall = mkOption { + type = types.bool; + default = true; + description = "Open port in firewall"; + }; + + war = mkOption { + default = + "${pkgs.self.airsonic-advanced-war.outPath}/webapps/airsonic.war"; + }; + }; config = mkIf cfg.enable { services.airsonic = { enable = true; jre = pkgs.openjdk11; maxMemory = 4096; - war = "${pkgs.self.airsonic-advanced-war.outPath}/webapps/airsonic.war"; - jveOptions = [ + war = cfg.war; + port = cfg.port; + jvmOptions = [ "-server" ]; + listenAddress = "0.0.0.0"; }; - - networking.firewall.allowedTCPPorts = [ config.services.airsonic.port ]; + networking.firewall.allowedTCPPorts = [ cfg.port ]; }; } diff --git a/packages/default.nix b/packages/default.nix index 37b8bf0..61e2fee 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -20,7 +20,7 @@ self-lib.withSystem (system: REDIRECT="https://github.com/skarlett"; }; - packages.airsonic-advanced = pkgs.callPackage ./airsonic-advanced.nix {}; + packages.airsonic-advanced-war = pkgs.callPackage ./airsonic-advanced.nix {}; } { packages = builtins.removeAttrs (pkgs.callPackage ./pzserver {})