Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ result
result-*
tags
TAGS
static.out
23 changes: 15 additions & 8 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@
iosSdkVersion = "13.2";
}
}:
with obelisk;
project ./. ({ pkgs, ... }: {
staticFiles = import ./static { inherit pkgs; };
android.applicationId = "systems.obsidian.obelisk.examples.tailwind";
android.displayName = "Obelisk + Tailwind CSS";
ios.bundleIdentifier = "systems.obsidian.obelisk.examples.tailwind";
ios.bundleName = "Obelisk + Tailwind CSS";
})
let
pkgs = import (builtins.fetchGit {
name = "nixos-22.11";
url = "https://github.com/nixos/nixpkgs/";
ref = "refs/heads/nixos-22.11";
}) {};
in
with obelisk;
project ./. ({ ... }: {
staticFiles = import ./static { inherit pkgs; };
android.applicationId = "systems.obsidian.obelisk.examples.tailwind";
android.displayName = "Obelisk + Tailwind CSS";
ios.bundleIdentifier = "systems.obsidian.obelisk.examples.tailwind";
ios.bundleName = "Obelisk + Tailwind CSS";
})
47 changes: 14 additions & 33 deletions static/default.nix
Original file line number Diff line number Diff line change
@@ -1,36 +1,17 @@
{ pkgs }:
let
# The nixified node project was generated from a package.json file in src using node2nix
# See https://github.com/svanderburg/node2nix#using-the-nodejs-environment-in-other-nix-derivations
nodePkgs = (pkgs.callPackage ./src {
inherit pkgs;
nodejs = pkgs.nodejs-12_x;
}).shell.nodeDependencies;

# The frontend source files have to be passed in so that tailwind's purge option works
# See https://tailwindcss.com/docs/optimizing-for-production#removing-unused-css
frontendSrcFiles = ../frontend;

in pkgs.stdenv.mkDerivation {
name = "static";
src = ./src;
buildInputs = [pkgs.nodejs];
installPhase = ''
mkdir -p $out/css
mkdir -p $out/images

# Setting up the node environment:
ln -s ${nodePkgs}/lib/node_modules ./node_modules
export PATH="${nodePkgs}/bin:$PATH"

# We make the frontend haskell source files available here:
# This corresponds to the path specified in tailwind.config.js
ln -s ${frontendSrcFiles} frontend

# Run the postcss compiler:
postcss css/styles.css -o $out/styles.css

# We can write other commands to produce more static files as well:
cp -r images/* $out/images/
'';
}
in
pkgs.stdenv.mkDerivation {
name = "static";
src = ./src;
buildInputs = [pkgs.haskellPackages.tailwind];
installPhase = ''
mkdir -p $out/images

tailwind-run '${frontendSrcFiles}/**/*.hs' --output $out/styles.css

# We can write other commands to produce more static files as well:
cp -r images/* $out/images/
'';
}
3 changes: 0 additions & 3 deletions static/src/css/styles.css

This file was deleted.

17 changes: 0 additions & 17 deletions static/src/default.nix

This file was deleted.

Loading