Want to contribute? Fork me on Codeberg.org!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
3.8 KiB

/*
Some utility commands:
- `nix flake update --commit-lock-file`
- `nix flake lock update-input <input>`
- `nix build .#tegakituesday` or `nix build .`
- `nix run .#tegakituesday` or `nix run .`
*/
{
description = "The website for the Tegaki Tuesday handwriting challenge.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = { self, nixpkgs, rust-overlay }:
let
overlays = [ (import rust-overlay) ];
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system overlays;
};
rust = pkgs.rust-bin.nightly.latest;
rust-bin = rust.minimal;
rustPlatform = pkgs.makeRustPlatform {
cargo = rust-bin;
rustc = rust-bin;
};
rustSettings = with pkgs; {
src = ./.;
cargoHash = nixpkgs.lib.fakeHash;
};
meta = with nixpkgs.lib; {
homepage = "https://tegakituesday.com";
#license = [ licenses.unfree ];
platforms = [ system ];
maintainers = with maintainers; [ elnudev ];
};
in {
devShells.${system}.default = with pkgs; mkShell {
packages = [
(pkgs.rust-bin.nightly.latest.default.override {
extensions = [ "rust-src" ];
})
cargo-edit
bacon
];
inputsFrom = with self.packages.${system}; [ tegakituesday ];
allowUnfree = true;
};
packages.${system} = {
default = self.packages.${system}.tegakituesday;
tegakituesday = rustPlatform.buildRustPackage (rustSettings // {
pname = "tegakituesday";
version = "0.1.0";
nativeBuildInputs = with pkgs; [ pkg-config dart-sass ];
buildInputs = with pkgs; [ openssl gettext sqlite ];
buildAndTestSubdir = "tegakituesday";
cargoHash = "sha256-XvC5YRt9q39L+b/SHJd7e1VutrEUlKpfbVhJP75/qco=";
postPatch = ''
pushd tegakituesday
sass styles/sass/style.sass:$out/share/styles/css/style.css
if [ -d assets ]; then
cp -r assets $out/share
else
mkdir -p $out/share/assets
fi
cp -r static $out/share
sed -i -E "s|relative\!\(\"([^\"]+)\"\)|\"''${out}\/share\/\1\"|" src/main.rs
popd
'';
meta = meta // {
description = "The website for the Tegaki Tuesday handwriting challenge.";
};
});
};
/*
nixosModules.default = { config, ... }: let
lib = nixpkgs.lib;
in {
options.services.tegakituesday = {
enable = lib.mkEnableOption (lib.mdDoc "tegakituesday service");
package = lib.mkOption {
type = lib.types.package;
default = self.packages.${system}.tegakituesday;
defaultText = "pkgs.tegakituesday";
description = lib.mdDoc ''
The tegakituesday package that should be used.
'';
};
port = lib.mkOption {
type = lib.types.port;
default = 8000;
description = lib.mdDoc ''
The port at which to run.
'';
};
};
config.systemd.services.tegakituesday = let
cfg = config.services.tegakituesday;
pkg = self.packages.${system}.tegakituesday;
in lib.mkIf cfg.enable {
description = pkg.meta.description;
after = [ "network.target" ];
wantedBy = [ "network.target" ];
serviceConfig = {
ExecStart = ''
${cfg.package}/bin/tegakituesday --port ${builtins.toString cfg.port}
'';
Restart = "always";
DynamicUser = true;
};
};
};
*/
};
}