Skip to content

Commit

Permalink
fix: use correct nixfmt package (#461)
Browse files Browse the repository at this point in the history
* revert: "style: format 6c244e5"

Refs: b5309c1.

* fix: use correct nixfmt package
  • Loading branch information
getchoo authored Jan 22, 2025
1 parent b5309c1 commit 06f0ea1
Show file tree
Hide file tree
Showing 89 changed files with 2,012 additions and 1,132 deletions.
58 changes: 34 additions & 24 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,31 +1,40 @@
{ 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;
collected = lib.packagesFromDirectoryRecursive {
callPackage = lib.callPackageWith (pkgs // catppuccinPackages);
directory = ./pkgs;
};
in
generated // collected;
in

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 @@ -34,8 +43,9 @@ 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: 42 additions & 22 deletions dev/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@
};
};

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

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

in eachDefaultSystem (system:
eachDefaultSystem (
system:

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

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

in {
apps = { serve = mkApp' self.packages.${system}.site.serve; };
{
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"}/";
urlPrefix = "https://github.com/catppuccin/nix/tree/${catppuccin.rev or "main"}/";
in

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

Expand Down
17 changes: 13 additions & 4 deletions docs/mk-site.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
{ 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 @@ -32,4 +40,5 @@ stdenvNoCC.mkDerivation (finalAttrs:
'';
};
};
})
}
)
106 changes: 61 additions & 45 deletions docs/package.nix
Original file line number Diff line number Diff line change
@@ -1,57 +1,71 @@
{ 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

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

Expand All @@ -61,17 +75,19 @@ in 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 06f0ea1

Please sign in to comment.