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-06-15 18:25:25 +00:00
rev = "3e14b2b89b60610eb3ae57603a451f1435ea45c0";
hash = "sha256-T5gc1W/tUW72H1x90nDV31hk9CMC4J8wJOtcNUegXNw=";
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-06-15 18:25:25 +00:00
npmDepsHash = "sha256-iLZMWvaPnpvWJi+/K8kYDe+8P7YOcwD6wKRRqcX7KCs=";
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
});
}