diff options
author | Franck Cuny <franck@fcuny.net> | 2023-12-03 13:14:59 -0800 |
---|---|---|
committer | Franck Cuny <franck@fcuny.net> | 2023-12-03 13:14:59 -0800 |
commit | 45f8e2d134e3dd716c5a47d15ab55266cb354ec9 (patch) | |
tree | bfb29152a651e6693bce077620b2760e3de38cda | |
parent | chore: update flake (#12) (diff) | |
download | fcuny.net-45f8e2d134e3dd716c5a47d15ab55266cb354ec9.tar.gz |
add `treefmt` and `pre-commit-hooks`
I can now run `nix fmt` or `nix flake check` to check the syntax for various files in this repository. Fixed a deprecation warning for `hugo`: ``` > WARN The author key in site configuration is deprecated. Use params.author.email instead. > WARN The author key in site configuration is deprecated. Use params.author.name instead. ```
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | config.toml | 98 | ||||
-rw-r--r-- | flake.lock | 162 | ||||
-rw-r--r-- | flake.nix | 38 | ||||
-rw-r--r-- | layouts/index.atom.xml | 20 | ||||
-rw-r--r-- | treefmt.nix | 8 |
6 files changed, 259 insertions, 68 deletions
diff --git a/.gitignore b/.gitignore index 8ec0a90..81e48e1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /docs/ /.hugo_build.lock /result +/.pre-commit-config.yaml diff --git a/config.toml b/config.toml index 9d8c464..22cbecc 100644 --- a/config.toml +++ b/config.toml @@ -5,70 +5,70 @@ publishDir = "docs" enableGitInfo = false [params] - homeText = "A collection of posts" +homeText = "A collection of posts" -[author] - name = "Franck Cuny" - email = "franck@fcuny.net" +[params.author] +name = "Franck Cuny" +email = "franck@fcuny.net" [taxonomies] - tag = "tags" +tag = "tags" [permalinks] - blog = "/blog/:slug/" - notes = "/notes/:slug/" - tags = "/tags/:slug/" +blog = "/blog/:slug/" +notes = "/notes/:slug/" +tags = "/tags/:slug/" [menu] - [[menu.main]] - identifier = "blog" - name = "blog" - title = "blog" - url = "/blog/" - weight = 110 +[[menu.main]] +identifier = "blog" +name = "blog" +title = "blog" +url = "/blog/" +weight = 110 - [[menu.main]] - identifier = "notes" - name = "notes" - title = "notes" - url = "/notes/" - weight = 120 +[[menu.main]] +identifier = "notes" +name = "notes" +title = "notes" +url = "/notes/" +weight = 120 - [[menu.main]] - identifier = "code" - name = "code" - title = "code" - url = "https://github.com/fcuny" - weight = 130 +[[menu.main]] +identifier = "code" +name = "code" +title = "code" +url = "https://github.com/fcuny" +weight = 130 - [[menu.main]] - identifier = "feed" - name = "feed" - title = "feed" - url = "/feed.xml" - weight = 140 +[[menu.main]] +identifier = "feed" +name = "feed" +title = "feed" +url = "/feed.xml" +weight = 140 [markup] - [markup.highlight] - anchorLineNos = false - codeFences = false - guessSyntax = false - hl_Lines = "" - lineAnchors = "" - lineNoStart = 1 - lineNos = false - lineNumbersInTable = false - noClasses = true - style = "pygments" - tabWidth = 4 +[markup.highlight] +anchorLineNos = false +codeFences = false +guessSyntax = false +hl_Lines = "" +lineAnchors = "" +lineNoStart = 1 +lineNos = false +lineNumbersInTable = false +noClasses = true +style = "pygments" +tabWidth = 4 [mediaTypes."application/atom"] - suffixes = ["xml"] +suffixes = ["xml"] [outputFormats.Atom] - mediaType = "application/atom" - baseName = "feed" - isPlainText = false +mediaType = "application/atom" +baseName = "feed" +isPlainText = false [outputs] - home = [ "HTML", "Atom" ] +home = ["HTML", "Atom"] diff --git a/flake.lock b/flake.lock index 2dc3d82..677ddcb 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,21 @@ { "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -18,6 +34,45 @@ "type": "github" } }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660459072, + "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1701624383, @@ -34,10 +89,82 @@ "type": "github" } }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1685801374, + "narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c37ca420157f4abc31e26f436c1145f8951ff373", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1689261696, + "narHash": "sha256-LzfUtFs9MQRvIoQ3MfgSuipBVMXslMPH/vZ+nM40LkA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "df1eee2aa65052a18121ed4971081576b25d6b5c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1695644571, + "narHash": "sha256-asS9dCCdlt1lPq0DLwkVBbVoEKuEuz+Zi3DG7pR/RxA=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "6500b4580c2a1f3d0f980d32d285739d8e156d92", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils_2", + "gitignore": "gitignore", + "nixpkgs": "nixpkgs_2", + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1700922917, + "narHash": "sha256-ej2fch/T584b5K9sk1UhmZF7W6wEfDHuoUYpFN8dtvM=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "e5ee5c5f3844550c01d2131096c7271cec5e9b78", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, "root": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks", + "treefmt-nix": "treefmt-nix" } }, "systems": { @@ -54,6 +181,39 @@ "repo": "default", "type": "github" } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1699786194, + "narHash": "sha256-3h3EH1FXQkIeAuzaWB+nK0XK54uSD46pp+dMD3gAcB4=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "e82f32aa7f06bbbd56d7b12186d555223dc399d1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 878be9f..5ee6f10 100644 --- a/flake.nix +++ b/flake.nix @@ -4,16 +4,20 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/master"; flake-utils.url = "github:numtide/flake-utils"; + pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix"; + treefmt-nix.url = "github:numtide/treefmt-nix"; }; - outputs = { self, nixpkgs, flake-utils }: + outputs = { self, nixpkgs, flake-utils, pre-commit-hooks, treefmt-nix, }: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; - in - { + treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix; + in { + formatter = treefmtEval.config.build.wrapper; + packages = { - site = with pkgs; + default = with pkgs; stdenv.mkDerivation { pname = "fcuny.net"; version = self.lastModifiedDate; @@ -32,20 +36,30 @@ ''; }; - apps = { - deploy = { - type = "app"; - program = "${self.packages."${system}".deploy}/bin/deploy"; + checks = { + pre-commit-check = pre-commit-hooks.lib.${system}.run { + src = ./.; + hooks = { + hugo = { + enable = true; + entry = "${pkgs.hugo}/bin/hugo --panicOnWarning"; + pass_filenames = false; + }; + }; }; + formatting = treefmtEval.config.build.check self; + }; + + apps = { default = { type = "app"; program = "${self.packages."${system}".hugo}/bin/hugo"; }; }; - defaultPackage = self.packages."${system}".container; - - devShell = - pkgs.mkShell { buildInputs = with pkgs; [ hugo git ]; }; + devShells.default = pkgs.mkShell { + inherit (self.checks.${system}.pre-commit-check) shellHook; + buildInputs = with pkgs; [ hugo git treefmt ]; + }; }); } diff --git a/layouts/index.atom.xml b/layouts/index.atom.xml index 1d73f9b..a80fc53 100644 --- a/layouts/index.atom.xml +++ b/layouts/index.atom.xml @@ -2,20 +2,28 @@ <title>{{ .Site.Title }}</title> <link href="{{ .Permalink }}feed.xml" rel="self"/> <link href="{{ .Permalink }}"/> - <id>{{ .Permalink }}</id>{{ with .Site.Author.name }} + <id>{{ .Permalink }}</id> + + {{ with .Site.Params.Author.name }} <author> - <name>{{.}}</name>{{ with $.Site.Author.email }} - <email>{{.}}</email>{{end}} - </author>{{end}} + <name>{{.}}</name> + {{ with $.Site.Params.Author.email }} + <email>{{.}}</email> + {{end}} + </author> + {{end}} + <generator>Hugo -- gohugo.io</generator> {{ range where (first 10 (where .Site.Pages "Section" "blog")) "Params.hidden" "ne" "true" }} <entry> {{ `<title type="html"><![CDATA[` | safeHTML }}{{ .Title }}]]></title> <link href="{{ .Permalink }}"/> - <id>{{ .Permalink }}</id>{{ with .Site.Params.Author }} + <id>{{ .Permalink }}</id> + {{ with .Site.Params.Author.name }} <author> <name>{{.}}</name> - </author>{{end}} + </author> + {{end}} {{- $fmt := "2006-01-02T15:04:05-07:00" }} <published>{{ .Date.Format $fmt | safeHTML }}</published> {{ `<content type="html"><![CDATA[` | safeHTML }}{{ .Content }}]]></content> diff --git a/treefmt.nix b/treefmt.nix new file mode 100644 index 0000000..e6164a0 --- /dev/null +++ b/treefmt.nix @@ -0,0 +1,8 @@ +{ + projectRootFile = "flake.nix"; + programs = { + nixfmt.enable = true; # nix + taplo.enable = true; # toml + yamlfmt.enable = true; # yaml + }; +} |