Skip to content

Commit

Permalink
add flake-compat, fixup some issues, update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jpetrucciani committed Nov 1, 2024
1 parent 06e806f commit 71f246a
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 4 deletions.
5 changes: 4 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{ pkgs ? import <nixpkgs> { }, system ? pkgs.system }:
{ _compat ? import ./flake-compat.nix
, pkgs ? import _compat.inputs.nixpkgs { }
, system ? pkgs.system
}:
let
params = { inherit pkgs system; };
pog = import ./pog params;
Expand Down
43 changes: 41 additions & 2 deletions docs/basic-examples.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
## basic examples
# basic examples

## github tags fetcher

```nix
TODO
github_tags = pog.pog {
name = "github_tags";
description = "a nice wrapper for getting github tags for a repo!";
flags = [
{
name = "latest";
description = "fetch only the latest tag";
bool = true;
}
pog._.flags.github.owner
pog._.flags.github.repo
];
script = helpers: ''
tags="$(${pog._.curl} -Ls "https://api.github.com/repos/''${owner}/''${repo}/tags" |
${pkgs.lib.getExe pkgs.jaq} -r '.[].name')"
if ${helpers.flag "latest"}; then
echo "$tags" | ${pog._.head} -n 1
else
echo "$tags"
fi
'';
};
```

### generated docs

```bash
Usage: github_tags [-l|--latest] [-o|--owner VAR] [-r|--repo VAR]

a nice wrapper for getting github tags for a repo!

Flags:
-l, --latest fetch only the latest tag [bool]
-o, --owner the github user or organization that owns the repo [will prompt if not passed in]
-r, --repo the github repo to pull tags from [will prompt if not passed in]
-h, --help print this help and exit
-v, --verbose enable verbose logging and info
--no-color disable color and other formatting
```
2 changes: 2 additions & 0 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Getting Started

## fetchTarball + import

```nix
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ features:
title: Pure Nix Power
details: Create comprehensive CLI tools using pure Nix, leveraging the vast nixpkgs ecosystem
- icon: 📖
title: Auto-Documentation
title: Automatic Documentation
details: Automatic help text generation, documentation, and tab completion out of the box
- icon: 🎯
title: Rich Flag System
Expand Down
9 changes: 9 additions & 0 deletions flake-compat.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
let
inherit (builtins) fromJSON readFile;
lock = fromJSON (readFile ./flake.lock);
flake-compat = with lock.nodes.flake-compat.locked; import (fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
sha256 = narHash;
});
in
(flake-compat { src = ./.; }).defaultNix
17 changes: 17 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
description = "pog";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-compat = {
flake = false;
url = "github:edolstra/flake-compat";
};
flake-utils.url = "github:numtide/flake-utils";
};

Expand Down

0 comments on commit 71f246a

Please sign in to comment.