From 4f9c169b34f69c5cda866a4605d05c4bb09196ae Mon Sep 17 00:00:00 2001 From: sefidel Date: Sat, 10 Feb 2024 07:16:59 +0900 Subject: feat(modules): add hydra --- flake.nix | 22 ++++++++++++++++++---- modules/services/hydra.nix | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 modules/services/hydra.nix diff --git a/flake.nix b/flake.nix index 18ca831..ecc05a7 100644 --- a/flake.nix +++ b/flake.nix @@ -23,6 +23,11 @@ sops-nix.url = "github:Mic92/sops-nix"; sops-nix.inputs.nixpkgs.follows = "unstable"; + flake-compat.url = "github:edolstra/flake-compat"; + flake-compat.flake = false; + + hydra.url = "github:NixOS/hydra"; + neovim-nightly.url = "github:nix-community/neovim-nightly-overlay"; neovim-nightly.inputs.nixpkgs.follows = "unstable"; @@ -38,10 +43,10 @@ }; outputs = { self, unstable, ... } @ inputs: - let - lib = unstable.lib.extend - (self: super: { my = import ./lib { inherit inputs; lib = self; }; }); - in + let + lib = unstable.lib.extend + (self: super: { my = import ./lib { inherit inputs; lib = self; }; }); + in { nixosConfigurations = import ./nixos inputs; @@ -50,5 +55,14 @@ colmena = self.lib.mkColmenaFromNixOSConfigurations self.nixosConfigurations; lib = lib.my; + + hydraJobs = lib.mapAttrs' (name: pname: { + name = pname; + value = self.nixosConfigurations.${name}.config.system.build.toplevel; + }) (lib.genAttrs (builtins.attrNames self.nixosConfigurations) (name: "nixos-${name}")); + # // lib.mapAttrs' (name: pname: { + # name = pname; + # value = self.homeConfigurations.${name}.activationPackage; + # }) (lib.genAttrs (builtins.attrNames self.homeConfigurations) (name: "home-${name}")); }; } diff --git a/modules/services/hydra.nix b/modules/services/hydra.nix new file mode 100644 index 0000000..65f602c --- /dev/null +++ b/modules/services/hydra.nix @@ -0,0 +1,38 @@ +{ config, lib, pkgs, hydra, ... }: + +with lib; +let + cfg = config.modules.services.hydra; +in +{ + options.modules.services.hydra = { + enable = mkEnableOption "Whether to enable Hydra, a Nix-based continuous build system"; + baseURL = mkOption { + type = types.str; + example = "https://hydra.kusanari.network"; + description = "The base URL for the Hydra webserver instance"; + }; + }; + + config = mkIf cfg.enable { + services.hydra = { + enable = true; + + package = hydra.packages.x86_64-linux.hydra; + + hydraURL = cfg.baseURL; + dbi = "dbi:Pg:dbname=hydra;user=hydra;"; + useSubstitutes = true; + notificationSender = "hydra@kusanari.network"; + + listenHost = "localhost"; + port = 4004; + }; + + modules.persistence.directories = [ + "/var/lib/hydra" + ]; + + nix.settings.allowed-uris = [ "github:" "https://" "http://" ]; + }; +} -- cgit 1.4.1