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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ In order to configure the environment variables and contexts for `timewarrior-we
| TASK_WEB_DISPLAY_TIME_OF_THE_DAY | DISPLAY_TIME_OF_THE_DAY | Displays a time of the day widget in case of value `1` |
| TASK_WEB_TWK_USE_FONT | TWK_USE_FONT | Font to be used. If not, browsers default fonts are used |
| TASK_WEB_TWK_THEME | TWK_THEME | Defines the theme to be used (see "Themes") |
| TASK_WEB_TWK_STATICS_DIR | TWK_STATICS_DIR | Sets the statics web assets dir. Defaults to `./dist/` |

## Hooks

Expand Down
66 changes: 66 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

122 changes: 122 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
description = "Minimalistic web UI for Taskwarrior";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
fenix = { # Rust toolchain
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, fenix }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;

pkgsFor = system: import nixpkgs {
inherit system;
overlays = [ fenix.overlays.default ];
};
in
{
packages = forAllSystems (system:
let
pkgs = pkgsFor system;
lib = pkgs.lib;

frontend = pkgs.buildNpmPackage {
pname = "taskwarrior-web-frontend";
version = "0.0.0";

src = ./frontend;

npmDepsHash = "sha256-Ul/gE/XEAehckV1Qj6Qwyy7QTx4sju6/0Omb3srQSgQ=";

# The build commands from build.rs
buildPhase = ''
runHook preBuild # Install dependencies

mkdir -p dist

node_modules/.bin/tailwindcss -i css/style.css -o dist/style.css

# The original config references 'frontend/src/main.ts' but we're already in frontend/
substituteInPlace rollup.config.js \
--replace-fail 'frontend/src/main.ts' 'src/main.ts'

node_modules/.bin/rollup -c rollup.config.js

cp -r templates dist/

runHook postBuild
'';

installPhase = ''
runHook preInstall
mkdir -p $out
cp -r dist $out/
runHook postInstall
'';

dontNpmBuild = true;
};

rustToolchain = pkgs.fenix.complete.withComponents [
"cargo"
"clippy"
"rust-src"
"rustc"
"rustfmt"
];

rustPlatform = pkgs.makeRustPlatform {
cargo = rustToolchain;
rustc = rustToolchain;
};

manifest = (pkgs.lib.importTOML ./Cargo.toml).package;

taskwarrior-web = rustPlatform.buildRustPackage {
pname = manifest.name;
version = manifest.version;

src = ./.;

cargoHash = "sha256-8eudwEVFDCmFbereV3f8ABOaXjjg4XxuAheO6dNPLqA=";

nativeBuildInputs = [ pkgs.makeWrapper ];

buildInputs = with pkgs; [
sqlite
];

# Some tests require a writable HOME directory which isn't available in the sandbox
doCheck = false;

preBuild = ''
rm build.rs # Skip the build.rs entirely since we built frontend separately
mkdir -p $out/dist
cp -r ${frontend}/* $out
'';

postFixup = ''
wrapProgram $out/bin/taskwarrior-web \
--set TWK_STATICS_DIR "$out/dist"
'';

meta = with lib; {
description = "Minimalistic web UI for Taskwarrior";
homepage = "https://github.com/tmahmood/taskwarrior-web.git";
license = licenses.mit;
mainProgram = "taskwarrior-web";
};
};
in
{
inherit frontend taskwarrior-web;
default = taskwarrior-web;
}
);
};
}
Loading