diff --git a/modules/default.nix b/modules/default.nix new file mode 100644 index 0000000..06e1ccc --- /dev/null +++ b/modules/default.nix @@ -0,0 +1,5 @@ +{ + imports = [ + ./hello.nix + ]; +} diff --git a/modules/hello.nix b/modules/hello.nix new file mode 100644 index 0000000..ed09a0a --- /dev/null +++ b/modules/hello.nix @@ -0,0 +1,23 @@ +{ lib, pkgs, config, ...}: + +with lib; +let + cfg = config.services.hello; + +in { + options.services.hello = { + enable = mkEnableOption "Hello service."; + greeter = mkOption { + type = types.str; + default = "world"; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = [ + (pkgs.writeShellScriptBin "hello" '' + echo "'Hello, ${escapeShellArg cfg.greeter}!'" + ''); + ]; + }; +}