diff --git a/nix/modules/knot.nix b/nix/modules/knot.nix index 3dd510d5..47970628 100644 --- a/nix/modules/knot.nix +++ b/nix/modules/knot.nix @@ -58,6 +58,28 @@ in }; }; + motd = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + Message of the day + + The contents are shown as-is; eg. you will want to add a newline if + setting a non-empty message since the knot won't do this for you. + ''; + }; + + motdFile = mkOption { + type = types.nullOr types.path; + default = null; + description = '' + File containing message of the day + + The contents are shown as-is; eg. you will want to add a newline if + setting a non-empty message since the knot won't do this for you. + ''; + }; + server = { listenAddr = mkOption { type = types.str; @@ -104,7 +126,15 @@ in cfg.package ]; - system.activationScripts.gitConfig = '' + system.activationScripts.gitConfig = let + setMotd = + if cfg.motdFile != null && cfg.motd != null then + throw "motdFile and motd cannot be both set" + else '' + ${optionalString (cfg.motdFile != null) "cat ${cfg.motdFile} > ${cfg.stateDir}/motd"} + ${optionalString (cfg.motd != null) ''printf "${cfg.motd}" > ${cfg.stateDir}/motd''} + ''; + in '' mkdir -p "${cfg.repo.scanPath}" chown -R ${cfg.gitUser}:${cfg.gitUser} "${cfg.repo.scanPath}" @@ -116,6 +146,7 @@ in [receive] advertisePushOptions = true EOF + ${setMotd} chown -R ${cfg.gitUser}:${cfg.gitUser} "${cfg.stateDir}" ''; diff --git a/nix/vm.nix b/nix/vm.nix index 7cee2c00..2f69fa93 100644 --- a/nix/vm.nix +++ b/nix/vm.nix @@ -48,6 +48,7 @@ nixpkgs.lib.nixosSystem { ]; services.tangled-knot = { enable = true; + motd = "Welcome to the development knot!\n"; server = { secretFile = "/var/lib/knot/secret"; hostname = "localhost:6000";