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": {
|
||||
"flake-utils": {
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1726560853,
|
||||
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
|
||||
"lastModified": 1727826117,
|
||||
"narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
|
@ -34,29 +34,26 @@
|
|||
"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": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"flake-parts": "flake-parts",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"typix": "typix",
|
||||
"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": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
|
|
108
2024/flake.nix
108
2024/flake.nix
|
@ -9,7 +9,7 @@
|
|||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
|
||||
typst-packages = {
|
||||
url = "github:typst/packages";
|
||||
|
@ -25,58 +25,68 @@
|
|||
|
||||
outputs =
|
||||
inputs@{
|
||||
nixpkgs,
|
||||
typix,
|
||||
flake-utils,
|
||||
flake-parts,
|
||||
self,
|
||||
typix,
|
||||
typst-packages,
|
||||
...
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
let
|
||||
typstPackagesSrc = "${inputs.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"/*
|
||||
'';
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
flake = {
|
||||
hydraJobs = {
|
||||
legacyPackages."x86_64-linux" = self.legacyPackages."x86_64-linux";
|
||||
};
|
||||
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