Skip to content

Commit

Permalink
office 2007 fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
leo60228 committed Oct 25, 2024
1 parent f68559d commit 7ab2c39
Show file tree
Hide file tree
Showing 9 changed files with 487 additions and 9 deletions.
146 changes: 137 additions & 9 deletions flake.lock

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

1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
url = "github:nix-community/lanzaboote/v0.4.1";
inputs.nixpkgs.follows = "nixpkgs";
};
inputs.poetry2nix.url = "github:nix-community/poetry2nix";

outputs =
{
Expand Down
1 change: 1 addition & 0 deletions home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@
syncthingtray
leoPkgs.twemoji-ttf
leoPkgs.determination-fonts
leoPkgs.office-2007-fonts
];

programs.git = {
Expand Down
1 change: 1 addition & 0 deletions nixpkgs/poetry2nix.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ poetry2nix, ... }: self: super: { poetry2nix = poetry2nix.lib.mkPoetry2Nix { pkgs = self; }; }
1 change: 1 addition & 0 deletions pkgs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ rec {
hactoolnet = callPackage ./hactoolnet { };
hyfetch = callPackage ./hyfetch { };
mastodon = callPackage ./mastodon { };
office-2007-fonts = callPackage ./office-2007-fonts { };
qtsass = python3.pkgs.toPythonApplication (python3.pkgs.callPackage ./qtsass { });
redumper = callPackage ./redumper { };
reposilite = callPackage ./reposilite { };
Expand Down
62 changes: 62 additions & 0 deletions pkgs/office-2007-fonts/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
lib,
stdenvNoCC,
runCommand,
poetry2nix,
libarchive,
}:

let
dl = poetry2nix.mkPoetryApplication {
projectDir = ./.;
overrides = poetry2nix.defaultPoetryOverrides.extend (
final: prev: {
pycdlib = prev.pycdlib.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ prev.setuptools ];
});
httpio = prev.httpio.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ prev.setuptools ];
});
libarchive-c = prev.libarchive-c.overridePythonAttrs (old: {
postPatch =
(old.postPatch or "")
+ ''
echo "Patching find_library call."
substituteInPlace libarchive/ffi.py \
--replace-warn "find_library('archive')" "\"${libarchive.lib}/lib/libarchive.so\""
'';
});
}
);
};
in
stdenvNoCC.mkDerivation rec {
pname = "office-fonts";
version = "2007";

src =
runCommand "office-fonts-src"
{
outputHashMode = "recursive";
outputHash = "sha256-unbiYm7lBGt4xy0/ul3VFOylAUbQV8GF44MVJWDbt5I=";
nativeBuildInputs = [ dl ];
}
''
mkdir $out
cd $out
dl
'';

installPhase = ''
runHook preInstall
install -Dm644 *.TTF -t $out/share/fonts/truetype
runHook postInstall
'';

meta = with lib; {
maintainers = with maintainers; [ leo60228 ];
platforms = platforms.all;
};
}
35 changes: 35 additions & 0 deletions pkgs/office-2007-fonts/dl/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import libarchive
import requests
import pycdlib
import sys

old_version = sys.version_info
sys.version_info = (3, 5)
import httpio
sys.version_info = old_version

def dl():
print('querying redirect')
url = "https://archive.org/download/microsoft-office-professional-plus-2007/Microsoft%20Office%20Professional%20Plus%202007.iso"
target = requests.head(url).headers['Location']

print('making request')
iso_fp = httpio.open(target, block_size=4*1024*1024)

print('opening iso')
iso = pycdlib.PyCdlib()
iso.open_fp(iso_fp)

print('opening file')
with iso.open_file_from_iso(iso_path='/PROPLUSW/PROPLSWW.CAB') as cab_fp:
print('reading archive')
with libarchive.stream_reader(cab_fp) as archive:
print('archive loaded')
for entry in archive:
if entry.name.endswith('.TTF'):
print(entry.name)
with open(entry.name, 'wb') as out:
for block in entry.get_blocks():
out.write(block)
if entry.name == "WINGDNG3.TTF":
break
Loading

0 comments on commit 7ab2c39

Please sign in to comment.