Skip to content

Flakeify the nix setup #283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Building.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Building from source

4. Build `tttool`:

nix-build -A linux-exe
nix build .#linux-exe

5. Copy the resulting program to the current directory:

Expand All @@ -39,12 +39,15 @@ Making a release

1. Ensure that the version number is up-to-date in:
`Changelog.md`, `tttool.cabal`, `book/conf.py`
2. Run `nix-build --arg checkMaterialization` and update hashes in `defaul.nix`
until it no longer complains.
2. Run

nix flake check

and update the hashes in `default.nix` until it no longer complains.
3. Push to CI so that the OSX binaries are built and uploaded to the Cachix
cache.
4. Run

nix-build -A release-zip
nix build

5. Upload `result/tttool-n.m.zip`.
2 changes: 1 addition & 1 deletion cabal.project.freeze
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Run nix-shell -A check-cabal-freeze default.nix to update this file
-- Run nix develop .#update-cabal-freeze to update this file
constraints: any.HPDF ==1.4.10,
any.JuicyPixels ==3.3.7,
any.OneTuple ==0.3.1,
Expand Down
22 changes: 13 additions & 9 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
{ checkMaterialization ? false }:
{ checkMaterialization, haskellNix }:
let
sources = import nix/sources.nix;

# Fetch the latest haskell.nix and import its default.nix
haskellNix = import sources.haskellNix {};
# haskellNix = import haskellNixSrc {};

# Peek at https://github.com/input-output-hk/haskell.nix/blob/master/ci.nix
# for supported nixpkgs and ghc versions
# or https://github.com/input-output-hk/haskell.nix/blob/master/docs/reference/supported-ghc-versions.md
nixpkgsSrc = haskellNix.sources.nixpkgs-unstable;
nixpkgsSrc = haskellNix.internal.compat;
nixpkgsArgs = haskellNix.nixpkgsArgs;

pkgs = import nixpkgsSrc nixpkgsArgs;
pkgs-osx = import nixpkgsSrc (nixpkgsArgs // { system = "x86_64-darwin"; });
pkgs = (haskellNix.internal.compat { system = "x86_64-linux"; }).pkgs-unstable;
pkgs-osx = (haskellNix.internal.compat { system = "x86_64-darwin"; }).pkgs-unstable;

# a nicer filterSource
sourceByRegex =
Expand Down Expand Up @@ -233,7 +231,7 @@ in rec {

# The following two derivations keep the cabal.config.freeze file
# up to date.
cabal-cmd = "nix-shell -A check-cabal-freeze default.nix";
cabal-cmd = "nix develop .#update-cabal-freeze";

cabal-freeze = pkgs.stdenv.mkDerivation {
name = "cabal-freeze";
Expand All @@ -258,7 +256,13 @@ in rec {
expected = cabal-freeze + /cabal.project.freeze;
actual = ./cabal.project.freeze;
shellHook = ''
dest=${toString ./cabal.project.freeze}
if ! diff -q $PWD/cabal.project.freeze ${toString ./cabal.project.freeze}
then
echo "$PWD/cabal.project.freeze and ${toString ./cabal.project.freeze} differ."
echo "Is this run from the right directory?"
exit 1
fi
dest=./cabal.project.freeze
rm -f $dest
cp -v $expected $dest
chmod u-w $dest
Expand Down
Loading