updated blog flake

This commit is contained in:
Kristian Krsnik 2024-03-02 19:36:04 +01:00
parent d2adef9dc0
commit cd187e3092
Signed by: Kristian
GPG Key ID: FD1330AC9F909E85
3 changed files with 43 additions and 72 deletions

18
.gitignore vendored
View File

@ -1,13 +1,11 @@
# Nix build output
/result
# development
/.direnv/
/themes
# Generated files by hugo
/public/
/resources/_gen/
/assets/jsconfig.json
hugo_stats.json
# Temporary lock file while building
/resources/
/.hugo_build.lock
# Nix
.direnv/
/result
/themes/

42
flake.lock generated
View File

@ -1,35 +1,17 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1689068808,
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1692207601,
"narHash": "sha256-tfPGNKQcJT1cvT6ufqO/7ydYNL6mcJClvzbrzhKjB80=",
"lastModified": 1709237383,
"narHash": "sha256-cy6ArO4k5qTx+l5o+0mL9f5fa86tYUX3ozE1S+Txlds=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b30c68669df77d981ce4aefd6b9d378563f6fc4e",
"rev": "1536926ef5621b09bba54035ae2bb6d806d72ac8",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.05",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
@ -52,25 +34,9 @@
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"nostyleplease": "nostyleplease"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",

View File

@ -3,7 +3,6 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
nostyleplease = {
url = "github:Masellum/hugo-theme-nostyleplease";
flake = false;
@ -13,49 +12,57 @@
outputs = {
self,
nixpkgs,
flake-utils,
nostyleplease,
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
formatter = pkgs.alejandra;
}: let
supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
in {
formatter = forAllSystems (system: pkgs.${system}.alejandra);
packages.default = pkgs.stdenv.mkDerivation {
packages = forAllSystems (system: {
default = pkgs.${system}.stdenv.mkDerivation {
name = "blog";
meta = with pkgs.lib; {
description = "Kristian's personal blog";
platforms = platforms.all;
};
# Exclude themes and public folder from build sources
src = builtins.filterSource (path: type:
!(type
== "directory"
&& (baseNameOf path == "themes" || baseNameOf path == "public")))
./.;
src = builtins.filterSource (path: type: !(type == "directory" && (baseNameOf path == "themes" || baseNameOf path == "public"))) ./.;
nativeBuildInputs = with pkgs.${system}; [
hugo
];
# Link theme to themes folder and build
buildPhase = ''
mkdir -p themes
ln -s ${nostyleplease} themes/nostyleplease
${pkgs.hugo}/bin/hugo --gc --minify
hugo --gc --minify
'';
installPhase = ''
cp -r public/. $out
'';
};
});
devShells = forAllSystems (system: {
default = pkgs.${system}.mkShellNoCC {
packages = with pkgs.${system}; [
hugo
];
devShells.default = pkgs.mkShellNoCC {
packages = with pkgs; [hugo];
# Link theme to themes folder
shellHook = ''
mkdir -p themes
unlink themes/nostyleplease
ln -s ${nostyleplease} themes/nostyleplease
if [ ! -d ./themes ]; then
mkdir ./themes
fi
if [ ! -d ./themes/nostyleplease ]; then
ln -s ${nostyleplease} ./themes/nostyleplease
fi
hugo server --buildDrafts
'';
};
});
};
}