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.

100 lines
3.4 KiB

1 year ago
/*
Some utility commands:
- `nix flake update --commit-lock-file`
- `nix flake lock update-input <input>`
- `nix build .#dyesub-tool`
- `nix run .#dyesub-tool`
1 year ago
Updating `cargoHash`:
- Set `cargoHash` to an empty string
- run `nix run .#dyesub-tool`
1 year ago
- Update `cargoHash` with correct hash from output
*/
{
description = "A tool for generating dye sublimation transfer sheet SVGs for Japanese thumb shift keycaps.";
1 year ago
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
1 year ago
};
outputs = { self, nixpkgs, rust-overlay, crane }:
1 year ago
let
overlays = [ (import rust-overlay) ];
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system overlays;
};
# nightly is required for function signal syntax in leptos
# https://leptos-rs.github.io/leptos/02_getting_started.html
rust = pkgs.rust-bin.nightly.latest;
# binary for output binary derivations
# (doesn't include dev tooling e.g. clippy)
rust-bin = rust.minimal;
rustPlatform = pkgs.makeRustPlatform {
cargo = rust-bin;
rustc = rust-bin;
};
1 year ago
rustSettings = with pkgs; {
src = ./.;
cargoHash = nixpkgs.lib.fakeHash;
};
meta = with nixpkgs.lib; {
license = [ licenses.gpl3 ];
1 year ago
platforms = [ system ];
maintainers = with maintainers; [ elnudev ];
1 year ago
};
in {
devShells.${system}.default = with pkgs; mkShell {
packages = [
(rust.default.override {
1 year ago
extensions = [ "rust-src" ];
targets = [ "wasm32-unknown-unknown" ];
1 year ago
})
bacon
];
inputsFrom = with self.packages.${system}; [ dyesub-tool dyesub-cli ];
1 year ago
};
packages.${system} = {
default = self.packages.${system}.dyesub-cli;
dyesub-cli = rustPlatform.buildRustPackage (rustSettings // {
pname = "dyesub-cli";
version = "0.1.0";
buildAndTestSubdir = "dyesub-cli";
cargoHash = "sha256-6nbUjVjroFp2KZEk0wDisCUw2e9GtVxFgsGZm8xEe2A=";
meta = meta // {
description = "A tool for generating dye sublimation transfer sheet SVGs for Japanese thumb shift keycaps.";
};
});
dyesub-tool = let
rustToolchain = rust.minimal.override {
targets = [ "wasm32-unknown-unknown" ];
};
craneLib = ((crane.mkLib pkgs).overrideToolchain rustToolchain).overrideScope' (final: prev: {
wasm-bindgen-cli = pkgs.wasm-bindgen-cli;
});
crateNameFromCargoToml = packageName: craneLib.crateNameFromCargoToml { cargoToml = ./${packageName}/Cargo.toml; };
in craneLib.buildTrunkPackage {
inherit (crateNameFromCargoToml "dyesub-tool") pname version;
src = with pkgs.lib; cleanSourceWith {
src = ./.;
filter = path: type:
(hasSuffix "\.html" path) ||
(hasSuffix "\.css" path) ||
(craneLib.filterCargoSources path type)
;
};
trunkIndexPath = "dyesub-tool/index.html";
1 year ago
meta = meta // {
description = "A tool for generating dye sublimation transfer sheet SVGs for Japanese thumb shift keycaps.";
1 year ago
};
};
1 year ago
};
};
}