Compare commits

...

3 Commits

Author SHA1 Message Date
Gregor Kleen
b9d76def10 cleanup stack.nix 2021-06-27 13:41:22 +02:00
Gregor Kleen
fda3a000f9 Merge branch 'master' into uni2work 2021-06-27 13:08:21 +02:00
Gregor Kleen
1c95b01004 chore: bump serversession-backend-acid-state for acid-state 0.16.* 2020-03-13 13:30:48 +01:00
9 changed files with 129 additions and 12 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
use flake

44
flake.lock Normal file
View File

@ -0,0 +1,44 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1619345332,
"narHash": "sha256-qHnQkEp1uklKTpx3MvKtY6xzgcqXDsz5nLilbbuL+3A=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "2ebf2558e5bf978c7fb8ea927dfaed8fefab2e28",
"type": "github"
},
"original": {
"owner": "numtide",
"ref": "master",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1620323686,
"narHash": "sha256-+gfcE3YTGl+Osc8HzOUXSFO8/0PAK4J8ZxCXZ4hjXHI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "dfacb8329b2236688b9a1e705116203a213b283a",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "master",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

30
flake.nix Normal file
View File

@ -0,0 +1,30 @@
{
inputs = {
nixpkgs = {
type = "github";
owner = "NixOS";
repo = "nixpkgs";
ref = "master";
};
flake-utils = {
type = "github";
owner = "numtide";
repo = "flake-utils";
ref = "master";
};
};
outputs = { self, nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem
(system:
let pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
in {
devShell = pkgs.mkShell {
name = "uni2work-serversession";
nativeBuildInputs = with pkgs.haskellPackages; [ stack ];
};
}
);
}

8
nixpkgs.nix Normal file
View File

@ -0,0 +1,8 @@
import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in fetchTarball {
url = "https://api.github.com/repos/NixOS/nixpkgs/tarball/${lock.nodes.nixpkgs.locked.rev}";
sha256 = lock.nodes.nixpkgs.locked.narHash;
}
)

View File

@ -26,7 +26,7 @@ library
, acid-state >= 0.16
, containers
, mtl
, safecopy >= 0.8
, safecopy >= 0.8 && <0.11
, unordered-containers
, serversession == 1.0.*

View File

@ -112,6 +112,8 @@ instance SafeCopy SS.SessionMap where
instance Typeable sess => SafeCopy (SS.SessionId sess) where
putCopy = contain . safePut . SSI.unS
getCopy = contain $ SSI.S <$> safeGet
errorTypeName _ = "SessionId"
-- | We can't @deriveSafeCopy 0 'base ''SS.Session@ due to the
@ -132,6 +134,8 @@ instance (Typeable sess, SafeCopy (SS.Decomposed sess)) => SafeCopy (SS.Session
<*> safeGet
<*> get_t
<*> get_t
errorTypeName _ = "Session"
-- | We can't @deriveSafeCopy 0 'base ''ServerSessionAcidState@ due
@ -144,6 +148,8 @@ instance (Typeable sess, SafeCopy (SS.Decomposed sess)) => SafeCopy (ServerSessi
ServerSessionAcidState
<$> (HM.fromList <$> safeGet)
<*> (HM.fromList <$> safeGet)
errorTypeName _ = "ServerSessionAcidState"
----------------------------------------------------------------------
@ -280,10 +286,14 @@ instance Typeable sess => SafeCopy (GetSession sess) where
instance Typeable sess => SafeCopy (DeleteSession sess) where
putCopy (DeleteSession v) = contain $ safePut v
getCopy = contain $ DeleteSession <$> safeGet
errorTypeName _ = "DeleteSession"
instance Typeable sess => SafeCopy (DeleteAllSessionsOfAuthId sess) where
putCopy (DeleteAllSessionsOfAuthId v) = contain $ safePut v
getCopy = contain $ DeleteAllSessionsOfAuthId <$> safeGet
errorTypeName _ = "DeleteAllSessionsOfAuthId"
instance (Typeable sess, SafeCopy (SS.Decomposed sess)) => SafeCopy (InsertSession sess) where
putCopy (InsertSession v) = contain $ safePut v
@ -293,6 +303,8 @@ instance (Typeable sess, SafeCopy (SS.Decomposed sess)) => SafeCopy (ReplaceSess
putCopy (ReplaceSession v) = contain $ safePut v
getCopy = contain $ ReplaceSession <$> safeGet
errorTypeName _ = "ReplaceSession"
type AcidContext sess =
( SS.IsSessionData sess
, SafeCopy sess
@ -321,9 +333,10 @@ instance AcidContext sess => Method (ReplaceSession sess) where
type MethodState (ReplaceSession sess) = ServerSessionAcidState sess
instance AcidContext sess => IsAcidic (ServerSessionAcidState sess) where
acidEvents =
[ QueryEvent (\(GetSession sid) -> getSession sid) safeCopyMethodSerialiser
, UpdateEvent (\(DeleteSession sid) -> deleteSession sid) safeCopyMethodSerialiser
, UpdateEvent (\(DeleteAllSessionsOfAuthId authId) -> deleteAllSessionsOfAuthId authId) safeCopyMethodSerialiser
, UpdateEvent (\(InsertSession session) -> insertSession session) safeCopyMethodSerialiser
, UpdateEvent (\(ReplaceSession session) -> replaceSession session) safeCopyMethodSerialiser ]
acidEvents =
[ flip QueryEvent safeCopyMethodSerialiser $ \(GetSession sid) -> getSession sid
, flip UpdateEvent safeCopyMethodSerialiser $ \(DeleteSession sid) -> deleteSession sid
, flip UpdateEvent safeCopyMethodSerialiser $ \(DeleteAllSessionsOfAuthId authId) -> deleteAllSessionsOfAuthId authId
, flip UpdateEvent safeCopyMethodSerialiser $ \(InsertSession session) -> insertSession session
, flip UpdateEvent safeCopyMethodSerialiser $ \(ReplaceSession session) -> replaceSession session
]

16
stack.nix Normal file
View File

@ -0,0 +1,16 @@
{ ghc, nixpkgs ? import ./nixpkgs.nix }:
let
# haskellPackages = import ./stackage.nix { inherit nixpkgs; };
haskellPackages = pkgs.haskellPackages;
inherit (nixpkgs {}) pkgs;
in pkgs.haskell.lib.buildStackProject {
inherit ghc;
inherit (haskellPackages) stack;
name = "stackenv";
buildInputs = (with pkgs;
[ # postgresql zlib libsodium gmp llvm_9
]) ++ (with haskellPackages;
[ # yesod-bin happy alex
]);
}

View File

@ -29,4 +29,9 @@ extra-deps:
- map-syntax-0.3@sha256:ca8b449615fa57419c16a5e98844624a6ac758692b87b3cfae8c74c87c56f1b2,2420
- pwstore-fast-2.4.4@sha256:9b6a37510d8b9f37f409a8ab3babac9181afcaaa3fce8ba1c131a7ed3de30698,1351
- xmlhtml-0.2.5.2@sha256:3f0990f725551985d777e8edb5563fe99aee998f1fde6a7633f720f76df54701,46997
resolver: lts-15.8
resolver: lts-16.31
nix:
packages: []
pure: false
shell-file: ./stack.nix
add-gc-roots: true

View File

@ -48,7 +48,7 @@ packages:
hackage: xmlhtml-0.2.5.2@sha256:3f0990f725551985d777e8edb5563fe99aee998f1fde6a7633f720f76df54701,46997
snapshots:
- completed:
size: 492015
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/15/8.yaml
sha256: 926bc3d70249dd0ba05277ff00943c0addb35b627cb641752669e7cf771310d0
original: lts-15.8
size: 534126
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/31.yaml
sha256: 637fb77049b25560622a224845b7acfe81a09fdb6a96a3c75997a10b651667f6
original: lts-16.31