diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..96eca6b --- /dev/null +++ b/.envrc @@ -0,0 +1,7 @@ +use flake || use nix +watch_file flake.nix + +if on_git_branch; then + echo && git status --short --branch && + echo && git fetch --verbose +fi diff --git a/.gitignore b/.gitignore index 60b2f55..7279b65 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,7 @@ -public -.hugo_build.lock \ No newline at end of file +# Hugo stuff +/public +/.hugo_build.lock + +# Nix build stuff +/.direnv +/result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..aa0aa66 --- /dev/null +++ b/flake.lock @@ -0,0 +1,85 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": [ + "systems" + ] + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1711715736, + "narHash": "sha256-9slQ609YqT9bT/MNX9+5k5jltL9zgpn36DpFB7TkttM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "807c549feabce7eddbf259dbdcec9e0600a0660d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "systems": "systems", + "treefmt-nix": "treefmt-nix" + } + }, + "systems": { + "locked": { + "lastModified": 1680978846, + "narHash": "sha256-Gtqg8b/v49BFDpDetjclCYXm8mAnTrUzR0JnE2nv5aw=", + "owner": "nix-systems", + "repo": "x86_64-linux", + "rev": "2ecfcac5e15790ba6ce360ceccddb15ad16d08a8", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "x86_64-linux", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1711803027, + "narHash": "sha256-Qic3OvsVLpetchzaIe2hJqgliWXACq2Oee6mBXa/IZQ=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "1810d51a015c1730f2fe05a255258649799df416", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..9f8a57f --- /dev/null +++ b/flake.nix @@ -0,0 +1,88 @@ +{ + description = "The Website for Trinitrix, deployed at trinitrix.vhack.eu"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs = { + nixpkgs.follows = "nixpkgs"; + }; + }; + + # inputs for following + systems = { + url = "github:nix-systems/x86_64-linux"; # only evaluate for this system + }; + flake-utils = { + url = "github:numtide/flake-utils"; + inputs = { + systems.follows = "systems"; + }; + }; + }; + + outputs = { + self, + nixpkgs, + flake-utils, + treefmt-nix, + ... + }: + flake-utils.lib.eachDefaultSystem (system: let + pkgs = nixpkgs.legacyPackages."${system}"; + + nativeBuildInputs = with pkgs; [hugo]; + treefmtEval = import ./treefmt.nix {inherit treefmt-nix pkgs;}; + + name = "trinitrix_website"; + + risotto = pkgs.fetchFromGitHub { + hash = "sha256-uYTrWkoxSnKfl3wgNRI9Bbqr8eK27vLYyYmlmcaG160="; + + owner = "joeroe"; + repo = "risotto"; + rev = "v0.4.0"; + }; + + build = pkgs.stdenv.mkDerivation { + inherit name; + + src = ./.; + + inherit nativeBuildInputs; + + configurePhase = '' + mkdir --parents themes/risotto; + cp --recursive ${risotto}/. ./themes/risotto; + ''; + + buildPhase = '' + hugo + ''; + + installPhase = '' + cp --recursive ./public "$out"; + ''; + }; + in { + packages.default = build; + checks = { + inherit build; + formatting = treefmtEval.config.build.check self; + }; + formatter = treefmtEval.config.build.wrapper; + + devShells.default = pkgs.mkShell { + packages = with pkgs; [ + cocogitto + + licensure + ]; + inherit nativeBuildInputs; + }; + }); +} +# vim: ts=2 + diff --git a/treefmt.nix b/treefmt.nix new file mode 100644 index 0000000..1cbab40 --- /dev/null +++ b/treefmt.nix @@ -0,0 +1,73 @@ +{ + treefmt-nix, + pkgs, +}: +treefmt-nix.lib.evalModule pkgs ( + {pkgs, ...}: { + # Used to find the project root + projectRootFile = "flake.nix"; + + programs = { + alejandra.enable = true; + rustfmt.enable = true; + clang-format.enable = true; + mdformat.enable = true; + shfmt = { + enable = true; + indent_size = 4; + }; + shellcheck.enable = true; + prettier = { + settings = { + arrowParens = "always"; + bracketSameLine = false; + bracketSpacing = true; + editorconfig = true; + embeddedLanguageFormatting = "auto"; + endOfLine = "lf"; + # experimentalTernaries = false; + htmlWhitespaceSensitivity = "css"; + insertPragma = false; + jsxSingleQuote = true; + printWidth = 80; + proseWrap = "always"; + quoteProps = "consistent"; + requirePragma = false; + semi = true; + singleAttributePerLine = true; + singleQuote = true; + trailingComma = "all"; + useTabs = false; + vueIndentScriptAndStyle = false; + + tabWidth = 4; + overrides = { + files = ["*.js"]; + options.tabwidth = 2; + }; + }; + }; + stylua.enable = true; + ruff = { + enable = true; + format = true; + }; + taplo.enable = true; + }; + + settings = { + global.excludes = [ + "CHANGELOG.md" + "NEWS.md" + ]; + formatter = { + clang-format = { + options = ["--style" "GNU"]; + }; + shfmt = { + includes = ["*.bash"]; + }; + }; + }; + } +) diff --git a/update.sh b/update.sh new file mode 100755 index 0000000..49216b8 --- /dev/null +++ b/update.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +nix flake update