Compare commits

...

16 Commits

Author SHA1 Message Date
7266a38c91 update nix channel to unstable 2024-10-25 15:00:05 +02:00
d77fd5ad2d enable ci 2024-10-25 14:56:09 +02:00
71f49aa290 update readme 2024-10-25 14:50:08 +02:00
4e26085e02 Update default.nix 2024-10-13 20:50:28 +00:00
28e562fee0 Update default.nix 2024-10-13 20:45:28 +00:00
dbb3f97799 remove unused code 2024-10-13 20:01:43 +02:00
d2f12e10f0 remove commented out lines 2024-10-13 19:40:20 +02:00
6fb5576114 update readme 2024-10-13 19:38:43 +02:00
8626e1e2f1 introduce a name variable 2024-10-13 19:33:49 +02:00
6a98c96f7a wip: generate src inputs 2024-10-13 19:17:19 +02:00
a8a62dde7f add note to README 2024-10-13 01:21:26 +02:00
dbba1430b0 add gayathri 2024-10-13 01:10:37 +02:00
9c53e5c3df update readme 2024-10-12 23:43:53 +02:00
3ba0bdc364 perform minor refactor 2024-10-12 23:31:59 +02:00
21592dc57d modify font install to match that of most fonts on nix github 2024-10-12 19:40:31 +02:00
16cf16e2c4 update flake description 2024-10-12 17:54:24 +02:00
9 changed files with 197 additions and 99 deletions

7
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,7 @@
stages:
- build
build:
stage: build
image: nixpkgs/nix:latest
script: nix build . --extra-experimental-features "nix-command flakes"

View File

@@ -1,3 +1,56 @@
# WIP SMC fonts flake SMC fonts flake
This is a WIP Flake that can install SMCs fonts. This is a nix flake that installs all SMC fonts.
## Using with a flakes+home-manager based nixOS setup
In the inputs section
```
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# Other flakes/modules/inputs
smcFonts.url = "gitlab:smc/smc-fonts-flake/trunk";
smcFonts.inputs.nixpkgs.follows = "nixpkgs";
};
```
In the outputs section of the flake:
```
# Note the smcFonts being passed as an argument
outputs = { self, nixpkgs, smcFonts, <other inputs> }@inputs:
let platforms = [ "x86_64-linux" ];
in {
nixosConfigurations = {
hex = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { inherit inputs; }; # <-- The inputs are being passed down to the modules
modules = [
(import ./hosts/default.nix)
];
};
};
}
```
Lastly, in `default.nix`
```
{ config, lib, pkgs, modulesPath, inputs, ... }: # <-- "inputs" is an argument
let
smc-fonts = inputs.smcFonts.packages."${pkgs.system}".default; # <-- by default, it will install all fonts
in
{
home-manager.users.<username> = { pkgs, ...}: {
home.packages = with pkgs; [
# list of home manager packages
smc-fonts # what we defined above.
```

View File

@@ -1,24 +0,0 @@
{ pkgs, ... }:
pkgs.stdenv.mkDerivation {
version = "7.1";
pname = "anjali-old-lipi";
src = pkgs.fetchzip {
url = "https://smc.org.in/downloads/fonts/anjalioldlipi/anjalioldlipi.zip";
hash = "sha256-c3ScpdN2h39Q6GLFL97pBBGrsillcMXmhlGilOAdF1w=";
stripRoot = false;
};
installPhase = ''
install -Dm444 -t $out/share/fonts/truetype $src/*.ttf
'';
meta = with pkgs.lib; {
homepage = "https://smc.org.in/fonts/manjari";
description = "Anjali Old Lipi Malayalam Typeface";
license = licenses.ofl;
platforms = platforms.all;
maintainers = with maintainers; [ aashiks ];
};
}

View File

@@ -1,24 +0,0 @@
{ pkgs, ... }:
pkgs.stdenv.mkDerivation {
version = "1.7";
pname = "chilanka";
src = pkgs.fetchzip {
url = "https://smc.org.in/downloads/fonts/chilanka/chilanka.zip";
hash = "sha256-z+pRvm/8alA3TbUBuR4oDD/kpvuXJTqOBlzXEKBZvnE=";
stripRoot = false;
};
installPhase = ''
install -Dm444 -t $out/share/fonts/truetype $src/*.ttf
'';
meta = with pkgs.lib; {
homepage = "https://smc.org.in/fonts/chilanka";
description = "Chilanka Malayalam Typeface";
license = licenses.ofl;
platforms = platforms.all;
maintainers = with maintainers; [ aashiks ];
};
}

View File

@@ -1,7 +1,76 @@
{ pkgs, ... }: { stdenv, fetchzip, lib
# To select only certain fonts, put a list of strings to `fonts`: every key in
# ./shas.nix is an optional font
, fonts ? [ ] }:
{ let
manjari = pkgs.callPackage ./manjari { }; version = "version-20241013";
anjali-old-lipi = pkgs.callPackage ./anjali-old-lipi { }; fontsShas = import ./shas.nix;
chilanka = pkgs.callPackage ./chilanka { }; knownFonts = builtins.attrNames fontsShas;
} selectedFonts = if (fonts == [ ]) then
knownFonts
else
let unknown = lib.subtractLists knownFonts fonts;
in if (unknown != [ ]) then
throw "Unknown font(s): ${lib.concatStringsSep " " unknown}"
else
fonts;
# Filter the fonts by selectedFonts list
filteredFonts =
builtins.filter (fontName: builtins.elem fontName selectedFonts)
(builtins.attrNames fontsShas);
# Function to generate a list of srcs that look like
# [
# (fetchurl {
# name = "namezzxs"
# url = "";
# sha256 = "sha256-abc123...";
# })
# (fetchurl {
# name = "namezzxy"
# url = "";
# sha256 = "sha256-def456...";
# })
# ]
generateUrls = fontAttrs: fontName:
builtins.map (variant:
let sha = fontAttrs.${variant};
in fetchzip {
name = "${fontName}-${variant}";
url = "https://smc.org.in/downloads/fonts/${fontName}/${variant}.zip";
sha256 = sha;
stripRoot = false;
}) (builtins.attrNames fontAttrs);
# Generate srcs for the filtered fonts
srcs = builtins.concatLists
(builtins.map (fontName: generateUrls fontsShas.${fontName} fontName)
filteredFonts);
in stdenv.mkDerivation (finalAttrs: {
inherit version;
inherit srcs;
pname = "smc-fonts";
sourceRoot = ".";
buildPhase = ''
echo "selected fonts are ${toString selectedFonts}"
ls *.otf *.ttf
'';
installPhase = ''
find -name \*.otf -exec mkdir -p $out/share/fonts/opentype/SMCFonts \; -exec mv {} $out/share/fonts/opentype/SMCFonts \;
find -name \*.ttf -exec mkdir -p $out/share/fonts/truetype/SMCFonts \; -exec mv {} $out/share/fonts/truetype/SMCFonts \;
'';
meta = with lib; {
description = "Malayalam typefaces made by smc.org.in";
longDescription = ''
Swathanthra Malayalam Computing (SMC) is a free software collective engaged in the development, localization, standardization and popularization of various Free and Open Source Software in the Malayalam language. This derivation builds all fonts made by SMC.
'';
homepage = "https://smc.org.in/";
license = licenses.ofl;
platforms = platforms.all;
maintainers = with maintainers; [ aashiks ];
};
})

6
flake.lock generated
View File

@@ -20,11 +20,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1721924956, "lastModified": 1728492678,
"narHash": "sha256-Sb1jlyRO+N8jBXEX9Pg9Z1Qb8Bw9QyOgLDNMEpmjZ2M=", "narHash": "sha256-9UTxR8eukdg+XZeHgxW5hQA9fIKHsKCdOIUycTryeVw=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "5ad6a14c6bf098e98800b091668718c336effc95", "rev": "5633bcff0c6162b9e4b5f1264264611e950c8ec7",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@@ -1,5 +1,5 @@
{ {
description = "A very basic flake"; description = "A flake that installs SMC fonts. It follows unstable.";
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
@@ -10,23 +10,12 @@
with inputs; with inputs;
flake-utils.lib.eachDefaultSystem (system: flake-utils.lib.eachDefaultSystem (system:
let let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = import nixpkgs { inherit system; };
font-smc-manjari = pkgs.callPackage ./manjari/default.nix { }; fonts-smc = pkgs.callPackage ./default.nix { };
font-smc-anjali-old-lipi =
pkgs.callPackage ./anjali-old-lipi/default.nix { };
font-smc-chilanka = pkgs.callPackage ./chilanka/default.nix { };
in rec { in rec {
packages = { packages = {
smc-anjali-old-lipi = font-smc-anjali-old-lipi; smc-fonts = fonts-smc;
smc-manjari = font-smc-manjari; default = fonts-smc;
smc-chilanka = font-smc-chilanka;
all = pkgs.symlinkJoin {
name = "all";
paths =
[ font-smc-anjali-old-lipi font-smc-chilanka font-smc-manjari ];
};
default = packages.all;
}; };
}); });
} }

View File

@@ -1,24 +0,0 @@
{ pkgs, ... }:
pkgs.stdenv.mkDerivation {
version = "2.200";
pname = "manjari";
src = pkgs.fetchzip {
url = "https://smc.org.in/downloads/fonts/manjari/manjari.zip";
hash = "sha256-Sq/7UOBO54c3id6FMZeOmnZTRceEkMAAN8W+C7v7Mtw=";
stripRoot = false;
};
installPhase = ''
install -Dm444 -t $out/share/fonts/opentype $src/*.otf
'';
meta = with pkgs.lib; {
homepage = "https://smc.org.in/fonts/manjari";
description = "Manjari Malayalam Typeface";
license = licenses.ofl;
platforms = platforms.all;
maintainers = with maintainers; [ aashiks ];
};
}

52
shas.nix Normal file
View File

@@ -0,0 +1,52 @@
{
# Font name , variant and sha
"anjalioldlipi" = {
"anjalioldlipi" = "sha256-c3ScpdN2h39Q6GLFL97pBBGrsillcMXmhlGilOAdF1w=";
};
"chilanka" = {
"chilanka" = "sha256-z+pRvm/8alA3TbUBuR4oDD/kpvuXJTqOBlzXEKBZvnE=";
};
"dyuthi" = {
"dyuthi" = "sha256-H+2ccvHmlZjtH8KfWBSQKPtMkY/NsydHqFNaTzLS4S8=";
};
"gayathri" = {
"gayathri" = "sha256-p9KZi31Na4hfUuDsKj4OXjc9s6J/8xMeuszlL5oVauQ=";
};
"karumbi" = {
"karumbi" = "sha256-aeKH7CWbJNtkgv1PsaWWxyBZor+UO9q9Cctpc/qnEQU=";
};
"keraleeyam" = {
"keraleeyam" = "sha256-UEhDtBaWof/2C36IapGhtYgdeQInUn+A/UAJIF7+RuA=";
};
"malini" = {
"Malini" = "sha256-LvXf1zAlLvZhn2/peRVjOPjQwG46mMP8Dxuvs4fmK1s=";
};
"manjari" = {
"manjari" = "sha256-Sq/7UOBO54c3id6FMZeOmnZTRceEkMAAN8W+C7v7Mtw=";
};
"meera" = {
"meera" = "sha256-yaqA2gYKc4OJ9YxmvQPUZ3qZFyKj0YciMaUoY1SST4I=";
};
"nupuram" = {
"Nupuram-Arrows-Color" =
"sha256-oFsUCu3mDuHok7BXPnb1VdKmqP7DTw6TXKv6iXDknzA=";
"Nupuram-Calligraphy" =
"sha256-R2fPKe5PZqWu4ftV3/iVZptBhq9rku7EcXQGzGgylns=";
"Nupuram-Color" = "sha256-JwanvoGtI3BrG/DxGreo+gVZNGPjLiQA31nheNcuZWw=";
"Nupuram-Dots" = "sha256-5V09G4PkDnHHd/oIRe3kHX6BOQ5HuVVcFSlae32bdVs=";
};
"rachana" = {
"rachana" = "sha256-csfMs4B6BD+yap/AaWpm4kQDsR/WNMrym6szM5iZNJo=";
};
"raghumalayalamsans" = {
"raghumalayalamsans" =
"sha256-rSM77MiFqRzs67mme8xkJZkw13esB9eG13j8OzytCaA=";
};
"suruma" = {
"suruma" = "sha256-x4ybBr5oCwD5Stu8rRGndOYRzaV6ikE+VnLJ/src+1U=";
};
"uroob" = {
"uroob" = "sha256-IJcKD3cDRMA7G7foKtXtJxOrv6OeOujkq9+uGo+R/dY=";
};
}