Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make things simple for Nix(OS) users #6

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
todo.md
ime/windows/KeyboardVerify.log
_site/*
_site/*
result
205 changes: 205 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
# Note that this is not a derivation, but a collection of derivations.
# Use `callPackage` on the derivations herein _after_ importing this.
{ lib, stdenv, fontforge, xclip, ibus-engines }:

let
lerfanva = stdenv.mkDerivation {
name = "lerfanva";
src = ./.;
installPhase = ''
mkdir -p $out/bin
cp ime/ime.sh $out/bin/lerfanva
'';

meta = with lib; {
version = "0.1.0";
description = "Transliterate latin text into Zbalermorna";
homepage = https://github.com/jackhumbert/zbalermorna;
platforms = platforms.linux;
license = licenses.publicDomain;
};
};

lerfanva-clip = stdenv.mkDerivation {
name = "lerfanva-clip";
src = ./.;
buildInputs = [ lerfanva xclip ];

installPhase = ''
mkdir -p $out/bin

ln -s ${lerfanva}/bin/lerfanva $out/bin/lerfanva

cat << EOF > $out/bin/lerfanva-clip
#!/usr/bin/env bash
SEL=0
case \$1 in
1) SEL=primary;;
2) SEL=secondary;;
*) SEL=clipboard;;
esac

OUT=\$(${lerfanva}/bin/lerfanva <(echo \$(xclip -o -selection \$SEL)))
echo -n \$OUT | ${xclip}/bin/xclip -selection \$SEL
echo \$OUT
EOF

chmod +x $out/bin/lerfanva-clip
'';

meta = with lib; {
version = "0.1.0";
description = "Replace clipboard or selection content with its transliteration into Zbalermorna";
homepage = https://github.com/jackhumbert/zbalermorna;
platforms = platforms.linux;
license = licenses.agpl3;
};
};

mkFontDrv = name: attrs: stdenv.mkDerivation {
inherit name;
inherit (attrs) version;
src = ./.;
buildInputs = [ fontforge ];
installPhase = ''
mkdir -p $out/share/fonts/zbalermorna
./build.sh ${name}
cp fonts/${name}.otf $out/share/fonts/zbalermorna
'';

meta = {
inherit (attrs)
version
license;
description = "A font for the Zbalermorna writing system of the language Lojban";
homepage = https://github.com/jackhumbert/zbalermorna;
platforms = lib.platforms.linux;
};
};

table-zbalermorna = let version = "0.1.0"; in with ibus-engines; stdenv.mkDerivation {
name = "table-zbalermorna";
inherit version;
src = ./.;
buildInputs = [ table ];
buildPhase = ''
export HOME=$TMP
${table}/bin/ibus-table-createdb -n zlm.db -s ime/zlm.ibus
'';
installPhase = ''
TABLE_LOCATION=$out/share/ibus-table/tables
mkdir -p $TABLE_LOCATION
cp zlm.db $TABLE_LOCATION/zlm.db
# TODO: Add icon? What icon to use? Where to get it from? Where do you put it?
# cp assets/img/favicon.png $out/share/ibus-table/???
'';

meta = with lib; {
isIbusEngine = true;
inherit version;
description = "Basic input method for Zbalermorna text";
homepage = https://github.com/jackhumbert/zbalermorna;
platforms = platforms.linux;
license = licenses.lgpl3;
};
};

fonts = builtins.mapAttrs mkFontDrv (with lib.licenses; {
# I extracted versions with: grep -oE '^Version: .*$' src/*.sfd
balvi-regular = {
version = "1.001";
license = ofl;
};
crisa-light = {
version = "2.015";
license = ofl;
};
crisa-regular = {
version = "0.1";
license = ofl;
};
dunda-regular = {
version = "1.10";
# modification of Lato family
license = ofl;
};
fira-code-zlm = {
version = "1.208";
license = ofl;
};
lavi-zlm = {
version = "2.0";
license = gpl3;
};
lobster-zlm = {
version = "001.001";
license = unfree;
};
nerfopi-regular = {
version = "001.001";
license = unfree;
};
piper-karot = {
version = "1.1";
license = ofl;
};
primihi-regular = {
version = "2008.02.06";
license = publicDomain;
};
ritli-regular = {
version = "0.1";
license = gpl3;
};
tanbo-regular = {
version = "2.000";
license = asl20;
};
tisna-bold = {
version = "0.1";
license = asl20;
};
tnr-zlm = {
version = "001.000";
license = unfree;
};
unicode-drakono = {
version = "001.000";
license = unfree;
};
unicode-manri = {
version = "001.000";
license = unfree;
};
unifont = {
version = "12.1.02";
license = gpl2;
};
vrude-italic-regular = {
version = "1.200";
license = ofl;
};
vrude-regular = {
version = "1.200";
license = ofl;
};
zlm-manri = {
version = "001.000";
license = unfree;
};
zlm-template = {
version = "0.1";
license = ofl;
};
zlm-tnr = {
version = "001.000";
license = unfree;
};
});

in {
inherit
lerfanva
lerfanva-clip
table-zbalermorna;
} // fonts
135 changes: 135 additions & 0 deletions doc/installing-via-nix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Using nix to get started with Zbalermorna

(includes IME via ibus for NixOS users)

See the available packages in `./default.nix`, which includes the fonts found in `./fonts.nix`. At the time of writing this includes:
* lerfanva
* lerfanva-clip
* ibus-table
* balvi-regular
* crisa-light
* crisa-regular
* dunda-regular
* fira-code-zlm
* lavi-zlm
* lobster-zlm
* nerfopi-regular
* piper-karot
* primihi-regular
* ritli-regular
* tanbo-regular
* tisna-bold
* tnr-zlm
* unicode-drakono
* unicode-manri
* unifont
* vrude-italic-regular
* vrude-regular
* zlm-manri
* zlm-template
* zlm-tnr


## On NixOS

Using [Nix flakes](https://www.tweag.io/blog/2020-07-31-nixos-flakes/):
```
{ description = "NixOS configuration with flakes";

inputs.zbalermorna.url = github:jackhumbert/zbalermorna;

outputs = { self, nixpkgs, zbalermorna }: {
# replace <your-hostname> with your actual hostname
nixosConfigurations.<your-hostname> = nixpkgs.lib.nixosSystem {

# ...

# add to your overlay so that the packages appear in pkgs
nixpkgs.overlays = [
# ...
zbalermorna.overlay
];

# You'll want at least the typical fonts
fonts = with pkgs.zbalermorna; [ crisa-regular fira-code-zlm ];

# If you want to be able to input zbalermorna characters directly
i18n.inputMethod = {
enabled = "ibus";
ibus.engines = with pkgs.ibus-engines; [ table zbalermorna.ibus-table ];
# optional (relevant only for plasma users)
# ibus.panel = "${pkgs.plasma5.plasma-desktop}/libexec/kimpanel-ibus-panel";
};

environment.systemPackages = with pkgs.zbalermorna; [
lerfanva
lerfanva-clip
];
};
};
}
```

### Without using flakes:


Add it to your configuration.nix:
```
{ config, pkgs, ... }:

# see below for how to get zbalermorna.nix.
let
zbalermorna = pkgs.callPackage (import /path/to/zbalermorna.nix) {};

in {
# ...

# You'll want at least the typical fonts
fonts = with pkgs.zbalermorna; [ crisa-regular fira-code-zlm ];

# If you want to be able to input zbalermorna characters directly
i18n.inputMethod = {
enabled = "ibus";
ibus.engines = with pkgs.ibus-engines; [ table zbalermorna.ibus-table ];
# optional (relevant only for plasma users)
# ibus.panel = "${pkgs.plasma5.plasma-desktop}/libexec/kimpanel-ibus-panel";
};

environment.systemPackages = with pkgs.zbalermorna; [
lerfanva
lerfanva-clip
];
}

```

## Using home-manager

Note: This does not account for IME, only the fonts and lerfanva tools.

In your `home.nix`:
```nix
{ pkgs, ... }:

let
# see below for how to get zbalermorna.nix.
zbalermorna = pkgs.callPackage (import /path/to/zbalermorna.nix) {};

in {
fonts.fontconfig.enable = true;
home.packages = with zbalermorna; [
lerfanva
lerfanva-clip
crisa-regular
fira-code-zlm
];
}
```

## Getting the derivation without using flakes

```bash
cd /path/to/wherever/you/want/it
nix run nixpkgs.nix-prefetch-github -c nix-prefetch-github --nix --prefetch jackhumbert zbalermorna > zbalermorna.nix
```
or use `fetchFromGitHub` directly in the appropriate nix expression to get the source.
27 changes: 27 additions & 0 deletions flake.lock

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

Loading