From b7092398db35c98bcf6d903d07c47f83058734d5 Mon Sep 17 00:00:00 2001 From: Gautier DI FOLCO Date: Sat, 13 Apr 2024 22:59:34 +0200 Subject: [PATCH 1/2] Revert "Remove nix build and CI" This reverts commit e542f0e938fba08bee7042cf92b6e5263e84f933. --- .github/workflows/nix.yml | 21 +++ flake.lock | 265 ++++++++++++++++++++++++++++++++++++++ flake.nix | 47 +++++++ 3 files changed, 333 insertions(+) create mode 100644 .github/workflows/nix.yml create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml new file mode 100644 index 0000000..9c94b0d --- /dev/null +++ b/.github/workflows/nix.yml @@ -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 diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..4ef3877 --- /dev/null +++ b/flake.lock @@ -0,0 +1,265 @@ +{ + "nodes": { + "base16": { + "flake": false, + "locked": { + "narHash": "sha256-pLnipLnF7YuQvCwgw7Lp7sbwhab63sdEpubeSpaoEmY=", + "type": "tarball", + "url": "https://hackage.haskell.org/package/base16-1.0/base16-1.0.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://hackage.haskell.org/package/base16-1.0/base16-1.0.tar.gz" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "libsodium-bindings", + "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" + } + }, + "gitignore_2": { + "inputs": { + "nixpkgs": [ + "libsodium-bindings", + "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" + } + }, + "libsodium-bindings": { + "inputs": { + "base16": "base16", + "flake-compat": "flake-compat", + "flake-utils": "flake-utils_2", + "gitignore": "gitignore", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" + }, + "locked": { + "lastModified": 1702158167, + "narHash": "sha256-14Q3KGjpHng85u4ORYTxaAf+/z1/63M5j0a6EH91xpE=", + "owner": "haskell-cryptography", + "repo": "libsodium-bindings", + "rev": "0963da7b3669ada9cce2c24cdfd52ba666b35d8d", + "type": "github" + }, + "original": { + "owner": "haskell-cryptography", + "repo": "libsodium-bindings", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1701693815, + "narHash": "sha256-7BkrXykVWfkn6+c1EhFA3ko4MLi3gVG0p9G96PNnKTM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "09ec6a0881e1a36c29d67497693a67a16f4da573", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1678872516, + "narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1701718080, + "narHash": "sha256-6ovz0pG76dE0P170pmmZex1wWcQoeiomUZGggfH9XPs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2c7f3c0fb7c08a0814627611d9d7d45ab6d75335", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat_2", + "flake-utils": [ + "libsodium-bindings", + "flake-utils" + ], + "gitignore": "gitignore_2", + "nixpkgs": [ + "libsodium-bindings", + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1685361114, + "narHash": "sha256-4RjrlSb+OO+e1nzTExKW58o3WRwVGpXwj97iCta8aj4=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "ca2fdbf3edda2a38140184da6381d49f8206eaf4", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "libsodium-bindings": "libsodium-bindings", + "nixpkgs": "nixpkgs_2" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..07f59c5 --- /dev/null +++ b/flake.nix @@ -0,0 +1,47 @@ +{ + 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;}; + in + rec + { + packages.one-time-password = + pkgs.haskellPackages.callCabal2nix "one-time-password" ./. + { + base32 = pkgs.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 pkgs.haskellPackages; [ + pkgs.libsodium + haskell-language-server + ghcid + cabal-install + scripts + ]; + inputsFrom = [ + self.defaultPackage.${system}.env + ]; + }; + }); +} From 085a69457245f6ddf54680f1daa7f99ddd1c873a Mon Sep 17 00:00:00 2001 From: Gautier DI FOLCO Date: Sun, 14 Apr 2024 01:06:15 +0200 Subject: [PATCH 2/2] refactoring: reintroduce nix --- flake.lock | 101 +++++++++++++++++++++------------------- flake.nix | 7 ++- one-time-password.cabal | 2 +- 3 files changed, 60 insertions(+), 50 deletions(-) diff --git a/flake.lock b/flake.lock index 4ef3877..6e40189 100644 --- a/flake.lock +++ b/flake.lock @@ -1,25 +1,29 @@ { "nodes": { - "base16": { + "chronos": { "flake": false, "locked": { - "narHash": "sha256-pLnipLnF7YuQvCwgw7Lp7sbwhab63sdEpubeSpaoEmY=", - "type": "tarball", - "url": "https://hackage.haskell.org/package/base16-1.0/base16-1.0.tar.gz" + "lastModified": 1710161479, + "narHash": "sha256-VyCGCIA6t2VR0v0AUYDKykjQO62Rj1jDzqNql0HPmwA=", + "owner": "byteverse", + "repo": "chronos", + "rev": "5a1dee666cc5a805461db4ce36bd6c3112b80f14", + "type": "github" }, "original": { - "type": "tarball", - "url": "https://hackage.haskell.org/package/base16-1.0/base16-1.0.tar.gz" + "owner": "byteverse", + "repo": "chronos", + "type": "github" } }, "flake-compat": { "flake": false, "locked": { - "lastModified": 1673956053, - "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", "owner": "edolstra", "repo": "flake-compat", - "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", "type": "github" }, "original": { @@ -31,11 +35,11 @@ "flake-compat_2": { "flake": false, "locked": { - "lastModified": 1673956053, - "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", "owner": "edolstra", "repo": "flake-compat", - "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", "type": "github" }, "original": { @@ -49,11 +53,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1694529238, - "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -67,11 +71,11 @@ "systems": "systems_2" }, "locked": { - "lastModified": 1685518550, - "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -88,11 +92,11 @@ ] }, "locked": { - "lastModified": 1660459072, - "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", "owner": "hercules-ci", "repo": "gitignore.nix", - "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", "type": "github" }, "original": { @@ -110,11 +114,11 @@ ] }, "locked": { - "lastModified": 1660459072, - "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", "owner": "hercules-ci", "repo": "gitignore.nix", - "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", "type": "github" }, "original": { @@ -125,7 +129,6 @@ }, "libsodium-bindings": { "inputs": { - "base16": "base16", "flake-compat": "flake-compat", "flake-utils": "flake-utils_2", "gitignore": "gitignore", @@ -133,12 +136,13 @@ "pre-commit-hooks": "pre-commit-hooks" }, "locked": { - "lastModified": 1702158167, - "narHash": "sha256-14Q3KGjpHng85u4ORYTxaAf+/z1/63M5j0a6EH91xpE=", - "owner": "haskell-cryptography", - "repo": "libsodium-bindings", - "rev": "0963da7b3669ada9cce2c24cdfd52ba666b35d8d", - "type": "github" + "lastModified": 1713048530, + "narHash": "sha256-twPl1o4kZg3+/cl+WQA+wUInccMLsSgMEw4Zj2OS+zQ=", + "ref": "refs/heads/nix/reintroduce", + "rev": "a7ca63a51dc1821a85e183b0858cb0ed7810cf44", + "revCount": 171, + "type": "git", + "url": "file:///home/black/ancien/haskell/libsodium-bindings" }, "original": { "owner": "haskell-cryptography", @@ -148,48 +152,48 @@ }, "nixpkgs": { "locked": { - "lastModified": 1701693815, - "narHash": "sha256-7BkrXykVWfkn6+c1EhFA3ko4MLi3gVG0p9G96PNnKTM=", + "lastModified": 1713010524, + "narHash": "sha256-ZhZIQcTtN1gn3XQTCj2Upap0wEtjTVSVC9whphx3xYg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "09ec6a0881e1a36c29d67497693a67a16f4da573", + "rev": "70850f72a07194b8071b6f839846f4d636d0b43f", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixpkgs-unstable", + "ref": "nixos-23.11-small", "repo": "nixpkgs", "type": "github" } }, "nixpkgs-stable": { "locked": { - "lastModified": 1678872516, - "narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=", + "lastModified": 1710695816, + "narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8", + "rev": "614b4613980a522ba49f0d194531beddbb7220d3", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-22.11", + "ref": "nixos-23.11", "repo": "nixpkgs", "type": "github" } }, "nixpkgs_2": { "locked": { - "lastModified": 1701718080, - "narHash": "sha256-6ovz0pG76dE0P170pmmZex1wWcQoeiomUZGggfH9XPs=", - "owner": "NixOS", + "lastModified": 1713010524, + "narHash": "sha256-ZhZIQcTtN1gn3XQTCj2Upap0wEtjTVSVC9whphx3xYg=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "2c7f3c0fb7c08a0814627611d9d7d45ab6d75335", + "rev": "70850f72a07194b8071b6f839846f4d636d0b43f", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "nixos-unstable", + "owner": "nixos", + "ref": "nixos-23.11-small", "repo": "nixpkgs", "type": "github" } @@ -209,11 +213,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1685361114, - "narHash": "sha256-4RjrlSb+OO+e1nzTExKW58o3WRwVGpXwj97iCta8aj4=", + "lastModified": 1712897695, + "narHash": "sha256-nMirxrGteNAl9sWiOhoN5tIHyjBbVi5e2tgZUgZlK3Y=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "ca2fdbf3edda2a38140184da6381d49f8206eaf4", + "rev": "40e6053ecb65fcbf12863338a6dcefb3f55f1bf8", "type": "github" }, "original": { @@ -224,6 +228,7 @@ }, "root": { "inputs": { + "chronos": "chronos", "flake-utils": "flake-utils", "libsodium-bindings": "libsodium-bindings", "nixpkgs": "nixpkgs_2" diff --git a/flake.nix b/flake.nix index 07f59c5..0649dda 100644 --- a/flake.nix +++ b/flake.nix @@ -2,9 +2,13 @@ description = "one-time-password"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11-small"; flake-utils.url = "github:numtide/flake-utils"; libsodium-bindings.url = "github:haskell-cryptography/libsodium-bindings"; + chronos = { + url = "github:byteverse/chronos"; + flake = false; + }; }; outputs = { self, nixpkgs, flake-utils, ... }@inputs: @@ -18,6 +22,7 @@ pkgs.haskellPackages.callCabal2nix "one-time-password" ./. { base32 = pkgs.haskellPackages.base32_0_4; + chronos = pkgs.haskellPackages.callCabal2nix "chronos" inputs.chronos {}; sel = inputs.libsodium-bindings.packages.${system}.sel; }; diff --git a/one-time-password.cabal b/one-time-password.cabal index 9474984..4788c6e 100644 --- a/one-time-password.cabal +++ b/one-time-password.cabal @@ -55,7 +55,7 @@ library , cryptohash-sha1 ^>=0.11 , network-uri ^>=2.6 , sel ^>=0.0 - , text ^>=2.1 + , text >=2.0 && <2.2 , text-display ^>=0.0 ghc-options: -Wall