Skip to content
Closed
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
2 changes: 2 additions & 0 deletions .copier-answers.yml.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
{{ _copier_answers|to_nice_yaml -}}
35 changes: 28 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,40 @@ on:
- master
pull_request:
jobs:
build:
template-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: nixbuild/nix-quick-install-action@v33
- name: Install omnix
run: |
nix --accept-flake-config profile install "github:juspay/omnix"
nix --version
- name: Build all flake outputs
run: om ci

- name: Install copier
run: nix profile install nixpkgs#copier

- name: Test template initialization with copier
run: |
# Initialize template with sample variables
copier copy --defaults \
--data author="Test Author" \
--data package_name="test-project" \
--data vscode=false \
--data github_ci=false \
. ../test-project

cd ../test-project

# Verify templating worked
grep "Test Author" LICENSE
grep "test-project" test-project.cabal
test -f test-project.cabal # Verify cabal file has templated name

# Build the project
nix build

# Run the executable
./result/bin/test-project

- name: What GHC version?
run: nix develop -c ghc --version
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,12 @@ result-*
.direnv

/.pre-commit-config.yaml

# LLM
/.claude/settings.local.json

# Template working files (originals are in .jinja files)
LICENSE
haskell-template.cabal
src/Main.hs
nix/modules/flake/haskell.nix
2 changes: 1 addition & 1 deletion LICENSE → LICENSE.jinja
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Sridhar Ratnakumar
Copyright (c) {{ '%Y' | strftime }} {{ author }}

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ If you have an *existing* Haskell project, you should probably use https://githu
Initialize this template using:

```sh
nix run nixpkgs#omnix -- \
init github:srid/haskell-template -o ./yourproject
nix run nixpkgs#copier -- copy gh:srid/haskell-template ./yourproject
```

*tldr: [Install Nix](https://nixos.asia/en/install), [setup direnv](https://nixos.asia/en/direnv), open in VSCode, install recommended extensions and run `just run`.*
Expand Down
42 changes: 42 additions & 0 deletions copier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copier template configuration for haskell-template
# https://copier.readthedocs.io/

_min_copier_version: "9.0.0"

# Answers file location
_answers_file: .copier-answers.yml

# Template questions
author:
type: str
help: Author name
default: Sridhar Ratnakumar
placeholder: "{{ author }}"

package_name:
type: str
help: Name of the Haskell package
default: haskell-template
placeholder: "{{ package_name }}"

vscode:
type: bool
help: Include the VSCode settings folder (./.vscode)?
default: true

github_ci:
type: bool
help: Include GitHub Actions workflow configuration (./.github)?
default: true

# Exclude patterns based on user choices
_exclude:
- "{% if not vscode %}.vscode{% endif %}"
- "{% if not github_ci %}.github{% endif %}"
- .git
- .copier-answers.yml
- "*.pyc"
- __pycache__

# Use .jinja suffix for templates
_templates_suffix: .jinja
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
inherit root;
fileset = lib.fileset.unions [
(root + /src)
(root + /haskell-template.cabal)
(root + /{{ package_name }}.cabal)
(root + /LICENSE)
(root + /README.md)
];
Expand All @@ -37,7 +37,7 @@

# Add your package overrides here
settings = {
haskell-template = {
{{ package_name }} = {
stan = true;
# haddock = false;
};
Expand All @@ -53,7 +53,7 @@
};

# Default package & app.
packages.default = self'.packages.haskell-template;
apps.default = self'.apps.haskell-template;
packages.default = self'.packages.{{ package_name }};
apps.default = self'.apps.{{ package_name }};
};
}
66 changes: 0 additions & 66 deletions nix/modules/flake/template.nix

This file was deleted.

2 changes: 1 addition & 1 deletion src/Main.hs → src/Main.hs.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ main :: IO ()
main = do
-- For withUtf8, see https://serokell.io/blog/haskell-with-utf8
Utf8.withUtf8 $ do
putTextLn "Hello 🌎 (from haskell-template)"
putTextLn "Hello 🌎 (from {{ package_name }})"
10 changes: 5 additions & 5 deletions haskell-template.cabal → {{ package_name }}.cabal.jinja
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
cabal-version: 2.4
name: haskell-template
name: {{ package_name }}
version: 0.1.0.0
license: MIT
copyright: 2022 Sridhar Ratnakumar
copyright: {{ '%Y' | strftime }} {{ author }}
maintainer: srid@srid.ca
author: Sridhar Ratnakumar
author: {{ author }}
category: Web
homepage: https://srid.ca/haskell-template
homepage: https://github.com/srid/haskell-template

-- TODO: Before hackage release.
-- A short (one-line) description of the package.
Expand Down Expand Up @@ -63,6 +63,6 @@ common shared
hs-source-dirs: src
default-language: GHC2021

executable haskell-template
executable {{ package_name }}
import: shared
main-is: Main.hs
Loading