Business-Edition on NixOS

Get help for specific problems
Posts: 12
Joined: 30 Dec 2020

Thiemo

Hi

I have been building a NixOS package for FreeFileSync Business Edition for its capabilities of silent installation. However, there are several problems.
- The file names contain [] but nix interpretes those as array marker or something. I agree, that nix should be able handle that correctly, however, on the command line this characters in file names are tiresome escape needies.
- The installer looks for /bin/bash. This is not quite portable. Why does it not rely on the path?
- I set symlink on a bash to that path but still the installer fails miserably with "Could not find path to terminal executable" quite immediately.

Are there any plans to support systems like NixOS?

Kind regards

Thiemo
freefilesync.nix
# $Header$

broken

{ config, pkgs, ... }:

let
  # Installer lokal holen
  ffsInstaller = pkgs.fetchurl {
    url = "file://${./packages/FreeFileSync_Business_Install.run_4_nix}";
    sha256 = "329973562a0d6c5679167d3885a37dc00f6029cb0ffc0c4927c7bae3a13a1a1d";
    name = "FreeFileSync_Install.run";
  };

  # Lizenz lokal holen (wird nur während Installation benötigt)
  ffsLicense = pkgs.fetchurl {
    url = "file://${./packages/FreeFileSync_Business_Install.license_4_nix}";
    sha256 = "b5baa8b91f705f1562be7a6fadd6c3f622ee785f51b454deeb69317c9ea91c55";
    name = "FreeFileSync_Install.license";  # Gleicher Basename wie .run
  };

  ffsPkg = pkgs.stdenv.mkDerivation {
    pname = "freefilesync";
    version = "14.10";

    src = ffsInstaller;

    nativeBuildInputs = with pkgs; [
      autoPatchelfHook  # Patcht Binaries automatisch für NixOS
      xvfb-run          # Virtueller X-Server für headless GUI-Apps
    ];

    buildInputs = with pkgs; [
      gtk3
      glib
      libssh2
      openssl
      curl
      stdenv.cc.cc.lib
    ];

    dontUnpack = true;

    installPhase = ''
      # Kopiere Installer und Lizenz ins selbe Verzeichnis
      # Beide müssen identischen Basename haben (außer Suffix)
      mkdir -p install-dir
      cp $src install-dir/FreeFileSync_Install.run
      cp ${ffsLicense} install-dir/FreeFileSync_Install.license
      chmod +x install-dir/FreeFileSync_Install.run

      cd install-dir

      # Patche den Installer für NixOS (fixt /bin/bash Problem)
      patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" FreeFileSync_Install.run || true

      # Erstelle temporäres /bin/bash für den Installer
      mkdir -p bin
      ln -s ${pkgs.bash}/bin/bash bin/bash
      export PATH=$PWD/bin:$PATH

      # Führe Installer im Silent-Modus aus mit virtuellem X-Server
      # Der Installer erstellt Binaries, Desktop-Einträge und Icons selbst
      # Lizenz wird während der Installation gelesen, danach nicht mehr benötigt
      mkdir -p $out

      # Setze Terminal-Umgebungsvariablen für den Installer
      export TERM=xterm
      export SHELL=${pkgs.bash}/bin/bash
      export TERMINFO=${pkgs.ncurses}/share/terminfo

      # Debug: Was passiert beim Start?
      echo "=== Installer start ==="
      HOME=$PWD xvfb-run -a -s "-screen 0 1024x768x24" ./FreeFileSync_Install.run /silent /dir="$out" /create_shortcuts=no || {
        echo "=== Installer failed, checking what was created ==="
        ls -la $out/ || true
        exit 1
      }

      # Der Installer sollte alles Notwendige eingerichtet haben
      # autoPatchelfHook patcht die Binaries automatisch nach der Installation
    '';

    meta = with pkgs.lib; {
      description = "FreeFileSync - Folder comparison and synchronization";
      homepage = "https://freefilesync.org/";
      license = licenses.unfree;  # Business-Lizenz
      platforms = platforms.linux;
    };
  };
in {
  # FreeFileSync installieren
  environment.systemPackages = [ ffsPkg ];

  # Lizenz wird während der Installation gelesen und muss nicht im System bleiben
}