Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
watch_file *.cabal
watch_file \
*.cabal \
nix/modules/flake/haskell.nix \
nix/modules/flake/devshell.nix \
nix/modules/flake/packages.nix
use flake
2 changes: 2 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages:
./ema-template
File renamed without changes.
22 changes: 9 additions & 13 deletions ema-template.cabal → ema-template/ema-template.cabal
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
cabal-version: 2.4
name: ema-template
version: 0.1.0.0
license: AGPL-3.0-only
copyright: 2022 Sridhar Ratnakumar
maintainer: srid@srid.ca
author: Sridhar Ratnakumar
category: Web
cabal-version: 2.4
name: ema-template
version: 0.1.0.0
license: AGPL-3.0-only
copyright: 2022 Sridhar Ratnakumar
maintainer: srid@srid.ca
author: Sridhar Ratnakumar
category: Web

-- A short (one-line) description of the package.
-- synopsis:
Expand All @@ -16,11 +16,7 @@ category: Web
-- A URL where users can report bugs.
-- bug-reports:

extra-source-files:
LICENSE
README.md

data-dir: static
data-dir: static
data-files:
*.css
*.svg
Expand Down
File renamed without changes.
File renamed without changes
16 changes: 8 additions & 8 deletions static/tailwind.css → ema-template/static/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
}

/*
! tailwindcss v3.4.12 | MIT License | https://tailwindcss.com
! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com
*/

/*
Expand Down Expand Up @@ -550,7 +550,7 @@ video {

/* Make elements with the HTML hidden attribute stay hidden by default */

[hidden] {
[hidden]:where(:not([hidden="until-found"])) {
display: none;
}

Expand Down Expand Up @@ -836,17 +836,17 @@ select {

.bg-gray-50 {
--tw-bg-opacity: 1;
background-color: rgb(249 250 251 / var(--tw-bg-opacity));
background-color: rgb(249 250 251 / var(--tw-bg-opacity, 1));
}

.bg-rose-400 {
--tw-bg-opacity: 1;
background-color: rgb(251 113 133 / var(--tw-bg-opacity));
background-color: rgb(251 113 133 / var(--tw-bg-opacity, 1));
}

.bg-white {
--tw-bg-opacity: 1;
background-color: rgb(255 255 255 / var(--tw-bg-opacity));
background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
}

.p-2 {
Expand Down Expand Up @@ -878,17 +878,17 @@ select {

.text-gray-700 {
--tw-text-opacity: 1;
color: rgb(55 65 81 / var(--tw-text-opacity));
color: rgb(55 65 81 / var(--tw-text-opacity, 1));
}

.text-rose-400 {
--tw-text-opacity: 1;
color: rgb(251 113 133 / var(--tw-text-opacity));
color: rgb(251 113 133 / var(--tw-text-opacity, 1));
}

.text-white {
--tw-text-opacity: 1;
color: rgb(255 255 255 / var(--tw-text-opacity));
color: rgb(255 255 255 / var(--tw-text-opacity, 1));
}

.shadow {
Expand Down
34 changes: 17 additions & 17 deletions flake.lock

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

101 changes: 7 additions & 94 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
description = "Ema template app";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
systems.url = "github:nix-systems/default";
flake-parts.url = "github:hercules-ci/flake-parts";
nixos-unified.url = "github:srid/nixos-unified";
haskell-flake.url = "github:srid/haskell-flake";

process-compose-flake.url = "github:Platonic-Systems/process-compose-flake";
Expand All @@ -15,97 +15,10 @@
ema.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = import inputs.systems;
imports = [
inputs.haskell-flake.flakeModule
inputs.process-compose-flake.flakeModule
inputs.fourmolu-nix.flakeModule
(inputs.git-hooks + /flake-module.nix)
];
perSystem = { config, pkgs, lib, ... }:
let
tailwind = pkgs.haskellPackages.tailwind;
in
{
# "haskellProjects" comes from https://github.com/srid/haskell-flake
haskellProjects.default = {
imports = [
inputs.ema.haskellFlakeProjectModules.output
];
autoWire = [ "packages" "apps" "checks" ];
};

pre-commit.settings = {
hooks = {
nixpkgs-fmt.enable = true;
cabal-fmt.enable = true;
fourmolu = {
enable = true;
package = config.fourmolu.wrapper;
};
hlint.enable = true;
};
};

fourmolu.settings = {
indentation = 2;
comma-style = "leading";
record-brace-space = true;
indent-wheres = true;
import-export-style = "diff-friendly";
respectful = true;
haddock-style = "multi-line";
newlines-between-decls = 1;
extensions = [ "ImportQualifiedPost" ];
};

process-compose."ema-tailwind-run" = {
cli.environment.PC_DISABLE_TUI = true;
settings = {
processes = {
haskell.command = "ghcid";
tailwind = {
command = "${lib.getExe tailwind} -w -o ./static/tailwind.css './src/**/*.hs'";
is_tty = true;
};
};
};
};

packages =
let
buildEmaSiteWithTailwind = { baseUrl }:
pkgs.runCommand "site"
{ }
''
mkdir -p $out
pushd ${inputs.self}
${lib.getExe config.packages.ema-template} \
--base-url=${baseUrl} gen $out
${lib.getExe tailwind} \
-o $out/tailwind.css 'src/**/*.hs'
'';
in
{
default = config.packages.ema-template;
site = buildEmaSiteWithTailwind { baseUrl = "/"; };
site-github = buildEmaSiteWithTailwind { baseUrl = "/ema-template/"; };
};

devShells.default = pkgs.mkShell {
name = "ema-template";
meta.description = "ema-template development environment";
packages = [
tailwind
pkgs.just
pkgs.nixd
];
inputsFrom = [
config.haskellProjects.default.outputs.devShell
config.pre-commit.devShell
];
};
};
};
# This will import ./nix/modules/flake/*.nix
# cf. https://nixos-unified.org/autowiring.html#flake-parts
#
# To write your own Nix, add or edit files in ./nix/modules/flake/
inputs.nixos-unified.lib.mkFlake
{ inherit inputs; root = ./.; };
}
21 changes: 21 additions & 0 deletions nix/modules/flake/devshell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
perSystem = { config, pkgs, lib, ... }:
let
tailwind = pkgs.haskellPackages.tailwind;
in
{
devShells.default = pkgs.mkShell {
name = "ema-template";
meta.description = "ema-template development environment";
packages = [
tailwind
pkgs.just
pkgs.nixd
];
inputsFrom = [
config.haskellProjects.default.outputs.devShell
config.pre-commit.devShell
];
};
};
}
24 changes: 24 additions & 0 deletions nix/modules/flake/haskell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{ root, inputs, ... }:
{
imports = [
inputs.haskell-flake.flakeModule
];
perSystem = { lib, config, ... }: {
haskellProjects.default = {
imports = [
inputs.ema.haskellFlakeProjectModules.output
];
projectRoot = builtins.toString (lib.fileset.toSource {
root = root;
fileset = lib.fileset.unions [
(root + /ema-template)
(root + /cabal.project)
(root + /LICENSE)
];
});
autoWire = [ "packages" "apps" "checks" ];
};

packages.default = config.packages.ema-template;
};
}
40 changes: 40 additions & 0 deletions nix/modules/flake/packages.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{ inputs, ... }:
{
imports = [
inputs.process-compose-flake.flakeModule
];
perSystem = { config, pkgs, lib, ... }:
let
tailwind = pkgs.haskellPackages.tailwind;
buildEmaSiteWithTailwind = { baseUrl }:
pkgs.runCommand "site"
{ }
''
mkdir -p $out
pushd ${inputs.self}/ema-template
${lib.getExe config.packages.ema-template} \
--base-url=${baseUrl} gen $out
${lib.getExe tailwind} \
-o $out/tailwind.css 'src/**/*.hs'
'';
in
{
process-compose."ema-tailwind-run" = {
cli.environment.PC_DISABLE_TUI = true;
settings = {
processes = {
haskell.command = "cd ./ema-template && ghcid";
tailwind = {
command = "cd ./ema-template && ${lib.getExe tailwind} -w -o ./static/tailwind.css './src/**/*.hs'";
is_tty = true;
};
};
};
};

packages = {
site = buildEmaSiteWithTailwind { baseUrl = "/"; };
site-github = buildEmaSiteWithTailwind { baseUrl = "/ema-template/"; };
};
};
}
32 changes: 32 additions & 0 deletions nix/modules/flake/pre-commit.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{ inputs, ... }:
{
imports = [
inputs.fourmolu-nix.flakeModule
(inputs.git-hooks + /flake-module.nix)
];
perSystem = { config, ... }: {
pre-commit.settings = {
hooks = {
nixpkgs-fmt.enable = true;
cabal-fmt.enable = true;
fourmolu = {
enable = true;
package = config.fourmolu.wrapper;
};
hlint.enable = true;
};
};

fourmolu.settings = {
indentation = 2;
comma-style = "leading";
record-brace-space = true;
indent-wheres = true;
import-export-style = "diff-friendly";
respectful = true;
haddock-style = "multi-line";
newlines-between-decls = 1;
extensions = [ "ImportQualifiedPost" ];
};
};
}