From 79b0eef25dc74fdb27cd0c7e84f2663973f9a15d Mon Sep 17 00:00:00 2001 From: Gregory Bednov Date: Mon, 16 Feb 2026 22:51:38 +0300 Subject: [PATCH] init --- flake.nix | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 flake.nix diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..35dd316 --- /dev/null +++ b/flake.nix @@ -0,0 +1,82 @@ +{ + description = "Kompas3D FHS wrapper"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = { self, nixpkgs }: + let + systems = [ "x86_64-linux" "aarch64-linux" ]; + forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system); + in + { + packages = forAllSystems (system: + let + pkgs = import nixpkgs { inherit system; }; + + kompas = pkgs.kdePackages.callPackage ./default.nix { }; + pname = "kompas3d-fhs"; + in + { + default = pkgs.buildFHSEnv rec { + inherit pname; + inherit (kompas) version; + + targetPkgs = pkgs': [ + kompas + pkgs'.open-sans + ]; + + extraBuildCommands = '' + mkdir -p $out/usr/local/ + ''; + + extraBwrapArgs = [ + "--tmpfs" "/usr/local" + "--bind-try" "/etc/nixos/" "/etc/nixos/" + ]; + + # symlink shared assets, including icons and desktop entries + extraInstallCommands = '' + ln -s "${kompas}/share" "$out/" + ln -s "$out/bin/${pname}" "$out/bin/${kompas.meta.mainProgram}" + ''; + + profile = '' + ( + custom_font_dir="/usr/local/share/fonts" + if [ -d "$custom_font_dir" ]; then + echo "Font directory $custom_font_dir already exists, skipping font linking" + return 0 + fi + echo "Start font linking inside FHS env cause kompas only checks /usr/{,local/}share/fonts/ dirs" + mkdir -p "$custom_font_dir" + for font in $(${pkgs.fontconfig}/bin/fc-list -f "%{file}\n" | sort -u | awk -F/ '{if (!seen[$NF]++) print $0}'); do + [ -L "$font" ] && font=$(readlink -f "$font") + relpath=$(dirname $(echo $font | sed 's|.*/share/fonts/||')) + target="$custom_font_dir/$relpath/" + mkdir -p "$target" + ln -s "$font" "$target" + done + ) + ''; + + runScript = "${pkgs.bash}/bin/bash ${pkgs.writeText "kompas-wrapper" '' + export QT_QPA_PLATFORM=xcb + export QT_STYLE_OVERRIDE=Fusion + cd /opt/ascon/kompas3d-v24/Bin/ + ./kKompas + ''}"; + }; + }); + + apps = forAllSystems (system: { + default = { + type = "app"; + program = "${self.packages.${system}.default}/bin/kompas3d-fhs"; + }; + }); + }; +} +