notebook/flake.nix

74 lines
2.1 KiB
Nix
Raw Normal View History

2024-02-01 14:34:27 +00:00
{
description = ''
A collection of my notes.
Uses [Quartz](https://quartz.jzhao.xyz/) to transform Markdown content into
a statically generated site. Markdown files are primarily managed with
[Obsidian](https://obsidian.md/).
'';
inputs = {
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
2024-02-01 15:11:29 +00:00
quartz-src = pkgs.fetchFromGitHub {
owner = "jackyzha0";
repo = "quartz";
2024-02-07 13:27:00 +00:00
rev = "d2fb50b83c9557f1cd36e4706e9a11aa8f01e458";
hash = "sha256-ShrwdHhrfFCFW2I+tlhfB7sqlC29nfsb12gaN4zpNsc=";
2024-02-01 14:34:27 +00:00
};
2024-02-01 15:11:29 +00:00
quartz = pkgs.buildNpmPackage {
pname = "quartz";
version = "v4";
src = quartz-src;
2024-02-07 13:27:00 +00:00
npmDepsHash = "sha256-VK51/8N8qeNuLB45NyzlYQAbMopTmLrX2nhjGu2ci4s=";
2024-02-01 15:11:29 +00:00
dontNpmBuild = true;
};
2024-02-01 14:34:27 +00:00
in
{
packages = {
app = pkgs.stdenv.mkDerivation {
pname = "notebook";
version = "0.1.0";
src = ./.;
nativeBuildInputs = [ pkgs.nodejs ];
buildPhase = ''
2024-02-01 15:11:29 +00:00
cp -r ${quartz-src} quartz
2024-02-01 14:34:27 +00:00
cd quartz
find -type f -execdir chmod 644 {} +
find -type d -execdir chmod 755 {} +
2024-02-01 15:11:29 +00:00
ln -s ${quartz}/lib/node_modules/@jackyzha0/quartz/node_modules ./node_modules
export PATH="${quartz}/bin:$PATH"
rm -r content
cp -r ${./notes} content
cp ${./quartz.config.ts} quartz.config.ts
cp ${./quartz.layout.ts} quartz.layout.ts
2024-02-01 14:34:27 +00:00
node quartz/bootstrap-cli.mjs build
2024-02-01 14:34:27 +00:00
'';
installPhase = ''
mkdir $out
2024-02-01 14:52:15 +00:00
cp -r public $out/share
2024-02-01 14:34:27 +00:00
'';
};
default = self.packages.${system}.app;
};
2024-02-07 13:27:00 +00:00
devShells.default = pkgs.mkShell { };
2024-02-01 14:34:27 +00:00
});
}