Skip to content

Commit

Permalink
style: format 6c244e5
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jan 22, 2025
1 parent 6c244e5 commit b5309c1
Show file tree
Hide file tree
Showing 89 changed files with 1,132 additions and 2,012 deletions.
58 changes: 24 additions & 34 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,40 +1,31 @@
{
pkgs ? import <nixpkgs> {
inherit system;
config = { };
overlays = [ ];
},
lib ? pkgs.lib,
system ? builtins.currentSystem,
}:
{ pkgs ? import <nixpkgs> {
inherit system;
config = { };
overlays = [ ];
}, lib ? pkgs.lib, system ? builtins.currentSystem, }:

let
catppuccinPackages =
let
generated = lib.foldlAttrs (
acc: port:
{ rev, hash }:
lib.recursiveUpdate acc {
# Save our sources for each port
sources.${port} = catppuccinPackages.fetchCatppuccinPort { inherit port rev hash; };
catppuccinPackages = let
generated = lib.foldlAttrs (acc: port:
{ rev, hash }:
lib.recursiveUpdate acc {
# Save our sources for each port
sources.${port} =
catppuccinPackages.fetchCatppuccinPort { inherit port rev hash; };

# And create a default package for them
"${port}" = catppuccinPackages.buildCatppuccinPort { pname = port; };
}
) { } (lib.importJSON ./pkgs/sources.json);
# And create a default package for them
"${port}" = catppuccinPackages.buildCatppuccinPort { pname = port; };
}) { } (lib.importJSON ./pkgs/sources.json);

collected = lib.packagesFromDirectoryRecursive {
callPackage = lib.callPackageWith (pkgs // catppuccinPackages);
directory = ./pkgs;
};
in
generated // collected;
in
collected = lib.packagesFromDirectoryRecursive {
callPackage = lib.callPackageWith (pkgs // catppuccinPackages);
directory = ./pkgs;
};
in generated // collected;

{
in {
# Filter out derivations not available on/meant for the current system
packages = lib.filterAttrs (lib.const (
deriv:
packages = lib.filterAttrs (lib.const (deriv:
let
# Only export packages available on the current system, *unless* they are being cross compiled
availableOnHost = lib.meta.availableOn pkgs.stdenv.hostPlatform deriv;
Expand All @@ -43,9 +34,8 @@ in
isCross = deriv.stdenv.buildPlatform != deriv.stdenv.targetPlatform;
# Make sure we don't remove our functions
isFunction = lib.isFunction deriv;
in
isFunction || (!broken) && availableOnHost || isCross
)) catppuccinPackages;
in isFunction || (!broken) && availableOnHost || isCross))
catppuccinPackages;

shell = import ./shell.nix { inherit pkgs; };
}
64 changes: 22 additions & 42 deletions dev/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,7 @@
};
};

outputs =
{
self,
nixpkgs,
catppuccin,
...
}@inputs:
outputs = { self, nixpkgs, catppuccin, ... }@inputs:

let
inherit (nixpkgs) lib;
Expand All @@ -63,10 +57,8 @@
"v1.2" = inputs.catppuccin-v1_2;
"rolling" = catppuccin;
};
in

eachDefaultSystem (
system:
in eachDefaultSystem (system:

let
pkgs = nixpkgs.legacyPackages.${system};
Expand All @@ -76,48 +68,36 @@

callWith = pkgs: lib.flip pkgs.callPackage;
callUnstable = callWith pkgs { inherit (inputs) home-manager; };
callStable = callWith pkgsStable { home-manager = inputs.home-manager-stable; };
in
callStable =
callWith pkgsStable { home-manager = inputs.home-manager-stable; };

{
apps = {
serve = mkApp' self.packages.${system}.site.serve;
};
in {
apps = { serve = mkApp' self.packages.${system}.site.serve; };

checks =
{
darwin = {
test-unstable = callUnstable (catppuccin + "/modules/tests/darwin.nix");
test-stable = callStable (catppuccin + "/modules/tests/darwin.nix");
};
checks = {
darwin = {
test-unstable =
callUnstable (catppuccin + "/modules/tests/darwin.nix");
test-stable = callStable (catppuccin + "/modules/tests/darwin.nix");
};

linux = {
test-unstable = callUnstable (catppuccin + "/modules/tests/nixos.nix");
test-stable = callStable (catppuccin + "/modules/tests/nixos.nix");
};
}
.${kernelName} or { };
linux = {
test-unstable =
callUnstable (catppuccin + "/modules/tests/nixos.nix");
test-stable = callStable (catppuccin + "/modules/tests/nixos.nix");
};
}.${kernelName} or { };

packages = {
# Used in CI
all-ports = pkgs.linkFarm "all-ports" (
lib.foldlAttrs (
acc: name: pkg:
if pkg ? "outPath" then
acc
// {
${name} = pkg.outPath;
}
else
acc
) { } (lib.removeAttrs catppuccin.packages.${system} [ "default" ])
);
all-ports = pkgs.linkFarm "all-ports" (lib.foldlAttrs (acc: name: pkg:
if pkg ? "outPath" then acc // { ${name} = pkg.outPath; } else acc)
{ } (lib.removeAttrs catppuccin.packages.${system} [ "default" ]));

site = pkgs.callPackage (catppuccin + "/docs/package.nix") {
inherit inputs searchVersions;
nuscht-search = inputs.nuscht-search.packages.${system};
};
};
}
);
});
}
6 changes: 3 additions & 3 deletions docs/mk-search.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
{ catppuccin, versionName }:

let
urlPrefix = "https://github.com/catppuccin/nix/tree/${catppuccin.rev or "main"}/";
in
urlPrefix =
"https://github.com/catppuccin/nix/tree/${catppuccin.rev or "main"}/";

mkMultiSearch {
in mkMultiSearch {
title = "catppuccin/nix Option Search";
baseHref = "/search/${versionName}/";

Expand Down
17 changes: 4 additions & 13 deletions docs/mk-site.nix
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
{
lib,
stdenvNoCC,
mdbook,
python3,
writeShellApplication,
}:
{ lib, stdenvNoCC, mdbook, python3, writeShellApplication, }:

args:

stdenvNoCC.mkDerivation (
finalAttrs:
args
// {
stdenvNoCC.mkDerivation (finalAttrs:
args // {
nativeBuildInputs = args.nativeBuildInputs or [ ] ++ [ mdbook ];

dontConfigure = true;
Expand Down Expand Up @@ -40,5 +32,4 @@ stdenvNoCC.mkDerivation (
'';
};
};
}
)
})
106 changes: 45 additions & 61 deletions docs/package.nix
Original file line number Diff line number Diff line change
@@ -1,71 +1,57 @@
{
lib,
callPackage,
linkFarm,
writeText,
{ lib, callPackage, linkFarm, writeText,

nuscht-search,
inputs,
/*
Should be in the format of
nuscht-search, inputs,
/* Should be in the format of
```
{
<version name> = <flake input>;
}
```
```
{
<version name> = <flake input>;
}
```
i.e.,
i.e.,
```
{
"v1.1" = catppuccin_v1_1;
"rolling" = catppuccin;
}
*/
searchVersions ? null,
}:
```
{
"v1.1" = catppuccin_v1_1;
"rolling" = catppuccin;
}
*/
searchVersions ? null, }:

assert lib.assertMsg (
searchVersions != null
) "./docs/package.nix: `searchVersions` must be provided";
assert lib.assertMsg (searchVersions != null)
"./docs/package.nix: `searchVersions` must be provided";

let
inherit (inputs) catppuccin;

mkSite = callPackage ./mk-site.nix { };
mkSearchInstance = callPackage ./mk-search.nix {
inherit (nuscht-search) mkMultiSearch;
};
mkSearchInstance =
callPackage ./mk-search.nix { inherit (nuscht-search) mkMultiSearch; };

# Collect the latest stable version from the `searchVersions` given
latestStableVersion =
let
latest = lib.foldl' (
latest: versionName:
if (versionName != "rolling" && lib.versionOlder latest (lib.removePrefix "v" versionName)) then
versionName
else
latest
) "0" (lib.attrNames searchVersions);
in
assert lib.assertMsg (latest != "0") "Unable to determine latest stable version!";
latest;
latestStableVersion = let
latest = lib.foldl' (latest: versionName:
if (versionName != "rolling"
&& lib.versionOlder latest (lib.removePrefix "v" versionName)) then
versionName
else
latest) "0" (lib.attrNames searchVersions);
in assert lib.assertMsg (latest != "0")
"Unable to determine latest stable version!";
latest;

# Then create a search instance for each one
searchInstances = lib.mapAttrs (
versionName: catppuccin: mkSearchInstance { inherit catppuccin versionName; }
) searchVersions;
searchInstances = lib.mapAttrs (versionName: catppuccin:
mkSearchInstance { inherit catppuccin versionName; }) searchVersions;

# Create an html page for redirecting to a given endpoint
redirectTo =
endpoint:
redirectTo = endpoint:
writeText "index.html" ''
<meta http-equiv="refresh" content="0;url=${endpoint}">
'';
in

mkSite {
in mkSite {
pname = "catppuccin-nix-site";
version = catppuccin.shortRev or catppuccin.dirtyShortRev or "unknown";

Expand All @@ -75,19 +61,17 @@ mkSite {

postInstall = ''
ln -sf ${
linkFarm "search-engines" (
[
{
name = "stable.html";
path = redirectTo "/search/${latestStableVersion}/";
}
{
name = "index.html";
path = redirectTo "/search/stable.html";
}
]
++ lib.mapAttrsToList (name: path: { inherit name path; }) searchInstances
)
linkFarm "search-engines" ([
{
name = "stable.html";
path = redirectTo "/search/${latestStableVersion}/";
}
{
name = "index.html";
path = redirectTo "/search/stable.html";
}
] ++ lib.mapAttrsToList (name: path: { inherit name path; })
searchInstances)
} $out/search
'';
}
Loading

0 comments on commit b5309c1

Please sign in to comment.