Nix flake

This commit is contained in:
Tom Sydney Kerckhove 2022-10-19 21:06:39 +02:00
parent c40721bc09
commit b49e3f4201
24 changed files with 518 additions and 425 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
use flake

View File

@ -2,19 +2,36 @@ name: "Nix Build"
on:
pull_request:
push:
branches: [development, master]
jobs:
tests:
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
- .#checks.x86_64-linux.nixpkgs-22_05
steps:
- uses: actions/checkout@v2.4.0
- uses: cachix/install-nix-action@v14.1
- 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: |
sudo rm -rf /opt
- uses: cachix/cachix-action@v10
if [[ "${{matrix.os}}" == "ubuntu-latest" ]]
then
sudo rm -rf /opt
fi
- uses: cachix/cachix-action@v11
with:
name: autodocodec
extraPullNames: validity,safe-coloured-text,sydtest
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
- run: nix-build default.nix
- run: nix-build ci.nix
- run: nix build "${{matrix.attribute}}"

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
*.yaml.lock
result*
.pre-commit-config.yaml
dist-newstyle/

View File

@ -0,0 +1,43 @@
{ mkDerivation, aeson, autodocodec, autodocodec-openapi3
, autodocodec-schema, autodocodec-servant-multipart
, autodocodec-swagger2, autodocodec-yaml, base, bytestring
, containers, criterion, deepseq, genvalidity, genvalidity-aeson
, genvalidity-containers, genvalidity-criterion
, genvalidity-scientific, genvalidity-sydtest
, genvalidity-sydtest-aeson, genvalidity-text, genvalidity-time
, lib, openapi3, pretty-show, QuickCheck, safe-coloured-text
, scientific, servant-multipart, servant-multipart-api, swagger2
, sydtest, sydtest-aeson, sydtest-discover, text, time
, unordered-containers, yaml
}:
mkDerivation {
pname = "autodocodec-api-usage";
version = "0.0.0.0";
src = ./.;
libraryHaskellDepends = [
aeson autodocodec autodocodec-openapi3 autodocodec-schema
autodocodec-servant-multipart autodocodec-swagger2 autodocodec-yaml
base bytestring deepseq genvalidity genvalidity-aeson
genvalidity-scientific genvalidity-text openapi3 QuickCheck
scientific servant-multipart servant-multipart-api swagger2 text
unordered-containers yaml
];
testHaskellDepends = [
aeson autodocodec autodocodec-openapi3 autodocodec-schema
autodocodec-servant-multipart autodocodec-swagger2 autodocodec-yaml
base bytestring containers genvalidity genvalidity-aeson
genvalidity-containers genvalidity-scientific genvalidity-sydtest
genvalidity-sydtest-aeson genvalidity-text genvalidity-time
openapi3 pretty-show QuickCheck safe-coloured-text scientific
servant-multipart-api swagger2 sydtest sydtest-aeson text time yaml
];
testToolDepends = [ sydtest-discover ];
benchmarkHaskellDepends = [
aeson autodocodec base bytestring containers criterion deepseq
genvalidity-containers genvalidity-criterion genvalidity-sydtest
genvalidity-text genvalidity-time QuickCheck scientific text time
];
homepage = "https://github.com/NorfairKing/autodocodec#readme";
description = "Autodocodec api usage tests";
license = lib.licenses.mit;
}

View File

@ -0,0 +1,15 @@
{ mkDerivation, aeson, autodocodec, base, insert-ordered-containers
, lens, lib, mtl, openapi3, scientific, text, unordered-containers
}:
mkDerivation {
pname = "autodocodec-openapi3";
version = "0.2.1.1";
src = ./.;
libraryHaskellDepends = [
aeson autodocodec base insert-ordered-containers lens mtl openapi3
scientific text unordered-containers
];
homepage = "https://github.com/NorfairKing/autodocodec#readme";
description = "Autodocodec interpreters for openapi3";
license = lib.licenses.mit;
}

View File

@ -240,9 +240,9 @@ declareNamedSchemaVia c' Proxy = evalStateT (go c') mempty
-- If both schemas are enums with the same type then combine their values
(Just s1enums, Just s2enums)
| s1 ^. type_ == s2 ^. type_ ->
prototype
& enum_ ?~ (s1enums ++ s2enums)
& type_ .~ s1 ^. type_
prototype
& enum_ ?~ (s1enums ++ s2enums)
& type_ .~ s1 ^. type_
_ ->
case (s1 ^. orLens, s2 ^. orLens) of
(Just s1s, Just s2s) -> prototype & orLens ?~ (s1s ++ s2s)

View File

@ -0,0 +1,16 @@
{ mkDerivation, aeson, autodocodec, base, containers, lib, mtl
, text, unordered-containers, validity, validity-aeson
, validity-containers, validity-text
}:
mkDerivation {
pname = "autodocodec-schema";
version = "0.1.0.2";
src = ./.;
libraryHaskellDepends = [
aeson autodocodec base containers mtl text unordered-containers
validity validity-aeson validity-containers validity-text
];
homepage = "https://github.com/NorfairKing/autodocodec#readme";
description = "Autodocodec interpreters for JSON Schema";
license = lib.licenses.mit;
}

View File

@ -0,0 +1,16 @@
{ mkDerivation, aeson, autodocodec, base, bytestring, lib
, servant-multipart, servant-multipart-api, text
, unordered-containers, vector
}:
mkDerivation {
pname = "autodocodec-servant-multipart";
version = "0.0.0.0";
src = ./.;
libraryHaskellDepends = [
aeson autodocodec base bytestring servant-multipart
servant-multipart-api text unordered-containers vector
];
homepage = "https://github.com/NorfairKing/autodocodec#readme";
description = "Autodocodec interpreters for Servant Multipart";
license = lib.licenses.mit;
}

View File

@ -0,0 +1,15 @@
{ mkDerivation, aeson, autodocodec, base, insert-ordered-containers
, lib, scientific, swagger2, text, unordered-containers
}:
mkDerivation {
pname = "autodocodec-swagger2";
version = "0.0.1.1";
src = ./.;
libraryHaskellDepends = [
aeson autodocodec base insert-ordered-containers scientific
swagger2 text unordered-containers
];
homepage = "https://github.com/NorfairKing/autodocodec#readme";
description = "Autodocodec interpreters for swagger2";
license = lib.licenses.mit;
}

View File

@ -0,0 +1,17 @@
{ mkDerivation, autodocodec, autodocodec-schema, base, bytestring
, containers, lib, path, path-io, safe-coloured-text, scientific
, text, unordered-containers, vector, yaml
}:
mkDerivation {
pname = "autodocodec-yaml";
version = "0.2.0.2";
src = ./.;
libraryHaskellDepends = [
autodocodec autodocodec-schema base bytestring containers path
path-io safe-coloured-text scientific text unordered-containers
vector yaml
];
homepage = "https://github.com/NorfairKing/autodocodec#readme";
description = "Autodocodec interpreters for yaml";
license = lib.licenses.mit;
}

16
autodocodec/default.nix Normal file
View File

@ -0,0 +1,16 @@
{ mkDerivation, aeson, base, bytestring, containers, hashable, lib
, mtl, scientific, text, time, unordered-containers, validity
, validity-scientific, vector
}:
mkDerivation {
pname = "autodocodec";
version = "0.2.0.1";
src = ./.;
libraryHaskellDepends = [
aeson base bytestring containers hashable mtl scientific text time
unordered-containers validity validity-scientific vector
];
homepage = "https://github.com/NorfairKing/autodocodec#readme";
description = "Self-documenting encoder and decoder";
license = lib.licenses.mit;
}

View File

@ -90,8 +90,8 @@ parseJSONContextVia codec_ context_ =
Left err -> fail err
Right new -> pure new
EitherCodec u c1 c2 ->
let leftParser = (\v -> Left <$> go v c1)
rightParser = (\v -> Right <$> go v c2)
let leftParser v = Left <$> go v c1
rightParser v = Right <$> go v c2
in case u of
PossiblyJointUnion ->
case parseEither leftParser value of

2
cabal.project Normal file
View File

@ -0,0 +1,2 @@
packages: */*.cabal
test-show-details: direct

33
ci.nix
View File

@ -1,33 +0,0 @@
{ sources ? import ./nix/sources.nix
, nixpkgs ? sources.nixpkgs
, system ? builtins.currentSystem
, pkgs ? import ./nix/pkgs.nix { inherit sources nixpkgs system; }
}:
let
pre-commit = import ./nix/pre-commit.nix { inherit sources; };
versions = {
"nixos-22_05" = sources.nixpkgs-22_05;
};
mkReleaseForVersion = version: nixpkgs:
let
p = import ./nix/pkgs.nix {
inherit sources nixpkgs system;
};
in
p.autodocodecRelease.overrideAttrs (old: { name = "autodocodec-release-${version}"; });
in
{
release = (import ./nix/pkgs.nix { inherit sources; }).autodocodecRelease;
pre-commit-check = (import ./nix/pre-commit.nix { }).run;
hoogle = pkgs.buildEnv {
name = "autodocodec-hoogle";
paths = [ (pkgs.haskellPackages.ghcWithHoogle (ps: pkgs.lib.attrValues pkgs.autodocodecPackages)) ];
};
shell = pkgs.symlinkJoin {
name = "autodocodec-shell";
paths = (import ./shell.nix { inherit sources pkgs pre-commit; }).buildInputs;
};
} // builtins.mapAttrs mkReleaseForVersion versions

View File

@ -1,4 +0,0 @@
let
pkgs = import ./nix/pkgs.nix { };
in
pkgs.autodocodecRelease

205
flake.lock Normal file
View File

@ -0,0 +1,205 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1668681692,
"narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "009399224d5e398d03b22badca40a37ac85412a1",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1660459072,
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1669735802,
"narHash": "sha256-qtG/o/i5ZWZLmXw108N2aPiVsxOcidpHJYNkT45ry9Q=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "731cc710aeebecbf45a258e977e8b68350549522",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-22.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-22_05": {
"locked": {
"lastModified": 1669677308,
"narHash": "sha256-n788Cx+W6J1CtQofJD/KUY1c2WcJx6GqyJ+++1y9B3k=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "f214b8c9455e90b70bafd4ed9a58d448c243e8bb",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-22.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1668984258,
"narHash": "sha256-0gDMJ2T3qf58xgcSbYoXiRGUkPWmKyr5C3vcathWhKs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "cf63ade6f74bbc9d2a017290f1b2e33e8fbfa70a",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-22.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1668994630,
"narHash": "sha256-1lqx6HLyw6fMNX/hXrrETG1vMvZRGm2XVC9O/Jt0T6c=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "af50806f7c6ab40df3e6b239099e8f8385f6c78b",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"gitignore": "gitignore",
"nixpkgs": "nixpkgs_2",
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1669807480,
"narHash": "sha256-MwIcNG1xqkqQSNcQC5x6bFb78/H3r+hc+p7U+Kf3BxM=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "84dc0bdabbcabf6617797fc43342429bf5bf663f",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"nixpkgs-22_05": "nixpkgs-22_05",
"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": 1669809024,
"narHash": "sha256-xPN8iPljAiZw+9j5F/uPQ6wd8w9fuBosAhQo0YPEgi4=",
"owner": "NorfairKing",
"repo": "sydtest",
"rev": "3cf59bdadf91c685983abc82e296040836724169",
"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
}

88
flake.nix Normal file
View File

@ -0,0 +1,88 @@
{
description = "autodocodec";
nixConfig = {
extra-substituters = "https://autodocodec.cachix.org";
extra-trusted-public-keys = "autodocodec.cachix.org-1:UU3l42g+wSr6tzvawO/oDLo+5yC5BJiATnoV4/AViMs=";
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-22.11";
nixpkgs-22_05.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;
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
, nixpkgs-22_05
, pre-commit-hooks
, validity
, safe-coloured-text
, sydtest
}:
let
system = "x86_64-linux";
pkgsFor = nixpkgs: import nixpkgs {
inherit system;
overlays = [
self.overlays.${system}
(import (validity + "/nix/overlay.nix"))
(import (safe-coloured-text + "/nix/overlay.nix"))
(import (sydtest + "/nix/overlay.nix"))
];
};
pkgs = pkgsFor nixpkgs;
in
{
overlays.${system} = import ./nix/overlay.nix;
packages.${system}.default = pkgs.haskellPackages.autodocodecRelease;
checks.${system} =
let
backwardCompatibilityCheckFor = nixpkgs:
let pkgs' = pkgsFor nixpkgs;
in pkgs'.haskellPackages.autodocodecRelease;
allNixpkgs = {
inherit
nixpkgs-22_05;
};
backwardCompatibilityChecks = pkgs.lib.mapAttrs (_: nixpkgs: backwardCompatibilityCheckFor nixpkgs) allNixpkgs;
in
backwardCompatibilityChecks // {
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 = "autodocodec-shell";
packages = p: builtins.attrValues p.autodocodecPackages;
withHoogle = true;
doBenchmark = true;
buildInputs = (with pkgs; [
niv
zlib
cabal-install
]) ++ (with pre-commit-hooks.packages.${system};
[
hlint
hpack
nixpkgs-fmt
ormolu
cabal2nix
]);
shellHook = self.checks.${system}.pre-commit.shellHook;
};
};
}

View File

@ -1,56 +1,55 @@
final:
previous:
final: prev:
with final.haskell.lib;
{
autodocodecPackages =
let
autodocodecPkg = name:
buildFromSdist (
overrideCabal (final.haskellPackages.callCabal2nixWithOptions name (final.gitignoreSource (../. + "/${name}")) "--no-hpack" { })
(old: {
doBenchmark = true;
configureFlags = (old.configureFlags or [ ]) ++ [
# Optimisations
"--ghc-options=-O2"
# Extra warnings
"--ghc-options=-Wall"
"--ghc-options=-Wincomplete-uni-patterns"
"--ghc-options=-Wincomplete-record-updates"
"--ghc-options=-Wpartial-fields"
"--ghc-options=-Widentities"
"--ghc-options=-Wredundant-constraints"
"--ghc-options=-Wcpp-undef"
"--ghc-options=-Werror"
"--ghc-options=-Wno-deprecations"
];
# 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";
})
);
in
final.lib.genAttrs [
"autodocodec"
"autodocodec-api-usage"
"autodocodec-openapi3"
"autodocodec-schema"
"autodocodec-servant-multipart"
"autodocodec-swagger2"
"autodocodec-yaml"
]
autodocodecPkg;
autodocodecRelease =
final.symlinkJoin {
name = "autodocodec-release";
paths = final.lib.attrValues final.autodocodecPackages;
};
haskellPackages = prev.haskellPackages.override (old: {
overrides = final.lib.composeExtensions (old.overrides or (_: _: { }))
(
self: super:
let
autodocodecPkg = name:
buildFromSdist (overrideCabal (self.callPackage (../${name}/default.nix) { }) (old: {
doBenchmark = true;
configureFlags = (old.configureFlags or [ ]) ++ [
# Optimisations
"--ghc-options=-O2"
# Extra warnings
"--ghc-options=-Wall"
"--ghc-options=-Wincomplete-uni-patterns"
"--ghc-options=-Wincomplete-record-updates"
"--ghc-options=-Wpartial-fields"
"--ghc-options=-Widentities"
"--ghc-options=-Wredundant-constraints"
"--ghc-options=-Wcpp-undef"
"--ghc-options=-Werror"
"--ghc-options=-Wno-deprecations"
];
# 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";
}));
haskellPackages = previous.haskellPackages.override (
old: {
overrides = final.lib.composeExtensions (old.overrides or (_: _: { })) (
self: super: final.autodocodecPackages
autodocodecPackages =
final.lib.genAttrs [
"autodocodec"
"autodocodec-api-usage"
"autodocodec-openapi3"
"autodocodec-schema"
"autodocodec-servant-multipart"
"autodocodec-swagger2"
"autodocodec-yaml"
]
autodocodecPkg;
in
{
inherit autodocodecPackages;
autodocodecRelease =
final.symlinkJoin {
name = "autodocodec-release";
paths = final.lib.attrValues self.autodocodecPackages;
};
} // autodocodecPackages
);
}
);
});
}

View File

@ -1,14 +0,0 @@
{ sources ? import ./sources.nix
, nixpkgs ? sources.nixpkgs
, system ? builtins.currentSystem
}:
import nixpkgs {
overlays = [
(import (sources.validity + "/nix/overlay.nix"))
(import (sources.safe-coloured-text + "/nix/overlay.nix"))
(import (sources.sydtest + "/nix/overlay.nix"))
(final: previous: { inherit (import sources.gitignore { inherit (final) lib; }) gitignoreSource; })
(import ./overlay.nix)
];
config.allowUnfree = true;
}

View File

@ -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
];
}

View File

@ -1,98 +0,0 @@
{
"gitignore": {
"branch": "master",
"description": "Nix function for filtering local git sources",
"homepage": "",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "bff2832ec341cf30acb3a4d3e2e7f1f7b590116a",
"sha256": "0va0janxvmilm67nbl81gdbpppal4aprxzb25gp9pqvf76ahxsci",
"type": "tarball",
"url": "https://github.com/hercules-ci/gitignore.nix/archive/bff2832ec341cf30acb3a4d3e2e7f1f7b590116a.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": "cd90e773eae83ba7733d2377b6cdf84d45558780",
"sha256": "1b2wn1ncx9x4651vfcgyqrm93pd7ghnrgqjbkf6ckkpidah69m03",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/cd90e773eae83ba7733d2377b6cdf84d45558780.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs-22_05": {
"branch": "nixos-22.05",
"description": "Nix Packages collection",
"homepage": "",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "cd90e773eae83ba7733d2377b6cdf84d45558780",
"sha256": "1b2wn1ncx9x4651vfcgyqrm93pd7ghnrgqjbkf6ckkpidah69m03",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/cd90e773eae83ba7733d2377b6cdf84d45558780.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": "db3bd555d3a3ceab208bed48f983ccaa6a71a25e",
"sha256": "1jq33qaayi253xvpa1clh5ib83zh2dfgcxmp6d3ya894x9md3l6b",
"type": "tarball",
"url": "https://github.com/cachix/pre-commit-hooks.nix/archive/db3bd555d3a3ceab208bed48f983ccaa6a71a25e.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": "d3fb43703a4b927362b7b83d8f2313173ad091a5",
"sha256": "0vva5qlqzgmbj7vslxqvm2h91kq49c0gqbvsrdnszbbnmbgjh545",
"type": "tarball",
"url": "https://github.com/NorfairKing/safe-coloured-text/archive/d3fb43703a4b927362b7b83d8f2313173ad091a5.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": "d88be911a7e2a84f6c089e9269aaed8d10a74acd",
"sha256": "088zl9vp7579qj1gqh1j8kb0035zjjp41k1yiww58x57pym200g7",
"type": "tarball",
"url": "https://github.com/NorfairKing/validity/archive/d88be911a7e2a84f6c089e9269aaed8d10a74acd.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}

View File

@ -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); }

View File

@ -1,14 +0,0 @@
{ sources ? import ./nix/sources.nix
, nixpkgs ? sources.nixpkgs
, pkgs ? import ./nix/pkgs.nix { inherit nixpkgs sources; }
, pre-commit ? import ./nix/pre-commit.nix { inherit sources; }
}:
pkgs.haskell.lib.buildStackProject {
name = "autodocodec-shell";
buildInputs = with pkgs; [
(import sources.niv { }).niv
zlib
haskellPackages.doctest
] ++ pre-commit.tools;
shellHook = pre-commit.run.shellHook;
}

View File

@ -40,5 +40,8 @@ extra-deps:
ghc-options:
"$locals": -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates -Wpartial-fields -Widentities -Wredundant-constraints -Wcpp-undef
system-ghc: true
nix:
shell-file: shell.nix
enable: false
with-hpack: hpack