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 # Generated files by hugo
/public/ /public/
/resources/_gen/ /resources/
/assets/jsconfig.json
hugo_stats.json
# Temporary lock file while building
/.hugo_build.lock /.hugo_build.lock
# Nix
.direnv/
/result
/themes/

View File

@ -1,35 +1,17 @@
{ {
"nodes": { "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": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1692207601, "lastModified": 1709237383,
"narHash": "sha256-tfPGNKQcJT1cvT6ufqO/7ydYNL6mcJClvzbrzhKjB80=", "narHash": "sha256-cy6ArO4k5qTx+l5o+0mL9f5fa86tYUX3ozE1S+Txlds=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "b30c68669df77d981ce4aefd6b9d378563f6fc4e", "rev": "1536926ef5621b09bba54035ae2bb6d806d72ac8",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "nixos-23.05", "ref": "nixos-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
@ -52,25 +34,9 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nostyleplease": "nostyleplease" "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", "root": "root",

View File

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