Skip to content

Commit

Permalink
Merge pull request #6 from obsidiansystems/aa/ci
Browse files Browse the repository at this point in the history
GHC 884 compatibility and CI
  • Loading branch information
ali-abrar authored Nov 24, 2020
2 parents 5de2b6c + fc2b6db commit bab7329
Show file tree
Hide file tree
Showing 24 changed files with 353 additions and 169 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: github-action

on: [push, pull_request]

jobs:
build:
strategy:
matrix:
ghc: ['8.6.5', '8.8.4']
os: ['ubuntu-latest', 'macos-latest']
runs-on: ${{ matrix.os }}

name: GHC ${{ matrix.ghc }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-haskell@v1
with:
ghc-version: ${{ matrix.ghc }}
- name: Cache
uses: actions/cache@v1
env:
cache-name: cache-cabal
with:
path: ~/.cabal
key: ${{ runner.os }}-${{ matrix.ghc }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }}
restore-keys: |
${{ runner.os }}-${{ matrix.ghc }}-build-${{ env.cache-name }}-
${{ runner.os }}-${{ matrix.ghc }}-build-
${{ runner.os }}-${{ matrix.ghc }}-
${{ runner.os }}
- name: Install dependencies
run: |
cabal update
cabal build --only-dependencies --enable-tests --enable-benchmarks
- name: Build
run: cabal build --enable-tests --enable-benchmarks all
- name: Run tests
run: cabal test all
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Revision history for nix-thunk

## 0.2.0.2
* Add support for GHC 8.8.4.

## 0.2.0.1
* Fix parsing of --rev arguments

Expand Down
57 changes: 57 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Contribution Guide

Contributions and issue reports are encouraged and appreciated!

- [Opening Issues](#opening-issues)
- [Submitting Changes](#submitting-changes)
- [Guidelines for Commit Messages](#guidelines-for-commit-messages)
- [Code Quality](#code-quality)
- [Documentation](#documentation)

## Opening Issues

Before opening an issue, please check whether your issue has already been reported. Assuming it has not:

* Describe the issue you're encountering or the suggestion you're making
* Include any relevant steps to reproduce or code samples you can. It's always easier for us to debug if we have something that demonstrates the error.
* Let us know what version of this project you were using. If you're using a github checkout, provide the git hash.
* Describe how you're building this project (i.e., via nix, reflex-platform, cabal install, stack, obelisk, etc.). If you're using reflex-platform or obelisk, provide the git hash of your checkout.

## Submitting Changes

### Guidelines for Commit Messages

#### Summary Line
The summary line of your commit message should summarize the changes being made. Commit messages should be written in the imperative mood and should describe what happens when the commit is applied.

One way to think about it is that your commit message should be able to complete the sentence:
"When applied, this commit will..."

#### Body
For breaking changes, new features, refactors, or other major changes, the body of the commit message should describe the motivation behind the change in greater detail and may include references to the issue tracker. The body shouldn't repeat code/comments from the diff.

### Code Quality

#### Warnings

Your pull request should add no new warnings to the project. It should also generally not disable any warnings.

#### Build and Test

Make sure the project builds and that the tests pass! This will generally also be checked by CI before merge, but trying it yourself first means you'll catch problems earlier and your contribution can be merged that much sooner!

### Documentation

#### In the code
We're always striving to improve documentation. Please include [haddock](https://haskell-haddock.readthedocs.io/en/latest/index.html) documentation for any added code, and update the documentation for any code you modify.

#### In the [Changelog](ChangeLog.md)
Add an entry to the changelog when your PR:
* Adds a feature
* Deprecates something
* Includes a breaking change
* Makes any other change that will impact users

#### In the [Readme](README.md)
The readme is the first place a lot of people look for information about the repository. Update any parts of the readme that are affected by your PR.

35 changes: 31 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
# nix-thunk
nix-thunk
=========
[![Haskell](https://img.shields.io/badge/language-Haskell-orange.svg)](https://haskell.org) [![Hackage](https://img.shields.io/hackage/v/nix-thunk.svg)](https://hackage.haskell.org/package/nix-thunk) [![Hackage CI](https://matrix.hackage.haskell.org/api/v2/packages/nix-thunk/badge)](https://matrix.hackage.haskell.org/#/package/nix-thunk) [![Github CI](https://github.com/obsidiansystems/nix-thunk/workflows/github-action/badge.svg)](https://github.com/obsidiansystems/nix-thunk/actions) [![BSD3 License](https://img.shields.io/badge/license-BSD3-blue.svg)](https://github.com/obsidiansystems/nix-thunk/blob/master/LICENSE)

nix-thunk is a lightweight Nix dependency manager, focused on making it easy to contribute improvements back to libraries you depend on.

nix-thunk does this by creating and managing "thunks" - directories that stand in for full git repositories. Like git submodules, they pin a specific commit of the target repository, but unlike git submodules, you don't have to clone them to use them. nix-thunk makes them "transparent" to Nix scripts, so any script that calls `import path/to/some/thunk` will work the same on the thunk as it does on the original repository.

* [Installation](#installation)
* [Command Usage](#command-usage)
* [Create a dependency](#create-a-dependency)
* [Work on a dependency](#work-on-a-dependency)
* [Update a dependency](#update-a-dependency)
* [Nix Usage](#nix-usage)
* [Contributing](#contributing)
* [License](#license)

## Installation

```bash
nix-env -f https://github.com/obsidiansystems/nix-thunk/archive/master.tar.gz -iA command
```

## Usage
## Command Usage

### Create a dependency

Expand All @@ -26,7 +37,7 @@ nix-thunk pack some-dep

### Work on a dependency

If you discover a bug fix or improvement that your dependency needs, you can use `nix-thunk unpack path/to/your/dependency` to turn the thunk back into a full checkout of the repository. Your Nix scripts should continue working, and you can modify the dependency's source code, push it to a branch or a fork, send a pull request, and then use `nix-thunk pack path/to/your/dependency` to pack it back up into a thunk. When the depenency accepts your pull request, you can easily update the thunk.
If you discover a bug fix or improvement that your dependency needs, you can use `nix-thunk unpack path/to/your/dependency` to turn the thunk back into a full checkout of the repository. Your Nix scripts should continue working, and you can modify the dependency's source code, push it to a branch or a fork, send a pull request, and then use `nix-thunk pack path/to/your/dependency` to pack it back up into a thunk. When the dependency accepts your pull request, you can easily update the thunk.

```bash
nix-thunk unpack some-dep
Expand All @@ -42,8 +53,24 @@ For routine updates, you can run `nix-thunk update path/to/your/dependency` to p
nix-thunk update some-dep
```

## Nix Usage

The [`default.nix`](default.nix) file in this repository also defines the nix function, `thunkSource`. This can be used in your nix files to access the contents of thunks. In the following example, a thunk is used in place of the source location argument to `callCabal2nix`. `thunkSource` works whether the thunk is packed or unpacked, making it convenient to run nix commands with modified thunks.

```nix
haskellPackages = pkgs.haskell.packages.ghc865.override {
overrides = self: super: {
which = self.callCabal2nix "which" (thunkSource ./dep/which) {};
};
};
```

## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. See the [contribution guide](CONTRIBUTING.md) for more details.

## License
[BSD3](./LICENSE)

***

![Obsidian Systems](https://obsidian.systems/static/images/ObsidianSystemsLogo.svg)
9 changes: 6 additions & 3 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
{ pkgs ? import ./dep/nixpkgs {} }:
{ pkgs ? (import ./dep/ci).nixos2003
, ghc ? "ghc865"
}:

with pkgs.haskell.lib;

let
inherit (pkgs) lib;

in rec {
haskellPackages = pkgs.haskellPackages.override {
haskellPackages = pkgs.haskell.packages."${ghc}".override {
overrides = self: super: {
which = self.callCabal2nix "which" (thunkSource ./dep/which) {};
cli-extras = self.callCabal2nix "cli-extras" (thunkSource ./dep/cli-extras) {};
cli-nix = self.callCabal2nix "cli-nix" (thunkSource ./dep/cli-nix) {};
cli-git = self.callCabal2nix "cli-git" (thunkSource ./dep/cli-git) {};
github = self.callCabal2nix "github" (thunkSource ./dep/github) {};
nix-thunk = self.callCabal2nix "nix-thunk" (gitignoreSource ./.) {};
};
};
Expand Down Expand Up @@ -74,4 +77,4 @@ in rec {
filterGit = builtins.trace "Warning: `filterGit` is deprecated; switch to using `gitignoreSource`, which provides better filtering" (builtins.filterSource (path: type: !(builtins.any (x: x == baseNameOf path) [".git" "tags" "TAGS" "dist"])));

hackGet = builtins.trace "Warning: hackGet is deprecated; it has been renamed to thunkSource" thunkSource;
}
}
17 changes: 17 additions & 0 deletions dep/ci/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{ nixos2003 = import (builtins.fetchTarball {
name = "nixos-20.03_2020-11-18";
url = "https://github.com/nixos/nixpkgs/archive/f05c380a51daee53ac2edb0bac2fd5f1774e977a.tar.gz";
sha256 = "1xkgv4kvh2nii1kbxi0brjnb15scpzk8rkp7mzycgqh1lzfg23im";
}) {};
nixos1809 = import (builtins.fetchTarball {
name = "nixos-18.09_2020-11-18";
url = "https://github.com/nixos/nixpkgs/archive/a7e559a5504572008567383c3dc8e142fa7a8633.tar.gz";
sha256 = "16j95q58kkc69lfgpjkj76gw5sx8rcxwi3civm0mlfaxxyw9gzp6";
}) {};
unstable = import (builtins.fetchTarball {
name = "nixpkgs-unstable_2020-11-18";
url = "https://github.com/nixos/nixpkgs/archive/4f3475b113c93d204992838aecafa89b1b3ccfde.tar.gz";
sha256 = "158iik656ds6i6pc672w54cnph4d44d0a218dkq6npzrbhd3vvbg";
}) {};

}
8 changes: 0 additions & 8 deletions dep/cli-extras/git.json

This file was deleted.

8 changes: 8 additions & 0 deletions dep/cli-extras/github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"owner": "obsidiansystems",
"repo": "cli-extras",
"branch": "release/0.1.0.1",
"private": false,
"rev": "64afac6a7bbb0a99e70ce6ce58bbdc26a0c11cb8",
"sha256": "05c84jfl20q6xnzwvy722zqx4zj1858q91dk2236gidvyawsybgz"
}
17 changes: 6 additions & 11 deletions dep/cli-extras/thunk.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
# DO NOT HAND-EDIT THIS FILE
let fetch = {url, rev, branch ? null, sha256 ? null, fetchSubmodules ? false, private ? false, ...}:
let realUrl = let firstChar = builtins.substring 0 1 url; in
if firstChar == "/" then /. + url
else if firstChar == "." then ./. + url
else url;
in if !fetchSubmodules && private then builtins.fetchGit {
url = realUrl; inherit rev;
${if branch == null then null else "ref"} = branch;
} else (import <nixpkgs> {}).fetchgit {
url = realUrl; inherit rev sha256;
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./git.json);
json = builtins.fromJSON (builtins.readFile ./github.json);
in fetch json
8 changes: 0 additions & 8 deletions dep/cli-git/git.json

This file was deleted.

8 changes: 8 additions & 0 deletions dep/cli-git/github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"owner": "obsidiansystems",
"repo": "cli-git",
"branch": "release/0.1.0.1",
"private": false,
"rev": "7872bd16115abaf099eb98985f214bb9e7982a41",
"sha256": "0f5aygzz35m498a5cqgnb10ylkz7cdni6d9hg4mdmdy30kmw910g"
}
17 changes: 6 additions & 11 deletions dep/cli-git/thunk.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
# DO NOT HAND-EDIT THIS FILE
let fetch = {url, rev, branch ? null, sha256 ? null, fetchSubmodules ? false, private ? false, ...}:
let realUrl = let firstChar = builtins.substring 0 1 url; in
if firstChar == "/" then /. + url
else if firstChar == "." then ./. + url
else url;
in if !fetchSubmodules && private then builtins.fetchGit {
url = realUrl; inherit rev;
${if branch == null then null else "ref"} = branch;
} else (import <nixpkgs> {}).fetchgit {
url = realUrl; inherit rev sha256;
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./git.json);
json = builtins.fromJSON (builtins.readFile ./github.json);
in fetch json
8 changes: 0 additions & 8 deletions dep/cli-nix/git.json

This file was deleted.

8 changes: 8 additions & 0 deletions dep/cli-nix/github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"owner": "obsidiansystems",
"repo": "cli-nix",
"branch": "release/0.1.0.1",
"private": false,
"rev": "54838e02b5ed96ef88520011d56fac57a1d20aa3",
"sha256": "094l10mkzzln7pqwxcww14qi3wgn4l2piam2q4hffyp7z40hznv3"
}
17 changes: 6 additions & 11 deletions dep/cli-nix/thunk.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
# DO NOT HAND-EDIT THIS FILE
let fetch = {url, rev, branch ? null, sha256 ? null, fetchSubmodules ? false, private ? false, ...}:
let realUrl = let firstChar = builtins.substring 0 1 url; in
if firstChar == "/" then /. + url
else if firstChar == "." then ./. + url
else url;
in if !fetchSubmodules && private then builtins.fetchGit {
url = realUrl; inherit rev;
${if branch == null then null else "ref"} = branch;
} else (import <nixpkgs> {}).fetchgit {
url = realUrl; inherit rev sha256;
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./git.json);
json = builtins.fromJSON (builtins.readFile ./github.json);
in fetch json
File renamed without changes.
8 changes: 8 additions & 0 deletions dep/github/github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"owner": "phadej",
"repo": "github",
"branch": "master",
"private": false,
"rev": "5b9df6f52d175df6b19eb3daa31f5a73237ea5dd",
"sha256": "14j4zzdj1ysy0r42qpmv22mrkxici3jdiycr1rp1xbkf841pdhwb"
}
File renamed without changes.
8 changes: 0 additions & 8 deletions dep/nixpkgs/github.json

This file was deleted.

6 changes: 3 additions & 3 deletions dep/which/github.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"owner": "obsidiansystems",
"repo": "which",
"branch": "develop",
"branch": "release/0.2.0.0",
"private": false,
"rev": "a7a86bfa1d05d81de4a12a89315bd383763b98ea",
"sha256": "1635wh4psqbhybbvgjr9gy6f051sb27zlgfamrqw14cdrqdvk5m8"
"rev": "29ec2b4675872afffeee9d4a6f37f4057d52ec7d",
"sha256": "1pm155p4ncbd61lsaicg6s6d6zv5h98c9dl5x675bnlhymk8zq9b"
}
Loading

0 comments on commit bab7329

Please sign in to comment.