chore: simplify dev flake (#260)

* chore: simplify dev flake

* chore: use patsh for `add-source`

* chore: improve `add-source` help output
This commit is contained in:
seth 2024-06-30 04:17:47 -04:00 committed by GitHub
parent 6459b5a4a7
commit 65543d2402
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 60 additions and 62 deletions

27
dev/add-source.sh Executable file
View file

@ -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"

View file

@ -1,22 +0,0 @@
#!/usr/bin/env bash
set -e
_usage="
Usage: add-source <repo_name> [branch]
repo_name: Name of the repository in the Catppuccin org (required)
branch: Primary branch of the repository (optional, defaults to main)
"
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"

View file

@ -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;
@ -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 { };
@ -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;
}
);