Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ccb352c
ignore stack.yaml.lock (stale local change)
robx May 17, 2022
0b2c750
rm travis
robx May 17, 2022
8f5e85b
flake copied over from puzzld
robx May 17, 2022
7131743
Data.Kind (fix warning)
robx May 17, 2022
1ba7598
upper bound on SVGFonts
robx May 17, 2022
885e22c
build with aeson 2.0
robx May 17, 2022
7e35773
working flake build
robx May 17, 2022
accbd08
make `make compare` work in `nix develop`
robx May 17, 2022
1944c80
accept greaterwall dotting rendering change
robx May 18, 2022
5d30361
make gallery.sh nix-compatible
robx May 18, 2022
e9cd41c
try patchShebangs
robx May 18, 2022
8bbd829
elm 0.19.1
robx May 18, 2022
c5fb02d
web: build with nix (via elm2nix)
robx May 18, 2022
c4221ea
inline elm-srcs.nix
robx May 18, 2022
a45babb
cut down default.nix
robx May 18, 2022
31fb24a
move elm nix expressions into nix subdir
robx May 19, 2022
c71d90c
elm build in flake
robx May 19, 2022
e88d7ee
puzzle-draw-serve package
robx May 19, 2022
482edda
restore source filtering to avoid puzzle-draw rebuilds
robx May 19, 2022
ad89511
format nix stuff, and a compiling nixos module
robx May 19, 2022
414e470
try optionally disabling puzzle-draw virtual host
robx May 19, 2022
4b519ad
fix nix module typo
robx May 19, 2022
b27feb5
towards actually testing modules
robx May 19, 2022
bdf0724
always set nginx backend, even without virtual host
robx May 19, 2022
862a6c8
puzzle-draw-serve package as an option
robx May 25, 2022
2f93d84
provide puzzle-draw package for test configuration
robx May 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ tests/examples/cur
tests/examples/diff
web/elm-stuff
static/web.js
stack.yaml.lock
186 changes: 0 additions & 186 deletions .travis.yml

This file was deleted.

3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.PHONY: format test compare ghcid

LOCALINSTALL := $(shell stack $(STACKARGS) path | grep ^local-install-root: | awk '{print $$2}')/bin
DRAW = $(LOCALINSTALL)/drawpuzzle
DRAW ?= $(shell cabal list-bin drawpuzzle)

ghcid:
ghcid
Expand Down
42 changes: 42 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 80 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = {
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
t = pkgs.lib.trivial;
hl = pkgs.haskell.lib;

name = "puzzld";

project = devTools: let
addBuildTools = (t.flip hl.addBuildTools) devTools;
in
pkgs.haskellPackages.developPackage {
root =
pkgs.lib.sourceFilesBySuffices ./.
[".cabal" ".hs" "LICENSE" ".svg" ".pzg" ".pzl" ".png" ".sh" "Makefile"];
name = name;
returnShellEnv = !(devTools == []);
source-overrides = {"SVGFonts" = "1.7.0.1";};
modifier = (t.flip t.pipe) [
addBuildTools
((t.flip hl.addBuildTools) [pkgs.imagemagick])
hl.dontHaddock
hl.enableStaticLibraries
hl.justStaticExecutables
hl.disableLibraryProfiling
hl.disableExecutableProfiling
((t.flip hl.overrideCabal) (drv: {
postCheck = ''
patchShebangs tests/examples/gallery.sh
make compare DRAW=$(pwd)/dist/build/drawpuzzle/drawpuzzle
'';
}))
];
};
in {
packages = rec {
puzzle-draw = project [];
puzzle-draw-web = pkgs.callPackage ./nix/web.nix {};
puzzle-draw-serve = import ./nix/serve.nix {
inherit pkgs system;
inherit puzzle-draw puzzle-draw-web;
src = self;
};
};
defaultPackage = self.packages.${system}.puzzle-draw;

devShell = project [
pkgs.haskellPackages.cabal-fmt
pkgs.haskellPackages.cabal-install
];
})
// rec {
nixosModule = import ./nix/module.nix;
nixosConfigurations.test = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
modules = [
({
config,
pkgs,
...
}: {
boot.isContainer = true;
services.puzzle-draw.enable = true;
services.puzzle-draw.package = self.packages.${system}.puzzle-draw-serve;
})
nixosModule
];
};
};
}
67 changes: 67 additions & 0 deletions nix/module.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
config,
lib,
pkgs,
modulesPath,
...
}:
with lib; let
cfg = config.services.puzzle-draw;
in {
options.services.puzzle-draw = {
enable = mkEnableOption "puzzle-draw server";

package = mkOption {
default = pkgs.puzzle-draw-serve;
defaultText = "pkgs.puzzle-draw-serve";
type = types.package;
description = ''
puzzle-draw-serve package to use.
'';
};

hostName = mkOption {
type = types.nullOr types.str;
default = null;
description = "Hostname to serve puzzle-draw virtual host on (null to disable)";
};

nginx = mkOption {
type =
types.submodule
(import "${modulesPath}/services/web-servers/nginx/vhost-options.nix" {
inherit config lib;
});
default = {};
description = "Extra configuration for the nginx virtual host of puzzle-draw.";
};
};

config = mkIf cfg.enable {
systemd.services.puzzle-draw = {
description = "Run puzzle-draw server";
wantedBy = ["multi-user.target"];
after = ["networking.target"];
serviceConfig = {
WorkingDirectory = "${cfg.package}";
ExecStart = "${cfg.package}/bin/servepuzzle -b 127.0.0.1 -p 8765";
Restart = "always";
};
};
services.nginx = {
upstreams.puzzle-draw-backend.servers."localhost:8765" = {};
virtualHosts = mkIf (cfg.hostName != null) {
"${cfg.hostName}" = mkMerge [
cfg.nginx
{
locations = {
"/" = {
proxyPass = "http://puzzle-draw-backend/";
};
};
}
];
};
};
};
}
Loading