Skip to content

Commit 2337f60

Browse files
committed
move nonce into prelude
1 parent dec4775 commit 2337f60

File tree

3 files changed

+87
-81
lines changed

3 files changed

+87
-81
lines changed

nix/configuration.nix

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ in {
493493
# "soundcloud"
494494
"spotify"
495495
"steam"
496-
"telegram"
496+
# "telegram"
497497
"temu"
498498
"tidal"
499499
"tiktok"
@@ -746,40 +746,45 @@ in {
746746
#
747747
programs.firejail.enable = true;
748748
programs.firejail.wrappedBinaries =
749-
fj.mkFirejailSimple "xonotic"
750-
// fj.mkFirejailSimple "chromium"
749+
fj.mkFirejailSimple "chromium"
751750
// mkOpenArena "rat"
752-
// mkOpenArena "omega"
753-
// mkOpenArena "excessiveplus"
754751
// fj.mkFirejailCustom {
755-
pkg = "doom-free2";
752+
pkg = "doom-infinite";
756753
dir = "doom";
757754
exe = ''
758-
${unst.gzdoom}/bin/gzdoom \
755+
${pkgs.gzdoom}/bin/gzdoom \
759756
-iwad ./freedoom-0.13.0/freedoom2.wad \
760-
-file ./Project_Brutality-PB_Staging.zip \
757+
-file ./DOOM_Infinite_DEMO_0978_6.pk3 \
758+
-file ./flashlight_plus_plus_v9_1.pk3 \
759+
-file ./DoomBSMS.wad \
760+
-file ./mod.pk3 \
761+
-file ./nashgore.pk3 \
761762
-file ./SimpleSlots.1.1.pk7
762763
'';
763764
}
764765
// fj.mkFirejailCustom {
765-
pkg = "doom-free1";
766+
pkg = "doom-64";
766767
dir = "doom";
767768
exe = ''
768769
${unst.gzdoom}/bin/gzdoom \
769-
-iwad ./freedoom-0.13.0/freedoom1.wad \
770-
-file ./Project_Brutality-PB_Staging.zip \
770+
-iwad ./freedoom-0.13.0/freedoom2.wad \
771+
-file ./BD64-VoH_game.pk3 \
772+
-file ./BD64-VoH_maps.pk3 \
773+
-file ./relite_0.7.3b.pk3 \
771774
-file ./SimpleSlots.1.1.pk7
772775
'';
773776
}
774777
// fj.mkFirejailCustom {
775-
pkg = "doom-dsc";
778+
pkg = "doom-dragon";
776779
dir = "doom";
777780
exe = ''
778-
${vkdoom}/bin/vkdoom \
781+
${unst.gzdoom}/bin/gzdoom \
779782
-iwad ./freedoom-0.13.0/freedoom2.wad \
780-
-file ./dsc/DSC-1.0.2.pk3 \
781-
-file ./dsc/DSCmaterialPack.pk3 \
782783
-file ./Project_Brutality-PB_Staging.zip \
784+
-file ./dragon/KAI-main.pk3 \
785+
-file ./dragon/dragon-sector-remake-v1.0.pk3 \
786+
-file ./flashlight_plus_plus_v9_1.pk3 \
787+
-file ./relite_0.7.3b.pk3 \
783788
-file ./SimpleSlots.1.1.pk7
784789
'';
785790
}

pub/bfx/src/Bfx/Data/Web.hs

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ module Bfx.Data.Web
55
ApiKey (..),
66
RequestMethod (..),
77
BaseUrl (..),
8-
Nonce,
9-
unNonce,
10-
NonceGen,
11-
newNonceGen,
128
withNonce,
139
parseJsonBs,
1410
utcTimeToMicros,
@@ -73,68 +69,6 @@ newtype BaseUrl = BaseUrl
7369
IsString
7470
)
7571

76-
newtype Nonce = Nonce
77-
{ unNonce :: Natural
78-
}
79-
deriving newtype
80-
( Eq,
81-
Ord,
82-
Show
83-
)
84-
deriving stock
85-
( Data,
86-
Generic
87-
)
88-
89-
mkNonce :: (MonadIO m) => m Nonce
90-
mkNonce =
91-
liftIO
92-
$ Nonce
93-
. utcTimeToMicros
94-
<$> getCurrentTime
95-
96-
newtype NonceGen
97-
= NonceGen (MVar Nonce)
98-
deriving stock
99-
( Eq
100-
)
101-
102-
instance Prelude.Show NonceGen where
103-
show =
104-
const "NonceGen"
105-
106-
newNonceGen ::
107-
( MonadIO m
108-
) =>
109-
m NonceGen
110-
newNonceGen = do
111-
nonce <- mkNonce
112-
var <- liftIO $ newMVar nonce
113-
pure $ NonceGen var
114-
115-
withNonce ::
116-
( MonadUnliftIO m
117-
) =>
118-
NonceGen ->
119-
(Nonce -> m a) ->
120-
m a
121-
withNonce (NonceGen var) this = do
122-
nextNonce <- mkNonce
123-
bracket
124-
(takeMVar var)
125-
(putMVar var . max nextNonce)
126-
(const $ this nextNonce)
127-
128-
utcTimeToMicros :: UTCTime -> Natural
129-
utcTimeToMicros x =
130-
Prelude.fromInteger
131-
$ diffTimeToPicoseconds
132-
( fromRational
133-
. toRational
134-
$ diffUTCTime x epoch
135-
)
136-
`div` 1000000
137-
13872
parseJsonBs ::
13973
forall a.
14074
( Typeable a,

pub/functora/src/prelude/Functora/Prelude.hs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ module Functora.Prelude
119119
dropAround,
120120
dropWhileEnd,
121121
AscOrDesc (..),
122+
Nonce,
123+
unNonce,
124+
NonceGen,
125+
newNonceGen,
126+
withNonce,
122127

123128
-- * FixedPoint
124129
-- $fixedPoint
@@ -1162,6 +1167,68 @@ data AscOrDesc
11621167
Bounded
11631168
)
11641169

1170+
newtype Nonce = Nonce
1171+
{ unNonce :: Natural
1172+
}
1173+
deriving newtype
1174+
( Eq,
1175+
Ord,
1176+
Show
1177+
)
1178+
deriving stock
1179+
( Data,
1180+
Generic
1181+
)
1182+
1183+
mkNonce :: (MonadIO m) => m Nonce
1184+
mkNonce =
1185+
liftIO
1186+
$ Nonce
1187+
. utcTimeToMicros
1188+
<$> getCurrentTime
1189+
1190+
newtype NonceGen
1191+
= NonceGen (MVar Nonce)
1192+
deriving stock
1193+
( Eq
1194+
)
1195+
1196+
instance Prelude.Show NonceGen where
1197+
show =
1198+
const "NonceGen"
1199+
1200+
newNonceGen ::
1201+
( MonadIO m
1202+
) =>
1203+
m NonceGen
1204+
newNonceGen = do
1205+
nonce <- mkNonce
1206+
var <- liftIO $ newMVar nonce
1207+
pure $ NonceGen var
1208+
1209+
withNonce ::
1210+
( MonadUnliftIO m
1211+
) =>
1212+
NonceGen ->
1213+
(Nonce -> m a) ->
1214+
m a
1215+
withNonce (NonceGen var) this = do
1216+
nextNonce <- mkNonce
1217+
bracket
1218+
(takeMVar var)
1219+
(putMVar var . max nextNonce)
1220+
(const $ this nextNonce)
1221+
1222+
utcTimeToMicros :: UTCTime -> Natural
1223+
utcTimeToMicros x =
1224+
Prelude.fromInteger
1225+
$ diffTimeToPicoseconds
1226+
( fromRational
1227+
. toRational
1228+
$ diffUTCTime x epoch
1229+
)
1230+
`div` 1000000
1231+
11651232
-- $fixedPoint
11661233
-- Fixed point numbers.
11671234

0 commit comments

Comments
 (0)