diff options
author | Brian Picciano <mediocregopher@gmail.com> | 2021-08-08 07:57:45 -0600 |
---|---|---|
committer | Brian Picciano <mediocregopher@gmail.com> | 2021-08-08 08:43:17 -0600 |
commit | 6feffc568ae790a883b9e0509d755e7d9bd82ee1 (patch) | |
tree | f913ce47e9f8204e5cf882f382d10e178e02367f /srv | |
parent | 0197d9cd493b5785bca05f476856540ec64da64a (diff) |
refactor how nix derivations are organized and built
Diffstat (limited to 'srv')
-rw-r--r-- | srv/Makefile | 7 | ||||
-rw-r--r-- | srv/default.nix | 52 |
2 files changed, 35 insertions, 24 deletions
diff --git a/srv/Makefile b/srv/Makefile deleted file mode 100644 index 173bf6a..0000000 --- a/srv/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -build: - nix-build -A build - -shell: - nix-shell -A shell - - diff --git a/srv/default.nix b/srv/default.nix index e4babab..8a12f33 100644 --- a/srv/default.nix +++ b/srv/default.nix @@ -1,20 +1,38 @@ -let - utils = (import ../nix) {}; - pkgs = utils.pkgs; - system = utils.system; -in - { +{pkgs, config, staticBuild}: rec { - build = pkgs.buildGoModule { - pname = "mediocre-blog-srv"; - version = "dev"; - src = ./.; - vendorSha256 = "08wv94yv2wmlxzmanw551gixc8v8nl6zq2m721ig9nl3r540x46f"; - }; + opts = [ + "-pow-secret=${config.powSecret}" + "-ml-smtp-addr=${config.mlSMTPAddr}" + "-ml-smtp-auth='${config.mlSMTPAuth}'" + "-data-dir=${config.dataDir}" + "-public-url=${config.publicURL}" + "-listen-proto=${config.listenProto}" + "-listen-addr=${config.listenAddr}" + ] ++ ( + if config.staticProxyURL == "" + then [ "-static-dir=${staticBuild}" ] + else [ "-static-proxy-url=${config.staticProxyURL}" ] + ); - shell = pkgs.stdenv.mkDerivation { - name = "mediocre-blog-srv-shell"; - buildInputs = [ pkgs.go ]; - }; + build = pkgs.buildGoModule { + pname = "mediocre-blog-srv"; + version = "dev"; + src = ./.; + vendorSha256 = "08wv94yv2wmlxzmanw551gixc8v8nl6zq2m721ig9nl3r540x46f"; + }; - } + bin = pkgs.writeScript "mediocre-blog-srv-bin" '' + #!/bin/sh + exec ${build}/bin/mediocre-blog ${toString opts} + ''; + + runScript = pkgs.writeScriptBin "run-mediocre-blog" '' + go run ./cmd/mediocre-blog/main.go ${toString opts} + ''; + + shell = pkgs.stdenv.mkDerivation { + name = "mediocre-blog-srv-shell"; + buildInputs = [ pkgs.go runScript ]; + }; + +} |