From 9038bb05ef64527f96716e43fb3556b2aa0d8c07 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Fri, 6 Dec 2024 16:14:02 -0600 Subject: [PATCH] working nix build --- flake.lock | 18 +++++++++++++++ flake.nix | 64 +++++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 76 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index 5a97c90..78ac072 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,22 @@ { "nodes": { + "blowfish": { + "flake": false, + "locked": { + "lastModified": 1702560004, + "narHash": "sha256-6Ovd1ACYq0/NRsMbQN0Lt8xGbCKJ4EKM7qiU2Y+6pP4=", + "owner": "nunocoracao", + "repo": "blowfish", + "rev": "b6744efbf2d76023084498552a916b49d5a764d8", + "type": "github" + }, + "original": { + "owner": "nunocoracao", + "repo": "blowfish", + "rev": "b6744efbf2d76023084498552a916b49d5a764d8", + "type": "github" + } + }, "cl-nix-lite": { "locked": { "lastModified": 1720140845, @@ -67,6 +84,7 @@ }, "root": { "inputs": { + "blowfish": "blowfish", "cl-nix-lite": "cl-nix-lite", "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", diff --git a/flake.nix b/flake.nix index 342f1bb..123849a 100644 --- a/flake.nix +++ b/flake.nix @@ -6,6 +6,10 @@ flake-utils.url = "github:numtide/flake-utils"; cl-nix-lite.url = "github:hraban/cl-nix-lite"; rust-overlay.url = "github:oxalica/rust-overlay"; + blowfish = { + url = "github:nunocoracao/blowfish?rev=b6744efbf2d76023084498552a916b49d5a764d8"; + flake = false; + }; }; outputs = inputs: with inputs; @@ -48,6 +52,7 @@ ]; bi = with pkgs; [ + git hugo go nodejs @@ -63,11 +68,35 @@ openssl.dev ]; + blowfish = inputs.blowfish; + nativeLibs = with pkgs; [ openssl openssl.out openssl.dev ]; + + site = pkgs.stdenv.mkDerivation rec { + name = "site"; + version = "2.0.0"; + src = ./.; + configurePhase = '' + ls + mkdir -p themes + cp -r ${blowfish} themes/blowfish + ls themes/blowfish + ''; + buildPhase = '' + NODE_ENV=production ./themes/blowfish/node_modules/tailwindcss/lib/cli.js -c ./themes/blowfish/tailwind.config.js -i ./themes/blowfish/assets/css/main.css -o ./assets/css/compiled/main.css --jit && hugo --gc --minify + ${pkgs.hugo}/bin/hugo --minify + ''; + installPhase = '' + mkdir -p $out/public + cp -r public $out/public + ''; + buildInputs = bi; + nativeBuildInputs = nbi; + }; in { @@ -78,21 +107,44 @@ nativeBuildInputs = nbi; buildInputs = bi; nativeLibs = nativeLibs; - shellHook = '' - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.lib.makeLibraryPath nativeLibs}" - ''; }; - packages.default = pkgs.rustPlatform.buildRustPackage { - pname = "api"; + packages.default = pkgs.rustPlatform.buildRustPackage rec { + pname = "tfcapi"; version = "0.0.1"; - src = src; + src = ./.; cargoBuildFlags = ""; + doCheck = false; cargoLock = { lockFile = ./Cargo.lock; }; nativeBuildInputs = nbi; buildInputs = bi; + fixupPhase = '' + ls -l + ls -l $out + cp -r ${site}/public $out/public + ''; + }; + packages.site = pkgs.stdenv.mkDerivation rec { + name = "site"; + version = "2.0.0"; + src = src; + configurePhase = '' + ls + mkdir -p themes + cp -r ${blowfish} themes/blowfish + ls themes/blowfish + ''; + buildPhase = '' + NODE_ENV=production ./themes/blowfish/node_modules/tailwindcss/lib/cli.js -c ./themes/blowfish/tailwind.config.js -i ./themes/blowfish/assets/css/main.css -o ./assets/css/compiled/main.css --jit && hugo --gc --minify + ${pkgs.hugo}/bin/hugo --minify + ''; + installPhase = '' + cp -r public $out + ''; + buildInputs = bi; + nativeBuildInputs = nbi; }; } );