Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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 .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ _ReSharper*/
artifacts/
# Scanner configuration file (user-specific)
scan_config.ini

result
out
.direnv
1 change: 1 addition & 0 deletions BFD9010/BFD9010.Gui/BFD9010.Gui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<AssemblyName>bfd9010</AssemblyName>
<Platforms>AnyCPU;x86</Platforms>
<PlatformTarget>x86</PlatformTarget>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<ApplicationIcon>..\..\documentation\images\BFD9000_logo_white.ico</ApplicationIcon>
</PropertyGroup>

Expand Down
15 changes: 11 additions & 4 deletions BFD9010/BFD9010.Scanner/ScanConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace BFD9010.Scanner
/// </summary>
public class ScanConfig
{
private const string CONFIG_FILENAME = "scan_config.ini";
private const string CONFIG_FILENAME = "~\\Desktop\\VidarScans\\scan_config.ini";
Comment thread
tnichols217 marked this conversation as resolved.
Outdated

// Scan parameters with their default values (from original code before PR)
public short Offset0_BitDepth { get; set; } = 16;
Expand Down Expand Up @@ -296,9 +296,16 @@ private void SetValue(string key, string value)

private static string GetConfigPath()
{
// Place config file in the same directory as the executable
string exeDir = AppDomain.CurrentDomain.BaseDirectory;
return Path.Combine(exeDir, CONFIG_FILENAME);
string outDir = Environment.ExpandEnvironmentVariables(CONFIG_FILENAME);
if (outDir.StartsWith('~'))
{
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
string rest = outDir.Length == 1 ? string.Empty : outDir.Substring(1).TrimStart('\\', '/');
outDir = Path.Combine(home, rest);
}
outDir = Path.GetFullPath(outDir);
Directory.CreateDirectory(Path.GetDirectoryName(outDir));
return outDir;
}

private static string ExpandPath(string path)
Expand Down
61 changes: 61 additions & 0 deletions flake.lock

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

100 changes: 100 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
description = "BFD9010: An HL7 FHIR API for Scanners";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
};

outputs =
{ nixpkgs, utils, ... }:
utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
in
{
packages = rec {
nugetDeps = pkgs.dotnetCorePackages.addNuGetDeps {
nugetDeps = ./nix/deps.json;
};
default = app;
base = {
pname = "BFD9010.Gui";
version = "1.0.0";
src = ./.;

nativeBuildInputs = [
pkgs.dotnetCorePackages.sdk_8_0
pkgs.cacert
];

# Explicitly set runtimeId to null to block the host-side targeting pack additions
runtimeId = null;

# Explicitly feed our win-x64 target down into the underlying NuGet fetcher mapping
# meta.platforms = [ "x86_64-windows" ];

configurePhase = ''
export HOME=$TMPDIR
export DOTNET_CLI_HOME=$TMPDIR

# The addNuGetDeps hook outputs its organized cache folder to $nugetDeps
# We map the standard .NET environment variable straight to it
export NUGET_PACKAGES=$nugetDeps
'';

buildPhase = ''
# Pure offline compilation phase using only the decoupled Windows targets
dotnet restore BFD9010/BFD9010.Gui/BFD9010.Gui.csproj \
-r win-x86 \
--source "$nugetDeps" \
-p:EnableWindowsTargeting=true

dotnet publish BFD9010/BFD9010.Gui/BFD9010.Gui.csproj \
-c Release \
-r win-x86 \
--no-restore \
-p:TargetFramework=net8.0-windows \
--self-contained true \
-o $out/share/bfd9010
'';

installPhase = ''
mkdir -p $out/bin

cat <<EOF > $out/bin/bfd9010-server
#!/usr/bin/env bash
export WINEDEBUG=-all
export WINEARCH=win32
export WINEPREFIX=\$HOME/.local/share/bfd9010-wine
if [ ! -d "\$WINEPREFIX" ]; then
echo "Initializing 32-bit Wine environment..."
${pkgs.wine}/bin/wineboot -u
fi
exec ${pkgs.wine}/bin/wine $out/share/bfd9010/bfd9010.exe "\$@"
EOF

chmod +x $out/bin/bfd9010-server
'';
};
app = pkgs.stdenv.mkDerivation (nugetDeps base);
};

# Spin up a quick development shell with 'nix develop'
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
dotnetCorePackages.runtime_8_0
dotnetCorePackages.sdk_8_0
nuget-to-json
nil
nixd
];

shellHook = ''
export DOTNET_ROOT="${pkgs.dotnetCorePackages.sdk_10_0}/share/dotnet"
'';
};
}
);
}
Loading