Created
February 3, 2018 02:31
-
-
Save dalaing/8c368445ec91a2cbae1590b16f75d422 to your computer and use it in GitHub Desktop.
Hail example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { config, pkgs, lib ? pkgs.lib, ... }: | |
| with lib; | |
| let | |
| cfg = config.services.blog-updater; | |
| in | |
| { | |
| # interface | |
| options = { | |
| services.blog-updater = rec { | |
| enable = mkOption { | |
| type = types.bool; | |
| default = false; | |
| description = '' | |
| Whether to run the blog updating service | |
| ''; | |
| }; | |
| virtualHost = mkOption { | |
| type = types.str; | |
| default = "blog.qfpl.io"; | |
| description = '' | |
| The virtual host to serve the blog content from | |
| ''; | |
| }; | |
| hydraJob = mkOption { | |
| type = types.str; | |
| default = "http://hydra.qfpl.io/job/team-blog/blog/blog"; | |
| description = '' | |
| The url to the hydra job for the blog content | |
| ''; | |
| }; | |
| blogProfile = mkOption { | |
| type = types.str; | |
| default = "blog"; | |
| description = '' | |
| The profile to run hail from | |
| ''; | |
| }; | |
| }; | |
| }; | |
| # implementation | |
| config = mkIf cfg.enable { | |
| services.nginx.virtualHosts."${cfg.virtualHost}" = { | |
| forceSSL = true; | |
| enableACME = true; | |
| locations."/".root = "/nix/var/nix/profiles/${cfg.blogProfile}/blog"; | |
| }; | |
| systemd.services.blog-updater = { | |
| description = "Team blog updater"; | |
| after = [ "network.target" ]; | |
| wantedBy = [ "multi-user.target" ]; | |
| path = [ pkgs.nix ]; | |
| environment = { | |
| HOME = "/var/lib/empty"; | |
| }; | |
| stopIfChanged = false; | |
| serviceConfig = { | |
| ExecStart = "${pkgs.haskellPackages.hail}/bin/hail --profile ${cfg.blogProfile} --job-uri ${cfg.hydraJob}"; | |
| }; | |
| }; | |
| }; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment