Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: simplify dev flake #260

Merged
merged 3 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions dev/add-source.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -euo pipefail

_usage="
A wrapper script around \`npins\` for adding sources to catppuccin/nix

Usage: $(basename "$0") repo_name [branch]

Options:

repo_name Name of the repository in the Catppuccin org
branch Primary branch of the repository (defaults to main if omitted)
"

repo_name="${1:-}"
branch_name="${2:-main}"

if [ "${repo_name:-}" = "" ]; then
echo "error: a repository name is required!" >&2
echo "$_usage"
exit 1
fi

npins add github \
catppuccin "$repo_name" \
--directory ./.sources \
--branch "$branch_name"
22 changes: 0 additions & 22 deletions dev/add_source.sh

This file was deleted.

73 changes: 33 additions & 40 deletions dev/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,16 @@
stable = nixpkgs-stable.legacyPackages.${system};
});

forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn nixpkgsFor.${system}.unstable);
forAllSystems = nixpkgs.lib.genAttrs systems;
in
{
apps = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system}.unstable;
inherit (pkgs) lib;
in
{
lib,
pkgs,
system,
...
}:
{
add-source = {
type = "app";
program = lib.getExe (
pkgs.runCommand "add-source"
{
nativeBuildInputs = [ pkgs.makeWrapper ];
meta.mainProgram = "add-source";
}
''
mkdir -p $out/bin
install -Dm755 ${./add_source.sh} $out/bin/add-source
wrapProgram $out/bin/add-source \
--prefix PATH : ${lib.makeBinPath [ pkgs.npins ]}
''
);
};

serve = {
type = "app";
program = lib.getExe self.packages.${system}.site.serve;
Expand All @@ -73,29 +55,23 @@
);

checks = forAllSystems (
{
lib,
pkgs,
system,
...
}:
import ../tests {
inherit lib home-manager home-manager-stable;
nixpkgs = pkgs;
system:
import ../tests rec {
inherit home-manager home-manager-stable;
inherit (nixpkgs) lib;
nixpkgs = nixpkgsFor.${system}.unstable;
nixpkgs-stable = nixpkgsFor.${system}.stable;
}
);

formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
formatter = forAllSystems (system: nixpkgsFor.${system}.unstable.nixfmt-rfc-style);

packages = forAllSystems (
{
lib,
pkgs,
system,
...
}:
system:
let
pkgs = nixpkgsFor.${system}.unstable;
inherit (pkgs) lib;

version = self.shortRev or self.dirtyShortRev or "unknown";
mkOptionDoc = pkgs.callPackage ../docs/options-doc.nix { };
mkSite = pkgs.callPackage ../docs/mk-site.nix { };
Expand Down Expand Up @@ -131,6 +107,23 @@
homeManagerDoc = packages'.home-manager-doc;
};

add-source =
pkgs.runCommand "add-source"
{
nativeBuildInputs = [ pkgs.patsh ];
buildInputs = [ pkgs.npins ];
meta.mainProgram = "add-source";
}
''
mkdir -p $out/bin

patsh \
--store-dir ${builtins.storeDir} \
${./add-source.sh} $out/bin/add-source

chmod 755 $out/bin/add-source
'';

default = packages'.site;
}
);
Expand Down