Compare commits

...

2 commits

Author SHA1 Message Date
ca2ebd5949 feat: add Windows cross-compilation and release artifacts
All checks were successful
Continuous Integration / Lint, Check & Test (push) Successful in 4m43s
Continuous Integration / Build Package (push) Successful in 5m17s
- Add mkWindowsCraneLib using x86_64-pc-windows-gnu target
- Add mkStreamdWindows using mingw-w64 toolchain for cross-compilation
- Export streamd-windows package from flake
- Add Windows build step and .exe artifact to release workflow
2026-04-13 18:56:22 +02:00
4ded06748b fix: cross-platform compatibility for Windows support
- Use directories::BaseDirs for config path fallback instead of hardcoded Unix path
- Default to notepad on Windows instead of vi for editor commands
- Skip +N line argument for notepad in todo edit (notepad doesn't support it)
2026-04-13 18:56:22 +02:00
6 changed files with 68 additions and 10 deletions

View file

@ -49,12 +49,17 @@ jobs:
if: steps.version.outputs.SKIP != 'true'
run: nix build .#streamd-musl -o result-musl
- name: Build Windows binary
if: steps.version.outputs.SKIP != 'true'
run: nix build .#streamd-windows -o result-windows
- name: Prepare release artifacts
if: steps.version.outputs.SKIP != 'true'
run: |
mkdir -p release
cp result-deb release/streamd_${{ steps.version.outputs.VERSION }}_amd64.deb
cp result-musl/bin/streamd release/streamd-${{ steps.version.outputs.VERSION }}-linux-x86_64
cp result-windows/bin/streamd.exe release/streamd-${{ steps.version.outputs.VERSION }}-windows-x86_64.exe
- name: Create release
if: steps.version.outputs.SKIP != 'true'

View file

@ -132,6 +132,38 @@
in
craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; });
mkWindowsCraneLib =
system:
let
pkgs = mkPkgs system;
toolchain = pkgs.rust-bin.stable.latest.default.override {
targets = [ "x86_64-pc-windows-gnu" ];
};
in
(crane.mkLib pkgs).overrideToolchain toolchain;
mkStreamdWindows =
system:
let
pkgs = mkPkgs system;
pkgsCross = pkgs.pkgsCross.mingwW64;
craneLib = mkWindowsCraneLib system;
commonArgs = {
src = craneLib.path ./.;
pname = "streamd";
inherit version;
strictDeps = true;
CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu";
CC_x86_64_pc_windows_gnu = "${pkgsCross.stdenv.cc}/bin/x86_64-w64-mingw32-gcc";
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER = "${pkgsCross.stdenv.cc}/bin/x86_64-w64-mingw32-gcc";
nativeBuildInputs = [ pkgsCross.stdenv.cc ];
buildInputs = [ pkgsCross.windows.pthreads ];
doCheck = false;
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
in
craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; });
mkStreamdDeb =
system:
let
@ -181,9 +213,10 @@
streamd = mkStreamd system;
streamd-musl = mkStreamdMusl system;
streamd-deb = mkStreamdDeb system;
streamd-windows = mkStreamdWindows system;
in
{
inherit streamd streamd-musl streamd-deb;
inherit streamd streamd-musl streamd-deb streamd-windows;
default = streamd;
}
);

View file

@ -67,7 +67,13 @@ pub fn run(number: i32) -> Result<(), StreamdError> {
};
if let Some(file_path) = sorted_shards[selected_index].location.get("file") {
let editor = std::env::var("EDITOR").unwrap_or_else(|_| "vi".to_string());
let editor = std::env::var("EDITOR").unwrap_or_else(|_| {
if cfg!(windows) {
"notepad".to_string()
} else {
"vi".to_string()
}
});
Command::new(&editor).arg(file_path).status()?;
}

View file

@ -24,7 +24,13 @@ pub fn run() -> Result<(), StreamdError> {
drop(file);
// Open in editor
let editor = std::env::var("EDITOR").unwrap_or_else(|_| "vi".to_string());
let editor = std::env::var("EDITOR").unwrap_or_else(|_| {
if cfg!(windows) {
"notepad".to_string()
} else {
"vi".to_string()
}
});
let status = Command::new(&editor).arg(&preliminary_path).status()?;
if !status.success() {

View file

@ -92,13 +92,19 @@ pub fn run_edit(number: usize) -> Result<(), StreamdError> {
.get("file")
.ok_or(StreamdError::MissingFilePath)?;
let editor = std::env::var("EDITOR").unwrap_or_else(|_| "vi".to_string());
let line_arg = format!("+{}", task.start_line);
let editor = std::env::var("EDITOR").unwrap_or_else(|_| {
if cfg!(windows) {
"notepad".to_string()
} else {
"vi".to_string()
}
});
let status = Command::new(&editor)
.arg(&line_arg)
.arg(file_path)
.status()?;
let mut cmd = Command::new(&editor);
if !editor.to_lowercase().contains("notepad") {
cmd.arg(format!("+{}", task.start_line));
}
let status = cmd.arg(file_path).status()?;
if !status.success() {
return Err(StreamdError::IoError(std::io::Error::other(

View file

@ -37,8 +37,10 @@ impl Settings {
fn config_path() -> PathBuf {
if let Some(proj_dirs) = ProjectDirs::from("", "", "streamd") {
proj_dirs.config_dir().join("config.toml")
} else if let Some(base_dirs) = directories::BaseDirs::new() {
base_dirs.config_dir().join("streamd").join("config.toml")
} else {
PathBuf::from("~/.config/streamd/config.toml")
PathBuf::from("streamd_config.toml")
}
}
}