mirror of
https://github.com/NorfairKing/feedback.git
synced 2024-11-22 12:04:21 +03:00
Nix flake
This commit is contained in:
parent
38ae15aa6f
commit
ad6c768ee4
74
.github/workflows/nix-build.yml
vendored
74
.github/workflows/nix-build.yml
vendored
@ -2,55 +2,35 @@ name: "Nix Build"
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- development
|
||||
- master
|
||||
branches: [development, master]
|
||||
jobs:
|
||||
hooks:
|
||||
runs-on: ubuntu-latest
|
||||
build:
|
||||
name: ${{ matrix.attribute }} / ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
attribute:
|
||||
- .#devShells.x86_64-linux.default
|
||||
- .#packages.x86_64-linux.default
|
||||
- .#checks.x86_64-linux.pre-commit
|
||||
steps:
|
||||
- uses: actions/checkout@v3.0.2
|
||||
- uses: cachix/install-nix-action@v17
|
||||
- uses: cachix/cachix-action@v10
|
||||
- uses: actions/checkout@v2.5.0
|
||||
- uses: cachix/install-nix-action@v18
|
||||
with:
|
||||
extra_nix_config: |
|
||||
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
||||
- name: free disk space
|
||||
run: |
|
||||
if [[ "${{matrix.os}}" == "ubuntu-latest" ]]
|
||||
then
|
||||
sudo rm -rf /opt
|
||||
fi
|
||||
- uses: cachix/cachix-action@v11
|
||||
with:
|
||||
name: feedback
|
||||
extraPullNames: validity,sydtest,autodocodec
|
||||
extraPullNames: validity,safe-coloured-text,sydtest,autodocodec
|
||||
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
|
||||
- run: nix-build ci.nix -A pre-commit-check
|
||||
|
||||
shell:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3.0.2
|
||||
- uses: cachix/install-nix-action@v17
|
||||
- uses: cachix/cachix-action@v10
|
||||
with:
|
||||
name: feedback
|
||||
extraPullNames: validity,sydtest,autodocodec
|
||||
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
|
||||
- run: nix-build ci.nix -A shell
|
||||
|
||||
hoogle:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3.0.2
|
||||
- uses: cachix/install-nix-action@v17
|
||||
- uses: cachix/cachix-action@v10
|
||||
with:
|
||||
name: feedback
|
||||
extraPullNames: validity,sydtest,autodocodec
|
||||
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
|
||||
- run: nix-build ci.nix -A hoogle
|
||||
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3.0.2
|
||||
- uses: cachix/install-nix-action@v17
|
||||
- uses: cachix/cachix-action@v10
|
||||
with:
|
||||
name: feedback
|
||||
extraPullNames: validity,sydtest,autodocodec
|
||||
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
|
||||
- run: nix-build ci.nix -A release
|
||||
|
||||
- run: nix build "${{matrix.attribute}}"
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@ stack.yaml.lock
|
||||
result*
|
||||
.pre-commit-config.yaml
|
||||
.direnv/
|
||||
dist-newstyle/
|
||||
|
68
README.md
68
README.md
@ -11,23 +11,26 @@ Use the `feedback` command to set up a feedback loop for your work.
|
||||
For example, if you are working on a nix build, you might use this feedback loop:
|
||||
|
||||
```
|
||||
feedback -- nix-build --no-out-link
|
||||
feedback -- nix-build
|
||||
```
|
||||
|
||||
Usually `feedback` will correctly figure out which files to watch and which
|
||||
files not to watch, but you can also configure this more precisely.
|
||||
|
||||
### Declarative feedback loops
|
||||
|
||||
You can declare feedback loops in the `feedback.yaml` configuration file to share them with your team.
|
||||
For example, this gives you a [`ci.nix`-based feedback loop](https://cs-syd.eu/posts/2021-04-11-the-ci-nix-pattern):
|
||||
For example, this gives you a flake-based feedback loop:
|
||||
|
||||
```
|
||||
``` yaml
|
||||
loops:
|
||||
ci: nix-build ci.nix --no-out-link
|
||||
check: nix flake check -L
|
||||
```
|
||||
|
||||
Then you can just run this command, and not have to remember the full incantation:
|
||||
|
||||
```
|
||||
feedback ci
|
||||
feedback check
|
||||
```
|
||||
|
||||
To see the full reference of options of the configuration file, run `feedback --help`.
|
||||
@ -38,6 +41,61 @@ When sharing feedback loops with team members, it is important that no one break
|
||||
You can use `feedback-test` to test out the feedback loops in a one-shot manner, so you can check that they still work on CI.
|
||||
See `feedback-test --help` for more details.
|
||||
|
||||
## Installation
|
||||
|
||||
### Try it out
|
||||
|
||||
```
|
||||
nix run github:NorfairKing/feedback
|
||||
```
|
||||
|
||||
### Install globally
|
||||
|
||||
Add this to your system flake:
|
||||
|
||||
``` nix
|
||||
{
|
||||
inputs = {
|
||||
feedback.url = "github:NorfairKing/feedback?ref=flake";
|
||||
};
|
||||
outputs = { nixpkgs, feedback, ... }:
|
||||
let system = "x86_64-linux";
|
||||
in {
|
||||
nixosConfigurations.example = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = [
|
||||
{ environment.systemPackages = [ feedback.packages.${system}.default ];
|
||||
];
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
## Hacking
|
||||
|
||||
1. Enter a dev shell
|
||||
|
||||
```
|
||||
$ nix develop
|
||||
```
|
||||
|
||||
2. Start a feedback loop
|
||||
|
||||
```
|
||||
feedback istall
|
||||
```
|
||||
|
||||
3. Make your changes
|
||||
|
||||
4. Make sure CI will pass
|
||||
|
||||
```
|
||||
nix flake check
|
||||
```
|
||||
|
||||
5. Make a PR to `development`.
|
||||
|
||||
## Comparison with other tools
|
||||
|
||||
| | feedback | [steeloverseer](https://github.com/schell/steeloverseer) | [watchexec](https://github.com/watchexec/watchexec) | [entr](https://github.com/eradman/entr)
|
||||
|
@ -1,8 +1,5 @@
|
||||
version: 2.0.0
|
||||
value:
|
||||
- Configurable debouncing
|
||||
- Configurable postponing with --postpone
|
||||
- Enter to rerun immediately
|
||||
- header: On-busy configuration
|
||||
contents: |-
|
||||
options:
|
||||
@ -13,9 +10,6 @@ value:
|
||||
- Send a given signal
|
||||
- header: Extension-based filter
|
||||
contents: This is simple enough to accomodate
|
||||
- Make it possible to use polling
|
||||
- header: Make it possible to not use a shell
|
||||
contents: also to use adifferent shell?
|
||||
- Make it possible to turn off default ignores
|
||||
- Show info if feedback is called without args
|
||||
- Autocompletion for the loops, assuming we use the default config
|
||||
|
2
cabal.project
Normal file
2
cabal.project
Normal file
@ -0,0 +1,2 @@
|
||||
packages: */*.cabal
|
||||
test-show-details: direct
|
18
ci.nix
18
ci.nix
@ -1,18 +0,0 @@
|
||||
let
|
||||
sources = import ./nix/sources.nix;
|
||||
pkgs = import ./nix/pkgs.nix { inherit sources; };
|
||||
pre-commit = import ./nix/pre-commit.nix { inherit sources; };
|
||||
|
||||
in
|
||||
{
|
||||
release = pkgs.feedbackRelease;
|
||||
pre-commit-check = pre-commit.run;
|
||||
hoogle = pkgs.buildEnv {
|
||||
name = "feedback-hoogle";
|
||||
paths = [ (pkgs.haskellPackages.ghcWithHoogle (ps: pkgs.lib.attrValues pkgs.feedbackPackages)) ];
|
||||
};
|
||||
shell = pkgs.symlinkJoin {
|
||||
name = "shell";
|
||||
paths = (import ./shell.nix { inherit sources pkgs pre-commit; }).buildInputs;
|
||||
};
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
let
|
||||
pkgs = import ./nix/pkgs.nix { };
|
||||
in
|
||||
pkgs.feedbackPackages
|
@ -1,19 +1,12 @@
|
||||
loops:
|
||||
ci:
|
||||
description: Run all of CI
|
||||
command: nix-build ci.nix --no-out-link
|
||||
command: nix flake check
|
||||
|
||||
install:
|
||||
description: Work on `feedback` and its `--help` page.
|
||||
script: |
|
||||
set -x
|
||||
stack install :feedback \
|
||||
--fast --no-nix --system-ghc --with-hpack hpack
|
||||
~/.local/bin/feedback --help
|
||||
command: cabal run feedback:feedback -- --help
|
||||
|
||||
test:
|
||||
description: Work on `feedback-test`
|
||||
script: |
|
||||
stack install :feedback-test \
|
||||
--fast --no-nix --system-ghc --with-hpack hpack
|
||||
~/.local/bin/feedback-test --debug ci
|
||||
command: cabal run feedback:feedback-test
|
||||
|
25
feedback/default.nix
Normal file
25
feedback/default.nix
Normal file
@ -0,0 +1,25 @@
|
||||
{ mkDerivation, autodocodec, autodocodec-yaml, base, bytestring
|
||||
, conduit, containers, envparse, fsnotify, lib
|
||||
, optparse-applicative, path, path-io, pretty-show
|
||||
, safe-coloured-text, safe-coloured-text-layout
|
||||
, safe-coloured-text-terminfo, text, time, typed-process, unix
|
||||
, unliftio, yaml
|
||||
}:
|
||||
mkDerivation {
|
||||
pname = "feedback";
|
||||
version = "0.0.0.0";
|
||||
src = ./.;
|
||||
isLibrary = true;
|
||||
isExecutable = true;
|
||||
libraryHaskellDepends = [
|
||||
autodocodec autodocodec-yaml base bytestring conduit containers
|
||||
envparse fsnotify optparse-applicative path path-io pretty-show
|
||||
safe-coloured-text safe-coloured-text-layout
|
||||
safe-coloured-text-terminfo text time typed-process unix unliftio
|
||||
yaml
|
||||
];
|
||||
executableHaskellDepends = [ base ];
|
||||
homepage = "https://github.com/NorfairKing/feedback#readme";
|
||||
description = "Declarative feedback loop manager";
|
||||
license = lib.licenses.gpl3Only;
|
||||
}
|
@ -58,7 +58,7 @@ makeProcessConfigFor RunSettings {..} = do
|
||||
pure $
|
||||
setStdout inherit
|
||||
. setStderr inherit
|
||||
. setStdin closed -- TODO make this configurable?
|
||||
. setStdin nullStream -- TODO make this configurable?
|
||||
. setEnv envForProcess
|
||||
. maybe id (setWorkingDir . fromAbsDir) runSettingWorkingDir
|
||||
$ shell commandString
|
||||
|
148
flake.lock
Normal file
148
flake.lock
Normal file
@ -0,0 +1,148 @@
|
||||
{
|
||||
"nodes": {
|
||||
"autodocodec": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1666331698,
|
||||
"narHash": "sha256-VrONoycKv3lOwN/oKet3Pix96aFNgK+PmLevzBgSsgY=",
|
||||
"owner": "NorfairKing",
|
||||
"repo": "autodocodec",
|
||||
"rev": "fdc5171d0f904613b6a8b986a909c7a8ade4d2f1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NorfairKing",
|
||||
"ref": "flake",
|
||||
"repo": "autodocodec",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1667077288,
|
||||
"narHash": "sha256-bdC8sFNDpT0HK74u9fUkpbf1MEzVYJ+ka7NXCdgBoaA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "6ee9ebb6b1ee695d2cacc4faa053a7b9baa76817",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1668281765,
|
||||
"narHash": "sha256-6Tuj9CZ9HacMk7FJ8sF9XSVTBnUhVzlSY40Jo1krIaQ=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c5091eec689acc45d4d818109236da31d3685ca2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-22.05",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1668266328,
|
||||
"narHash": "sha256-+nAW+XR8nswyEnt5IkQlkrz9erTcQWBVLkhtNHxckFw=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "5ca8e2e9e1fa5e66a749b39261ad6bd0e07bc87f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"pre-commit-hooks": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1667992213,
|
||||
"narHash": "sha256-8Ens8ozllvlaFMCZBxg6S7oUyynYx2v7yleC5M0jJsE=",
|
||||
"owner": "cachix",
|
||||
"repo": "pre-commit-hooks.nix",
|
||||
"rev": "ebcbfe09d2bd6d15f68de3a0ebb1e4dcb5cd324b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "cachix",
|
||||
"repo": "pre-commit-hooks.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"autodocodec": "autodocodec",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"pre-commit-hooks": "pre-commit-hooks",
|
||||
"safe-coloured-text": "safe-coloured-text",
|
||||
"sydtest": "sydtest",
|
||||
"validity": "validity"
|
||||
}
|
||||
},
|
||||
"safe-coloured-text": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1666332070,
|
||||
"narHash": "sha256-Jvx1599QUkgzPhdvSOrxEKKBXF42eYv26EgXwM+RguU=",
|
||||
"owner": "NorfairKing",
|
||||
"repo": "safe-coloured-text",
|
||||
"rev": "df6d65d1afb0140d081b685b411dcfe03ae6f789",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NorfairKing",
|
||||
"ref": "flake",
|
||||
"repo": "safe-coloured-text",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"sydtest": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1666335564,
|
||||
"narHash": "sha256-RUAQuAaCCF+bFXWKQV9lx3Caj9pHp7l5NGnMfBaK05I=",
|
||||
"owner": "NorfairKing",
|
||||
"repo": "sydtest",
|
||||
"rev": "56eb625a7603652f475d0cfd4af50b700e9a5d1e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NorfairKing",
|
||||
"ref": "flake",
|
||||
"repo": "sydtest",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"validity": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1666331942,
|
||||
"narHash": "sha256-xKqunzWw3w7OaKSatckNxn7gCKtusjaj9szhgBWQwAc=",
|
||||
"owner": "NorfairKing",
|
||||
"repo": "validity",
|
||||
"rev": "dc24b655564beaa6750e390e37e64f8b0b67e18f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NorfairKing",
|
||||
"ref": "flake",
|
||||
"repo": "validity",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
80
flake.nix
Normal file
80
flake.nix
Normal file
@ -0,0 +1,80 @@
|
||||
{
|
||||
description = "feedback";
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-22.05";
|
||||
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
|
||||
validity.url = "github:NorfairKing/validity?ref=flake";
|
||||
validity.flake = false;
|
||||
autodocodec.url = "github:NorfairKing/autodocodec?ref=flake";
|
||||
autodocodec.flake = false;
|
||||
safe-coloured-text.url = "github:NorfairKing/safe-coloured-text?ref=flake";
|
||||
safe-coloured-text.flake = false;
|
||||
sydtest.url = "github:NorfairKing/sydtest?ref=flake";
|
||||
sydtest.flake = false;
|
||||
};
|
||||
|
||||
outputs =
|
||||
{ self
|
||||
, nixpkgs
|
||||
, pre-commit-hooks
|
||||
, validity
|
||||
, safe-coloured-text
|
||||
, sydtest
|
||||
, autodocodec
|
||||
}:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
pkgsFor = nixpkgs: import nixpkgs {
|
||||
inherit system;
|
||||
config.allowUnfree = true;
|
||||
overlays = [
|
||||
self.overlays.${system}
|
||||
(import (autodocodec + "/nix/overlay.nix"))
|
||||
(import (safe-coloured-text + "/nix/overlay.nix"))
|
||||
(import (sydtest + "/nix/overlay.nix"))
|
||||
(import (validity + "/nix/overlay.nix"))
|
||||
];
|
||||
};
|
||||
pkgs = pkgsFor nixpkgs;
|
||||
|
||||
in
|
||||
{
|
||||
overlays.${system} = import ./nix/overlay.nix;
|
||||
packages.${system}.default = pkgs.feedback;
|
||||
checks.${system} = {
|
||||
package = self.packages.${system}.default;
|
||||
shell = self.devShells.${system}.default;
|
||||
pre-commit = pre-commit-hooks.lib.${system}.run {
|
||||
src = ./.;
|
||||
hooks = {
|
||||
hlint.enable = true;
|
||||
hpack.enable = true;
|
||||
ormolu.enable = true;
|
||||
nixpkgs-fmt.enable = true;
|
||||
nixpkgs-fmt.excludes = [ ".*/default.nix" ];
|
||||
cabal2nix.enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
devShells.${system}.default = pkgs.haskellPackages.shellFor {
|
||||
name = "feedback-shell";
|
||||
packages = p: [ p.feedback ];
|
||||
withHoogle = true;
|
||||
doBenchmark = true;
|
||||
buildInputs = with pkgs; [
|
||||
feedback
|
||||
niv
|
||||
zlib
|
||||
cabal-install
|
||||
] ++ (with pre-commit-hooks;
|
||||
[
|
||||
hlint
|
||||
hpack
|
||||
nixpkgs-fmt
|
||||
ormolu
|
||||
cabal2nix
|
||||
]);
|
||||
shellHook = self.checks.${system}.pre-commit.shellHook + pkgs.feedback.shellHook;
|
||||
};
|
||||
};
|
||||
}
|
@ -1,19 +1,25 @@
|
||||
final: previous:
|
||||
final: prev:
|
||||
with final.lib;
|
||||
with final.haskell.lib;
|
||||
|
||||
let
|
||||
sources = import ./sources.nix;
|
||||
in
|
||||
{
|
||||
feedbackPackages =
|
||||
let
|
||||
feedbackPkg = name:
|
||||
overrideCabal
|
||||
|
||||
feedback = (justStaticExecutables final.haskellPackages.feedback).overrideAttrs (old: {
|
||||
passthru = (old.passthru or { }) // {
|
||||
shellHook = ''
|
||||
${final.haskellPackages.feedback}/bin/feedback
|
||||
'';
|
||||
};
|
||||
});
|
||||
|
||||
haskellPackages = prev.haskellPackages.override (old: {
|
||||
overrides = composeExtensions (old.overrides or (_: _: { })) (
|
||||
self: super:
|
||||
{
|
||||
feedback = generateOptparseApplicativeCompletion "feedback" (
|
||||
buildFromSdist (overrideCabal
|
||||
(
|
||||
final.haskellPackages.callCabal2nixWithOptions name
|
||||
(final.gitignoreSource (../. + "/${name}"))
|
||||
"--no-hpack"
|
||||
self.callPackage
|
||||
../feedback
|
||||
{ }
|
||||
)
|
||||
(old: {
|
||||
@ -21,7 +27,6 @@ in
|
||||
doHaddock = true;
|
||||
doCoverage = false;
|
||||
doHoogle = true;
|
||||
doCheck = false; # Only check the release version.
|
||||
hyperlinkSource = false;
|
||||
enableLibraryProfiling = false;
|
||||
enableExecutableProfiling = false;
|
||||
@ -43,42 +48,8 @@ in
|
||||
# Ugly hack because we can't just add flags to the 'test' invocation.
|
||||
# Show test output as we go, instead of all at once afterwards.
|
||||
testTarget = (old.testTarget or "") + " --show-details=direct";
|
||||
});
|
||||
feedbackPkgWithComp =
|
||||
exeName: name:
|
||||
generateOptparseApplicativeCompletion exeName (feedbackPkg name);
|
||||
feedbackPkgWithOwnComp = name: feedbackPkgWithComp name name;
|
||||
in
|
||||
{
|
||||
|
||||
"feedback" = feedbackPkgWithOwnComp "feedback";
|
||||
};
|
||||
|
||||
feedbackReleasePackages = mapAttrs
|
||||
(_: pkg: justStaticExecutables (doCheck pkg))
|
||||
final.feedbackPackages;
|
||||
|
||||
|
||||
feedbackRelease =
|
||||
final.symlinkJoin {
|
||||
name = "feedback-release";
|
||||
paths = attrValues final.feedbackReleasePackages;
|
||||
passthru.shellHook = ''
|
||||
${final.feedbackReleasePackages.feedback}/bin/feedback
|
||||
'';
|
||||
};
|
||||
|
||||
feedback = final.feedbackRelease;
|
||||
|
||||
haskellPackages =
|
||||
previous.haskellPackages.override (
|
||||
old:
|
||||
{
|
||||
overrides =
|
||||
composeExtensions (old.overrides or (_: _: { })) (
|
||||
self: super:
|
||||
final.feedbackPackages
|
||||
);
|
||||
})));
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
14
nix/pkgs.nix
14
nix/pkgs.nix
@ -1,14 +0,0 @@
|
||||
{ sources ? import ./sources.nix
|
||||
}:
|
||||
import sources.nixpkgs {
|
||||
overlays =
|
||||
[
|
||||
(final: previous: { inherit (import sources.gitignore { inherit (final) lib; }) gitignoreSource; })
|
||||
(import (sources.autodocodec + "/nix/overlay.nix"))
|
||||
(import (sources.safe-coloured-text + "/nix/overlay.nix"))
|
||||
(import (sources.sydtest + "/nix/overlay.nix"))
|
||||
(import (sources.validity + "/nix/overlay.nix"))
|
||||
(import ./overlay.nix)
|
||||
];
|
||||
config.allowUnfree = true;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
{ sources ? import ./sources.nix }:
|
||||
let
|
||||
pre-commit-hooks = import sources.pre-commit-hooks;
|
||||
in
|
||||
{
|
||||
run = pre-commit-hooks.run {
|
||||
src = ../.;
|
||||
hooks = {
|
||||
hlint.enable = true;
|
||||
hpack.enable = true;
|
||||
nixpkgs-fmt.enable = true;
|
||||
ormolu.enable = true;
|
||||
};
|
||||
};
|
||||
tools = with pre-commit-hooks; [
|
||||
hlint
|
||||
hpack
|
||||
nixpkgs-fmt
|
||||
ormolu
|
||||
];
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
{
|
||||
"autodocodec": {
|
||||
"branch": "master",
|
||||
"description": "self(auto)- documenting encoders and decoders",
|
||||
"homepage": "",
|
||||
"owner": "NorfairKing",
|
||||
"repo": "autodocodec",
|
||||
"rev": "98135d2b24c4c52f56f53c6650a169aeec61c7f1",
|
||||
"sha256": "0srbn65343a213690samf7pf2q0kvnngpv6wn0srm57dpv0f68hn",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NorfairKing/autodocodec/archive/98135d2b24c4c52f56f53c6650a169aeec61c7f1.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"gitignore": {
|
||||
"branch": "master",
|
||||
"description": "Nix functions for filtering local git sources",
|
||||
"homepage": "",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
|
||||
"sha256": "07vg2i9va38zbld9abs9lzqblz193vc5wvqd6h7amkmwf66ljcgh",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/hercules-ci/gitignore.nix/archive/a20de23b925fd8264fd7fad6454652e142fd7f73.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"niv": {
|
||||
"branch": "master",
|
||||
"description": "Easy dependency management for Nix projects",
|
||||
"homepage": "https://github.com/nmattia/niv",
|
||||
"owner": "nmattia",
|
||||
"repo": "niv",
|
||||
"rev": "82e5cd1ad3c387863f0545d7591512e76ab0fc41",
|
||||
"sha256": "090l219mzc0gi33i3psgph6s2pwsc8qy4lyrqjdj4qzkvmaj65a7",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/nmattia/niv/archive/82e5cd1ad3c387863f0545d7591512e76ab0fc41.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nixpkgs": {
|
||||
"branch": "nixos-22.05",
|
||||
"description": "Nix Packages collection",
|
||||
"homepage": "",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a82127cea64fd801c5e138ae23dfd444ec1e06d1",
|
||||
"sha256": "07i03bwpk5s6daqc5s1v02zfjzmvl5sz8s3xccg9akcbn9phyn2s",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/a82127cea64fd801c5e138ae23dfd444ec1e06d1.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"pre-commit-hooks": {
|
||||
"branch": "master",
|
||||
"description": "Seamless integration of https://pre-commit.com git hooks with Nix.",
|
||||
"homepage": "",
|
||||
"owner": "cachix",
|
||||
"repo": "pre-commit-hooks.nix",
|
||||
"rev": "521a524771a8e93caddaa0ac1d67d03766a8b0b3",
|
||||
"sha256": "16qfrylk41r7gc7g4352hxz7b3vk9w7bc6893apmmr6yy08ra0m9",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/cachix/pre-commit-hooks.nix/archive/521a524771a8e93caddaa0ac1d67d03766a8b0b3.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"safe-coloured-text": {
|
||||
"branch": "master",
|
||||
"description": null,
|
||||
"homepage": "https://cs-syd.eu/posts/2021-03-07-safe-coloured-text",
|
||||
"owner": "NorfairKing",
|
||||
"repo": "safe-coloured-text",
|
||||
"rev": "675cb01fce5f46718416d7746de5b856ed90a63f",
|
||||
"sha256": "18lf28k51f24smkyba0dfv1hqz3jxfqr81w70zjvbw77z5q0vxf6",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NorfairKing/safe-coloured-text/archive/675cb01fce5f46718416d7746de5b856ed90a63f.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"sydtest": {
|
||||
"branch": "master",
|
||||
"description": "A modern testing framework for Haskell with good defaults and advanced testing features.",
|
||||
"homepage": "",
|
||||
"owner": "NorfairKing",
|
||||
"repo": "sydtest",
|
||||
"rev": "130de92053c1c3d60a8f45d509210415ffbea530",
|
||||
"sha256": "1873sjmmxfmf2iig5p1ka0y7n7n1zmiv92d6pq4cyc9a2f10184a",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NorfairKing/sydtest/archive/130de92053c1c3d60a8f45d509210415ffbea530.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"validity": {
|
||||
"branch": "master",
|
||||
"description": "Validity and validity-based testing",
|
||||
"homepage": "https://www.youtube.com/watch?v=eIs9qNh17SM",
|
||||
"owner": "NorfairKing",
|
||||
"repo": "validity",
|
||||
"rev": "8373ac5f0f02ad66f1b83c9bf572290430e84062",
|
||||
"sha256": "04rs2hq9xz9y8w5zpc15zazm8dcbkd5kryh4cy7yww187jgp0saq",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/NorfairKing/validity/archive/8373ac5f0f02ad66f1b83c9bf572290430e84062.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
}
|
||||
}
|
177
nix/sources.nix
177
nix/sources.nix
@ -1,177 +0,0 @@
|
||||
# This file has been generated by Niv.
|
||||
|
||||
let
|
||||
|
||||
#
|
||||
# The fetchers. fetch_<type> fetches specs of type <type>.
|
||||
#
|
||||
|
||||
fetch_file = pkgs: name: spec:
|
||||
let
|
||||
name' = sanitizeName name + "-src";
|
||||
in
|
||||
if spec.builtin or true then
|
||||
builtins_fetchurl { inherit (spec) url sha256; name = name'; }
|
||||
else
|
||||
pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
|
||||
|
||||
fetch_tarball = pkgs: name: spec:
|
||||
let
|
||||
name' = sanitizeName name + "-src";
|
||||
in
|
||||
if spec.builtin or true then
|
||||
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
|
||||
else
|
||||
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
|
||||
|
||||
fetch_git = name: spec:
|
||||
let
|
||||
ref =
|
||||
if spec ? ref then spec.ref else
|
||||
if spec ? branch then "refs/heads/${spec.branch}" else
|
||||
if spec ? tag then "refs/tags/${spec.tag}" else
|
||||
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
|
||||
in
|
||||
builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; };
|
||||
|
||||
fetch_local = spec: spec.path;
|
||||
|
||||
fetch_builtin-tarball = name: throw
|
||||
''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
|
||||
$ niv modify ${name} -a type=tarball -a builtin=true'';
|
||||
|
||||
fetch_builtin-url = name: throw
|
||||
''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
|
||||
$ niv modify ${name} -a type=file -a builtin=true'';
|
||||
|
||||
#
|
||||
# Various helpers
|
||||
#
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695
|
||||
sanitizeName = name:
|
||||
(
|
||||
concatMapStrings (s: if builtins.isList s then "-" else s)
|
||||
(
|
||||
builtins.split "[^[:alnum:]+._?=-]+"
|
||||
((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)
|
||||
)
|
||||
);
|
||||
|
||||
# The set of packages used when specs are fetched using non-builtins.
|
||||
mkPkgs = sources: system:
|
||||
let
|
||||
sourcesNixpkgs =
|
||||
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; };
|
||||
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
|
||||
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
|
||||
in
|
||||
if builtins.hasAttr "nixpkgs" sources
|
||||
then sourcesNixpkgs
|
||||
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
|
||||
import <nixpkgs> { }
|
||||
else
|
||||
abort
|
||||
''
|
||||
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
|
||||
add a package called "nixpkgs" to your sources.json.
|
||||
'';
|
||||
|
||||
# The actual fetching function.
|
||||
fetch = pkgs: name: spec:
|
||||
|
||||
if ! builtins.hasAttr "type" spec then
|
||||
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
|
||||
else if spec.type == "file" then fetch_file pkgs name spec
|
||||
else if spec.type == "tarball" then fetch_tarball pkgs name spec
|
||||
else if spec.type == "git" then fetch_git name spec
|
||||
else if spec.type == "local" then fetch_local spec
|
||||
else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
|
||||
else if spec.type == "builtin-url" then fetch_builtin-url name
|
||||
else
|
||||
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
|
||||
|
||||
# If the environment variable NIV_OVERRIDE_${name} is set, then use
|
||||
# the path directly as opposed to the fetched source.
|
||||
replace = name: drv:
|
||||
let
|
||||
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
|
||||
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
|
||||
in
|
||||
if ersatz == "" then drv else
|
||||
# this turns the string into an actual Nix path (for both absolute and
|
||||
# relative paths)
|
||||
if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}";
|
||||
|
||||
# Ports of functions for older nix versions
|
||||
|
||||
# a Nix version of mapAttrs if the built-in doesn't exist
|
||||
mapAttrs = builtins.mapAttrs or (
|
||||
f: set: with builtins;
|
||||
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
|
||||
);
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
|
||||
range = first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1);
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
|
||||
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
|
||||
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
|
||||
concatMapStrings = f: list: concatStrings (map f list);
|
||||
concatStrings = builtins.concatStringsSep "";
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
|
||||
optionalAttrs = cond: as: if cond then as else { };
|
||||
|
||||
# fetchTarball version that is compatible between all the versions of Nix
|
||||
builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
|
||||
let
|
||||
inherit (builtins) lessThan nixVersion fetchTarball;
|
||||
in
|
||||
if lessThan nixVersion "1.12" then
|
||||
fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
|
||||
else
|
||||
fetchTarball attrs;
|
||||
|
||||
# fetchurl version that is compatible between all the versions of Nix
|
||||
builtins_fetchurl = { url, name ? null, sha256 }@attrs:
|
||||
let
|
||||
inherit (builtins) lessThan nixVersion fetchurl;
|
||||
in
|
||||
if lessThan nixVersion "1.12" then
|
||||
fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
|
||||
else
|
||||
fetchurl attrs;
|
||||
|
||||
# Create the final "sources" from the config
|
||||
mkSources = config:
|
||||
mapAttrs
|
||||
(
|
||||
name: spec:
|
||||
if builtins.hasAttr "outPath" spec
|
||||
then
|
||||
abort
|
||||
"The values in sources.json should not have an 'outPath' attribute"
|
||||
else
|
||||
spec // { outPath = replace name (fetch config.pkgs name spec); }
|
||||
)
|
||||
config.sources;
|
||||
|
||||
# The "config" used by the fetchers
|
||||
mkConfig =
|
||||
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
|
||||
, sources ? if isNull sourcesFile then { } else builtins.fromJSON (builtins.readFile sourcesFile)
|
||||
, system ? builtins.currentSystem
|
||||
, pkgs ? mkPkgs sources system
|
||||
}: rec {
|
||||
# The sources, i.e. the attribute set of spec name to spec
|
||||
inherit sources;
|
||||
|
||||
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
|
||||
inherit pkgs;
|
||||
};
|
||||
|
||||
in
|
||||
mkSources (mkConfig { }) // { __functor = _: settings: mkSources (mkConfig settings); }
|
11
shell.nix
11
shell.nix
@ -1,11 +0,0 @@
|
||||
{ sources ? import ./nix/sources.nix
|
||||
, pkgs ? import ./nix/pkgs.nix { inherit sources; }
|
||||
, pre-commit ? import ./nix/pre-commit.nix { inherit sources; }
|
||||
}:
|
||||
pkgs.haskell.lib.buildStackProject {
|
||||
name = "feedback-shell";
|
||||
buildInputs = with pkgs; [
|
||||
(import sources.niv { }).niv
|
||||
zlib
|
||||
] ++ pre-commit.tools;
|
||||
}
|
64
stack.yaml
64
stack.yaml
@ -1,64 +0,0 @@
|
||||
resolver: lts-19.6
|
||||
|
||||
packages:
|
||||
- feedback
|
||||
|
||||
ghc-options:
|
||||
"$locals": -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates -Wpartial-fields -Widentities -Wredundant-constraints -Wcpp-undef
|
||||
|
||||
extra-deps:
|
||||
- github: NorfairKing/safe-coloured-text
|
||||
commit: 675cb01fce5f46718416d7746de5b856ed90a63f
|
||||
subdirs:
|
||||
- safe-coloured-text
|
||||
- safe-coloured-text-layout
|
||||
- safe-coloured-text-terminfo
|
||||
- github: NorfairKing/sydtest
|
||||
commit: 130de92053c1c3d60a8f45d509210415ffbea530
|
||||
subdirs:
|
||||
- sydtest
|
||||
- github: NorfairKing/autodocodec
|
||||
commit: 98135d2b24c4c52f56f53c6650a169aeec61c7f1
|
||||
subdirs:
|
||||
- autodocodec
|
||||
- autodocodec-schema
|
||||
- autodocodec-yaml
|
||||
- github: NorfairKing/validity
|
||||
commit: 8373ac5f0f02ad66f1b83c9bf572290430e84062
|
||||
subdirs:
|
||||
- genvalidity
|
||||
- genvalidity-aeson
|
||||
- genvalidity-bytestring
|
||||
- genvalidity-containers
|
||||
- genvalidity-criterion
|
||||
- genvalidity-path
|
||||
- genvalidity-persistent
|
||||
- genvalidity-property
|
||||
- genvalidity-scientific
|
||||
- genvalidity-sydtest
|
||||
- genvalidity-sydtest-aeson
|
||||
- genvalidity-sydtest-hashable
|
||||
- genvalidity-sydtest-lens
|
||||
- genvalidity-sydtest-persistent
|
||||
- genvalidity-text
|
||||
- genvalidity-time
|
||||
- genvalidity-unordered-containers
|
||||
- genvalidity-uuid
|
||||
- genvalidity-vector
|
||||
- validity
|
||||
- validity-aeson
|
||||
- validity-bytestring
|
||||
- validity-containers
|
||||
- validity-path
|
||||
- validity-persistent
|
||||
- validity-primitive
|
||||
- validity-scientific
|
||||
- validity-text
|
||||
- validity-time
|
||||
- validity-unordered-containers
|
||||
- validity-uuid
|
||||
- validity-vector
|
||||
|
||||
nix:
|
||||
enable: true
|
||||
shell-file: shell.nix
|
Loading…
Reference in New Issue
Block a user