Skip to content

Commit

Permalink
Merge pull request #34 from ptitfred/move-to-flakes
Browse files Browse the repository at this point in the history
Move to Flakes
  • Loading branch information
ptitfred authored Aug 4, 2023
2 parents 95d6eea + 63fedf4 commit 1724240
Show file tree
Hide file tree
Showing 36 changed files with 239 additions and 193 deletions.
29 changes: 7 additions & 22 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v18
with:
nix_path: nixpkgs=channel:nixos-20.09
- run: nix-build nix/release.nix
- uses: cachix/install-nix-action@v22
- run: nix build

lint-shell:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v18
with:
nix_path: nixpkgs=channel:nixos-20.09
- run: nix-shell --command tests/lint-shell.sh

lint-nix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v18
with:
nix_path: nixpkgs=channel:nixos-20.09
- run: nix-shell --command tests/lint-nix.sh
- uses: cachix/install-nix-action@v22
- run: nix run .#lint

spell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v18
with:
nix_path: nixpkgs=channel:nixos-20.09
- run: nix-shell --command tests/spell.sh
- uses: cachix/install-nix-action@v22
- run: nix run .#spell
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.*.swp
result
85 changes: 36 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,58 +12,56 @@ properly use it as is.
## What's in the toolbox

A collection of script to add to your PATH:
- [git-authors](src/git-authors), a git script to list committers other a commit range
- [git-bubbles](src/git-bubbles), a git script to handle pull requests
- [git-checkout-log](src/git-checkout-log), a git script to browser reflog and follow checkouts
- [git-prd](src/git-prd), a git script to display the path of the root of a git repository relative to your HOME directory
- [git-pwd](src/git-pwd), a git script to display the path relative to the root of a git repository
- [git-rm-others](src/git-rm-others), a git script to clean the working copy from untracked files
- [git-search](src/git-search), a git script to search the diff other a commit range
- [git-short](src/git-short), a git script to display short SHA1 of a given commit
- [git-std-init](src/git-std-init), a git script to setup a repository with an initial empty commit and a base and master branches
- [git-tree](src/git-tree), a git script to tree files handled by git
- [prd](src/prd), a script to print the working directory relative to your HOME directory
- [repeat](src/repeat), a script to repeat a command some times
- [short-path](src/short-path), a script to abbreviate every directory unless the last part of a path
- [wait-tcp](src/wait-tcp), a script to wait for some server sockets to be opened on a TCP
- [git-authors](src/scripts/git-authors), a git script to list committers other a commit range
- [git-bubbles](src/scripts/git-bubbles), a git script to handle pull requests
- [git-checkout-log](src/scripts/git-checkout-log), a git script to browser reflog and follow checkouts
- [git-prd](src/scripts/git-prd), a git script to display the path of the root of a git repository relative to your HOME directory
- [git-pwd](src/scripts/git-pwd), a git script to display the path relative to the root of a git repository
- [git-rm-others](src/scripts/git-rm-others), a git script to clean the working copy from untracked files
- [git-search](src/scripts/git-search), a git script to search the diff other a commit range
- [git-short](src/scripts/git-short), a git script to display short SHA1 of a given commit
- [git-std-init](src/scripts/git-std-init), a git script to setup a repository with an initial empty commit and a base and master branches
- [git-tree](src/scripts/git-tree), a git script to tree files handled by git
- [prd](src/scripts/prd), a script to print the working directory relative to your HOME directory
- [repeat](src/scripts/repeat), a script to repeat a command some times
- [short-path](src/scripts/short-path), a script to abbreviate every directory unless the last part of a path
- [wait-tcp](src/scripts/wait-tcp), a script to wait for some server sockets to be opened on a TCP

2 source-able bash scripts to customize your terminal:
- [git-ps1](src/bash/git-ps1), a PS1 expression, mostly focusing on handling git
- [ls-colors](nix/ls-colors.nix), a LS_COLORS env var, built from [trapd00r's LS_COLORS](https://github.com/trapd00r/LS_COLORS)
- [git-ps1](src/scripts/git-ps1), a PS1 expression, mostly focusing on handling git
- [ls-colors](src/ls-colors.nix), a LS_COLORS env var, built from [trapd00r's LS_COLORS](https://github.com/trapd00r/LS_COLORS)

## How-to install

- [via Nix](#nix)
- [from sources](#from-sources) (deprecated)
This project relies on [nix](https://nixos.org), and [flakes must be enabled](https://nixos.wiki/wiki/Flakes#Enable_flakes).

### Nix

You can install it from the sources this way:
### Test from a shell

```bash
nix-env -i -f nix/release.nix
nix shell github:ptitfred/posix-toolbox
```

You can also add it to an overlay, such as this one:
### Install via a profile

```nix
self: super:
let fetchPackage = owner: repo: path: rev: sha256:
self.callPackage (self.fetchFromGitHub { inherit owner repo rev sha256; } + path) {};
in {
posix-toolbox = fetchPackage "ptitfred" "posix-toolbox" "/nix/default.nix"
"d31128c1c8bbf7907534377633a43477c2e8d521" "lhkGUYuMvIsBJfHJEeitiH58Yh29h7ePgracCevtHHc=";
}
I would recommend you to use [home-manager](https://nix-community.github.io/home-manager/index.html#ch-nix-flakes) instead (see below), but if you prefer a more classic approach, you can install it in your user's path this way:

```bash
nix profile install github:ptitfred/posix-toolbox
```

And later install some scripts from the nix path:
### Install via home-manager

```bash
nix-env -i -f '<nixpkgs>' posix-toolbox
The flake exposes an overlay, let's first configure it (via a flake input for instance):

```nix
{ inputs, ... }:
{
nixpkgs.overlays = [ inputs.posix-toolbox.overlay ];
}
```

I would recommend you to use home-manager instead, in which case you would like to include the scripts you're interested in in the `home.packages` list:
We can now add the scripts we'd like in our PATH via the `home.packages` list:

```nix
{ pkgs, ... }:
Expand All @@ -77,7 +75,7 @@ I would recommend you to use home-manager instead, in which case you would like
}
```

You can also configure bash to use the PS1 provided by this project via home-manager too:
You can also configure bash to use the PS1 provided by this project via home-manager:

```nix
{ pkgs, ... }:
Expand Down Expand Up @@ -111,18 +109,7 @@ It's exactly the same for the ls-colors:

If you're curious about [home-manager](https://github.com/nix-community/home-manager)
you can learn about it via [their official documentation](https://nix-community.github.io/home-manager)
or by examples via [my own configuration](https://github.com/ptitfred/nixos-configuration).

### From sources

:warning: **With 2.0 release, it's untested and at your own risk.** I will only use Nix from now on.

You still have the old-school approach to checkout the sources and add it to your PATH:

```bash
git checkout https://github.com/ptitfred/posix-toolbox
export PATH=$(pwd)/posix-toolbox/src:$PATH
```
or by examples via [my own configuration](https://github.com/ptitfred/home-manager).

* * *

Expand Down
62 changes: 62 additions & 0 deletions flake.lock

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

32 changes: 32 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
description = "A very basic flake";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
nixos-22_11.url = "github:nixos/nixpkgs/nixos-22.11";
trapd00r-ls-colors.url = "github:trapd00r/LS_COLORS?rev=e91cc9cc69f6c4780f03b121bc633569742de7cd";
trapd00r-ls-colors.flake = false;
};

outputs = { nixpkgs, nixos-22_11, trapd00r-ls-colors, ... }:
let system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
previous = import nixos-22_11 { inherit system; };

posix-toolbox = pkgs.callPackages ./src { inherit trapd00r-ls-colors; };

tests = pkgs.callPackages ./tests { inherit (previous) nix-linter; };

default = pkgs.symlinkJoin {
name = "posix-toolbox";
paths = builtins.attrValues posix-toolbox;
};

overlay = _: _: { inherit posix-toolbox; };

in {
inherit overlay;
overlays.default = overlay;
packages.${system} = tests // { inherit default; };
};
}
11 changes: 0 additions & 11 deletions nix/default.nix

This file was deleted.

17 changes: 0 additions & 17 deletions nix/git-ps1.nix

This file was deleted.

18 changes: 0 additions & 18 deletions nix/ls-colors.nix

This file was deleted.

24 changes: 0 additions & 24 deletions nix/package.nix

This file was deleted.

2 changes: 0 additions & 2 deletions nix/release.nix

This file was deleted.

21 changes: 0 additions & 21 deletions nix/scripts.nix

This file was deleted.

7 changes: 0 additions & 7 deletions nix/trapd00r-ls-colors.json

This file was deleted.

7 changes: 0 additions & 7 deletions shell.nix

This file was deleted.

Loading

0 comments on commit 1724240

Please sign in to comment.