diff --git a/dev/add-source.sh b/dev/add-source.sh new file mode 100755 index 0000000..5f62caa --- /dev/null +++ b/dev/add-source.sh @@ -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" diff --git a/dev/add_source.sh b/dev/add_source.sh deleted file mode 100644 index 7c0bee0..0000000 --- a/dev/add_source.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash -set -e - -_usage=" -Usage: add-source [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" diff --git a/dev/flake.nix b/dev/flake.nix index a3eb30d..7dadc9d 100644 --- a/dev/flake.nix +++ b/dev/flake.nix @@ -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; } );