refactor: use flake-parts for better management of per-system flake attributes
This commit is contained in:
parent
0c964e1d5c
commit
b28b8455a9
2 changed files with 81 additions and 74 deletions
|
@ -1,20 +1,20 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"flake-utils": {
|
"flake-parts": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"systems": "systems"
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1726560853,
|
"lastModified": 1727826117,
|
||||||
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
|
"narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=",
|
||||||
"owner": "numtide",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-parts",
|
||||||
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
|
"rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "numtide",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-parts",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -34,29 +34,26 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"nixpkgs-lib": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1727825735,
|
||||||
|
"narHash": "sha256-0xHYkMkeLVQAMa7gvkddbPqpxph+hDzdu1XdGPJR+Os=",
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz"
|
||||||
|
}
|
||||||
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils",
|
"flake-parts": "flake-parts",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"typix": "typix",
|
"typix": "typix",
|
||||||
"typst-packages": "typst-packages"
|
"typst-packages": "typst-packages"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systems": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"typix": {
|
"typix": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
|
|
108
2024/flake.nix
108
2024/flake.nix
|
@ -9,7 +9,7 @@
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
|
|
||||||
typst-packages = {
|
typst-packages = {
|
||||||
url = "github:typst/packages";
|
url = "github:typst/packages";
|
||||||
|
@ -25,58 +25,68 @@
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
inputs@{
|
inputs@{
|
||||||
nixpkgs,
|
flake-parts,
|
||||||
typix,
|
|
||||||
flake-utils,
|
|
||||||
self,
|
self,
|
||||||
|
typix,
|
||||||
|
typst-packages,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
flake-utils.lib.eachDefaultSystem (
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
system:
|
systems = [
|
||||||
let
|
"x86_64-linux"
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
"aarch64-linux"
|
||||||
in
|
"x86_64-darwin"
|
||||||
let
|
"aarch64-darwin"
|
||||||
typstPackagesSrc = "${inputs.typst-packages}/packages";
|
];
|
||||||
|
flake = {
|
||||||
typstPackagesCache = pkgs.stdenv.mkDerivation {
|
hydraJobs = {
|
||||||
name = "typst-packages-cache";
|
legacyPackages."x86_64-linux" = self.legacyPackages."x86_64-linux";
|
||||||
src = typstPackagesSrc;
|
|
||||||
dontBuild = true;
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p "$out/typst/packages"
|
|
||||||
cp -LR --reflink=auto --no-preserve=mode -t "$out/typst/packages" "$src"/*
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
typixLib = typix.lib.${system};
|
|
||||||
in
|
|
||||||
let
|
|
||||||
alexandriaLib = import ./nix/lib {
|
|
||||||
inherit pkgs typixLib typstPackagesCache;
|
|
||||||
};
|
|
||||||
|
|
||||||
in
|
|
||||||
{
|
|
||||||
legacyPackages = (
|
|
||||||
(alexandriaLib.indexByName ./documents/by-name)
|
|
||||||
// (alexandriaLib.indexByCourse ./documents/by-course)
|
|
||||||
);
|
|
||||||
# devShells.default = typixLib.devShell {
|
|
||||||
# inherit (commonArgs) fontPaths virtualPaths;
|
|
||||||
# packages = [
|
|
||||||
# # WARNING: Don't run `typst-build` directly, instead use `nix run .#build`
|
|
||||||
# # See https://github.com/loqusion/typix/issues/2
|
|
||||||
# # build-script
|
|
||||||
# watch-script
|
|
||||||
# # More packages can be added here, like typstfmt
|
|
||||||
# pkgs.typstyle
|
|
||||||
# ];
|
|
||||||
# };
|
|
||||||
}
|
|
||||||
)
|
|
||||||
// {
|
|
||||||
hydraJobs = {
|
|
||||||
legacyPackages."x86_64-linux" = self.legacyPackages."x86_64-linux";
|
|
||||||
};
|
};
|
||||||
|
perSystem =
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
system,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
typstPackagesSrc = "${typst-packages}/packages";
|
||||||
|
|
||||||
|
typstPackagesCache = pkgs.stdenv.mkDerivation {
|
||||||
|
name = "typst-packages-cache";
|
||||||
|
src = typstPackagesSrc;
|
||||||
|
dontBuild = true;
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p "$out/typst/packages"
|
||||||
|
cp -LR --reflink=auto --no-preserve=mode -t "$out/typst/packages" "$src"/*
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
typixLib = typix.lib.${system};
|
||||||
|
in
|
||||||
|
let
|
||||||
|
alexandriaLib = import ./nix/lib {
|
||||||
|
inherit pkgs typixLib typstPackagesCache;
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
{
|
||||||
|
legacyPackages = (
|
||||||
|
(alexandriaLib.indexByName ./documents/by-name)
|
||||||
|
// (alexandriaLib.indexByCourse ./documents/by-course)
|
||||||
|
);
|
||||||
|
# devShells.default = typixLib.devShell {
|
||||||
|
# inherit (commonArgs) fontPaths virtualPaths;
|
||||||
|
# packages = [
|
||||||
|
# # WARNING: Don't run `typst-build` directly, instead use `nix run .#build`
|
||||||
|
# # See https://github.com/loqusion/typix/issues/2
|
||||||
|
# # build-script
|
||||||
|
# watch-script
|
||||||
|
# # More packages can be added here, like typstfmt
|
||||||
|
# pkgs.typstyle
|
||||||
|
# ];
|
||||||
|
# };
|
||||||
|
formatter = pkgs.nixfmt-rfc-style;
|
||||||
|
};
|
||||||
|
# // {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue