Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
vst committed Jul 18, 2022
2 parents 4fe6f4f + d8099bf commit ec5471c
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 91 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
result
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2022 Telostat Pte Ltd

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 changes: 24 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# deback

![GitHub release (latest by date)](https://img.shields.io/github/v/release/telostat/deback)
![GitHub contributors](https://img.shields.io/github/contributors/telostat/deback)
![GitHub](https://img.shields.io/github/license/telostat/deback)

> **Note:** This software is under development and of prototype quality at the
> moment. Expect significant breaking changes without notification until we
> reach the first minor version. Until then, we will keep bumping the patch
> version.
Backups are hard, but we need to do it right for business continuity
and sanity.

Expand Down Expand Up @@ -74,10 +83,10 @@ Development takes place in a Nix shell ([./shell.nix](./shell.nix)):
nix-shell
```

Static builds can be obtained using [./static.nix](./static.nix):
Static builds can be obtained via:

```sh
nix-build static.nix
nix-build --arg doStatic true
file result/bin/deback
```

Expand All @@ -87,8 +96,8 @@ In this case, all runtime dependencies ([rclone](https://rclone.org/),
[smartmontools](https://www.smartmontools.org/) etc.) must be installed on the
host and be on the `PATH` when running `deback`.

If you are on Nix, use [./default.nix](./default.nix) to install the application
(all its runtime dependencies will be automatically installed) via:
If you are on Nix, install the application (all its runtime dependencies will be
automatically installed) via:

```sh
nix-env -f default.nix -i
Expand All @@ -100,13 +109,18 @@ nix-env -f default.nix -i
nix-env -f https://github.com/telostat/deback/archive/main.tar.gz -i
```

[./default.nix](./default.nix), [./shell.nix](./shell.nix) and
[./static.nix](./static.nix) depend on [./deback.nix](./deback.nix).
## Releasing

If Haskell dependencies are updated or the application version has changed in
[./deback.cabal](./deback.cabal) file, you must update
[./deback.nix](./deback.nix) as well:
Here is the release process:

```sh
cabal2nix --no-haddock . > deback.nix
git checkout develop
git pull
git checkout main
git pull
git merge --no-ff develop
bash release.sh -n <NEXT-TAG>
git checkout develop
git rebase main
git push
```
24 changes: 9 additions & 15 deletions deback.cabal
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
cabal-version: 2.4
name: deback
version: 0.0.2

-- A short (one-line) description of the package.
-- synopsis:

-- A longer description of the package.
-- description:

-- A URL where users can report bugs.
-- bug-reports:

-- The license under which the package is released.
-- license:
synopsis: An opinionated backup and archive tool
description: Please see the README on GitHub at <https://github.com/telostat/deback#readme>
homepage: https://github.com/telostat/deback#readme
bug-reports: https://github.com/telostat/deback/issues
author: Vehbi Sinan Tunalioglu
maintainer: [email protected]
copyright: 2022 Teloscube Pte Ltd
license: MIT
license-file: LICENSE
category: System, Backup
build-type: Simple

-- A copyright notice.
-- copyright:
-- category:
extra-source-files:
CHANGELOG.md
README.md
Expand Down
17 changes: 0 additions & 17 deletions deback.nix

This file was deleted.

32 changes: 24 additions & 8 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ compiler ? "ghc922"
, doStatic ? false
, ...
}:

Expand All @@ -12,22 +13,37 @@ let
## Import rrclone:
rrclone = import sources.rrclone;


## Get the haskell set:
haskell = pkgs.haskell.packages.${compiler};

## Get deback:
deback = haskell.callPackage (import ./deback.nix) { };

## Get installable deback:
installableDeback = deback.overrideAttrs (oldAttrs: rec {
## Define a function that makes deback statically compiled:
makeDebackStatic = drv: pkgs.haskell.lib.compose.overrideCabal
(_: {
enableSharedExecutables = false;
enableSharedLibraries = false;
configureFlags = [
"--ghc-option=-optl=-static"
"--ghc-option=-optl=-pthread"
"--ghc-option=-optl=-L${pkgs.gmp6.override { withStatic = true; }}/lib"
"--ghc-option=-optl=-L${pkgs.zlib.static}/lib"
"--ghc-option=-optl=-L${pkgs.glibc.static}/lib"
"--extra-lib-dirs=${pkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; })}/lib"
];
})
drv;

## Define a function that makes deback installable in Nix environment with all its dependencies:
makeDebackInstallable = drv: drv.overrideAttrs (oldAttrs: rec {
nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [
pkgs.makeWrapper
];

postFixup = (oldAttrs.postFixup or "") + ''
wrapProgram $out/bin/deback --prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.rclone pkgs.smartmontools ]}
wrapProgram $out/bin/deback --prefix PATH : ${pkgs.lib.makeBinPath [ rrclone pkgs.rclone pkgs.smartmontools ]}
'';
});

## Get raw deback:
deback = haskell.callCabal2nixWithOptions "deback" ./. "--no-haddock" { };
in
installableDeback
if doStatic then makeDebackStatic deback else makeDebackInstallable deback
21 changes: 15 additions & 6 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,11 @@ fi
## Update version:
sed -i -E "s/^version:([ ]+).*/version:\\1${_VERSION_NEXT}/g" deback.cabal

## Regenerate deback.nix:
cabal2nix --no-haddock . > deback.nix

## Update CHANGELOG.md:
git-chglog -o CHANGELOG.md --next-tag "v${_VERSION_NEXT}"

## Add files:
git add deback.cabal deback.nix CHANGELOG.md
git add deback.cabal CHANGELOG.md

## Commit:
git commit -m "chore(release): v${_VERSION_NEXT}"
Expand All @@ -50,8 +47,20 @@ git tag -a -m "Release v${_VERSION_NEXT}" "v${_VERSION_NEXT}"
git push --follow-tags origin main

## Build application:
nix-build static.nix
nix-build --arg doStatic true

## Get compiled output file path:
_infile="result/bin/deback"

## Get compressed, renamed output file path:
_outfile="deback-v${_VERSION_NEXT}-$(uname -s)-$(uname -m)-static"

## Compress file:
upx -o "${_outfile}" "${_infile}"

## Release
gh release create "v${_VERSION_NEXT}" --generate-notes
gh release upload "v${_VERSION_NEXT}" result/bin/deback
gh release upload "v${_VERSION_NEXT}" "${_outfile}"

## Remove outfile:
rm "${_outfile}"
4 changes: 3 additions & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let
haskell = pkgs.haskell.packages.${compiler};

## Get deback:
deback = haskell.callPackage (import ./deback.nix) { };
deback = haskell.callCabal2nixWithOptions "deback" ./. "--no-haddock" { };

## Get deback Haskell dependencies:
debackDeps = pkgs.haskell.lib.compose.getHaskellBuildInputs deback;
Expand All @@ -31,9 +31,11 @@ pkgs.mkShell {
pkgs.lolcat

## Release stuff:
pkgs.busybox
pkgs.gh
pkgs.git
pkgs.git-chglog
pkgs.upx

## Haskell stuff:
ghc
Expand Down
34 changes: 0 additions & 34 deletions static.nix

This file was deleted.

0 comments on commit ec5471c

Please sign in to comment.