diff --git a/.envrc b/.envrc index 704ceb8..5e5c298 100644 --- a/.envrc +++ b/.envrc @@ -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 \ No newline at end of file diff --git a/cabal.project b/cabal.project new file mode 100644 index 0000000..9ca32d1 --- /dev/null +++ b/cabal.project @@ -0,0 +1,2 @@ +packages: + ./ema-template diff --git a/.ghcid b/ema-template/.ghcid similarity index 100% rename from .ghcid rename to ema-template/.ghcid diff --git a/ema-template.cabal b/ema-template/ema-template.cabal similarity index 85% rename from ema-template.cabal rename to ema-template/ema-template.cabal index e8e397d..bb2a090 100644 --- a/ema-template.cabal +++ b/ema-template/ema-template.cabal @@ -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: @@ -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 diff --git a/src/Main.hs b/ema-template/src/Main.hs similarity index 100% rename from src/Main.hs rename to ema-template/src/Main.hs diff --git a/static/logo.svg b/ema-template/static/logo.svg similarity index 100% rename from static/logo.svg rename to ema-template/static/logo.svg diff --git a/static/tailwind.css b/ema-template/static/tailwind.css similarity index 97% rename from static/tailwind.css rename to ema-template/static/tailwind.css index e6b6bd1..1e7bda1 100644 --- a/static/tailwind.css +++ b/ema-template/static/tailwind.css @@ -107,7 +107,7 @@ } /* -! tailwindcss v3.4.12 | MIT License | https://tailwindcss.com +! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com */ /* @@ -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; } @@ -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 { @@ -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 { diff --git a/flake.lock b/flake.lock index 72452ce..a52ed3e 100644 --- a/flake.lock +++ b/flake.lock @@ -366,6 +366,21 @@ "type": "github" } }, + "nixos-unified_2": { + "locked": { + "lastModified": 1753730363, + "narHash": "sha256-IB+0W+n6cMnYwYjFGsJi7TIJA26pSaFhgzwmnmB9Pdc=", + "owner": "srid", + "repo": "nixos-unified", + "rev": "e91aecaaa310065b067b946774660febc7f212a2", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "nixos-unified", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1752900028, @@ -450,24 +465,9 @@ "fourmolu-nix": "fourmolu-nix_2", "git-hooks": "git-hooks_2", "haskell-flake": "haskell-flake_3", + "nixos-unified": "nixos-unified_2", "nixpkgs": "nixpkgs_2", - "process-compose-flake": "process-compose-flake", - "systems": "systems" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" + "process-compose-flake": "process-compose-flake" } }, "treefmt-nix": { diff --git a/flake.nix b/flake.nix index 43b0cad..2806915 100644 --- a/flake.nix +++ b/flake.nix @@ -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"; @@ -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 = ./.; }; } diff --git a/nix/modules/flake/devshell.nix b/nix/modules/flake/devshell.nix new file mode 100644 index 0000000..167208d --- /dev/null +++ b/nix/modules/flake/devshell.nix @@ -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 + ]; + }; + }; +} diff --git a/nix/modules/flake/haskell.nix b/nix/modules/flake/haskell.nix new file mode 100644 index 0000000..c081a6b --- /dev/null +++ b/nix/modules/flake/haskell.nix @@ -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; + }; +} diff --git a/nix/modules/flake/packages.nix b/nix/modules/flake/packages.nix new file mode 100644 index 0000000..bf0fb05 --- /dev/null +++ b/nix/modules/flake/packages.nix @@ -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/"; }; + }; + }; +} diff --git a/nix/modules/flake/pre-commit.nix b/nix/modules/flake/pre-commit.nix new file mode 100644 index 0000000..7e2c7ec --- /dev/null +++ b/nix/modules/flake/pre-commit.nix @@ -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" ]; + }; + }; +}