diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5396764..252ef77 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/.gitignore b/.gitignore index a01ee28..3bcd14f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .*.swp +result diff --git a/README.md b/README.md index f8c1a2b..c30433b 100644 --- a/README.md +++ b/README.md @@ -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 '' 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, ... }: @@ -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, ... }: @@ -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). * * * diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a8bf21f --- /dev/null +++ b/flake.lock @@ -0,0 +1,62 @@ +{ + "nodes": { + "nixos-22_11": { + "locked": { + "lastModified": 1688392541, + "narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1690835256, + "narHash": "sha256-SZy/Nvwbf6CorhEsvmjqgjoYNLnRfaKVZMfSnpUDPnc=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "b7cde1c47b7316f6138a2b36ef6627f3d16d645c", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixos-22_11": "nixos-22_11", + "nixpkgs": "nixpkgs", + "trapd00r-ls-colors": "trapd00r-ls-colors" + } + }, + "trapd00r-ls-colors": { + "flake": false, + "locked": { + "lastModified": 1609339936, + "narHash": "sha256-6DnZgWXlQ1+focJGvhlVvgo97owDCj5w2zydF2ZiV8Q=", + "owner": "trapd00r", + "repo": "LS_COLORS", + "rev": "e91cc9cc69f6c4780f03b121bc633569742de7cd", + "type": "github" + }, + "original": { + "owner": "trapd00r", + "repo": "LS_COLORS", + "rev": "e91cc9cc69f6c4780f03b121bc633569742de7cd", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..fe6b5fa --- /dev/null +++ b/flake.nix @@ -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; }; + }; +} diff --git a/nix/default.nix b/nix/default.nix deleted file mode 100644 index c9c26e5..0000000 --- a/nix/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ callPackage }: - -let scripts = callPackage ./scripts.nix {}; - lsColors = callPackage ./ls-colors.nix {}; - git-ps1 = callPackage ./git-ps1.nix { - git-pwd = scripts.git-pwd; - git-prd = scripts.git-prd; - prd = scripts.prd; - short-path = scripts.short-path; - }; -in scripts // lsColors // git-ps1 diff --git a/nix/git-ps1.nix b/nix/git-ps1.nix deleted file mode 100644 index fa34cf4..0000000 --- a/nix/git-ps1.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ stdenv, git, git-prd, git-pwd, prd, short-path }: - -let git-ps1 = - stdenv.mkDerivation { - name = "posix-toolbox-git-ps1"; - src = ./../src; - buildInputs = [ git git-prd git-pwd prd short-path ]; - installPhase = '' - mkdir -p $out/share/posix-toolbox - substitute $src/bash/git-ps1 $out/share/posix-toolbox/git-ps1 \ - --replace "prd_ " ${prd}/bin/prd \ - --replace git-prd ${git-prd}/bin/git-prd \ - --replace git-pwd ${git-pwd}/bin/git-pwd \ - --replace short-path ${short-path}/bin/short-path - ''; - }; -in { inherit git-ps1; } diff --git a/nix/ls-colors.nix b/nix/ls-colors.nix deleted file mode 100644 index 3d6845c..0000000 --- a/nix/ls-colors.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ stdenv, coreutils, fetchFromGitHub }: - -let fromJSON = path: fetchFromGitHub (builtins.fromJSON (builtins.readFile path)); - ls-colors = - stdenv.mkDerivation { - name = "posix-toolbox-ls-colors"; - - src = fromJSON ./trapd00r-ls-colors.json; - - buildInputs = [ coreutils ]; - - installPhase = '' - mkdir -p $out/share/ls-colors - dircolors -b $src/LS_COLORS > $out/share/ls-colors/bash.sh - dircolors -c $src/LS_COLORS > $out/share/ls-colors/csh.sh - ''; - }; -in { inherit ls-colors; } diff --git a/nix/package.nix b/nix/package.nix deleted file mode 100644 index 93c0d8a..0000000 --- a/nix/package.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ stdenv, lib, makeWrapper }: - -script: inputs: description: - stdenv.mkDerivation rec { - name = "posix-toolbox-" + script; - - src = ./../src; - - buildInputs = inputs ++ [ makeWrapper ] ; - - installPhase = - let runtimePath = lib.makeBinPath inputs; - in '' - mkdir -p $out/bin - cp $src/${script} $out/bin/${script} - wrapProgram $out/bin/${script} --prefix PATH : "${runtimePath}" - ''; - - meta = { - homepage = "https://github.com/ptitfred/posix-toolbox"; - inherit description; - license = lib.licenses.mit; - }; - } diff --git a/nix/release.nix b/nix/release.nix deleted file mode 100644 index 5ef4139..0000000 --- a/nix/release.nix +++ /dev/null @@ -1,2 +0,0 @@ -{ pkgs ? import {} -}: pkgs.callPackage ./default.nix {} diff --git a/nix/scripts.nix b/nix/scripts.nix deleted file mode 100644 index e06ad01..0000000 --- a/nix/scripts.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ callPackage, coreutils, findutils, gawk, git, gnugrep, gnused, i3lock, imagemagick, less, lsof, psmisc, scrot, tree, utillinux }: - -let packageScript = callPackage ./package.nix {}; -in rec { - git-authors = packageScript "git-authors" [ coreutils findutils git gnused ] "A git script to list committers other a commit range"; - git-bubbles = packageScript "git-bubbles" [ coreutils git gnused ] "A git script to handle pull requests"; - git-checkout-log = packageScript "git-checkout-log" [ coreutils git gnused less ] "A git script to browser reflog and follow checkouts"; - git-prd = packageScript "git-prd" [ git prd ] "A git script to display the path of the root of a git repository relative to your HOME directory"; - git-pwd = packageScript "git-pwd" [ coreutils git ] "A git script to display the path relative to the root of a git repository"; - git-rm-others = packageScript "git-rm-others" [ coreutils findutils git ] "A git script to clean the working copy from untracked files"; - git-search = packageScript "git-search" [ findutils git gnugrep ] "A git script to search the diff other a commit range"; - git-short = packageScript "git-short" [ git ] "A git script to display short SHA1 of a given commit"; - git-std-init = packageScript "git-std-init" [ coreutils git ] "A git script to setup a repository with an initial empty commit and a base and master branches"; - git-tree = packageScript "git-tree" [ coreutils git tree ] "A git script to tree files handled by git"; - i3-screen-locker = packageScript "i3-screen-locker" [ coreutils i3lock imagemagick scrot ] "A variant of i3lock that take a screenshot to use as background of the lock screen"; - prd = packageScript "prd" [ coreutils ] "A script to print the working directory relative to your HOME directory"; - repeat = packageScript "repeat" [ coreutils gnused utillinux ] "A script to repeat a command some times"; - short-path = packageScript "short-path" [ coreutils gnused ] "A script to abbreviate every directory unless the last part of a path"; - wait-tcp = packageScript "wait-tcp" [ coreutils gawk gnugrep gnused lsof psmisc ] # FIXME: make buildInputs dependent on the target system (darwin vs linux) - "A script to wait for some server sockets to be opened on a TCP"; - } diff --git a/nix/trapd00r-ls-colors.json b/nix/trapd00r-ls-colors.json deleted file mode 100644 index 811e180..0000000 --- a/nix/trapd00r-ls-colors.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "owner": "trapd00r", - "repo": "LS_COLORS", - "rev": "e91cc9cc69f6c4780f03b121bc633569742de7cd", - "sha256": "1i2pc9k1g79wvdq3w2h3ikp3s2myalcvwin2l6gmyhz5cn0xjfg8", - "fetchSubmodules": true -} \ No newline at end of file diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 3a9ada3..0000000 --- a/shell.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ pkgs ? import {} -}: - -let aspell = pkgs.aspellWithDicts (d: [d.en]); - in pkgs.mkShell { - buildInputs = [ aspell pkgs.findutils pkgs.git pkgs.nix-linter pkgs.shellcheck ]; - } diff --git a/src/default.nix b/src/default.nix new file mode 100644 index 0000000..778fe15 --- /dev/null +++ b/src/default.nix @@ -0,0 +1,52 @@ +{ callPackage, trapd00r-ls-colors +, lib, stdenv, makeWrapper +, coreutils, findutils, gawk, git, gnugrep, gnused, i3lock, imagemagick, less +, lsof, psmisc, scrot, tree, utillinux }: + +let packageScript = + script: inputs: description: + stdenv.mkDerivation { + name = "posix-toolbox-" + script; + + src = ./scripts; + + buildInputs = inputs ++ [ makeWrapper ] ; + + installPhase = + let runtimePath = lib.makeBinPath inputs; + in '' + mkdir -p $out/bin + cp $src/${script} $out/bin/${script} + wrapProgram $out/bin/${script} --prefix PATH : "${runtimePath}" + ''; + + meta = { + homepage = "https://github.com/ptitfred/posix-toolbox"; + inherit description; + license = lib.licenses.mit; + }; + }; +in +rec { + git-authors = packageScript "git-authors" [ coreutils findutils git gnused ] "A git script to list committers other a commit range"; + git-bubbles = packageScript "git-bubbles" [ coreutils git gnused ] "A git script to handle pull requests"; + git-checkout-log = packageScript "git-checkout-log" [ coreutils git gnused less ] "A git script to browser reflog and follow checkouts"; + git-prd = packageScript "git-prd" [ git prd ] "A git script to display the path of the root of a git repository relative to your HOME directory"; + git-pwd = packageScript "git-pwd" [ coreutils git ] "A git script to display the path relative to the root of a git repository"; + git-rm-others = packageScript "git-rm-others" [ coreutils findutils git ] "A git script to clean the working copy from untracked files"; + git-search = packageScript "git-search" [ findutils git gnugrep ] "A git script to search the diff other a commit range"; + git-short = packageScript "git-short" [ git ] "A git script to display short SHA1 of a given commit"; + git-std-init = packageScript "git-std-init" [ coreutils git ] "A git script to setup a repository with an initial empty commit and a base and master branches"; + git-tree = packageScript "git-tree" [ coreutils git tree ] "A git script to tree files handled by git"; + i3-screen-locker = packageScript "i3-screen-locker" [ coreutils i3lock imagemagick scrot ] "A variant of i3lock that take a screenshot to use as background of the lock screen"; + prd = packageScript "prd" [ coreutils ] "A script to print the working directory relative to your HOME directory"; + repeat = packageScript "repeat" [ coreutils gnused utillinux ] "A script to repeat a command some times"; + short-path = packageScript "short-path" [ coreutils gnused ] "A script to abbreviate every directory unless the last part of a path"; + + # FIXME: make buildInputs dependent on the target system (darwin vs linux) + wait-tcp = packageScript "wait-tcp" [ coreutils gawk gnugrep gnused lsof psmisc ] "A script to wait for some server sockets to be opened on a TCP"; + + ls-colors = callPackage ./ls-colors.nix { inherit trapd00r-ls-colors; }; + git-ps1 = callPackage ./git-ps1.nix { inherit git-pwd git-prd prd short-path; }; + } + diff --git a/src/git-ps1.nix b/src/git-ps1.nix new file mode 100644 index 0000000..d9055b2 --- /dev/null +++ b/src/git-ps1.nix @@ -0,0 +1,15 @@ +{ runCommand, git, git-prd, git-pwd, prd, short-path }: + +runCommand "posix-toolbox-git-ps1" + { + src = ./scripts; + buildInputs = [ git git-prd git-pwd prd short-path ]; + } + '' + mkdir -p $out/share/posix-toolbox + substitute $src/git-ps1 $out/share/posix-toolbox/git-ps1 \ + --replace "prd_ " ${prd}/bin/prd \ + --replace git-prd ${git-prd}/bin/git-prd \ + --replace git-pwd ${git-pwd}/bin/git-pwd \ + --replace short-path ${short-path}/bin/short-path + '' diff --git a/src/ls-colors.nix b/src/ls-colors.nix new file mode 100644 index 0000000..83a791f --- /dev/null +++ b/src/ls-colors.nix @@ -0,0 +1,12 @@ +{ runCommand, coreutils, trapd00r-ls-colors }: + +runCommand "posix-toolbox-ls-colors" + { + src = trapd00r-ls-colors; + buildInputs = [ coreutils ]; + } + '' + mkdir -p $out/share/ls-colors + dircolors -b $src/LS_COLORS > $out/share/ls-colors/bash.sh + dircolors -c $src/LS_COLORS > $out/share/ls-colors/csh.sh + '' diff --git a/src/git-authors b/src/scripts/git-authors similarity index 100% rename from src/git-authors rename to src/scripts/git-authors diff --git a/src/git-bubbles b/src/scripts/git-bubbles similarity index 100% rename from src/git-bubbles rename to src/scripts/git-bubbles diff --git a/src/git-checkout-log b/src/scripts/git-checkout-log similarity index 100% rename from src/git-checkout-log rename to src/scripts/git-checkout-log diff --git a/src/git-prd b/src/scripts/git-prd similarity index 100% rename from src/git-prd rename to src/scripts/git-prd diff --git a/src/bash/git-ps1 b/src/scripts/git-ps1 similarity index 99% rename from src/bash/git-ps1 rename to src/scripts/git-ps1 index 85ee670..0d298ab 100644 --- a/src/bash/git-ps1 +++ b/src/scripts/git-ps1 @@ -148,7 +148,7 @@ __git_ps1 () local branch_name=${b##refs/heads/} if [ "$shorten" == "1" ]; then - branch_name=$(short-path ${b##refs/heads/}) + branch_name=$(short-path "${b##refs/heads/}") fi if [ -n "${1-}" ]; then diff --git a/src/git-pwd b/src/scripts/git-pwd similarity index 98% rename from src/git-pwd rename to src/scripts/git-pwd index acbedd5..ada5cb6 100755 --- a/src/git-pwd +++ b/src/scripts/git-pwd @@ -31,5 +31,5 @@ if [[ $root == ".git" ]] then echo "/" else - echo "${wd##${root}}" + echo "${wd##"${root}"}" fi diff --git a/src/git-rm-others b/src/scripts/git-rm-others similarity index 100% rename from src/git-rm-others rename to src/scripts/git-rm-others diff --git a/src/git-search b/src/scripts/git-search similarity index 100% rename from src/git-search rename to src/scripts/git-search diff --git a/src/git-short b/src/scripts/git-short similarity index 100% rename from src/git-short rename to src/scripts/git-short diff --git a/src/git-std-init b/src/scripts/git-std-init similarity index 100% rename from src/git-std-init rename to src/scripts/git-std-init diff --git a/src/git-tree b/src/scripts/git-tree similarity index 100% rename from src/git-tree rename to src/scripts/git-tree diff --git a/src/i3-screen-locker b/src/scripts/i3-screen-locker similarity index 100% rename from src/i3-screen-locker rename to src/scripts/i3-screen-locker diff --git a/src/prd b/src/scripts/prd similarity index 98% rename from src/prd rename to src/scripts/prd index 5cbaee0..84a6258 100755 --- a/src/prd +++ b/src/scripts/prd @@ -29,7 +29,7 @@ if [ "$#" = "0" ]; then else pwd=$1 fi -wd=${pwd#$HOME/} +wd=${pwd#"$HOME"/} if [ "${wd}" = "$HOME" ] then # right in home diff --git a/src/repeat b/src/scripts/repeat similarity index 100% rename from src/repeat rename to src/scripts/repeat diff --git a/src/short-path b/src/scripts/short-path similarity index 100% rename from src/short-path rename to src/scripts/short-path diff --git a/src/wait-tcp b/src/scripts/wait-tcp similarity index 100% rename from src/wait-tcp rename to src/scripts/wait-tcp diff --git a/tests/default.nix b/tests/default.nix new file mode 100644 index 0000000..72d0807 --- /dev/null +++ b/tests/default.nix @@ -0,0 +1,19 @@ +{ writeShellApplication +, nix-linter +, aspellWithDicts +}: + +let aspell = aspellWithDicts (d: [d.en]); +in +{ + lint = writeShellApplication { + name = "posix-toolbox-lint-nix"; + runtimeInputs = [ nix-linter ]; + text = "find . -name '*.nix' -exec nix-linter {} +"; + }; + spell = writeShellApplication { + name = "posix-toolbox-spell"; + runtimeInputs = [ aspell ]; + text = builtins.readFile ./spell.sh; + }; +} diff --git a/tests/lint-nix.sh b/tests/lint-nix.sh deleted file mode 100755 index 0b53784..0000000 --- a/tests/lint-nix.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -e - -find -name '*.nix' | xargs nix-linter diff --git a/tests/lint-shell.sh b/tests/lint-shell.sh deleted file mode 100755 index 7ae6795..0000000 --- a/tests/lint-shell.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -e - -shellcheck $(git ls-files src/) diff --git a/tests/spell.sh b/tests/spell.sh old mode 100755 new mode 100644 index 803a655..56c3b7c --- a/tests/spell.sh +++ b/tests/spell.sh @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - function check { local filename="$1" echo "$filename"