flake: add treefmt, reorganize flake, format using treefmt
This commit is contained in:
parent
967b613d91
commit
12aa7125b5
17 changed files with 187 additions and 123 deletions
8
.github/workflows/main.yml
vendored
8
.github/workflows/main.yml
vendored
|
|
@ -32,17 +32,13 @@ jobs:
|
||||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||||
- uses: DeterminateSystems/flake-checker-action@main
|
- uses: DeterminateSystems/flake-checker-action@main
|
||||||
- name: Build with Hugo
|
- name: Build with Hugo
|
||||||
run: |
|
run: nix run .
|
||||||
nix develop --command bash -c "hugo \
|
|
||||||
--environment production \
|
|
||||||
--minify \
|
|
||||||
--baseURL '${{ steps.pages.outputs.base_url }}/'"
|
|
||||||
- name: Upload to GitHub Pages
|
- name: Upload to GitHub Pages
|
||||||
uses: actions/upload-pages-artifact@main
|
uses: actions/upload-pages-artifact@main
|
||||||
with:
|
with:
|
||||||
path: ./public
|
path: ./public
|
||||||
- name: Upload to Netim FTP
|
- name: Upload to Netim FTP
|
||||||
uses: SamKirkland/FTP-Deploy-Action@main
|
uses: SamKirkland/FTP-Deploy-Action@master
|
||||||
with:
|
with:
|
||||||
server: ftp.netim.hosting
|
server: ftp.netim.hosting
|
||||||
username: AS12798_FTP1
|
username: AS12798_FTP1
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
title: {{ replace .Name "-" " " | title }}
|
title: { { replace .Name "-" " " | title } }
|
||||||
date: {{ .Date }}
|
date: { { .Date } }
|
||||||
description:
|
description:
|
||||||
tags:
|
tags:
|
||||||
draft: true
|
draft: true
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
title: {{ replace .Name "-" " " | title }}
|
title: { { replace .Name "-" " " | title } }
|
||||||
date: {{ .Date }}
|
date: { { .Date } }
|
||||||
draft: true
|
draft: true
|
||||||
---
|
---
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
title: {{ replace .Name "-" " " | title }}
|
title: { { replace .Name "-" " " | title } }
|
||||||
date: {{ .Date }}
|
date: { { .Date } }
|
||||||
tags:
|
tags:
|
||||||
- micro
|
- micro
|
||||||
draft: true
|
draft: true
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
title: {{ replace .Name "-" " " | title }}
|
title: { { replace .Name "-" " " | title } }
|
||||||
date: {{ .Date }}
|
date: { { .Date } }
|
||||||
description:
|
description:
|
||||||
feature:
|
feature:
|
||||||
tags:
|
tags:
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,9 @@ code {
|
||||||
body {
|
body {
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
background: var(--background);
|
background: var(--background);
|
||||||
font-family: "EB Garamond", Constantia, "Lucida Bright", Lucidabright, "Lucida Serif", Lucida, "DejaVu Serif", "Bitstream Vera Serif", "Liberation Serif", Athelas, Georgia, serif;
|
font-family: "EB Garamond", Constantia, "Lucida Bright", Lucidabright,
|
||||||
|
"Lucida Serif", Lucida, "DejaVu Serif", "Bitstream Vera Serif",
|
||||||
|
"Liberation Serif", Athelas, Georgia, serif;
|
||||||
/* font-family: -apple-system, BlinkMacSystemFont, "Avenir Next", Avenir, "Nimbus Sans L", Roboto, Noto, "Segoe UI", Arial, Helvetica, "Helvetica Neue", sans-serif; */
|
/* font-family: -apple-system, BlinkMacSystemFont, "Avenir Next", Avenir, "Nimbus Sans L", Roboto, Noto, "Segoe UI", Arial, Helvetica, "Helvetica Neue", sans-serif; */
|
||||||
font-variant-numeric: oldstyle-nums;
|
font-variant-numeric: oldstyle-nums;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
|
|
@ -54,9 +56,7 @@ header {
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
|
|
||||||
& nav {
|
& nav {
|
||||||
|
|
||||||
& ul {
|
& ul {
|
||||||
|
|
||||||
font-size: 1.25rem;
|
font-size: 1.25rem;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
@ -66,7 +66,6 @@ header {
|
||||||
.active {
|
.active {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -78,7 +77,7 @@ p {
|
||||||
text-justify: inter-word;
|
text-justify: inter-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
article>p:nth-of-type(2)::first-letter {
|
article > p:nth-of-type(2)::first-letter {
|
||||||
font-size: 3rem;
|
font-size: 3rem;
|
||||||
float: left;
|
float: left;
|
||||||
line-height: 2.9rem;
|
line-height: 2.9rem;
|
||||||
|
|
@ -166,7 +165,6 @@ footer {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tags {
|
.tags {
|
||||||
|
|
|
||||||
52
flake.lock
generated
52
flake.lock
generated
|
|
@ -16,9 +16,59 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"nixpkgs_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1719690277,
|
||||||
|
"narHash": "sha256-0xSej1g7eP2kaUF+JQp8jdyNmpmCJKRpO12mKl/36Kc=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "2741b4b489b55df32afac57bc4bfd220e8bf617e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs",
|
||||||
|
"systems": "systems",
|
||||||
|
"treefmt": "treefmt"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "systems",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"treefmt": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs_2"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1719887753,
|
||||||
|
"narHash": "sha256-p0B2r98UtZzRDM5miGRafL4h7TwGRC4DII+XXHDHqek=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"rev": "bdb6355009562d8f9313d9460c0d3860f525bc6c",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "treefmt-nix",
|
||||||
|
"type": "github"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
78
flake.nix
78
flake.nix
|
|
@ -1,36 +1,64 @@
|
||||||
{
|
{
|
||||||
description = "Hugo website";
|
description = "Hugo website";
|
||||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||||
|
inputs.treefmt.url = "github:numtide/treefmt-nix";
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
{ nixpkgs, ... }:
|
{
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
systems,
|
||||||
|
treefmt,
|
||||||
|
...
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
systems = [
|
eachSystem = f: nixpkgs.lib.genAttrs (import systems) (system: f nixpkgs.legacyPackages.${system});
|
||||||
"x86_64-linux"
|
|
||||||
"x86_64-darwin"
|
|
||||||
];
|
|
||||||
forAllSystems = f: nixpkgs.lib.genAttrs (systems) f;
|
|
||||||
|
|
||||||
devShell =
|
treefmtEval = eachSystem (pkgs: treefmt.lib.evalModule pkgs ./treefmt.nix);
|
||||||
system:
|
|
||||||
let
|
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
default =
|
|
||||||
with pkgs;
|
|
||||||
mkShell {
|
|
||||||
name = "Hugo website";
|
|
||||||
packages = with pkgs; [
|
|
||||||
go
|
|
||||||
hugo
|
|
||||||
nodePackages.prettier
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
devShells = forAllSystems devShell;
|
devShells = eachSystem (pkgs: {
|
||||||
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style);
|
default = pkgs.mkShell {
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
go
|
||||||
|
hugo
|
||||||
|
];
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
formatter = eachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper);
|
||||||
|
|
||||||
|
checks = eachSystem (pkgs: {
|
||||||
|
formatting = treefmtEval.${pkgs.system}.config.build.check self;
|
||||||
|
});
|
||||||
|
|
||||||
|
apps = eachSystem (pkgs: {
|
||||||
|
default = {
|
||||||
|
type = "app";
|
||||||
|
program =
|
||||||
|
(pkgs.writeShellScript "build-website" ''
|
||||||
|
set -e
|
||||||
|
${pkgs.hugo}/bin/hugo --minify
|
||||||
|
'').outPath;
|
||||||
|
};
|
||||||
|
|
||||||
|
test = {
|
||||||
|
type = "app";
|
||||||
|
program =
|
||||||
|
(pkgs.writeShellScript "test-website" ''
|
||||||
|
set -e
|
||||||
|
${pkgs.hugo}/bin/hugo --environment="development"
|
||||||
|
'').outPath;
|
||||||
|
};
|
||||||
|
|
||||||
|
server = {
|
||||||
|
type = "app";
|
||||||
|
program =
|
||||||
|
(pkgs.writeShellScript "serve-website" ''
|
||||||
|
set -e
|
||||||
|
${pkgs.hugo}/bin/hugo server
|
||||||
|
'').outPath;
|
||||||
|
};
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,15 @@
|
||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html lang="{{ or site.Language.LanguageCode site.Language.Lang }}"
|
<html
|
||||||
dir="{{ or site.Language.LanguageDirection `ltr` }}">
|
lang="{{ or site.Language.LanguageCode site.Language.Lang }}"
|
||||||
|
dir="{{ or site.Language.LanguageDirection `ltr` }}"
|
||||||
<head>
|
>
|
||||||
{{ partial "head.html" . }}
|
<head>
|
||||||
</head>
|
{{ partial "head.html" . }}
|
||||||
|
</head>
|
||||||
<body>
|
|
||||||
<header>
|
|
||||||
{{ partial "header.html" . }}
|
|
||||||
</header>
|
|
||||||
<main>
|
|
||||||
{{ block "main" . }}{{ end }}
|
|
||||||
</main>
|
|
||||||
<footer>
|
|
||||||
{{ partial "footer.html" . }}
|
|
||||||
</footer>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<header>{{ partial "header.html" . }}</header>
|
||||||
|
<main>{{ block "main" . }}{{ end }}</main>
|
||||||
|
<footer>{{ partial "footer.html" . }}</footer>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,9 @@
|
||||||
{{ define "main" }}
|
{{ define "main" }} {{ .Content }} {{ $pages := .Paginate (where
|
||||||
{{ .Content }}
|
.Site.RegularPages "Type" "ne" "page") }} {{ range $pages.Pages }}
|
||||||
{{ $pages := .Paginate (where .Site.RegularPages "Type" "ne" "page") }}
|
<a href="{{ .RelPermalink }}" style="display: block">
|
||||||
{{ range $pages.Pages }}
|
|
||||||
<a href="{{ .RelPermalink }}" style="display:block">
|
|
||||||
<div class="list">
|
<div class="list">
|
||||||
{{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05-07:00" }}
|
{{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05-07:00" }} {{
|
||||||
{{ $dateHuman := .Date | time.Format "2006-01-02" }}
|
$dateHuman := .Date | time.Format "2006-01-02" }}
|
||||||
<time datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>
|
<time datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>
|
||||||
|
|
||||||
<h2>{{ .Title }}</h2>
|
<h2>{{ .Title }}</h2>
|
||||||
|
|
@ -13,5 +11,4 @@
|
||||||
<p class="lead">{{ .Description }}</p>
|
<p class="lead">{{ .Description }}</p>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
{{ end }}
|
{{ end }} {{ end }}
|
||||||
{{ end }}
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
{{ define "main" }}
|
{{ define "main" }} {{ .Content }} {{ range .Pages }}
|
||||||
{{ .Content }}
|
<a href="{{ .RelPermalink }}" style="display: block">
|
||||||
{{ range .Pages }}
|
|
||||||
<a href="{{ .RelPermalink }}" style="display:block">
|
|
||||||
<div class="list">
|
<div class="list">
|
||||||
{{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05-07:00" }}
|
{{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05-07:00" }} {{
|
||||||
{{ $dateHuman := .Date | time.Format "2006-01-02" }}
|
$dateHuman := .Date | time.Format "2006-01-02" }}
|
||||||
<time datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>
|
<time datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>
|
||||||
|
|
||||||
<h2>{{ .Title }}</h2>
|
<h2>{{ .Title }}</h2>
|
||||||
|
|
@ -12,5 +10,4 @@
|
||||||
<p class="lead">{{ .Description }}</p>
|
<p class="lead">{{ .Description }}</p>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
{{ end }}
|
{{ end }} {{ end }}
|
||||||
{{ end }}
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
{{ define "main" }}
|
{{ define "main" }}
|
||||||
<article>
|
<article>
|
||||||
{{ $dateMachine := .Lastmod | time.Format "2006-01-02T15:04:05-07:00" }}
|
{{ $dateMachine := .Lastmod | time.Format "2006-01-02T15:04:05-07:00" }} {{
|
||||||
{{ $dateHuman := .Lastmod | time.Format "2006-01-02" }}
|
$dateHuman := .Lastmod | time.Format "2006-01-02" }}
|
||||||
<time datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>
|
<time datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>
|
||||||
<br>
|
<br />
|
||||||
|
|
||||||
<h1>{{ .Title }}</h1>
|
<h1>{{ .Title }}</h1>
|
||||||
|
|
||||||
|
|
@ -11,5 +11,4 @@
|
||||||
|
|
||||||
{{ .Content }}
|
{{ .Content }}
|
||||||
</article>
|
</article>
|
||||||
{{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }}
|
{{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }} {{ end }}
|
||||||
{{ end }}
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
{{ if hugo.IsProduction }}
|
{{ if hugo.IsProduction }}
|
||||||
<script data-goatcounter="https://jankremer.goatcounter.com/count" async src="//gc.zgo.at/count.js"></script>
|
<script
|
||||||
|
data-goatcounter="https://jankremer.goatcounter.com/count"
|
||||||
|
async
|
||||||
|
src="//gc.zgo.at/count.js"
|
||||||
|
></script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
{{- with resources.Get "css/main.css" }}
|
{{- with resources.Get "css/main.css" }} {{- if eq hugo.Environment
|
||||||
{{- if eq hugo.Environment "development" }}
|
"development" }}
|
||||||
<link rel="stylesheet" href="{{ .RelPermalink }}">
|
<link rel="stylesheet" href="{{ .RelPermalink }}" />
|
||||||
{{- else }}
|
{{- else }} {{- with . | minify | fingerprint }}
|
||||||
{{- with . | minify | fingerprint }}
|
<link
|
||||||
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
|
rel="stylesheet"
|
||||||
{{- end }}
|
href="{{ .RelPermalink }}"
|
||||||
{{- end }}
|
integrity="{{ .Data.Integrity }}"
|
||||||
{{- end }}
|
crossorigin="anonymous"
|
||||||
|
/>
|
||||||
|
{{- end }} {{- end }} {{- end }}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
{{- with resources.Get "js/main.js" }}
|
{{- with resources.Get "js/main.js" }} {{- if eq hugo.Environment "development"
|
||||||
{{- if eq hugo.Environment "development" }}
|
}} {{- with . | js.Build }}
|
||||||
{{- with . | js.Build }}
|
<script src="{{ .RelPermalink }}"></script>
|
||||||
<script src="{{ .RelPermalink }}"></script>
|
{{- end }} {{- else }} {{- $opts := dict "minify" true }} {{- with . | js.Build
|
||||||
{{- end }}
|
$opts | fingerprint }}
|
||||||
{{- else }}
|
<script
|
||||||
{{- $opts := dict "minify" true }}
|
src="{{ .RelPermalink }}"
|
||||||
{{- with . | js.Build $opts | fingerprint }}
|
integrity="{{- .Data.Integrity }}"
|
||||||
<script src="{{ .RelPermalink }}" integrity="{{- .Data.Integrity }}" crossorigin="anonymous"></script>
|
crossorigin="anonymous"
|
||||||
{{- end }}
|
></script>
|
||||||
{{- end }}
|
{{- end }} {{- end }} {{- end }}
|
||||||
{{- end }}
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,8 @@
|
||||||
{{- /*
|
{{- /* For a given taxonomy, renders a list of terms assigned to the page.
|
||||||
For a given taxonomy, renders a list of terms assigned to the page.
|
@context {page} page The current page. @context {string} taxonomy The taxonony.
|
||||||
|
@example: {{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }} */}} {{-
|
||||||
@context {page} page The current page.
|
$page := .page }} {{- $taxonomy := .taxonomy }} {{- with $page.GetTerms
|
||||||
@context {string} taxonomy The taxonony.
|
$taxonomy }} {{- $label := (index . 0).Parent.LinkTitle }}
|
||||||
|
|
||||||
@example: {{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }}
|
|
||||||
*/}}
|
|
||||||
|
|
||||||
{{- $page := .page }}
|
|
||||||
{{- $taxonomy := .taxonomy }}
|
|
||||||
|
|
||||||
{{- with $page.GetTerms $taxonomy }}
|
|
||||||
{{- $label := (index . 0).Parent.LinkTitle }}
|
|
||||||
<div class="tags">
|
<div class="tags">
|
||||||
<ul>
|
<ul>
|
||||||
{{- range . }}
|
{{- range . }}
|
||||||
|
|
|
||||||
9
treefmt.nix
Normal file
9
treefmt.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
projectRootFile = "flake.nix";
|
||||||
|
programs = {
|
||||||
|
nixfmt.enable = true;
|
||||||
|
gofmt.enable = true;
|
||||||
|
taplo.enable = true;
|
||||||
|
prettier.enable = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue