Skip to content

Commit

Permalink
Prepare 0.1.0.1 release
Browse files Browse the repository at this point in the history
Reformatted.
Added workflow dependencies script.
Removed unused deps.
Using new .github workflows.
Updated package metadata.
  • Loading branch information
brianjosephmckeon authored Feb 13, 2024
1 parent ffd1b88 commit 1375809
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 44 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@byteverse/l3c
4 changes: 4 additions & 0 deletions .github/workflow_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -e
sudo apt-get update
sudo apt-get install libsystemd-dev
11 changes: 11 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: build
on:
pull_request:
branches:
- "*"

jobs:
call-workflow:
uses: byteverse/.github/.github/workflows/build-matrix.yaml@main
with:
cabal-file: systemd-api.cabal
10 changes: 10 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: release
on:
push:
tags:
- "*"

jobs:
call-workflow:
uses: byteverse/.github/.github/workflows/release.yaml@main
secrets: inherit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.vscode/
dist
dist-*
cabal-dev
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Revision history for systemd-api

## 0.1.0.1 -- 2024-02-01

* Update package metadata.
* Remove unused dependencies.
51 changes: 51 additions & 0 deletions fourmolu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Number of spaces per indentation step
indentation: 2

# Max line length for automatic line breaking
column-limit: 200

# Styling of arrows in type signatures (choices: trailing, leading, or leading-args)
function-arrows: trailing

# How to place commas in multi-line lists, records, etc. (choices: leading or trailing)
comma-style: leading

# Styling of import/export lists (choices: leading, trailing, or diff-friendly)
import-export-style: leading

# Whether to full-indent or half-indent 'where' bindings past the preceding body
indent-wheres: false

# Whether to leave a space before an opening record brace
record-brace-space: true

# Number of spaces between top-level declarations
newlines-between-decls: 1

# How to print Haddock comments (choices: single-line, multi-line, or multi-line-compact)
haddock-style: multi-line

# How to print module docstring
haddock-style-module: null

# Styling of let blocks (choices: auto, inline, newline, or mixed)
let-style: auto

# How to align the 'in' keyword with respect to the 'let' keyword (choices: left-align, right-align, or no-space)
in-style: right-align

# Whether to put parentheses around a single constraint (choices: auto, always, or never)
single-constraint-parens: always

# Output Unicode syntax (choices: detect, always, or never)
unicode: never

# Give the programmer more choice on where to insert blank lines
respectful: true

# Fixity information for operators
fixities: []

# Module reexports Fourmolu should know about
reexports: []

43 changes: 25 additions & 18 deletions src/Linux/Systemd.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,41 @@ module Linux.Systemd
, isSocket
) where

import Foreign.C.Types (CInt(..))
import System.Posix.Types (Fd(..))
import Foreign.C.Error (Errno,getErrno)
import Posix.Socket (Type(..),Family(..))
import Foreign.C.Error (Errno, getErrno)
import Foreign.C.Types (CInt (..))
import Posix.Socket (Family (..), Type (..))
import System.Posix.Types (Fd (..))

foreign import ccall unsafe "systemd/sd-daemon.h sd_listen_fds"
c_listenFds :: CInt -> IO CInt

foreign import ccall unsafe "systemd/sd-daemon.h sd_is_socket"
c_isSocket :: Fd -> Family -> Type -> CInt -> IO CInt

-- | Check for file descriptors passed by the system manager. Returns
-- the number of received file descriptors. If no file descriptors
-- have been received, zero is returned.
{- | Check for file descriptors passed by the system manager. Returns
the number of received file descriptors. If no file descriptors
have been received, zero is returned.
-}
listenFds ::
CInt -- ^ unset environment (non-zero unsets @LISTEN_FDS@, @LISTEN_PID@, and @LISTEN_FDNAMES@)
-> IO (Either Errno CInt)
-- | unset environment (non-zero unsets @LISTEN_FDS@, @LISTEN_PID@, and @LISTEN_FDNAMES@)
CInt ->
IO (Either Errno CInt)
listenFds a = c_listenFds a >>= errorsFromInt

isSocket ::
Fd -- ^ File descriptor
-> Family -- ^ Socket family
-> Type -- ^ Socket type
-> CInt -- ^ Positive: require listen mode. Zero: require non-listening mode.
-> IO (Either Errno CInt)
isSocket ::
-- | File descriptor
Fd ->
-- | Socket family
Family ->
-- | Socket type
Type ->
-- | Positive: require listen mode. Zero: require non-listening mode.
CInt ->
IO (Either Errno CInt)
isSocket a b c d = c_isSocket a b c d >>= errorsFromInt

errorsFromInt :: CInt -> IO (Either Errno CInt)
errorsFromInt r = if r >= 0
then pure (Right r)
else fmap Left getErrno
errorsFromInt r =
if r >= 0
then pure (Right r)
else fmap Left getErrno
59 changes: 33 additions & 26 deletions systemd-api.cabal
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
cabal-version: 2.2
name: systemd-api
version: 0.1.0.0
synopsis: systemd bindings
description: Bindings to various systemd functions
homepage: https://github.com/byteverse/systemd-api
license: BSD-3-Clause
license-file: LICENSE
author: Andrew Martin
maintainer: [email protected]
copyright: 2023 Andrew Martin
category: System
build-type: Simple
cabal-version: 2.2
name: systemd-api
version: 0.1.0.1
synopsis: systemd bindings
description: Bindings to various systemd functions
homepage: https://github.com/byteverse/systemd-api
bug-reports: https://github.com/byteverse/systemd-api/issues
license: BSD-3-Clause
license-file: LICENSE
author: Andrew Martin
maintainer: [email protected]
copyright: 2023 Andrew Martin
category: System
build-type: Simple
extra-doc-files: CHANGELOG.md
tested-with: GHC ==9.4.8 || ==9.6.3 || ==9.8.1

common build-settings
default-language: Haskell2010
ghc-options: -Wall -Wunused-packages

library
exposed-modules:
Linux.Systemd
import: build-settings
exposed-modules: Linux.Systemd
build-depends:
, base >=4.16.3 && <5
, byte-order >= 0.1.2 && <0.2
, byteslice >= 0.2.10 && <0.3
, primitive >= 0.7 && <0.10
, text-short >=0.1.5
, posix-api >=0.5
hs-source-dirs: src
default-language: Haskell2010
ghc-options: -Wall -O2
extra-libraries: systemd
build-tool-depends: hsc2hs:hsc2hs >= 0.68.5
, base >=4.16.3 && <5
, posix-api >=0.5 && <1

hs-source-dirs: src
ghc-options: -O2
extra-libraries: systemd
build-tool-depends: hsc2hs:hsc2hs >=0.68.5

source-repository head
type: git
location: git://github.com/byteverse/systemd-api.git

0 comments on commit 1375809

Please sign in to comment.