build(flake): Init

This commit is contained in:
Benedikt Peetz 2024-05-25 22:11:47 +02:00
parent 3b4ced63e7
commit e72cd91dbd
Signed by: bpeetz
GPG Key ID: B6139BCB07CE946D
6 changed files with 263 additions and 2 deletions

7
.envrc Normal file
View File

@ -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

9
.gitignore vendored
View File

@ -1,2 +1,7 @@
public
.hugo_build.lock
# Hugo stuff
/public
/.hugo_build.lock
# Nix build stuff
/.direnv
/result

85
flake.lock Normal file
View File

@ -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
}

88
flake.nix Normal file
View File

@ -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

73
treefmt.nix Normal file
View File

@ -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"];
};
};
};
}
)

3
update.sh Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env sh
nix flake update