diff --git a/flake.nix b/flake.nix index c8b556c..0935017 100644 --- a/flake.nix +++ b/flake.nix @@ -6,9 +6,16 @@ }; outputs = { self, nixpkgs }: - let - system = "x86_64-linux"; - in { - packages.${system}.default = nixpkgs.legacyPackages.${system}.callPackage ./. { }; + let + system = "x86_64-linux"; + package = nixpkgs.legacyPackages.${system}.callPackage ./. { }; + in { + packages.${system}.default = package; + + nixosModules.default = { + imports = [ ./module.nix ]; + + _module.args.package = package; }; + }; } diff --git a/module.nix b/module.nix new file mode 100644 index 0000000..d41d0fb --- /dev/null +++ b/module.nix @@ -0,0 +1,26 @@ +{ config, lib, pkgs, package, ... }: + +let + cfg = config.custom.minimal-youtube; +in +{ + options.custom.minimal-youtube = { + enable = lib.mkEnableOption "minimal-youtube web app"; + port = lib.mkOption { + type = lib.types.port; + default = 8080; + }; + }; + + config.systemd.services.minimal-youtube = { + wantedBy = [ "multi-user.target" ]; + + serviceConfig = { + ExecStart = + "${package}/bin/minimal-youtube --port ${toString cfg.port}"; + + Restart = "always"; + }; + }; +} +