Skip to content

Commit

Permalink
feat: introduce nix support
Browse files Browse the repository at this point in the history
  • Loading branch information
blackheaven committed Dec 9, 2023
1 parent 9064284 commit cab6e63
Show file tree
Hide file tree
Showing 5 changed files with 346 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
use flake
dotenv_if_exists .env
21 changes: 21 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: nix build

on:
- push
- pull_request
jobs:
check_nix:
name: Check nix build
runs-on: ubuntu-latest
steps:
- name: git checkout
uses: actions/checkout@v3
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
with:
extra-conf: system-features = nixos-test benchmark big-parallel kvm
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Check Nix flake inputs
uses: DeterminateSystems/flake-checker-action@v4
- name: Build lib
run: nix build -L
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ tags
tags.mtime
.DS_Store
TAGS

.env
.direnv
result
265 changes: 265 additions & 0 deletions flake.lock

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

54 changes: 54 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
description = "one-time-password";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
libsodium-bindings.url = "github:haskell-cryptography/libsodium-bindings";
};

outputs = { self, nixpkgs, flake-utils, ... }@inputs:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs{inherit system;};

haskellPackages = pkgs.haskellPackages.override {
overrides = hself: hsuper: {
libsodium-bindings = inputs.libsodium-bindings.packages.${system}.libsodium-bindings;
sel = inputs.libsodium-bindings.packages.${system}.sel;
};
};
in
rec
{
packages.one-time-password =
haskellPackages.callCabal2nix "one-time-password" ./.
{
base32 = haskellPackages.base32_0_4;
sel = inputs.libsodium-bindings.packages.${system}.sel;
};

defaultPackage = packages.one-time-password;

devShell =
let
scripts = pkgs.symlinkJoin {
name = "scripts";
paths = pkgs.lib.mapAttrsToList pkgs.writeShellScriptBin {
};
};
in
pkgs.mkShell {
buildInputs = with haskellPackages; [
pkgs.libsodium
haskell-language-server
ghcid
cabal-install
scripts
];
inputsFrom = [
self.defaultPackage.${system}.env
];
};
});
}

0 comments on commit cab6e63

Please sign in to comment.