From 34a674872fd88bdf299fe6911d828f45c58c7e5d Mon Sep 17 00:00:00 2001 From: emily Date: Mon, 15 Jan 2024 16:57:10 +0100 Subject: [PATCH] added vyosbld options --- flake.nix | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index f3e6707..5ea93f4 100644 --- a/flake.nix +++ b/flake.nix @@ -25,9 +25,70 @@ pname = "kyouma-www"; version = self.shortRev or (toString self.lastModifiedDate); src = ./.; - buildPhase = ''mkdir src/assets/media; ln -s ${packages.vid}/* src/assets/media/''; + buildPhase = ''''; installPhase = ''cp -r src $out''; }; packages.default = packages.kyouma-www; + nixosModules.default = + { config, options, pkgs, ... }: + let + cfg = config.services.vyosBld; + buildFlags = (attrsets.mapAttrsToList (flag: opt: "--" + flag + " " + opt) cfg.buildFlags); + in { + options.services.vyosBld = with lib; { + enable = mkEnableOption "VyOS automatic build"; + + output = mkOption { + type = types.str; + default = null; + description = "Where the iso should be copied to"; + }; + + keep = mkOption { + type = types.number; + default = 5; + description = "Amount of versions to keep"; + }; + + buildFreq = mkOption { + type = types.str; + default = "*-*-* 4:20:00"; + description = "How often a new Image should be build. See {manpage}`systemd.timer(5)`"; + }; + + flavor = mkOption { + type = types.str; + default = "iso"; + description = "See VyOS build docs"; + }; + + buildFlags = mkOption { + type = types.set; + default = ""; + description = "Build Flags see https://docs.vyos.io/en/latest/contributing/build-vyos.html + example: + { build-by = 'mail@server.tld' }"; + }; + }; + config = with lib; mkIf cfg.enable rec { + bldScript = pkgs.copyPathToStore ./vybld.nix; + + systemd.services.vyosBld = { + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + ExecStart = "${pkgs.nix-shell} ${bldScript} -p docker git" + Type = "onshot"; + }; + }; + systemd.timer.vyosBld-time = { + wantedBy = [ "timers.target" ]; + timerConfig = { + Unit = "vyosBld.service"; + OnCalendar = cfg.buildFreq; + }; + }; + }; + }; + ; }); }