kompact-io-landing/flake.nix

140 lines
4.6 KiB
Nix

{
description = "Description for the project";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
devshell.url = "github:numtide/devshell";
treefmt-nix.url = "github:numtide/treefmt-nix";
haskell-flake.url = "github:srid/haskell-flake";
flake-root.url = "github:srid/flake-root";
};
outputs = inputs @ { flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
# To import a flake module
# 1. Add foo to inputs
# 2. Add foo as a parameter to the outputs function
# 3. Add here: foo.flakeModule
inputs.devshell.flakeModule
inputs.treefmt-nix.flakeModule
inputs.haskell-flake.flakeModule
inputs.flake-root.flakeModule
];
systems = [ "x86_64-linux" "aarch64-darwin" ];
perSystem =
{ config
, self'
, inputs'
, pkgs
, system
, ...
}: {
# Per-system attributes can be defined here. The self' and inputs'
# module parameters provide easy access to attributes of the same
# system.
haskellProjects.default = {
devShell = {
tools = hp:
{
fourmolu = hp.fourmolu;
hoogle = hp.hoogle;
haskell-language-server = hp.haskell-language-server;
treefmt = config.treefmt.build.wrapper;
}
// config.treefmt.build.programs;
hlsCheck.enable = false;
};
autoWire = [ "packages" "apps" "checks" ]; # Wire all but the devShell
};
packages.default = self'.packages.kompact-site;
treefmt.config = {
inherit (config.flake-root) projectRootFile;
package = pkgs.treefmt;
flakeFormatter = false; # For https://github.com/numtide/treefmt-nix/issues/55
programs.ormolu.enable = true;
programs.nixpkgs-fmt.enable = true;
programs.cabal-fmt.enable = true;
programs.hlint.enable = true;
programs.alejandra.enable = true;
# We use fourmolu
programs.ormolu.package = pkgs.haskellPackages.fourmolu;
settings.formatter.ormolu = {
options = [
"--ghc-opt"
"-XImportQualifiedPost"
];
};
programs.prettier = {
enable = true;
settings = {
printWidth = 80;
proseWrap = "always";
};
};
};
# Equivalent to inputs'.nixpkgs.legacyPackages.hello;
devShells.default =
let
menu =
pkgs.writeShellScriptBin "menu"
''
echo -e "\nCommands available: \n${
builtins.foldl' (x: y: x + " -> " + (pkgs.lib.getName y) + "\n") "" my-packages
}"
'';
my-packages = [
menu
build
watch
tailwind
deploy
];
tailwind = pkgs.writeShellScriptBin "tailwind" ''
tailwindcss -i ./content/css/main.css -o ./assets/css/mini.css --minify
'';
build = pkgs.writeShellScriptBin "build" ''
${tailwind}/bin/tailwind
cabal run site -- build
'';
watch = pkgs.writeShellScriptBin "watch" ''
${tailwind}/bin/tailwind
cabal run site -- watch
'';
deploy = pkgs.writeShellScriptBin "deploy" ''
rsync -r --delete ./docs/* genesis:/var/www/kompactio-landing/
'';
in
pkgs.mkShell {
inputsFrom = [
config.haskellProjects.default.outputs.devShell
config.flake-root.devShell
];
packages = with pkgs;
[
caddy
nil
nodePackages_latest.vscode-langservers-extracted
nodePackages_latest.tailwindcss
nodePackages_latest.typescript-language-server
haskellPackages.hakyll
zlib
]
++ my-packages;
};
};
flake = {
# The usual flake attributes can be defined here, including system-
# agnostic ones like nixosModule and system-enumerating ones, although
# those are more easily expressed in perSystem.
};
};
}