-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72f3817
commit a59cb31
Showing
4 changed files
with
323 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
use flake -Lv --fallback | ||
use flake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: "libsodium hs nix check" | ||
on: | ||
pull_request: | ||
push: | ||
branches: ["main"] | ||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
continue-on-error: true | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: cachix/install-nix-action@v25 | ||
with: | ||
github_access_token: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: cachix/cachix-action@v14 | ||
with: | ||
name: libsodium-hs | ||
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' | ||
- run: nix flake check -Lv --allow-import-from-derivation --fallback |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
{ | ||
inputs = { | ||
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11-small"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
flake-compat = { | ||
url = "github:edolstra/flake-compat"; | ||
flake = false; | ||
}; | ||
pre-commit-hooks = { | ||
url = "github:cachix/pre-commit-hooks.nix"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
inputs.flake-utils.follows = "flake-utils"; | ||
}; | ||
gitignore = { | ||
url = "github:hercules-ci/gitignore.nix"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
}; | ||
|
||
nixConfig = { | ||
extra-substituters = [ | ||
"https://libsodium-hs.cachix.org" | ||
]; | ||
extra-trusted-public-keys = [ | ||
"libsodium-hs.cachix.org-1:u/v4XdWrbl+G/fDUoEwB1yvMdlxdKM4al2odCNsrqkg=" | ||
]; | ||
allow-import-from-derivation = true; | ||
}; | ||
|
||
outputs = inputs@{ nixpkgs, ... }: | ||
let | ||
# this is to allow running `nix flake check` by using `--impure` | ||
systems = | ||
if builtins.hasAttr "currentSystem" builtins | ||
then [ builtins.currentSystem ] | ||
else nixpkgs.lib.systems.flakeExposed; | ||
in | ||
inputs.flake-utils.lib.eachSystem systems (system: | ||
let | ||
inherit (inputs.gitignore.lib) gitignoreSource; | ||
|
||
pkgs = import nixpkgs { | ||
inherit system; | ||
config.allowBroken = true; | ||
}; | ||
|
||
pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run { | ||
src = ./.; | ||
hooks = { | ||
# nix checks | ||
nixpkgs-fmt.enable = true; | ||
deadnix.enable = true; | ||
statix.enable = true; | ||
|
||
# Haskell checks | ||
fourmolu.enable = true; | ||
cabal-fmt.enable = true; | ||
hlint.enable = true; | ||
}; | ||
}; | ||
|
||
hsPkgs = pkgs.haskellPackages.override (_old: { | ||
overrides = with pkgs.haskell.lib.compose; hself: hsuper: | ||
let | ||
commonOverrides = overrideCabal (_drv: { | ||
doInstallIntermediates = true; | ||
enableSeparateIntermediatesOutput = true; | ||
pkg-configDepends = [ | ||
pkgs.libsodium | ||
]; | ||
}); | ||
in | ||
{ | ||
libsodium-bindings = commonOverrides (hself.callCabal2nix "libsodium-bindings" (gitignoreSource ./libsodium-bindings) { }); | ||
sel = | ||
commonOverrides (hself.callCabal2nix "sel" (gitignoreSource ./sel) { | ||
base16 = hsuper.base16_1_0; | ||
hedgehog = hsuper.hedgehog_1_4; | ||
tasty = hsuper.tasty_1_5; | ||
}); | ||
# text-display = markUnbroken hsuper.text-display; | ||
}; | ||
}); | ||
|
||
hsShell = hsPkgs.shellFor { | ||
shellHook = '' | ||
${pre-commit-check.shellHook} | ||
set -x | ||
export LD_LIBRARY_PATH="${pkgs.libsodium}/lib" | ||
set +x | ||
''; | ||
|
||
packages = ps: with ps; [ | ||
libsodium-bindings | ||
sel | ||
]; | ||
|
||
buildInputs = with hsPkgs; [ | ||
pkgs.pkg-config | ||
pkgs.libsodium.dev | ||
cabal-install | ||
haskell-language-server | ||
hlint | ||
cabal-fmt | ||
fourmolu | ||
]; | ||
}; | ||
|
||
in | ||
{ | ||
checks = { | ||
inherit (hsPkgs) libsodium-bindings sel; | ||
shell = hsShell; | ||
formatting = pre-commit-check; | ||
}; | ||
|
||
packages = { | ||
inherit (hsPkgs) libsodium-bindings sel; | ||
}; | ||
|
||
devShells.default = hsShell; | ||
} | ||
); | ||
} |