From 1918359fd8e8e3f337590517c0a118bbea6e43ac Mon Sep 17 00:00:00 2001 From: Xe Date: Sat, 26 Mar 2022 17:37:12 +0000 Subject: [PATCH] working module Signed-off-by: Xe --- flake.nix | 19 +++++++++++-------- main.go | 3 +-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/flake.nix b/flake.nix index e70dcea..bb2bf7f 100644 --- a/flake.nix +++ b/flake.nix @@ -66,11 +66,17 @@ }; }; + defaultApp = utils.lib.mkApp { drv = self.packages.${system}.default; }; + + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ go gopls gotools go-tools ]; + }; + }) // { nixosModule = { config, lib, pkgs, ... }: with lib; - let cfg = config.xeserv.services.gohello-http; + let cfg = config.xeserv.services.gohello; in { - options.xeserv.services.gohello-http = { + options.xeserv.services.gohello = { enable = mkEnableOption "Enables the gohello HTTP service"; domain = mkOption rec { @@ -85,7 +91,7 @@ systemd.services."xeserv.gohello" = { wantedBy = [ "multi-user.target" ]; - serviceConfig = let pkg = pkgs.hello; #self.packages.${system}.default; + serviceConfig = let pkg = self.packages.${pkgs.system}.default; in { Restart = "on-failure"; ExecStart = "${pkg}/bin/web-server"; @@ -104,12 +110,7 @@ }; }; }; - defaultApp = utils.lib.mkApp { drv = self.packages.${system}.default; }; - devShells.default = pkgs.mkShell { - buildInputs = with pkgs; [ go gopls gotools go-tools ]; - }; - }) // { nixosConfigurations.container = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ @@ -122,6 +123,8 @@ networking.firewall.allowedTCPPorts = [ 80 ]; services.nginx.enable = true; + + xeserv.services.gohello.enable = true; }) ]; }; diff --git a/main.go b/main.go index 3121b88..d5994d6 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,6 @@ import ( "fmt" "log" "net/http" - "os" ) var ( @@ -16,7 +15,7 @@ func main() { flag.Parse() http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - fmt.Fprintf(w, "PORTABLE=%s\n", os.Getenv("PORTABLE")) + fmt.Fprintln(w, "hello world :)") }) log.Printf("listening for HTTP on %s", *bindhost)