Skip to content

Commit

Permalink
Use the flake lockfile instead of niv.
Browse files Browse the repository at this point in the history
This will ensure versions are kept in sync.
  • Loading branch information
shlevy committed Jul 29, 2021
1 parent 2229981 commit 699e70d
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 376 deletions.
2 changes: 0 additions & 2 deletions .gitattributes
@@ -1,5 +1,3 @@
# sources.nix is generated by niv
nix/sources.nix linguist-generated=true
# haskell.nix materialized files
nix/pkgs/haskell/materialized*/**/*.nix linguist-generated=true
# linguist gets confused by PIR files, and thinks they make up a lot of our source!
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/flakes-update.yml
@@ -0,0 +1,40 @@
name: Automated Nix flakes-managed dependency updates
on:
schedule:
# * is a special character in YAML so you have to quote this string
# run this every day at 4:00am
- cron: '0 4 * * *'
jobs:
nix-flakes-updater:
name: 'Create PRs for Nix flakes-managed dependencies'
runs-on: ubuntu-latest
# Borrowed from https://github.com/Mic92/dotfiles/blob/9c2fc2cc98021dd8d42bbb714278785a9a6757c2/.github/workflows/upgrade-flakes.yml
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v13
with:
install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.4pre20210415_76980a1/install
extra_nix_config: |
experimental-features = nix-command flakes
- name: Make changes to pull request
run: nix flake update
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v3
with:
commit-message: Update flakes
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
signoff: false
branch: flake-updates
delete-branch: true
title: 'Upgrade flakes'
body: |
Update report
- Updated with *today's* date
- Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
30 changes: 0 additions & 30 deletions .github/workflows/niv-update.yml

This file was deleted.

10 changes: 5 additions & 5 deletions CONTRIBUTING.adoc
Expand Up @@ -139,10 +139,10 @@ For the moment you have to do this by hand, using the following command to get t

We pin versions of some git repositories that are used by Nix, for example `nixpkgs`.

These are specified in link:./nix/sources.json[`sources.json`].
This file is managed by https://github.com/nmattia/niv[`niv`].
You can edit it by hand, but we wouldn't recommend it.
See the `niv` website for usage instructions, but the simplest action is `niv update <dependency>`, which will update it to the latest version on the tracked branch.
We use Nix flakes to manage these dependencies, even though we do not
actually use flakes for normal Nix builds. To manage the dependencies,
see https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html#flake-inputs[the Nix flake inputs documentation]
and https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake-update.html[the Nix flake update command].

[[update-index-state]]
=== How to update the Hackage index state
Expand All @@ -157,7 +157,7 @@ Note that `cabal` itself keeps track of what index states it knows about, so you
The Nix code which builds our packages also cares about the index state.
The set of index states which it knows about is controlled by `hackage.nix`, which is a Nix representation of Hackage.
This therefore needs to be newer than the index state.
You can update it xref:update-nix-pins[with `niv`].
You can update it xref:update-nix-pins[with the Nix flake commands].

You will need to update the xref:update-generated[package set] after this to reflect the new build plan that Cabal will pick.

Expand Down
7 changes: 3 additions & 4 deletions default.nix
Expand Up @@ -5,16 +5,15 @@
# developing Plutus.
#
########################################################################

{ system ? builtins.currentSystem
, crossSystem ? null
, config ? { allowUnfreePredicate = (import ./nix/lib/unfree.nix).unfreePredicate; }
, sourcesOverride ? { }
, sources ? import ./nix/sources.nix { inherit system; } // sourcesOverride
, haskellNix ? import (sources."haskell.nix" or sources.haskell-nix) {
, haskellNix ? import sources.haskell-nix {
sourcesOverride = {
hackage = sources."hackage.nix" or sources.hackage-nix;
stackage = sources."stackage.nix" or sources.stackage-nix;
hackage = sources.hackage-nix;
stackage = sources.stackage-nix;
};
}
, packages ? import ./nix { inherit system sources crossSystem config sourcesOverride haskellNix checkMaterialization enableHaskellProfiling; }
Expand Down
7 changes: 4 additions & 3 deletions nix/pkgs/default.nix
Expand Up @@ -8,7 +8,7 @@
let
inherit (pkgs) stdenv;

gitignore-nix = pkgs.callPackage (sources."gitignore.nix" or sources.gitignore-nix) { };
gitignore-nix = pkgs.callPackage sources.gitignore-nix { };

# { index-state, compiler-nix-name, project, projectPackages, packages, extraPackages }
haskell = pkgs.callPackage ./haskell {
Expand Down Expand Up @@ -110,7 +110,7 @@ let
# By default pre-commit-hooks.nix uses its own pinned version of nixpkgs. In order to
# to get it to use our version we have to (somewhat awkwardly) use `nix/default.nix`
# to which both `nixpkgs` and `system` can be passed.
nix-pre-commit-hooks = (pkgs.callPackage ((sources."pre-commit-hooks.nix" or sources.pre-commit-hooks-nix) + "/nix/default.nix") {
nix-pre-commit-hooks = (pkgs.callPackage (sources.pre-commit-hooks-nix + "/nix/default.nix") {
inherit system;
inherit (sources) nixpkgs;
});
Expand Down Expand Up @@ -152,7 +152,8 @@ let
# If it succeeds:
#
# * Merge your new `inherit (easyPS) spago2nix` with the one above.
# * Run `niv delete spago2nix`.
# * Remove spago2nix from flake.nix
# * Run `nix --experimental-features 'nix-command flakes' flake lock`
#
spago2nix = pkgs.callPackage (sources.spago2nix) { };

Expand Down
166 changes: 0 additions & 166 deletions nix/sources.json

This file was deleted.

0 comments on commit 699e70d

Please sign in to comment.