init
This commit is contained in:
commit
79b0eef25d
1 changed files with 82 additions and 0 deletions
82
flake.nix
Normal file
82
flake.nix
Normal file
|
|
@ -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";
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue