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:
parent
6459b5a4a7
commit
65543d2402
3 changed files with 60 additions and 62 deletions
27
dev/add-source.sh
Executable file
27
dev/add-source.sh
Executable 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"
|
|
@ -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"
|
|
|
@ -37,34 +37,16 @@
|
||||||
stable = nixpkgs-stable.legacyPackages.${system};
|
stable = nixpkgs-stable.legacyPackages.${system};
|
||||||
});
|
});
|
||||||
|
|
||||||
forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn nixpkgsFor.${system}.unstable);
|
forAllSystems = nixpkgs.lib.genAttrs systems;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
apps = forAllSystems (
|
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 = {
|
serve = {
|
||||||
type = "app";
|
type = "app";
|
||||||
program = lib.getExe self.packages.${system}.site.serve;
|
program = lib.getExe self.packages.${system}.site.serve;
|
||||||
|
@ -73,29 +55,23 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
checks = forAllSystems (
|
checks = forAllSystems (
|
||||||
{
|
system:
|
||||||
lib,
|
import ../tests rec {
|
||||||
pkgs,
|
inherit home-manager home-manager-stable;
|
||||||
system,
|
inherit (nixpkgs) lib;
|
||||||
...
|
nixpkgs = nixpkgsFor.${system}.unstable;
|
||||||
}:
|
|
||||||
import ../tests {
|
|
||||||
inherit lib home-manager home-manager-stable;
|
|
||||||
nixpkgs = pkgs;
|
|
||||||
nixpkgs-stable = nixpkgsFor.${system}.stable;
|
nixpkgs-stable = nixpkgsFor.${system}.stable;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
|
formatter = forAllSystems (system: nixpkgsFor.${system}.unstable.nixfmt-rfc-style);
|
||||||
|
|
||||||
packages = forAllSystems (
|
packages = forAllSystems (
|
||||||
{
|
system:
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
system,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
let
|
||||||
|
pkgs = nixpkgsFor.${system}.unstable;
|
||||||
|
inherit (pkgs) lib;
|
||||||
|
|
||||||
version = self.shortRev or self.dirtyShortRev or "unknown";
|
version = self.shortRev or self.dirtyShortRev or "unknown";
|
||||||
mkOptionDoc = pkgs.callPackage ../docs/options-doc.nix { };
|
mkOptionDoc = pkgs.callPackage ../docs/options-doc.nix { };
|
||||||
mkSite = pkgs.callPackage ../docs/mk-site.nix { };
|
mkSite = pkgs.callPackage ../docs/mk-site.nix { };
|
||||||
|
@ -131,6 +107,23 @@
|
||||||
homeManagerDoc = packages'.home-manager-doc;
|
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;
|
default = packages'.site;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue