From 20d62336a446bea6c5846805e8325b67cd59fe54 Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 8 Oct 2024 11:49:47 -0400 Subject: nice redesign (#145) * nix: drop treefmt * nix: remove .envrc * nix: move `serve` to apps output * nice redesign * use local stylesheet * nix: fix build --- flake.nix | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 65 insertions(+), 17 deletions(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index 530ade2..48e7350 100644 --- a/flake.nix +++ b/flake.nix @@ -1,15 +1,9 @@ { - description = "seth's website"; + description = "Getchoo's website"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - nix-filter.url = "github:numtide/nix-filter"; - - treefmt-nix = { - url = "github:numtide/treefmt-nix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; }; outputs = @@ -17,7 +11,6 @@ self, nixpkgs, nix-filter, - treefmt-nix, }: let inherit (nixpkgs) lib; @@ -25,14 +18,26 @@ forAllSystems = lib.genAttrs systems; nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system}); - treefmtFor = forAllSystems ( - system: treefmt-nix.lib.evalModule nixpkgsFor.${system} (self + "/treefmt.nix") - ); in { - checks = forAllSystems (system: { - treefmt = treefmtFor.${system}.config.build.check self; - }); + apps = forAllSystems ( + system: + let + pkgs = nixpkgsFor.${system}; + in + { + serve = { + type = "app"; + program = toString ( + pkgs.runCommand "serve-website" { nativeBuildInputs = [ pkgs.zola ]; } '' + tmpdir=$(mktemp -d) + cd ${self.packages.${system}.website.src} + zola serve --force --output-dir "$tmpdir" + '' + ); + }; + } + ); devShells = forAllSystems ( system: @@ -43,14 +48,18 @@ default = pkgs.mkShellNoCC { packages = [ pkgs.zola - self.formatter.${system} + pkgs.actionlint + pkgs.deadnix + pkgs.nil + pkgs.statix + self.formatter.${system} ]; }; } ); - formatter = forAllSystems (system: treefmtFor.${system}.config.build.wrapper); + formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style); packages = forAllSystems ( system: @@ -58,7 +67,46 @@ pkgs = nixpkgsFor.${system}; in { - website = pkgs.callPackage ./nix/package.nix { inherit nix-filter self; }; + website = pkgs.callPackage ( + { + lib, + stdenvNoCC, + writeShellApplication, + zola, + }: + + stdenvNoCC.mkDerivation { + pname = "getchoo-website"; + version = self.shortRev or self.dirtyShortRev or "unknown"; + + src = nix-filter.lib.filter { + root = self; + include = [ + "config.toml" + "content" + "highlight_themes" + "sass" + "static" + "templates" + ]; + }; + + nativeBuildInputs = [ zola ]; + + postBuild = "zola build --output-dir $out"; + + dontConfigure = true; + dontInstall = true; + dontFixup = true; + + meta = { + homepage = "https://github.com/getchoo/website"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ getchoo ]; + }; + } + ) { }; + default = self.packages.${system}.website; } ); -- cgit v1.2.3