Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Add a nix flake setup #15

Merged
merged 6 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use_flake() {
watch_file flake.nix
watch_file flake.lock
eval "$(nix print-dev-env)"
}
use flake
24 changes: 24 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "Nix flakes CI"
tydeu marked this conversation as resolved.
Show resolved Hide resolved
on:
pull_request:
push:
branches:
- main
jobs:
tests:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, name the job Ubuntu as that is the machine it is running on (and building for). It is doing both a build and a check, so tests is a bit of a misnomer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please name it just Ubuntu, not Build and Check Ubuntu to make it consistent with the other CIs. Also, I don't think GItHub even allows job names that are arbitrary strings (or, at least, that would be my best guess as to why the job doesn't register).

runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: cachix/install-nix-action@v13
with:
install_url: https://nixos-nix-install-tests.cachix.org/serve/i6laym9jw3wg9mw6ncyrk6gjx4l34vvx/install
install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
extra_nix_config: |
experimental-features = nix-command flakes
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v10
with:
name: yatima
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix build
- run: nix flake check
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
result*
182 changes: 182 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-21.05";
lean = {
url = "github:leanprover/lean4";
inputs.nixpkgs.follows = "nixpkgs";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should remove this follows btw to avoid unnecessary binary cache misses

};
flake-utils = {
url = "github:numtide/flake-utils";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs =
{ self
, flake-utils
, nixpkgs
, lean
}:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
packageName = "Lake";
src = ./.;
leanPkgs = lean.packages.${system};
inherit (leanPkgs) leanc stage1;
inherit (pkgs.lib) concatStrings debug;
project = leanPkgs.buildLeanPackage {
name = packageName;
inherit src;
};
in
{
packages.${packageName} = project.lean-package;

defaultPackage = self.packages.${system}.${packageName};

apps.lake = flake-utils.lib.mkApp {
name = "lake";
drv = project.executable;
};

defaultApp = self.apps.${system}.lake;

# `nix develop`
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
lean-pkgs.lean
];
};
});
}